chordia-ui 0.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../Timeline.cjs.js"),e=require("react/jsx-runtime"),g=require("react"),S=require("lucide-react");function Ye(n){return`${Math.floor(n/6e4)}:${String(Math.floor(n%6e4/1e3)).padStart(2,"0")}`}function _e({ev:n,onPlay:i,onHighlight:o}){var r;const s=n.actor==="agent"?e.jsx(S.UserCheck,{size:11}):e.jsx(S.User,{size:11});return e.jsxs("div",{style:{fontSize:"var(--text-sm)",padding:"6px 10px",borderRadius:"var(--radius-sm)",background:"var(--paper-elevated)",border:"1px solid var(--border)",marginTop:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:3},children:[e.jsx("span",{style:{color:"var(--text-muted)"},children:s}),n.source&&e.jsx("span",{style:{color:"var(--text-muted)",fontWeight:500},children:n.source}),e.jsxs("span",{style:{marginLeft:"auto",display:"flex",gap:4,alignItems:"center"},children:[n.start_ms!=null&&e.jsx(w.SmallButton,{variant:"ghost",size:"sm",onClick:()=>i(n.start_ms,n.end_ms),title:"Play audio",children:e.jsx(S.Play,{size:10})}),((r=n.turn_ids)==null?void 0:r.length)>0&&e.jsx(w.SmallButton,{variant:"ghost",size:"sm",onClick:()=>o(n.turn_ids),title:"Show in transcript",children:e.jsx(S.ScrollText,{size:10})}),n.start_ms!=null&&e.jsx("span",{style:{fontSize:"var(--text-xs)",color:"var(--text-faint)"},children:Ye(n.start_ms)})]})]}),e.jsxs("div",{style:{color:"var(--text-base)",fontStyle:"italic",lineHeight:1.4},children:['"',(n.text||"").slice(0,200),'"']})]})}function Me({outcomeLift:n}){var v,b;if(n.lift==null)return null;const i=n.p_expected,o=n.p_full,s=n.lift_raw??(o!=null&&i!=null?o-i:null),r=n.lift,y=l=>l!=null?Math.round(l*100)+"%":"—",f=l=>{if(l==null)return"—";const x=(l*100).toFixed(1);return l>0?`+${x}pp`:`${x}pp`},p=l=>l>0?"var(--state-present)":l<0?"#f87171":"var(--text-muted)";return e.jsxs(w.DetailCard,{title:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx(S.TrendingUp,{size:12})," Agent Lift Analysis"]}),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16},children:[e.jsxs("div",{style:{textAlign:"center",flex:1},children:[e.jsx("div",{style:{fontSize:20,fontWeight:600,color:"var(--text-faint)"},children:y(i)}),e.jsx("div",{style:{fontSize:10,color:"var(--text-faint)",marginTop:2},children:"Expected Outcome"}),e.jsx("div",{style:{fontSize:9,color:"var(--text-faint)",marginTop:1},children:"Based on call type & difficulty"})]}),e.jsx("div",{style:{fontSize:16,color:"var(--text-faint)",fontWeight:300},children:"+"}),e.jsxs("div",{style:{textAlign:"center",flex:1},children:[e.jsx("div",{style:{fontSize:20,fontWeight:700,color:p(s)},children:f(s)}),e.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",marginTop:2},children:"Agent Impact"}),e.jsx("div",{style:{fontSize:9,color:"var(--text-faint)",marginTop:1},children:"Behavior-driven change"})]}),e.jsx("div",{style:{fontSize:16,color:"var(--text-faint)",fontWeight:300},children:"="}),e.jsxs("div",{style:{textAlign:"center",flex:1},children:[e.jsx("div",{style:{fontSize:20,fontWeight:600,color:"var(--text-ink)"},children:y(o)}),e.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",marginTop:2},children:"Predicted Outcome"}),e.jsx("div",{style:{fontSize:9,color:"var(--text-faint)",marginTop:1},children:"With agent behaviors"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"8px 12px",borderRadius:6,background:"var(--surface-raised, #f5f5f5)",marginBottom:12},children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-muted)"},children:"vs. Average Agent:"}),e.jsxs("span",{style:{fontSize:14,fontWeight:700,color:p(r),display:"flex",alignItems:"center",gap:4},children:[f(r),e.jsx("svg",{width:"10",height:"7",children:r>0?e.jsx("path",{d:"M5 0 L9 6 L1 6 Z",fill:"var(--state-present)"}):r<0?e.jsx("path",{d:"M5 6 L9 0 L1 0 Z",fill:"#f87171"}):e.jsx("rect",{x:"1",y:"2.5",width:"8",height:"1",fill:"var(--text-muted)"})})]}),((v=n.interpretation)==null?void 0:v.lift_band)&&e.jsx("span",{style:{fontSize:9,fontWeight:600,color:p(r),textTransform:"capitalize"},children:n.interpretation.lift_band.replace(/_/g," ")})]}),((b=n.driver_signal_keys)==null?void 0:b.length)>0&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:9,fontWeight:600,color:"var(--text-muted)",marginBottom:6,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Key Drivers"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:n.driver_signal_keys.map((l,x)=>e.jsx(w.Tag,{variant:"default",size:"xs",children:l.replace(/^sig\./,"").replace(/_/g," ")},x))})]})]})}const Re="coaching-synthesis-keyframes";function qe(){if(typeof document>"u"||document.getElementById(Re))return;const n=document.createElement("style");n.id=Re,n.textContent=`
|
|
2
2
|
@keyframes coaching-shimmer {
|
|
3
3
|
0% { background-position: -200% 0; }
|
|
4
4
|
100% { background-position: 200% 0; }
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
0%, 100% { opacity: 0.4; }
|
|
8
8
|
50% { opacity: 1; }
|
|
9
9
|
}
|
|
10
|
-
`,document.head.appendChild(t)}function Se({data:t,loading:o,error:l}){var v,f;if(g.useEffect(()=>{Be()},[]),o)return e.jsxs("div",{style:{padding:"20px 0",display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"var(--rail-tone)",animation:"coaching-pulse 1.5s ease-in-out infinite"}}),e.jsx("span",{style:{fontSize:"var(--text-base)",color:"var(--rail-tone)",fontFamily:"var(--font-sans)",fontWeight:500},children:"Compass is synthesizing coaching insights…"})]}),[180,260,220].map((p,x)=>e.jsx("div",{style:{height:10,width:p,maxWidth:"100%",borderRadius:4,background:"linear-gradient(90deg, var(--hover-warm-subtle) 25%, var(--hover-warm) 50%, var(--hover-warm-subtle) 75%)",backgroundSize:"200% 100%",animation:"coaching-shimmer 1.8s ease-in-out infinite",animationDelay:`${x*.2}s`}},x))]});if(l)return e.jsx("div",{style:{padding:"16px 0",fontSize:"var(--text-base)",color:"var(--text-faint)",fontFamily:"var(--font-sans)"},children:"Unable to generate coaching summary."});if(!t)return null;const s=t.strengths||[],n=t.improvements||[],d=t.organizational||t.organizational_insights||[],a=typeof t.one_liner=="string"?t.one_liner:((v=t.one_liner)==null?void 0:v.text)||"",c=typeof t.context=="string"?t.context:((f=t.context)==null?void 0:f.text)||"";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14,fontFamily:"var(--font-sans)"},children:[a&&e.jsx("div",{style:{fontSize:"var(--text-lg)",fontWeight:600,color:"var(--text-strong)",lineHeight:1.4},children:a}),c&&e.jsx("div",{style:{fontSize:"var(--text-base)",color:"var(--text-muted)",lineHeight:1.45},children:c}),s.length>0&&e.jsx(he,{icon:e.jsx(m.TrendingUp,{size:13}),label:"Strengths",color:"var(--rail-discovery)",items:s}),n.length>0&&e.jsx(he,{icon:e.jsx(m.Lightbulb,{size:13}),label:"Improvements",color:"var(--rail-compliance)",items:n}),d.length>0&&e.jsx(he,{icon:e.jsx(m.Building,{size:13}),label:"Organizational",color:"var(--rail-outcome)",items:d}),t.overall&&e.jsxs("div",{style:{fontSize:"var(--text-base)",color:"var(--text-faint)",fontStyle:"italic",marginTop:2},children:["Overall: ",t.overall.replace(/_/g," ")]})]})}function he({icon:t,label:o,color:l,items:s}){return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6,color:l,fontSize:"var(--text-base)",fontWeight:650,letterSpacing:"0.04em"},children:[t,o]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s.map((n,d)=>{const a=typeof n=="string"?n:(n==null?void 0:n.text)||"",c=typeof n=="object"?n==null?void 0:n.quote:null;return e.jsxs("div",{style:{paddingLeft:14},children:[e.jsxs("div",{style:{fontSize:"var(--text-base)",color:"var(--text-base)",lineHeight:1.4},children:["• ",a]}),c&&e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:4,marginTop:3,paddingLeft:8},children:[e.jsx(m.MessageSquareQuote,{size:10,style:{color:"var(--text-faint)",flexShrink:0,marginTop:2}}),e.jsxs("span",{style:{fontSize:"var(--text-base)",color:"var(--text-muted)",fontStyle:"italic",lineHeight:1.35},children:['"',c,'"']})]})]},d)})})]})}function Ee(t){const o=Math.floor(t/60),l=Math.round(t%60);return`${o}:${l.toString().padStart(2,"0")}`}function ke({title:t,meta:o,callPurpose:l,classification:s,dimensions:n}){const d=l||{},a=s||{};return e.jsxs(j.Card,{variant:"elevated",padding:"sm",children:[e.jsx("div",{style:{fontSize:"var(--text-md)",fontWeight:550,color:"var(--text-strong)",lineHeight:1.375,marginBottom:6},children:t}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"4px 12px",fontSize:11,color:"var(--text-muted)"},children:[o.evaluated_dt&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Date"}),e.jsx("div",{style:{color:"var(--text-base)"},children:new Date(o.evaluated_dt).toLocaleString()})]}),o.duration_seconds!=null&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Duration"}),e.jsx("div",{style:{color:"var(--text-base)"},children:Ee(o.duration_seconds)})]}),o.message_count&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Messages"}),e.jsx("div",{style:{color:"var(--text-base)"},children:o.message_count})]}),d.interaction_direction&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Direction"}),e.jsx("div",{style:{color:"var(--text-base)"},children:d.interaction_direction})]}),d.interaction_driver&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Driver"}),e.jsx("div",{style:{color:"var(--text-base)"},children:d.interaction_driver})]}),d.customer_intent&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Intent"}),e.jsx("div",{style:{color:"var(--text-base)"},children:d.customer_intent})]}),a.interaction_paradigm&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Paradigm"}),e.jsx("div",{style:{color:"var(--text-base)"},children:a.interaction_paradigm})]}),n.map((c,v)=>e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:c.label||c.key}),e.jsx("div",{style:{color:"var(--text-base)"},children:c.value})]},v))]}),o.session_id&&e.jsx("div",{style:{fontSize:9,color:"var(--text-faint)",fontFamily:"var(--font-mono)",marginTop:4,userSelect:"all"},children:o.session_id})]})}function ze({scores:t}){return t!=null&&t.length?e.jsx(j.DetailCard,{title:"Scores",children:e.jsx("div",{style:{display:"flex",gap:24,flexWrap:"wrap"},children:t.map((o,l)=>{const s=o.value!=null?Math.round(o.value):null;return e.jsxs("div",{style:{textAlign:"center",minWidth:48},children:[e.jsx("div",{style:{fontSize:20,fontWeight:700,color:"var(--text-ink)"},children:s??"—"}),e.jsx("div",{style:{fontSize:"var(--text-sm)",color:"var(--text-muted)",marginTop:2},children:o.label||o.key})]},l)})})}):null}const ve={outcome:{label:"Outcome",icon:e.jsx(m.Target,{size:12}),color:"var(--rail-outcome)"},process:{label:"Process & Protocol",icon:e.jsx(m.FileText,{size:12}),color:"var(--rail-discovery)"},compliance:{label:"Compliance",icon:e.jsx(m.Scale,{size:12}),color:"var(--rail-compliance)"},customer_friction:{label:"Customer Friction",icon:e.jsx(m.Zap,{size:12}),color:"var(--rail-coral)"},experience:{label:"Experience",icon:e.jsx(m.MessageSquare,{size:12}),color:"var(--rail-teal)"}},We={risk:{icon:e.jsx(m.Zap,{size:10}),color:"var(--rail-signal-churn)"},opportunity:{icon:e.jsx(m.Lightbulb,{size:10}),color:"var(--state-unknown)"},excellence:{icon:e.jsx(m.CheckCircle,{size:10}),color:"var(--rail-teal)"}};function Ce({signals:t,expandedSignals:o,toggleSignal:l,playAudio:s,highlightTurns:n}){var a;if(!((a=t==null?void 0:t.signals)!=null&&a.length))return null;const d=g.useMemo(()=>{const c={};for(const v of t.signals){const f=v.group||"experience";c[f]||(c[f]=[]),c[f].push(v)}return c},[t]);return e.jsx(j.DetailCard,{title:`Signals (${t.present_count} present / ${t.total_signals_evaluated} evaluated)`,children:Object.entries(d).map(([c,v])=>{const f=ve[c]||ve.experience;return e.jsxs("div",{style:{marginBottom:10},children:[e.jsxs(j.SectionLabel,{style:{display:"flex",alignItems:"center",gap:4},children:[f.icon,e.jsx("span",{children:f.label})]}),e.jsx("div",{style:{marginTop:4,display:"flex",flexDirection:"column",gap:6},children:v.map((p,x)=>{var C,T,I;const z=p.display_name||p.key||"",w=(C=p.baseline)==null?void 0:C.delta,k=((T=p.observations)==null?void 0:T.length)>0,S=o.has(p.key);return e.jsxs("div",{id:`signal-${p.key}`,style:{border:"1px solid var(--border)",borderRadius:"var(--radius-md)",background:"var(--paper)",overflow:"hidden"},children:[e.jsxs("button",{type:"button",onClick:R=>{k&&(l(p.key),R.currentTarget.blur())},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",background:"transparent",border:"none",cursor:k?"pointer":"default"},title:[p.confidence!=null?`Confidence: ${Math.round(p.confidence*100)}%`:"",w!=null?`Δ baseline: ${w>0?"+":""}${(w*100).toFixed(1)}%`:""].filter(Boolean).join(" · "),children:[e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap"},children:[(I=We[p.kind])==null?void 0:I.icon,e.jsx("span",{children:z}),k&&e.jsxs("span",{style:{marginLeft:4,fontSize:10,opacity:.6},children:["(",p.observations.length,")"]})]}),k&&e.jsx(m.ChevronDown,{size:14,style:{color:"var(--text-muted)",flexShrink:0,transform:S?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.16s ease"}})]}),S&&p.observations&&e.jsx("div",{style:{width:"100%",margin:"0 0 6px"},children:p.observations.map((R,P)=>{var F;return e.jsxs("div",{style:{fontSize:"var(--text-sm)",color:"var(--text-muted)",padding:"8px 12px",background:"var(--paper)",borderLeft:`3px solid ${f.color}`,marginBottom:6,borderRadius:"0 var(--radius-sm) var(--radius-sm) 0"},children:[e.jsx("div",{style:{fontWeight:600,color:"var(--text-base)",marginBottom:3,fontSize:"var(--text-base)"},children:R.key||""}),e.jsx("div",{style:{marginBottom:6,lineHeight:1.4},children:R.reason||R.explanation||""}),(F=R.evidence)==null?void 0:F.map((W,K)=>e.jsx(ye,{ev:W,onPlay:s,onHighlight:n},K))]},P)})})]},x)})})]},c)})})}const be={risk:{icon:e.jsx(m.Zap,{size:10}),color:"var(--rail-signal-churn)"},opportunity:{icon:e.jsx(m.Lightbulb,{size:10}),color:"var(--state-unknown)"},excellence:{icon:e.jsx(m.CheckCircle,{size:10}),color:"var(--rail-teal)"}};function we({guidance:t,playAudio:o,highlightTurns:l}){var s;return(s=t==null?void 0:t.items)!=null&&s.length?e.jsx(j.DetailCard,{title:`Guidance (${t.total_items} items)`,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:t.items.map((n,d)=>{var v;const a=be[n.guidance_kind]||be.excellence,c=n.owner==="organization"?{bg:"color-mix(in srgb, var(--rail-discovery) 15%, transparent)",color:"var(--rail-discovery)",text:"ORG"}:n.owner==="shared"?{bg:"color-mix(in srgb, var(--state-unknown) 15%, transparent)",color:"var(--state-unknown)",text:"SHARED"}:{bg:"color-mix(in srgb, var(--rail-teal) 10%, transparent)",color:"var(--rail-teal)",text:"AGENT"};return e.jsxs("div",{style:{padding:"10px 12px",borderRadius:"var(--radius)",background:"var(--paper)",borderLeft:`3px solid ${a.color}`},children:[e.jsxs("div",{style:{fontSize:"var(--text-base)",color:"var(--text-strong)",display:"flex",alignItems:"center",gap:5,fontWeight:550},children:[a.icon," ",n.title||"",e.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:8,marginLeft:4,background:c.bg,color:c.color,fontWeight:600},children:c.text})]}),n.detail&&e.jsx("div",{style:{fontSize:"var(--text-sm)",color:"var(--text-muted)",marginTop:4,lineHeight:1.4},children:n.detail}),(v=n.signal_refs)==null?void 0:v.map((f,p)=>{var x;return e.jsxs("div",{style:{marginTop:6},children:[e.jsxs("div",{style:{fontSize:10,color:"var(--text-muted)",fontWeight:600,marginBottom:3,display:"flex",alignItems:"center",gap:3},children:[e.jsx(m.CornerDownRight,{size:10})," ",f.display_name||f.signal_key,f.confidence!=null&&e.jsxs("span",{style:{fontWeight:400,opacity:.7},children:[" (",Math.round(f.confidence*100),"%)"]})]}),(x=f.evidence)==null?void 0:x.map((z,w)=>e.jsx(ye,{ev:z,onPlay:o,onHighlight:l},w))]},p)})]},d)})})}):null}function Te({nba:t}){const o=(t==null?void 0:t.recommendations)||(t==null?void 0:t.actions)||[];return o.length?e.jsx(j.DetailCard,{title:"Next Best Actions",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:o.slice(0,8).map((l,s)=>e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",display:"flex",alignItems:"center",gap:4},children:[e.jsx(m.Target,{size:12})," ",e.jsx("strong",{style:{color:"var(--text-base)"},children:l.action||l.title||""}),l.rationale&&` — ${l.rationale}`]},s))})}):null}function Ie({audioUrl:t,timelineSegments:o,durationSeconds:l,currentTimeSeconds:s,timelinePlaying:n,playbackRate:d,onSeek:a,onTogglePlay:c,onSeekBack:v,onSeekForward:f,onSetPlaybackRate:p,audioRef:x}){return t?e.jsxs(j.DetailCard,{title:"Recording",children:[e.jsx(j.Timeline,{segments:o,durationSeconds:l||0,currentTimeSeconds:s,onSeek:a,showControls:!0,hasRecording:!0,timelinePlaying:n,playbackRate:d,onTogglePlay:c,onSeekBack:v,onSeekForward:f,onSetPlaybackRate:p}),e.jsx("audio",{ref:x,preload:"none",style:{display:"none"},children:e.jsx("source",{src:t,type:"audio/mpeg"})})]}):null}function _e({transcript:t,audioUrl:o,highlightedTurns:l,activeTurnIndex:s,timelinePlaying:n,turnObservations:d,setExpandedSignals:a,onTurnPlayPause:c}){var p;if(!((p=t==null?void 0:t.messages)!=null&&p.length))return null;const v=(x,z)=>{if(x==null)return;const w=C=>{const T=Math.floor(C/6e4),I=Math.floor(C%6e4/1e3);return`${T.toString().padStart(2,"0")}:${I.toString().padStart(2,"0")}`},k=w(x),S=z!=null?w(z):k;return`${k}–${S}`},f=t.messages.map((x,z)=>{var w,k;return{actor:x.actor==="agent"?((w=t.actor_map)==null?void 0:w.agent)||"Agent":((k=t.actor_map)==null?void 0:k.customer)||"Customer",actorType:x.actor==="agent"?"agent":"customer",text:x.text||"",timeRange:v(x.start??x.start_ms,x.end??x.end_ms),isHighlighted:l.has(z),highlightColor:n&&s===z?x.actor==="agent"?"var(--rail-outcome)":"var(--rail-discovery)":void 0,observations:(d[z]||[]).map(S=>({...S,onClick:()=>{a(C=>new Set([...C,S.signalKey])),setTimeout(()=>{const C=document.getElementById(`signal-${S.signalKey}`);C&&C.scrollIntoView({behavior:"smooth",block:"nearest"})},100)}}))}});return e.jsx("div",{id:"transcript-container",children:e.jsx(j.TranscriptCard,{turns:f,audioUrl:o,activeTurnIndex:s,autoScrollActiveTurn:n,isExternalPlaying:n,onTurnPlayPause:c})})}const fe={padding:0,border:"none",background:"transparent",fontSize:"12px",fontWeight:500,color:"rgba(30, 33, 37, 0.65)",cursor:"pointer",fontFamily:"inherit"};function Le({sessionTitle:t,sessionSubtitle:o,threadLabel:l,messages:s=[],onSendMessage:n,onReplyMessage:d,onEditMessage:a,onDeleteMessage:c,onCreateNewThread:v,currentUser:f,isLoading:p=!1}){const[x,z]=g.useState(""),[w,k]=g.useState(!1),[S,C]=g.useState(s),[T,I]=g.useState(!1),[R,P]=g.useState(null),[F,W]=g.useState(null),[K,_]=g.useState(""),[V,N]=g.useState(null),[xe,O]=g.useState(""),[U,q]=g.useState(null),[ue,G]=g.useState(!1),[A,Z]=g.useState(""),[H,te]=g.useState(!1),Y=g.useRef(null),J=g.useRef(null),Q=f||{name:"You",initials:"YO",color:"#6B7C93"},ne=l||t||o,ge=F?S.find(r=>r.id===F):null;g.useEffect(()=>{C(s)},[s]),g.useEffect(()=>{Y.current&&(!S||S.length===0||Y.current.scrollIntoView({behavior:"smooth"}))},[S]);const X=async()=>{const r=A.trim();if(r){te(!0);try{await(v==null?void 0:v(r)),Z(""),G(!1)}finally{te(!1)}}},re=()=>{G(!1),Z("")},ee=async()=>{const r=x.trim();if(!r)return;const u=r;z("");const $=`temp-${Date.now()}`,pe={id:$,author:Q,content:u,timestamp:"Just now",type:"comment",isOptimistic:!0};if(C(i=>[...i,pe]),n){I(!0);try{await n(u),C(i=>i.map(y=>y.id===$?{...y,isOptimistic:!1}:y))}catch{C(i=>i.filter(y=>y.id!==$))}finally{I(!1)}return}C(i=>i.map(y=>y.id===$?{...y,isOptimistic:!1}:y))},ie=r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),ee())},oe=r=>{W(r.id),_(""),N(null),O(""),P(null),d==null||d(r)},se=async r=>{const u=K.trim();if(u){I(!0);try{await(n==null?void 0:n(u,r)),W(null),_("")}finally{I(!1)}}},ae=r=>{N(r.id),O(r.content||""),W(null),_(""),P(null),a==null||a(r)},le=async()=>{const r=xe.trim();!r||!V||(await(a==null?void 0:a({id:V,content:r})),N(null),O(""))},ce=r=>{q(r),P(null)},de=async()=>{if(!U)return;const r=U;q(null),await(c==null?void 0:c(r))};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"rgba(255, 255, 255, 0.98)",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",overflow:"hidden",position:"relative"},children:[U&&e.jsx("div",{style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(30, 33, 37, 0.35)",borderRadius:"12px"},onClick:()=>q(null),children:e.jsxs("div",{style:{background:"white",borderRadius:"12px",padding:"20px 24px",boxShadow:"0 8px 24px rgba(30, 33, 37, 0.15)",maxWidth:"320px",width:"90%"},onClick:r=>r.stopPropagation(),children:[e.jsx("p",{style:{margin:0,marginBottom:"20px",fontSize:"14px",fontWeight:500,color:"rgba(30, 33, 37, 0.9)",lineHeight:1.45},children:"Do you really want to delete?"}),e.jsxs("div",{style:{display:"flex",gap:"10px",justifyContent:"flex-end"},children:[e.jsx("button",{type:"button",onClick:()=>q(null),style:{padding:"8px 16px",fontSize:"12px",fontWeight:600,color:"rgba(30, 33, 37, 0.45)",background:"rgba(30, 33, 37, 0.1)",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:de,style:{padding:"8px 16px",fontSize:"12px",fontWeight:600,color:"white",background:"#5e88b0",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Delete"})]})]})}),ne&&e.jsx("div",{style:{padding:"14px 16px",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",background:"rgba(255, 255, 255, 0.98)"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"rgba(30, 33, 37, 0.95)",marginBottom:"4px"},children:l||"Session Discussion"}),(t||o)&&e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.52)"},children:t||o})]}),e.jsxs("button",{type:"button",onClick:()=>{G(r=>!r)},style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"6px 12px",fontSize:"13px",fontWeight:500,color:"rgba(30, 33, 37, 0.75)",background:"transparent",border:"1px solid rgba(30, 33, 37, 0.12)",borderRadius:"6px",cursor:"pointer",transition:"background 0.15s ease, color 0.15s ease"},onMouseEnter:r=>{r.currentTarget.style.background="rgba(231, 212, 162, 0.12)",r.currentTarget.style.color="rgba(30, 33, 37, 0.9)"},onMouseLeave:r=>{r.currentTarget.style.background="transparent",r.currentTarget.style.color="rgba(30, 33, 37, 0.75)"},title:"Start a new discussion thread",children:[e.jsx("span",{style:{fontSize:16,lineHeight:1,marginTop:-1},children:"+"}),"New thread"]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"16px"},children:[ue&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px",background:"rgba(30, 33, 37, 0.04)",border:"1px solid rgba(52, 58, 64, 0.14)",borderRadius:"8px"},children:[e.jsx("textarea",{value:A,onChange:r=>Z(r.target.value),onKeyDown:r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),X())},placeholder:"Start a new thread...",disabled:H,style:{width:"100%",minHeight:"64px",padding:"8px 12px",fontSize:"13px",color:"rgba(30, 33, 37, 0.88)",background:"white",border:"1px solid rgba(52, 58, 64, 0.16)",borderRadius:"6px",resize:"vertical",outline:"none",fontFamily:"inherit",lineHeight:1.5,marginBottom:"10px"}}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{type:"button",onClick:re,disabled:H,style:{padding:"6px 14px",fontSize:"12px",fontWeight:500,color:"rgba(30, 33, 37, 0.7)",background:"rgba(30, 33, 37, 0.08)",border:"none",borderRadius:"6px",cursor:H?"not-allowed":"pointer"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:X,disabled:!A.trim()||H,style:{padding:"6px 14px",fontSize:"12px",fontWeight:600,color:"white",background:A.trim()&&!H?"#5e88b0":"rgba(30, 33, 37, 0.25)",border:"none",borderRadius:"6px",cursor:A.trim()&&!H?"pointer":"not-allowed"},children:H?"Sending...":"Send"})]})]}),p?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"40px",color:"rgba(30, 33, 37, 0.42)"},children:"Loading messages..."}):S.length===0?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"40px",color:"rgba(30, 33, 37, 0.42)"},children:"No messages yet. Start the conversation!"}):S.map(r=>e.jsxs("div",{onMouseEnter:()=>r.type!=="system"&&P(r.id),onMouseLeave:()=>P(null),style:{display:"flex",gap:"12px",opacity:r.type==="system"?.75:1,padding:"4px 0",margin:"0 -4px",borderRadius:"8px"},children:[r.type!=="system"?e.jsx("div",{style:{width:"36px",height:"36px",borderRadius:"50%",background:r.author.color,color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:650,flexShrink:0},children:r.author.initials}):e.jsx("div",{style:{width:"36px",height:"36px",borderRadius:"50%",background:"rgba(30, 33, 37, 0.1)",color:"rgba(30, 33, 37, 0.55)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(m.Clock,{size:16})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",flexWrap:"wrap",gap:"8px",marginBottom:"6px",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",flexWrap:"wrap",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:650,color:"rgba(30, 33, 37, 0.9)"},children:r.author.name}),e.jsx("span",{style:{fontSize:"10px",fontFamily:"var(--default-mono-font-family)",color:"rgba(30, 33, 37, 0.5)"},children:r.timestamp})]}),r.type!=="system"&&R===r.id&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flexShrink:0},children:[d&&e.jsx("button",{type:"button",onClick:u=>{u.preventDefault(),u.stopPropagation(),oe(r)},style:fe,children:"Reply"}),a&&e.jsx("button",{type:"button",onClick:u=>{u.preventDefault(),u.stopPropagation(),ae(r)},style:fe,children:"Edit"}),c&&e.jsx("button",{type:"button",onClick:u=>{u.preventDefault(),u.stopPropagation(),ce(r)},style:{...fe,color:"rgba(198, 99, 99, 0.9)"},children:"Delete"})]})]}),V===r.id?e.jsx("div",{style:{marginTop:"6px"},children:e.jsx("textarea",{value:xe,onChange:u=>O(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),le()),u.key==="Escape"&&(N(null),O(""))},placeholder:"Edit message...",autoFocus:!0,style:{width:"100%",minHeight:"64px",padding:"8px 12px",fontSize:"13px",color:"rgba(30, 33, 37, 0.88)",background:"white",border:"1px solid rgba(52, 58, 64, 0.2)",borderRadius:"6px",resize:"vertical",outline:"none",fontFamily:"inherit",lineHeight:1.5,marginBottom:"8px"}})}):e.jsx("div",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.88)",lineHeight:1.55},children:r.content}),F===r.id&&e.jsx("div",{style:{marginTop:"12px"},children:e.jsx("textarea",{value:K,onChange:u=>_(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),se(r.id)),u.key==="Escape"&&(W(null),_(""))},placeholder:"Type your reply...",disabled:T,autoFocus:!0,style:{width:"100%",minHeight:"64px",padding:"8px 12px",fontSize:"13px",color:"rgba(30, 33, 37, 0.88)",background:"white",border:"1px solid rgba(52, 58, 64, 0.16)",borderRadius:"6px",resize:"vertical",outline:"none",fontFamily:"inherit",lineHeight:1.5,marginBottom:"10px"}})})]})]},r.id)),e.jsx("div",{ref:Y})]}),e.jsx("div",{style:{padding:"12px",borderTop:"1px solid rgba(52, 58, 64, 0.12)",background:"rgba(255, 255, 255, 0.95)"},children:e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[e.jsx("div",{style:{width:"36px",height:"36px",borderRadius:"50%",background:Q.color,color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:650,flexShrink:0},children:Q.initials}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("textarea",{ref:J,value:x,onChange:r=>z(r.target.value),onKeyDown:ie,onFocus:()=>k(!0),onBlur:()=>k(!1),placeholder:ge?"Type your reply...":"Add a comment...",style:{width:"100%",minHeight:"38px",maxHeight:"120px",padding:"8px 12px",fontSize:"13px",color:"rgba(30, 33, 37, 0.85)",background:"white",border:`1px solid ${w?"rgba(94, 136, 176, 0.35)":"rgba(52, 58, 64, 0.16)"}`,borderRadius:"8px",resize:"vertical",outline:"none",transition:"border-color 0.15s ease",fontFamily:"inherit",lineHeight:1.5}}),e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",onClick:ee,disabled:!x.trim()||T,style:{padding:"8px 16px",background:x.trim()&&!T?"#5e88b0":"rgba(30, 33, 37, 0.1)",border:"none",borderRadius:"6px",color:x.trim()&&!T?"white":"rgba(30, 33, 37, 0.45)",fontSize:"12px",fontWeight:600,cursor:x.trim()&&!T?"pointer":"not-allowed",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.15s ease"},children:T?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"14px",height:"14px",border:"2px solid rgba(255, 255, 255, 0.3)",borderTopColor:"white",borderRadius:"50%",animation:"spin 0.6s linear infinite"}}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(m.Send,{size:14}),"Send"]})})})]})]})})]})}function E(t,o){return t.find(l=>l.block_id===o)}function Pe({data:t,audioUrl:o,coachingData:l,coachingLoading:s,coachingError:n}){var re,ee,ie,oe,se,ae,le,ce,de,r,u,$,pe;const d=t.blocks||[];t.evidence_index;const a=g.useRef(null),c=g.useRef(null),[v,f]=g.useState(new Set),[p,x]=g.useState(new Set),[z,w]=g.useState(0),[k,S]=g.useState(!1),[C,T]=g.useState(1),I=((re=E(d,"interaction-metadata"))==null?void 0:re.payload)||{},R=((ee=E(d,"interaction-context"))==null?void 0:ee.payload)||{},P=((ie=E(d,"interaction-summary"))==null?void 0:ie.payload)||{},F=((oe=E(d,"interaction-scores"))==null?void 0:oe.payload)||{},W=((se=E(d,"interaction-signals"))==null?void 0:se.payload)||{},K=((ae=E(d,"interaction-guidance"))==null?void 0:ae.payload)||{},_=((le=E(d,"interaction-transcript"))==null?void 0:le.payload)||{},V=((ce=E(d,"interaction-message-thread"))==null?void 0:ce.payload)||{},N=((de=E(d,"interaction-nba"))==null?void 0:de.payload)||{},O=((((r=E(d,"interaction-dimensions"))==null?void 0:r.payload)||{}).dimensions||[]).filter(i=>i.value),U=((u=E(d,"interaction-outcome-lift"))==null?void 0:u.payload)||{},q=g.useMemo(()=>{var h;const i={},y={outcome:{color:"var(--rail-outcome)"},process:{color:"var(--rail-discovery)"},compliance:{color:"var(--rail-compliance)"},customer_friction:{color:"var(--rail-coral)"},experience:{color:"var(--rail-teal)"}};for(const b of W.signals||[]){const D=y[b.group]||{};for(const B of b.observations||[])for(const L of B.evidence||[])if((h=L.turn_ids)!=null&&h.length)for(const M of L.turn_ids)i[M]||(i[M]=[]),i[M].some(De=>De.label===(B.key||b.display_name||b.key))||i[M].push({label:B.key||b.display_name||b.key,reason:B.reason||B.explanation||"",color:D.color||"var(--state-present)",signalKey:b.key})}return i},[W.signals]),ue=(($=_.messages)==null?void 0:$.map((i,y)=>{var L,M;const h=i.start??i.start_ms?(i.start??i.start_ms)/1e3:0,b=i.end??i.end_ms?(i.end??i.end_ms)/1e3:h+1,D=i.actor==="agent",B=D?((L=_.actor_map)==null?void 0:L.agent)||"Agent":((M=_.actor_map)==null?void 0:M.customer)||"Customer";return{startTime:h,endTime:b,actor:B,actorColor:D?"var(--rail-outcome)":"var(--rail-discovery)"}}))||[],G=g.useMemo(()=>{if(!k&&z===0)return-1;const i=_.messages||[],y=z*1e3;for(let h=i.length-1;h>=0;h--){const b=i[h].start??i[h].start_ms;if(b!=null&&y>=b)return h}return-1},[z,k,_.messages]),A=i=>{a.current&&(a.current.currentTime=i,w(i))},Z=()=>{if(a.current)if(k)a.current.pause(),S(!1);else{const i=a.current.play();i!==void 0&&i.catch(()=>{}),S(!0)}},H=()=>{a.current&&(a.current.currentTime=Math.max(0,a.current.currentTime-15))},te=()=>{if(a.current){const i=I.duration_seconds||a.current.duration||0;a.current.currentTime=Math.min(i,a.current.currentTime+15)}},Y=i=>{a.current&&(a.current.playbackRate=i,T(i))};g.useEffect(()=>{const i=a.current;if(!i)return;const y=()=>w(i.currentTime),h=()=>S(!0),b=()=>S(!1),D=()=>S(!1);return i.addEventListener("timeupdate",y),i.addEventListener("play",h),i.addEventListener("pause",b),i.addEventListener("ended",D),()=>{i.removeEventListener("timeupdate",y),i.removeEventListener("play",h),i.removeEventListener("pause",b),i.removeEventListener("ended",D)}},[o]);const J=(i,y)=>{const h=a.current;if(!h)return;const b=i/1e3;h.currentTime=b,w(b);const D=h.play();if(D!==void 0&&D.catch(()=>{}),c.current&&(h.removeEventListener("timeupdate",c.current),c.current=null),y!=null){const B=y/1e3,L=()=>{h.currentTime>=B&&(h.pause(),c.current&&(h.removeEventListener("timeupdate",c.current),c.current=null))};c.current=L,h.addEventListener("timeupdate",L)}},Q=(i,y)=>{const b=(_.messages||[])[y],D=a.current;if(!b||!D)return;const B=b.start??b.start_ms,L=b.end??b.end_ms;if(k&&G===y){D.pause();return}B!=null&&J(B,L)},ne=i=>{f(new Set(i));const y=document.getElementById("transcript-container");y&&y.scrollIntoView({behavior:"smooth",block:"nearest"}),setTimeout(()=>f(new Set),5e3)},ge=i=>{x(y=>{const h=new Set(y);return h.has(i)?h.delete(i):h.add(i),h})},X=((pe=R.call_purpose)==null?void 0:pe.interaction_driver)||P.one_liner||"Interaction Detail";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx(ke,{title:X,meta:I,callPurpose:R.call_purpose,classification:R.classification,dimensions:O}),e.jsx(ze,{scores:F.scores}),e.jsx(je,{outcomeLift:U}),(s||l||n)&&e.jsx(j.DetailCard,{title:"Coaching Summary",children:e.jsx(Se,{data:l,loading:s,error:n})}),e.jsx(Ce,{signals:W,expandedSignals:p,toggleSignal:ge,playAudio:J,highlightTurns:ne}),e.jsx(we,{guidance:K,playAudio:J,highlightTurns:ne}),e.jsx(Te,{nba:N}),e.jsx(Ie,{audioUrl:o,timelineSegments:ue,durationSeconds:I.duration_seconds,currentTimeSeconds:z,timelinePlaying:k,playbackRate:C,onSeek:A,onTogglePlay:Z,onSeekBack:H,onSeekForward:te,onSetPlaybackRate:Y,audioRef:a}),e.jsx(_e,{transcript:_,audioUrl:o,highlightedTurns:v,activeTurnIndex:G,timelinePlaying:k,turnObservations:q,setExpandedSignals:x,onTurnPlayPause:Q}),e.jsx(Le,{messageThread:V,sessionTitle:X,messages:[]})]})}class He extends g.Component{constructor(o){super(o),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(o,l){console.error("InteractionDetailPanel render error:",o,l==null?void 0:l.componentStack)}render(){return this.state.hasError?this.props.fallback:this.props.children}}function Fe(t){return e.jsx(He,{fallback:e.jsx("div",{style:{padding:16,color:"var(--state-unknown)",fontSize:12},children:"Error rendering detail."}),children:e.jsx(Pe,{...t})})}function Oe({pattern:t}){const[o,l]=g.useState(!1),s={name:"Customer Escalation Likelihood",description:"Based on observed patterns, this session shows indicators consistent with potential escalation.",technicalKey:"signal.escalation_likelihood",probability:.68,confidence:.81,observations:3};return t==="text-link"?e.jsxs("div",{style:{position:"relative",background:"rgba(255, 255, 255, 0.82)",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",overflow:"hidden",boxShadow:"0 2px 4px rgba(30, 33, 37, 0.06)"},children:[e.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"5px",background:"#6B7C93",opacity:.6}}),e.jsxs("div",{style:{padding:"14px 16px 14px 21px"},children:[e.jsx("div",{style:{marginBottom:"4px"},children:e.jsx("span",{style:{fontSize:"13px",fontWeight:680,color:"rgba(30, 33, 37, 0.92)",lineHeight:1.2},children:s.name})}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.65)",lineHeight:1.4,marginBottom:"6px"},children:s.description}),e.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.42)",fontFamily:"ui-monospace, monospace",marginBottom:"8px"},children:s.technicalKey}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",fontSize:"11.5px",marginBottom:"10px"},children:[e.jsx("span",{style:{color:"rgba(139, 157, 127, 0.65)"},children:"prob"}),e.jsx("strong",{style:{color:"rgba(139, 157, 127, 0.85)"},children:s.probability.toFixed(2)}),e.jsx("span",{style:{color:"rgba(30, 33, 37, 0.24)"},children:"·"}),e.jsx("span",{style:{color:"rgba(184, 156, 106, 0.65)"},children:"conf"}),e.jsx("strong",{style:{color:"rgba(184, 156, 106, 0.85)"},children:s.confidence.toFixed(2)}),e.jsx("span",{style:{color:"rgba(30, 33, 37, 0.24)"},children:"·"}),e.jsxs("span",{style:{color:"rgba(30, 33, 37, 0.52)"},children:[s.observations," observations"]})]}),!o&&e.jsx("button",{onClick:()=>l(!0),style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.56)",background:"none",border:"none",padding:0,cursor:"pointer",textDecoration:"underline",textDecorationColor:"rgba(30, 33, 37, 0.2)"},onMouseEnter:n=>{n.currentTarget.style.color="rgba(30, 33, 37, 0.78)",n.currentTarget.style.textDecorationColor="rgba(30, 33, 37, 0.4)"},onMouseLeave:n=>{n.currentTarget.style.color="rgba(30, 33, 37, 0.56)",n.currentTarget.style.textDecorationColor="rgba(30, 33, 37, 0.2)"},children:"View contributing observations"})]}),o&&e.jsxs("div",{style:{borderTop:"1px solid rgba(52, 58, 64, 0.08)",background:"rgba(244, 241, 230, 0.25)",padding:"16px 16px 16px 21px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:650,letterSpacing:"0.08em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.52)",marginBottom:"8px"},children:"Contributing Observations"}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.62)"},children:"[Observations would appear here]"}),e.jsx("button",{onClick:()=>l(!1),style:{marginTop:"10px",fontSize:"12px",color:"rgba(30, 33, 37, 0.56)",background:"none",border:"none",padding:0,cursor:"pointer",textDecoration:"underline",textDecorationColor:"rgba(30, 33, 37, 0.2)"},onMouseEnter:n=>{n.currentTarget.style.color="rgba(30, 33, 37, 0.78)",n.currentTarget.style.textDecorationColor="rgba(30, 33, 37, 0.4)"},onMouseLeave:n=>{n.currentTarget.style.color="rgba(30, 33, 37, 0.56)",n.currentTarget.style.textDecorationColor="rgba(30, 33, 37, 0.2)"},children:"Hide observations"})]})]}):t==="rotating-chevron"?e.jsxs("div",{style:{position:"relative",background:"rgba(255, 255, 255, 0.82)",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",overflow:"hidden",boxShadow:"0 2px 4px rgba(30, 33, 37, 0.06)"},children:[e.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"5px",background:"#6B7C93",opacity:.6}}),e.jsx("button",{type:"button",onClick:()=>l(!o),style:{width:"100%",padding:"14px 16px 14px 21px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",transition:"background 0.15s ease"},onMouseEnter:n=>{n.currentTarget.style.background="rgba(231, 212, 162, 0.08)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent"},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"12px"},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{marginBottom:"4px"},children:e.jsx("span",{style:{fontSize:"13px",fontWeight:680,color:"rgba(30, 33, 37, 0.92)",lineHeight:1.2},children:s.name})}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.65)",lineHeight:1.4,marginBottom:"6px"},children:s.description}),e.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.42)",fontFamily:"ui-monospace, monospace",marginBottom:"8px"},children:s.technicalKey}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",fontSize:"11.5px"},children:[e.jsx("span",{style:{color:"rgba(139, 157, 127, 0.65)"},children:"prob"}),e.jsx("strong",{style:{color:"rgba(139, 157, 127, 0.85)"},children:s.probability.toFixed(2)}),e.jsx("span",{style:{color:"rgba(30, 33, 37, 0.24)"},children:"·"}),e.jsx("span",{style:{color:"rgba(184, 156, 106, 0.65)"},children:"conf"}),e.jsx("strong",{style:{color:"rgba(184, 156, 106, 0.85)"},children:s.confidence.toFixed(2)}),e.jsx("span",{style:{color:"rgba(30, 33, 37, 0.24)"},children:"·"}),e.jsxs("span",{style:{color:"rgba(30, 33, 37, 0.52)"},children:[s.observations," observations"]})]})]}),e.jsx("div",{style:{paddingTop:"2px",color:"rgba(30, 33, 37, 0.42)",flexShrink:0,transition:"transform 0.2s ease"},children:e.jsx(m.ChevronDown,{size:18,style:{transform:o?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})})]})}),o&&e.jsxs("div",{style:{borderTop:"1px solid rgba(52, 58, 64, 0.08)",background:"rgba(244, 241, 230, 0.25)",padding:"16px 16px 16px 21px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:650,letterSpacing:"0.08em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.52)",marginBottom:"8px"},children:"Contributing Observations"}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.62)"},children:"[Observations would appear here]"})]})]}):e.jsxs("div",{style:{position:"relative",background:"rgba(255, 255, 255, 0.82)",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",overflow:"hidden",boxShadow:"0 2px 4px rgba(30, 33, 37, 0.06)"},children:[e.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"5px",background:"#6B7C93",opacity:.6}}),e.jsxs("button",{type:"button",onClick:()=>l(!o),style:{width:"100%",padding:"14px 16px 14px 21px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"flex-start",gap:"12px",transition:"background 0.15s ease"},onMouseEnter:n=>{n.currentTarget.style.background="rgba(231, 212, 162, 0.08)"},onMouseLeave:n=>{n.currentTarget.style.background="transparent"},children:[e.jsx("div",{style:{paddingTop:"2px",color:"rgba(30, 33, 37, 0.42)",flexShrink:0},children:o?e.jsx(m.ChevronDown,{size:16}):e.jsx(m.ChevronRight,{size:16})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{marginBottom:"4px"},children:e.jsx("span",{style:{fontSize:"13px",fontWeight:680,color:"rgba(30, 33, 37, 0.92)",lineHeight:1.2},children:s.name})}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.65)",lineHeight:1.4,marginBottom:"6px"},children:s.description}),e.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.42)",fontFamily:"ui-monospace, monospace",marginBottom:"8px"},children:s.technicalKey}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",fontSize:"11.5px"},children:[e.jsx("span",{style:{color:"rgba(139, 157, 127, 0.65)"},children:"prob"}),e.jsx("strong",{style:{color:"rgba(139, 157, 127, 0.85)"},children:s.probability.toFixed(2)}),e.jsx("span",{style:{color:"rgba(30, 33, 37, 0.24)"},children:"·"}),e.jsx("span",{style:{color:"rgba(184, 156, 106, 0.65)"},children:"conf"}),e.jsx("strong",{style:{color:"rgba(184, 156, 106, 0.85)"},children:s.confidence.toFixed(2)}),e.jsx("span",{style:{color:"rgba(30, 33, 37, 0.24)"},children:"·"}),e.jsxs("span",{style:{color:"rgba(30, 33, 37, 0.52)"},children:[s.observations," observations"]})]})]})]}),o&&e.jsxs("div",{style:{borderTop:"1px solid rgba(52, 58, 64, 0.08)",background:"rgba(244, 241, 230, 0.25)",padding:"16px 16px 16px 21px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:650,letterSpacing:"0.08em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.52)",marginBottom:"8px"},children:"Contributing Observations"}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.62)"},children:"[Observations would appear here]"})]})]})}exports.ConditionCard=j.ConditionCard;exports.ModelScoreCard=j.ModelScoreCard;exports.ObservationCard=j.ObservationCard;exports.ScoreDriverCard=j.ScoreDriverCard;exports.ScoreDriverCardVariant=j.ScoreDriverCardVariant;exports.SignalCard=j.SignalCard;exports.SmallObservationCard=j.SmallObservationCard;exports.SummarySection=j.SummarySection;exports.AgentLiftCard=je;exports.CoachingSynthesisCard=Se;exports.EvidenceItem=ye;exports.ExpandPatternComparison=Oe;exports.InteractionContext=ke;exports.InteractionDetailPanel=Fe;exports.InteractionGuidance=we;exports.InteractionNBA=Te;exports.InteractionRecording=Ie;exports.InteractionScores=ze;exports.InteractionSignals=Ce;exports.InteractionTranscript=_e;
|
|
10
|
+
`,document.head.appendChild(n)}function Le({data:n,loading:i,error:o}){var v,b;if(g.useEffect(()=>{qe()},[]),i)return e.jsxs("div",{style:{padding:"20px 0",display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"var(--rail-tone)",animation:"coaching-pulse 1.5s ease-in-out infinite"}}),e.jsx("span",{style:{fontSize:"var(--text-base)",color:"var(--rail-tone)",fontFamily:"var(--font-sans)",fontWeight:500},children:"Compass is synthesizing coaching insights…"})]}),[180,260,220].map((l,x)=>e.jsx("div",{style:{height:10,width:l,maxWidth:"100%",borderRadius:4,background:"linear-gradient(90deg, var(--hover-warm-subtle) 25%, var(--hover-warm) 50%, var(--hover-warm-subtle) 75%)",backgroundSize:"200% 100%",animation:"coaching-shimmer 1.8s ease-in-out infinite",animationDelay:`${x*.2}s`}},x))]});if(o)return e.jsx("div",{style:{padding:"16px 0",fontSize:"var(--text-base)",color:"var(--text-faint)",fontFamily:"var(--font-sans)"},children:"Unable to generate coaching summary."});if(!n)return null;const s=n.strengths||[],r=n.improvements||[],y=n.organizational||n.organizational_insights||[],f=typeof n.one_liner=="string"?n.one_liner:((v=n.one_liner)==null?void 0:v.text)||"",p=typeof n.context=="string"?n.context:((b=n.context)==null?void 0:b.text)||"";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14,fontFamily:"var(--font-sans)"},children:[f&&e.jsx("div",{style:{fontSize:"var(--text-lg)",fontWeight:600,color:"var(--text-strong)",lineHeight:1.4},children:f}),p&&e.jsx("div",{style:{fontSize:"var(--text-base)",color:"var(--text-muted)",lineHeight:1.45},children:p}),s.length>0&&e.jsx(ze,{icon:e.jsx(S.TrendingUp,{size:13}),label:"Strengths",color:"var(--rail-discovery)",items:s}),r.length>0&&e.jsx(ze,{icon:e.jsx(S.Lightbulb,{size:13}),label:"Improvements",color:"var(--rail-compliance)",items:r}),y.length>0&&e.jsx(ze,{icon:e.jsx(S.Building,{size:13}),label:"Organizational",color:"var(--rail-outcome)",items:y}),n.overall&&e.jsxs("div",{style:{fontSize:"var(--text-base)",color:"var(--text-faint)",fontStyle:"italic",marginTop:2},children:["Overall: ",n.overall.replace(/_/g," ")]})]})}function ze({icon:n,label:i,color:o,items:s}){return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6,color:o,fontSize:"var(--text-base)",fontWeight:650,letterSpacing:"0.04em"},children:[n,i]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:s.map((r,y)=>{const f=typeof r=="string"?r:(r==null?void 0:r.text)||"",p=typeof r=="object"?r==null?void 0:r.quote:null;return e.jsxs("div",{style:{paddingLeft:14},children:[e.jsxs("div",{style:{fontSize:"var(--text-base)",color:"var(--text-base)",lineHeight:1.4},children:["• ",f]}),p&&e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:4,marginTop:3,paddingLeft:8},children:[e.jsx(S.MessageSquareQuote,{size:10,style:{color:"var(--text-faint)",flexShrink:0,marginTop:2}}),e.jsxs("span",{style:{fontSize:"var(--text-base)",color:"var(--text-muted)",fontStyle:"italic",lineHeight:1.35},children:['"',p,'"']})]})]},y)})})]})}function Ge(n){const i=Math.floor(n/60),o=Math.round(n%60);return`${i}:${o.toString().padStart(2,"0")}`}function Ae({title:n,meta:i,callPurpose:o,classification:s,dimensions:r}){const y=o||{},f=s||{};return e.jsxs(w.Card,{variant:"elevated",padding:"sm",children:[e.jsx("div",{style:{fontSize:"var(--text-md)",fontWeight:550,color:"var(--text-strong)",lineHeight:1.375,marginBottom:6},children:n}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"4px 12px",fontSize:11,color:"var(--text-muted)"},children:[i.evaluated_dt&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Date"}),e.jsx("div",{style:{color:"var(--text-base)"},children:new Date(i.evaluated_dt).toLocaleString()})]}),i.duration_seconds!=null&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Duration"}),e.jsx("div",{style:{color:"var(--text-base)"},children:Ge(i.duration_seconds)})]}),i.message_count&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Messages"}),e.jsx("div",{style:{color:"var(--text-base)"},children:i.message_count})]}),y.interaction_direction&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Direction"}),e.jsx("div",{style:{color:"var(--text-base)"},children:y.interaction_direction})]}),y.interaction_driver&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Driver"}),e.jsx("div",{style:{color:"var(--text-base)"},children:y.interaction_driver})]}),y.customer_intent&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Intent"}),e.jsx("div",{style:{color:"var(--text-base)"},children:y.customer_intent})]}),f.interaction_paradigm&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:"Paradigm"}),e.jsx("div",{style:{color:"var(--text-base)"},children:f.interaction_paradigm})]}),r.map((p,v)=>e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-faint)"},children:p.label||p.key}),e.jsx("div",{style:{color:"var(--text-base)"},children:p.value})]},v))]}),i.session_id&&e.jsx("div",{style:{fontSize:9,color:"var(--text-faint)",fontFamily:"var(--font-mono)",marginTop:4,userSelect:"all"},children:i.session_id})]})}function Ve({scores:n}){return n!=null&&n.length?e.jsx(w.DetailCard,{title:"Scores",children:e.jsx("div",{style:{display:"flex",gap:24,flexWrap:"wrap"},children:n.map((i,o)=>{const s=i.value!=null?Math.round(i.value):null;return e.jsxs("div",{style:{textAlign:"center",minWidth:48},children:[e.jsx("div",{style:{fontSize:20,fontWeight:700,color:"var(--text-ink)"},children:s??"—"}),e.jsx("div",{style:{fontSize:"var(--text-sm)",color:"var(--text-muted)",marginTop:2},children:i.label||i.key})]},o)})})}):null}const Ee={outcome:{label:"Outcome",icon:e.jsx(S.Target,{size:12}),color:"var(--rail-outcome)"},process:{label:"Process & Protocol",icon:e.jsx(S.FileText,{size:12}),color:"var(--rail-discovery)"},compliance:{label:"Compliance",icon:e.jsx(S.Scale,{size:12}),color:"var(--rail-compliance)"},customer_friction:{label:"Customer Friction",icon:e.jsx(S.Zap,{size:12}),color:"var(--rail-coral)"},experience:{label:"Experience",icon:e.jsx(S.MessageSquare,{size:12}),color:"var(--rail-teal)"}},Ze={risk:{icon:e.jsx(S.Zap,{size:10}),color:"var(--rail-signal-churn)"},opportunity:{icon:e.jsx(S.Lightbulb,{size:10}),color:"var(--state-unknown)"},excellence:{icon:e.jsx(S.CheckCircle,{size:10}),color:"var(--rail-teal)"}};function Fe({signals:n,expandedSignals:i,toggleSignal:o,playAudio:s,highlightTurns:r}){var f;if(!((f=n==null?void 0:n.signals)!=null&&f.length))return null;const y=g.useMemo(()=>{const p={};for(const v of n.signals){const b=v.group||"experience";p[b]||(p[b]=[]),p[b].push(v)}return p},[n]);return e.jsx(w.DetailCard,{title:`Signals (${n.present_count} present / ${n.total_signals_evaluated} evaluated)`,children:Object.entries(y).map(([p,v])=>{const b=Ee[p]||Ee.experience;return e.jsxs("div",{style:{marginBottom:10},children:[e.jsxs(w.SectionLabel,{style:{display:"flex",alignItems:"center",gap:4},children:[b.icon,e.jsx("span",{children:b.label})]}),e.jsx("div",{style:{marginTop:4,display:"flex",flexDirection:"column",gap:6},children:v.map((l,x)=>{var z,T,C;const u=l.display_name||l.key||"",k=(z=l.baseline)==null?void 0:z.delta,_=((T=l.observations)==null?void 0:T.length)>0,E=i.has(l.key);return e.jsxs("div",{id:`signal-${l.key}`,style:{border:"1px solid var(--border)",borderRadius:"var(--radius-md)",background:"var(--paper)",overflow:"hidden"},children:[e.jsxs("button",{type:"button",onClick:D=>{_&&(o(l.key),D.currentTarget.blur())},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",background:"transparent",border:"none",cursor:_?"pointer":"default"},title:[l.confidence!=null?`Confidence: ${Math.round(l.confidence*100)}%`:"",k!=null?`Δ baseline: ${k>0?"+":""}${(k*100).toFixed(1)}%`:""].filter(Boolean).join(" · "),children:[e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap"},children:[(C=Ze[l.kind])==null?void 0:C.icon,e.jsx("span",{children:u}),_&&e.jsxs("span",{style:{marginLeft:4,fontSize:10,opacity:.6},children:["(",l.observations.length,")"]})]}),_&&e.jsx(S.ChevronDown,{size:14,style:{color:"var(--text-muted)",flexShrink:0,transform:E?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.16s ease"}})]}),E&&l.observations&&e.jsx("div",{style:{width:"100%",margin:"0 0 6px"},children:l.observations.map((D,L)=>{var R;return e.jsxs("div",{style:{fontSize:"var(--text-sm)",color:"var(--text-muted)",padding:"8px 12px",background:"var(--paper)",borderLeft:`3px solid ${b.color}`,marginBottom:6,borderRadius:"0 var(--radius-sm) var(--radius-sm) 0"},children:[e.jsx("div",{style:{fontWeight:600,color:"var(--text-base)",marginBottom:3,fontSize:"var(--text-base)"},children:D.key||""}),e.jsx("div",{style:{marginBottom:6,lineHeight:1.4},children:D.reason||D.explanation||""}),(R=D.evidence)==null?void 0:R.map((Y,P)=>e.jsx(_e,{ev:Y,onPlay:s,onHighlight:r},P))]},L)})})]},x)})})]},p)})})}const Be={risk:{icon:e.jsx(S.Zap,{size:10}),color:"var(--rail-signal-churn)"},opportunity:{icon:e.jsx(S.Lightbulb,{size:10}),color:"var(--state-unknown)"},excellence:{icon:e.jsx(S.CheckCircle,{size:10}),color:"var(--rail-teal)"}};function Pe({guidance:n,playAudio:i,highlightTurns:o}){var s;return(s=n==null?void 0:n.items)!=null&&s.length?e.jsx(w.DetailCard,{title:`Guidance (${n.total_items} items)`,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:n.items.map((r,y)=>{var v;const f=Be[r.guidance_kind]||Be.excellence,p=r.owner==="organization"?{bg:"color-mix(in srgb, var(--rail-discovery) 15%, transparent)",color:"var(--rail-discovery)",text:"ORG"}:r.owner==="shared"?{bg:"color-mix(in srgb, var(--state-unknown) 15%, transparent)",color:"var(--state-unknown)",text:"SHARED"}:{bg:"color-mix(in srgb, var(--rail-teal) 10%, transparent)",color:"var(--rail-teal)",text:"AGENT"};return e.jsxs("div",{style:{padding:"10px 12px",borderRadius:"var(--radius)",background:"var(--paper)",borderLeft:`3px solid ${f.color}`},children:[e.jsxs("div",{style:{fontSize:"var(--text-base)",color:"var(--text-strong)",display:"flex",alignItems:"center",gap:5,fontWeight:550},children:[f.icon," ",r.title||"",e.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:8,marginLeft:4,background:p.bg,color:p.color,fontWeight:600},children:p.text})]}),r.detail&&e.jsx("div",{style:{fontSize:"var(--text-sm)",color:"var(--text-muted)",marginTop:4,lineHeight:1.4},children:r.detail}),(v=r.signal_refs)==null?void 0:v.map((b,l)=>{var x;return e.jsxs("div",{style:{marginTop:6},children:[e.jsxs("div",{style:{fontSize:10,color:"var(--text-muted)",fontWeight:600,marginBottom:3,display:"flex",alignItems:"center",gap:3},children:[e.jsx(S.CornerDownRight,{size:10})," ",b.display_name||b.signal_key,b.confidence!=null&&e.jsxs("span",{style:{fontWeight:400,opacity:.7},children:[" (",Math.round(b.confidence*100),"%)"]})]}),(x=b.evidence)==null?void 0:x.map((u,k)=>e.jsx(_e,{ev:u,onPlay:i,onHighlight:o},k))]},l)})]},y)})})}):null}function $e({nba:n}){const i=(n==null?void 0:n.recommendations)||(n==null?void 0:n.actions)||[];return i.length?e.jsx(w.DetailCard,{title:"Next Best Actions",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:i.slice(0,8).map((o,s)=>e.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",display:"flex",alignItems:"center",gap:4},children:[e.jsx(S.Target,{size:12})," ",e.jsx("strong",{style:{color:"var(--text-base)"},children:o.action||o.title||""}),o.rationale&&` — ${o.rationale}`]},s))})}):null}function He({audioUrl:n,timelineSegments:i,durationSeconds:o,currentTimeSeconds:s,timelinePlaying:r,playbackRate:y,onSeek:f,onTogglePlay:p,onSeekBack:v,onSeekForward:b,onSetPlaybackRate:l,audioRef:x}){return n?e.jsxs(w.DetailCard,{title:"Recording",children:[e.jsx(w.Timeline,{segments:i,durationSeconds:o||0,currentTimeSeconds:s,onSeek:f,showControls:!0,hasRecording:!0,timelinePlaying:r,playbackRate:y,onTogglePlay:p,onSeekBack:v,onSeekForward:b,onSetPlaybackRate:l}),e.jsx("audio",{ref:x,preload:"none",style:{display:"none"},children:e.jsx("source",{src:n,type:"audio/mpeg"})})]}):null}function Oe({transcript:n,audioUrl:i,highlightedTurns:o,activeTurnIndex:s,timelinePlaying:r,turnObservations:y,setExpandedSignals:f,onTurnPlayPause:p}){var l;if(!((l=n==null?void 0:n.messages)!=null&&l.length))return null;const v=(x,u)=>{if(x==null)return;const k=z=>{const T=Math.floor(z/6e4),C=Math.floor(z%6e4/1e3);return`${T.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`},_=k(x),E=u!=null?k(u):_;return`${_}–${E}`},b=n.messages.map((x,u)=>{var k,_;return{actor:x.actor==="agent"?((k=n.actor_map)==null?void 0:k.agent)||"Agent":((_=n.actor_map)==null?void 0:_.customer)||"Customer",actorType:x.actor==="agent"?"agent":"customer",text:x.text||"",timeRange:v(x.start??x.start_ms,x.end??x.end_ms),isHighlighted:o.has(u),highlightColor:r&&s===u?x.actor==="agent"?"var(--rail-outcome)":"var(--rail-discovery)":void 0,observations:(y[u]||[]).map(E=>({...E,onClick:()=>{f(z=>new Set([...z,E.signalKey])),setTimeout(()=>{const z=document.getElementById(`signal-${E.signalKey}`);z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})},100)}}))}});return e.jsx("div",{id:"transcript-container",children:e.jsx(w.TranscriptCard,{turns:b,audioUrl:i,activeTurnIndex:s,autoScrollActiveTurn:r,isExternalPlaying:r,onTurnPlayPause:p})})}const Te={padding:0,border:"none",background:"transparent",fontSize:"12px",fontWeight:500,color:"rgba(30, 33, 37, 0.65)",cursor:"pointer",fontFamily:"inherit"},Ne=n=>{if(!n)return null;const i=String(n).toLowerCase();return i==="supervisor"?"var(--rail-compliance)":i==="admin"||i==="administrator"?"var(--rail-discovery)":i==="agent"?"var(--rail-outcome)":null},We=n=>{if(!n)return[];const i=[n.messages,n.comments,n.thread_messages,n.items,n.children];for(const o of i)if(Array.isArray(o)&&o.length)return o;return n.messages&&Array.isArray(n.messages.data)?n.messages.data:[]},Ie=(n,i=null,o=0)=>{const s=[];return(n||[]).forEach((r,y)=>{const f=r.author||{},p=f.name||r.author_name||"Unknown",v=f.initials||p.split(" ").map(_=>_[0]).join("").toUpperCase()||"U",b=f.role||r.author_role,l=Ne(b),x=f.color||r.author_color||l||"#6B7C93",u=r.id||`msg-${o+y}`,k={id:u,author:{name:p,initials:v,color:x,role:b},content:r.content||r.text||"",timestamp:r.timestamp||r.created_at_display||r.created_at||"",type:r.type||"comment",isEdited:r.isEdited||r.is_edited||r.edited||!1,references:r.references||[],parentId:r.parentId||r.parent_message_id||i||null};s.push(k),Array.isArray(r.replies)&&r.replies.length>0&&s.push(...Ie(r.replies,u,o+s.length))}),s},Je=n=>{if(!n)return"";if(!/^\d{4}-\d{2}-\d{2}T/.test(n))return n;try{const i=new Date(n);if(Number.isNaN(i.getTime()))return n;const o=new Date,s=i.getFullYear()===o.getFullYear()&&i.getMonth()===o.getMonth()&&i.getDate()===o.getDate(),r=new Date(o);r.setDate(r.getDate()-1);const y=i.getFullYear()===r.getFullYear()&&i.getMonth()===r.getMonth()&&i.getDate()===r.getDate(),f=i.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1});if(s)return`Today at ${f}`;if(y)return`Yesterday at ${f}`;const v=(o.getTime()-i.getTime())/(1e3*60*60*24);return v<7&&v>0?`${i.toLocaleDateString(void 0,{weekday:"long"})} at ${f}`:`${i.toLocaleDateString(void 0,{month:"short",day:"numeric",year:i.getFullYear()!==o.getFullYear()?"numeric":void 0})} at ${f}`}catch{return n}};function Qe({sessionTitle:n,sessionSubtitle:i,threadLabel:o,messages:s,messageThread:r,onSendMessage:y,onReplyMessage:f,onEditMessage:p,onDeleteMessage:v,onCreateNewThread:b,currentUser:l,isLoading:x=!1}){const[u,k]=g.useState(""),[_,E]=g.useState(!1),[z,T]=g.useState(s||[]),[C,D]=g.useState(!1),[L,R]=g.useState(null),[Y,P]=g.useState([]),[Q,$]=g.useState(null),[O,M]=g.useState(null),[H,B]=g.useState(""),[ve,se]=g.useState(null),[De,ae]=g.useState(""),[U,q]=g.useState(null),[le,X]=g.useState(!1),[N,ee]=g.useState(""),[F,ce]=g.useState(!1),[te,G]=g.useState(new Set),K=g.useRef(null),je=g.useRef(null),ne=l&&l.role&&String(l.role).toLowerCase()||"",V=g.useMemo(()=>{if(!l)return{name:"You",initials:"YO",color:"#6B7C93"};const t=l.name||"You",c=l.initials||t.split(" ").map(m=>m[0]).join("").toUpperCase()||"YO",a=l.role&&String(l.role).toLowerCase(),d=Ne(a),h=l.color||d||"#6B7C93";return{...l,name:t,initials:c,color:h}},[l]),Se=ne==="supervisor"||ne==="admin",ke=g.useMemo(()=>{const t={};return(z||[]).forEach(c=>{c.parentId&&(t[c.parentId]||(t[c.parentId]=[]),t[c.parentId].push(c))}),t},[z]),de=g.useMemo(()=>(z||[]).filter(t=>!t.parentId),[z]),Ce=t=>O===t,we=t=>ve===t,pe=o||n||i,xe=O?z.find(t=>t.id===O):null;g.useEffect(()=>{r||s&&T(s)},[s,r]),g.useEffect(()=>{if(!r)return;const t=Array.isArray(r.threads)?r.threads:Array.isArray(r.items)?r.items:[];if(t.length>0){const a=t.map((j,W)=>{const Z=j.id||j.thread_id||`thread-${W+1}`,I=j.label||j.title||(W===0?o||"Session":`Thread ${W+1}`),J=We(j),Ke=Ie(J);return{id:Z,label:I,messages:Ke}});P(a);const d=a.find(j=>(j.messages||[]).length>0)||a[0],h=(d==null?void 0:d.messages)||[];T(h);const m=new Set(h.filter(j=>j.parentId).map(j=>j.parentId));G(m),$((d==null?void 0:d.id)||null);return}const c=We(r);if(c.length){const a=Ie(c);T(a);const d=new Set(a.filter(j=>j.parentId).map(j=>j.parentId));G(d);const h=r.id||"thread-1",m=r.title||o||"Thread 1";P([{id:h,label:m}]),$(h)}},[r,o]),g.useEffect(()=>{o&&P(t=>t.map((c,a)=>a===0?{...c,label:o}:c))},[o]),g.useEffect(()=>{if(!K.current||!z||z.length===0)return;const t=K.current.parentElement;t?t.scrollTop=t.scrollHeight:K.current.scrollIntoView({behavior:"smooth",block:"end"})},[z]);const re=async()=>{const t=N.trim();if(t){ce(!0);try{const c=`thread-${Date.now()}`;P(a=>[...a,{id:c,label:t.slice(0,32)||`Thread ${a.length+1}`}]),$(c),await(b==null?void 0:b(t)),ee(""),X(!1)}finally{ce(!1)}}},ue=()=>{X(!1),ee("")},ie=async()=>{const t=u.trim();if(!t)return;const c=t;k("");const a=`temp-${Date.now()}`,d={id:a,author:V,content:c,timestamp:"Just now",type:"comment",isOptimistic:!0,parentId:O||null};if(T(h=>[...h,d]),y){D(!0);try{await y({content:c,parent_message_id:O||null}),T(h=>h.map(m=>m.id===a?{...m,isOptimistic:!1}:m))}catch{T(h=>h.filter(m=>m.id!==a))}finally{D(!1)}M(null);return}T(h=>h.map(m=>m.id===a?{...m,isOptimistic:!1}:m)),M(null)},ge=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),ie())},fe=t=>{M(t.id),B(""),se(null),ae(""),R(null),f==null||f(t)},he=async t=>{const c=H.trim();if(!c)return;const a=`reply-${Date.now()}`,d={id:a,author:V,content:c,timestamp:"Just now",type:"comment",isOptimistic:!y,parentId:t};T(h=>[...h,d]),D(!0);try{y&&(await y({content:c,parent_message_id:t}),T(h=>h.map(m=>m.id===a?{...m,isOptimistic:!1}:m))),M(null),B("")}catch{y&&T(h=>h.filter(m=>m.id!==a))}finally{D(!1)}},ye=t=>{se(t.id),ae(t.content||""),M(null),B(""),R(null),p==null||p(t)},me=t=>{q(t),R(null)},be=async()=>{if(!U)return;const t=U;q(null),T(c=>c.filter(a=>a.id!==t.id)),await(v==null?void 0:v(t))},oe=(t,c=0)=>{var W,Z;const a=ke[t.id]||[],d=a.length>0,h=te.has(t.id),m=we(t.id),j=Ce(t.id);return e.jsx("div",{children:e.jsxs("div",{onMouseEnter:()=>t.type!=="system"&&R(t.id),onMouseLeave:()=>R(null),style:{display:"flex",gap:"12px",opacity:t.type==="system"?.75:1,padding:"4px 0",margin:"0 -4px",borderRadius:"8px",marginLeft:c>0?16:0},children:[t.type!=="system"?e.jsx("div",{style:{width:"36px",height:"36px",borderRadius:"50%",background:t.author.color,color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:650,flexShrink:0},children:t.author.initials}):e.jsx("div",{style:{width:"36px",height:"36px",borderRadius:"50%",background:"rgba(30, 33, 37, 0.1)",color:"rgba(30, 33, 37, 0.55)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(S.Clock,{size:16})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",flexWrap:"wrap",gap:"8px",marginBottom:"6px",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",flexWrap:"wrap",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:650,color:"rgba(30, 33, 37, 0.9)"},children:t.author.name}),t.timestamp&&e.jsx("span",{style:{fontSize:"10px",fontFamily:"var(--default-mono-font-family)",color:"rgba(30, 33, 37, 0.5)"},children:Je(t.timestamp)}),((W=t.author)==null?void 0:W.role)&&e.jsx("span",{style:{display:"inline-flex",alignItems:"center",fontSize:"10px",color:"rgba(30, 33, 37, 0.6)",background:"rgba(30, 33, 37, 0.08)",padding:"3px 8px",borderRadius:"6px",textTransform:"uppercase",letterSpacing:"0.04em",fontWeight:600},children:String(t.author.role)})]}),t.type!=="system"&&L===t.id&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flexShrink:0},children:[e.jsx("button",{type:"button",onClick:I=>{I.preventDefault(),I.stopPropagation(),fe(t)},style:Te,children:"Reply"}),p&&e.jsx("button",{type:"button",onClick:I=>{I.preventDefault(),I.stopPropagation(),ye(t)},style:Te,children:"Edit"}),v&&e.jsx("button",{type:"button",onClick:I=>{I.preventDefault(),I.stopPropagation(),me(t)},style:{...Te,color:"rgba(198, 99, 99, 0.9)"},children:"Delete"})]})]}),m?null:e.jsx("div",{style:{fontSize:"13px",color:"rgba(30, 33, 37, 0.88)",lineHeight:1.55,marginBottom:(Z=t.references)!=null&&Z.length?"8px":0},children:t.content}),j&&e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsx("textarea",{value:H,onChange:I=>B(I.target.value),onKeyDown:I=>{I.key==="Escape"&&(M(null),B(""))},placeholder:"Type your reply...",disabled:C,autoFocus:!0,style:{width:"100%",minHeight:"64px",padding:"8px 12px",fontSize:"13px",color:"rgba(30, 33, 37, 0.88)",background:"white",border:"1px solid rgba(52, 58, 64, 0.16)",borderRadius:"6px",resize:"vertical",outline:"none",fontFamily:"inherit",lineHeight:1.5,marginBottom:"10px"}}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end",alignItems:"center"},children:[e.jsx("button",{type:"button",onClick:()=>{M(null),B("")},disabled:C,style:{padding:"8px 16px",fontSize:"12px",fontWeight:600,color:"rgba(30, 33, 37, 0.45)",background:"rgba(30, 33, 37, 0.1)",border:"none",borderRadius:"6px",cursor:C?"not-allowed":"pointer"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>he(t.id),disabled:!H.trim()||C,style:{padding:"8px 16px",fontSize:"12px",fontWeight:600,color:H.trim()&&!C?"white":"rgba(30, 33, 37, 0.45)",background:H.trim()&&!C?"#5e88b0":"rgba(30, 33, 37, 0.12)",border:"none",borderRadius:"6px",cursor:H.trim()&&!C?"pointer":"not-allowed"},children:"Send"})]})]}),d&&e.jsxs("div",{style:{marginTop:8},children:[e.jsx("button",{type:"button",onClick:()=>G(I=>{const J=new Set(I);return J.has(t.id)?J.delete(t.id):J.add(t.id),J})}),h&&e.jsx("div",{style:{marginTop:8,marginLeft:16,paddingLeft:16,borderLeft:"2px solid rgba(52, 58, 64, 0.14)"},children:a.map(I=>oe(I,c+1))})]})]})]})},t.id)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"rgba(255, 255, 255, 0.98)",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",overflow:"hidden",position:"relative"},children:[U&&e.jsx("div",{style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(30, 33, 37, 0.35)",borderRadius:"12px"},onClick:()=>q(null),children:e.jsxs("div",{style:{background:"white",borderRadius:"12px",padding:"20px 24px",boxShadow:"0 8px 24px rgba(30, 33, 37, 0.15)",maxWidth:"320px",width:"90%"},onClick:t=>t.stopPropagation(),children:[e.jsx("p",{style:{margin:0,marginBottom:"20px",fontSize:"14px",fontWeight:500,color:"rgba(30, 33, 37, 0.9)",lineHeight:1.45},children:"Do you really want to delete?"}),e.jsxs("div",{style:{display:"flex",gap:"10px",justifyContent:"flex-end"},children:[e.jsx("button",{type:"button",onClick:()=>q(null),style:{padding:"8px 16px",fontSize:"12px",fontWeight:600,color:"rgba(30, 33, 37, 0.45)",background:"rgba(30, 33, 37, 0.1)",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:be,style:{padding:"8px 16px",fontSize:"12px",fontWeight:600,color:"white",background:"#5e88b0",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Delete"})]})]})}),pe&&e.jsx("div",{style:{padding:"14px 16px",borderBottom:"1px solid rgba(52, 58, 64, 0.12)",background:"rgba(255, 255, 255, 0.98)"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"rgba(30, 33, 37, 0.95)",marginBottom:"4px"},children:o||"Session Discussion"}),(n||i)&&e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.52)"},children:n||i}),Y.length>0&&e.jsx("div",{style:{marginTop:"8px",display:"flex",flexWrap:"wrap",gap:"8px"},children:Y.map(t=>{const c=t.id===Q;return e.jsx("button",{type:"button",onClick:()=>{if($(t.id),Array.isArray(t.messages)){T(t.messages);const a=new Set(t.messages.filter(d=>d.parentId).map(d=>d.parentId));G(a)}R(null),M(null),se(null)},style:{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(184, 156, 106, 0.35)",background:c?"rgba(184, 156, 106, 0.16)":"rgba(255, 255, 255, 0.9)",color:"rgba(30, 33, 37, 0.85)",fontSize:"11px",fontWeight:500,cursor:"pointer"},children:t.label},t.id)})})]}),Se&&e.jsxs("button",{type:"button",onClick:()=>{X(t=>!t)},style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"6px 12px",fontSize:"13px",fontWeight:500,color:"rgba(30, 33, 37, 0.75)",background:"transparent",border:"1px solid rgba(30, 33, 37, 0.12)",borderRadius:"6px",cursor:"pointer",transition:"background 0.15s ease, color 0.15s ease"},onMouseEnter:t=>{t.currentTarget.style.background="rgba(231, 212, 162, 0.12)",t.currentTarget.style.color="rgba(30, 33, 37, 0.9)"},onMouseLeave:t=>{t.currentTarget.style.background="transparent",t.currentTarget.style.color="rgba(30, 33, 37, 0.75)"},title:"Start a new discussion thread",children:[e.jsx("span",{style:{fontSize:16,lineHeight:1,marginTop:-1},children:"+"}),"New thread"]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"16px"},children:[le&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px",background:"rgba(30, 33, 37, 0.04)",border:"1px solid rgba(52, 58, 64, 0.14)",borderRadius:"8px"},children:[e.jsx("textarea",{value:N,onChange:t=>ee(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),re())},placeholder:"Start a new thread...",disabled:F,style:{width:"100%",minHeight:"64px",padding:"8px 12px",fontSize:"13px",color:"rgba(30, 33, 37, 0.88)",background:"white",border:"1px solid rgba(52, 58, 64, 0.16)",borderRadius:"6px",resize:"vertical",outline:"none",fontFamily:"inherit",lineHeight:1.5,marginBottom:"10px"}}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{type:"button",onClick:ue,disabled:F,style:{padding:"6px 14px",fontSize:"12px",fontWeight:500,color:"rgba(30, 33, 37, 0.7)",background:"rgba(30, 33, 37, 0.08)",border:"none",borderRadius:"6px",cursor:F?"not-allowed":"pointer"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:re,disabled:!N.trim()||F,style:{padding:"6px 14px",fontSize:"12px",fontWeight:600,color:"white",background:N.trim()&&!F?"#5e88b0":"rgba(30, 33, 37, 0.25)",border:"none",borderRadius:"6px",cursor:N.trim()&&!F?"pointer":"not-allowed"},children:F?"Sending...":"Send"})]})]}),x?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"40px",color:"rgba(30, 33, 37, 0.42)"},children:"Loading messages..."}):de.length===0?e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"40px",color:"rgba(30, 33, 37, 0.42)"},children:"No messages yet. Start the conversation!"}):de.map(t=>oe(t,0)),e.jsx("div",{ref:K})]}),e.jsx("div",{style:{padding:"12px",borderTop:"1px solid rgba(52, 58, 64, 0.12)",background:"rgba(255, 255, 255, 0.95)"},children:e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[e.jsx("div",{style:{width:"36px",height:"36px",borderRadius:"50%",background:V.color,color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",fontWeight:650,flexShrink:0},children:V.initials}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("textarea",{ref:je,value:u,onChange:t=>k(t.target.value),onKeyDown:ge,onFocus:()=>E(!0),onBlur:()=>E(!1),placeholder:xe?"Type your reply...":"Add a comment...",style:{width:"100%",minHeight:"38px",maxHeight:"120px",padding:"8px 12px",fontSize:"13px",color:"rgba(30, 33, 37, 0.85)",background:"white",border:`1px solid ${_?"rgba(94, 136, 176, 0.35)":"rgba(52, 58, 64, 0.16)"}`,borderRadius:"8px",resize:"vertical",outline:"none",transition:"border-color 0.15s ease",fontFamily:"inherit",lineHeight:1.5}}),e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",onClick:ie,disabled:!u.trim()||C,style:{padding:"8px 16px",background:u.trim()&&!C?"#5e88b0":"rgba(30, 33, 37, 0.1)",border:"none",borderRadius:"6px",color:u.trim()&&!C?"white":"rgba(30, 33, 37, 0.45)",fontSize:"12px",fontWeight:600,cursor:u.trim()&&!C?"pointer":"not-allowed",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.15s ease"},children:C?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"14px",height:"14px",border:"2px solid rgba(255, 255, 255, 0.3)",borderTopColor:"white",borderRadius:"50%",animation:"spin 0.6s linear infinite"}}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(S.Send,{size:14}),"Send"]})})})]})]})})]})}function A(n,i){return n.find(o=>o.block_id===i)}function Ue({data:n,audioUrl:i,coachingData:o,messageThread:s,coachingLoading:r,coachingError:y,onThreadSendMessage:f,onThreadEditMessage:p,onThreadDeleteMessage:v,onThreadCreateNewThread:b,threadCurrentUser:l}){var pe,xe,re,ue,ie,ge,fe,he,ye,me,be,oe;const x=n.blocks||[];n.evidence_index;const u=g.useRef(null),k=g.useRef(null),[_,E]=g.useState(new Set),[z,T]=g.useState(new Set),[C,D]=g.useState(0),[L,R]=g.useState(!1),[Y,P]=g.useState(1),Q=((pe=A(x,"interaction-metadata"))==null?void 0:pe.payload)||{},$=((xe=A(x,"interaction-context"))==null?void 0:xe.payload)||{},O=((re=A(x,"interaction-summary"))==null?void 0:re.payload)||{};(ue=A(x,"interaction-scores"))!=null&&ue.payload;const M=((ie=A(x,"interaction-signals"))==null?void 0:ie.payload)||{},H=((ge=A(x,"interaction-guidance"))==null?void 0:ge.payload)||{},B=((fe=A(x,"interaction-transcript"))==null?void 0:fe.payload)||{},ve=((he=A(x,"interaction-nba"))==null?void 0:he.payload)||{},De=((((ye=A(x,"interaction-dimensions"))==null?void 0:ye.payload)||{}).dimensions||[]).filter(t=>t.value),ae=((me=A(x,"interaction-outcome-lift"))==null?void 0:me.payload)||{},U=g.useMemo(()=>{var a;const t={},c={outcome:{color:"var(--rail-outcome)"},process:{color:"var(--rail-discovery)"},compliance:{color:"var(--rail-compliance)"},customer_friction:{color:"var(--rail-coral)"},experience:{color:"var(--rail-teal)"}};for(const d of M.signals||[]){const h=c[d.group]||{};for(const m of d.observations||[])for(const j of m.evidence||[])if((a=j.turn_ids)!=null&&a.length)for(const W of j.turn_ids)t[W]||(t[W]=[]),t[W].some(Z=>Z.label===(m.key||d.display_name||d.key))||t[W].push({label:m.key||d.display_name||d.key,reason:m.reason||m.explanation||"",color:h.color||"var(--state-present)",signalKey:d.key})}return t},[M.signals]),q=((be=B.messages)==null?void 0:be.map((t,c)=>{var j,W;const a=t.start??t.start_ms?(t.start??t.start_ms)/1e3:0,d=t.end??t.end_ms?(t.end??t.end_ms)/1e3:a+1,h=t.actor==="agent",m=h?((j=B.actor_map)==null?void 0:j.agent)||"Agent":((W=B.actor_map)==null?void 0:W.customer)||"Customer";return{startTime:a,endTime:d,actor:m,actorColor:h?"var(--rail-outcome)":"var(--rail-discovery)"}}))||[],le=g.useMemo(()=>{if(!L&&C===0)return-1;const t=B.messages||[],c=C*1e3;for(let a=t.length-1;a>=0;a--){const d=t[a].start??t[a].start_ms;if(d!=null&&c>=d)return a}return-1},[C,L,B.messages]),X=t=>{u.current&&(u.current.currentTime=t,D(t))},N=()=>{if(u.current)if(L)u.current.pause(),R(!1);else{const t=u.current.play();t!==void 0&&t.catch(()=>{}),R(!0)}},ee=()=>{u.current&&(u.current.currentTime=Math.max(0,u.current.currentTime-15))},F=()=>{if(u.current){const t=Q.duration_seconds||u.current.duration||0;u.current.currentTime=Math.min(t,u.current.currentTime+15)}},ce=t=>{u.current&&(u.current.playbackRate=t,P(t))};g.useEffect(()=>{const t=u.current;if(!t)return;const c=()=>D(t.currentTime),a=()=>R(!0),d=()=>R(!1),h=()=>R(!1);return t.addEventListener("timeupdate",c),t.addEventListener("play",a),t.addEventListener("pause",d),t.addEventListener("ended",h),()=>{t.removeEventListener("timeupdate",c),t.removeEventListener("play",a),t.removeEventListener("pause",d),t.removeEventListener("ended",h)}},[i]);const te=(t,c)=>{const a=u.current;if(!a)return;const d=t/1e3;a.currentTime=d,D(d);const h=a.play();if(h!==void 0&&h.catch(()=>{}),k.current&&(a.removeEventListener("timeupdate",k.current),k.current=null),c!=null){const m=c/1e3,j=()=>{a.currentTime>=m&&(a.pause(),k.current&&(a.removeEventListener("timeupdate",k.current),k.current=null))};k.current=j,a.addEventListener("timeupdate",j)}},G=(t,c)=>{const d=(B.messages||[])[c],h=u.current;if(!d||!h)return;const m=d.start??d.start_ms,j=d.end??d.end_ms;if(L&&le===c){h.pause();return}m!=null&&te(m,j)},K=t=>{E(new Set(t));const c=document.getElementById("transcript-container");c&&c.scrollIntoView({behavior:"smooth",block:"nearest"}),setTimeout(()=>E(new Set),5e3)},je=t=>{T(c=>{const a=new Set(c);return a.has(t)?a.delete(t):a.add(t),a})},ne=((oe=$.call_purpose)==null?void 0:oe.interaction_driver)||O.one_liner||"Interaction Detail",V=async t=>{if(f){await f(t);return}},Se=async t=>{if(p){await p(t);return}},ke=async t=>{if(v){await v(t);return}},de=async t=>{if(b){await b(t);return}},Ce={project_id:"8f70f83a-bad9-41b6-8252-f7dbb111140f",session_id:"0f01a9c1-24f7-4ae2-af6e-c1813cf1868d",created_by:"3cb05056-24aa-422d-90e5-ac45a4fac785",status:"active",title:"Hello",agent_id:"62a1f398-961e-45b6-8be3-573c1cc47ec2",agent_name:"Mona Gorgan",id:"c0cb03d8-74bf-4487-9fd0-ea226e2b73a6",created_at:"2026-02-27T05:44:55.308000",updated_at:"2026-02-27T05:44:55.308000",messages:[{thread_id:"c0cb03d8-74bf-4487-9fd0-ea226e2b73a6",parent_message_id:null,author_id:"3cb05056-24aa-422d-90e5-ac45a4fac785",author_role:"supervisor",author_name:"Joel",content:"Hello",attachments:[],id:"903e6fed-91c0-462f-a0b4-f443e1557029",created_at:"2026-02-27T05:44:55.328000",updated_at:"2026-02-27T05:44:55.328000",is_edited:!1,replies:[]}],acknowledgements:[]},we=s&&Object.keys(s).length>0?s:Ce;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx(Ae,{title:ne,meta:Q,callPurpose:$.call_purpose,classification:$.classification,dimensions:De}),e.jsx(Me,{outcomeLift:ae}),(r||o||y)&&e.jsx(w.DetailCard,{title:"Coaching Summary",children:e.jsx(Le,{data:o,loading:r,error:y})}),e.jsx(Fe,{signals:M,expandedSignals:z,toggleSignal:je,playAudio:te,highlightTurns:K}),e.jsx(Pe,{guidance:H,playAudio:te,highlightTurns:K}),e.jsx($e,{nba:ve}),e.jsx(He,{audioUrl:i,timelineSegments:q,durationSeconds:Q.duration_seconds,currentTimeSeconds:C,timelinePlaying:L,playbackRate:Y,onSeek:X,onTogglePlay:N,onSeekBack:ee,onSeekForward:F,onSetPlaybackRate:ce,audioRef:u}),e.jsx(Oe,{transcript:B,audioUrl:i,highlightedTurns:_,activeTurnIndex:le,timelinePlaying:L,turnObservations:U,setExpandedSignals:T,onTurnPlayPause:G}),e.jsx(Qe,{sessionTitle:ne,messageThread:we,currentUser:l,onSendMessage:V,onEditMessage:Se,onDeleteMessage:ke,onCreateNewThread:de})]})}class Xe extends g.Component{constructor(i){super(i),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(i,o){console.error("InteractionDetailPanel render error:",i,o==null?void 0:o.componentStack)}render(){return this.state.hasError?this.props.fallback:this.props.children}}function et(n){return e.jsx(Xe,{fallback:e.jsx("div",{style:{padding:16,color:"var(--state-unknown)",fontSize:12},children:"Error rendering detail."}),children:e.jsx(Ue,{...n})})}function tt({pattern:n}){const[i,o]=g.useState(!1),s={name:"Customer Escalation Likelihood",description:"Based on observed patterns, this session shows indicators consistent with potential escalation.",technicalKey:"signal.escalation_likelihood",probability:.68,confidence:.81,observations:3};return n==="text-link"?e.jsxs("div",{style:{position:"relative",background:"rgba(255, 255, 255, 0.82)",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",overflow:"hidden",boxShadow:"0 2px 4px rgba(30, 33, 37, 0.06)"},children:[e.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"5px",background:"#6B7C93",opacity:.6}}),e.jsxs("div",{style:{padding:"14px 16px 14px 21px"},children:[e.jsx("div",{style:{marginBottom:"4px"},children:e.jsx("span",{style:{fontSize:"13px",fontWeight:680,color:"rgba(30, 33, 37, 0.92)",lineHeight:1.2},children:s.name})}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.65)",lineHeight:1.4,marginBottom:"6px"},children:s.description}),e.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.42)",fontFamily:"ui-monospace, monospace",marginBottom:"8px"},children:s.technicalKey}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",fontSize:"11.5px",marginBottom:"10px"},children:[e.jsx("span",{style:{color:"rgba(139, 157, 127, 0.65)"},children:"prob"}),e.jsx("strong",{style:{color:"rgba(139, 157, 127, 0.85)"},children:s.probability.toFixed(2)}),e.jsx("span",{style:{color:"rgba(30, 33, 37, 0.24)"},children:"·"}),e.jsx("span",{style:{color:"rgba(184, 156, 106, 0.65)"},children:"conf"}),e.jsx("strong",{style:{color:"rgba(184, 156, 106, 0.85)"},children:s.confidence.toFixed(2)}),e.jsx("span",{style:{color:"rgba(30, 33, 37, 0.24)"},children:"·"}),e.jsxs("span",{style:{color:"rgba(30, 33, 37, 0.52)"},children:[s.observations," observations"]})]}),!i&&e.jsx("button",{onClick:()=>o(!0),style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.56)",background:"none",border:"none",padding:0,cursor:"pointer",textDecoration:"underline",textDecorationColor:"rgba(30, 33, 37, 0.2)"},onMouseEnter:r=>{r.currentTarget.style.color="rgba(30, 33, 37, 0.78)",r.currentTarget.style.textDecorationColor="rgba(30, 33, 37, 0.4)"},onMouseLeave:r=>{r.currentTarget.style.color="rgba(30, 33, 37, 0.56)",r.currentTarget.style.textDecorationColor="rgba(30, 33, 37, 0.2)"},children:"View contributing observations"})]}),i&&e.jsxs("div",{style:{borderTop:"1px solid rgba(52, 58, 64, 0.08)",background:"rgba(244, 241, 230, 0.25)",padding:"16px 16px 16px 21px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:650,letterSpacing:"0.08em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.52)",marginBottom:"8px"},children:"Contributing Observations"}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.62)"},children:"[Observations would appear here]"}),e.jsx("button",{onClick:()=>o(!1),style:{marginTop:"10px",fontSize:"12px",color:"rgba(30, 33, 37, 0.56)",background:"none",border:"none",padding:0,cursor:"pointer",textDecoration:"underline",textDecorationColor:"rgba(30, 33, 37, 0.2)"},onMouseEnter:r=>{r.currentTarget.style.color="rgba(30, 33, 37, 0.78)",r.currentTarget.style.textDecorationColor="rgba(30, 33, 37, 0.4)"},onMouseLeave:r=>{r.currentTarget.style.color="rgba(30, 33, 37, 0.56)",r.currentTarget.style.textDecorationColor="rgba(30, 33, 37, 0.2)"},children:"Hide observations"})]})]}):n==="rotating-chevron"?e.jsxs("div",{style:{position:"relative",background:"rgba(255, 255, 255, 0.82)",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",overflow:"hidden",boxShadow:"0 2px 4px rgba(30, 33, 37, 0.06)"},children:[e.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"5px",background:"#6B7C93",opacity:.6}}),e.jsx("button",{type:"button",onClick:()=>o(!i),style:{width:"100%",padding:"14px 16px 14px 21px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",transition:"background 0.15s ease"},onMouseEnter:r=>{r.currentTarget.style.background="rgba(231, 212, 162, 0.08)"},onMouseLeave:r=>{r.currentTarget.style.background="transparent"},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"12px"},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{marginBottom:"4px"},children:e.jsx("span",{style:{fontSize:"13px",fontWeight:680,color:"rgba(30, 33, 37, 0.92)",lineHeight:1.2},children:s.name})}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.65)",lineHeight:1.4,marginBottom:"6px"},children:s.description}),e.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.42)",fontFamily:"ui-monospace, monospace",marginBottom:"8px"},children:s.technicalKey}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",fontSize:"11.5px"},children:[e.jsx("span",{style:{color:"rgba(139, 157, 127, 0.65)"},children:"prob"}),e.jsx("strong",{style:{color:"rgba(139, 157, 127, 0.85)"},children:s.probability.toFixed(2)}),e.jsx("span",{style:{color:"rgba(30, 33, 37, 0.24)"},children:"·"}),e.jsx("span",{style:{color:"rgba(184, 156, 106, 0.65)"},children:"conf"}),e.jsx("strong",{style:{color:"rgba(184, 156, 106, 0.85)"},children:s.confidence.toFixed(2)}),e.jsx("span",{style:{color:"rgba(30, 33, 37, 0.24)"},children:"·"}),e.jsxs("span",{style:{color:"rgba(30, 33, 37, 0.52)"},children:[s.observations," observations"]})]})]}),e.jsx("div",{style:{paddingTop:"2px",color:"rgba(30, 33, 37, 0.42)",flexShrink:0,transition:"transform 0.2s ease"},children:e.jsx(S.ChevronDown,{size:18,style:{transform:i?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})})]})}),i&&e.jsxs("div",{style:{borderTop:"1px solid rgba(52, 58, 64, 0.08)",background:"rgba(244, 241, 230, 0.25)",padding:"16px 16px 16px 21px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:650,letterSpacing:"0.08em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.52)",marginBottom:"8px"},children:"Contributing Observations"}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.62)"},children:"[Observations would appear here]"})]})]}):e.jsxs("div",{style:{position:"relative",background:"rgba(255, 255, 255, 0.82)",border:"1px solid rgba(52, 58, 64, 0.12)",borderRadius:"12px",overflow:"hidden",boxShadow:"0 2px 4px rgba(30, 33, 37, 0.06)"},children:[e.jsx("div",{style:{position:"absolute",left:0,top:0,bottom:0,width:"5px",background:"#6B7C93",opacity:.6}}),e.jsxs("button",{type:"button",onClick:()=>o(!i),style:{width:"100%",padding:"14px 16px 14px 21px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"flex-start",gap:"12px",transition:"background 0.15s ease"},onMouseEnter:r=>{r.currentTarget.style.background="rgba(231, 212, 162, 0.08)"},onMouseLeave:r=>{r.currentTarget.style.background="transparent"},children:[e.jsx("div",{style:{paddingTop:"2px",color:"rgba(30, 33, 37, 0.42)",flexShrink:0},children:i?e.jsx(S.ChevronDown,{size:16}):e.jsx(S.ChevronRight,{size:16})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{marginBottom:"4px"},children:e.jsx("span",{style:{fontSize:"13px",fontWeight:680,color:"rgba(30, 33, 37, 0.92)",lineHeight:1.2},children:s.name})}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.65)",lineHeight:1.4,marginBottom:"6px"},children:s.description}),e.jsx("div",{style:{fontSize:"11px",color:"rgba(30, 33, 37, 0.42)",fontFamily:"ui-monospace, monospace",marginBottom:"8px"},children:s.technicalKey}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",fontSize:"11.5px"},children:[e.jsx("span",{style:{color:"rgba(139, 157, 127, 0.65)"},children:"prob"}),e.jsx("strong",{style:{color:"rgba(139, 157, 127, 0.85)"},children:s.probability.toFixed(2)}),e.jsx("span",{style:{color:"rgba(30, 33, 37, 0.24)"},children:"·"}),e.jsx("span",{style:{color:"rgba(184, 156, 106, 0.65)"},children:"conf"}),e.jsx("strong",{style:{color:"rgba(184, 156, 106, 0.85)"},children:s.confidence.toFixed(2)}),e.jsx("span",{style:{color:"rgba(30, 33, 37, 0.24)"},children:"·"}),e.jsxs("span",{style:{color:"rgba(30, 33, 37, 0.52)"},children:[s.observations," observations"]})]})]})]}),i&&e.jsxs("div",{style:{borderTop:"1px solid rgba(52, 58, 64, 0.08)",background:"rgba(244, 241, 230, 0.25)",padding:"16px 16px 16px 21px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:650,letterSpacing:"0.08em",textTransform:"uppercase",color:"rgba(30, 33, 37, 0.52)",marginBottom:"8px"},children:"Contributing Observations"}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(30, 33, 37, 0.62)"},children:"[Observations would appear here]"})]})]})}exports.ConditionCard=w.ConditionCard;exports.ModelScoreCard=w.ModelScoreCard;exports.ObservationCard=w.ObservationCard;exports.ScoreDriverCard=w.ScoreDriverCard;exports.ScoreDriverCardVariant=w.ScoreDriverCardVariant;exports.SignalCard=w.SignalCard;exports.SmallObservationCard=w.SmallObservationCard;exports.SummarySection=w.SummarySection;exports.AgentLiftCard=Me;exports.CoachingSynthesisCard=Le;exports.EvidenceItem=_e;exports.ExpandPatternComparison=tt;exports.InteractionContext=Ae;exports.InteractionDetailPanel=et;exports.InteractionGuidance=Pe;exports.InteractionNBA=$e;exports.InteractionRecording=He;exports.InteractionScores=Ve;exports.InteractionSignals=Fe;exports.InteractionTranscript=Oe;
|
|
11
11
|
//# sourceMappingURL=interactionDetails.cjs.js.map
|