1import{j as n,B as f,T as c,r as h,b2 as ue,R as ze,d as fe,_ as gt,g as Ve,f as pr,bf as fr,bg as mr,i as hr}from"./MarketingSiteLoadingFallback-DF4Bevx8.js";import{u as O,h as o,a as gr,B as Ke,d7 as _r,T as xr,aD as Ge,b6 as br,ah as yr,dG as vr,dH as Sr,dI as wr}from"./renderJungleWebApp-Bj6DEPtG.js";import{G as An,F as v,a as Tn,L as Se,r as jr}from"./landingHandoffUploadClaim-ZWzmhSYt.js";import{trackError as Ct}from"./track-error-fzCnz4fY.js";import{f as En}from"./formatTimeSince-D2c9cw_Y.js";import{g as me,i as Ne,a as zt,f as Cr,n as kr,b as Ht,c as Ar,d as In}from"./investigationDisplayHelpers-j1XbcXQ9.js";import{a as Tr,s as Er,b as Ln,c as Ir,d as Lr,e as Rn,u as zn,g as Rr,h as zr}from"./SupportInvestigationsApiClient-CaUDv1GA.js";import{S as ee,b as Nr,a as Nt,A as Mr,r as Fr,c as Wr,s as Mt,d as $r,e as Or,f as Dr,W as Ur,g as Pr}from"./SupportUserServiceLinks-CjDbnxFe.js";import{T as Nn}from"./textarea-CI-iJEcp.js";import{V as Mn}from"./SupportConversationMessageAttachmentsRenderer-CESgDjAB.js";import{I as Bt}from"./icon-button-BEFLF1_f.js";import{b as Hr}from"./stripe-price-details-Q-KLtuJy.js";import"./frontend-release-DHVEZwfg.js";import"./hub-CmyV34zS.js";import"./index-rQLcFmgX.js";import"./legacy-referrer-id-B23nat6c.js";import"./main-CR0pPclt.js";import"./document-upload-sentry-CwY_2GoS.js";import"./jungle_river-fkLKo0Re.js";import"./sentry-init-DYpmux4V.js";import"./client-environment-BMTHOZAb.js";import"./supportApiHttpClient-DlFpP-Dk.js";import"./SupportConversationsApiClient-smS6dF1H.js";import"./MarkdownWithMath-BLgSLgpk.js";import"./index-CjTPgQvc.js";import"./IconCheckmarkWithCircle-B11Llvq1.js";import"./IconEmail-DaUyTF1y.js";import"./IconSearch-zNjWrF9U.js";import"./IconFileSearch-ypgfWWQh.js";import"./badge-Dq2M1c8-.js";import"./popover-trigger-CnLjGxc8.js";import"./popover-body-BMquvHv7.js";import"./popover-header-r9teBnEw.js";import"./avatar-BzxJV4zF.js";import"./chevron-right-7iYPKuZ3.js";import"./close-CKCy2mmL.js";import"./modal-close-button-DePB9zB8.js";import"./visually-hidden.style-BUiBK_kv.js";const Br=e=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:n.jsx("path",{d:"M11.06 10.28L8 7.22003L4.94 10.28L4 9.33336L8 5.33336L12 9.33336L11.06 10.28Z",fill:"#6A6B6A"})});function qr({summary:e}){const{t:r}=O();if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e,i=r("admin.support.generation.unknown","Unknown"),s=d=>typeof d=="string"&&d?d:i,a=d=>typeof d=="number"&&Number.isFinite(d)&&d>=0?`${Math.floor(Math.round(d/1e3)/60)}m ${Math.round(d/1e3)%60}s`:i,l=[[r("admin.support.generation.first_question_saved","First question saved"),a(t.time_to_first_question_ms)],[r("admin.support.generation.completed","Generation completed"),a(t.total_duration_ms)],[r("admin.support.generation.template_architecture","Template / architecture"),[s(t.template),s(t.pipeline),t.workflow_version].filter(Boolean).join(" / ")],...typeof t.postprocessing_recorded_after_ms=="number"?[[r("admin.support.generation.cleanup_recorded","Cleanup recorded"),a(t.postprocessing_recorded_after_ms)]]:[],[r("admin.support.generation.saved_questions","Current saved questions"),typeof t.current_cards_count=="number"?String(t.current_cards_count):i]];return n.jsxs(f,{borderWidth:"1px",borderColor:o.surface.border,borderRadius:"12px",p:4,mb:4,children:[n.jsx(c,{fontWeight:"700",fontSize:"14px",color:o.text.body,children:r("admin.support.generation.title","Generation context")}),n.jsx(c,{mt:1,mb:3,fontSize:"13px",color:o.text.label,overflowWrap:"anywhere",children:s(t.title)}),n.jsx(f,{as:"dl",m:0,children:l.map(([d,u])=>n.jsxs(An,{templateColumns:{base:"1fr",sm:"180px 1fr"},gap:1,py:1,children:[n.jsx(c,{as:"dt",fontSize:"13px",color:o.text.label,children:d}),n.jsx(c,{as:"dd",m:0,fontSize:"13px",fontWeight:"600",color:o.text.body,children:u})]},d))}),n.jsx(c,{mt:3,fontSize:"12px",color:o.text.label,children:r("admin.support.generation.timing_note","Measured from generation acceptance to saved questions. Upload time and the time questions appeared on the customer's screen are separate.")})]})}function X(e){const r=typeof e=="string"?e.trim():"";if(!r)return"";const t=r.replace(/[_-]+/g," ").replace(/\s+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const Vr={queued:"Starting automatically",running:"Investigating now",completed:"Finished",failed:"Could not finish",waiting_on_user:"Waiting on the customer"},Kr={auto_fixed:"Fixed automatically",queued_for_human:"Needs a human",needs_user_info:"Waiting on the customer",unconfirmed:"Cause not confirmed",ux_not_bug:"Not a bug, they needed help",ai_quality_review:"AI quality, a human decides",fix_in_progress:"Fix in progress"},Gr={needs_investigation:"Something looks broken",user_requested_human:"They asked for a human",refund_beyond_policy:"Refund outside policy",billing_ambiguous:"Billing needs a decision",legal_or_privacy:"Legal or privacy",repeated_failure:"Keeps happening"},Yr={entitlement_resync:"Restore their premium access",retry_stuck_generation:"Restart the stuck generation",stale_account_deleti
1on:"Clean up a duplicate account",refund_beyond_tier_a:"Refund beyond what the agent may do alone",code_fix:"Needs a code change",none:"No action needed",other:"Something else"},Xr={high:"High confidence",medium:"Medium confidence",low:"Low confidence"},Zr={responder_escalation:"Handed over by the support agent",admin_manual:"Started by an admin"};function Ee(e,r){const t=(r??"").trim();return t?e[t]??X(t):""}const Ft=e=>Ee(Vr,e),Fn=e=>Ee(Kr,e),kt=e=>Ee(Gr,e),Wn=e=>Ee(Yr,e),$n=e=>Ee(Xr,e),Jr=e=>Ee(Zr,e);function On(e){var l;let r="";if(typeof e=="string")r=e;else if(e&&typeof e=="object"){const d=e;for(const u of["issue_summary","summary","description"]){const p=d[u];if(typeof p=="string"&&p.trim()){r=p.trim();break}}}if(!r)return"No issue was recorded";const i=((l=r.replace(/\b[\w.+-]+@[\w.-]+\.[a-z]{2,}\b/gi,"").replace(/\buser(?:\s+id)?\s*[:=#-]\s*[A-Za-z0-9_-]{3,}\b/gi,"").replace(/\s+for\s+(?:the\s+)?user\s+[\w-]{12,}.*$/i,"").replace(/\b[a-f\d]{8}-[a-f\d-]{20,}\b/gi,"").replace(/\b[A-Za-z\d_-]{28,}\b/g,"").replace(/^the (?:customer|user) (?:reports?|says?|is reporting) (?:that )?/i,"").replace(/\s+/g," ").replace(/\s+([,.;:!?])/g,"$1").trim().split(new RegExp("\\n|(?<=[.!?])\\s"))[0])==null?void 0:l.trim())??"";if(!i)return"Issue needs investigation";if(i.length<=88)return i;const s=i.slice(0,88),a=s.lastIndexOf(" ");return`${s.slice(0,a>50?a:88).trim()}â¦`}const qt={sentry:{label:"Sentry",glyph:"â³",description:"A Sentry issue this claim rests on"},trace:{label:"Trace",glyph:"â¢",description:"A LangSmith trace of the agent run"},deploy:{label:"Deploy",glyph:"â",description:"The deploy this behavior was correlated with"},file:{label:"File",glyph:"â¤",description:"A source location in the repository"},event:{label:"Event",glyph:"â",description:"A product-analytics event on the user's timeline"},log:{label:"Log",glyph:"â¡",description:"A runtime log line from Modal or Cloudflare"},openpanel:{label:"OpenPanel",glyph:"â",description:"Product analytics evidence in OpenPanel"},cloudflare:{label:"Cloudflare",glyph:"â¡",description:"Worker logs or deployment evidence in Cloudflare"},stripe:{label:"Stripe",glyph:"$",description:"Billing evidence in Stripe"},modal:{label:"Modal",glyph:"â¡",description:"Runtime evidence in Modal"},langsmith:{label:"LangSmith",glyph:"â¢",description:"A LangSmith trace of the agent run"},github:{label:"GitHub",glyph:"â¤",description:"Source or deploy evidence in GitHub"},unknown:{label:"Evidence",glyph:"â¢",description:"Supporting evidence of an unrecorded kind"}},Qr={error:"sentry",exception:"sentry",issue:"sentry",span:"trace",commit:"deploy",release:"deploy",revert:"deploy",code:"file",source:"file",analytics:"openpanel",logs:"log",worker:"cloudflare"};function _t(e){return typeof e!="string"?"":e.trim().toLowerCase().replace(/[\s-]+/g,"_")}function lt(e){const r=_t(e),t=Qr[r]??r;return qt[t]??qt.unknown}const ct=["intake","triage","evidence","hypotheses","fixing","awaiting_human_merge","verifying","waiting_on_user","closed"],ei={intake:"Intake",triage:"Triage",evidence:"Evidence",hypotheses:"Hypotheses",fixing:"Fix",awaiting_human_merge:"Awaiting human merge",verifying:"Verify",waiting_on_user:"Waiting on customer",closed:"Closed"},ti=e=>Ee(ei,e);function Dn(e){const r=_t(e);return r?ct.indexOf(r):-1}const ni={not_started:"Not started",starting:"Opening a workspace",running:"Writing a fix",succeeded:"Finished with a fix",failed:"Could not produce a fix",cancelled:"Cancelled"},ri=e=>Ee(ni,e);function ii(e){const r=e.trim();return!r||r.includes(" ")?!1:/^[A-Z][A-Z0-9]*-[A-Z0-9]{3,}$/.test(r)||/^(ch|sub|re|cus|pi|pm|in|evt|price|prod)_[A-Za-z0-9]{6,}$/.test(r)||/^[0-9a-f]{7,40}$/.test(r)||/^[A-Za-z0-9]{20,}$/.test(r)}function Te(e,r=18){const t=e.trim();if(t.length<=r)return t;const i=Math.ceil((r-1)/2),s=Math.floor((r-1)/2);return`${t.slice(0,i)}â¦${t.slice(-s)}`}function Wt(e){if(typeof e!="string")return[];const r=[];let t=[];const i=()=>{t.length>0&&(r.push({kind:"text",value:t.join(" ")}),t=[])};for(const s of e.split(/\s+/)){const a=s.replace(/^[("']+|[)"',.;:]+$/g,"");a&&ii(a)?(i(),r.push({kind:"identifier",value:a})):t.push(s)}return i(),r}function ve(e){return typeof e!="string"?"":En(e)}
1function Vt(e,r=Date.now()){if(typeof e!="string")return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const i=Math.max(0,r-t.getTime()),s=1e3,a=60*s,l=60*a,d=24*l;return i<a?`${Math.floor(i/s)}s ago`:i<l?`${Math.floor(i/a)}m ago`:i<d?`${Math.floor(i/l)}h ago`:i<=7*d?`${Math.floor(i/d)}d ago`:t.toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}).replace(/\s([AP]M)$/i,(u,p)=>p.toLowerCase())}function Un(e){if(typeof e!="string")return"";const r=new Date(e);return Number.isNaN(r.getTime())?"":r.toLocaleString()}function oi(e,r,t){const i=e&&typeof e=="object"&&!Array.isArray(e)?e:null,s=(typeof(i==null?void 0:i.customer_message)=="string"?i.customer_message.trim():"")||(typeof(i==null?void 0:i.exact_user_message)=="string"?i.exact_user_message.trim():"");if(s)return s;const a=typeof r=="string"?Date.parse(r):Number.NaN,d=t.filter(u=>{if(u.role!=="user"||typeof u.content!="string"||!u.content.trim())return!1;if(!Number.isFinite(a))return!0;const p=typeof u.created_at=="string"?Date.parse(u.created_at):Number.NaN;return!Number.isFinite(p)||p<=a}).at(-1);return typeof(d==null?void 0:d.content)=="string"?d.content.trim():""}function dt(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return"";if(e<1e3)return`${Math.round(e)}ms`;const r=Math.round(e/1e3);if(r<60)return`${r}s`;const t=Math.floor(r/60);if(t<60)return`${t}m ${r%60}s`;const i=Math.floor(t/60);return i<24?`${i}h ${t%60}m`:`${Math.floor(i/24)}d ${i%24}h`}const si=new Set(["past_due","expired","canceled","cancelled","unpaid","lapsed","payment_failed"]),ai=new Set(["true","yes","high","elevated","critical","severe"]);function Kt(e,r){for(const t of r){const i=e[t];if(typeof i=="string"&&i.trim())return i.trim();if(typeof i=="number"&&Number.isFinite(i))return String(i)}return""}function li(e,r){for(const t of r){const i=e[t];if(typeof i=="number"&&Number.isFinite(i))return i;if(typeof i=="string"&&i.trim()){const s=Number(i);if(Number.isFinite(s))return s}}return null}function ci(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function di(e){return e<1?"joined today":e<30?`${Math.floor(e)}d member`:e<365?`${Math.floor(e/30)}mo member`:`${Math.floor(e/365)}y member`}function Pn(e){const r=ci(e);if(!r)return[];const t=[],i=Kt(r,["plan","plan_name","subscription_plan"]);i&&t.push({label:X(i),tone:si.has(_t(i))?"warning":"neutral"});const s=li(r,["signup_days","tenure_days","account_age_days"]);s!==null&&s>=0&&t.push({label:di(s),tone:"neutral"});const a=Kt(r,["usage_tier","usage","activity_tier"]);if(a){const l=X(a).toLowerCase(),d=l.endsWith("user")?l:`${l} user`;t.push({label:d,tone:"neutral"})}return ui(r)&&t.push({label:"churn risk",tone:"warning"}),t}function ui(e){for(const r of["churn_risk","churn_risk_level","at_churn_risk","churn_score"]){const t=e[r];if(typeof t=="boolean")return t;if(typeof t=="number"&&Number.isFinite(t))return t>=.5;if(typeof t=="string"&&ai.has(_t(t)))return!0}return!1}const Le=300,pi=["created_at","at","executed_at","timestamp","occurred_at"],fi=["action","kind","action_kind","tool","name"],mi=["outcome","result","status","verdict"],hi=["policy_reason","summary","description","note","message"],gi=["error_code","error","failure_reason"],_i=["executed_by","actor","agent","performed_by"],xi=["approved_by","approver","approved_by_admin_user_id","approved_by_user_id","admin_user_id"],bi=["target","target_id","charge_id","refund_id","subscription_id","invoice_id","payment_intent_id","card_id","deck_id","document_id","generation_id","conversation_id","user_id"],yi=["amount_cents","amount_in_cents","refund_amount_cents","total_cents"],vi=["amount_usd","amount_dollars","amount","refund_amount","credit_amount","total_amount"],Si=new Set(["executed","granted","approved","succeeded","success","ok","completed","verified","refunded","confirmed"]),wi=new Set(["refused","denied","blocked","rejected","skipped","partial","pending","queued","awaiting_approval","needs_approval"]),ji=new Set(["failed","failure","error","errored","reverted","cancelled","canceled"]),Ci=new Set(["admin","human","operator","support_agent","engineer"]),ki=new Set(["responder","investigator","fixer","agent","system","worker","automation"]),Ai=ue` 2 from { opacity: 0; transform: translateY(4px); } 3 to { opacity: 1; transform: none; } 4`;function $t(e){return{animation:`${Ai} 220ms ease-out both`,animationDelay:`${Math.min(e,8)*25}ms`,"@media (prefers-reduced-motion: reduce)":{animation:"none"}}}function ut(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function ne(e,r){for(const t of r){const i=e[t];if(typeof i=="string"&&i.trim().length>0)return i.trim();if(typeof i=="number"&&Number.isFinite(i))return String(i)}return null}function Me(e,r){for(const t of r){const i=e[t];if(typeof i=="boolean")return i}return null}function Gt(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e!="string")return null;
4const r=e.replace(/[^0-9.-]/g,"");if(!r||r==="-"||r===".")return null;const t=Number(r);return Number.isFinite(t)?t:null}function Ti(e,r){try{return new Intl.NumberFormat("en-US",{style:"currency",currency:r}).format(e)}catch{return`${r} ${e.toFixed(2)}`}}const Yt={amountUsd:null,label:null,hasAmount:!1};function At(e){if(!e)return Yt;const r=ne(e,["currency","currency_code"]),t=r&&/^[A-Za-z]{3}$/.test(r)?r.toUpperCase():null;let i=null;for(const a of yi){const l=Gt(e[a]);if(l!==null){i=l/100;break}}if(i===null)for(const a of vi){const l=Gt(e[a]);if(l!==null){i=l;break}}return i===null?Yt:{amountUsd:t===null||t==="USD"?i:null,label:Ti(i,t??"USD"),hasAmount:!0}}function Ei(e,r){return r.hasAmount?!0:e?/refund|credit|comp|payout|charge|payment|invoice|discount|billing/i.test(e):!1}function Ii(e){return e?/ai_quality|question_quality|ai quality/i.test(e):!1}function Re(e){try{const r=JSON.stringify(e);if(typeof r=="string"&&r.length>0)return r.length>160?`${r.slice(0,160)}â¦`:r}catch{}try{return String(e)}catch{return"unprintable value"}}function Li(e,r){const t=(e??"").trim().toLowerCase().replace(/[\s-]+/g,"_");return t?Si.has(t)?{tone:"positive",label:t}:wi.has(t)?{tone:"warning",label:t}:ji.has(t)?{tone:"negative",label:t}:{tone:r===!1?"negative":"neutral",label:t}:r===!0?{tone:"positive",label:"executed"}:r===!1?{tone:"negative",label:"failed"}:{tone:"neutral",label:"outcome not recorded"}}function Ri(e){const r=ne(e,xi);if(r)return{mode:"human",label:"human-approved",approverNote:`approved by ${Te(r,14)}`};const t=Me(e,["auto_executed","automatic","unattended"]);if(t===!0)return{mode:"auto",label:"auto-executed",approverNote:null};if(t===!1)return{mode:"human",label:"human-approved",approverNote:null};if(Me(e,["requires_approval","required_approval"])===!0)return{mode:"human",label:"human-approved",approverNote:null};const a=(ne(e,_i)??"").trim().toLowerCase();return Ci.has(a)?{mode:"human",label:"human-approved",approverNote:null}:ki.has(a)?{mode:"auto",label:"auto-executed",approverNote:null}:{mode:"unknown",label:"actor not recorded",approverNote:null}}function zi(e,r){const t={sourceIndex:r,sortableTime:null,relativeTimestamp:"",absoluteTimestamp:null,actionLabel:"Audit entry",actionKind:null,targetLabel:null,targetFullValue:null,outcomeLabel:"outcome not recorded",outcomeTone:"neutral",executionMode:"unknown",executionLabel:"actor not recorded",approverNote:null,amountLabel:null,breachedAutoLimit:!1,detailLine:null,unreadableSummary:null},i=ut(e);if(!i)return typeof e=="string"&&e.trim().length>0?{...t,detailLine:e.trim()}:{...t,actionLabel:"Unreadable audit entry",unreadableSummary:Re(e)};const s=ne(i,pi),a=s?Date.parse(s):Number.NaN,l=Number.isFinite(a),d=ne(i,fi),u=At(i),p=Ri(i),_=Li(ne(i,mi),Me(i,["succeeded","success","ok"])),b=bi.find(A=>{const y=i[A];return typeof y=="string"&&y.trim().length>0}),g=b?String(i[b]).trim():null,m=ne(i,hi)??ne(i,gi)??null,x=d===null&&g===null&&m===null&&!u.hasAmount;return{...t,unreadableSummary:x?Re(i):null,sortableTime:l?a:null,relativeTimestamp:ve(s),absoluteTimestamp:s,actionLabel:d?Wn(d):"Action not recorded",actionKind:d,targetLabel:b?X(b.replace(/_id$/,"")):null,targetFullValue:g,outcomeLabel:_.label,outcomeTone:_.tone,executionMode:p.mode,executionLabel:p.label,approverNote:p.approverNote,amountLabel:u.label,breachedAutoLimit:p.mode==="auto"&&u.amountUsd!==null&&u.amountUsd>Le,detailLine:m}}function Ni(e){return(Array.isArray(e)?e:[]).map((t,i)=>zi(t,i)).sort((t,i)=>t.sortableTime===null&&i.sortableTime===null?0:t.sortableTime===null?1:i.sortableTime===null?-1:i.sortableTime-t.sortableTime)}function Mi(e){const r=ut(e);return r?JSON.stringify([ne(r,["kind","action","name"]),ne(r,["description","summary"]),ne(r,["target_reference"]),Me(r,["requires_human_approval"]),Me(r,["is_marked_for_execution"]),ne(r,["approved_at"]),ne(r,["approved_by_admin_user_id"]),ne(r,["approval_context"]),Re(r.arguments),Re(r.verification_plan),Re(r.evidence_refs)]):"no_proposed_action"}function Fi(e,r){const t=ut(e);if(!t)return null;const i=ne(t,["kind","action","name"]),s=ne(t,["description","summary"]),a=ne(t,["target_reference"]),l=ut(t.arguments),d=At(l),u=d.hasAmount?d:At(t),p=Ei(i,u),b=!(Me(t,["requires_human_approval"])===!0)&&ne(t,["approved_at"])!==null&&ne(t,["approved_by_admin_user_id"])!==null,g=Me(t,["is_marked_for_execution"])===!0,m=i==="code_fix"||i==="observability_fix",x=r==="starting"||r==="running",A=p&&u.amountUsd!==null&&u.amountUsd<=Le;let y=null;if(l&&Object.keys(l).length>0)try{y=JSON.stringify(l,null,2)}catch{y=Re(l)}let w="needs_approval";Ii(i)?w="human_launch_only":m&&g&&x?w="fixer_in_progress":b?w="approved_not_executed":m&&g?w="autonomous_handoff":A&&(w="auto_executed");const k=w==="human_launch_only"?"AI quality review":i?Wn(i):"Proposed action";return{disposition:w,actionKind:i,actionLabel:k,description:s,targetReference:a,amountLabel:u.label,isMoneyAction:p,hasUngatableAmou
4nt:p&&u.amountUsd===null,argumentsJson:y,isFixerAction:m}}const Hn=h.memo(({proposedAction:e,auditRows:r,investigationId:t,fixerStatus:i=null,onApproved:s})=>{const{t:a}=O(),l=gr(W=>{var z;return((z=W.currentUser)==null?void 0:z.id)??null}),[d,u]=h.useState(!1),[p,_]=h.useState(null),[b,g]=h.useState(!1),[m,x]=h.useState(!1),[A,y]=h.useState(""),[w,k]=h.useState(null),S=h.useId(),L=h.useMemo(()=>Ni(r),[r]),E=h.useMemo(()=>Fi(e,i),[i,e]),j=h.useMemo(()=>Mi(e),[e]),C=JSON.stringify([Re(t),j]),I=h.useRef(C),$=h.useRef(0);I.current=C;const T=h.useCallback(()=>{const W=I.current,z=$.current+1;return $.current=z,()=>$.current===z&&I.current===W},[]);h.useEffect(()=>{$.current+=1,u(!1),_(null),g(!1),x(!1),y(""),k(null)},[t,j]);const F=h.useCallback(async W=>{if(!l||!t)return;const z=T();u(!0),_(null),k(null);try{const Z=await Tr({investigationId:t,adminUserId:l,approvalContext:W});if(!z())return;g(!0),x(!1);const q=(Z==null?void 0:Z.fixerDispatch)??null;(q==null?void 0:q.status)==="started"?k(a("admin.support.investigations.actions.fixer_started","Approved. The Fixer is now working on it.")):!q||q.status==="not_applicable"?k(a("admin.support.investigations.actions.approval_recorded","Approval recorded.")):k(a("admin.support.investigations.actions.approved_fixer_not_started","Approval was recorded, but the Fixer could not start: {reason}",{reason:X(q.reason)})),s==null||s()}catch(Z){if(!z())return;_(Z instanceof Error?Z.message:String(Z))}finally{z()&&u(!1)}},[T,l,t,s,a]),B=h.useCallback(async()=>{if(!l||!t)return;const W=T();u(!0),_(null),k(null);try{if(await Er(t),!W())return;g(!0),k(a("admin.support.investigations.actions.fixer_started","Approved. The Fixer is now working on it.")),s==null||s()}catch(z){if(!W())return;_(z instanceof Error?z.message:String(z))}finally{W()&&u(!1)}},[T,l,t,s,a]),re=l?null:a("admin.support.investigations.actions.waiting_for_admin_account","Waiting for your admin account to load.");return n.jsxs(f,{as:"section","aria-labelledby":S,bg:o.surface.white,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"8px",p:4,mb:3,sx:$t(0),children:[n.jsxs(v,{align:"center",justify:"space-between",gap:3,mb:3,children:[n.jsx(c,{id:S,fontSize:"14px",fontWeight:"700",color:o.text.header,children:a("admin_support.investigations_actionsauditcard.actions_and_approvals_10609479","Actions and approvals")}),n.jsx(c,{fontSize:"11px",fontFamily:"mono",color:o.text.label,children:a("admin.support.investigations.action_count","{count, plural, one {# action} other {# actions}}",{count:L.length})})]}),E?n.jsx(Wi,{view:E,hasApproved:b,isApproving:d,approveDisabledReason:re,approveErrorMessage:p,fixerStatus:i,isModificationEditorOpen:m,approvalContext:A,approvalResultMessage:w,onApprove:()=>void F(null),onApproveWithModification:()=>void F(A),onChangeApprovalContext:y,onToggleModificationEditor:()=>x(W=>!W),onRetryFixerStart:()=>void B()}):null,n.jsx(c,{fontSize:"10.5px",fontWeight:"700",textTransform:"uppercase",letterSpacing:"0.04em",color:o.text.label,mb:2,children:a("admin_support.investigations_actionsauditcard.audit_trail_newest_first_2f28e170","Audit trail · newest first")}),L.length===0?n.jsx(c,{fontSize:"13px",color:o.text.placeholder,children:a("admin_support.investigations_actionsauditcard.nothing_has_been_executed_on_this_investigation_yet_tier_b_fixes_and_mon_9bd078e1","Nothing has been executed on this investigation yet. Tier-B fixes and money actions write a row here the moment they run.")}):n.jsx(f,{as:"ol","aria-label":a("admin_support.investigations_actionsauditcard.action_audit_trail_newest_first_0b3e0970","Action audit trail, newest first"),listStyleType:"none",m:0,p:0,children:L.map((W,z)=>n.jsx($i,{row:W,displayIndex:z},`${W.sourceIndex}-${W.absoluteTimestamp??"no-timestamp"}`))})]})});Hn.displayName="ActionsAuditCard";function Wi({view:e,hasApproved:r,isApproving:t,approveDisabledReason:i,approveErrorMessage:s,fixerStatus:a,isModificationEditorOpen:l,approvalContext:d,approvalResultMessage:u,onApprove:p,onApproveWithModification:_,onChangeApprovalContext:b,onToggleModificationEditor:g,onRetryFixerStart:m}){const{t:x}=O(),A=e.disposition==="needs_approval",y=e.disposition==="approved_not_executed",w=e.disposition==="autonomous_handoff",k=e.disposition==="fixer_in_progress",S=e.disposition==="human_launch_only",L=a==="starting"||a==="running",E=y&&e.isFixerAction&&!L&&a!=="succeeded",j=A?o.accentColors.warningLight:S||w||k?o.accentColors.infoLight:o.surface.offWhite,C=A?o.accentColors.warningStrong:S||w||k?o.accentColors.infoDark:o.surface.border,I=A?o.accentColors.warningStrong:S||w||k?o.accentColors.infoDark:o.accentColors.successStrong,$=A?x("admin.support.investigations.actions.waiting_for_approval","Waiting on your approval"):y?e.isFixerAction?L?x("admin.support.investigations.actions.approved_fixer_running","Approved · Fixer running"):x("admin.support.investigations.actions.approved","Approved"):x("admin.support.investigations.actions.approved_not_executed","Approved, not executed"):S?x("admin.support.investigations.actions.human_decision","A person decides this one"):k?x("admin.support.investigations.actions.autonomous_fixer_running","Automatic Fixer running"):w?x("admin.support.investigations.actions.autonomous_handoff","Cleared for automatic execution"):x("admin.support.investigations.actions.executed_automatically","Executed automatically");return n.jsxs(f,{bg:j,borderWidth:"1px",borderColor:C,borderRadius:"8px",p:4,mb:4,sx:$t(1),children:[n.jsxs(v,{align:"flex-start",justify:"space-between",gap:4,children:[n.jsxs(f,{minW:0,children:[n.jsx(c,{fontSize:"10.5px",fontWeight:"700",textTransform:"uppercase",letterSpacing:"0.04em",color:I,children:$}),n.jsx(c,{fontSize:"15px",fontWeight:"700",color:o.text.header,mt:1,children:e.actionLabel}),e.actionKind?n.jsx(c,{fontSize:"11.5px",fontFamily:"mono",color:o.text.label,mt:.5,children:e.actionKind}):null]}),e.isMoneyAction?n.jsxs(f,{textAlign:"right",flexShrink:0,children:[n.jsx(c,{fontSize:A?"26px":"20px",fontWeight:"800",fontFamily:"mono",lineHeight:"1.1",color:o.text.header,children:e.amountLabel??x("admin.support.investigations.amount_not_recorded","amount not recorded")}),n.jsx(c,{fontSize:"10.5px",fontFamily:"mono",color:I,mt:1,children:e.disposition==="auto_executed"?`within the $${Le}
4 limit`:e.hasUngatableAmount?`not gatable against the $${Le} limit`:`over the $${Le} limit`})]}):null]}),n.jsx(c,{fontSize:"13.5px",color:o.text.body,whiteSpace:"pre-wrap",mt:2,children:n.jsx(ee,{text:e.description||x("admin.support.investigations.action_description_missing","No description was recorded for this action.")})}),e.targetReference?n.jsxs(c,{fontSize:"11.5px",color:o.text.label,mt:1.5,children:[x("admin.support.object_reference.target","Target"),":"," ",n.jsx(ee,{text:e.targetReference})]}):null,e.argumentsJson?n.jsx(f,{mt:2,bg:o.surface.background,borderRadius:"6px",px:3,py:2,maxH:"180px",overflowY:"auto",children:n.jsx(c,{fontSize:"11.5px",fontFamily:"mono",lineHeight:"1.45",color:o.text.label,whiteSpace:"pre-wrap",children:n.jsx(ee,{text:e.argumentsJson})})}):null,e.disposition==="auto_executed"?n.jsxs(c,{fontSize:"12px",color:o.text.label,mt:3,children:[x("admin_support.investigations_actionsauditcard.money_at_or_under_82eff20d","Money at or under $"),Le," ",x("admin_support.investigations_actionsauditcard.runs_without_waiting_for_a_person_its_row_is_in_the_trail_below_2e14bb46","runs without waiting for a person. Its row is in the trail below.")]}):null,y?n.jsx(c,{fontSize:"12px",color:o.text.label,mt:3,children:e.isFixerAction?L?x("admin.support.investigations.actions.fixer_is_working","The Fixer is working on this action now."):x("admin.support.investigations.actions.approval_recorded_fixer_idle","Approval is recorded. The Fixer is not currently running."):x("admin.support.investigations.actions.approval_recorded_not_executed","Approved. No action was executed.")}):null,S?n.jsx(c,{fontSize:"12px",color:o.text.label,mt:3,children:x("admin_support.investigations_actionsauditcard.ai_quality_work_has_no_evidence_chain_to_approve_against_so_nothing_laun_eff17323","AI quality work has no evidence chain to approve against, so nothing launches from this card. An engineer picks up the review packet and decides what the fix should be.")}):null,k||w?n.jsx(c,{fontSize:"12px",color:o.text.label,mt:3,children:k?x("admin.support.investigations.actions.fixer_is_working","The Fixer is working on this action now."):x("admin.support.investigations.actions.autonomous_no_approval","This action passed the automatic safety gates. No human approval is needed.")}):null,A&&!r?n.jsxs(f,{mt:3,children:[n.jsxs(v,{gap:2,wrap:"wrap",children:[n.jsx(Ke,{title:e.isFixerAction?x("admin.support.investigations.actions.approve_and_start_fixer","Approve and start Fixer"):x("admin.support.investigations.actions.approve_proposed_action","Approve proposed action"),size:"small",buttonPrimaryOrSecondaryType:"primary",buttonStyleType:"default",onClick:p,isLoading:t&&!l,loadingText:x("admin.support.investigations.actions.approving","Approving..."),disabled:!!i||t}),e.isFixerAction?n.jsx(Ke,{title:x("admin.support.investigations.actions.approve_with_modification","Approve with modification"),size:"small",buttonPrimaryOrSecondaryType:"primary",buttonStyleType:"outline",onClick:g,disabled:!!i||t}):null]}),l?n.jsxs(f,{mt:3,children:[n.jsx(c,{fontSize:"12px",color:o.text.label,mb:1.5,children:x("admin.support.investigations.actions.modification_prompt","Add guidance the Fixer should consider while making this change.")}),n.jsx(Nn,{value:d,onChange:T=>b(T.target.value),maxLength:4e3,minH:"96px",resize:"vertical",bg:o.surface.white,placeholder:x("admin.support.investigations.actions.modification_placeholder","For example: preserve the current mobile behavior and add a regression test for mixed-deck reviews.")}),n.jsx(Ke,{title:x("admin.support.investigations.actions.approve_start_with_modification","Approve and start with modification"),mt:2,size:"small",buttonPrimaryOrSecondaryType:"primary",buttonStyleType:"default",onClick:_,isLoading:t,loadingText:x("admin.support.investigations.actions.approving","Approving..."),disabled:!d.trim()||!!i})]}):null,i?n.jsx(c,{fontSize:"12px",color:o.text.placeholder,mt:1,children:i}):null]}):null,r?n.jsx(c,{fontSize:"12.5px",fontWeight:"600",color:o.accentColors.successStrong,mt:3,children:u??x("admin.support.investigations.actions.approval_recorded","Approval recorded.")}):null,E?n.jsx(Ke,{title:x("admin.support.investigations.actions.start_fixer","Start Fixer"),mt:3,size:"small",buttonPrimaryOrSecondaryType:"primary",buttonStyleType:"outline",onClick:m,isLoading:t,loadingText:x("admin.support.investigations.actions.starting_fixer","Starting Fixer..."),disabled:!!i}
4):null,s?n.jsxs(c,{fontSize:"12px",color:o.accentColors.errorStrong,mt:2,children:[x("admin_support.investigations_actionsauditcard.could_not_approve_864f559e","Could not approve:")," ",s]}):null]})}function $i({row:e,displayIndex:r}){var d;const{t}=O(),i=me(e.outcomeTone),s=((d=e.targetLabel)==null?void 0:d.toLowerCase())??"",a=e.targetFullValue&&(s==="deck"||s==="card")?Nr({[`${s}_id`]:e.targetFullValue})[0]??null:null,l=e.executionMode==="human"?o.accentColors.infoDark:o.text.label;return n.jsxs(v,{as:"li",align:"flex-start",gap:3,py:2.5,borderTopWidth:r===0?"0":"1px",borderColor:o.surface.border,sx:$t(r+2),children:[n.jsx(f,{w:"86px",flexShrink:0,children:n.jsx(c,{fontSize:"11px",fontFamily:"mono",lineHeight:"1.35",color:o.text.label,title:e.absoluteTimestamp??void 0,children:e.relativeTimestamp||t("admin.support.investigations.no_timestamp","no timestamp")})}),n.jsxs(f,{flex:"1",minW:0,children:[n.jsxs(v,{align:"baseline",gap:2,wrap:"wrap",children:[n.jsx(c,{fontSize:"13px",fontWeight:"600",lineHeight:"1.35",color:o.text.header,children:e.actionLabel}),e.amountLabel?n.jsx(c,{fontSize:"12.5px",fontWeight:"700",fontFamily:"mono",color:o.text.header,children:e.amountLabel}):null]}),e.targetFullValue?n.jsxs(v,{align:"center",gap:1,mt:.5,children:[n.jsxs(c,{fontSize:"11.5px",fontFamily:"mono",lineHeight:"1.4",color:o.text.label,title:e.targetFullValue,children:[e.targetLabel?`${e.targetLabel.toLowerCase()} `:"",Te(e.targetFullValue)]}),a?n.jsx(Nt,{reference:a}):null]}):null,e.detailLine?n.jsx(c,{fontSize:"12px",lineHeight:"1.45",color:o.text.label,mt:.5,children:n.jsx(ee,{text:e.detailLine})}):null,e.unreadableSummary?n.jsx(c,{fontSize:"11.5px",fontFamily:"mono",lineHeight:"1.4",color:o.text.label,mt:.5,wordBreak:"break-all",children:n.jsx(ee,{text:e.unreadableSummary})}):null,e.breachedAutoLimit?n.jsxs(c,{fontSize:"11.5px",fontWeight:"600",color:o.accentColors.errorStrong,mt:1,children:[t("admin_support.investigations_actionsauditcard.ran_unattended_above_the_36bc4567","Ran unattended above the $"),Le," ",t("admin_support.investigations_actionsauditcard.limit_check_the_policy_path_c7cff1b4","limit. Check the policy path.")]}):null]}),n.jsxs(v,{direction:"column",align:"flex-end",gap:1,flexShrink:0,children:[n.jsx(f,{bg:i.backgroundColor,color:i.textColor,borderRadius:"full",px:2,py:.5,children:n.jsx(c,{fontSize:"10.5px",fontWeight:"700",fontFamily:"mono",whiteSpace:"nowrap",children:e.outcomeLabel})}),n.jsx(c,{fontSize:"10.5px",fontFamily:"mono",color:l,whiteSpace:"nowrap",children:e.executionLabel}),e.approverNote?n.jsx(c,{fontSize:"10.5px",fontFamily:"mono",color:o.text.label,whiteSpace:"nowrap",children:e.approverNote}):null]})]})}const oe="11.5px",pt="10.5px",He="13px",Oi=ue` 5 from { opacity: 0; transform: translateY(4px); } 6 to { opacity: 1; transform: none; } 7`,Di=ue` 8 0% { opacity: 0.55; } 9 50% { opacity: 1; } 10 100% { opacity: 0.55; } 11`,Bn={"@media (prefers-reduced-motion: reduce)":{animation:"none"}},Ui="rgba(18, 18, 18, 0.88)";function _e(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function H(e,r){for(const t of r){const i=e[t];if(typeof i=="string"&&i.trim().length>0)return i.trim()}return""}function J(e,r){for(const t of r){const i=e[t];if(typeof i=="number"&&Number.isFinite(i))return i;if(typeof i=="string"&&i.trim().length>0){const s=Number(i);if(Number.isFinite(s))return s}}return null}const Pi=new Set(["true","yes","y","1"]);function Hi(e,r){for(const t of r){const i=e[t];if(typeof i=="boolean")return i;if(typeof i=="number")return i===1;if(typeof i=="string"&&Pi.has(i.trim().toLowerCase()))return!0}return!1}function Ot(e){return typeof e!="string"?"":e.trim().toLowerCase().replace(/[\s-]+/g,"_")}function Bi(e){const r=e.lastIndexOf(".");return r<=0||r===e.length-1?"":e.slice(r+1).toLowerCase()}const qi=new Set(["png","jpg","jpeg","gif","webp","bmp","heic","heif","avif"]),Vi=new Set(["mp4","mov","m4v","webm","avi","mkv","qt","mpeg","mpg"]),Ki=new Set(["video_frame","videoframe","frame","keyframe","storyboard"]),Gi=new Set(["video","screen_recording","recording","video_recording","screenrecording"]),Yi=new Set(["screenshot","image","page_screenshot","auto_screenshot"]);function Xi(e){const r=Bi(e.filename);return Ki.has(e.kindToken)?"video_frame":e.contentType.startsWith("video/")||Gi.has(e.kindToken)||Vi.has(r)?"video":e.contentType.startsWith("image/")||Yi.has(e.kindToken)||qi.has(r)?"image":"file"}function Zi(e,r){const t=_e(e);
11if(!t)return null;const i=H(t,["id","attachment_id","s3_key"]),s=H(t,["presigned_get_url","url","download_url","href","src"]),a=Ne(s)?s:"",l=H(t,["content_type","contentType","mime_type","mimeType","type"]),d=l.includes("/")?l.toLowerCase():"",u=H(t,["filename","file_name","name","title"])||Ji(a)||"Unnamed attachment";return{reactKey:`${i||"attachment"}-${r}`,attachmentId:i,filename:u,contentType:d,sizeBytes:J(t,["size_bytes","sizeBytes","size","bytes"]),downloadUrl:a,kindToken:Ot(t.kind),record:t}}function Ji(e){if(!e)return"";try{const r=new URL(e).pathname.split("/").filter(Boolean).pop();return r?decodeURIComponent(r):""}catch{return""}}function Qi(e){const{record:r}=e,t=J(r,["start_seconds","timestamp_seconds","frame_timestamp_seconds"]),i=J(r,["end_seconds"]),s=J(r,["timestamp_seconds","frame_timestamp_seconds","at_seconds","offset_seconds","start_seconds"]),a=H(r,["timestamp_label","timestamp_range","timestamp"]),l=t!==null&&i!==null?`${nt(t)}â${nt(i)}`:"",d=s!==null?nt(s):"";return{...e,galleryIndex:-1,isStoryboard:Hi(r,["is_storyboard","storyboard"])||e.kindToken==="storyboard"||e.filename.toLowerCase().includes("storyboard"),timestampLabel:a||l||d,timestampSeconds:s,sourceVideoId:H(r,["source_attachment_id","video_attachment_id","parent_attachment_id","source_id"])}}const eo=new Set(["failed","failure","error","errored","cancelled","canceled"]),to=new Set(["pending","queued","processing","running","extracting","in_progress","started"]);function no(e,r){const{record:t}=e,i=Ot(H(t,["video_evidence_status","extraction_status","frame_extraction_status","video_evidence_state","status"])),s=H(t,["video_evidence_error","extraction_error","frame_extraction_error","error"]),a=r.filter(_=>_.isStoryboard).sort(Tt),l=r.filter(_=>!_.isStoryboard).sort(Tt),d=a.length>0||l.length>0,u=!!s||eo.has(i);let p="pending";return d?p="ready":u?p="failed":to.has(i)&&(p="pending"),{...e,metadataLine:ro(t),transcript:io(t),storyboards:a,keyframes:l,extractionState:p,extractionFailureText:u?oo(s):"",statusToken:i}}function Tt(e,r){return e.timestampSeconds===null&&r.timestampSeconds===null?0:e.timestampSeconds===null?1:r.timestampSeconds===null?-1:e.timestampSeconds-r.timestampSeconds}function ro(e){const r=_e(e.video_metadata)??_e(e.metadata)??e,t=[],i=J(r,["width"]),s=J(r,["height"]);if(i!==null&&s!==null)t.push(`${Math.round(i)}Ã${Math.round(s)}`);else{const u=H(r,["resolution","dimensions"]);u&&t.push(u)}const a=J(r,["duration_seconds","duration"]);if(a!==null){const u=nt(a);u&&t.push(u)}const l=J(r,["fps","frame_rate","avg_frame_rate"]);l!==null&&l>0&&t.push(`${Math.round(l)} fps`);const d=H(r,["codec","video_codec","codec_name"]);return d&&t.push(d),t.join(" · ")}function io(e){const r=e.transcript??e.video_transcript??e.transcription;if(typeof r=="string")return r.trim();const t=_e(r);return t?H(t,["text","transcript","content"]):Array.isArray(r)?r.map(i=>{if(typeof i=="string")return i.trim();const s=_e(i);return s?H(s,["text","content"]):""}).filter(i=>i.length>0).join(` 12`):""}function oo(e){return e?!e.includes(" ")&&/[_-]/.test(e)?X(e):e:""}function nt(e){if(!Number.isFinite(e)||e<0)return"";const r=Math.floor(e),t=r%60,i=Math.floor(r/60)%60,s=Math.floor(r/3600),a=String(t).padStart(2,"0");return s>0?`${s}:${String(i).padStart(2,"0")}:${a}`:`${i}:${a}`}function Dt(e){if(e===null||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${Math.round(e)} B`;const r=e/1024;if(r<1024)return`${Math.max(1,Math.round(r))} KB`;const t=r/1024;if(t<1024)return`${t.toFixed(t>=10?0:1)} MB`;const i=t/1024;return`${i.toFixed(i>=10?0:1)} GB`}function De(e,r,t){return`${e} ${e===1?r:t}`}function so(e){const r=Array.isArray(e)?e:[],t=[],i=[],s=[],a=[];let l=0;r.forEach((y,w)=>{const k=Zi(y,w);if(!k){l+=1;return}const S=Xi(k);S==="image"?t.push({...k,galleryIndex:-1}):S==="video"?i.push(k):S==="video_frame"?s.push(Qi(k)):a.push(k)});const d=new Set(i.map(y=>y.attachmentId).filter(Boolean)),u=s.filter(y=>!y.sourceVideoId),p=i.length===1,_=i.map(y=>{const w=s.filter(k=>k.sourceVideoId&&k.sourceVideoId===y.attachmentId||p&&!k.sourceVideoId);return no(y,w)}),b=s.filter(y=>y.sourceVideoId?!d.has(y.sourceVideoId):!p).sort(Tt),g=i.length>1&&u.length>0,m=[],x=(y,w)=>{y.downloadUrl&&(y.galleryIndex=m.length,m.push({key:y.reactKey,imageUrl:y.downloadUrl,filename:y.filename,caption:w}))};t.forEach(y=>x(y,y.contentType||"image")),_.forEach(y=>{y.storyboards.forEach(w=>
12x(w,xt(w))),y.keyframes.forEach(w=>x(w,xt(w)))}),b.forEach(y=>x(y,xt(y)));const A=[];return t.length>0&&A.push(De(t.length,"image","images")),_.length>0&&A.push(De(_.length,"recording","recordings")),s.length>0&&A.push(De(s.length,"extracted frame","extracted frames")),a.length>0&&A.push(De(a.length,"file","files")),l>0&&A.push(De(l,"unreadable entry","unreadable entries")),{images:t,videos:_,unlinkedFrames:b,unlinkedFramesHaveUnknownSource:g,files:a,galleryItems:m,unreadableCount:l,summaryLine:A.join(" · "),hasAnyAttachment:t.length>0||_.length>0||s.length>0||a.length>0||l>0}}function xt(e){const r=e.isStoryboard?"storyboard":"keyframe";return e.timestampLabel?`${r} ${e.timestampLabel}`:r}const ao=new Set(["error","fatal","severe","assert"]),lo=new Set(["warn","warning"]);function co(e){const r=_e(e);if(!r)return null;const t=_e(r.summary)??{},i=uo(r.console_entries??r.consoleEntries),s=po(r.network_entries??r.networkEntries),a=bt(t.recent_console_error_messages,"console-sample").map(z=>({key:z.key,level:"error",isError:!0,isWarning:!1,text:z.text})),l=bt(t.failed_network_request_lines,"network-failure-sample").map(z=>({key:z.key,isFailed:!0,hasUnknownStatus:!Xt(z.text),text:z.text})),d=bt(t.slow_first_party_request_lines,"network-performance-sample").map(z=>({key:z.key,isFailed:!1,hasUnknownStatus:!Xt(z.text),text:z.text})),u=[...l,...d].filter((z,Z,q)=>q.findIndex(de=>de.text===z.text)===Z),p=i.length>0?i:a,_=s.length>0?s:u,b=J(t,["console_error_count"])??p.filter(z=>z.isError).length,g=J(t,["network_failed_count"])??_.filter(z=>z.isFailed).length,m=J(t,["network_total_count"])??_.length,x=H(t,["console_capture_status"]),A=H(t,["network_capture_status"]),y=_.filter(z=>!z.hasUnknownStatus).length,w=H(r,["presigned_get_url","url"]),k=H(r,["captured_at","capturedAt","created_at"]),S=_e(r.display_context)??_e(t.display_context),L=S?J(S,["viewport_width_css_px"]):null,E=S?J(S,["viewport_height_css_px"]):null,j=S?J(S,["visual_viewport_width_css_px"]):null,C=S?J(S,["visual_viewport_height_css_px"]):null,I=S?J(S,["screen_width_css_px"]):null,$=S?J(S,["screen_height_css_px"]):null,T=S?J(S,["device_pixel_ratio"]):null,F=S?H(S,["orientation"]):"",B=S?J(S,["orientation_angle_degrees"]):null,W=L!==null&&E!==null&&I!==null&&$!==null&&T!==null&&!!F?{viewportWidth:L,viewportHeight:E,visualViewportWidth:j,visualViewportHeight:C,screenWidth:I,screenHeight:$,devicePixelRatio:T,orientation:F,orientationAngleDegrees:B}:null;return{capturedAtLabel:ve(k),pageUrl:H(r,["page_url","pageUrl","url_at_capture"]),userAgent:H(r,["user_agent","userAgent"]),consoleLines:p,networkLines:_,consoleErrorCount:Math.max(0,Math.round(b)),networkFailedCount:Math.max(0,Math.round(g)),networkTotalCount:Math.max(0,Math.round(m)),consoleCaptureStatus:x==="captured"||x==="not_instrumented"?x:p.length>0?"captured":"unknown",networkCaptureStatus:A==="instrumented"||A==="resource_timing"||A==="unavailable"?A:_.length>0?"resource_timing":"unknown",networkStatusCoverageCount:Math.max(0,Math.round(J(t,["network_status_coverage_count"])??y)),isSummaryOnly:i.length===0&&s.length===0,fullCaptureUrl:Ne(w)?w:"",displayContext:W,hasAnything:p.length>0||_.length>0||!!k||!!H(r,["page_url","pageUrl"])||W!==null}}function Xt(e){return/â\s*[1-5]\d{2}(?:\s|$)/.test(e)}function bt(e,r){if(!Array.isArray(e))return[];const t=[];return e.forEach((i,s)=>{const a=typeof i=="string"?i.trim():"";a&&t.push({key:`${r}-${s}`,text:a})}),t}function uo(e){if(!Array.isArray(e))return[];const r=[];return e.forEach((t,i)=>{const s=_e(t);if(!s)return;const a=Ot(s.level)||"log",l=H(s,["message","text","serialized_arguments"]);if(!l)return;const d=H(s,["timestamp","at","time"]);r.push({key:`${H(s,["id"])||"console"}-${i}`,level:a,isError:ao.has(a),isWarning:lo.has(a),text:[d,a.toUpperCase(),l].filter(Boolean).join(" ")})}),r}function po(e){if(!Array.isArray(e))return[];const r=[];return e.forEach((t,i)=>{const s=_e(t);if(!s)return;const a=(H(s,["method"])||"GET").toUpperCase(),l=H(s,["url","request_url"]);if(!l)return;const d=J(s,["status","status_code"]),u=H(s,["error_message","error"]),p=J(s,["duration_ms","durationMs"]),_=d===null?!!u:d>=400,b=d===null?"":String(Math.round(d));r.push({key:`${H(s,["id"])||"request"}-${i}`,isFailed:_,hasUnknownStatus:d===null,text:[`${a} ${l}`,b,p!==null?`${Math.round(p)}
12 ms`:"",u].filter(Boolean).join(" ")})}),r}const qn=h.memo(({attachments:e,debugContext:r})=>{const{t}=O(),i=h.useMemo(()=>so(e),[e]),s=h.useMemo(()=>co(r),[r]),[a,l]=h.useState(null),d=h.useId(),u=i.galleryItems.length,p=h.useCallback(m=>{m<0||l(m)},[]),_=h.useCallback(()=>l(null),[]),b=h.useCallback(m=>{l(x=>x===null||u===0?null:(x+m+u)%u)},[u]),g=a!==null?i.galleryItems[a]??null:null;return n.jsxs(f,{as:"section","aria-labelledby":d,bg:o.surface.white,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"8px",p:4,mb:3,animation:`${Oi} 220ms ease-out both`,sx:Bn,children:[n.jsxs(v,{align:"baseline",justify:"space-between",gap:3,mb:3,wrap:"wrap",children:[n.jsx(c,{id:d,as:"h3",fontSize:"14px",fontWeight:"700",color:o.text.header,children:t("admin_support.investigations_customerevidencecard.customer_evidence_535cc5e0","Customer evidence")}),i.summaryLine?n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.text.label,children:i.summaryLine}):null]}),!i.hasAnyAttachment&&!(s!=null&&s.hasAnything)?n.jsx(c,{fontSize:He,color:o.text.placeholder,children:t("admin_support.investigations_customerevidencecard.the_customer_attached_nothing_and_no_browser_context_was_captured_with_t_0c72d301","The customer attached nothing, and no browser context was captured with this report.")}):null,i.images.length>0?n.jsx(rt,{label:t("admin_support.investigations_customerevidencecard.images_09e871c9","Images"),children:n.jsx(f,{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(116px, 1fr))",gap:2,children:i.images.map(m=>n.jsx(Ut,{imageUrl:m.downloadUrl,altText:m.filename,captionPrimary:m.filename,captionSecondary:Dt(m.sizeBytes),galleryIndex:m.galleryIndex,onOpen:p,thumbnailHeight:"88px"},m.reactKey))})}):null,i.videos.map((m,x)=>n.jsx(fo,{video:m,sectionLabel:i.videos.length>1?t("admin.support.investigations.recording_number","Recording {recordingNumber}",{recordingNumber:x+1}):t("admin.support.investigations.recording","Recording"),onOpenGalleryItem:p},m.reactKey)),i.unlinkedFrames.length>0?n.jsxs(rt,{label:t("admin_support.investigations_customerevidencecard.extracted_frames_d09f857e","Extracted frames"),children:[n.jsx(c,{fontSize:"12px",color:o.text.label,mb:2,children:i.unlinkedFramesHaveUnknownSource?t("admin.support.investigations.frames_unknown_source","These frames could not be matched to any of the recordings attached to this investigation."):t("admin.support.investigations.frames_detached_source","These frames were extracted from a recording that is not attached to this investigation.")}),n.jsx(Vn,{frames:i.unlinkedFrames,onOpenGalleryItem:p,tileWidth:"112px"})]}):null,i.files.length>0?n.jsx(rt,{label:t("admin_support.investigations_customerevidencecard.other_files_b0c0a378","Other files"),children:n.jsx(v,{wrap:"wrap",gap:2,children:i.files.map(m=>n.jsx(ho,{file:m},m.reactKey))})}):null,i.unreadableCount>0?n.jsx(c,{fontSize:"12px",color:o.text.placeholder,mt:2,children:t("admin.support.investigations.unreadable_attachments","{count, plural, one {# attachment on this conversation could not be read and is not shown above.} other {# attachments on this conversation could not be read and are not shown above.}}",{count:i.unreadableCount})}):null,s!=null&&s.hasAnything?n.jsx(go,{browserContext:s}):null,g?n.jsx(xo,{item:g,position:(a??0)+1,totalCount:u,onClose:_,onStep:b}):null]})});qn.displayName="CustomerEvidenceCard";function rt({label:e,children:r}){return n.jsxs(f,{mb:4,children:[n.jsx(c,{as:"h4",fontSize:pt,fontWeight:"700",textTransform:"uppercase",letterSpacing:"0.04em",color:o.text.label,mb:2,children:e}),r]})}function Ut({imageUrl:e,altText:r,captionPrimary:t,captionSecondary:i,galleryIndex:s,onOpen:a,thumbnailHeight:l}){const{t:d}=O(),u=[t,i].filter(Boolean).join(" · ");return e?n.jsxs(f,{as:"button",type:"button",onClick:()=>a(s),"aria-label":`Open ${t} full size`,textAlign:"left",borderWidth:"1px",borderColor:o.surface.border,borderRadius:"6px",overflow:"hidden",bg:o.surface.offWhite,cursor:"zoom-in",transition:"border-color 120ms ease",_hover:{borderColor:o.primaryAction.default},_focusVisible:{outline:`2px solid ${o.primaryAction.default}`,outlineOffset:"1px"},children:[n.jsx(Tn,{src:e,alt:r,width:"100%",height:l,objectFit:"cover",display:"block",bg:o.surface.secondary}),n.jsx(f,{px:2,py:1.5,borderTopWidth:"1px",borderColor:o.surface.border,children:n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.text.label,noOfLines:1,children:u})})]}):n.jsxs(f,{borderWidth:"1px",borderColor:o.surface.border,borderRadius:"6px",p:2,bg:o.surface.primary,children:[n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.text.label,noOfLines:1,children:t}),n.jsx(c,{fontSize:"10.5px",color:o.text.placeholder,children:d("admin_support.investigations_customerevidencecard.link_unavailable_ecc44144","link unavailable")})]})}function Vn({frames:e,onOpenGalleryItem:r,tileWidth:t}){const{t:i}=O();return n.jsx(v,{gap:2,overflowX:"auto",pb:1,sx:{scrollbarWidth:"thin"},children:e.map(s=>n.jsx(f,{flexShrink:0,width:t,children:n.jsx(Ut,{imageUrl:s.downloadUrl,altText:`${s.isStoryboard?i("admin.support.investigations.storyboard","Storyboard"):i("admin.support.investigations.keyframe","Keyframe")} ${s.timestampLabel||s.filename}`,captionPrimary:s.timestampLabel||s.filename,captionSecondary:"",galleryIndex:s.galleryIndex,onOpen:r,thumbnailHeight:"72px"})},s.reactKey))})}function fo({video:e,sectionLabel:r,onOpenGalleryItem:t}){const{t:i}
12=O(),a=[Dt(e.sizeBytes),e.metadataLine].filter(Boolean).join(" · ");return n.jsxs(rt,{label:r,children:[n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.text.body,mb:1,wordBreak:"break-all",children:e.filename}),a?n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.text.label,mb:2,children:a}):null,e.downloadUrl?n.jsx("video",{controls:!0,preload:"metadata",src:e.downloadUrl,"data-testid":"customer-evidence-video",style:{width:"100%",maxHeight:"320px",borderRadius:"6px",border:`1px solid ${o.surface.border}`,background:o.surface.secondary}}):n.jsx(c,{fontSize:He,color:o.text.placeholder,children:i("admin_support.investigations_customerevidencecard.the_download_link_for_this_recording_is_missing_or_has_expired_so_it_can_aeebf119","The download link for this recording is missing or has expired, so it cannot be played here.")}),e.storyboards.length>0?n.jsxs(f,{mt:3,children:[n.jsx(c,{as:"h5",fontSize:pt,fontWeight:"700",color:o.text.label,mb:1,children:i("admin_support.investigations_customerevidencecard.storyboard_7c293d67","Storyboard")}),n.jsx(f,{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))",gap:2,children:e.storyboards.map(l=>n.jsx(Ut,{imageUrl:l.downloadUrl,altText:`Storyboard ${l.timestampLabel||l.filename}`,captionPrimary:l.timestampLabel||l.filename,captionSecondary:"",galleryIndex:l.galleryIndex,onOpen:t,thumbnailHeight:"160px"},l.reactKey))})]}):null,e.keyframes.length>0?n.jsxs(f,{mt:3,children:[n.jsx(c,{as:"h5",fontSize:pt,fontWeight:"700",color:o.text.label,mb:1,children:i("admin_support.investigations_customerevidencecard.keyframes_987e5e1f","Keyframes")}),n.jsx(Vn,{frames:e.keyframes,onOpenGalleryItem:t,tileWidth:"112px"})]}):null,n.jsx(mo,{video:e}),e.transcript?n.jsxs(f,{as:"details","data-testid":"customer-evidence-transcript",mt:3,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"6px",bg:o.surface.offWhite,px:3,py:2,children:[n.jsx(f,{as:"summary",cursor:"pointer",children:n.jsx(c,{as:"span",fontSize:"12px",fontWeight:"700",color:o.text.body,children:i("admin_support.investigations_customerevidencecard.transcript_5bcd6022","Transcript")})}),n.jsx(c,{fontSize:He,color:o.text.body,whiteSpace:"pre-wrap",mt:2,children:e.transcript})]}):null]})}function mo({video:e}){const{t:r}=O();return e.extractionState==="ready"?e.extractionFailureText?n.jsxs(c,{fontSize:"12px",color:o.accentColors.warningStrong,mt:2,children:[r("admin_support.investigations_customerevidencecard.extraction_reported_a_problem_97f11b3f","Extraction reported a problem ("),e.extractionFailureText,r("admin_support.investigations_customerevidencecard.the_frames_above_are_all_it_produced_d9b11748","); the frames above are all it produced.")]}):null:e.extractionState==="failed"?n.jsxs(f,{mt:3,bg:o.accentColors.errorLight,borderLeftWidth:"3px",borderColor:o.accentColors.errorStrong,borderRadius:"4px",px:3,py:2,children:[n.jsx(c,{fontSize:He,color:o.accentColors.errorStrong,children:r("admin_support.investigations_customerevidencecard.frame_extraction_failed_so_there_is_nothing_extracted_to_read_watch_the_87f2cd25","Frame extraction failed, so there is nothing extracted to read. Watch the recording above.")}),e.extractionFailureText?n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.accentColors.errorStrong,mt:1,children:e.extractionFailureText}):null]}):n.jsxs(v,{align:"center",gap:2,mt:3,children:[n.jsx(f,{width:"6px",height:"6px",borderRadius:"full",bg:o.text.placeholder,animation:`${Di} 1.8s ease-in-out infinite`,sx:Bn}),n.jsx(c,{fontSize:He,color:o.text.label,children:r("admin_support.investigations_customerevidencecard.frames_are_being_extracted_from_this_recording_nothing_has_been_extracte_1db15d42","Frames are being extracted from this recording. Nothing has been extracted yet.")}),e.statusToken?n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.text.placeholder,children:e.statusToken}):null]})}function ho({file:e}){const r=[Dt(e.sizeBytes),e.contentType||"unknown type"].filter(Boolean).join(" · "),t=n.jsxs(v,{align:"center",gap:2,bg:o.surface.offWhite,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"6px",px:3,py:2,maxW:"280px",transition:"border-color 120ms ease",_hover:e.downloadUrl?{borderColor:o.primaryAction.default}:void 0,children:[n.jsx(f,{width:"28px",height:"28px",borderRadius:"6px",bg:o.surface.secondary,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,children:n.jsx(_r,{width:16,height:16,color:o.text.label})}),n.jsxs(f,{minW:0,children:[n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.text.body,noOfLines:1,children:e.filename}),n.jsx(c,{fontSize:"10.5px",color:o.text.placeholder,noOfLines:1,children:e.downloadUrl?r:`${r?`${r} · `:""}link unavailable`})]})]});return e.downloadUrl?n.jsx(Se,{href:e.downloadUrl,isExternal:!0,rel:"noopener noreferrer",_hover:{textDecoration:"none"},_focusVisible:{outline:`2px solid ${o.primaryAction.default}`,outlineOffset:"1px"},children:t}):t}function go({browserContext:e}){const{t:r}=O(),t=e.networkCaptureStatus==="instrumented"||e.networkCaptureStatus==="resource_timing",i=[e.consoleCaptureStatus==="captured"?r("admin.support.debug.console_error_summary","{count, plural, one {# console error} other {# console errors}}",{count:e.consoleErrorCount}):r("admin.support.debug.console_not_captured_short","console not captured"),t?r("admin.support.debug.resource_timing_summary","{failedCount} known failed · {totalCount} resources · {statusCount} statuses",{failedCount:e.networkFailedCount,totalCount:e.networkTotalCount,statusCount:e.networkStatusCoverageCount}):r("admin.support.debug.network_not_captured_short","network not captured")].join(" · "),s=e.consoleLines.slice(-60),a=e.networkLines.slice(-60);return n.jsxs(f,{as:"details","data-testid":"customer-evidence-browser-context",mt:2,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"6px",bg:o.surface.offWhite,px:3,py:2,children:[n.jsxs(f,{as:"summary",cursor:"pointer",children:[n.jsx(c,{as:"span",fontSize:"12px",fontWeight:"700",color:o.text.body,children:r("admin_support.investigations_customerevidencecard.auto_captured_browser_context_bb4018f8","Auto-captured browser context")}),n.jsx(c,{as:"span",fontSize:oe,fontFamily:"mono",color:o.text.label,ml:2,children:i})]}),n.jsxs(f,{mt:2,children:[e.capturedAtLabel?n.jsxs(c,{fontSize:oe,fontFamily:"mono",color:o.text.label,children:[r("admin_support.investigations_customerevidencecard.captured_d19695c5","captured")," ",e.capturedAtLabel]}):null,e.pageUrl?n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.text.label,wordBreak:"break-all",children:e.pageUrl}):null,e.userAgent?n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.text.placeholder,wordBreak:"break-all",children:e.userAgent}):null,e.displayContext?n.jsxs(n.Fragment,{children:[n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.text.label,children:r("admin.support.debug.dis
12play_geometry","Viewport {viewportWidth}Ã{viewportHeight} CSS px · screen {screenWidth}Ã{screenHeight} CSS px · DPR {devicePixelRatio} · {orientation}",e.displayContext)}),e.displayContext.visualViewportWidth!==null&&e.displayContext.visualViewportHeight!==null?n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.text.label,children:r("admin.support.debug.visual_viewport_geometry","Visual viewport {visualViewportWidth}Ã{visualViewportHeight} CSS px",e.displayContext)}):null,e.displayContext.orientationAngleDegrees!==null?n.jsx(c,{fontSize:oe,fontFamily:"mono",color:o.text.label,children:r("admin.support.debug.orientation_angle","Orientation angle {orientationAngleDegrees}°",e.displayContext)}):null]}):null,e.isSummaryOnly&&(s.length>0||a.length>0)?n.jsx(c,{fontSize:"12px",color:o.text.placeholder,mt:2,children:r("admin_support.investigations_customerevidencecard.only_the_captures_summary_is_on_the_record_the_full_buffer_is_stored_wit_1b47777f","Only the capture's summary is on the record; the full buffer is stored with the conversation.")}):null,e.consoleCaptureStatus!=="captured"?n.jsx(c,{fontSize:"12px",color:o.accentColors.warningStrong,mt:2,children:r("admin.support.debug.console_zero_is_unknown","Console history was not recorded. The zero shown on older reports is unknown, not evidence of no errors.")}):null,t?e.networkStatusCoverageCount<e.networkTotalCount?n.jsx(c,{fontSize:"12px",color:o.text.placeholder,mt:2,children:r("admin.support.debug.network_status_partial","The browser exposed an HTTP status for only {statusCount} of {totalCount} resources. Missing statuses are unknown.",{statusCount:e.networkStatusCoverageCount,totalCount:e.networkTotalCount})}):null:n.jsx(c,{fontSize:"12px",color:o.accentColors.warningStrong,mt:2,children:r("admin.support.debug.network_zero_is_unknown","Network history was not recorded. The zero shown on older reports is unknown, not evidence that requests succeeded.")}),s.length>0?n.jsx(Zt,{label:r("admin_support.investigations_customerevidencecard.console_9f3341d3","Console"),children:s.map(l=>n.jsx(f,{as:"span",display:"block",color:l.isError?o.accentColors.errorStrong:l.isWarning?o.accentColors.warningStrong:o.text.label,children:l.text},l.key))}):null,a.length>0?n.jsx(Zt,{label:r("admin_support.investigations_customerevidencecard.network_53ebc572","Network"),children:a.map(l=>n.jsxs(f,{as:"span",display:"block",color:l.isFailed?o.accentColors.errorStrong:o.text.label,children:[l.text,l.hasUnknownStatus&&!/\bstatus unknown\b/i.test(l.text)?` ${r("admin.support.debug.network_status_unknown","(status unknown)")}`:""]},l.key))}):null,e.fullCaptureUrl?n.jsx(Se,{href:e.fullCaptureUrl,isExternal:!0,rel:"noopener noreferrer",fontSize:"12px",color:o.primaryAction.default,display:"inline-block",mt:2,children:r("admin_support.investigations_customerevidencecard.open_the_full_capture_7f906dd3","Open the full capture")}):null]})]})}function Zt({label:e,children:r}){return n.jsxs(f,{mt:2,children:[n.jsx(c,{fontSize:pt,fontWeight:"700",color:o.text.label,mb:1,children:e}),n.jsx(f,{as:"pre","data-testid":"customer-evidence-ring-buffer",m:0,px:2,py:2,bg:o.surface.background,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"4px",fontFamily:"mono",fontSize:oe,lineHeight:"1.45",maxH:"220px",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",children:r})]})}const _o='a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])';function xo({item:e,position:r,totalCount:t,onClose:i,onStep:s}){const{t:a}=O(),l=h.useRef(null);h.useEffect(()=>{var _;const p=document.activeElement;return(_=l.current)==null||_.focus(),()=>{var b;(b=p==null?void 0:p.focus)==null||b.call(p)}},[]);const d=h.useCallback(p=>{var A;if(p.key==="Escape"){p.preventDefault(),i();return}if(p.key==="ArrowRight"){p.preventDefault(),s(1);return}if(p.key==="ArrowLeft"){p.preventDefault(),s(-1);return}if(p.key!=="Tab")return;p.preventDefault();const _=l.current;if(!_)return;const b=Array.from(_.querySelectorAll(_o));if(b.length===0)return;const g=b.indexOf(document.activeElement),m=p.shiftKey?-1:1,x=(g+m+b.length)%b.length;(A=b[x])==null||A.focus()},[i,s]),u=t>1;return n.jsx(f,{ref:l,role:"dialog","aria-modal":"true","aria-label":`Customer evidence viewer: ${e.filename}`,tabIndex:-1,onKeyDown:d,onClick:i,position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:1400,bg:Ui,display:"flex",alignItems:"center",justifyContent:"center",p:6,children:n.jsxs(v,{direction:"column",align:"center",gap:3,maxW:"100%",maxH:"100%",onClick:p=>p.stopPropagation(),children:[n.jsxs(v,{align:"center",gap:3,width:"100%",justify:"space-between",children:[n.jsxs(c,{fontSize:oe,fontFamily:"mono",color:o.text.white,wordBreak:"break-all",children:[e.filename,e.caption?` · ${e.caption}`:""]}),n.jsxs(v,{align:"center",gap:2,flexShrink:0,children:[n.jsxs(c,{fontSize:oe,fontFamily:"mono",color:o.text.inactive,children:[r," / ",t]}),n.jsx(Jt,{label:a("admin_support.investigations_customerevidencecard.previous_evidence_item_8044a294","Previous evidence item"),glyph:"â¹",isDisabled:!u,onClick:()=>s(-1)}),n.jsx(Jt,{label:a("admin_support.investigations_customerevidencecard.next_evidence_item_89438f91","Next evidence item"),glyph:"âº",isDisabled:!u,onClick:()=>s(1)}),n.jsx(f,{as:"button",type:"button",onClick:i,"aria-label":a("admin_support.investigations_customerevidencecard.close_evidence_viewer_e0af7373","Close evidence viewer"),display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",borderRadius:"6px",bg:o.surface.white,_focusVisible:{outline:`2px solid ${o.primaryAction.default}`,outlineOffset:"2px"},children:n.jsx(jr,{width:12,height:12,color:o.text.body})})]})]}),n.jsx(Tn,{src:e.imageUrl,alt:e.filename,maxW:"100%",maxH:"72vh",objectFit:"contain",borderRadius:"6px",bg:o.surface.white}),n.jsx(Se,{href:e.imageUrl,isExternal:!0,rel:"noopener noreferrer",fontSize:"12px",color:o.text.white,textDecoration:"underline",children:a("admin_support.investigations_customerevidencecard.open_the_original_b639d9aa","Open the original")})]})})}function Jt({label:e,glyph:r,isDisabled:t,onClick:i}){return n.jsx(f,{as:"button",type:"button",onClick:i,"aria-label":e,disabled:t,display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",borderRadius:"6px",bg:o.surface.white,color:o.text.body,opacity:t?.4:1,cursor:t?"not-allowed":"pointer",fontSize:"16px",lineHeight:"1",_focusVisible:{outline:`2px solid ${o.primaryAction.default}`,outlineOffset:"2px"},children:r})}const ge=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},P=e=>typeof e=="string"?e.trim():"",Qt=ze.memo(function({investigation:r}){const{t}=O(),i=V=>V==="conductor_incident_v1"?t("admin.support.engineering.conductor_investigation_fix_8d9b2b","Conductor · investigation + fix"):V==="worker_investigator"?t("admin.support.engineering.worker_investigator_separate_fixer_96fafa","Worker investigator · separate fixer"):t("admin.support.engineering.not_recorded_b37c78","Not recorded"),s={existing_incident_owner:t("admin.support.engineering.continuing_the_existing_conductor_case_00c9d4","Continuing the existing Conductor case"),automation_disabled:t("admin.support.engineering.support_automation_is_disabled_6438d9","Support automation is disabled"),incident_intake_disabled:t("admin.support.engineering.conductor_incident_intake_is_disabled_6e7426","Conductor incident intake is disabled"),cutover_not_configured:t("admin.support.engineering.the_incident_cutover_date_is_not_configured_18d0ef","The incident cutover date is not configured"),case_predates_cutover:t("admin.support.engineering.this_case_predates_the_incident_cutover_b758d7","This case predates the incident cutover"),outside_incident_cohort:t("admin.support.engineering.this_customer_is_outside_the_incident_cohort_b1ee08","This customer is outside the incident cohort"),existing_legacy_work:t("admin.support.engineering.existing_worker_investigation_is_retained_cd889b","Existing Worker investigation is retained"),missing_incident_configuration:t("admin.support.engineering.conductor_configuration_was_incomplete_at_routing_7c8be6","Conductor configuration was incomplete at routing"),invalid_or_expired_computer_qualification:t("admin.support.engineering.conductor_qualification_was_invali
12d_or_expired_at_routing_a5b677","Conductor qualification was invalid or expired at routing"),incident_cohort_selected:t("admin.support.engineering.selected_for_the_conductor_incident_cohort_5044c0","Selected for the Conductor incident cohort")},a=ge(r.engineering_status);if(!Object.keys(a).length)return null;const l=ge(a.recorded_selection),d=ge(a.current_configuration),u=ge(a.readiness),p=ge(a.report),_=ge(p.diagnostic_plan),b=ge(p.scope_request),g=ge(p.patch),m=ge(a.execution),x=r.engineering_runtime==="conductor_incident_v1",A=P(m.status==="available"?m.workspace_id:Object.keys(m).length===0?p.workspace_id:null),y=A&&/^[A-Za-z0-9_-]+$/.test(A)?`conductor://workspace?id=${encodeURIComponent(A)}`:null,w={queued:t("admin.support.engineering.waiting_for_an_engineer_79b02c","Waiting for an engineer"),provisioning:t("admin.support.engineering.starting_the_conductor_workspace_e70237","Starting the Conductor workspace"),investigating:t("admin.support.engineering.investigating_13e386","Investigating"),reproducing:t("admin.support.engineering.reproducing_the_issue_50d199","Reproducing the issue"),implementing:t("admin.support.engineering.implementing_a_fix_58e4d0","Implementing a fix"),review:t("admin.support.engineering.reviewing_the_change_387f93","Reviewing the change"),waiting_for_merge:t("admin.support.engineering.waiting_for_merge_b4394c","Waiting for merge"),deployment_watch:t("admin.support.engineering.watching_deployment_f92cf7","Watching deployment"),verification:t("admin.support.engineering.verifying_the_customer_journey_2b0b6d","Verifying the customer journey"),paused:t("admin.support.engineering.engineering_paused_b19950","Engineering paused"),cancelled:t("admin.support.engineering.engineering_stopped_e3f164","Engineering stopped"),failed:t("admin.support.engineering.engineering_failed_9667b5","Engineering failed")},k=ge(p.release_watch),S={review:t("admin.support.engineering.reviewing_the_pull_request_5e0e3b","Reviewing the pull request"),correcting:t("admin.support.engineering.addressing_review_feedback_1d211b","Addressing review feedback"),waiting_for_merge:t("admin.support.engineering.waiting_for_merge_b4394c","Waiting for merge"),deployment_watch:t("admin.support.engineering.watching_deployment_and_verification_9c3283","Watching deployment and verification"),needs_attention:t("admin.support.engineering.release_needs_attention_bb463a","Release needs attention"),closed:t("admin.support.engineering.pull_request_closed_2babc5","Pull request closed"),verified:t("admin.support.engineering.customer_journey_verified_db9794","Customer journey verified")},E=m.status==="available"&&m.report_is_current===!0&&!["cancelled","failed"].includes(P(m.phase))&&k.revision===m.revision?S[P(k.phase)]:null,j=m.status==="unavailable"?t("admin.support.engineering.live_engineering_status_is_temporarily_unavailable_173b41","Live engineering status is temporarily unavailable"):m.status==="pending"?t("admin.support.engineering.waiting_for_the_conductor_workspace_6769c5","Waiting for the Conductor workspace"):E||w[P(m.phase)]||t("admin.support.engineering.live_engineering_status_is_not_recorded_56bb8d","Live engineering status is not recorded"),C=m.status==="available"&&m.report_is_current===!1,I=x&&m.status!=="available",$=P(g.repository),F=/^Jungle-Learning\/(jungle-backend|jungle-web|jungle-mobile)$/.test($)&&Number.isSafeInteger(g.number)&&Number(g.number)>0?`https://github.com/${$}/pull/${g.number}`:null,B=Object.keys(l).length>0,re=B?l:d,W=P(l.model),z=p.change_kind==="instrumentation",Z=p.production_verified===!0,q=Object.keys(g).length>0,de=p.resolution_kind==="explained",se=!!(P(p.id)||P(p.summary)||p.change_kind||p.resolution_kind||q),ae=()=>C&&se?t("admin.support.engineering.previous_report_awaiting_updated_findings_d89743","Previous report · awaiting updated findings"):I&&se?t("admin.support.engineering.saved_report_current_status_unavailable_ae18b5","Saved report · current status unavailable"):z?t("admin.support.engineering.instrumentation_only_diagnosis_remains_open_6488ae","Instrumentation only · diagnosis remains open"):Z?t("admin.support.engineering.restoration_independently_verified_5028f9","Restoration independently verified"):q?g.state==="merged"?t("admin.support.engineering.patch_merged_restoration_unverified_192439","Patch merged · restoration unverified"):g.state==="closed"?t("admin.support.engineering.pull_request_closed_restoration_unverified_6f0cf2","Pull request closed · restoration unverified"):t("admin.support.engineering.patch_prepared_restoration_unverified_2c62f2","Patch prepared · restoration unverified"):de?t("admin.support.engineering.explanation_reported_a57906","Explanation reported"):se?t("admin.support.engineering.diagnosis_in_progress_895033","Diagnosis in progress"):t("admin.support.engineering.not_recorded_for_this_run_c52361","Not recorded for this run"),we=[[t("admin.support.engineering.runtime_109311","Runtime"),B?i(l.runtime):t("admin.support.engineering.not_recorded_for_this_run_c52361","Not recorded for this run")],[t("admin.support.engineering.model_5e2c61","Model"),W?`${W}${P(l.effort)?` · ${P(l.effort)} effort`:""}`:t("admin.support.engineering.not_recorded_for_this_run_c52361","Not recorded for this run")],[B?t("admin.support.engineering.routing_reason_2a30e4","Routing reason"):t("admin.support.engineering.current_routing_configuration_fd
1274ff","Current routing configuration"),s[P(re.reason)]||t("admin.support.engineering.not_recorded_b37c78","Not recorded")],...!B&&P(d.model)?[[t("admin.support.engineering.current_model_default_c96979","Current model default"),P(d.model)]]:[],[t("admin.support.engineering.progress_466482","Progress"),ae()]];return n.jsxs(f,{as:"section","aria-label":t("admin.support.engineering.engineering_execution_fe7047","Engineering execution"),borderTopWidth:"1px",borderColor:o.surface.border,pt:3,mt:3,mb:3,children:[n.jsxs(v,{align:"center",justify:"space-between",gap:3,wrap:"wrap",mb:2,children:[n.jsx(c,{fontSize:"13px",fontWeight:"700",color:o.text.body,children:x?t("admin.support.engineering.investigation_fix_in_conductor_64bf3c","Investigation & fix in Conductor"):t("admin.support.engineering.engineering_execution_fe7047","Engineering execution")}),y&&n.jsx(Se,{href:y,fontSize:"13px",fontWeight:"700",color:o.primaryAction.default,textDecoration:"underline",_focusVisible:{outline:"2px solid",outlineOffset:"3px"},children:t("admin.support.engineering.open_in_conductor_b32559","Open in Conductor")})]}),x&&n.jsxs(f,{mb:3,children:[n.jsx(c,{fontSize:"13px",fontWeight:"600",color:o.text.body,children:j}),P(m.suspension_reason)&&n.jsx(c,{mt:1,fontSize:"12px",color:o.text.label,children:m.suspension_reason==="waiting_for_customer"?t("admin.support.engineering.waiting_customer","Waiting for the customer's answer."):m.suspension_reason==="waiting_for_operator"?t("admin.support.engineering.waiting_operator","Waiting for an operator action. See the investigation dependencies below."):m.suspension_reason==="waiting_for_release"?t("admin.support.engineering.waiting_release","Engineering report received; release or verification is pending."):m.suspension_reason==="report_complete"?t("admin.support.engineering.report_complete","Engineering report received."):m.suspension_reason==="human_takeover"?t("admin.support.engineering.human_takeover","A teammate has taken over this case."):m.suspension_reason==="agent_stalled"?t("admin.support.engineering.the_engineer_stopped_making_progress_afcfeb","The engineer stopped making progress."):m.suspension_reason==="lease_expired"?t("admin.support.engineering.the_engineer_stopped_reporting_its_status_ab1b9f","The engineer stopped reporting its status."):m.suspension_reason==="window_expired"?t("admin.support.engineering.this_engineering_attempt_reached_its_time_limit_1d82cc","This engineering attempt reached its time limit."):""}),n.jsx(c,{mt:1,fontSize:"12px",color:o.text.label,children:t("admin.support.engineering.follow_the_engineering_work_and_chat_with_the_engineer_in_conduct_5a0d62","Follow the engineering work and chat with the engineer in Conductor. Customer replies stay in Threads.")}),!y&&n.jsx(c,{mt:1,fontSize:"12px",color:o.text.label,children:t("admin.support.engineering.the_conductor_link_appears_when_a_workspace_has_been_assigned_555057","The Conductor link appears when a workspace has been assigned.")})]}),Array.isArray(p.operator_dependencies)&&p.operator_dependencies.length>0&&n.jsxs(f,{mb:3,children:[n.jsx(c,{fontSize:"13px",fontWeight:"600",color:o.text.body,children:t("admin.support.engineering.internal_dependencies","Internal diagnostic follow-up")}),p.operator_dependencies.map((V,te)=>{const K=ge(V);return n.jsxs(c,{mt:1,fontSize:"12px",color:o.text.label,overflowWrap:"anywhere",children:[P(K.tool),": ",P(K.problem),". ",P(K.nextAction)]},te)})]}),n.jsx(f,{as:"dl",m:0,children:we.map(([V,te])=>n.jsxs(An,{templateColumns:{base:"1fr",sm:"150px minmax(0, 1fr)"},columnGap:3,rowGap:.5,mb:{base:2,sm:1},alignItems:"baseline",children:[n.jsx(c,{as:"dt",minW:"150px",fontSize:"12px",color:o.text.label,children:V}),n.jsx(c,{as:"dd",m:0,fontSize:"12px",color:o.text.body,overflowWrap:"anywhere",children:te})]},V))}),u.ready===!1&&n.jsx(c,{mt:2,fontSize:"12px",color:o.accentColors.warningStrong,children:u.reason==="missing_incident_configuration"?t("admin.support.engineering.dedicated_conductor_setup_is_incomplete_def31f","Dedicated Conductor setup is incomplete."):u.reason==="invalid_or_expired_computer_qualification"?t("admin.support.engineering.dedicated_conductor_qualification_is_invali
12d_or_expired_8aa435","Dedicated Conductor qualification is invalid or expired."):t("admin.support.engineering.dedicated_conductor_setup_is_not_ready_the_reason_was_not_recorde_4d22d2","Dedicated Conductor setup is not ready; the reason was not recorded.")}),se&&n.jsxs(f,{mt:3,fontSize:"12px",color:o.text.body,children:[n.jsx(c,{fontWeight:"700",children:C?t("admin.support.engineering.previous_engineering_report_e582e5","Previous engineering report"):t("admin.support.engineering.engineering_report_56f427","Engineering report")}),n.jsx(c,{mt:1,whiteSpace:"pre-wrap",overflowWrap:"anywhere",children:P(p.summary)}),F&&n.jsx(Se,{href:F,isExternal:!0,color:o.primaryAction.default,display:"inline-block",mt:2,textDecoration:"underline",children:t("admin.support.engineering.open_pull_request_439996","Open pull request")}),[[t("admin.support.engineering.evidence_03867a","Evidence"),p.evidence],[t("admin.support.engineering.tests_e5c9d7","Tests"),p.tests],[t("admin.support.engineering.missing_evidence_d54d5b","Missing evidence"),p.missing_evidence]].map(([V,te])=>Array.isArray(te)&&te.some(K=>P(K))?n.jsxs(f,{mt:2,children:[n.jsx(c,{fontWeight:"600",children:V}),n.jsx(f,{as:"ul",pl:4,m:0,children:te.filter(K=>P(K)).map((K,xe)=>n.jsx(c,{as:"li",overflowWrap:"anywhere",children:P(K)},xe))})]},V):null)]}),Object.keys(_).length>0&&n.jsxs(f,{mt:3,fontSize:"12px",color:o.text.body,overflowWrap:"anywhere",children:[n.jsx(c,{fontWeight:"700",children:t("admin.support.engineering.diagnosis_recheck_plan_f28b15","Diagnosis recheck plan")}),[[t("admin.support.engineering.question_289aff","Question"),_.unansweredQuestion],[t("admin.support.engineering.signal_1e9806","Signal"),_.expectedSignal],[t("admin.support.engineering.recheck_when_e685e9","Recheck when"),_.recheckTrigger],[t("admin.support.engineering.owner_4b1b8a","Owner"),_.owner]].map(([V,te])=>P(te)&&n.jsxs(c,{mt:1,children:[n.jsxs("strong",{children:[P(V),t("admin.support.engineering._e7ac07",":")]})," ",P(te)]},P(V))),Array.isArray(_.reproductionAttempts)&&_.reproductionAttempts.filter(V=>P(V)).map((V,te)=>n.jsxs(c,{mt:1,children:[t("admin.support.engineering.attempt_a3d3a0","Attempt:")," ",P(V)]},te))]}),P(b.action)&&n.jsxs(f,{mt:3,fontSize:"12px",color:o.text.body,overflowWrap:"anywhere",children:[n.jsx(c,{fontWeight:"700",children:t("admin.support.engineering.requested_operator_action_e2b64b","Requested operator action")}),n.jsx(c,{children:P(b.action)}),n.jsx(c,{children:P(b.reason)})]})]})}),bo=1200*1e3,yo={conductor:"Conductor",github_actions:"GitHub Actions"},vo={not_started:"neutral",starting:"warning",running:"warning",succeeded:"positive",failed:"negative",cancelled:"neutral"},So=new Set(["starting","running"]),Kn=ue` 13 0%, 100% { opacity: 0.4; } 14 50% { opacity: 1; } 15`,wo=ue` 16 from { opacity: 0; transform: translateY(4px); } 17 to { opacity: 1; transform: translateY(0); } 18`,Et={"@media (prefers-reduced-motion: reduce)":{animation:"none"}};function jo({fixer:e,investigationId:r}){const{t}=O(),i=Gn(e);if(!i)return null;const s=tn(i.status),a=So.has(s),l=me(vo[s]??"neutral"),d=ri(Y(i.status))||"Status not recorded",u=Y(i.runtime),p=yo[tn(u)]??(u&&u!=="unknown"?X(u):t("admin.support.follow_up.not_recorded","Not recorded")),_=Y(i.run_id),b=Y(i.workspace_url),g=Ne(b),m=Y(i.pr_url),x=Ne(m),A=Y(i.tests_run),y=Y(i.verdict),w=Y(i.notes),k=To(i.lessons),S=Eo(i.milestones),L=Ao(i.attempt),E=L!==null&&L>1?Math.floor(L):null,j=Date.now(),C=Y(i.started_at),I=ve(C),$=it(C),T=Y(i.finished_at),F=ve(T),re=it(T)??j,W=$!==null&&re>=$?dt(re-$):"",z=!!(Y(i.change_ownership_status)||Y(i.change_ownership_reason)||Y(i.duplicate_of_pull_request_url)),Z=!!(_||g||x||C||A||y||S.length);if(z&&s==="not_started"&&!Z)return null;const de=Y(i.last_activity_at),se=it(de),ae=se!==null&&j>se?j-se:null,we=a&&ae!==null&&ae>bo,V=!!(m||A||y||w),te=`fixer-card-heading-${Y(r)||"unknown"}`;return n.jsxs(f,{as:"section","aria-labelledby":te,bg:o.surface.white,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"8px",p:4,mb:3,animation:`${wo} 220ms ease-out both`,sx:Et,children:[n.jsxs(v,{align:"flex-start",justify:"space-between",gap:3,wrap:"wrap",children:[n.jsxs(f,{minW:0,children:[n.jsx(Ye,{children:t("admin_support.investigations_fixercard.fixer_7397423e","Fixer")}),n.jsxs(v,{align:"baseline",gap:2,wrap:"wrap",children:[n.jsx(c,{as:"h3",id:te,fontSize:"15px",fontWeight:"800",color:o.text.header,children:p}),_?n.jsx(c,{fontSize:"11px",fontFamily:"mono",color:o.text.placeholder,title:_,wordBreak:"break-all",children:Te(_)}):null]}),n.jsx(Co,{segments:[I?{label:t("admin.support.investigations.fixer.started","Started"),machineValue:I,title:ot(C)}:{label:t("admin.support.investigations.fixer.start_time_not_recorded","Start time not recorded")},W?{label:a?t("admin.support.investigations.fixer.running_for","running for"):t("admin.support.investigations.fixer.took","took"),machineValue:W}:{label:""},!a&&F?{label:t("admin.support.investigations.fixer.finished","finished"),machineValue:F,title:ot(T)}:{label:""}]})]}),n.jsxs(v,{align:"center",gap:2,flexShrink:0,children:[n.jsxs(v,{align:"center",gap:1.5,bg:l.backgroundColor,color:l.textColor,borderRadius:"full",px:2.5,py:1,children:[a?n.jsx(f,{w:"6px",h:"6px",borderRadius:"full",bg:"currentColor",flexShrink:0,"aria-hidden":"true",animation:`${Kn} 1.8s ease-in-out infinite`,sx:Et}):null,n.jsx(c,{fontSize:"11px",fontWeight:"700",whiteSpace:"nowrap",children:d})]}),g?n.jsxs(fe,{as:"a",href:b,target:"_blank",rel:"noopener noreferrer",size:"sm",colorScheme:"green",fontSize:"12.5px",children:[u&&u!=="unknown"?`${t("admin_support.investigations_fixercard.open_in_f03b6f67","Open in")} ${p}`:t("admin.support.follow_up.open_workspace","Open workspace"),n.jsx(f,{as:"span","aria-hidden":"true",ml:1.5,children:"â"})]}):n.jsx(fe,{size:"sm",colorScheme:"green",fontSize:"12.5px",isDisabled:!0,children:u&&u!=="unknown"?`${t("admin_support.investigations_fixercard.open_in_f03b6f67","Open in")} ${p}`:t("admin.support.follow_up.open_workspace","Open workspace")})]})]}),g?null:n.jsx(c,{fontSize:"11.5px",color:o.text.placeholder,mt:2,children:t("admin_support.investigations_fixercard.no_workspace_link_was_recorded_for_this_run_so_there_is_nothing_to_take_6cc9a709","No workspace link was recorded for this run, so there is nothing to take over yet.")}),E!==null?n.jsxs(v,{align:"baseline",gap:2,wrap:"wrap",mt:3,px:3,py:2,borderRadius:"6px",bg:o.accentColors.warningLight,children:[n.jsxs(c,{fontSize:"11px",fontWeight:"700",fontFamily:"mono",color:o.accentColors.warningStrong,children:[t("admin_support.investigations_fixercard.attempt_38e4e4b0","attempt")," ",E]}),n.jsx(c,{fontSize:"12px",color:o.text.body,lineHeight:"1.4",children:t("admin_support.investigations_fixercard.an_earlier_fix_was_reverted_after_production_verification_failed_and_the_a274865a","An earlier fix was reverted after production verification failed, and the Fixer restarted from the revert.")})]}):null,S.length>0?n.jsxs(f,{mt:3,children:[n.jsx(Ye,{children:t("admin_support.investigations_fixercard.milestones_e7bdefe8","Milestones")}),n.jsxs(f,{as:"ol",listStyleType:"none",m:0,p:0,mt:2,children:[S.map((K,xe)=>n.jsx(en,{milestone:K,isLastRow:!a&&xe===S.length-1},`${K.name}-${K.at}-${xe}`)),a?n.jsx(en,{milestone:{name:t("admin.support.investigations.fixer.still_working","still working"),at:""},isLastRow:!0,isPending:!0}):null]})]}):a?n.jsx(c,{fontSize:"12px",color:o.text.placeholder,mt:3,children:t("admin_support.investigations_fixercard.no_milestones_reported_yet_the_poller_records_one_when_the_run_hits_a_re_314b9da8","No milestones reported yet. The poller records one when the run hits a repro, a red test, a green test or an open pull request.")}):null,a?n.jsx(v,{align:"baseline",gap:2,wrap:"wrap",mt:3,px:3,py:2,borderRadius:"6px",bg:we?o.accentColors.warningLight:o.surface.background,role:we?"status":void 0,children:we&&ae!==null?n.jsxs(n.Fragment,{children:[n.jsxs(c,{fontSize:"12px",fontWeight:"700",color:o.accentColors.warningStrong,children:[t("admin_support.investigations_fixercard.quiet_for_496ce0fd","Quiet for")," ",n.jsx(c,{as:"span",fontFamily:"mono",fontSize:"11.5px",children:dt(ae)})]}),n.jsx(c,{fontSize:"12px",color:o.text.body,lineHeight:"1.4",children:t("admin_support.investigations_fixercard.no_new_milestone_commit_or_tool_call_in_that_time_worth_o
18pening_the_work_e8bdaa4a","No new milestone, commit or tool call in that time. Worth opening the workspace.")})]}):de?n.jsxs(c,{fontSize:"12px",color:o.text.label,title:ot(de),children:[t("admin_support.investigations_fixercard.last_activity_1c73b806","Last activity")," ",n.jsx(c,{as:"span",fontFamily:"mono",fontSize:"11.5px",children:ve(de)||de})]}):n.jsx(c,{fontSize:"12px",color:o.text.label,children:t("admin_support.investigations_fixercard.no_activity_has_been_reported_for_this_run_yet_9cdb15da","No activity has been reported for this run yet.")})}):null,V?n.jsxs(f,{mt:3,pt:3,borderTopWidth:"1px",borderColor:o.surface.border,children:[n.jsx(Ye,{children:t("admin_support.investigations_fixercard.close_out_61151c47","Close-out")}),n.jsxs(f,{mt:2,children:[x?n.jsxs(fe,{as:"a",href:m,target:"_blank",rel:"noopener noreferrer",size:"xs",variant:"outline",fontFamily:"mono",fontSize:"11.5px",mb:2,children:[ko(m),n.jsx(f,{as:"span","aria-hidden":"true",ml:1.5,children:"â"})]}):m?n.jsx(Xe,{label:t("admin_support.investigations_fixercard.pull_request_881e7431","Pull request"),value:m,isMachineText:!0}):null,n.jsx(Xe,{label:t("admin_support.investigations_fixercard.tests_39fdec11","Tests"),value:A,isMachineText:!0}),n.jsx(Xe,{label:t("admin_support.investigations_fixercard.verdict_7f6e5a6e","Verdict"),value:y}),n.jsx(Xe,{label:t("admin_support.investigations_fixercard.notes_70440046","Notes"),value:w})]})]}):null,k.length>0?n.jsxs(f,{mt:3,pt:3,borderTopWidth:"1px",borderColor:o.surface.border,children:[n.jsx(Ye,{children:t("admin_support.investigations_fixercard.what_this_run_taught_us_90a93847","What this run taught us")}),n.jsx(f,{as:"ul",listStyleType:"none",m:0,p:0,mt:2,children:k.map((K,xe)=>n.jsxs(v,{as:"li",align:"flex-start",gap:2,mb:1.5,children:[n.jsx(f,{as:"span","aria-hidden":"true",color:o.text.inactive,fontSize:"12px",lineHeight:"1.5",children:"â¢"}),n.jsx(c,{fontSize:"13px",color:o.text.body,lineHeight:"1.5",children:K})]},`${K}-${xe}`))})]}):null]})}function Ye({children:e}){return n.jsx(c,{fontSize:"10.5px",fontWeight:"700",textTransform:"uppercase",color:o.text.label,children:e})}function Co({segments:e}){const r=e.filter(t=>t.label);return r.length===0?null:n.jsx(v,{align:"baseline",gap:1.5,wrap:"wrap",mt:1,children:r.map((t,i)=>n.jsxs(ze.Fragment,{children:[i>0?n.jsx(c,{fontSize:"11px",color:o.text.inactive,"aria-hidden":"true",children:"·"}):null,n.jsxs(c,{fontSize:"12px",color:o.text.label,title:t.title||void 0,children:[t.label,t.machineValue?n.jsxs(n.Fragment,{children:[" ",n.jsx(c,{as:"span",fontFamily:"mono",fontSize:"11.5px",children:t.machineValue})]}):null]})]},`${t.label}-${t.machineValue??""}`))})}function en({milestone:e,isLastRow:r,isPending:t}){const i=ve(e.at);return n.jsxs(v,{as:"li",align:"stretch",gap:2.5,pb:r?0:2,children:[n.jsxs(v,{direction:"column",align:"center",flexShrink:0,pt:"5px",children:[n.jsx(f,{w:"7px",h:"7px",borderRadius:"full",flexShrink:0,bg:t?"transparent":o.primaryAction.default,borderWidth:t?"1.5px":void 0,borderColor:t?o.accentColors.warningStrong:void 0,animation:t?`${Kn} 1.8s ease-in-out infinite`:void 0,sx:t?Et:void 0}),r?null:n.jsx(f,{flex:"1",w:"1px",minH:"10px",mt:"2px",bg:o.surface.border})]}),n.jsxs(v,{flex:"1",minW:0,align:"baseline",justify:"space-between",gap:3,children:[n.jsx(c,{fontSize:"12.5px",color:t?o.text.label:o.text.body,lineHeight:"1.35",children:X(e.name)||e.name}),i?n.jsx(c,{fontSize:"11px",fontFamily:"mono",color:o.text.placeholder,title:ot(e.at),whiteSpace:"nowrap",children:i}):null]})]})}function Xe({label:e,value:r,isMachineText:t}){return r?n.jsxs(v,{align:"baseline",gap:2,mb:1.5,wrap:"wrap",children:[n.jsx(c,{fontSize:"10.5px",fontWeight:"700",textTransform:"uppercase",color:o.text.label,minW:"52px",children:e}),n.jsx(c,{fontSize:t?"12px":"13px",fontFamily:t?"mono":void 0,color:o.text.body,lineHeight:"1.45",whiteSpace:"pre-wrap",wordBreak:"break-word",children:r})]}):null}function ko(e){const r=/\/pull\/(\d+)/.exec(e);return r?`Pull request #${r[1]}`:"Pull request"}function Gn(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function Y(e){return typeof e=="string"?e.trim():""}function Ao(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const r=Number(e);if(Number.isFinite(r))return r}return null}function tn(e){return typeof e!="string"?"":e.trim().toLowerCase().replace(/[\s-]+/g,"_")}function To(e){if(Array.isArray(e))return e.map(t=>Y(t)).filter(t=>t.length>0);const r=Y(e);return r?[r]:[]}function Eo(e){if(!Array.isArray(e))return[];const r=[];for(const t of e){const i=Gn(t),s=i?Y(i.name)||Y(i.milestone)||Y(i.label):Y(t);if(!s)continue;const a=i?Y(i.at)||Y(i.timestamp):"";r.push({name:s,at:a})}return r}function it(e){const r=Y(e);if(!r)return null;const t=Date.parse(r);return Number.isFinite(t)?t:null}function ot(e){const r=it(e);
18return r===null?"":new Date(r).toLocaleString()}const nn="8px",Io=lt("file").glyph,Lo=ue` 19 from { opacity: 0; transform: translateY(3px); } 20 to { opacity: 1; transform: translateY(0); } 21`,rn={w:"100%",align:"center",justify:"space-between",gap:3,px:4,py:3};function Yn(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function Xn(e){return typeof e!="string"?"":e.trim().toLowerCase().replace(/[\s-]+/g,"_")}function ft(e,r){for(const t of r){const i=e[t];if(typeof i=="string"&&i.trim())return i.trim()}return""}const Ro=new Set(["high","medium","low"]);function zo(e){for(const r of["confidence","confidence_level"]){const t=Xn(e[r]);if(Ro.has(t))return t}return null}const No=new Set(["confirmed","confirm","proven","verified","validated","true","supported"]),Mo=new Set(["killed","kill","ruled_out","refuted","disproven","disproved","falsified","rejected","eliminated","false"]);function Fo(e){const r=ft(e,["status","state","verdict","outcome","result"]),t=Xn(r);if(No.has(t))return{resolution:"confirmed",resolutionLabel:"confirmed"};if(Mo.has(t))return{resolution:"killed",resolutionLabel:"killed"};for(const i of["confirmed","is_confirmed","was_confirmed"])if(e[i]===!0)return{resolution:"confirmed",resolutionLabel:"confirmed"};for(const i of["killed","is_killed","ruled_out","was_ruled_out","disproven"])if(e[i]===!0)return{resolution:"killed",resolutionLabel:"killed"};return r?{resolution:"open",resolutionLabel:X(r).toLowerCase()}:{resolution:"open",resolutionLabel:"open"}}function Wo(e){const r=Array.isArray(e)?e:[e],t=[];for(const i of r){if(typeof i=="string"){for(const u of i.split(` 22`)){const p=u.trim();p&&t.push(p)}continue}const s=Yn(i);if(!s)continue;const a=ft(s,["file","path","file_path","location","ref"]);if(!a)continue;const l=s.line??s.line_number,d=typeof l=="number"&&Number.isFinite(l)||typeof l=="string"&&l.trim().length>0;t.push(d&&!/:\d+$/.test(a)?`${a}:${String(l).trim()}`:a)}return Array.from(new Set(t))}function $o(e,r){if(typeof e=="string"){const p=e.trim();return p?{originalIndex:r,rank:r+1,statement:p,confidence:null,falsifiablePrediction:"",codeSuspects:[],resolution:"open",resolutionLabel:"open"}:null}const t=Yn(e);if(!t)return null;const i=ft(t,["falsifiable_prediction","prediction","if_true","what_would_confirm_or_kill"]),s=ft(t,["statement","hypothesis","title","description","summary"])||i;if(!s)return null;const a=t.rank??t.order,l=typeof a=="number"&&Number.isFinite(a)&&a>0,{resolution:d,resolutionLabel:u}=Fo(t);return{originalIndex:r,rank:l?a:r+1,statement:s,confidence:zo(t),falsifiablePrediction:i===s?"":i,codeSuspects:Wo(t.code_suspects??t.suspects??t.files),resolution:d,resolutionLabel:u}}const Zn=h.memo(({hypotheses:e,hasRootCause:r})=>{const{t}=O(),[i,s]=h.useState(()=>!r),a=h.useId(),l=h.useId(),d=Array.isArray(e)?e:[],u=d.map((g,m)=>$o(g,m)).filter(g=>g!==null).sort((g,m)=>g.rank-m.rank||g.originalIndex-m.originalIndex),p=d.length-u.length;if(d.length===0)return null;const _=u.length>0,b=i||!_;return n.jsxs(f,{as:"section","aria-labelledby":l,bg:o.surface.white,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"8px",mb:3,overflow:"hidden",children:[_?n.jsxs(v,{as:"button",type:"button",onClick:()=>s(g=>!g),"aria-expanded":i,"aria-controls":a,...rn,cursor:"pointer",textAlign:"left",_hover:{bg:o.surface.primary},_focusVisible:{boxShadow:`inset 0 0 0 2px ${o.primaryAction.default}`},transition:"background 120ms ease",children:[n.jsx(on,{headingElementId:l,readableCount:u.length}),n.jsxs(v,{align:"center",gap:1.5,flexShrink:0,children:[n.jsx(c,{fontSize:"11px",fontWeight:"700",color:o.text.label,children:i?t("admin.support.hide","Hide"):t("admin.support.show","Show")}),n.jsx(c,{"aria-hidden":"true",fontSize:"10px",color:o.text.placeholder,transform:i?"rotate(90deg)":void 0,transition:"transform 140ms ease",children:"â¸"})]})]}):n.jsx(v,{...rn,children:n.jsx(on,{headingElementId:l,readableCount:u.length})}),b?n.jsxs(f,{id:a,px:4,pb:4,pt:1,children:[u.length>0?n.jsx(f,{as:"ol",listStyleType:"none",m:0,p:0,children:u.map((g,m)=>n.jsx(Oo,{hypothesis:g,rowIndex:m},`${g.originalIndex}-${g.rank}`))}):null,p>0?n.jsx(c,{fontSize:"11.5px",color:o.text.placeholder,mt:u.length>0?3:0,children:t("admin.support.investigations.unreadable_hypotheses","{count, plural, one {# more hypothesis was recorded in a shape this view could not read.} other {# more hypotheses were recorded in a shape this view could not read.}}",{count:p})}):null]}):null]})});Zn.displayName="HypothesesCard";function on({headingElementId:e,readableCount:r}){const{t}=O();return n.jsxs(v,{align:"baseline",gap:2,minW:0,children:[n.jsx(c,{id:e,fontSize:"11px",fontWeight:"800",textTransform:"uppercase",letterSpacing:"0.06em",color:o.text.label,children:t("admin_support.investigations_hypothesescard.hypotheses_564b7df3","Hypotheses")}),n.jsx(c,{fontSize:"11px",fontFamily:"mono",color:o.text.label,children:r})]})}function Oo({hypothesis:e,rowIndex:r}){const{t}=O(),i=e.resolution==="killed",s=e.resolution==="confirmed"?o.accentColors.successStrong:i?o.surface.tertiary:o.surface.border;return n.jsx(f,{as:"li",borderLeftWidth:"2px",borderColor:s,pl:3,py:2.5,_notLast:{mb:1.5},sx:{animation:`${Lo} 200ms ease-out both`,animationDelay:`${Math.min(r,6)*30}ms`,"@media (prefers-reduced-motion: reduce)":{animation:"none"}}
22,children:n.jsxs(v,{align:"flex-start",gap:2.5,children:[n.jsx(c,{fontSize:"11px",fontFamily:"mono",fontWeight:"700",color:o.text.label,lineHeight:"1.5",mt:"1px",flexShrink:0,children:e.rank}),n.jsxs(f,{flex:"1",minW:0,children:[n.jsxs(v,{align:"flex-start",justify:"space-between",gap:3,children:[n.jsx(c,{fontSize:"13.5px",fontWeight:"600",lineHeight:"1.45",color:i?o.text.label:o.text.header,minW:0,wordBreak:"break-word",children:n.jsx(ee,{text:e.statement})}),n.jsx(Do,{resolution:e.resolution,resolutionLabel:e.resolutionLabel})]}),n.jsx(Uo,{confidence:e.confidence}),e.falsifiablePrediction?n.jsxs(c,{fontSize:"12.5px",lineHeight:"1.5",color:o.text.body,mt:1.5,children:[n.jsxs(c,{as:"span",fontWeight:"700",color:o.text.label,children:[t("admin_support.investigations_hypothesescard.if_true_a3b42d71","If true:")," "]}),n.jsx(c,{as:"span",fontStyle:"italic",children:n.jsx(ee,{text:e.falsifiablePrediction})})]}):null,e.codeSuspects.length>0?n.jsx(v,{wrap:"wrap",gap:1.5,mt:2,children:e.codeSuspects.map(a=>n.jsxs(v,{align:"center",gap:1,bg:o.surface.background,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"4px",px:1.5,py:.5,minW:0,children:[n.jsx(c,{"aria-hidden":"true",fontSize:"10px",color:o.text.placeholder,children:Io}),n.jsx(c,{fontSize:"11px",fontFamily:"mono",lineHeight:"1.4",color:o.text.body,wordBreak:"break-all",children:a})]},a))}):null]})]})})}function Do({resolution:e,resolutionLabel:r}){const t=me(e==="confirmed"?"positive":"neutral"),i=e==="confirmed"?"â":e==="killed"?"â":"â¢";return n.jsxs(v,{align:"center",gap:1,flexShrink:0,bg:e==="open"?"transparent":t.backgroundColor,borderWidth:"1px",borderColor:e==="open"?o.surface.border:"transparent",color:e==="open"?o.text.label:t.textColor,borderRadius:"full",px:2,py:.5,children:[n.jsx(c,{"aria-hidden":"true",fontSize:"9px",lineHeight:"1",children:i}),n.jsx(c,{fontSize:"10.5px",fontWeight:"700",whiteSpace:"nowrap",children:r})]})}function Uo({confidence:e}){const{t:r}=O(),t=me(zt(e));return n.jsxs(v,{align:"center",gap:1.5,mt:1,title:r("admin_support.investigations_hypothesescard.ranking_signal_between_hypotheses_only_no_gate_in_this_system_keys_on_co_d4556e61","Ranking signal between hypotheses only. No gate in this system keys on confidence."),children:[n.jsx(f,{"aria-hidden":"true",w:nn,h:nn,borderRadius:"full",flexShrink:0,bg:e?t.textColor:"transparent",borderWidth:e?"0":"1px",borderColor:o.text.inactive}),n.jsx(c,{fontSize:"11px",color:o.text.label,lineHeight:"1.4",children:e?$n(e):r("admin.support.investigations.no_confidence_recorded","No confidence recorded")})]})}const Po="/admin/support/threads";function Jn(e){return`${Po}?conversation_id=${encodeURIComponent(e)}`}const sn=600,Ho=ue` 23 from { opacity: 0; transform: translateY(4px); } 24 to { opacity: 1; transform: none; } 25`,Qn=h.memo(({conversationIds:e,activeConversationId:r})=>{const{t}=O(),i=h.useMemo(()=>qo(e,r),[e,r]),[s,a]=h.useState(null),[l,d]=h.useState({}),[u,p]=h.useState(0),_=h.useRef(new Set),b=h.useRef({}),g=Vo(i,s,r);h.useEffect(()=>{if(!g||_.current.has(g))return;const j=g;_.current.add(j);let C=!1;return d(I=>({...I,[j]:{phase:"loading"}})),Ln(j).then(I=>{if(C){_.current.delete(j);return}d($=>({...$,[j]:{phase:"loaded",threadData:I??null}}))}).catch(I=>{if(C){_.current.delete(j);return}d($=>({...$,[j]:{phase:"error",message:I instanceof Error?I.message:String(I)}}))}),()=>{C=!0}},[g,u]);const m=h.useCallback(j=>{a(j)},[]),x=h.useCallback(()=>{g&&(_.current.delete(g),d(j=>{const C={...j};return delete C[g],C}),p(j=>j+1))},[g]),A=h.useCallback(j=>{var F;if(!g)return;const C=i.indexOf(g);if(C<0)return;let I=C;if(j.key==="ArrowRight")I=C+1;else if(j.key==="ArrowLeft")I=C-1;else if(j.key==="Home")I=0;else if(j.key==="End")I=i.length-1;else return;j.preventDefault();const $=(I+i.length)%i.length,T=i[$];T&&(a(T),(F=b.current[T])==null||F.focus())},[i,g]),y=g?l[g]:void 0,w=(y==null?void 0:y.phase)==="loaded"?y.threadData:null,k=h.useMemo(()=>Xo(w==null?void 0:w.messages),[w]),S=Zo(w==null?void 0:w.conversation),L=i.length>0,E=i.length>1;return n.jsxs(f,{as:"section","aria-label":t("admin_support.investigations_investigationconversationthread.customer_conversation_3bfc6a97","Customer conversation"),bg:o.surface.white,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"8px",overflow:"hidden",animation:`${Ho} 180ms ease-out both`,sx:{"@media (prefers-reduced-motion: reduce)":{animation:"none"}},children:[n.jsxs(v,{align:"flex-start",justify:"space-between",gap:4,px:4,pt:3,pb:E?2:3,children:[n.jsxs(f,{minW:0,children:[n.jsx(c,{fontSize:"10.5px",fontWeight:"700",textTransform:"uppercase",letterSpacing:"0.4px",color:o.text.label,children:t("admin_support.investigations_investigationconversationthread.c
25onversation_thread_c9dd946a","Conversation thread")}),n.jsx(c,{fontSize:"13.5px",fontFamily:"mono",color:o.text.header,mt:.5,noOfLines:1,wordBreak:"break-all",children:S.customerLabel||(g?Te(g,24):"no conversation")}),n.jsx(Bo,{conversationHeaderFacts:S,messageCount:k.length,hasLoadedThread:(y==null?void 0:y.phase)==="loaded"})]}),n.jsxs(v,{direction:"column",align:"flex-end",gap:1,flexShrink:0,children:[n.jsx(c,{fontSize:"10.5px",fontWeight:"700",textTransform:"uppercase",color:o.text.label,children:t("admin_support.investigations_investigationconversationthread.read_only_9b19a5a2","Read-only")}),g?n.jsxs(Se,{href:Jn(g),isExternal:!0,"aria-label":t("admin_support.investigations_investigationconversationthread.open_this_conversation_in_threads_to_reply_opens_in_a_new_tab_00fb3203","Open this conversation in Threads to reply (opens in a new tab)"),fontSize:"12px",fontWeight:"700",color:o.primaryAction.default,_hover:{color:o.primaryAction.hover,textDecoration:"underline"},whiteSpace:"nowrap",children:[t("admin_support.investigations_investigationconversationthread.open_in_threads_a21a417e","Open in Threads")," ",n.jsx(f,{as:"span","aria-hidden":"true",children:"â"})]}):null]})]}),E?n.jsx(v,{role:"tablist","aria-label":t("admin_support.investigations_investigationconversationthread.conversations_on_this_incident_28de17b5","Conversations on this incident"),onKeyDown:A,gap:1,px:4,pb:2,overflowX:"auto",children:i.map((j,C)=>{const I=j===g;return n.jsxs(f,{as:"button",type:"button",ref:$=>{b.current[j]=$},role:"tab",id:an(j),"aria-selected":I,"aria-controls":ln(j),tabIndex:I?0:-1,title:j,onClick:()=>m(j),px:2.5,py:1,borderRadius:"6px",borderWidth:"1px",borderColor:I?o.primaryAction.default:o.surface.border,bg:I?o.primaryAction.light:o.surface.offWhite,color:I?o.text.header:o.text.label,whiteSpace:"nowrap",flexShrink:0,transition:"border-color 120ms ease, background 120ms ease",_hover:{borderColor:o.surface.hoverBorder},children:[n.jsx(c,{as:"span",fontSize:"11px",fontWeight:"700",children:C+1}),n.jsx(c,{as:"span",fontSize:"11px",fontFamily:"mono",ml:1.5,children:Te(j,14)})]},j)})}):null,n.jsx(f,{role:E?"tabpanel":void 0,id:g?ln(g):void 0,"aria-labelledby":E&&g?an(g):void 0,borderTopWidth:"1px",borderColor:o.surface.border,children:L?(y==null?void 0:y.phase)==="error"?n.jsxs(f,{px:4,py:4,role:"alert",bg:o.accentColors.errorLight,children:[n.jsxs(c,{fontSize:"13px",color:o.accentColors.errorStrong,children:[t("admin_support.investigations_investigationconversationthread.couldnt_load_this_conversation_77ee98c7","Couldn't load this conversation:")," ",y.message]}),n.jsx(fe,{size:"xs",variant:"outline",mt:2,onClick:x,children:t("admin_support.investigations_investigationconversationthread.try_again_042c862e","Try again")})]}):(y==null?void 0:y.phase)==="loaded"?n.jsx(v,{direction:"column",minH:"120px",maxH:"440px",children:n.jsx(Mr,{conversationId:g,messages:k,isLoadingInitialSnapshot:!1})}):n.jsxs(v,{align:"center",gap:2,px:4,py:5,role:"status",children:[n.jsx(gt,{size:"sm",color:o.primaryAction.default}),n.jsx(c,{fontSize:"13px",color:o.text.label,children:t("admin_support.investigations_investigationconversationthread.loading_this_conversation_b293967b","Loading this conversationâ¦")})]}):n.jsx(f,{px:4,py:5,children:n.jsx(c,{fontSize:"13px",color:o.text.label,children:t("admin_support.investigations_investigationconversationthread.no_customer_conversation_is_attached_to_this_investigation_28f06c24","no customer conversation is attached to this investigation.")})})})]})});Qn.displayName="InvestigationConversationThread";function Bo({conversationHeaderFacts:e,messageCount:r,hasLoadedThread:t}){const{t:i}=O();if(!t)return null;if(e.isConversationRecordMissing)return n.jsx(c,{fontSize:"11.5px",color:o.accentColors.warningStrong,mt:.5,children:i("admin_support.investigations_investigationconversationthread.conversation_record_unavailable_showing_the_messages_we_have_cf08738b","conversation record unavailable â showing the messages we have")});const s=[e.channelLabel,e.statusLabel,`${r} ${r===1?"message":"messages"}`].filter(a=>a.length>0);return n.jsxs(v,{align:"center",gap:1.5,mt:.5,flexWrap:"wrap",children:[n.jsx(c,{fontSize:"11.5px",color:o.text.label,children:s.join(" · ")}),e.lastMessageRelativeLabel?n.jsxs(c,{fontSize:"11.5px",fontFamily:"mono",color:o.text.label,children:[i("admin_support.investigations_investigationconversationthread.last_reply_a49f3d31","· last reply")," ",e.lastMessageRelativeLabel]}):null]})}function an(e){return`investigation-conversation-tab-${e}`}function ln(e){return`investigation-conversation-tabpanel-${e}`}function qo(e,r){const t=[],i=new Set,s=a=>
25{if(typeof a!="string")return;const l=a.trim();!l||i.has(l)||(i.add(l),t.push(l))};if(s(r),Array.isArray(e))for(const a of e)s(a);return t}function Vo(e,r,t){if(r&&e.includes(r))return r;const i=typeof t=="string"?t.trim():"";return i&&e.includes(i)?i:e[0]??null}function mt(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function Q(e,r){if(!e)return"";const t=e[r];return typeof t=="string"?t.trim():""}function Ko(e){if(typeof e=="string")return e;if(typeof e=="number"&&Number.isFinite(e)||typeof e=="boolean")return String(e);if(e==null)return"";try{const r=JSON.stringify(e);return typeof r!="string"?"":r.length>sn?`${r.slice(0,sn)}â¦`:r}catch{return""}}function Go(e){return e==="user"||e==="admin"||e==="bot"?e:"bot"}function Yo(e,r){if(!Array.isArray(e))return[];const t=[];return e.forEach((i,s)=>{const a=mt(i);if(!a)return;const l=a.size_bytes;t.push({id:Q(a,"id")||`${r}-attachment-${s}`,kind:a.kind==="screenshot"?"screenshot":"file",filename:Q(a,"filename")||"attachment",content_type:Q(a,"content_type"),size_bytes:typeof l=="number"&&Number.isFinite(l)?l:0,s3_bucket:Q(a,"s3_bucket"),s3_key:Q(a,"s3_key"),presigned_get_url:Q(a,"presigned_get_url"),presigned_get_url_expires_at:Q(a,"presigned_get_url_expires_at")})}),t}function Xo(e){if(!Array.isArray(e))return[];const r=[],t=new Set;return e.forEach((i,s)=>{const a=mt(i);if(!a)return;const l=Q(a,"id"),d=mt(a.english_translation),u=Q(d,"translated_text"),p=u?{translated_text:u,source_language_code:Q(d,"source_language_code")||null,source_language_name:Q(d,"source_language_name")||null}:null,_=!l||t.has(l)?`investigation-thread-message-${s}`:l;t.add(_);const b=Go(a.role),g=b==="admin"?Fr(a.admin_reply_translation):null;r.push({id:_,conversation_id:Q(a,"conversation_id"),role:b,content:Ko(a.content),...p?{english_translation:p}:{},...g?{admin_reply_translation:g}:{},admin_user_id:Q(a,"admin_user_id")||null,admin_user_name:Q(a,"admin_user_name")||null,knowledge_base_citations:[],attachments:Yo(a.attachments,_),is_finalization:a.is_finalization===!0,is_handover_trigger:a.is_handover_trigger===!0,created_at:Q(a,"created_at")})}),r}function Zo(e){const r=mt(e);return{customerLabel:Q(r,"user_email")||Q(r,"user_name"),channelLabel:X(Q(r,"channel")),statusLabel:X(Q(r,"status")),lastMessageRelativeLabel:ve(Q(r,"last_message_at")),isConversationRecordMissing:r===null}}function Jo({investigation:e}){const{t:r}=O(),t=e.customer_context,i=r("admin.support.investigations.context.not_recorded","Not recorded"),s=Vt(e.created_at)||i,a=e.completed_at?Vt(e.completed_at)||i:r("admin.support.investigations.context.not_completed","Not completed"),l=Qo(e.completed_at,e.duration_ms),d=ts(t==null?void 0:t.subscription_plan,i),u=X(t==null?void 0:t.subscription_status)||i,p=es(t==null?void 0:t.platform)||i,_=[t==null?void 0:t.app_version,t==null?void 0:t.build_number].filter(Boolean).join(" · build ")||i,b=[X(t==null?void 0:t.operating_system),t==null?void 0:t.operating_system_version].filter(Boolean).join(" ")||i,g=[X(t==null?void 0:t.browser),t==null?void 0:t.browser_version].filter(Boolean).join(" ")||i,m=[{label:r("admin.support.investigations.context.created","Created"),value:s,tooltip:Un(e.created_at)},{label:r("admin.support.investigations.context.completed","Completed"),value:a,tooltip:l},{label:r("admin.support.investigations.context.user_email","User email"),value:(t==null?void 0:t.user_email)||i},{label:r("admin.support.investigations.context.user_id","User ID"),value:(t==null?void 0:t.user_id)||e.user_id||i},{label:r("admin.support.investigations.context.user_type","User type"),value:X(t==null?void 0:t.user_type)||i},{label:r("admin.support.investigations.context.student_type","Student type"),value:X(t==null?void 0:t.student_type)||i},{label:r("admin.support.investigations.context.subscription","Subscription"),value:`${d} · ${u}`},{label:r("admin.support.investigations.context.platform","Platform"),value:p},{label:r("admin.support.investigations.context.app_version","App version"),value:_},{label:r("admin.support.investigations.context.operating_system","Operating system"),value:b},{label:r("admin.support.investigations.context.browser","Browser"),value:g,tooltip:(t==null?void 0:t.user_agent)||void 0}];return n.jsxs(f,{mb:4,pb:3,borderBottomWidth:"1px",borderColor:o.surface.border,children:[n.jsx(v,{wrap:"wrap",gap:4,mb:3,children:m.map(x=>n.jsxs(f,{minW:"120px",children:[n.jsx(c,{fontSize:"10.5px",fontWeight:"700",textTransform:"uppercase",color:o.text.label,children:x.label}),n.jsx(xr,{label:x.tooltip,isDisabled:!x.tooltip,placement:"top",openDelay:200,children:n.jsx(c,{fontSize:"12px",color:o.text.body,fontFamily:"mono",wordBreak:"break-all",children:x.value})})]},x.label))}),n.jsx(Wr,{userId:(t==null?void 0:t.user_id)||e.user_id,userEmail:t==null?void 0:t.user_email})]})}function Qo(e,r){const t=Un(e);if(!t)return"";const i=Cr(r);return`${t}${i?` (${i})`:""}`}function es(e){const r={desktop:"Desktop","tablet-web":"Tablet web","tablet-ios-app":"Tablet iOS app","tablet-android-app":"Tablet Android app","mobile-web":"Mobile web","mobile-ios-app":"Mobile iOS app","mobile-android-app":"Mobile Android app","web-desktop":"Desktop","web-tablet":"Tablet web","web-mobile":"Mobile web","mobile-app":"Mobile app"},t=(e==null?void 0:e.trim().toLowerCase())??"";return r[t]??X(e)}function ts(e,r){const t=e==null?void 0:e.trim().toLowerCase().replace(/[\s_-]+/g,"");return t==="superlearner"||t==="pro"?Ge(Ve.SUPER_LEARNER,null):t==="megamind"?Ge(Ve.MEGA_MIND,null):t==="elite"?Ge(Ve.ELITE,null):t==="free"?Ge(Ve.FREE,null):X(e)||r}function ns({status:e}
25){const r=e==="running"?"the agent is working on this one right now. findings appear here when the run finishes.":e==="queued"?"the agent is starting this investigation automatically. findings appear here when it finishes.":e==="failed"?"this run failed before it produced findings. its failure details are recorded below.":"this run finished without recording findings.";return n.jsx(f,{bg:o.surface.white,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"8px",p:5,mb:3,children:n.jsx(c,{fontSize:"13px",color:o.text.label,children:r})})}const Ie=h.memo(({questionNumber:e,question:r,verdictLabel:t,verdictTone:i,children:s})=>{const a=me(i);return n.jsxs(f,{bg:o.surface.white,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"8px",p:4,mb:3,children:[n.jsxs(v,{align:"flex-start",justify:"space-between",gap:3,mb:2,children:[n.jsxs(v,{align:"baseline",gap:2,minW:0,children:[n.jsx(c,{fontSize:"12px",fontWeight:"700",color:o.text.placeholder,children:e}),n.jsx(c,{fontSize:"14px",fontWeight:"700",color:o.text.header,children:r})]}),n.jsx(f,{flexShrink:0,bg:a.backgroundColor,color:a.textColor,borderRadius:"full",px:2.5,py:1,children:n.jsx(c,{fontSize:"11px",fontWeight:"700",whiteSpace:"nowrap",children:t})})]}),n.jsx(f,{children:s})]})});Ie.displayName="InvestigationQuestionSection";function Ue({text:e,fallbackText:r}){const t=(e??"").trim();return t.length===0?n.jsx(c,{fontSize:"13px",color:o.text.placeholder,children:n.jsx(ee,{text:r})}):n.jsx(c,{fontSize:"13.5px",color:o.text.body,whiteSpace:"pre-wrap",children:n.jsx(ee,{text:t})})}function yt({lines:e,emptyText:r}){return e.length===0?n.jsx(c,{fontSize:"13px",color:o.text.placeholder,children:r}):n.jsx(f,{as:"ul",pl:4,m:0,children:e.map((t,i)=>n.jsx(f,{as:"li",mb:1,children:Mt(t.label).some(s=>s.kind==="reference")?n.jsx(c,{fontSize:"13px",color:o.text.body,wordBreak:"break-word",children:n.jsx(ee,{text:t.label})}):Ne(t.url)?n.jsx(Se,{href:t.url,isExternal:!0,rel:"noopener noreferrer",fontSize:"13px",color:o.primaryAction.default,wordBreak:"break-word",children:t.label}):n.jsx(c,{fontSize:"13px",color:o.text.body,wordBreak:"break-word",children:n.jsx(ee,{text:t.label})})},`${t.label}-${i}`))})}function vt({label:e,tone:r,children:t}){const i=me(r);return n.jsxs(f,{mt:3,bg:i.backgroundColor,borderLeftWidth:"3px",borderColor:i.textColor,borderRadius:"4px",px:3,py:2,children:[n.jsx(c,{fontSize:"10.5px",fontWeight:"700",textTransform:"uppercase",color:i.textColor,mb:1,children:e}),n.jsx(f,{fontSize:"13px",color:o.text.body,children:typeof t=="string"?n.jsx(ee,{text:t}):t})]})}const er=h.memo(({findings:e,fallbackConfidence:r})=>{const{t}=O(),i=e.replication,s=e.diagnosis,a=e.proposed_fix,l=(e.errors_found??[]).map(_=>kr(_)),d=Ht((i==null?void 0:i.steps)??null),u=Ht((s==null?void 0:s.load_bearing_evidence)??null),p=(s==null?void 0:s.confidence)??r??null;return n.jsxs(f,{children:[n.jsx(Ie,{questionNumber:1,question:t("admin.support.investigations.report.real_bug_question","Real bug or UX confusion?"),verdictLabel:e.is_real_bug?t("admin.support.investigations.report.real_bug","real bug"):t("admin.support.investigations.report.ux_confusion","UX confusion"),verdictTone:e.is_real_bug?"negative":"warning",children:n.jsx(Ue,{text:e.ux_confusion_explanation,fallbackText:e.is_real_bug?t("admin.support.investigations.report.genuine_bug_fallback","Something is genuinely broken. See the diagnosis below."):t("admin.support.investigations.report.confusion_fallback","No explanation was recorded for the confusion.")})}),n.jsxs(Ie,{questionNumber:2,question:t("admin.support.investigations.report.understood_question","Did we understand it well enough?"),verdictLabel:e.understood_well_enough?t("admin.support.investigations.report.understood","understood"):t("admin.support.investigations.report.blocked","blocked"),verdictTone:e.understood_well_enough?"positive":"warning",children:[n.jsx(Ue,{text:e.understood_well_enough?t("admin.support.investigations.report.context_was_enough","The report plus auto collected context was enough to investigate without going back to the user."):null,fallbackText:t("admin.support.investigations.report.context_was_not_enough","The Investigator could not proceed on the context it had.")}),e.blocking_question_for_user?n.jsx(vt,{label:t("admin_support.investigations_investigationsixquestionsreport.blocking_question_for_the_user_90cfb934","Blocking question for the user"),tone:"warning",children:e.blocking_question_for_user}):null,e.tracking_gap_suggestion?n.jsx(vt,{label:t("admin_support.investigations_investigationsixquestionsreport.tracking_gap_to_close_15d687c7","Tracking gap to close"),tone:"neutral",children:e.tracking_gap_suggestion}):null]}),n.jsx(Ie,{questionNumber:3,question:t("admin.support.investigations.report.errors_question","Errors and logs found"),verdictLabel:l.length===0?t("admin.support.investigations.report.nothing_found","nothing found"):t("admin.support.investigations.report.found_count","{count} found",{count:l.length}),verdictTone:l.length===0?"neutral":"warning",children:n.jsx(yt,{lines:l,emptyText:t("admin.support.investigations.report.no_matching_errors","No Sentry issues, Modal logs or Cloudflare logs matched this user or symptom.")})}),n.jsx(Ie,{questionNumber:4,question:t("admin.support.investigations.report.replication_question","Could we replicate it?"),verdictLabel:!i||!i.attempted?t("admin.support.investigations.report.not_attempted","not attempted"):i.succeeded?t("admin.support.investigations.report.replicated","replicated"):t("admin.support.investigations.report.not_replicated","not replicated"),verdictTone:!i||!i.attempted?"neutral":i.succeeded?"positive":"warning",children:i!=null&&i.succeeded?n.jsxs(n.Fragment,{children:[n.jsx(c,{fontSize:"12px",color:o.text.label,mb:1,children:t("admin_support.investigations_investigationsixquestionsreport.repro_steps_47940dea","Repro steps")}),n.jsx(yt,{lines:d.map(_=>({label:_})),emptyText:t("admin.support.investigations.report.no_reproduction_steps","Reproduced, but no steps were recorded.")})]}):n.jsx(Ue,{text:(i==null?void 0:i.why_not)??null,fallbackText:i!=null&&i.attempted?t("admin.support.investigations.report.replication_failed_without_reason","Reproduction was attempted and failed, with no reason recorded."):t("admin.support.investigations.report.replication_not_attempted","No reproduction was attempted on this run.")})}),n.jsxs(Ie,{questionNumber:5,question:t("admin.support.investigations.report.diagnosis_question","Diagnosis and confidence"),verdictLabel:Ar(p),verdictTone:zt(p),children:[n.jsx(Ue,{text:(s==null?void 0:s.what_went_wrong)??null,fallbackText:t("admin.support.investigations.report.no_diagnosis","No diagnosis was recorded on this run.")}),n.jsx(c,{fontSize:"12px",color:o.text.label,mt:3,mb:1,children:t("admin_support.investigations_investigationsixquestionsreport.load_bearing_evidence_eb0c26b4","Load bearing evidence")}),n.jsx(yt,{lines:u.map(_=>({label:_})),emptyText:t("admin.support.investigations.report.no_load_bearing_evidence","The diagnosis did not name the evidence it rests on. Treat it as unverified.")})]}),n.jsxs(Ie,{questionNumber:6,question:t("admin.support.investigations.report.proposed_fix_question","Proposed fix"),verdictLabel:a!=null&&a.can_auto_apply?t("admin.support.investigations.report.can_auto_apply","can auto apply"):t("admin.support.investigations.report.needs_human","needs a human"),verdictTone:a!=null&&a.can_auto_apply?"positive":"neutral",children:[n.jsx(Ue,{text:(a==null?void 0:a.description)??null,fallbackText:t("admin.support.investigations.report.no_proposed_fix","No fix was proposed on this run.")}),a!=null&&a.observability_to_add?n.jsx(vt,{label:t("admin_support.investigations_investigationsixquestionsreport.observability_to_add_312fd255","Observability to add"),tone:"neutral",children:a.observability_to_add}):null]})]})});er.displayName="InvestigationSixQuestionsReport";const rs=ue` 26 from { opacity: 0; transform: translateY(4px); } 27 to { opacity: 1; transform: translateY(0); } 28`,is=ue` 29 0%, 100% { opacity: 0.3; transform: scale(0.82); } 30 50% { opacity: 1; transform: scale(1); } 31`,tr={"@media (prefers-reduced-motion: reduce)":{animation:"none"}},os=6,ss=40;function as(e){return e==="admin"?{label:"Admin",accentColor:o.primaryAction.default,groundColor:o.surface.secondary}:e==="investigator"?{label:"Investigator",accentColor:o.accentColors.infoDark,groundColor:o.surface.background}:{label:X(e)||"Note",accentColor:o.surface.tertiary,groundColor:o.surface.background}}function nr(e){try{return JSON.stringify(e,null,2)??""}catch{return""}}function ls(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e!==null&&typeof e=="object"?nr(e):""}function cn(e){if(!Array.isArray(e))return[];const r=[];for(const t of e){if(typeof t=="string"){const l=t.trim();l&&r.push({role:"",text:l,at:""});continue}if(t===null||typeof t!="object"||Array.isArray(t))continue;const i=t,a=ls(i.text??i.content??i.message).trim()||nr(i).trim();!a||a==="{}"||r.push({role:typeof i.role=="string"?i.role.trim().toLowerCase():"",text:a,at:typeof i.at=="string"?i.at:typeof i.created_at=="string"?i.created_at:""})}return r}function dn(e){return e instanceof Error?e.message:String(e)}function cs({investigationId:e,disabled:r}){const{t}
31=O(),[i,s]=h.useState([]),[a,l]=h.useState(!1),[d,u]=h.useState(null),[p,_]=h.useState(""),[b,g]=h.useState(!1),[m,x]=h.useState(null),[A,y]=h.useState(0),w=h.useRef(null),k=h.useRef(0),S=typeof e=="string"&&e.trim().length>0?e.trim():null,L=!!r||S===null,E=h.useCallback(async()=>{if(!S){s([]),u(null),l(!1);return}const T=k.current+1;k.current=T,l(!0),u(null),s([]);try{const F=await Ir(S);if(k.current!==T)return;s(cn(F))}catch(F){if(k.current!==T)return;u(dn(F))}finally{k.current===T&&l(!1)}},[S]);h.useEffect(()=>{E()},[E]),h.useEffect(()=>{if(!b){y(0);return}const T=Date.now();y(0);const F=window.setInterval(()=>{y(Date.now()-T)},1e3);return()=>window.clearInterval(F)},[b]),h.useEffect(()=>{const T=w.current;T&&(T.scrollTop=T.scrollHeight)},[i,b]);const j=h.useCallback(async()=>{if(b||L||!S)return;const T=p.trim();if(T){g(!0),x(null);try{const F=await Lr({investigationId:S,message:T}),B=cn(F);if(B.length===0){x("The investigator returned an empty thread. Your message may not have been saved â try again.");return}s(B),_("")}catch(F){x(dn(F))}finally{g(!1)}}},[p,L,b,S]),C=h.useCallback(T=>{T.key!=="Enter"||T.shiftKey||(T.preventDefault(),j())},[j]),I=p.trim().length>0,$=L||b||!I;return n.jsxs(f,{as:"section","aria-label":t("admin_support.investigations_investigatorchat.investigator_chat_c1bf29c9","Investigator chat"),bg:o.surface.white,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"8px",p:4,mb:3,children:[n.jsxs(v,{align:"flex-start",justify:"space-between",gap:3,mb:1,children:[n.jsx(c,{fontSize:"14px",fontWeight:"700",color:o.text.header,children:t("admin_support.investigations_investigatorchat.investigator_chat_c1bf29c9","Investigator chat")}),i.length>0?n.jsx(c,{fontSize:"11px",fontFamily:"mono",color:o.text.label,flexShrink:0,children:t("admin.support.investigations.chat_message_count","{count, plural, one {# message} other {# messages}}",{count:i.length})}):null]}),n.jsx(c,{fontSize:"12px",color:o.text.label,mb:3,children:t("admin_support.investigations_investigatorchat.admin_only_each_message_is_appended_to_this_investigation_and_runs_the_i_5f61f75d","Admin only. Each message is appended to this investigation and runs the Investigator again with the same tools against the same record.")}),S===null?n.jsx(c,{fontSize:"13px",color:o.text.placeholder,children:t("admin_support.investigations_investigatorchat.this_investigation_has_no_id_so_there_is_no_chat_thread_to_load_85c906db","This investigation has no id, so there is no chat thread to load.")}):n.jsxs(f,{ref:w,role:"log","aria-label":t("admin_support.investigations_investigatorchat.investigator_chat_thread_f729db4d","Investigator chat thread"),"aria-live":"polite","aria-busy":b,maxH:"340px",overflowY:"auto",pr:1,children:[a&&i.length===0?n.jsxs(v,{align:"center",gap:2,py:2,children:[n.jsx(gt,{size:"xs",color:o.primaryAction.default}),n.jsx(c,{fontSize:"13px",color:o.text.label,children:t("admin_support.investigations_investigatorchat.loading_the_thread_26a0c738","Loading the threadâ¦")})]}):null,!a&&i.length===0&&d===null?n.jsx(c,{fontSize:"13px",color:o.text.placeholder,py:2,children:t("admin_support.investigations_investigatorchat.nothing_asked_yet_a_question_here_re_runs_the_investigator_against_this_b60257fe","Nothing asked yet. A question here re-runs the Investigator against this record â what it checked, what it ruled out, or a fresh look with something it did not have.")}):null,i.map((T,F)=>n.jsx(ds,{chatMessage:T,animationDelayMs:Math.min(F,os)*ss},`${F}-${T.at}`)),b?n.jsxs(v,{align:"center",gap:2,role:"status",py:2,children:[n.jsx(f,{width:"6px",height:"6px",borderRadius:"full",flexShrink:0,bg:o.accentColors.infoDark,animation:`${is} 1.4s ease-in-out infinite`,sx:tr}),n.jsx(c,{fontSize:"12.5px",color:o.text.label,children:t("admin_support.investigations_investigatorchat.investigator_is_working_deedc912","Investigator is working")}),n.jsx(c,{fontSize:"12px",fontFamily:"mono",color:o.text.label,children:dt(A)||"0s"})]}):null]}),d?n.jsxs(v,{role:"alert",align:"center",justify:"space-between",gap:3,mt:2,bg:o.accentColors.errorLight,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"6px",px:3,py:2,children:[n.jsxs(c,{fontSize:"12.5px",color:o.accentColors.errorStrong,children:[t("admin_support.investigations_investigatorchat.could_not_load_the_thread_7a6b9d27","Could not load the thread:")," ",d]}),n.jsx(fe,{size:"xs",variant:"outline",flexShrink:0,onClick:()=>void E(),children:t("admin_support.investigations_investigatorchat.retry_9f5cd8a2","Retry")})]}):null,m?n.jsxs(f,{role:"alert",mt:2,bg:o.accentColors.errorLight,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"6px",px:3,py:2,children:[n.jsxs(c,{fontSize:"12.5px",color:o.accentColors.errorStrong,children:[t("admin_support.investigations_investigatorchat.could_not_reach_the_investigator_20ba8ca3","Could not reach the investigator:")," ",m]}),n.jsx(c,{fontSize:"11.5px",color:o.text.label,mt:.5,children:t("admin_support.investigations_investigatorchat.your_message_is_still_in_the_box_below_714c797a","Your message is still in the box below.")})]}):null,n.jsxs(f,{mt:3,children:[n.jsx(Nn,{"aria-label":t("admin_support.investigations_investigatorchat.message_the_investigator_0b9725a5","Message the investigator"),value:p,onChange:T=>_(T.target.value),onKeyDown:C,isDisabled:L,placeholder:L?t("admin.support.investigations.chat_unavailable","Chat is unavailable for this investigation right now."):t("admin.support.investigations.chat_placeholder","Ask the Investigator about this runâ¦"),_placeholder:{color:o.text.placeholder},rows:2,resize:"vertical",fontSize:"13.5px",lineHeight:"1.5",color:o.text.header,bg:o.surface.white,borderColor:o.surface.border,borderRadius:"6px",_hover:{borderColor:o.surface.tertiary},_focusVisible:{borderColor:o.primaryAction.default,boxShadow:`0 0 0 1px ${o.primaryAction.default}`}}),n.jsxs(v,{align:"center",justify:"space-between",gap:3,mt:2,children:[n.jsx(c,{fontSize:"11px",color:o.text.label,children:t("admin_support.investigations_investigatorchat.enter_sends_shift_enter_adds_a_line_207c382f","Enter sends · Shift + Enter adds a line")}),n.jsx(fe,{size:"sm",flexShrink:0,bg:o.primaryAction.default,color:o.text.white,_hover:{bg:o.primaryAction.hover},_disabled:{bg:o.primaryAction.inactiveButton,opacity:1,cursor:"not-allowed"},onClick:()=>void j(),isDisabled:$,isLoading:b,loadingText:"Running",children:t("admin_support.investigations_investigatorchat.send_9bc2575c","Send")})]})]})]})}function ds({chatMessage:e,animationDelayMs:r}){const t=as(e.role),i=ve(e.at);return n.jsxs(f,{mb:2.5,animation:`${rs} 220ms ease-out both`,style:{animationDelay:`${r}ms`},sx:tr,children:[n.jsxs(v,{align:"baseline",justify:"space-between",gap:2,mb:1,children:[n.jsx(c,{fontSize:"10.5px",fontFamily:"mono",fontWeight:"700",textTransform:"uppercase",letterSpacing:"0.04em",color:t.accentColor,children:t.label}),i?n.jsx(c,{fontSize:"10.5px",fontFamily:"mono",color:o.text.label,flexShrink:0,children:i}):null]}),n.jsx(f,{bg:t.groundColor,borderLeftWidth:"2px",borderColor:t.accentColor,borderRadius:"4px",px:3,py:2,children:n.jsx(us,{text:e.text})})]})}function us({text:e}){const r=e.split(` 32`);return n.jsx(f,{children:r.map((t,i)=>t.trim().length===0?n.jsx(f,{height:"6px"},i):/^\s/.test(t)?n.jsx(c,{fontSize:"12.5px",fontFamily:"mono",lineHeight:"1.45",color:o.text.body,whiteSpace:"pre-wrap",wordBreak:"break-word",children:n.jsx(ee,{text:t})},i):n.jsx(c,{fontSize:"13.5px",lineHeight:"1.5",color:o.text.body,wordBreak:"break-word",children:n.jsx(ps,{text:t})},i))})}function un({value:e}){return n.jsx(c,{as:"span",fontSize:"12.5px",fontFamily:"mono",color:o.text.header,bg:o.surface.secondary,borderRadius:"3px",px:"3px",children:e})}function ps({text:e}){const r=h.useMemo(()=>Mt(e),[e]);return n.jsx(n.Fragment,{children:r.map((t,i)=>{if(t.kind==="reference")return n.jsxs(f,{as:"span",display:"inline-flex",alignItems:"center",gap:"3px",whiteSpace:"nowrap",children:[n.jsx(un,{value:t.value}),n.jsx(Nt,{reference:t.reference})]},`${i}-${t.reference.kind}-${t.value}`);const s=Wt(t.value),a=/^\s/.test(t.value),l=/\s$/.test(t.value);return n.jsxs(ze.Fragment,{children:[a?" ":null,s.map((d,u)=>n.jsxs(ze.Fragment,{children:[u>0?" ":null,d.kind==="identifier"?n.jsx(un,{value:d.value}):d.value]},`${u}-${d.value}`)),l?" ":null]},`${i}-text`)})})}const Ze=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},be=e=>typeof e=="string"?e.trim():"";function fs({investigation:e}){const{t:r}=O(),t=r("admin.support.follow_up.not_recorded","Not recorded"),i=Ze(e.follow_up),s=Ze(e.resolution),a=Ze(s.relief),l=Ze(s.root_cause_resolution),d=e.fixer,u=d==null?void 0:d.duplicate_of_pull_request_url,p=be(d==null?void 0:d.change_ownership_reason)||be(i.reason),_=Array.isArray(i.successful_evidence_tools)?i.successful_evidence_tools.filter(j=>typeof j=="string").map(X).join(", "):"",b=be(i.kind),g=b==="human_requested"&&e.review_state==="needs_review",m=be(l.status)==="fixed"&&!!be(l.verified_at),x=(d==null?void 0:d.status)==="failed"||(d==null?void 0:d.status)==="cancelled",A=(d==null?void 0:d.status)==="running"||(d==null?void 0:d.status)==="starting",y=b==="human_requested"&&e.review_state==="closed";let w=b;g?w="human_requested":m?w="production_verified":x?w="engineering_blocked":A?w="engineering_active":(d==null?void 0:d.status)==="succeeded"?w=d.pr_url?"awaiting_production_verification":"engineering_completed":y&&(w="review_closed");const k=e.engineering_runtime==="conductor_incident_v1",S=!!be(d==null?void 0:d.runtime)&&(d==null?void 0:d.runtime)!=="unknown";let L=t;k?L=r("admin.support.follow_up.conductor_incident","Conductor incident"):S&&(L=X(d.runtime));const E=[[r("admin.support.follow_up.next_actor","Next step"),X(w)||t],[r("admin.support.follow_up.runtime","Engineering runtime"),L],[r("admin.support.follow_up.relief","Customer relief"),[X(be(a.status)),be(a.description)].filter(
32Boolean).join(" · ")||t],[r("admin.support.follow_up.cause","Root cause"),X(be(l.status))||t],[r("admin.support.follow_up.verification","Production verification"),m?be(l.verified_at):r("admin.support.follow_up.not_verified","No verified production fix")]];return n.jsxs(f,{borderWidth:"1px",borderColor:o.surface.border,borderRadius:"12px",p:4,mb:4,"data-testid":"investigation-follow-up-summary",children:[n.jsx(c,{fontWeight:"600",mb:3,children:r("admin.support.follow_up.title","What happens next")}),E.map(([j,C])=>n.jsxs(v,{gap:3,mb:2,direction:{base:"column",md:"row"},children:[n.jsx(c,{fontSize:"sm",color:o.text.label,minW:{md:"160px"},children:j}),n.jsx(c,{fontSize:"sm",overflowWrap:"anywhere",children:C})]},j)),p?n.jsx(c,{fontSize:"sm",mt:3,overflowWrap:"anywhere",children:p}):null,u&&Ne(u)?n.jsxs(Se,{href:u,isExternal:!0,color:o.primaryAction.default,fontSize:"sm",children:[r("admin.support.follow_up.owner_pr","Open PR checked for overlapping work")," â"]}):null,_?n.jsxs(c,{fontSize:"sm",mt:3,color:o.text.label,children:[r("admin.support.follow_up.evidence","Sources read successfully"),": ",_]}):null]})}const ms=600*1e3,hs=1e3,st="ui-monospace, SFMono-Regular, Menlo, monospace",gs=ue` 33 0% { transform: scale(0.85); opacity: 0.55; } 34 70%, 100% { transform: scale(1.5); opacity: 0; } 35`,_s=ue` 36 from { opacity: 0; transform: translateY(2px); } 37 to { opacity: 1; transform: translateY(0); } 38`,xs=35,bs={completed:{markerColor:o.accentColors.successStrong,labelColor:o.text.body,isMarkerFilled:!0,isLabelEmphasized:!1,hasHalo:!1,hasPulse:!1},running:{markerColor:o.primaryAction.default,labelColor:o.text.header,isMarkerFilled:!0,isLabelEmphasized:!0,hasHalo:!0,hasPulse:!0},stalled:{markerColor:o.accentColors.warningStrong,labelColor:o.accentColors.warningStrong,isMarkerFilled:!0,isLabelEmphasized:!0,hasHalo:!0,hasPulse:!1},parked:{markerColor:o.accentColors.infoDark,labelColor:o.accentColors.infoDark,isMarkerFilled:!1,isLabelEmphasized:!0,hasHalo:!0,hasPulse:!1},pending:{markerColor:o.surface.tertiary,labelColor:o.text.label,isMarkerFilled:!1,isLabelEmphasized:!1,hasHalo:!1,hasPulse:!1}};function pn(e){if(typeof e!="string")return null;const r=e.trim();if(!r)return null;const t=Date.parse(r);return Number.isFinite(t)?t:null}function ys(e,r){const t=Dn(e),i=t>=0?ct[t]:null,s=i==="waiting_on_user",d=i!==null&&i!=="closed"&&!(s||i==="awaiting_human_merge")&&r!==null&&r>=ms,u=dt(r);return ct.map((p,_)=>{const b=_===t;let g="pending";return b?p==="closed"?g="completed":p==="waiting_on_user"||p==="awaiting_human_merge"?g="parked":g=d?"stalled":"running":!s&&t>=0&&_<t&&p!=="waiting_on_user"&&(g="completed"),{stage:p,label:ti(p)||p,markerState:g,elapsedLabel:b?u:""}})}function vs(e){switch(e.markerState){case"completed":return"done";case"running":return"running now";case"stalled":return e.elapsedLabel?`running, but nothing has happened for ${e.elapsedLabel}`:"running, but nothing has happened recently";case"parked":return e.stage==="awaiting_human_merge"?"waiting for a human to test and merge":e.elapsedLabel?`waiting on the customer for ${e.elapsedLabel}`:"waiting on the customer";default:return"not started"}}function Ss({investigationStatus:e=null,currentStage:r,startedAt:t,lastActivityAt:i=null,onStageClick:s}){const{t:a}=O(),[l,d]=h.useState(()=>Date.now()),u=Dn(r),p=u>=0?ct[u]:null,_=pn(i)??pn(t),b=p!==null&&p!=="closed"&&_!==null;h.useEffect(()=>{if(!b)return;const C=window.setInterval(()=>d(Date.now()),hs);return()=>window.clearInterval(C)},[b]);const g=b&&_!==null?Math.max(0,l-_):null,m={intake:a("admin.support.investigations.pipeline.intake","Reading report"),triage:a("admin.support.investigations.pipeline.triage","Choosing checks"),evidence:a("admin.support.investigations.pipeline.evidence","Checking evidence"),hypotheses:a("admin.support.investigations.pipeline.hypotheses","Evaluating causes"),fixing:a("admin.support.investigations.pipeline.fixing","Working on fix"),awaiting_human_merge:a("admin.support.investigations.pipeline.awaiting_human_merge","Awaiting human merge"),verifying:a("admin.support.investigations.pipeline.verifying","Verifying result"),waiting_on_user:a("admin.support.investigations.pipeline.waiting_on_user","Waiting on customer"),closed:a("admin.support.investigations.pipeline.closed","Complete")},x=ys(r,g).map(C=>({...C,label:m[C.stage]})),A=x.find(C=>C.markerState==="stalled")??null,y=x.find(C=>["running","stalled","parked"].includes(C.markerState))??(p==="closed"?x.find(C=>C.stage==="closed")??null:null),w=typeof e=="string"?e.trim():"",S={queued:a("admin.support.investigations.status.queued","Starting automatically"),running:a("admin.support.investigations.status.running","Investigating now"),waiting_on_user:a("admin.support.investigations.status.waiting_on_user","Waiting on the customer"),completed:a("admin.support.investigations.status.completed","Finished"),failed:a("admin.support.investigations.status.failed","Could not finish")}[w]??Ft(w),L=ve(t),E=ve(i),j=[];return L&&j.push(`started ${L}`),E&&j.push(`last activity ${E}`),n.jsxs(f,{as:"section","aria-label":a("admin.support.investigations.pipeline.title","Investigation progress"),bg:o.surface.white,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"8px",px:4,py:3.5,mb:3,children:[n.jsxs(v,{align:"baseline",justify:"space-between",gap:3,mb:3,children:[n.jsx(c,{fontSize:"10.5px",fontWeight:"700",textTransform:"uppercase",color:o.text.label,children:a("admin.support.investigations.pipeline.title","Investigation progress")}),j.length>0?n.jsx(c,{fontSize:"11px",fontFamily:st,color:o.text.label,textAlign:"right",children:j.join(" · ")}):null]}),n.jsxs(v,{gap:6,mb:3,wrap:"wrap",children:[n.jsxs(f,{children:[n.jsx(c,{fontSize:"10px",fontWeight:"700",color:o.text.placeholder,textTransform:"uppercase",children:a("admin.support.investigations.pipeline.overall_status","Overall status")}),n.jsx(c,{fontSize:"12px",fontWeight:"700",color:o.text.body,mt:.5,children:S||a("admin.support.reply_trace.not_recorded","Not recorded")})]}),n.jsxs(f,{children:[n.jsx(c,{fontSize:"10px",fontWeight:"700",color:o.text.placeholder,textTransform:"uppercase",children:a("admin.support.investigations.pipeline.current_step","Current step")}),n.jsxs(c,{fontSize:"12px",fontWeight:"700",color:o.text.body,mt:.5,children:[(y==null?void 0:y.label)??a("admin.support.reply_trace.not_recorded","Not recorded"),y!=null&&y.elapsedLabel?n.jsx(c,{as:"span",ml:1.5,fontFamily:st,color:o.text.label,children:y.elapsedLabel}):null]})]})]}),n.jsx(v,{as:"ol",role:"list","aria-label":a("admin.support.investigations.pipeline.title","Investigation progress"),wrap:"wrap",rowGap:3,m:0,p:0,children:x.map((C,I)=>n.jsx(ws,{stageView:C,isFirstStage:I===0,isLastStage:I===x.length-1,isPreviousStageCompleted:I>0&&x[I-1].markerState==="completed",enterDelayMs:I*xs,onStageClick:s},C.stage))}),A?n.jsx(f,{role:"status",mt:3,bg:o.accentColors.warningLight,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"6px",px:3,py:2,children:n.jsxs(c,{fontSize:"12px",color:o.accentColors.warningStrong,children:[a("admin_support.investigations_pipelinetimeline.nothing_has_happened_in_822000ce","Nothing has happened in")," ",n.jsx(c,{as:"span",fontWeight:"700",children:A.label})," ",a("admin_support.investigations_pipelinetimeline.for_43eef9a6","for")," ",n.jsx(c,{as:"span",fontFamily:st,children:A.elapsedLabel}),a("admin_support.investigations_pipelinetimeline.this_run_may_be_stuck_eaa2711f",". This run may be stuck.")]})}
38):null,u<0?n.jsx(c,{mt:3,fontSize:"11.5px",color:o.text.label,children:a("admin_support.investigations_pipelinetimeline.no_pipeline_stage_was_recorded_for_this_run_a60c82f4","No pipeline stage was recorded for this run.")}):null]})}function ws({stageView:e,isFirstStage:r,isLastStage:t,isPreviousStageCompleted:i,enterDelayMs:s,onStageClick:a}){const l=bs[e.markerState],d=vs(e),u=e.markerState==="running"||e.markerState==="stalled"||e.markerState==="parked",p=i?o.primaryAction.inactiveButton:o.surface.border,_=e.markerState==="completed"?o.primaryAction.inactiveButton:o.surface.border,b=n.jsxs(n.Fragment,{children:[n.jsxs(v,{align:"center","aria-hidden":"true",children:[n.jsx(f,{h:"2px",flex:"1",bg:r?"transparent":p}),n.jsxs(v,{position:"relative",align:"center",justify:"center",w:"16px",h:"16px",flexShrink:0,children:[l.hasHalo?n.jsx(f,{position:"absolute",top:"0",right:"0",bottom:"0",left:"0",borderRadius:"full",borderWidth:"2px",borderColor:l.markerColor,opacity:.45}):null,l.hasPulse?n.jsx(f,{position:"absolute",top:"0",right:"0",bottom:"0",left:"0",borderRadius:"full",borderWidth:"2px",borderColor:l.markerColor,animation:`${gs} 2s ease-out infinite`,sx:{"@media (prefers-reduced-motion: reduce)":{display:"none"}}}):null,n.jsx(v,{align:"center",justify:"center",w:"12px",h:"12px",borderRadius:"full",bg:l.isMarkerFilled?l.markerColor:o.surface.white,borderWidth:l.isMarkerFilled?"0":"2px",borderColor:l.markerColor,children:e.markerState==="completed"?n.jsx(c,{fontSize:"8px",lineHeight:"1",fontWeight:"700",color:o.text.white,children:"â"}):null})]}),n.jsx(f,{h:"2px",flex:"1",bg:t?"transparent":_})]}),n.jsx(c,{mt:1.5,px:1,fontSize:"10.5px",lineHeight:"1.25",textAlign:"center",color:l.labelColor,fontWeight:l.isLabelEmphasized?"700":"500",children:e.label}),e.elapsedLabel?n.jsx(c,{mt:.5,fontSize:"10px",fontFamily:st,lineHeight:"1.2",textAlign:"center",color:l.labelColor,children:e.elapsedLabel}):null]});return n.jsx(f,{as:"li",role:"listitem",listStyleType:"none",flex:"1 1 92px",minW:"92px",animation:`${_s} 320ms ease-out both`,sx:{animationDelay:`${s}ms`,"@media (prefers-reduced-motion: reduce)":{animation:"none"}},children:a?n.jsx(f,{as:"button",type:"button",w:"100%",px:0,py:1,bg:"transparent",borderRadius:"6px",cursor:"pointer","aria-label":`${e.label}: ${d}`,"aria-current":u?"step":void 0,onClick:()=>a(e.stage),_hover:{bg:o.surface.primary},_focusVisible:{outline:"2px solid",outlineColor:o.primaryAction.default,outlineOffset:"1px"},transition:"background 120ms ease",children:b}):n.jsxs(f,{py:1,"aria-current":u?"step":void 0,children:[b,n.jsx(Mn,{children:d})]})})}const rr={background:o.surface.primary,kindLabelColor:o.text.label},js={sentry:{background:o.accentColors.errorLight,kindLabelColor:o.accentColors.errorStrong},trace:{background:o.accentColors.infoLight,kindLabelColor:o.accentColors.infoDark},deploy:{background:o.accentColors.successLight,kindLabelColor:o.accentColors.successStrong},event:{background:o.accentColors.infoLight,kindLabelColor:o.accentColors.infoDark}},Cs=["sentry","trace","deploy","file","event","log","openpanel","cloudflare","stripe","modal","langsmith","github","unknown"],ks=new Map(Cs.map(e=>[lt(e),js[e]??rr]));function As(e){return ks.get(e)??rr}const Ts=28,fn="https://mindflow-pa.sentry.io/issues/",Es="https://analytics.jungleai.com",Is="https://dash.cloudflare.com/",Ls="https://dashboard.stripe.com",Rs="https://modal.com/apps",mn="https://smith.langchain.com/o/c703ea79-d17d-4cfc-b1b4-562178b7a4f3/projects/p/0458417e-999f-4b90-8955-73bda7418d3b",hn="https://github.com/Jungle-Learning",gn=new Set(["sentry","openpanel","cloudflare","stripe","modal","langsmith","github"]);function ir(e){return typeof e=="string"?e.trim().toLowerCase().replace(/[\s-]+/g,"_"):""}function or(e,r){const t=new RegExp(`^${r}:`,"i");return e.replace(t,"").trim()}function sr(e,r){const t=ir(e);if(gn.has(t))return t;if(t==="trace")return"langsmith";if(t==="event")return"openpanel";if(t==="deploy"||t==="file")return"github";const i=r.trim().toLowerCase(),s=i.split(":",1)[0]??"";if(gn.has(s))return s;if(/^(cus|sub|ch|pi|in|re)_/.test(i))return"stripe";if(t==="log"||t==="unknown"){if(/cloudflare|cf[-_ ]?ray|worker/.test(i))return"cloudflare";if(/modal|modal-run|^(ap|fc)-/.test(i))return"modal"}return/^jungle-(web|backend|mobile):/.test(i)?"github":null}function zs(e){return e.split("/").map(r=>encodeURIComponent(r)).join("/")}function Ns(e,r){var x;const t=ir(e),s=or(r,"github").match(/^(jungle-web|jungle-backend|jungle-mobile):(.*)$/i);if(!s)return hn;const a=s[1].toLowerCase(),l=s[2].trim(),d=`${hn}/${a}`;if(t==="deploy"||/^[a-f\d]{7,40}$/i.test(l))return`${d}/commit/${encodeURIComponent(l)}`;
38const u=l.match(/^(.*?)(?::(\d+)(?:-(\d+))?)?$/),p=((x=u==null?void 0:u[1])==null?void 0:x.trim())??"";if(!p)return d;const _=u==null?void 0:u[2],b=u==null?void 0:u[3],g=_?`#L${_}${b?`-L${b}`:""}`:"";return`${d}/blob/${a==="jungle-mobile"?"master":"main"}/${zs(p)}${g}`}function _n(e,r){const t=sr(e,r);if(!t)return null;const i=or(r,t);return t==="sentry"?/^\d+$/.test(i)?`${fn}${i}/`:`${fn}?query=${encodeURIComponent(i)}`:t==="openpanel"?Es:t==="cloudflare"?Is:t==="stripe"?`${Ls}/search?query=${encodeURIComponent(i)}`:t==="modal"?Rs:t==="langsmith"?i?`${mn}/r/${encodeURIComponent(i)}`:mn:t==="github"?Ns(e,r):null}function Pe(e){if(typeof e=="string"){const r=e.trim();return r.length>0?r:null}return typeof e=="number"&&Number.isFinite(e)?String(e):null}function Ms(e){if(typeof e!="string")return null;const r=e.trim();if(!r)return null;try{const t=new URL(r);return t.protocol!=="http:"&&t.protocol!=="https:"?null:r}catch{return null}}function xn(e){const r=Pe(e);if(r!==null){const d=sr("unknown",r)??"unknown";return{meta:lt(d),refText:r,url:_n(d,r)}}if(typeof e!="object"||e===null||Array.isArray(e))return null;const t=e,i=Pe(t.ref)??Pe(t.id)??Pe(t.label)??Pe(t.value),s=Ms(t.url);if(i===null&&s===null)return null;const a=i??s??"",l=s===null?_n(t.kind,a):null;return{meta:lt(t.kind),refText:a,url:s??l}}function Fs(e){if(!Array.isArray(e)){const t=xn(e);return t?[t]:[]}const r=[];for(const t of e){const i=xn(t);i&&r.push(i)}return r}function Ws({chip:e,maxRefLength:r}){const t=As(e.meta),i=Te(e.refText,r),s=`${e.meta.description}: ${e.refText}`,a=n.jsxs(n.Fragment,{children:[n.jsx(f,{as:"span","aria-hidden":"true",fontSize:"11px",lineHeight:"1",color:t.kindLabelColor,children:e.meta.glyph}),n.jsx(c,{as:"span",fontSize:"10px",fontWeight:"700",letterSpacing:"0.04em",textTransform:"uppercase",lineHeight:"1.2",color:t.kindLabelColor,flexShrink:0,children:e.meta.label}),n.jsx(c,{as:"span",fontFamily:"mono",fontSize:"11.5px",lineHeight:"1.3",color:o.text.body,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:i})]}),l={display:"inline-flex",alignItems:"center",gap:"6px",px:"8px",py:"3px",maxW:"100%",borderWidth:"1px",borderColor:o.surface.border,borderRadius:"6px",bg:t.background};return e.url?n.jsxs(Se,{href:e.url,target:"_blank",rel:"noopener noreferrer",title:s,"aria-label":`${e.meta.label} evidence ${e.refText}, opens in a new tab`,transition:"border-color 120ms ease",sx:{"@media (prefers-reduced-motion: reduce)":{transition:"none"}},_hover:{borderColor:o.surface.hoverBorder,textDecoration:"none"},_focusVisible:{outline:"2px solid",outlineColor:o.primaryAction.default,outlineOffset:"1px"},...l,children:[a,n.jsx(f,{as:"span","aria-hidden":"true",fontSize:"9px",lineHeight:"1",color:t.kindLabelColor,children:"â"})]}):n.jsx(f,{as:"span",title:s,cursor:"default",...l,children:a})}function $s({evidenceRefs:e,emptyLabel:r}){const{t}=O(),i=Fs(e);if(i.length===0){const s=typeof r=="string"?r.trim():"";return s?n.jsx(c,{fontSize:"12px",color:o.text.placeholder,children:s}):null}return n.jsx(v,{as:"ul",role:"list","aria-label":t("admin_support.investigations_evidencechips.evidence_7ea014de","Evidence"),wrap:"wrap",gap:2,m:0,p:0,listStyleType:"none",children:i.map((s,a)=>n.jsx(f,{as:"li",display:"inline-flex",maxW:"100%",minW:0,children:n.jsx(Ws,{chip:s,maxRefLength:Ts})},`${a}:${s.refText}`))})}const It="ui-monospace, SFMono-Regular, Menlo, monospace",Os=["text","step","claim","statement","description","summary","detail"],Ds=["sentry","trace","deploy","file","event","log","openpanel","cloudflare","stripe","modal","langsmith","github","unknown"],Us=["high","medium","low"];function ht(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function Fe(e){if(typeof e=="string")return e.trim();if(typeof e=="number"&&Number.isFinite(e))return String(e);const r=ht(e);if(!r)return"";for(const t of Os){const i=r[t];if(typeof i=="string"&&i.trim())return i.trim()}return""}function at(e){return Array.isArray(e)?e.map(Fe).filter(r=>r.length>0):typeof e=="string"?e.split(` 39`).map(r=>r.trim()).filter(r=>r.length>0):[]}function Ps(e){if(typeof e!="string")return"unknown";const r=e.trim().toLowerCase();return Ds.find(t=>t===r)??"unknown"}function Hs(e){if(e==null)return[];const r=Array.isArray(e)?e:[e],t=[];for(const i of r){if(typeof i=="string"){const u=i.trim();u&&t.push({kind:"unknown",ref:u,url:null});continue}const s=ht(i);if(!s)continue;const a=typeof s.url=="string"?s.url.trim():"",l=Ne(a)?a:null,d=Fe(s.ref)||Fe(s.id)||Fe(s.value);!d&&!l||t.push({kind:Ps(s.kind),ref:d||l||"",url:l})}return t}const Bs=/\b(?:unrelated|irrelevant|did not match|does not match|didn't match|no match|different issue|not this|not related)\b/i;function qs(e,r){const t=at(r);return t.length===0?e:e.filter(i=>i.kind!=="sentry"?!0:t.some(s=>s.includes(i.ref)&&!Bs.test(s)))}function Vs(e){if(typeof e!="string")return null;const r=e.trim().toLowerCase();return Us.find(t=>t===r)??null}function Ks(e,r){const t=ht(e),i=ht(r),s=Fe(t==null?void 0:t.statement),a=at(t==null?void 0:t.causal_chain),l=at(t==null?void 0:t.repro_steps),d=qs(Hs(t==null?void 0:t.evidence_refs),i==null?void 0:i.load_bearing_evidence);if(s.length>0||a.length>0||l.length>0||d.length>0)return{statementText:s,causalChainSteps:a,reproSteps:l,evidenceRefs:d,evidenceProseLines:[],confidenceBand:null,confidenceLabel:"",isLegacyDiagnosis:!1,hasAnyContent:!0};const p=Fe(i==null?void 0:i.what_went_wrong),_=at(i==null?void 0:i.load_bearing_evidence),b=i==null?void 0:i.confidence,g=Vs(b);return{statementText:p,causalChainSteps:[],reproSteps:[],evidenceRefs:[],evidenceProseLines:_,confidenceBand:g,confidenceLabel:typeof b=="string"?$n(b):"",isLegacyDiagnosis:!0,hasAnyContent:p.length>0||_.length>0}}function Gs(e){const r=[];e.statementText&&r.push(`Root cause 40${e.statementText}`),e.confidenceLabel&&r.push(e.confidenceLabel),e.causalChainSteps.length>0&&r.push(`Why did this happen? 41${e.causalChainSteps.map(i=>`- ${i}`).join(` 42`)}`),e.reproSteps.length>0&&r.push(`Reproduction steps 43${e.reproSteps.map((i,s)=>`${s+1}. ${i}`).join(` 44`)}`);const t=[...e.evidenceRefs.map(i=>`- ${i.kind==="unknown"?"":`${i.kind}: `}${i.ref}${i.url?` (${i.url})`:""}`),...e.evidenceProseLines.map(i=>`- ${i}`)];return t.length>0&&r.push(`Evidence 45${t.join(` 46`)}`),r.join(` 47 48`)}const Ys=ue` 49 from { opacity: 0; transform: translateY(4px); } 50 to { opacity: 1; transform: translateY(0); } 51`;function Je(e){return{"@media (prefers-reduced-motion: no-preference)":{animation:`${Ys} 260ms ease-out ${e}ms both`}}}function St({children:e,id:r}){return n.jsx(c,{as:"h4",id:r,fontSize:"10.5px",fontWeight:"700",textTransform:"uppercase",letterSpacing:"0.06em",color:o.text.label,mb:2,children:e})}function bn({value:e}){const r=Te(e);return n.jsx(f,{as:"code",title:r===e?void 0:e,fontFamily:It,fontSize:"0.88em",bg:o.surface.secondary,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"4px",color:o.text.header,px:"4px",py:"1px",whiteSpace:"nowrap",children:r})}function Lt({text:e}){const r=h.useMemo(()=>Mt(e),[e]);return n.jsx(n.Fragment,{children:r.map((t,i)=>{if(t.kind==="reference")return n.jsxs(f,{as:"span",display:"inline-flex",alignItems:"center",gap:"3px",whiteSpace:"nowrap",children:[n.jsx(bn,{value:t.value}),n.jsx(Nt,{reference:t.reference})]},`${i}-${t.reference.kind}-${t.value}`);const s=Wt(t.value),a=/^\s/.test(t.value),l=/\s$/.test(t.value);return n.jsxs(ze.Fragment,{children:[a?" ":null,s.map((d,u)=>n.jsxs(ze.Fragment,{children:[u>0?" ":null,d.kind==="identifier"?n.jsx(bn,{value:d.value}):d.value]},`${u}-${d.value}`)),l?" ":null]},`${i}-text`)})})}function Xs({steps:e,labelledById:r}){return n.jsx(f,{as:"ol","aria-labelledby":r,listStyleType:"none",m:0,p:0,children:e.map((t,i)=>{const s=i===0,a=i===e.length-1;return n.jsxs(v,{as:"li",gap:2.5,align:"stretch",children:[n.jsxs(f,{position:"relative",w:"18px",flexShrink:0,"aria-hidden":"true",children:[s?null:n.jsx(f,{position:"absolute",left:"7px",top:"0",h:"6px",w:"2px",bg:o.surface.tertiary}),a?null:n.jsx(f,{position:"absolute",left:"7px",top:"16px",bottom:"0",w:"2px",bg:o.surface.tertiary}),n.jsx(f,{position:"absolute",left:"3px",top:"6px",w:"10px",h:"10px",borderRadius:"full",borderWidth:"2px",borderColor:a?o.accentColors.infoDark:o.surface.tertiary,bg:a?o.accentColors.infoDark:o.surface.white})]}),n.jsx(c,{fontSize:"14px",lineHeight:"1.55",color:a?o.text.header:o.text.body,fontWeight:a?"600":"400",pb:a?0:3.5,children:n.jsx(Lt,{text:t})})]},`${i}-${t}`)})})}function Zs({steps:e,labelledById:r}){return n.jsx(f,{as:"ol","aria-labelledby":r,listStyleType:"none",m:0,p:0,children:e.map((t,i)=>n.jsxs(v,{as:"li",gap:2.5,align:"flex-start",mb:1,children:[n.jsx(c,{as:"span","aria-hidden":"true",fontFamily:It,fontSize:"12px",lineHeight:"1.6",color:o.text.placeholder,minW:"16px",textAlign:"right",flexShrink:0,children:i+1}),n.jsx(c,{as:"span",fontFamily:It,fontSize:"12.5px",lineHeight:"1.6",color:o.text.body,whiteSpace:"pre-wrap",children:n.jsx(ee,{text:t})})]},`${i}-${t}`))})}const ar=h.memo(({rootCause:e,fallbackDiagnosis:r=null})=>{const{t}=O(),i=h.useId(),s=h.useId(),a=h.useId(),l=h.useMemo(()=>Ks(e,r),[e,r]),d=h.useMemo(()=>Gs(l),[l]),[u,p]=h.useState("idle");h.useEffect(()=>{if(u==="idle")return;const g=window.setTimeout(()=>p("idle"),2400);return()=>window.clearTimeout(g)},[u]);const _=h.useCallback(async()=>{try{const g=typeof navigator>"u"?void 0:navigator.clipboard;if(!(g!=null&&g.writeText))throw new Error("Clipboard is unavailable here");await g.writeText(d),p("copied")}catch{p("failed")}},[d]),b=me(zt(l.confidenceBand));return n.jsxs(f,{as:"section","aria-labelledby":i,bg:o.surface.white,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"8px",px:5,py:4,mb:3,sx:Je(0),children:[n.jsxs(v,{align:"center",justify:"space-between",gap:3,mb:2.5,children:[n.jsxs(v,{align:"center",gap:2,minW:0,children:[n.jsx(c,{as:"h3",id:i,fontSize:"10.5px",fontWeight:"700",textTransform:"uppercase",letterSpacing:"0.06em",color:o.text.label,children:t("admin_support.investigations_rootcausecard.root_cause_32fd8829","Root cause")}),l.confidenceLabel?n.jsx(f,{bg:b.backgroundColor,color:b.textColor,borderRadius:"full",px:2,py:"1px",children:n.jsx(c,{fontSize:"10.5px",fontWeight:"700",children:l.confidenceLabel})}):null]}),l.hasAnyContent?n.jsx(fe,{size:"xs",variant:"outline",flexShrink:0,onClick:_,"aria-label":t("admin_support.investigations_rootcausecard.copy_the_root_cause_as_text_44b50f8e","Copy the root cause as text"),children:u==="copied"?t("admin.support.copied","Copied"):u==="failed"?t("admin.support.copy_failed","Copy failed"):t("admin.support.copy","Copy")}):null]}),n.jsx(Mn,{role:"status","aria-live":"polite",children:u==="copied"?t("admin.support.investigations.root_cause_copied","Root cause copied to the clipboard"):u==="failed"?t("admin.support.investigations.root_cause_copy_failed","Could not copy the root cause"):""}),l.hasAnyContent?n.jsxs(n.Fragment,{children:[l.statementText?n.jsx(c,{fontSize:"20px",fontWeight:"600",lineHeight:"1.42",color:o.text.header,mb:l.causalChainSteps.length>0?5:4,children:n.jsx(Lt,{text:l.statementText})}):n.jsx(c,{fontSize:"13px",lineHeight:"1.6",color:o.text.placeholder,mb:4,children:t("admin_support.investigations_rootcausecard.no_one_paragraph_statement_was_written_so_the_chain_below_is_the_whole_a_af046bf8","No one-paragraph statement was written, so the chain below is the whole answer.")}),l.causalChainSteps.length>0?n.jsxs(f,{mb:5,sx:Je(60),children:[n.jsx(St,{id:s,children:t("admin_support.investigations_rootcausecard.why_did_this_happen_e0dbe23c","Why did this happen?")}),n.jsx(Xs,{steps:l.causalChainSteps,labelledById:s})]}):null,l.reproSteps.length>0?n.jsxs(f,{mb:5,sx:Je(120),children:[n.jsx(St,{id:a,children:t("admin_support.investigations_rootcausecard.reproduction_steps_b0b1f0b6","Reproduction steps")}),n.jsx(Zs,{steps:l.reproSteps,labelledById:a})]}):null,n.jsxs(f,{sx:Je(180),children:[n.jsx(St,{children:t("admin_support.investigations_rootcausecard.evidence_7ea014de","Evidence")}),l.evidenceRefs.length>0?n.jsx($s,{evidenceRefs:l.evidenceRefs}):null,l.evidenceProseLines.length>0?n.jsx(f,{as:"ul",listStyleType:"none",m:0,p:0,children:l.evidenceProseLines.map((g,m)=>n.jsxs(v,{as:"li",gap:2,align:"flex-start",mb:1,children:[n.jsx(c,{as:"span","aria-hidden":"true",fontSize:"13px",lineHeight:"1.55",color:o.text.placeholder,children:"â¢"}),n.jsx(c,{as:"span",fontSize:"13px",lineHeight:"1.55",color:o.text.body,children:n.jsx(Lt,{text:g})})]},`${m}-${g}`))}):null,l.evidenceRefs.length===0&&l.evidenceProseLines.length===0?n.jsx(c,{fontSize:"12.5px",lineHeight:"1.55",color:o.text.placeholder,children:t("admin_support.investigations_rootcausecard.no_artifacts_were_attached_to_this_root_cause_treat_it_as_unverified_25612ae3","No artifacts were attached to this root cause. Treat it as unverified.")}):null]})]}):n.jsx(c,{fontSize:"13px",lineHeight:"1.6",color:o.text.placeholder,children:t("admin_support.investigations_rootcausecard.no_root_cause_has_been_recorded_on_this_investigation_yet_it_either_hasn_7f62eebf","No root cause has been recorded on this investigation yet. It either hasn't reached the hypotheses stage or it finished without naming one.")})]})});ar.displayName="RootCauseCard";const Js="ui-monospace, SFMono-Regular, Menlo, monospace",yn=84,Qs=["header","rootCause","hypotheses","fixer","customerEvidence","actions"],ea={intake:"header",triage:"rootCause",evidence:"customerEvidence",hypotheses:"hypotheses",fixing:"fixer",awaiting_human_merge:"fixer",verifying:"fixer",waiting_on_user:"customerEvidence",closed:"actions"},ta=["actions_taken","actions","audit_rows","audit_log"];function je(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function le(e){return typeof e=="string"?e.trim():""}function vn(e){const r=typeof e=="number"?e:typeof e=="string"&&e.trim()?Number(e.trim()):Number.NaN;return!Number.isFinite(r)||r<0?null:Math.floor(r)}function Qe(e,r){const t=je(e);if(!t)return[];for(const i of r){const s=t[i];if(Array.isArray(s))return s}return[]}function na(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}class lr extends h.Component{constructor(){super(...arguments),this.state={hasRenderFailed:!1}}static getDerivedStateFromError(){return{hasRenderFailed:!0}}componentDidCatch(r,t){Ct(r,{scope:"support-investigation-card",tags:{investigationCard:this.props.cardName},extra:{componentStack:t.componentStack}})}render(){return this.state.hasRenderFailed?n.jsx(Rt,{label:this.props.fallbackLabel,message:this.props.fallbackMessage,tone:"warning"}):this.props.children}}function Rt({label:e,message:r,tone:t="neutral"}){const i=me(t);return n.jsxs(f,{role:"status",bg:o.surface.white,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"8px",px:4,py:3,mb:3,children:[n.jsx(c,{fontSize:"10.5px",fontWeight:"700",textTransform:"uppercase",letterSpacing:"0.06em",color:i.textColor,mb:1,children:e}),n.jsx(c,{fontSize:"12.5px",color:o.text.label,lineHeight:"1.5",children:r})]})}function ra({text:e}){const r=Wt(e);return n.jsx(n.Fragment,{children:r.map((t,i)=>n.jsxs(ze.Fragment,{children:[i>0?" ":null,t.kind==="identifier"?n.jsx(c,{as:"span",fontFamily:Js,fontSize:"10.5px",children:Te(t.value,14)}):t.value]},`${i}-${t.value}`))})}function Sn({ariaLabel:e,chips:r}){return r.length===0?null:n.jsx(v,{as:"ul",role:"list","aria-label":e,wrap:"wrap",gap:1.5,m:0,p:0,listStyleType:"none",children:r.map(t=>{const i=me(t.tone);return n.jsx(f,{as:"li",bg:i.backgroundColor,color:i.textColor,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"full",px:2,py:"2px",maxW:"100%",title:t.fullText,children:n.jsx(c,{fontSize:"11px",fontWeight:"600",lineHeight:"1.5",children:n.jsx(ra,{text:t.label})})},t.reactKey)})})}function wn({title:e,summary:r,children:t}){const{t:i}=O(),[s,a]=h.useState(!1),l=h.useId(),d=h.useId();return n.jsxs(f,{as:"section","aria-labelledby":d,bg:o.surface.offWhite,borderWidth:"1px",borderColor:o.surface.border,borderRadius:"8px",mb:3,overflow:"hidden",children:[n.jsxs(v,{as:"button",type:"button",onClick:()=>a(u=>!u),"aria-expanded":s,"aria-controls":l,align:"baseline",justify:"space-between",gap:3,w:"100%",px:4,py:3,cursor:"pointer",textAlign:"left",_hover:{bg:o.surface.primary},_focusVisible:{boxShadow:`inset 0 0 0 2px ${o.primaryAction.default}`},transition:"background 120
51ms ease",children:[n.jsxs(v,{align:"baseline",gap:2,minW:0,children:[n.jsx(c,{id:d,fontSize:"11px",fontWeight:"800",textTransform:"uppercase",letterSpacing:"0.06em",color:o.text.label,children:e}),r?n.jsx(c,{fontSize:"11px",color:o.text.placeholder,noOfLines:1,children:r}):null]}),n.jsxs(v,{align:"center",gap:1.5,flexShrink:0,children:[n.jsx(c,{fontSize:"11px",fontWeight:"700",color:o.text.label,children:s?i("admin.support.hide","Hide"):i("admin.support.show","Show")}),n.jsx(c,{"aria-hidden":"true",fontSize:"10px",color:o.text.placeholder,transform:s?"rotate(90deg)":void 0,transition:"transform 140ms ease",children:"â¸"})]})]}),s?n.jsx(f,{id:l,px:4,pb:4,pt:1,children:t}):null]})}function ye({cardName:e,investigationId:r,anchorRef:t,children:i}){const{t:s}=O();return n.jsx(f,{ref:t,sx:{scrollMarginTop:"12px"},children:n.jsx(lr,{cardName:e,fallbackLabel:s("admin.support.investigations.card_unavailable","Card unavailable"),fallbackMessage:s("admin.support.investigations.card_unavailable_message","The {cardName} card could not be rendered from this record. Everything else on this investigation is unaffected.",{cardName:e}),children:i},r)})}function ia(e){const r=[],t=je(e.incident),i=vn(t==null?void 0:t.conversation_count);i!==null&&i>0&&r.push({reactKey:"conversation-count",label:i===1?"1 conversation":`${i} conversations`,tone:i>1?"warning":"neutral"});const s=je(e.blast_radius),a=vn(s==null?void 0:s.affected_user_count),l=le(s==null?void 0:s.single_user_or_systemic),d=a!==null&&a>0?`${a} ${a===1?"user":"users"} affected`:"";l==="systemic"?r.push({reactKey:"blast-radius",label:d?`systemic · ${d}`:"systemic",tone:"warning"}):l==="single_user"?r.push({reactKey:"blast-radius",label:"single user",tone:"neutral"}):d&&r.push({reactKey:"blast-radius",label:d,tone:"neutral"});const u=le(s==null?void 0:s.deploy_correlation);if(u){const p=u.length>yn;r.push({reactKey:"deploy-correlation",label:p?`${u.slice(0,yn).trimEnd()}â¦`:u,tone:"neutral",fullText:p?u:void 0})}return r}function oa({investigation:e}){var a;const{t:r}=O(),t=Pn(e.user_context).map((l,d)=>({reactKey:`user-context-${d}-${l.label}`,label:l.label,tone:l.tone})),i=ia(e),s=((a=je(e.incident))==null?void 0:a.blocks_deploy)===!0;return n.jsxs(n.Fragment,{children:[t.length>0||i.length>0?n.jsxs(v,{direction:"column",gap:1.5,mb:3,children:[n.jsx(Sn,{ariaLabel:"Customer context",chips:t}),n.jsx(Sn,{ariaLabel:"Incident context",chips:i})]}):null,s?n.jsxs(f,{role:"status",bg:o.accentColors.warningLight,borderWidth:"1px",borderLeftWidth:"3px",borderColor:o.surface.border,borderLeftColor:o.accentColors.warningStrong,borderRadius:"6px",px:3,py:2,mb:3,children:[n.jsx(c,{fontSize:"11px",fontWeight:"800",textTransform:"uppercase",letterSpacing:"0.06em",color:o.accentColors.warningStrong,children:r("admin_support.investigations_investigationfindingspanel.re_validating_this_diagnosis_a76716c4","Re-validating this diagnosis")}),n.jsx(c,{fontSize:"12.5px",color:o.text.body,lineHeight:"1.5",mt:1,children:r("admin_support.investigations_investigationfindingspanel.new_evidence_landed_on_this_incident_so_the_diagnosis_below_is_being_re_15c70052","New evidence landed on this incident, so the diagnosis below is being re-checked and the pending fix is held out of deploy until it clears. Read what follows as provisional.")})]}):null,n.jsx(qr,{summary:e.generation_summary}),e.engineering_runtime==="conductor_incident_v1"&&n.jsx(Qt,{investigation:e}),n.jsx(Jo,{investigation:e}),e.engineering_runtime!=="conductor_incident_v1"&&n.jsx(Qt,{investigation:e})]})}function sa(e){const r=[];for(const t of e){const i=t.attachments;if(Array.isArray(i))for(const s of i)r.push(s)}return r}function aa(e){return On(e.brief)}function la(e,r){return oi(e.brief,e.created_at,(r==null?void 0:r.messages)??[])}function ca(e,r,t){const i=je(e.brief),s=je(i==null?void 0:i.customer_message_english_translation),a=le(s==null?void 0:s.translated_text);if(a)return{translated_text:a,source_language_code:le(s==null?void 0:s.source_language_code)||null,source_language_name:le(s==null?void 0:s.source_language_name)||null};const l=[...(r==null?void 0:r.messages)??[]].reverse().find(p=>p.role==="user"&&typeof p.content=="string"&&p.content.trim()===t.trim()),d=je(l==null?void 0:l.english_translation),u=le(d==null?void 0:d.translated_text);return u?{translated_text:u,source_language_code:le(d==null?void 0:d.source_language_code)||null,source_language_name:le(d==null?void 0:d.source_language_name)||null}:null}function da({investigation:e,isLoadingInvestigation:r,loadErrorMessage:t,onInvestigationUpdated:i}){var Oe,M;const{t:s}
51=O(),[a,l]=h.useState(!1),[d,u]=h.useState({phase:"idle"}),[p,_]=h.useState(null),[b,g]=h.useState(null),m=(e==null?void 0:e.id)??"",x=(e==null?void 0:e.conversation_id)??"",A=h.useRef(m),y=h.useRef(0),w=h.useRef(null);A.current=m,h.useEffect(()=>{l(!1),w.current=null,_(null),g(null)},[m]);const k=h.useRef({}),S=h.useMemo(()=>{const N={};for(const R of Qs)N[R]=D=>{k.current[R]=D};return N},[]),L=h.useCallback(N=>{const R=k.current[ea[N]];!R||typeof R.scrollIntoView!="function"||R.scrollIntoView({behavior:na()?"auto":"smooth",block:"start"})},[]),E=h.useCallback(async()=>{if(m)try{const N=await Rn(m);i(N)}catch{}},[m,i]),j=h.useCallback(async N=>{if(!m||w.current)return;const R=m,D=y.current+1;y.current=D,w.current={investigationId:R,requestId:D};const G=()=>{var U,ie;return A.current===R&&((U=w.current)==null?void 0:U.investigationId)===R&&((ie=w.current)==null?void 0:ie.requestId)===D};_(N),g(null);try{const U=await zn({investigationId:R,reviewState:N});if(!G())return;i(U)}catch(U){if(!G())return;g(U instanceof Error?U.message:String(U))}finally{G()&&(w.current=null,_(null))}},[m,i]);h.useEffect(()=>{if(!x){u({phase:"idle"});return}let N=!0;return u({phase:"loading"}),Ln(x).then(R=>{var D;N&&u({phase:"loaded",attachments:sa(R.messages),debugContext:((D=R.conversation)==null?void 0:D.bug_investigation_debug_context)??null,threadData:R})}).catch(R=>{N&&u({phase:"error",message:R instanceof Error?R.message:String(R)})}),()=>{N=!1}},[x]);const C=h.useMemo(()=>Qe(e==null?void 0:e.findings,["hypotheses"]),[e]),I=h.useMemo(()=>Qe(e,ta),[e]),$=h.useMemo(()=>{var R;const N=$r(e==null?void 0:e.brief);return N||(d.phase!=="loaded"?null:((R=d.threadData.messages.find(D=>D.product_context))==null?void 0:R.product_context)??null)},[d,e==null?void 0:e.brief]),T=h.useMemo(()=>{const N=Qe(e,["conversation_ids"]).filter(R=>typeof R=="string");return x&&N.push(x),N},[e,x]);if(r&&!e)return n.jsxs(v,{align:"center",justify:"center",h:"100%",direction:"column",gap:3,children:[n.jsx(gt,{size:"sm",color:o.primaryAction.default}),n.jsx(c,{fontSize:"13px",color:o.text.label,children:s("admin_support.investigations_investigationfindingspanel.loading_this_investigation_d4987cae","Loading this investigationâ¦")})]});if(t&&!e)return n.jsx(f,{p:6,children:n.jsx(f,{p:4,bg:o.accentColors.errorLight,borderRadius:"6px",borderWidth:"1px",borderColor:o.surface.border,children:n.jsxs(c,{fontSize:"14px",color:o.accentColors.errorStrong,children:[s("admin_support.investigations_investigationfindingspanel.couldnt_load_this_investigation_c7eb7913","Couldn't load this investigation:")," ",t]})})});if(!e)return n.jsx(v,{align:"center",justify:"center",h:"100%",px:6,children:n.jsx(c,{fontSize:"13px",color:o.text.placeholder,textAlign:"center",children:s("admin_support.investigations_investigationfindingspanel.pick_an_investigation_on_the_left_to_see_what_the_agent_found_80071a84","pick an investigation on the left to see what the agent found.")})});const F=le(e.status),B=e.review_state,re=le(e.reason_category),W=le(e.outcome),z=le(e.trigger),Z=aa(e),q=la(e,d.phase==="loaded"?d.threadData:null),de=ca(e,d.phase==="loaded"?d.threadData:null,q),se=me(In(e.status)),ae=je(e.root_cause),we=!!(le(ae==null?void 0:ae.statement)||Qe(ae,["causal_chain"]).length>0),V=je(e.fixer),te=le(e.last_activity_at)||le(V==null?void 0:V.last_activity_at)||e.completed_at,K=e.engineering_runtime==="conductor_incident_v1",xe=F==="running"||F==="queued";return n.jsxs(f,{h:"100%",overflowY:"auto",px:5,py:5,children:[n.jsxs(f,{ref:S.header,sx:{scrollMarginTop:"12px"},children:[n.jsxs(f,{as:"header",mb:3,children:[n.jsxs(v,{align:"flex-start",justify:"space-between",gap:4,direction:{base:"column",xl:"row"},children:[n.jsx(f,{minW:0,children:n.jsx(c,{as:"h2",fontSize:"18px",fontWeight:"800",color:o.text.header,lineHeight:"1.35",children:n.jsx(ee,{text:Z||kt(re)||s("admin.support.investigations.investigation","Investigation")})})}),n.jsxs(v,{direction:"column",align:{base:"flex-start",xl:"flex-end"},gap:1.5,flexShrink:0,children:[n.jsxs(v,{align:"center",gap:2,wrap:"wrap",children:[!K&&n.jsx(f,{bg:se.backgroundColor,color:se.textColor,borderRadius:"full",px:2.5,py:1,children:n.jsx(c,{fontSize:"11px",fontWeight:"700",children:Ft(F)||s("admin.support.investigations.status_not_recorded","Status not recorded")})}),B?n.jsx(f,{bg:B==="needs_review"?o.accentColors.warningLight:o.accentColors.successLight,color:B==="needs_review"?o.accentColors.warningStrong:o.accentColors.successStrong,borderRadius:"full",px:2.5,py:1,children:n.jsx(c,{fontSize:"11px",fontWeight:"700",children:B==="needs_review"?s("admin.support.threads.filter.needs_review","Needs review"):s("admin.support.investigations.review.closed","Closed")})}):null]}),n.jsxs(v,{align:"center",gap:1,"aria-label":s("admin.support.investigations.review.status","Review status"),children:[n.jsx(fe,{size:"xs",variant:B==="needs_review"?"solid":"ghost",colorScheme:B==="needs_review"?"orange":void 0,isLoading:p==="needs_review",isDisabled:p!==null,onClick:()=>void j("needs_review"),children:s("admin.support.threads.filter.needs_review","Needs review")}),n.jsx(fe,{size:"xs",variant:B==="closed"?"solid":"ghost",colorScheme:B==="closed"?"green":void 0,isLoading:p==="closed",isDisabled:p!==null||F!=="completed"&&F!=="failed",onClick:()=>void j("closed"),children:s("admin.support.investigations.review.closed","Closed")})]})]})]}),b?n.jsxs(c,{fontSize:"12px",color:o.accentColors.errorStrong,mt:2,textAlign:"right",children:[s("admin.support.investigations.review.update_failed","Couldn't update review status.")," ",b]}):null]}),n.jsx(lr,{cardName:"investigation context",fallbackLabel:s("admin.support.investigations.card_unavailable","Card unavailable"),fallbackMessage:s("admin.support.investigations.card_unavailable_message","The {cardName} card could not be rendered from this record. Everything else on this investigation is unaffected.",{cardName:"investigation context"}),children:n.jsx(oa,{investigation:e})},m),n.jsxs(f,{mb:3,px:3,py:3,bg:o.surface.offWhite,borderLeftWidth:"3px",borderLeftColor:o.primaryAction.default,borderRadius:"4px",children:[n.jsx(c,{fontSize:"10.5px",fontWeight:"800",textTransform:"uppercase",color:o.text.label,children:s("admin.support.investigations.context.
51issue_reported","Issue reported")}),n.jsx(c,{fontSize:"14px",fontWeight:"700",color:o.text.header,lineHeight:"1.45",mt:.5,children:n.jsx(ee,{text:Z||kt(re)||s("admin.support.investigations.investigation","Investigation")})}),n.jsx(c,{fontSize:"10.5px",fontWeight:"800",textTransform:"uppercase",color:o.text.label,mt:3,children:s("admin.support.investigations.context.exact_user_message","Exact user message")}),n.jsx(f,{fontSize:"13.5px",color:o.text.body,lineHeight:"1.55",mt:1,whiteSpace:"pre-wrap",children:q?n.jsx(Or,{originalText:q,englishTranslation:de,renderText:N=>n.jsx(ee,{text:N})}):n.jsx(ee,{text:d.phase==="loading"?s("admin.support.investigations.context.loading_message","Loading messageâ¦"):s("admin.support.investigations.context.message_not_recorded","Message not recorded")})}),!K&&n.jsxs(c,{fontSize:"12px",color:o.text.label,mt:2,children:[Fn(W)||s("admin.support.investigations.no_outcome_yet","No outcome yet"),z?` · ${Jr(z)}`:""]})]}),n.jsxs(v,{align:"center",justify:"space-between",gap:3,mb:3,wrap:"wrap",children:[n.jsx(fe,{size:"sm",variant:"outline",onClick:()=>l(N=>!N),leftIcon:a?n.jsx(Br,{width:16,height:16}):n.jsx(br,{width:16,height:16}),"aria-expanded":a,"aria-controls":"investigation-conversation-thread",children:a?s("admin.support.investigations.context.hide_conversation","Hide conversation"):s("admin.support.investigations.context.show_conversation","Show conversation")}),x?n.jsxs(Se,{href:Jn(x),isExternal:!0,fontSize:"12px",fontWeight:"700",color:o.primaryAction.default,"aria-label":s("admin.support.investigations.context.open_threads_new_tab","Open in Threads in a new tab"),children:[s("admin.support.investigations.context.open_threads","Open in Threads")," â"]}):null]}),a?n.jsx(f,{id:"investigation-conversation-thread",mb:3,children:n.jsx(Qn,{conversationIds:T,activeConversationId:x||void 0})}):null]}),!K&&n.jsx(ye,{cardName:"follow-up summary",investigationId:m,children:n.jsx(fs,{investigation:e})}),!K&&n.jsxs(n.Fragment,{children:[n.jsx(ye,{cardName:"pipeline timeline",investigationId:m,children:n.jsx(Ss,{investigationStatus:e.status,currentStage:e.pipeline_stage??null,startedAt:e.created_at||null,lastActivityAt:te,onStageClick:L})}),n.jsx(ye,{cardName:"root cause",investigationId:m,anchorRef:S.rootCause,children:n.jsx(ar,{rootCause:e.root_cause??null,fallbackDiagnosis:((Oe=e.findings)==null?void 0:Oe.diagnosis)??null})}),n.jsx(ye,{cardName:"hypotheses",investigationId:m,anchorRef:S.hypotheses,children:n.jsx(Zn,{hypotheses:C,hasRootCause:we})}),n.jsx(ye,{cardName:"fixer",investigationId:m,anchorRef:S.fixer,children:n.jsx(jo,{fixer:e.fixer??null,investigationId:m})})]}),n.jsxs(ye,{cardName:"customer evidence",investigationId:m,anchorRef:S.customerEvidence,children:[d.phase==="loading"?n.jsx(Rt,{label:s("admin_support.investigations_investigationfindingspanel.customer_evidence_535cc5e0","Customer evidence"),message:"Loading the screenshots, recordings and browser context from this conversationâ¦"}):d.phase==="error"?n.jsx(Rt,{label:s("admin_support.investigations_investigationfindingspanel.customer_evidence_535cc5e0","Customer evidence"),message:`Couldn't load what the customer attached: ${d.message}`,tone:"warning"}):n.jsx(qn,{attachments:d.phase==="loaded"?d.attachments:[],debugContext:d.phase==="loaded"?d.debugContext:null}),n.jsx(Dr,{productContext:$,referencedValues:e})]}),(!K||I.length>0||!!e.proposed_action)&&n.jsx(ye,{cardName:"actions and approvals",investigationId:m,anchorRef:S.actions,children:n.jsx(Hn,{proposedAction:e.proposed_action,fixerStatus:((M=e.fixer)==null?void 0:M.status)??null,auditRows:I,investigationId:m,onApproved:E},m)}),!K&&n.jsx(ye,{cardName:"investigator chat",investigationId:m,children:n.jsx(cs,{investigationId:m,disabled:xe},m)}),n.jsx(ye,{cardName:"hand-off brief",investigationId:m,children:e.brief?n.jsx(wn,{title:s("admin_support.investigations_investigationfindingspanel.hand_off_brief_c8f784a6","Hand-off brief"),summary:"what the support agent escalated",children:typeof e.brief=="string"?n.jsx(c,{fontSize:"13.5px",color:o.text.body,whiteSpace:"pre-wrap",children:n.jsx(ee,{text:e.brief})}):Object.entries(e.brief).map(([N,R])=>n.jsxs(f,{mb:1.5,children:[n.jsx(c,{fontSize:"10.5px",fontWeight:"700",color:o.text.label,children:N}),n.jsx(c,{fontSize:"13.5px",color:o.text.body,whiteSpace:"pre-wrap",children:n.jsx(ee,{text:typeof R=="str
51ing"?R:JSON.stringify(R,null,2)})})]},N))}):null}),n.jsx(ye,{cardName:"six-question report",investigationId:m,children:e.findings?n.jsx(wn,{title:s("admin_support.investigations_investigationfindingspanel.full_six_question_report_97876a76","Full six-question report"),summary:"the complete record of what the agent asked and answered",children:n.jsx(er,{findings:e.findings,fallbackConfidence:e.confidence})}):K?null:n.jsx(ns,{status:e.status})})]})}const ua=wr,pa=vr,fa=Sr,cr="all",jn=2,ma=2,ha=[{id:cr,axis:"status",status:null,label:"All",activeColorScheme:"green"},{id:"starred",axis:"status",status:"starred",label:"Starred",activeColorScheme:"yellow"},{id:"running",axis:"status",status:"running",label:"Running",activeColorScheme:"yellow"},{id:"waiting_on_user",axis:"status",status:"waiting_on_user",label:"Waiting",accessibleLabel:"Waiting on the customer",activeColorScheme:"blue"},{id:"completed",axis:"status",status:"completed",label:"Completed",activeColorScheme:"green"},{id:"failed",axis:"status",status:"failed",label:"Failed",activeColorScheme:"red"},{id:"ai_quality_review",axis:"outcome",outcome:"ai_quality_review",label:"AI quality",accessibleLabel:"AI quality review, waiting on a human decision",activeColorScheme:"orange"}],dr=h.memo(({activeFilter:e,investigations:r,isLoadingInvestigations:t,loadErrorMessage:i,selectedInvestigationId:s,onChangeFilter:a,onSelectInvestigation:l,onArchiveInvestigation:d,archivingInvestigationId:u,onToggleInvestigationStar:p,starringInvestigationId:_,onRefresh:b})=>{const{t:g}=O(),[m,x]=h.useState(null),A=e===null?m:null,y=A??e??cr,w=E=>{if(E.axis==="outcome"){x(E.outcome),a(null);return}x(null),a(E.status)},k=h.useMemo(()=>(Array.isArray(r)?r:[]).filter(E=>typeof E=="object"&&E!==null),[r]),S=h.useMemo(()=>k.filter(E=>ga(E,e,A)).sort((E,j)=>Cn(j)-Cn(E)),[k,e,A]),L=k.length>0&&S.length===0;return n.jsxs(f,{w:{base:"100%",md:"240px",xl:"340px"},flexShrink:0,h:{base:"min(200px, 40%)",md:"100%"},overflowY:{base:"auto",md:"visible"},borderRightWidth:"1px",borderColor:o.surface.border,display:"flex",flexDirection:"column",bg:o.surface.white,children:[n.jsxs(f,{px:3,py:3,flexShrink:0,borderBottomWidth:"1px",borderColor:o.surface.border,children:[n.jsxs(v,{align:"center",justify:"space-between",mb:2,children:[n.jsx(c,{fontSize:"14px",fontWeight:"800",color:o.text.header,children:g("admin_support.investigations_investigationssidebar.investigations_dc715e36","Investigations")}),n.jsx(fe,{size:"xs",variant:"outline",onClick:b,isLoading:t,children:g("admin_support.investigations_investigationssidebar.refresh_56e3badc","Refresh")})]}),n.jsx(Ur,{spacing:2,children:ha.map(E=>{const j=y===E.id,C=E.id==="starred"?g("admin.support.filter.starred","Starred"):E.label;return n.jsx(Pr,{children:n.jsx(fe,{size:"xs",variant:j?"solid":"ghost",colorScheme:j?E.activeColorScheme:void 0,"aria-pressed":j,"aria-label":E.accessibleLabel,title:E.accessibleLabel,onClick:()=>w(E),children:C})},E.id)})})]}),n.jsx(f,{flex:{base:"0 0 auto",md:"1"},overflowY:{base:"visible",md:"auto"},children:t&&k.length===0?n.jsxs(v,{direction:"column",align:"center",gap:2,py:6,children:[n.jsx(gt,{size:"sm",color:o.primaryAction.default}),n.jsx(c,{fontSize:"12px",color:o.text.label,children:g("admin_support.investigations_investigationssidebar.loading_investigations_eef3d257","Loading investigationsâ¦")})]}):i?n.jsx(f,{px:3,py:3,children:n.jsxs(c,{fontSize:"13px",color:o.accentColors.errorStrong,children:[g("admin_support.investigations_investigationssidebar.failed_to_load_investigations_3b4418e1","Failed to load investigations:")," ",i]})}):L?n.jsx(f,{px:3,py:4,children:n.jsx(c,{fontSize:"13px",color:o.text.placeholder,textAlign:"center",children:g("admin_support.investigations_investigationssidebar.no_runs_match_this_filter_pick_another_pill_to_see_the_rest_of_the_queue_dafb80cf","no runs match this filter. pick another pill to see the rest of the queue.")})}):S.length===0?n.jsx(f,{px:3,py:4,children:n.jsx(c,{fontSize:"13px",color:o.text.placeholder,textAlign:"center",children:g("admin_support.investigations_investigationssidebar.nothing_here_yet_investigations_show_up_when_the_bot_escalates_a_thread_4a9a4150","nothing here yet. investigations show up when the bot escalates a thread.")})}):n.jsx(yr,{spacing:0,align:"stretch",children:S.map((E,j)=>{const C=Ae(E.id);return n.jsx(ya,{investigation:E,isSelected:C.length>0&&C===s,onSelectInvestigation:l,onArchiveInvestigation:d,isArchiving:C===u,onToggleInvestigationStar:p,isStarring:C===_},C||`investigation-${j}`)})})})]})});dr.displayName="InvestigationsSidebar";function ga(e,r,t){return t?Be(e.outcome)===t:r?r==="starred"?e.is_starred===!0:Be(e.status)===r:!0}function Cn(e){const r=Ae(e.last_activity_at)||Ae(e.created_at),t=Date.parse(r);return Number.isFinite(t)?t:0}function _a(e){return On(e)}const xa=ue` 52 0%, 100% { opacity: 0.35; } 53 50% { opacity: 1; } 54`,ba={"@media (prefers-reduced-motion: reduce)":{animation:"none"}};function ya({investigation:e,isSelected:r,onSelectInvestigation:t,onArchiveInvestigation:i,isArchiving:s,onToggleInvestigationStar:a,isStarring:l}){const{t:d}=O(),u=e.engineering_runtime==="conductor_incident_v1",p=me(u?"neutral":In(e.status)),_=u?d("admin.support.investigations.conductor","Conductor"):Ft(Ae(e.status))||d("admin.support.investigations.status_not_recorded","Status not recorded"),b=Be(e.review_state),g=_a(e.brief),m=Be(wt(e.fixer,"status"))==="running",x=ur(e.incident),A=Ca(wt(x,"conversation_count")),y=ka(wt(x,"blocks_deploy")),{visibleChips:w,hiddenChips:k}=wa(Pn(e.user_context)),S=Ae(e.id),L=y||A!==null||w.length>0,E=b!=="closed"&&S.length>0,j=S.length>0,C=e.is_starred===!0,I=d("admin.support.archive","Archive"),$=C?d("admin.support.unstar","Remove from starred"):d("admin.support.star","Add to starred");return n.jsxs(f,{role:"group",position:"relative",borderBottomWidth:"1px",borderColor:o.surface.border,bg:r?o.primaryAction.light:"transparent",_hover:{bg:r?o.primaryAction.light:o.surface.hover}
54,transition:"background 120ms ease",sx:{"&:hover .support-row-archive-button, &:focus-within .support-row-archive-button":{opacity:1,pointerEvents:"auto"}},children:[n.jsxs(f,{role:"button",tabIndex:0,"aria-current":r?"true":void 0,onClick:()=>t(S),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),t(S))},px:3,py:3,cursor:"pointer",_focusVisible:{outline:`2px solid ${o.primaryAction.default}`,outlineOffset:"-2px"},children:[n.jsxs(v,{align:"center",gap:2,mb:1,children:[n.jsx(f,{bg:p.backgroundColor,color:p.textColor,borderRadius:"full",px:2,py:.5,flexShrink:0,children:n.jsx(c,{fontSize:"10px",fontWeight:"700",whiteSpace:"nowrap",children:_})}),b==="needs_review"?n.jsx(et,{label:d("admin.support.threads.filter.needs_review","Needs review"),backgroundColor:o.accentColors.warningLight,textColor:o.accentColors.warningStrong,title:d("admin.support.threads.filter.needs_review","Needs review")}):b==="closed"?n.jsx(et,{label:d("admin.support.investigations.review.closed","Closed"),backgroundColor:o.accentColors.successLight,textColor:o.accentColors.successStrong,title:d("admin.support.investigations.review.closed","Closed")}):null,m?n.jsx(va,{}):null,n.jsx(c,{fontSize:"11px",color:o.text.placeholder,ml:"auto",flexShrink:0,children:En(e.last_activity_at||e.created_at)})]}),n.jsx(c,{fontSize:"13px",fontWeight:"700",color:o.text.body,noOfLines:1,children:g}),n.jsx(c,{fontSize:"12px",color:o.text.placeholder,noOfLines:1,mt:.5,pr:E&&!L?16:j&&!L?8:0,children:!u&&Fn(Ae(e.outcome))||kt(Ae(e.reason_category))||d("admin.support.investigations.no_outcome_yet","No outcome yet")}),L?n.jsx(v,{align:"center",gap:1.5,mt:1.5,pr:E?16:j?8:0,children:n.jsxs(v,{align:"center",gap:1,flex:"1",minW:0,overflow:"hidden",children:[y?n.jsx(et,{label:d("admin_support.investigations_investigationssidebar.blocks_deploy_b15a2bf0","blocks deploy"),backgroundColor:o.accentColors.errorLight,textColor:o.accentColors.errorStrong,title:d("admin_support.investigations_investigationssidebar.a_pending_deploy_is_held_until_this_investigation_clears_9229f014","A pending deploy is held until this investigation clears")}):null,A!==null?n.jsx(et,{label:`${A} chats`,backgroundColor:o.accentColors.infoLight,textColor:o.accentColors.infoDark,title:`${A} conversations are on this incident`,isMachineText:!0}):null,w.map(T=>n.jsx(Sa,{chip:T},T.label)),k.length>0?n.jsxs(c,{fontSize:"10px",fontFamily:"mono",color:o.text.placeholder,flexShrink:0,title:k.map(T=>T.label).join(", "),children:["+",k.length]}):null]})}):null]}),j?n.jsx(Bt,{"aria-label":$,title:$,"aria-pressed":C,icon:C?n.jsx(pa,{size:19}):n.jsx(fa,{size:19}),position:"absolute",right:E?10:2,bottom:2,minW:"30px",w:"30px",h:"30px",borderRadius:"6px",variant:"ghost",color:C?o.tertiaryAction.hover:o.secondaryAction.default,bg:"transparent",transition:"color 120ms ease",_hover:{color:o.tertiaryAction.hover,bg:"transparent"},_active:{color:o.tertiaryAction.pressed,bg:"transparent"},_focusVisible:{outline:`2px solid ${o.primaryAction.default}`,outlineOffset:"2px"},isLoading:l,isDisabled:l,onClick:T=>{T.stopPropagation(),a(S,!C)}}):null,E?n.jsx(Bt,{className:"support-row-archive-button","aria-label":I,title:I,icon:n.jsx(ua,{size:18}),position:"absolute",right:2,bottom:2,minW:"30px",w:"30px",h:"30px",borderRadius:"6px",variant:"ghost",color:o.secondaryAction.default,bg:"transparent",opacity:s?1:0,pointerEvents:s?"auto":"none",transition:"opacity 120ms ease, color 120ms ease",_hover:{color:o.secondaryAction.hover,bg:"transparent"},_active:{bg:"transparent"},_focusVisible:{opacity:1,pointerEvents:"auto",outline:`2px solid ${o.primaryAction.default}`,outlineOffset:"2px"},isLoading:s,isDisabled:s,onClick:T=>{T.stopPropagation(),i(S)}}):null]})}function va(){const{t:e}=O();return n.jsxs(v,{align:"center",gap:1,flexShrink:0,title:e("admin_support.investigations_investigationssidebar.a_fixer_run_is_working_on_this_now_37e93add","A Fixer run is working on this now"),children:[n.jsx(f,{"aria-hidden":"true",w:"6px",h:"6px",borderRadius:"full",bg:o.accentColors.warningStrong,animation:`${xa} 1.8s ease-in-out infinite`,sx:ba}),n.jsx(c,{fontSize:"10px",fontWeight:"700",color:o.accentColors.warningStrong,whiteSpace:"nowrap",children:e("admin_support.investigations_investigationssidebar.fixer_running_b0fdab30","Fixer running")})]})}function et({label:e,backgroundColor:r,textColor:t,title:i,isMachineText:s=!1}){return n.jsx(c,{as:"span",title:i,flexShrink:0,px:"5px",py:"1px",borderRadius:"4px",bg:r,color:t,fontFamily:s?"mono":void 0,fontSize:"10px",fontWeight:"700",lineHeight:"1.4",whiteSpace:"nowrap",children:e})}function Sa({chip:e}){const r=me(e.tone==="warning"?"warning":"neutral");return n.jsx(c,{as:"span",title:e.label,minW:0,px:"5px",py:"1px",borderRadius:"4px",bg:r.backgroundColor,color:r.textColor,fontSize:"10px",fontWeight:"600",lineHeight:"1.4",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:e.label})}function wa(e){const r=e.filter(i=>
54typeof(i==null?void 0:i.label)=="string"&&i.label.trim().length>0),t=[...r.filter(i=>i.tone==="warning"),...r.filter(i=>i.tone!=="warning")];return{visibleChips:t.slice(0,jn),hiddenChips:t.slice(jn)}}function ur(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}function wt(e,r){var t;return(t=ur(e))==null?void 0:t[r]}function Ae(e){return typeof e=="string"?e.trim():""}function Be(e){return Ae(e).toLowerCase()}function ja(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const r=Number(e);if(Number.isFinite(r))return r}return null}function Ca(e){const r=ja(e);if(r===null)return null;const t=Math.floor(r);return t>=ma?t:null}function ka(e){return typeof e=="boolean"?e:["true","yes"].includes(Be(e))}const Aa=1e4;function We(e){const r=Date.parse(e.review_state_updated_at??"");return Number.isFinite(r)?r:null}function $e(e){const r=Date.parse(e.star_state_updated_at??"");return Number.isFinite(r)?r:null}function kn(e,r){return e!==null&&r!==null&&e>r}function Ta(e){const{updatedInvestigation:r,investigationBeforeMutation:t,currentInvestigation:i,mutationField:s}=e;return!s||!t||!i||t.id!==r.id||i.id!==r.id?r:s==="reviewState"&&!kn($e(r),$e(i))?{...r,is_starred:i.is_starred,star_state_updated_at:i.star_state_updated_at,star_state_updated_by_admin_user_id:i.star_state_updated_by_admin_user_id}:s==="starState"&&!kn(We(r),We(i))?{...r,review_state:i.review_state,review_state_updated_at:i.review_state_updated_at,review_state_updated_by_admin_user_id:i.review_state_updated_by_admin_user_id}:r}function tt(e){var L;const{incomingInvestigation:r,currentInvestigation:t,latestLocalMutation:i,requestStartedAtMutationVersion:s}=e,a=((L=i==null?void 0:i.starState)==null?void 0:L.investigation.id)===r.id?i.starState:void 0,l=(t==null?void 0:t.id)===r.id?t:void 0,d=a==null?void 0:a.investigation;if(!d&&!l)return r;const u=a!==void 0&&a.mutationVersion>s,p=a!==void 0&&(u||a.expiresAtMilliseconds>Date.now()),_=d?$e(d):null,b=d?_??(a==null?void 0:a.previousStateUpdatedAtMilliseconds)??null:null,g=l?$e(l):null,m=l&&g!==null&&(b===null||g>b)?l:d??l;if(!m)return r;const x=m===d?b:g,A=m===d?_:g,y=$e(r),w=y!==null&&A!==null&&y>A,k=x!==null&&(y!==null&&y<=x||p&&y===null&&g!==null),S=p&&d!==void 0&&(y===null||_===null)&&r.is_starred!==m.is_starred;return u&&!w||r.is_starred!==m.is_starred&&k||S?{...r,is_starred:m.is_starred,star_state_updated_at:m.star_state_updated_at,star_state_updated_by_admin_user_id:m.star_state_updated_by_admin_user_id}:r}function jt({incomingInvestigation:e,currentInvestigation:r,latestLocalMutation:t,requestStartedAtMutationVersion:i}){var L;const s=(r==null?void 0:r.id)===e.id?r:void 0,a=((L=t==null?void 0:t.reviewState)==null?void 0:L.investigation.id)===e.id?t.reviewState:void 0,l=a!==void 0&&a.mutationVersion>i,d=a&&(l||a.expiresAtMilliseconds>Date.now())?a:void 0,u=We(e),p=s?We(s):null,_=d,b=_?We(_.investigation):null,g=_?b??_.previousStateUpdatedAtMilliseconds:null,m=s&&p!==null&&(g===null||p>g)?s:(_==null?void 0:_.investigation)??s;if(!m)return tt({incomingInvestigation:e,currentInvestigation:r,latestLocalMutation:t,requestStartedAtMutationVersion:i});if(a!==void 0&&d===void 0&&u===null&&m.review_state!==e.review_state)return tt({incomingInvestigation:e,currentInvestigation:r,latestLocalMutation:t,requestStartedAtMutationVersion:i});const A=m===(_==null?void 0:_.investigation)?g:p,y=m===(_==null?void 0:_.investigation)?b:p,w=A!==null&&(u===null||A>=u),k=u!==null&&y!==null&&u>y,S=_!==void 0&&b===null&&m.review_state!==e.review_state;return tt(l&&!k||w||S?{incomingInvestigation:{...e,review_state:m.review_state,review_state_updated_at:m.review_state_updated_at,review_state_updated_by_admin_user_id:m.review_state_updated_by_admin_user_id},currentInvestigation:r,latestLocalMutation:t,requestStartedAtMutationVersion:i}:{incomingInvestigation:e,currentInvestigation:r,latestLocalMutation:t,requestStartedAtMutationVersion:i})}function fl(){var Oe;const[e]=Hr("(max-width: 47.99em)",{ssr:!1}),[r]=pr(),t=((Oe=r.get("investigationId"))==null?void 0:Oe.trim())||null,[i,s]=h.useState(null),[a,l]=h.useState([]),[d,u]=
54h.useState(!0),[p,_]=h.useState(null),[b,g]=h.useState(t),[m,x]=h.useState(null),[A,y]=h.useState(!1),[w,k]=h.useState(null),[S,L]=h.useState(null),[E,j]=h.useState(null),C=h.useRef(null),I=h.useRef(null),$=h.useRef(!1),T=h.useRef(0),F=h.useRef(0),B=h.useRef(new Map),re=h.useRef(a),W=h.useRef(m),z=h.useRef(t),Z=h.useRef(!0);h.useEffect(()=>{C.current=b},[b]),h.useEffect(()=>{I.current=i},[i]),h.useEffect(()=>{re.current=a},[a]),h.useEffect(()=>{W.current=m},[m]);const q=h.useCallback(M=>{C.current=M,M&&(Z.current=!0),g(M)},[]),de=h.useCallback(M=>{I.current=M,Z.current=!0,s(M)},[]);h.useEffect(()=>{t?q(t):z.current&&(Z.current=!0,q(null),x(null)),z.current=t},[q,t]),h.useEffect(()=>{t||b||!Z.current||d||a.length===0||q(a[0].id)},[q,a,d,t,b]);const se=h.useCallback(async(M,N=!0)=>{if($.current)return;$.current=!0,N&&(u(!0),_(null));const R=F.current;try{const D=await Rr({status:M&&M!=="starred"?M:void 0,starredOnly:M==="starred"});if(I.current!==M)return;l(G=>{const U=new Map(G.map(ie=>[ie.id,ie]));return D.map(ie=>jt({incomingInvestigation:ie,currentInvestigation:U.get(ie.id),latestLocalMutation:B.current.get(ie.id),requestStartedAtMutationVersion:R}))}),_(null)}catch(D){N&&_(D instanceof Error?D.message:String(D))}finally{$.current=!1,N&&u(!1)}},[]);h.useEffect(()=>{se(i);const M=window.setInterval(()=>{document.visibilityState==="visible"&&se(i,!1)},2e3);return()=>window.clearInterval(M)},[i,se]),h.useEffect(()=>{if(!b){x(null),k(null),y(!1);return}const M=b,N=T.current+1;T.current=N;let R=!1;x(U=>(U==null?void 0:U.id)===M?U:null);const D=async U=>{if(R)return;R=!0,U&&(y(!0),k(null));const ie=F.current;try{const ce=await Rn(M);if(T.current!==N||C.current!==M)return;const he=B.current.get(ce.id);x(Ce=>jt({incomingInvestigation:ce,currentInvestigation:Ce??void 0,latestLocalMutation:he,requestStartedAtMutationVersion:ie})),k(null),l(Ce=>Ce.map(ke=>ke.id===ce.id?jt({incomingInvestigation:ce,currentInvestigation:ke,latestLocalMutation:he,requestStartedAtMutationVersion:ie}):ke))}catch(ce){U&&T.current===N&&C.current===M&&k(ce instanceof Error?ce.message:String(ce))}finally{R=!1,U&&T.current===N&&C.current===M&&y(!1)}};D(!0);const G=window.setInterval(()=>{document.visibilityState==="visible"&&D(!1)},2e3);return()=>window.clearInterval(G)},[b]);const ae=h.useCallback((M,N,R)=>{var Ce,ke;const D=((Ce=W.current)==null?void 0:Ce.id)===M.id?W.current:re.current.find(pe=>pe.id===M.id),G=Ta({updatedInvestigation:M,investigationBeforeMutation:N,currentInvestigation:D,mutationField:R}),U=N??(((ke=W.current)==null?void 0:ke.id)===G.id?W.current:re.current.find(pe=>pe.id===G.id)),ie=U!==void 0&&(R===void 0||R==="reviewState")&&U.review_state!==G.review_state,ce=U!==void 0&&(R===void 0||R==="starState")&&U.is_starred!==G.is_starred;if(ie||ce){const pe=F.current+1;F.current=pe;const qe=B.current.get(G.id),Pt=Date.now()+Aa;B.current.set(G.id,{...qe,...ie?{reviewState:{investigation:G,mutationVersion:pe,previousStateUpdatedAtMilliseconds:U?We(U):null,expiresAtMilliseconds:Pt}}:{},...ce?{starState:{investigation:G,mutationVersion:pe,previousStateUpdatedAtMilliseconds:U?$e(U):null,expiresAtMilliseconds:Pt}}:{}})}C.current===G.id&&(W.current=G,x(G));const he=re.current.map(pe=>pe.id===G.id?G:pe);re.current=he,l(pe=>pe.map(qe=>qe.id===G.id?G:qe))},[]),we=h.useCallback(async M=>{var R;if(S)return;const N=((R=W.current)==null?void 0:R.id)===M?W.current:re.current.find(D=>D.id===M);L(M);try{const D=await zn({investigationId:M,reviewState:"closed"});ae(D,N,"reviewState")}catch(D){console.error("Failed to archive support investigation",D),Ct(D,{scope:"support-admin-investigation-archive",fingerprint:["support-admin-investigation-archive-failed"]})}finally{L(null)}},[S,ae]),V=h.useCallback(async(M,N)=>{var ie,ce;if(E)return;const R=re.current,D=R.findIndex(he=>he.id===M),G=((ie=W.current)==null?void 0:ie.id)===M?W.current:R[D],U=((ce=R[D+1])==null?void 0:ce.id)??null;j(M);try{const he=await zr({investigationId:M,isStarred:N});ae(he,G,"starState"),I.current==="starred"&&!N&&(l(Ce=>Ce.filter(ke=>ke.id!==M)),C.current===M&&(Z.current=U!==null,q(U)))}catch(he){console.error("Failed to update support investigation star",he),Ct(he,{scope:"support-admin-investigation-star",fingerprint:["support-admin-investigation-star-failed"]})}finally{j(null)}},[ae,q,E]),te=h.useCallback(()=>{se(i)},[i,se]),xe=`calc(100dvh - ${Number.parseInt(hr?fr:mr,10)+(e?76:32)}px)`;return n.jsxs(v,{"data-testid":"admin-support-investigations-page",h:xe,w:"100%",direction:{base:"column",md:"row"},children:[n.jsx(dr,{activeFilter:i,investigations:a,isLoadingInvestigations:d,loadErrorMessage:p,selectedInvestigationId:b,onChangeFilter:de,onSelectInvestigation:q,onArchiveInvestigation:we,archivingInvestigationId:S,onToggleInvestigationStar:V,starringInvestigationId:E,onRefresh:te}),n.jsx(f,{flex:"1",minW:0,minH:0,bg:o.surface.background,children:n.jsx(da,{investigation:m,isLoadingInvestigation:A,loadErrorMessage:w,onInvestigationUpdated:ae})})]})}export{fl as default,Ta as mergeInvestigationMutationResponse,jt as reconcileIncomingSupportInvestigation}; 55//# sourceMappingURL=AdminSupportInvestigationsPage-DVIJE57Y.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.