jinn-cli 0.4.0 → 0.5.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.
Files changed (70) hide show
  1. package/dist/src/engines/claude.d.ts +1 -0
  2. package/dist/src/engines/claude.d.ts.map +1 -1
  3. package/dist/src/engines/claude.js +58 -2
  4. package/dist/src/engines/claude.js.map +1 -1
  5. package/dist/src/gateway/api.d.ts.map +1 -1
  6. package/dist/src/gateway/api.js +16 -0
  7. package/dist/src/gateway/api.js.map +1 -1
  8. package/dist/src/gateway/server.d.ts.map +1 -1
  9. package/dist/src/gateway/server.js +38 -3
  10. package/dist/src/gateway/server.js.map +1 -1
  11. package/dist/src/mcp/gateway-server.js +1 -1
  12. package/dist/src/mcp/gateway-server.js.map +1 -1
  13. package/dist/src/sessions/context.d.ts.map +1 -1
  14. package/dist/src/sessions/context.js +228 -213
  15. package/dist/src/sessions/context.js.map +1 -1
  16. package/dist/src/sessions/queue.d.ts +1 -1
  17. package/dist/src/sessions/queue.d.ts.map +1 -1
  18. package/dist/src/sessions/queue.js +2 -0
  19. package/dist/src/sessions/queue.js.map +1 -1
  20. package/dist/src/sessions/registry.d.ts +7 -1
  21. package/dist/src/sessions/registry.d.ts.map +1 -1
  22. package/dist/src/sessions/registry.js +12 -2
  23. package/dist/src/sessions/registry.js.map +1 -1
  24. package/dist/src/shared/types.d.ts +6 -2
  25. package/dist/src/shared/types.d.ts.map +1 -1
  26. package/dist/web/404.html +1 -1
  27. package/dist/web/_next/static/chunks/282-4e9c26e9a600c58e.js +1 -0
  28. package/dist/web/_next/static/chunks/700-a7cbf54fe1fbf4bc.js +1 -0
  29. package/dist/web/_next/static/chunks/app/chat/{page-2f3c561ed768ed58.js → page-757fcd211d059cb7.js} +1 -1
  30. package/dist/web/_next/static/chunks/app/costs/{page-13a6f2c65a827f8a.js → page-7940c2fe7e3dace1.js} +1 -1
  31. package/dist/web/_next/static/chunks/app/cron/{page-0ee07a679c7b79aa.js → page-f81a986689712af7.js} +1 -1
  32. package/dist/web/_next/static/chunks/app/kanban/page-6ab8586b063ca3ac.js +1 -0
  33. package/dist/web/_next/static/chunks/app/layout-c24e2d25774ff71a.js +1 -0
  34. package/dist/web/_next/static/chunks/app/logs/{page-6de6b16523e85193.js → page-388b787cb847ca97.js} +1 -1
  35. package/dist/web/_next/static/chunks/app/org/{page-cd9d362e77f4799e.js → page-3d44d51e94edb85e.js} +1 -1
  36. package/dist/web/_next/static/chunks/app/{page-b98417ed4f4d45a0.js → page-7ac43789d477a51f.js} +1 -1
  37. package/dist/web/_next/static/chunks/app/sessions/{page-9f83fa32b654db3b.js → page-18757fcd067b7e9d.js} +1 -1
  38. package/dist/web/_next/static/chunks/app/settings/page-beb4dce244545649.js +1 -0
  39. package/dist/web/_next/static/chunks/app/skills/page-26b727333df9db45.js +1 -0
  40. package/dist/web/_next/static/css/bd612b1ca9b40306.css +1 -0
  41. package/dist/web/chat.html +1 -1
  42. package/dist/web/chat.txt +5 -5
  43. package/dist/web/costs.html +2 -2
  44. package/dist/web/costs.txt +5 -5
  45. package/dist/web/cron.html +1 -1
  46. package/dist/web/cron.txt +5 -5
  47. package/dist/web/index.html +1 -1
  48. package/dist/web/index.txt +5 -5
  49. package/dist/web/kanban.html +1 -1
  50. package/dist/web/kanban.txt +5 -5
  51. package/dist/web/logs.html +2 -2
  52. package/dist/web/logs.txt +5 -5
  53. package/dist/web/org.html +1 -1
  54. package/dist/web/org.txt +5 -5
  55. package/dist/web/sessions.html +1 -1
  56. package/dist/web/sessions.txt +5 -5
  57. package/dist/web/settings.html +1 -1
  58. package/dist/web/settings.txt +5 -5
  59. package/dist/web/skills.html +1 -1
  60. package/dist/web/skills.txt +5 -5
  61. package/package.json +1 -1
  62. package/dist/web/_next/static/chunks/704-ca24be493a922639.js +0 -1
  63. package/dist/web/_next/static/chunks/73-2d6e730cea0fe6c8.js +0 -1
  64. package/dist/web/_next/static/chunks/app/kanban/page-a7facadd4194faae.js +0 -1
  65. package/dist/web/_next/static/chunks/app/layout-fd975d16033dab25.js +0 -1
  66. package/dist/web/_next/static/chunks/app/settings/page-34c9276e2a012445.js +0 -1
  67. package/dist/web/_next/static/chunks/app/skills/page-18cf3b7bb9a7339c.js +0 -1
  68. package/dist/web/_next/static/css/24da9dfc818cea32.css +0 -1
  69. /package/dist/web/_next/static/{Tn0FXDHalXGkNoojna-vg → PdaYoul-532GSdcvOaz-m}/_buildManifest.js +0 -0
  70. /package/dist/web/_next/static/{Tn0FXDHalXGkNoojna-vg → PdaYoul-532GSdcvOaz-m}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[457],{3095:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>N});var n=r(8111),a=r(5271),i=r(4736),s=r(3176),o=r(4263),l=r(3073),d=r(2755);let c="jinn-sidebar-collapsed",u="jinn-pinned-sessions";function p(){try{let e=localStorage.getItem("jinn-read-sessions");return e?new Set(JSON.parse(e)):new Set}catch(e){return new Set}}function h(e){try{localStorage.setItem(u,JSON.stringify(Array.from(e)))}catch(e){}}function g(e){return"cron"===e.source||(e.sourceRef||"").startsWith("cron:")}function v(e,t){let r=(e,t)=>{let r=e.lastActivity||e.createdAt||"";return(t.lastActivity||t.createdAt||"").localeCompare(r)};return[...e.filter(e=>t.has(e.id)).sort(r),...e.filter(e=>!t.has(e.id)).sort(r)]}function x(e){var t;let{selectedId:r,onSelect:i,onNewChat:o,onDelete:l,refreshKey:x,connectionSeq:m,onSessionsLoaded:f,events:y}=e,{settings:b}=(0,d.t0)(),j=null!=(t=b.portalName)?t:"Jinn",k=j.toLowerCase(),[w,S]=(0,a.useState)([]),[C,I]=(0,a.useState)(!0),[R,L]=(0,a.useState)(""),[W,z]=(0,a.useState)(null),[D,T]=(0,a.useState)(null),[M,B]=(0,a.useState)(null),[E,A]=(0,a.useState)(null),[U,N]=(0,a.useState)(new Set),[F,H]=(0,a.useState)(new Set),[O,P]=(0,a.useState)(new Set),[V,q]=(0,a.useState)(new Map),J=(0,a.useRef)(null);(0,a.useEffect)(()=>{N(p()),H(function(){try{let e=localStorage.getItem(u);return e?new Set(JSON.parse(e)):new Set}catch(e){return new Set}}()),P(function(){try{let e=localStorage.getItem(c);return e?new Set(JSON.parse(e)):new Set}catch(e){return new Set}}()),s.F.getOrg().then(async e=>{let t=new Map;await Promise.all(e.employees.map(async e=>{try{let r=await s.F.getEmployee(e);r.emoji&&t.set(e,r.emoji)}catch(e){}})),q(t)}).catch(()=>{})},[]),(0,a.useEffect)(()=>{if(r){let e=p();e.add(r);let t=Array.from(e);t.length>500&&t.splice(0,t.length-500),localStorage.setItem("jinn-read-sessions",JSON.stringify(t)),N(e=>{let t=new Set(e);return t.add(r),t})}},[r]);let _=(0,a.useCallback)(()=>{s.F.getSessions().then(e=>{let t=e.filter(e=>"web"===e.source||"cron"===e.source||!e.source);t.sort((e,t)=>{let r=e.lastActivity||e.createdAt||"";return(t.lastActivity||t.createdAt||"").localeCompare(r)}),S(t),null==f||f(t)}).catch(()=>S([])).finally(()=>I(!1))},[f]);(0,a.useEffect)(()=>{I(!0),_()},[x,_]),(0,a.useEffect)(()=>{m&&_()},[m,_]),(0,a.useEffect)(()=>{if(!y||0===y.length)return;let e=y[y.length-1],t="".concat(e.event,":").concat(JSON.stringify(e.payload));t!==J.current&&(J.current=t,("session:started"===e.event||"session:completed"===e.event||"session:deleted"===e.event||"session:error"===e.event)&&_())},[y,_]);let K=(0,a.useCallback)(e=>{P(t=>{let r=new Set(t);r.has(e)?r.delete(e):r.add(e);try{localStorage.setItem(c,JSON.stringify(Array.from(r)))}catch(e){}return r})},[]),Y=(0,a.useCallback)(e=>{H(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),h(r),r})},[]);async function X(e){let t=e.sessions.map(e=>e.id);try{await s.F.bulkDeleteSessions(t),S(e=>e.filter(e=>!t.includes(e.id))),H(e=>{let r=new Set(e);for(let e of t)r.delete(e);return h(r),r}),r&&t.includes(r)&&o()}catch(e){}T(null)}async function G(e){try{await s.F.deleteSession(e),S(t=>t.filter(t=>t.id!==e)),H(t=>{if(!t.has(e))return t;let r=new Set(t);return r.delete(e),h(r),r}),l?l(e):r===e&&o()}catch(e){}z(null)}let $=function(e,t,r,n){let a=[],i=[],s=new Map;for(let t of e)if(g(t))i.push(t);else if(g(t)||t.employee&&t.employee!==r){let e=t.employee;s.has(e)||s.set(e,[]),s.get(e).push(t)}else a.push(t);let o=[];for(let e of(a.length>0&&o.push({key:"direct",label:"Direct",emoji:"\uD83D\uDCAC",sessions:v(a,n),sortOrder:0}),Array.from(s.keys()).sort())){let r=s.get(e);o.push({key:"emp:".concat(e),label:e,emoji:t.get(e)||"\uD83E\uDD16",sessions:v(r,n),sortOrder:1})}return i.length>0&&o.push({key:"cron",label:"Cron",emoji:"⏰",sessions:v(i,n),sortOrder:2}),o}(R.trim()?w.filter(e=>{let t=R.toLowerCase();return e.id.toLowerCase().includes(t)||e.employee&&e.employee.toLowerCase().includes(t)||e.title&&e.title.toLowerCase().includes(t)}):w,V,k,F);return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--sidebar-bg)",borderRight:"1px solid var(--separator)"},children:[(0,n.jsxs)("div",{style:{padding:"var(--space-4) var(--space-4) var(--space-3)",borderBottom:"1px solid var(--separator)",background:"var(--material-thick)",flexShrink:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"var(--space-3)"},children:[(0,n.jsx)("h2",{style:{fontSize:"var(--text-title3)",fontWeight:"var(--weight-bold)",letterSpacing:"-0.5px",color:"var(--text-primary)",margin:0},children:"Chats"}),(0,n.jsxs)("button",{onClick:o,"aria-label":"New chat",style:{padding:"var(--space-1) var(--space-3)",fontSize:"var(--text-footnote)",fontWeight:"var(--weight-semibold)",color:"var(--accent-contrast)",background:"var(--accent)",border:"none",borderRadius:"var(--radius-md)",cursor:"pointer",display:"flex",alignItems:"center",gap:"var(--space-1)"},children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,n.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New"]})]}),(0,n.jsxs)("div",{style:{background:"var(--fill-tertiary)",borderRadius:"var(--radius-md)",padding:"7px var(--space-3)",display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},"aria-hidden":"true",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),(0,n.jsx)("input",{type:"text",value:R,onChange:e=>L(e.target.value),placeholder:"Search sessions...","aria-label":"Search sessions",style:{flex:1,fontSize:"var(--text-footnote)",color:"var(--text-primary)",background:"transparent",border:"none",outline:"none",padding:0,margin:0,lineHeight:1.4}}),R.trim()&&(0,n.jsx)("button",{onClick:()=>L(""),"aria-label":"Clear search",style:{padding:2,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,background:"transparent",border:"none",cursor:"pointer",color:"var(--text-tertiary)"},children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),(0,n.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"var(--space-1) 0"},children:C?(0,n.jsx)("div",{style:{padding:"var(--space-8) var(--space-4)",textAlign:"center"},children:(0,n.jsx)("span",{style:{fontSize:"var(--text-caption1)",color:"var(--text-quaternary)"},children:"Loading sessions..."})}):0===$.length?(0,n.jsx)("div",{style:{padding:"var(--space-8) var(--space-4)",textAlign:"center"},children:(0,n.jsx)("span",{style:{fontSize:"var(--text-caption1)",color:"var(--text-quaternary)"},children:R.trim()?"No matching sessions":"No conversations yet"})}):$.map(e=>{let t=O.has(e.key);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{onMouseEnter:()=>A(e.key),onMouseLeave:()=>A(null),style:{display:"flex",alignItems:"center",marginTop:"var(--space-1)"},children:[(0,n.jsxs)("button",{onClick:()=>K(e.key),style:{flex:1,display:"flex",alignItems:"center",gap:"var(--space-2)",padding:"var(--space-2) var(--space-4)",paddingRight:"var(--space-1)",background:"transparent",border:"none",cursor:"pointer",textAlign:"left"},children:[(0,n.jsx)("span",{style:{fontSize:"var(--text-caption1)"},children:e.emoji}),(0,n.jsx)("span",{style:{fontSize:"var(--text-caption1)",fontWeight:"var(--weight-semibold)",color:"var(--text-secondary)",letterSpacing:"0.3px",textTransform:"uppercase",flex:1},children:e.label}),(0,n.jsx)("span",{style:{fontSize:"var(--text-caption2)",color:"var(--text-tertiary)",background:"var(--fill-tertiary)",borderRadius:"var(--radius-sm)",padding:"0 5px",lineHeight:"18px",minWidth:18,textAlign:"center"},children:e.sessions.length}),(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transition:"transform 150ms ease",transform:t?"rotate(-90deg)":"rotate(0deg)"},children:(0,n.jsx)("polyline",{points:"6 9 12 15 18 9"})})]}),E===e.key&&(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),T(e)},"aria-label":"Delete all sessions in ".concat(e.label),style:{padding:4,marginRight:"var(--space-3)",borderRadius:"var(--radius-sm)",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-tertiary)",display:"flex",alignItems:"center",flexShrink:0,transition:"color 150ms ease"},onMouseEnter:e=>e.currentTarget.style.color="var(--system-red)",onMouseLeave:e=>e.currentTarget.style.color="var(--text-tertiary)",children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]}),!t&&e.sessions.map(e=>{var t,a;let s,o=e.id===r,l=e.id===M,d="running"===e.status,c=U.has(e.id),u="error"===e.status,p=F.has(e.id),h=function(e){if(!e)return"";let t=new Date(e),r=Date.now()-t.getTime();return r<6e4?"now":r<36e5?"".concat(Math.floor(r/6e4),"m"):r<864e5?new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}):new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}(e.lastActivity||e.createdAt);return s=d?"var(--system-blue)":u?"var(--system-red)":c?"var(--text-quaternary)":"var(--system-green)",(0,n.jsxs)("button",{onClick:()=>i(e.id),onMouseEnter:()=>B(e.id),onMouseLeave:()=>B(null),style:{width:"100%",display:"flex",alignItems:"center",gap:"var(--space-3)",padding:"var(--space-3) var(--space-4)",paddingLeft:"calc(var(--space-4) + 8px)",background:o?"var(--fill-secondary)":"transparent",border:"none",cursor:"pointer",textAlign:"left",borderLeft:o?"2px solid var(--accent)":"2px solid transparent",position:"relative"},children:[(0,n.jsx)("div",{style:{width:8,height:8,borderRadius:"50%",background:s,flexShrink:0,animation:d?"sidebar-pulse 2s ease-in-out infinite":"none",boxShadow:d?"0 0 6px ".concat(s):"none"}}),(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:2},children:[(0,n.jsx)("span",{style:{fontSize:"var(--text-footnote)",fontWeight:c&&!o?"var(--weight-medium)":"var(--weight-semibold)",color:"var(--text-primary)",letterSpacing:"-0.2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:(t=e.title,a=e.employee,t?"Jinn"!==j&&t.startsWith("Jinn - ")?j+t.slice(4):t:a||j)}),(0,n.jsx)("span",{style:{fontSize:"var(--text-caption2)",color:"var(--text-tertiary)",flexShrink:0,marginLeft:"var(--space-1)"},children:h})]}),(0,n.jsx)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.employee||j})]}),p&&!l&&(0,n.jsx)("span",{style:{fontSize:11,flexShrink:0,opacity:.5},children:"\uD83D\uDCCC"}),l&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),Y(e.id)},"aria-label":p?"Unpin session":"Pin session",style:{padding:4,borderRadius:"var(--radius-sm)",background:"transparent",border:"none",cursor:"pointer",color:p?"var(--accent)":"var(--text-tertiary)",display:"flex",alignItems:"center",flexShrink:0,transition:"color 150ms ease"},onMouseEnter:e=>{p||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{p||(e.currentTarget.style.color="var(--text-tertiary)")},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:p?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 17v5"}),(0,n.jsx)("path",{d:"M9 2h6l-1 7h4l-2 4H8l-2-4h4L9 2z"})]})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),z(e.id)},"aria-label":"Delete session",style:{padding:4,borderRadius:"var(--radius-sm)",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-tertiary)",display:"flex",alignItems:"center",flexShrink:0,transition:"color 150ms ease"},onMouseEnter:e=>e.currentTarget.style.color="var(--system-red)",onMouseLeave:e=>e.currentTarget.style.color="var(--text-tertiary)",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]},e.id)})]},e.key)})}),W&&(0,n.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",zIndex:60,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>z(null),children:(0,n.jsxs)("div",{style:{background:"var(--bg)",borderRadius:"var(--radius-lg)",padding:"var(--space-6)",maxWidth:400,width:"90%",boxShadow:"var(--shadow-overlay)"},onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h3",{style:{fontSize:"var(--text-headline)",fontWeight:"var(--weight-bold)",color:"var(--text-primary)",marginBottom:"var(--space-2)"},children:"Delete Session?"}),(0,n.jsx)("p",{style:{fontSize:"var(--text-body)",color:"var(--text-secondary)",marginBottom:"var(--space-5)"},children:"This will permanently delete the session and all its messages."}),(0,n.jsxs)("div",{style:{display:"flex",gap:"var(--space-3)",justifyContent:"flex-end"},children:[(0,n.jsx)("button",{onClick:()=>z(null),style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--fill-tertiary)",color:"var(--text-primary)",border:"none",cursor:"pointer",fontSize:"var(--text-body)"},children:"Cancel"}),(0,n.jsx)("button",{onClick:()=>G(W),style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--system-red)",color:"#fff",border:"none",cursor:"pointer",fontSize:"var(--text-body)",fontWeight:"var(--weight-semibold)"},children:"Delete"})]})]})}),D&&(0,n.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",zIndex:60,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>T(null),children:(0,n.jsxs)("div",{style:{background:"var(--bg)",borderRadius:"var(--radius-lg)",padding:"var(--space-6)",maxWidth:400,width:"90%",boxShadow:"var(--shadow-overlay)"},onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h3",{style:{fontSize:"var(--text-headline)",fontWeight:"var(--weight-bold)",color:"var(--text-primary)",marginBottom:"var(--space-2)"},children:"Delete Group?"}),(0,n.jsxs)("p",{style:{fontSize:"var(--text-body)",color:"var(--text-secondary)",marginBottom:"var(--space-5)"},children:["Delete all ",D.sessions.length," chats in “",D.label,"”? This cannot be undone."]}),(0,n.jsxs)("div",{style:{display:"flex",gap:"var(--space-3)",justifyContent:"flex-end"},children:[(0,n.jsx)("button",{onClick:()=>T(null),style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--fill-tertiary)",color:"var(--text-primary)",border:"none",cursor:"pointer",fontSize:"var(--text-body)"},children:"Cancel"}),(0,n.jsxs)("button",{onClick:()=>X(D),style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--system-red)",color:"#fff",border:"none",cursor:"pointer",fontSize:"var(--text-body)",fontWeight:"var(--weight-semibold)"},children:["Delete ",D.sessions.length," Chats"]})]})]})}),(0,n.jsx)("style",{children:"\n @keyframes sidebar-pulse {\n 0%, 100% { opacity: 1; transform: scale(1); }\n 50% { opacity: 0.5; transform: scale(0.85); }\n }\n "})]})}let m="jinn-intermediate-";function f(e){try{localStorage.removeItem("".concat(m).concat(e))}catch(e){}}function y(e){let{name:t,size:r,mimeType:a,url:i,isUser:s}=e;return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-lg)",background:s?"var(--accent)":"var(--material-thin)",border:s?"none":"1px solid var(--separator)",maxWidth:280,minWidth:180},children:[(0,n.jsx)("div",{style:{width:36,height:36,borderRadius:"var(--radius-sm)",background:s?"rgba(0,0,0,0.15)":"var(--fill-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:s?"#000":"var(--text-secondary)"},children:function(e,t){var r;let a=(null==t||null==(r=t.split(".").pop())?void 0:r.toLowerCase())||"",i="application/pdf"===e||"pdf"===a,s=["doc","docx"].includes(a)||(null==e?void 0:e.includes("wordprocessingml")),o=["txt","csv","json","md"].includes(a)||(null==e?void 0:e.startsWith("text/")),l=["zip","tar","gz","rar","7z"].includes(a);return i?(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,n.jsx)("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}):s?(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,n.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),(0,n.jsx)("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),(0,n.jsx)("polyline",{points:"10 9 9 9 8 9"})]}):o?(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("polyline",{points:"14 2 14 8 20 8"})]}):l?(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 8v13H3V8"}),(0,n.jsx)("path",{d:"M1 3h22v5H1z"}),(0,n.jsx)("path",{d:"M10 12h4"})]}):(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,n.jsx)("polyline",{points:"13 2 13 9 20 9"})]})}(a,t)}),(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)("div",{style:{fontSize:"var(--text-footnote)",fontWeight:"var(--weight-medium)",color:s?"#000":"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t}),null!=r&&(0,n.jsx)("div",{style:{fontSize:"var(--text-caption2)",color:s?"rgba(0,0,0,0.5)":"var(--text-tertiary)",marginTop:1},children:r<1024?"".concat(r," B"):r<1048576?"".concat((r/1024).toFixed(0)," KB"):"".concat((r/1048576).toFixed(1)," MB")})]}),(0,n.jsx)("a",{href:i,download:t,"aria-label":"Download ".concat(t),style:{width:28,height:28,borderRadius:"50%",background:s?"rgba(0,0,0,0.15)":"var(--fill-secondary)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:s?"#000":"var(--text-secondary)",textDecoration:"none"},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,n.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})]})}function b(e){let{src:t,duration:r,waveform:i,isUser:s}=e,o=(0,a.useRef)(null),[l,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(0),[p,h]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=new Audio(t);return o.current=e,e.addEventListener("timeupdate",()=>{e.duration&&isFinite(e.duration)&&(u(e.currentTime/e.duration),h(e.currentTime))}),e.addEventListener("ended",()=>{d(!1),u(0),h(0)}),e.addEventListener("pause",()=>d(!1)),e.addEventListener("play",()=>d(!0)),()=>{e.pause(),e.src=""}},[t]);let g=(0,a.useCallback)(()=>{let e=o.current;e&&(l?e.pause():e.play().catch(()=>{}))},[l]),v=i.length>0?i:Array(50).fill(.1),x=l?p:r;return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-lg)",background:s?"var(--accent)":"var(--material-thin)",border:s?"none":"1px solid var(--separator)",maxWidth:280,minWidth:200},children:[(0,n.jsx)("button",{onClick:g,"aria-label":l?"Pause":"Play",style:{width:28,height:28,borderRadius:"50%",background:s?"rgba(0,0,0,0.2)":"var(--fill-secondary)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:s?"#000":"var(--text-primary)"},children:l?(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),(0,n.jsx)("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]}):(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("polygon",{points:"6,4 20,12 6,20"})})}),(0,n.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",gap:2,height:28},children:v.map((e,t)=>{let r=t/v.length<=c;return(0,n.jsx)("div",{style:{width:3,borderRadius:1.5,height:"".concat(Math.max(4,24*e),"px"),background:s?r?"rgba(0,0,0,0.7)":"rgba(0,0,0,0.25)":r?"var(--accent)":"var(--fill-primary)",transition:"background 100ms ease",flexShrink:0}},t)})}),(0,n.jsx)("span",{style:{fontSize:"var(--text-caption2)",color:s?"rgba(0,0,0,0.6)":"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",flexShrink:0,minWidth:28,textAlign:"right"},children:function(e){let t=Math.floor(e/60),r=Math.floor(e%60);return"".concat(t,":").concat(r.toString().padStart(2,"0"))}(x)})]})}function j(e){let{msgs:t,isActive:r}=e,[i,s]=(0,a.useState)(!1),o=t.every(e=>e.content.startsWith("Used ")),l=r&&!o?"".concat(t.length," tool").concat(1!==t.length?"s":""," running…"):"".concat(t.length," tool").concat(1!==t.length?"s":""," used");return(0,n.jsxs)("div",{style:{padding:"0 var(--space-4)",marginBottom:"var(--space-1)"},children:[(0,n.jsxs)("button",{onClick:()=>s(e=>!e),style:{display:"flex",alignItems:"center",gap:"var(--space-2)",padding:"5px var(--space-3)",borderRadius:"var(--radius-full, 999px)",background:"var(--fill-secondary)",border:"1px solid var(--separator)",fontSize:"var(--text-caption1)",color:"var(--text-secondary)",cursor:"pointer",transition:"background 150ms ease"},onMouseEnter:e=>e.currentTarget.style.background="var(--fill-tertiary)",onMouseLeave:e=>e.currentTarget.style.background="var(--fill-secondary)",children:[(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.6},children:(0,n.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),l,r&&!o&&(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--system-blue)",animation:"jinn-pulse 1.4s infinite"}}),(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:i?"rotate(180deg)":"rotate(0deg)",transition:"transform 150ms ease",opacity:.5},children:(0,n.jsx)("polyline",{points:"6 9 12 15 18 9"})})]}),i&&(0,n.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--space-1)",marginTop:"var(--space-1)",paddingLeft:"var(--space-1)"},children:t.map(e=>(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:"var(--radius-full, 999px)",background:"var(--fill-tertiary)",border:"1px solid var(--separator)",fontSize:"var(--text-caption2)",color:"var(--text-tertiary)"},children:e.toolCall},e.id))})]})}function k(e){let t,r=[],a=/(https?:\/\/[^\s<]+[^\s<.,;:!?)}\]'"])|(\*\*(.+?)\*\*)|(`([^`]+)`)|\*([^*]+)\*/g,i=0;for(;null!==(t=a.exec(e));)t.index>i&&r.push(e.slice(i,t.index)),t[1]?r.push((0,n.jsx)("a",{href:t[1],target:"_blank",rel:"noopener noreferrer",style:{color:"var(--system-blue)",textDecoration:"underline",textUnderlineOffset:2},children:t[1]},t.index)):t[2]?r.push((0,n.jsx)("strong",{style:{fontWeight:"var(--weight-bold)"},children:t[3]},t.index)):t[4]?r.push((0,n.jsx)("code",{style:{background:"var(--fill-secondary)",border:"1px solid var(--separator)",borderRadius:5,padding:"1px 5px",fontSize:"0.88em",fontFamily:'"SF Mono", Menlo, monospace',color:"var(--accent)"},children:t[5]},t.index)):t[6]&&r.push((0,n.jsx)("em",{style:{fontStyle:"italic",opacity:.85},children:t[6]},t.index)),i=t.index+t[0].length;return i<e.length&&r.push(e.slice(i)),1===r.length?r[0]:(0,n.jsx)(n.Fragment,{children:r})}function w(e){let{code:t,keyProp:r}=e,[i,s]=(0,a.useState)(!1);return(0,n.jsxs)("div",{style:{position:"relative",margin:"8px 0"},children:[(0,n.jsx)("button",{onClick:function(){navigator.clipboard.writeText(t).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})},"aria-label":"Copy code",style:{position:"absolute",top:8,right:8,padding:"2px 8px",fontSize:11,borderRadius:"var(--radius-sm)",background:"var(--fill-secondary)",color:"var(--text-secondary)",border:"1px solid var(--separator)",cursor:"pointer"},children:i?"Copied!":"Copy"}),(0,n.jsx)("pre",{className:"code-block",style:{background:"var(--fill-tertiary)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",padding:"var(--space-3) var(--space-4)",overflowX:"auto",fontSize:13,lineHeight:1.5,fontFamily:'"SF Mono", Menlo, monospace',color:"var(--text-primary)"},children:(0,n.jsx)("code",{children:t})})]},r)}function S(e){return/^\|[\s:|-]+\|$/.test(e.trim())}function C(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>e.trim())}function I(e){let{headerLine:t,rows:r,keyProp:a}=e,i=C(t),s=r.map(C);return(0,n.jsx)("div",{style:{margin:"10px 0",borderRadius:10,border:"1px solid var(--separator)",overflow:"hidden"},children:(0,n.jsx)("div",{style:{overflowX:"auto",WebkitOverflowScrolling:"touch"},children:(0,n.jsxs)("table",{style:{borderCollapse:"collapse",fontSize:"var(--text-footnote)",lineHeight:1.6,width:"100%",minWidth:"max-content"},children:[(0,n.jsx)("thead",{children:(0,n.jsx)("tr",{style:{background:"var(--fill-tertiary)"},children:i.map((e,t)=>(0,n.jsx)("th",{style:{textAlign:"left",padding:"10px 16px",fontWeight:600,color:"var(--text-primary)",borderBottom:"1px solid var(--separator)",maxWidth:280,wordBreak:"break-word"},children:k(e)},t))})}),(0,n.jsx)("tbody",{children:s.map((e,t)=>(0,n.jsx)("tr",{style:{background:t%2==1?"var(--fill-quaternary, transparent)":"transparent"},children:e.map((e,r)=>(0,n.jsx)("td",{style:{padding:"10px 16px",borderBottom:t<s.length-1?"1px solid var(--separator)":"none",color:"var(--text-primary)",maxWidth:280,wordBreak:"break-word"},children:k(e)},r))},t))})]})})},a)}function R(e){if(!e)return null;let t=e.split("\n"),r=[],a=!1,i=[];for(let e=0;e<t.length;e++){let o=t[e];if(o.startsWith("```")){a?(a=!1,r.push((0,n.jsx)(w,{keyProp:e,code:i.join("\n")},e))):a=!0,i=[];continue}if(a){i.push(o);continue}if(o.trim().startsWith("|")&&o.trim().endsWith("|")&&e+1<t.length&&S(t[e+1])){e++;let a=[];for(;e+1<t.length&&t[e+1].trim().startsWith("|")&&t[e+1].trim().endsWith("|")&&!S(t[e+1]);)e++,a.push(t[e]);r.push((0,n.jsx)(I,{keyProp:e,headerLine:o,rows:a},"table-".concat(e)));continue}if(""===o.trim()){r.push((0,n.jsx)("div",{style:{height:6}},"space-".concat(e)));continue}if(o.match(/^[-*] /)){r.push((0,n.jsxs)("div",{style:{display:"flex",gap:"var(--space-2)",marginBottom:2},children:[(0,n.jsx)("span",{style:{color:"var(--accent)",flexShrink:0,marginTop:1},children:"•"}),(0,n.jsx)("span",{children:k(o.slice(2))})]},e));continue}if(o.match(/^\d+\. /)){var s;let t=null==(s=o.match(/^(\d+)\. /))?void 0:s[1];r.push((0,n.jsxs)("div",{style:{display:"flex",gap:"var(--space-2)",marginBottom:2},children:[(0,n.jsxs)("span",{style:{color:"var(--accent)",flexShrink:0,fontWeight:"var(--weight-semibold)",minWidth:16},children:[t,"."]}),(0,n.jsx)("span",{children:k(o.replace(/^\d+\. /,""))})]},e));continue}if(o.startsWith("### ")){r.push((0,n.jsx)("div",{style:{fontWeight:"var(--weight-semibold)",fontSize:"var(--text-footnote)",marginTop:"var(--space-2)",marginBottom:2},children:k(o.slice(4))},e));continue}if(o.startsWith("## ")){r.push((0,n.jsx)("div",{style:{fontWeight:"var(--weight-bold)",fontSize:"var(--text-subheadline)",marginTop:"var(--space-3)",marginBottom:3},children:k(o.slice(3))},e));continue}if(o.startsWith("# ")){r.push((0,n.jsx)("div",{style:{fontWeight:"var(--weight-bold)",fontSize:"var(--text-body)",marginTop:"var(--space-3)",marginBottom:"var(--space-1)"},children:k(o.slice(2))},e));continue}r.push((0,n.jsx)("div",{style:{marginBottom:1},children:k(o)},e))}return a&&i.length>0&&r.push((0,n.jsx)(w,{keyProp:999,code:i.join("\n")},"trailing-code")),(0,n.jsx)(n.Fragment,{children:r})}function L(e){let t=new Date,r=new Date(e),n=t.toDateString()===r.toDateString(),a=new Date(t);a.setDate(a.getDate()-1);let i=a.toDateString()===r.toDateString(),s=r.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return n?"Today ".concat(s):i?"Yesterday ".concat(s):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})+" ".concat(s)}function W(e,t){return 0===t||e[t].timestamp-e[t-1].timestamp>3e5}function z(e,t){let r=e.filter(e=>"image"===e.type),a=e.filter(e=>"audio"===e.type),i=e.filter(e=>"file"===e.type);return(0,n.jsxs)(n.Fragment,{children:[r.map((e,t)=>(0,n.jsx)("div",{style:{marginTop:"var(--space-2)",borderRadius:"var(--radius-lg)",overflow:"hidden",maxWidth:280},children:(0,n.jsx)("img",{src:e.url,alt:e.name||"Image",style:{width:"100%",display:"block",borderRadius:"var(--radius-lg)",cursor:"pointer"},onClick:()=>window.open(e.url,"_blank")})},"img-".concat(t))),a.map((e,r)=>(0,n.jsx)("div",{style:{marginTop:"var(--space-2)"},children:(0,n.jsx)(b,{src:e.url,duration:e.duration||0,waveform:e.waveform||[],isUser:t})},"audio-".concat(r))),i.map((e,r)=>(0,n.jsx)("div",{style:{marginTop:"var(--space-2)"},children:(0,n.jsx)(y,{name:e.name||"File",size:e.size,mimeType:e.mimeType,url:e.url,isUser:t})},"file-".concat(r)))]})}function D(e){var t,r;let{messages:i,loading:s,streamingText:o}=e,l=(0,a.useRef)(null),d=(0,a.useRef)(0);return((0,a.useEffect)(()=>{var e;let t=0===d.current&&i.length>0;null==(e=l.current)||e.scrollIntoView({behavior:t?"instant":"smooth"}),d.current=i.length},[i,s]),0!==i.length||s)?(0,n.jsxs)("div",{className:"chat-messages-scroll",style:{flex:1,overflowY:"auto",overflowX:"hidden",padding:"var(--space-3) 0 var(--space-6) 0",background:"var(--bg)",minHeight:0},children:[(function(e){let t=[],r=0;for(;r<e.length;)if("assistant"===e[r].role&&e[r].toolCall){let n=[],a=r;for(;r<e.length&&"assistant"===e[r].role&&e[r].toolCall;)n.push(e[r]),r++;t.push({kind:"tool-group",msgs:n,startIndex:a})}else t.push({kind:"message",msg:e[r],index:r}),r++;return t})(i).map(e=>{if("tool-group"===e.kind){let t=e.msgs[0],r=W(i,e.startIndex),a=e.startIndex>0?i[e.startIndex-1]:null,o=s&&e.startIndex+e.msgs.length===i.length;return(0,n.jsxs)("div",{children:[r&&(0,n.jsx)("div",{style:{textAlign:"center",padding:"var(--space-3) 0",fontSize:"var(--text-caption2)",color:"var(--text-tertiary)"},children:L(t.timestamp)}),!r&&a&&(0,n.jsx)("div",{style:{height:"assistant"!==a.role?"var(--space-4)":"var(--space-1)"}}),(0,n.jsx)(j,{msgs:e.msgs,isActive:o})]},"tg-".concat(e.startIndex))}let{msg:t,index:r}=e,a="user"===t.role,o=W(i,r),l=t.media||function(e){let t,r=[],n=/!\[([^\]]*)\]\((https?:\/\/[^)]+\.(jpg|jpeg|png|gif|webp|svg)(\?[^)]*)?)\)/gi;for(;null!==(t=n.exec(e));)r.push({type:"image",url:t[2],name:t[1]||"Image"});let a=RegExp("(?<!\\]\\()https?:\\/\\/\\S+\\.(jpg|jpeg|png|gif|webp)(\\?\\S*)?\\b","gi");for(;null!==(t=a.exec(e));){let e=t[0];r.find(t=>t.url===e)||r.push({type:"image",url:e})}let i=/https?:\/\/\S+\.(mp3|wav|ogg|m4a|aac)(\?\S*)?\b/gi;for(;null!==(t=i.exec(e));)r.push({type:"audio",url:t[0],name:t[0].split("/").pop()});return r}(t.content),d=t.content;return l.length>0&&!t.media&&(l.forEach(e=>{d=(d=d.replace(e.url,"")).replace(/!\[[^\]]*\]\([^)]+\)/g,"")}),d=d.trim()),t.media&&t.media.length>0&&d.startsWith("[")&&d.endsWith("]")&&(d=""),(0,n.jsxs)("div",{children:[o&&(0,n.jsx)("div",{style:{textAlign:"center",padding:"var(--space-3) 0",fontSize:"var(--text-caption2)",color:"var(--text-tertiary)"},children:L(t.timestamp)}),!o&&r>0&&(0,n.jsx)("div",{style:{height:i[r-1].role!==t.role?"var(--space-4)":"var(--space-1)"}}),a&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",padding:"0 var(--space-4)",marginBottom:"var(--space-1)"},children:[d&&(0,n.jsx)("div",{className:"user-msg-bubble",style:{padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg)",background:"var(--accent)",color:"var(--accent-contrast)",fontSize:"var(--text-subheadline)",lineHeight:"var(--leading-relaxed)",fontWeight:"var(--weight-medium)",boxShadow:"var(--shadow-subtle)"},children:R(d)}),l.length>0&&(0,n.jsx)("div",{className:"user-msg-bubble",children:z(l,!0)})]}),!a&&(0,n.jsx)("div",{className:"assistant-msg-row",style:{display:"flex",justifyContent:"flex-start",padding:"0 var(--space-4)",marginBottom:"var(--space-1)"},children:(0,n.jsxs)("div",{className:"assistant-msg-bubble",style:{display:"flex",flexDirection:"column"},children:[d&&(0,n.jsx)("div",{style:{padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-sm) var(--radius-lg) var(--radius-lg) var(--radius-lg)",background:"var(--material-thin)",border:"1px solid var(--separator)",color:"var(--text-primary)",fontSize:"var(--text-subheadline)",lineHeight:"var(--leading-relaxed)"},children:R(d)}),l.length>0&&z(l,!1)]})})]},t.id||r)}),o&&(0,n.jsx)("div",{style:{display:"flex",justifyContent:"flex-start",padding:"0 var(--space-4)",marginBottom:"var(--space-1)"},className:"assistant-msg-row",children:(0,n.jsx)("div",{className:"assistant-msg-bubble",style:{display:"flex",flexDirection:"column"},children:(0,n.jsx)("div",{style:{padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-sm) var(--radius-lg) var(--radius-lg) var(--radius-lg)",background:"var(--material-thin)",border:"1px solid var(--separator)",color:"var(--text-primary)",fontSize:"var(--text-subheadline)",lineHeight:"var(--leading-relaxed)"},children:R(function(e){let t=e,r=(t.match(/```/g)||[]).length;if(r%2!=0&&(t+="\n```"),r%2==0){let e=t.replace(/```[\s\S]*?```/g,"");(e.match(/`/g)||[]).length%2!=0&&(t+="`"),(e.match(/\*\*/g)||[]).length%2!=0&&(t+="**")}return t}(o))})})}),s&&!o&&i.length>0&&((null==(t=i[i.length-1])?void 0:t.role)==="user"||(null==(r=i[i.length-1])?void 0:r.toolCall))&&(0,n.jsx)("div",{style:{display:"flex",justifyContent:"flex-start",padding:"0 var(--space-4)",marginTop:"var(--space-2)"},children:(0,n.jsx)("div",{style:{padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-sm) var(--radius-lg) var(--radius-lg) var(--radius-lg)",background:"var(--material-thin)",border:"1px solid var(--separator)"},children:(0,n.jsxs)("div",{style:{display:"flex",gap:4,alignItems:"center",height:16},children:[(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--text-quaternary)",animation:"jinn-pulse 1.4s infinite",animationDelay:"0ms"}}),(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--text-quaternary)",animation:"jinn-pulse 1.4s infinite",animationDelay:"200ms"}}),(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--text-quaternary)",animation:"jinn-pulse 1.4s infinite",animationDelay:"400ms"}})]})})}),(0,n.jsx)("div",{ref:l}),(0,n.jsx)("style",{children:"\n @keyframes jinn-pulse {\n 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }\n 40% { opacity: 1; transform: scale(1); }\n }\n .assistant-msg-bubble { max-width: 100%; overflow-wrap: break-word; word-break: break-word; }\n .user-msg-bubble { max-width: 90%; overflow-wrap: break-word; word-break: break-word; }\n .assistant-msg-row { padding: 0 var(--space-2) !important; }\n @media (min-width: 1024px) {\n .assistant-msg-bubble { max-width: 75%; }\n .user-msg-bubble { max-width: 75%; }\n .assistant-msg-row { padding: 0 var(--space-4) !important; }\n }\n /* User message contrast fixes — ensure all child elements are visible on accent background */\n .user-msg-bubble code {\n background: rgba(255,255,255,0.2) !important;\n border-color: rgba(255,255,255,0.3) !important;\n color: inherit !important;\n }\n .user-msg-bubble .code-block,\n .user-msg-bubble pre {\n background: rgba(0,0,0,0.2) !important;\n border-color: rgba(255,255,255,0.15) !important;\n color: rgba(255,255,255,0.95) !important;\n }\n .user-msg-bubble a {\n color: inherit !important;\n text-decoration-color: rgba(255,255,255,0.6) !important;\n }\n .user-msg-bubble strong { color: inherit !important; }\n .user-msg-bubble em { color: inherit !important; opacity: 0.9; }\n .user-msg-bubble span { color: inherit !important; }\n .user-msg-bubble div { color: inherit !important; }\n .user-msg-bubble th, .user-msg-bubble td { color: inherit !important; }\n .user-msg-bubble table { border-color: rgba(255,255,255,0.2) !important; }\n .user-msg-bubble th { border-color: rgba(255,255,255,0.2) !important; }\n .user-msg-bubble td { border-color: rgba(255,255,255,0.15) !important; }\n .user-msg-bubble tr { background: transparent !important; }\n .user-msg-bubble thead tr { background: rgba(255,255,255,0.1) !important; }\n /* Selection visibility for user messages */\n .user-msg-bubble ::selection {\n background: rgba(255,255,255,0.35);\n color: inherit;\n }\n .user-msg-bubble ::-moz-selection {\n background: rgba(255,255,255,0.35);\n color: inherit;\n }\n "})]}):(0,n.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,n.jsxs)("div",{style:{textAlign:"center"},children:[(0,n.jsx)("div",{style:{fontSize:"var(--text-title3)",fontWeight:"var(--weight-semibold)",color:"var(--text-tertiary)"},children:"Start a conversation"}),(0,n.jsx)("div",{style:{fontSize:"var(--text-footnote)",color:"var(--text-quaternary)",marginTop:"var(--space-2)"},children:"Send a message or use /new to begin"})]})})}function T(e){let{attachments:t,onRemove:r}=e;return 0===t.length?null:(0,n.jsx)("div",{style:{display:"flex",gap:"var(--space-2)",padding:"var(--space-2) var(--space-3)",overflowX:"auto",overflowY:"hidden"},children:t.map((e,t)=>{var a,i;return(0,n.jsxs)("div",{style:{position:"relative",width:56,height:56,flexShrink:0,borderRadius:"var(--radius-sm)",overflow:"hidden",background:"var(--fill-tertiary)",border:"1px solid var(--separator)"},children:["image"===e.type?(0,n.jsx)("img",{src:e.url,alt:e.name||"Preview",style:{width:"100%",height:"100%",objectFit:"cover"}}):(0,n.jsxs)("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,padding:4},children:["audio"===e.type?(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("circle",{cx:"18",cy:"16",r:"3"})]}):(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,n.jsx)("polyline",{points:"13 2 13 9 20 9"})]}),(0,n.jsx)("span",{style:{fontSize:8,color:"var(--text-quaternary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%",textAlign:"center"},children:(null==(i=e.name)||null==(a=i.split(".").pop())?void 0:a.toUpperCase())||e.type.toUpperCase()})]}),(0,n.jsx)("button",{onClick:()=>r(t),"aria-label":"Remove attachment",style:{position:"absolute",top:2,right:2,width:18,height:18,borderRadius:"50%",background:"rgba(0,0,0,0.6)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:11,lineHeight:1,padding:0},children:(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},t)})})}function M(e){let{open:t,progress:r,onDownload:a,onCancel:i}=e;if(!t)return null;let s=null!==r;return(0,n.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",zIndex:60,display:"flex",alignItems:"center",justifyContent:"center"},onClick:s?void 0:i,children:(0,n.jsxs)("div",{style:{background:"var(--bg)",borderRadius:"var(--radius-lg)",padding:"var(--space-6)",maxWidth:400,width:"90%",boxShadow:"var(--shadow-overlay)"},onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("div",{style:{width:48,height:48,borderRadius:"var(--radius-md)",background:"var(--fill-secondary)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"var(--space-4)"},children:(0,n.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),(0,n.jsx)("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),(0,n.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),(0,n.jsx)("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}),(0,n.jsx)("h3",{style:{fontSize:"var(--text-headline)",fontWeight:"var(--weight-bold)",color:"var(--text-primary)",marginBottom:"var(--space-2)"},children:"Enable voice input?"}),(0,n.jsx)("p",{style:{fontSize:"var(--text-body)",color:"var(--text-secondary)",marginBottom:"var(--space-5)",lineHeight:"var(--leading-relaxed)"},children:"This will download a speech recognition model (~500MB). Transcription runs locally on your server — no data leaves your network."}),s&&(0,n.jsxs)("div",{style:{marginBottom:"var(--space-5)"},children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"var(--space-2)",fontSize:"var(--text-footnote)",color:"var(--text-tertiary)"},children:[(0,n.jsx)("span",{children:"Downloading model…"}),(0,n.jsxs)("span",{children:[r,"%"]})]}),(0,n.jsx)("div",{style:{height:6,borderRadius:3,background:"var(--fill-tertiary)",overflow:"hidden"},children:(0,n.jsx)("div",{style:{height:"100%",width:"".concat(r,"%"),borderRadius:3,background:"var(--accent)",transition:"width 300ms ease"}})})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:"var(--space-3)",justifyContent:"flex-end"},children:[!s&&(0,n.jsx)("button",{onClick:i,style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--fill-tertiary)",color:"var(--text-primary)",border:"none",cursor:"pointer",fontSize:"var(--text-body)"},children:"Cancel"}),(0,n.jsx)("button",{onClick:a,disabled:s,style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:s?"var(--fill-tertiary)":"var(--accent)",color:s?"var(--text-tertiary)":"#000",border:"none",cursor:s?"default":"pointer",fontSize:"var(--text-body)",fontWeight:"var(--weight-semibold)"},children:s?"Downloading…":"Download"})]})]})})}function B(e){let{analyser:t,width:r=64,height:i=32,color:s="var(--system-red)"}=e,o=(0,a.useRef)(null),l=(0,a.useRef)(0);return(0,a.useEffect)(()=>{let e=o.current;if(!e||!t)return;let n=e.getContext("2d");if(!n)return;let a=t.frequencyBinCount,d=new Uint8Array(a),c=(r-22)/12;return!function e(){l.current=requestAnimationFrame(e),t.getByteFrequencyData(d),n.clearRect(0,0,r,i);for(let e=0;e<12;e++){let t=Math.max(3,d[Math.floor(e/12*(.6*a))]/255*i),r=e*(c+2),o=(i-t)/2;n.fillStyle=s,n.beginPath(),n.roundRect(r,o,c,t,1.5),n.fill()}}(),()=>{cancelAnimationFrame(l.current)}},[t,r,i,s]),(0,n.jsx)("canvas",{ref:o,width:r,height:i,style:{width:r,height:i,display:"block"}})}let E=[{name:"new",description:"Start a new chat session"},{name:"status",description:"Show current session info"}];async function A(e){let t,r=e.type.startsWith("image/"),n=e.type.startsWith("audio/");if(r)t=await new Promise((t,r)=>{let n=new Image,a=URL.createObjectURL(e);n.onload=()=>{URL.revokeObjectURL(a);let{width:i,height:s}=n;if(i>1200||s>1200){let e=1200/Math.max(i,s);i=Math.round(i*e),s=Math.round(s*e)}let o=document.createElement("canvas");o.width=i,o.height=s;let l=o.getContext("2d");if(!l)return void r(Error("no canvas context"));l.drawImage(n,0,0,i,s);let d=e.size>5e4?"image/jpeg":"image/png";t(o.toDataURL(d,"image/jpeg"===d?.85:void 0))},n.onerror=()=>{URL.revokeObjectURL(a),r(Error("image load failed"))},n.src=a});else t=await new Promise((t,r)=>{let n=new FileReader;n.onloadend=()=>t(n.result),n.onerror=r,n.readAsDataURL(e)});return{type:r?"image":n?"audio":"file",url:t,name:e.name,mimeType:e.type,size:t.length}}function U(e){let{disabled:t,loading:r,onSend:i,onInterrupt:o,onNewSession:l,onStatusRequest:d,skillsVersion:c,events:u}=e,[p,h]=(0,a.useState)(""),[g,v]=(0,a.useState)([]),[x,m]=(0,a.useState)(!1),[f,y]=(0,a.useState)(""),[b,j]=(0,a.useState)(0),[k,w]=(0,a.useState)(E),[S,C]=(0,a.useState)(!1),[I,R]=(0,a.useState)(""),[L,W]=(0,a.useState)(0),[z,D]=(0,a.useState)([]),U=(0,a.useRef)(null),N=(0,a.useRef)(null),F=(0,a.useRef)(new Map),H=function(e,t){let[r,n]=(0,a.useState)("idle"),[i,o]=(0,a.useState)(null),[l,d]=(0,a.useState)(null),[c,u]=(0,a.useState)(null),[p,h]=(0,a.useState)(["en"]),[g,v]=(0,a.useState)(null),[x,m]=(0,a.useState)(()=>localStorage.getItem("stt-language")||"en"),f=(0,a.useRef)(x);f.current=x;let y=(0,a.useRef)(null),b=(0,a.useRef)(null),j=(0,a.useRef)(null),k=(0,a.useRef)([]),w=(0,a.useRef)(null),S=(0,a.useRef)(null),C=(0,a.useRef)(t);C.current=t,(0,a.useEffect)(()=>{if(!e||0===e.length)return;let t=e[e.length-1];if(!t.event.startsWith("stt:"))return;let r=t.payload;"stt:download:progress"===t.event&&d(Number(r.progress)||0),"stt:download:complete"===t.event&&(d(null),o(!0),n("idle")),"stt:download:error"===t.event&&(d(null),n("idle"))},[e]);let I=(0,a.useCallback)(()=>{var e,t;null==(e=j.current)||e.getTracks().forEach(e=>e.stop()),j.current=null,null==(t=b.current)||t.close().catch(()=>{}),b.current=null,u(null),y.current=null},[]);(0,a.useEffect)(()=>()=>{var e,t,r;w.current&&clearTimeout(w.current),(null==(e=y.current)?void 0:e.state)==="recording"&&y.current.stop(),null==(t=j.current)||t.getTracks().forEach(e=>e.stop()),null==(r=b.current)||r.close().catch(()=>{})},[]);let R=(0,a.useCallback)(async()=>{try{var e;let t=await s.F.sttStatus();return o(t.available),t.downloading&&d(t.progress),(null==(e=t.languages)?void 0:e.length)>0&&(h(t.languages),m(e=>{if(!t.languages.includes(e)){let e=t.languages[0];return localStorage.setItem("stt-language",e),e}return e})),t.available}catch(e){return o(!1),!1}},[]),L=(0,a.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});j.current=e;let t=new AudioContext;b.current=t;let r=t.createMediaStreamSource(e),a=t.createAnalyser();a.fftSize=128,r.connect(a),u(a);let i=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",o=new MediaRecorder(e,i?{mimeType:i}:void 0);y.current=o,k.current=[],o.ondataavailable=e=>{e.data.size>0&&k.current.push(e.data)},o.onstop=async()=>{I(),n("transcribing");let e=new Blob(k.current,{type:o.mimeType||"audio/webm"});if(k.current=[],0===e.size){var t;n("idle"),null==(t=S.current)||t.call(S,null),S.current=null;return}try{let t=(await s.F.sttTranscribe(e,f.current)).text||null;n("idle"),v(null),S.current?(S.current(t),S.current=null):t&&C.current&&C.current(t)}catch(t){let e=t instanceof Error?t.message:"Transcription failed";v(e),n("error"),S.current&&(S.current(null),S.current=null)}},o.start(5e3),n("recording"),w.current=setTimeout(()=>{var e;(null==(e=y.current)?void 0:e.state)==="recording"&&y.current.stop()},18e5)}catch(e){I(),n("idle")}},[I]),W=(0,a.useCallback)(async()=>{"recording"!==r&&"transcribing"!==r&&("error"===r&&(v(null),n("idle")),await R()?await L():n("no-model"))},[r,R,L]),z=(0,a.useCallback)(async()=>{await L()},[L]),D=(0,a.useCallback)(async()=>y.current&&"inactive"!==y.current.state?(w.current&&(clearTimeout(w.current),w.current=null),new Promise(e=>{var t;S.current=e,(null==(t=y.current)?void 0:t.state)==="recording"?y.current.stop():(I(),n("idle"),S.current=null,e(null))})):(n("idle"),null),[I]),T=(0,a.useCallback)(()=>{var e;w.current&&(clearTimeout(w.current),w.current=null),(null==(e=y.current)?void 0:e.state)==="recording"&&y.current.stop(),I(),k.current=[],n("idle")},[I]),M=(0,a.useCallback)(()=>{d(0),s.F.sttDownload().catch(()=>{d(null)})},[]),B=(0,a.useCallback)(()=>{n("idle"),d(null)},[]),E=(0,a.useCallback)(()=>{n("idle"),v(null)},[]),A=(0,a.useCallback)(()=>{m(e=>{let t=p.indexOf(e),r=p[(t+1)%p.length];return localStorage.setItem("stt-language",r),r})},[p]);return{state:r,available:i,downloadProgress:l,analyser:c,languages:p,selectedLanguage:x,error:g,cycleLanguage:A,handleMicClick:W,startRecording:z,stopRecording:D,cancelRecording:T,startDownload:M,dismissDownload:B,dismissError:E}}(u,e=>{e&&h(t=>t?t+" "+e:e)});(0,a.useEffect)(()=>{s.F.getOrg().then(async e=>{let t=e.employees;Array.isArray(t)&&v(await Promise.all(t.map(async e=>{try{let t=await s.F.getEmployee(e);return{name:t.name,displayName:t.displayName,department:t.department,rank:t.rank,engine:t.engine}}catch(t){return{name:e}}})))}).catch(()=>{})},[]),(0,a.useEffect)(()=>{s.F.getSkills().then(e=>{if(!Array.isArray(e))return;let t=e.filter(e=>!E.some(t=>t.name===e.name)).map(e=>({name:e.name,description:e.description||"",needsEmployee:"sync"===e.name}));w([...E,...t])}).catch(()=>{})},[c]);let O=(0,a.useCallback)(e=>{var t;let r=p.lastIndexOf("@");-1!==r&&h(p.slice(0,r)+"@"+e+" "),m(!1),null==(t=U.current)||t.focus()},[p]),P=(0,a.useCallback)(e=>{var t;e.needsEmployee?(h("/"+e.name+" @"),C(!1),y(""),j(0),m(!0)):(h("/"+e.name),C(!1)),null==(t=U.current)||t.focus()},[]);function V(){let e=p.trim(),r=z.length>0;if(!e&&!r||t)return;if("/new"===e){h(""),l();return}if("/status"===e){h(""),d();return}let n=r?[...z]:void 0;h(""),D([]),m(!1),C(!1),U.current&&(U.current.style.height="auto"),i(e,n,!1)}async function q(e){let t=e.target.files;if(!t||0===t.length)return;let r=[];for(let e=0;e<t.length;e++)r.push(await A(t[e]));D(e=>[...e,...r]),e.target.value=""}async function J(e){var t;let r=null==(t=e.clipboardData)?void 0:t.items;if(r){for(let t=0;t<r.length;t++)if(r[t].type.startsWith("image/")){e.preventDefault();let n=r[t].getAsFile();if(n){let e=await A(n);D(t=>[...t,e])}return}}}let _=(0,a.useCallback)(e=>{e&&h(t=>t?t+" "+e:e)},[]);async function K(){if("recording"===H.state){var e;let t=await H.stopRecording();_(null!=t?t:""),null==(e=U.current)||e.focus()}else"transcribing"===H.state||H.handleMicClick()}(0,a.useEffect)(()=>{U.current&&(U.current.style.height="auto",U.current.style.height=Math.min(U.current.scrollHeight,120)+"px")},[p]);let Y=k.filter(e=>e.name.toLowerCase().startsWith(I)),X=g.filter(e=>e.name.toLowerCase().includes(f)),G=p.trim().length>0||z.length>0;return(0,n.jsxs)("div",{className:"px-3 sm:px-4",style:{paddingTop:"var(--space-3)",paddingBottom:"var(--space-3)",borderTop:"1px solid var(--separator)",background:"var(--material-regular)",flexShrink:0,position:"relative"},children:[S&&Y.length>0&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"100%",left:"var(--space-4)",right:"var(--space-4)",marginBottom:4,background:"var(--bg)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-lg)",maxHeight:240,overflowY:"auto",zIndex:10},children:Y.map((e,t)=>{let r=t===L;return(0,n.jsxs)("button",{ref:e=>{r&&e&&e.scrollIntoView({block:"nearest"})},onClick:()=>P(e),style:{width:"100%",textAlign:"left",padding:"var(--space-2) var(--space-3)",fontSize:"var(--text-footnote)",background:r?"var(--fill-secondary)":"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"var(--space-2)",color:"var(--text-primary)"},children:[(0,n.jsxs)("span",{style:{fontFamily:"var(--font-mono)",fontWeight:"var(--weight-semibold)",color:"var(--accent)",fontSize:"var(--text-footnote)"},children:["/",e.name]}),(0,n.jsx)("span",{style:{color:"var(--text-tertiary)",fontSize:"var(--text-caption1)"},children:e.description})]},e.name)})}),x&&X.length>0&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"100%",left:"var(--space-4)",right:"var(--space-4)",marginBottom:4,background:"var(--bg)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-lg)",maxHeight:160,overflowY:"auto",zIndex:10},children:X.slice(0,8).map((e,t)=>{let r=t===b;return(0,n.jsxs)("button",{ref:e=>{e?F.current.set(t,e):F.current.delete(t),r&&e&&e.scrollIntoView({block:"nearest"})},onClick:()=>O(e.name),style:{width:"100%",textAlign:"left",padding:"var(--space-2) var(--space-3)",fontSize:"var(--text-footnote)",background:r?"var(--fill-secondary)":"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"var(--space-2)",color:"var(--text-primary)"},children:[(0,n.jsx)("span",{style:{fontSize:16,lineHeight:1},children:{executive:"\uD83C\uDFAF",manager:"\uD83D\uDCCB",senior:"⭐",employee:"\uD83D\uDC64"}[e.rank||"employee"]||"\uD83D\uDC64"}),(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[(0,n.jsx)("span",{style:{fontWeight:"var(--weight-semibold)"},children:e.displayName||e.name}),(0,n.jsxs)("span",{style:{fontFamily:"var(--font-mono)",fontSize:"var(--text-caption2)",color:"var(--text-tertiary)"},children:["@",e.name]})]}),e.department&&(0,n.jsxs)("div",{style:{fontSize:"var(--text-caption2)",color:"var(--text-quaternary)",display:"flex",gap:"var(--space-2)",marginTop:1},children:[(0,n.jsx)("span",{children:e.department}),e.engine&&(0,n.jsx)("span",{style:{color:"var(--accent)",fontWeight:"var(--weight-medium)"},children:e.engine})]})]})]},e.name)})}),z.length>0&&(0,n.jsx)("div",{style:{marginBottom:"var(--space-2)"},children:(0,n.jsx)(T,{attachments:z,onRemove:function(e){D(t=>t.filter((t,r)=>r!==e))}})}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",background:"var(--fill-secondary)",borderRadius:"var(--radius-lg)",padding:"6px var(--space-3)",border:r?"1px solid var(--accent)":"1px solid var(--separator)",minHeight:44,transition:"border-color 200ms ease"},children:[(0,n.jsx)("button",{"aria-label":"Attach file",onClick:()=>{var e;return null==(e=N.current)?void 0:e.click()},style:{width:32,height:32,flexShrink:0,borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-secondary)",marginBottom:0},children:(0,n.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),(0,n.jsx)("input",{ref:N,type:"file",accept:"image/*,audio/*,.pdf,.doc,.docx,.txt,.csv,.json,.zip",multiple:!0,style:{display:"none"},onChange:q}),(0,n.jsx)("textarea",{ref:U,value:p,onChange:function(e){let t=e.target.value;if(h(t),t.startsWith("/")&&!t.includes(" ")){R(t.slice(1).toLowerCase()),W(0),C(!0),m(!1);return}C(!1);let r=t.lastIndexOf("@");if(-1!==r){let e=t.slice(r+1);if(!e.includes(" ")&&!e.includes("\n")){y(e.toLowerCase()),j(0),m(!0);return}}m(!1)},onKeyDown:function(e){if(S&&Y.length>0){let t=Y.length;if("ArrowDown"===e.key){e.preventDefault(),W(e=>(e+1)%t);return}if("ArrowUp"===e.key){e.preventDefault(),W(e=>(e-1+t)%t);return}if("Tab"===e.key||"Enter"===e.key){e.preventDefault(),P(Y[L]);return}if("Escape"===e.key){e.preventDefault(),C(!1);return}}if(x&&X.length>0){let t=Math.min(X.length,8);if("ArrowDown"===e.key){e.preventDefault(),j(e=>(e+1)%t);return}if("ArrowUp"===e.key){e.preventDefault(),j(e=>(e-1+t)%t);return}if("Tab"===e.key||"Enter"===e.key){e.preventDefault(),O(X[b].name);return}if("Escape"===e.key){e.preventDefault(),m(!1);return}}"Enter"!==e.key||e.shiftKey||(e.preventDefault(),V())},onPaste:J,placeholder:t?"Waiting for response...":"Type a message...",rows:1,disabled:t,style:{flex:1,background:"transparent",border:"none",outline:"none",resize:"none",color:"var(--text-primary)",fontSize:"var(--text-subheadline)",lineHeight:"20px",maxHeight:120,minHeight:20,height:20,padding:0,margin:0,opacity:t?.5:1},onInput:e=>{let t=e.target;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,120)+"px"}}),H.languages.length>1&&(0,n.jsx)("button",{"aria-label":"STT language: ".concat(H.selectedLanguage.toUpperCase(),". Click to switch."),onClick:H.cycleLanguage,style:{height:24,padding:"0 6px",flexShrink:0,borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--fill-tertiary)",border:"none",cursor:"pointer",color:"var(--text-secondary)",fontSize:11,fontWeight:600,fontFamily:"var(--font-mono)",letterSpacing:"0.5px",textTransform:"uppercase",transition:"all 150ms ease"},title:"Transcription language: ".concat(H.selectedLanguage.toUpperCase(),". Click to cycle."),children:H.selectedLanguage}),(0,n.jsx)("button",{"aria-label":"recording"===H.state?"Stop recording":"transcribing"===H.state?"Transcribing…":"Voice input",onClick:K,disabled:"transcribing"===H.state,style:{width:32,height:32,flexShrink:0,borderRadius:"recording"===H.state?"999px":"var(--radius-sm)",display:"flex",alignItems:"center",justifyContent:"center",background:"recording"===H.state?"var(--system-red)":"transparent",border:"none",cursor:"transcribing"===H.state?"wait":"pointer",color:"recording"===H.state?"#fff":"var(--text-secondary)",transition:"all 150ms ease"},title:"recording"===H.state?"Stop recording":"transcribing"===H.state?"Transcribing…":"Voice input",children:"transcribing"===H.state?(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{animation:"stt-spin 1s linear infinite"},children:(0,n.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})}):(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),(0,n.jsx)("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),(0,n.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),(0,n.jsx)("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}),"recording"===H.state&&H.analyser&&(0,n.jsx)(B,{analyser:H.analyser,width:64,height:28}),r&&o&&(0,n.jsx)("button",{onClick:o,"aria-label":"Stop",style:{width:32,height:32,borderRadius:"50%",background:"var(--system-red)",color:"#fff",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 150ms ease"},children:(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),(0,n.jsx)("button",{onClick:V,disabled:!G||t,"aria-label":"Send message",style:{width:32,height:32,borderRadius:"50%",background:G?"var(--accent)":"var(--fill-tertiary)",color:G?"#000":"var(--text-quaternary)",border:"none",cursor:G?"pointer":"default",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 150ms ease"},children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),(0,n.jsx)("polyline",{points:"5 12 12 5 19 12"})]})})]}),(0,n.jsxs)("div",{className:"hidden sm:flex",style:{fontSize:"var(--text-caption2)",color:"var(--text-quaternary)",textAlign:"center",marginTop:"var(--space-1)",justifyContent:"center",gap:"var(--space-3)"},children:[(0,n.jsx)("span",{children:"Enter to send"}),(0,n.jsx)("span",{children:"/ - commands"}),(0,n.jsx)("span",{children:"@name - mention"})]}),"error"===H.state&&H.error&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",marginTop:"var(--space-2)",padding:"var(--space-2) var(--space-3)",background:"color-mix(in srgb, var(--system-red) 12%, transparent)",borderRadius:"var(--radius-sm)",fontSize:"var(--text-caption1)",color:"var(--system-red)"},children:[(0,n.jsxs)("span",{style:{flex:1},children:["Voice input error: ",H.error]}),(0,n.jsx)("button",{onClick:H.dismissError,style:{background:"none",border:"none",cursor:"pointer",color:"var(--system-red)",fontSize:"var(--text-caption1)",fontWeight:600,padding:"2px 6px"},children:"Dismiss"})]}),(0,n.jsx)(M,{open:"no-model"===H.state,progress:H.downloadProgress,onDownload:H.startDownload,onCancel:H.dismissDownload}),(0,n.jsx)("style",{children:"\n @keyframes stt-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n "})]})}function N(){return(0,n.jsx)(a.Suspense,{fallback:(0,n.jsx)(l.M,{children:(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--text-tertiary)"},children:"Loading..."})}),children:(0,n.jsx)(F,{})})}function F(){var e;let{settings:t}=(0,d.t0)(),r=null!=(e=t.portalName)?e:"Jinn",[c,u]=(0,a.useState)(null),[p,h]=(0,a.useState)([]),[g,v]=(0,a.useState)(!1),[y,b]=(0,a.useState)(0),[j,k]=(0,a.useState)("sidebar"),[w,S]=(0,a.useState)(null),C=(0,a.useRef)(""),[I,R]=(0,a.useState)(""),L=(0,a.useRef)(-1),W=(0,a.useRef)(!1),[z,T]=(0,a.useState)(!1),[M,B]=(0,a.useState)(null),[E,A]=(0,a.useState)(!1),N=(0,a.useRef)(null),{events:F,connectionSeq:H,skillsVersion:O}=(0,o.G)(),P=(0,i.useSearchParams)(),V=(0,a.useRef)(!1),q=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(z)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){N.current&&!N.current.contains(e.target)&&T(!1)}},[z]);let J=(0,a.useCallback)((e,t)=>{navigator.clipboard.writeText(e),B(t),T(!1),setTimeout(()=>B(null),1500)},[]);function _(){s.F.createStubSession({greeting:"Hey! \uD83D\uDC4B Say hi when you're ready to get started.",title:"Welcome"}).then(e=>{let t=String(e.id);q.current=!0,u(t),b(e=>e+1)}).catch(()=>{})}(0,a.useEffect)(()=>{V.current||("1"===P.get("onboarding")?(V.current=!0,_()):s.F.getOnboarding().then(e=>{e.needed&&!V.current&&(V.current=!0,_())}).catch(()=>{}))},[P]);let K=(0,a.useCallback)((e,t)=>{if(!t)return;let r=L.current;if(r<0)return;let n=e.slice(r);n.length>0&&function(e,t){try{localStorage.setItem("".concat(m).concat(e),JSON.stringify(t))}catch(e){}}(t,n)},[]);(0,a.useEffect)(()=>{if(0===F.length)return;let e=F[F.length-1],t=e.payload;if(c&&t.sessionId===c){if("session:delta"===e.event){let e=String(t.type||"text");if("text"===e){let e=String(t.content||"");C.current+=e,R(C.current)}else if("tool_use"===e){if(C.current){let e=C.current;C.current="",R(""),h(r=>{L.current<0&&(L.current=r.length);let n=[...r,{id:crypto.randomUUID(),role:"assistant",content:e,timestamp:Date.now()}];return K(n,c||t.sessionId),n})}let e=String(t.toolName||"tool");h(r=>{L.current<0&&(L.current=r.length);let n=[...r,{id:crypto.randomUUID(),role:"assistant",content:"Using ".concat(e),timestamp:Date.now(),toolCall:e}];return K(n,c||t.sessionId),n})}else"tool_result"===e&&h(e=>{let r=[...e],n=r[r.length-1];return n&&"assistant"===n.role&&n.toolCall&&(r[r.length-1]={...n,content:"Used ".concat(n.toolCall)}),K(r,c||t.sessionId),r})}if("session:interrupted"===e.event&&(C.current="",R("")),"session:completed"===e.event){C.current="",R(""),v(!1),L.current=-1;let e=c||(t.sessionId?String(t.sessionId):null);e&&f(e),t.result&&h(e=>{let r=[...e],n=r[r.length-1];return n&&"assistant"===n.role&&!n.toolCall&&r.pop(),[...r,{id:crypto.randomUUID(),role:"assistant",content:String(t.result),timestamp:Date.now()}]}),t.error&&!t.result&&h(e=>[...e,{id:crypto.randomUUID(),role:"assistant",content:"Error: ".concat(t.error),timestamp:Date.now()}]),b(e=>e+1)}}},[F,c,K]);let Y=(0,a.useCallback)(async e=>{try{let t=await s.F.getSession(e);S({engine:t.engine?String(t.engine):void 0,engineSessionId:t.engineSessionId?String(t.engineSessionId):void 0,model:t.model?String(t.model):void 0,title:t.title?String(t.title):void 0,employee:t.employee?String(t.employee):void 0});let r=t.messages||t.history||[],n=Array.isArray(r)?r.map(e=>({id:crypto.randomUUID(),role:e.role||"assistant",content:String(e.content||e.text||""),timestamp:e.timestamp?Number(e.timestamp):Date.now()})):[];if("error"===t.status&&t.lastError){let e=n[n.length-1],r="Error: ".concat(String(t.lastError));e&&"assistant"===e.role&&e.content===r||n.push({id:crypto.randomUUID(),role:"assistant",content:r,timestamp:Date.now()})}if("running"===t.status){let t=function(e){try{let t=localStorage.getItem("".concat(m).concat(e));return t?JSON.parse(t):[]}catch(e){return[]}}(e);t.length>0?(L.current=n.length,h([...n,...t])):(L.current=n.length,h(n)),v(!0)}else f(e),L.current=-1,h(n)}catch(e){h([]),S(null),L.current=-1}},[]);(0,a.useEffect)(()=>{H&&c&&Y(c)},[H,c,Y]),(0,a.useEffect)(()=>{if(!c||!g)return;let e=setInterval(async()=>{try{let e=await s.F.getSession(c);"running"!==e.status&&(await Y(c),v(!1))}catch(e){}},5e3);return()=>clearInterval(e)},[c,g,Y]);let X=(0,a.useCallback)(e=>{W.current=!1,u(e),h([]),v(!1),k("chat"),Y(e)},[Y]),G=(0,a.useCallback)(()=>{W.current=!0,u(null),h([]),v(!1),S(null),k("chat"),L.current=-1},[]),$=(0,a.useCallback)(e=>{c||V.current||W.current||!(e.length>0)||X(e[0].id)},[c,X]),Q=(0,a.useCallback)(async(e,t,n)=>{let a={id:crypto.randomUUID(),role:"user",content:e,timestamp:Date.now(),media:t};h(e=>(L.current=e.length+1,[...e,a])),v(!0);try{let t=c;if(t&&q.current){q.current=!1;let n="This is your first time being activated. The user just set up ".concat(r," and opened the web dashboard for the first time.\n\nRead your CLAUDE.md instructions and the onboarding skill at ~/.jinn/skills/onboarding/SKILL.md, then follow the onboarding flow:\n- Greet the user warmly and introduce yourself as ").concat(r,"\n- Briefly explain what you can do (manage cron jobs, hire AI employees, connect to Slack, etc.)\n- Ask the user what they'd like to set up first\n\nThe user said: \"").concat(e,'"');await s.F.sendMessage(t,{message:n}),b(e=>e+1)}else if(t)await s.F.sendMessage(t,{message:e,interrupt:n||void 0}),b(e=>e+1);else{let r=await s.F.createSession({source:"web",prompt:e});t=String(r.id),u(t),b(e=>e+1)}}catch(e){v(!1),h(t=>[...t,{id:crypto.randomUUID(),role:"assistant",content:"Error: ".concat(e instanceof Error?e.message:"Failed to send message"),timestamp:Date.now()}])}},[c,r]),Z=(0,a.useCallback)(async e=>{try{await s.F.deleteSession(e),c===e&&(u(null),h([]),v(!1),S(null),C.current="",R(""),L.current=-1),f(e),b(e=>e+1)}catch(e){}A(!1),T(!1)},[c]),ee=(0,a.useCallback)(async()=>{if(!c)return void h(e=>[...e,{id:crypto.randomUUID(),role:"assistant",content:"No active session. Send a message to start one.",timestamp:Date.now()}]);try{let e=await s.F.getSession(c),t=["**Session Info**","ID: `".concat(e.id,"`"),"Status: ".concat(e.status||"unknown"),e.employee?"Employee: ".concat(e.employee):null,e.engine?"Engine: ".concat(e.engine):null,e.model?"Model: ".concat(e.model):null,e.createdAt?"Created: ".concat(e.createdAt):null].filter(Boolean).join("\n");h(e=>[...e,{id:crypto.randomUUID(),role:"assistant",content:t,timestamp:Date.now()}])}catch(e){h(e=>[...e,{id:crypto.randomUUID(),role:"assistant",content:"Failed to fetch session status.",timestamp:Date.now()}])}},[c]);return(0,n.jsxs)(l.M,{children:[(0,n.jsxs)("div",{className:"h-[calc(100%-48px)] lg:h-full",style:{display:"flex",overflow:"hidden"},children:[(0,n.jsx)("div",{className:"hidden lg:block",style:{width:280,flexShrink:0,height:"100%"},children:(0,n.jsx)(x,{selectedId:c,onSelect:X,onNewChat:G,onDelete:Z,refreshKey:y,connectionSeq:H,onSessionsLoaded:$,events:F})}),(0,n.jsx)("div",{className:"sidebar"===j?"block lg:hidden":"hidden",style:{width:"100%",height:"100%"},children:(0,n.jsx)(x,{selectedId:c,onSelect:X,onNewChat:G,onDelete:Z,refreshKey:y,connectionSeq:H,onSessionsLoaded:$,events:F})}),(0,n.jsxs)("div",{style:{flex:1,flexDirection:"column",height:"100%",background:"var(--bg)",minWidth:0,overflow:"hidden"},className:"sidebar"===j?"hidden lg:flex":"flex",children:[(0,n.jsxs)("div",{style:{height:52,display:"flex",alignItems:"center",padding:"0 var(--space-4)",borderBottom:"1px solid var(--separator)",background:"var(--material-thick)",flexShrink:0},children:[(0,n.jsxs)("button",{className:"flex lg:hidden",onClick:()=>k("sidebar"),"aria-label":"Back to sessions",style:{padding:"var(--space-1) var(--space-2)",borderRadius:"var(--radius-sm)",marginRight:"var(--space-2)",fontSize:"var(--text-subheadline)",alignItems:"center",gap:"var(--space-1)",background:"transparent",border:"none",cursor:"pointer",color:"var(--accent)"},children:[(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"15 18 9 12 15 6"})}),"Back"]}),(0,n.jsx)("div",{style:{flex:1,minWidth:0},children:(0,n.jsx)("div",{style:{fontSize:"var(--text-subheadline)",fontWeight:"var(--weight-semibold)",color:"var(--text-primary)",letterSpacing:"-0.2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c?(null==w?void 0:w.title)||(null==w?void 0:w.employee)||r:"New Chat"})}),M&&(0,n.jsx)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--accent)",marginRight:"var(--space-2)",whiteSpace:"nowrap"},children:"Copied!"}),c&&(0,n.jsxs)("div",{ref:N,style:{position:"relative"},children:[(0,n.jsx)("button",{onClick:()=>T(e=>!e),"aria-label":"More options",style:{background:"transparent",border:"none",cursor:"pointer",padding:"var(--space-1)",borderRadius:"var(--radius-sm)",color:"var(--text-secondary)",display:"flex",alignItems:"center",transition:"color 150ms ease"},onMouseEnter:e=>e.currentTarget.style.color="var(--text-primary)",onMouseLeave:e=>e.currentTarget.style.color="var(--text-secondary)",children:(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,n.jsx)("circle",{cx:"12",cy:"19",r:"2"})]})}),z&&(0,n.jsxs)("div",{style:{position:"absolute",top:"100%",right:0,marginTop:4,background:"var(--material-thick)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:100,minWidth:200,overflow:"hidden"},children:[(0,n.jsx)("button",{onClick:()=>J(c,"id"),style:{display:"block",width:"100%",padding:"var(--space-2) var(--space-3)",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",fontSize:"var(--text-subheadline)",color:"var(--text-primary)"},onMouseEnter:e=>e.currentTarget.style.background="var(--fill-tertiary)",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:"Copy Session ID"}),(null==w?void 0:w.engineSessionId)&&(0,n.jsx)("button",{onClick:()=>{let e="codex"===w.engine?"codex":"claude";J("".concat(e," --resume ").concat(w.engineSessionId),"cli")},style:{display:"block",width:"100%",padding:"var(--space-2) var(--space-3)",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",fontSize:"var(--text-subheadline)",color:"var(--text-primary)"},onMouseEnter:e=>e.currentTarget.style.background="var(--fill-tertiary)",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:"Copy CLI Resume Command"}),(0,n.jsx)("div",{style:{borderTop:"1px solid var(--separator)",margin:"2px 0"}}),(0,n.jsxs)("button",{onClick:()=>{T(!1),A(!0)},style:{display:"flex",alignItems:"center",gap:"var(--space-2)",width:"100%",padding:"var(--space-2) var(--space-3)",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",fontSize:"var(--text-subheadline)",color:"var(--system-red)"},onMouseEnter:e=>e.currentTarget.style.background="var(--fill-tertiary)",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),"Delete Session"]})]})]})]}),(0,n.jsx)(D,{messages:p,loading:g,streamingText:I}),(0,n.jsx)(U,{disabled:!1,loading:g,onSend:Q,onNewSession:G,onStatusRequest:ee,skillsVersion:O,events:F})]})]}),E&&c&&(0,n.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",zIndex:60,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>A(!1),children:(0,n.jsxs)("div",{style:{background:"var(--bg)",borderRadius:"var(--radius-lg)",padding:"var(--space-6)",maxWidth:400,width:"90%",boxShadow:"var(--shadow-overlay)"},onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h3",{style:{fontSize:"var(--text-headline)",fontWeight:"var(--weight-bold)",color:"var(--text-primary)",marginBottom:"var(--space-2)"},children:"Delete Session?"}),(0,n.jsx)("p",{style:{fontSize:"var(--text-body)",color:"var(--text-secondary)",marginBottom:"var(--space-5)"},children:"This will permanently delete the session and all its messages."}),(0,n.jsxs)("div",{style:{display:"flex",gap:"var(--space-3)",justifyContent:"flex-end"},children:[(0,n.jsx)("button",{onClick:()=>A(!1),style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--fill-tertiary)",color:"var(--text-primary)",border:"none",cursor:"pointer",fontSize:"var(--text-body)"},children:"Cancel"}),(0,n.jsx)("button",{onClick:()=>Z(c),style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--system-red)",color:"#fff",border:"none",cursor:"pointer",fontSize:"var(--text-body)",fontWeight:"var(--weight-semibold)"},children:"Delete"})]})]})})]})}},7906:(e,t,r)=>{Promise.resolve().then(r.bind(r,3095))}},e=>{e.O(0,[704,73,814,743,358],()=>e(e.s=7906)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[457],{3095:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>N});var n=r(8111),a=r(5271),i=r(4736),s=r(3176),o=r(4263),l=r(8700),d=r(2755);let c="jinn-sidebar-collapsed",u="jinn-pinned-sessions";function p(){try{let e=localStorage.getItem("jinn-read-sessions");return e?new Set(JSON.parse(e)):new Set}catch(e){return new Set}}function h(e){try{localStorage.setItem(u,JSON.stringify(Array.from(e)))}catch(e){}}function g(e){return"cron"===e.source||(e.sourceRef||"").startsWith("cron:")}function v(e,t){let r=(e,t)=>{let r=e.lastActivity||e.createdAt||"";return(t.lastActivity||t.createdAt||"").localeCompare(r)};return[...e.filter(e=>t.has(e.id)).sort(r),...e.filter(e=>!t.has(e.id)).sort(r)]}function x(e){var t;let{selectedId:r,onSelect:i,onNewChat:o,onDelete:l,refreshKey:x,connectionSeq:m,onSessionsLoaded:y,events:f}=e,{settings:b}=(0,d.t0)(),j=null!=(t=b.portalName)?t:"Jinn",k=j.toLowerCase(),[w,S]=(0,a.useState)([]),[C,I]=(0,a.useState)(!0),[R,L]=(0,a.useState)(""),[W,z]=(0,a.useState)(null),[D,T]=(0,a.useState)(null),[M,B]=(0,a.useState)(null),[E,A]=(0,a.useState)(null),[U,N]=(0,a.useState)(new Set),[F,H]=(0,a.useState)(new Set),[O,P]=(0,a.useState)(new Set),[V,q]=(0,a.useState)(new Map),J=(0,a.useRef)(null);(0,a.useEffect)(()=>{N(p()),H(function(){try{let e=localStorage.getItem(u);return e?new Set(JSON.parse(e)):new Set}catch(e){return new Set}}()),P(function(){try{let e=localStorage.getItem(c);return e?new Set(JSON.parse(e)):new Set}catch(e){return new Set}}()),s.F.getOrg().then(async e=>{let t=new Map;await Promise.all(e.employees.map(async e=>{try{let r=await s.F.getEmployee(e);r.emoji&&t.set(e,r.emoji)}catch(e){}})),q(t)}).catch(()=>{})},[]),(0,a.useEffect)(()=>{if(r){let e=p();e.add(r);let t=Array.from(e);t.length>500&&t.splice(0,t.length-500),localStorage.setItem("jinn-read-sessions",JSON.stringify(t)),N(e=>{let t=new Set(e);return t.add(r),t})}},[r]);let _=(0,a.useCallback)(()=>{s.F.getSessions().then(e=>{let t=e.filter(e=>"web"===e.source||"cron"===e.source||!e.source);t.sort((e,t)=>{let r=e.lastActivity||e.createdAt||"";return(t.lastActivity||t.createdAt||"").localeCompare(r)}),S(t),null==y||y(t)}).catch(()=>S([])).finally(()=>I(!1))},[y]);(0,a.useEffect)(()=>{I(!0),_()},[x,_]),(0,a.useEffect)(()=>{m&&_()},[m,_]),(0,a.useEffect)(()=>{if(!f||0===f.length)return;let e=f[f.length-1],t="".concat(e.event,":").concat(JSON.stringify(e.payload));t!==J.current&&(J.current=t,("session:started"===e.event||"session:completed"===e.event||"session:deleted"===e.event||"session:error"===e.event)&&_())},[f,_]);let K=(0,a.useCallback)(e=>{P(t=>{let r=new Set(t);r.has(e)?r.delete(e):r.add(e);try{localStorage.setItem(c,JSON.stringify(Array.from(r)))}catch(e){}return r})},[]),Y=(0,a.useCallback)(e=>{H(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),h(r),r})},[]);async function X(e){let t=e.sessions.map(e=>e.id);try{await s.F.bulkDeleteSessions(t),S(e=>e.filter(e=>!t.includes(e.id))),H(e=>{let r=new Set(e);for(let e of t)r.delete(e);return h(r),r}),r&&t.includes(r)&&o()}catch(e){}T(null)}async function G(e){try{await s.F.deleteSession(e),S(t=>t.filter(t=>t.id!==e)),H(t=>{if(!t.has(e))return t;let r=new Set(t);return r.delete(e),h(r),r}),l?l(e):r===e&&o()}catch(e){}z(null)}let $=function(e,t,r,n){let a=[],i=[],s=new Map;for(let t of e)if(g(t))i.push(t);else if(g(t)||t.employee&&t.employee!==r){let e=t.employee;s.has(e)||s.set(e,[]),s.get(e).push(t)}else a.push(t);let o=[];for(let e of(a.length>0&&o.push({key:"direct",label:"Direct",emoji:"\uD83D\uDCAC",sessions:v(a,n),sortOrder:0}),Array.from(s.keys()).sort())){let r=s.get(e);o.push({key:"emp:".concat(e),label:e,emoji:t.get(e)||"\uD83E\uDD16",sessions:v(r,n),sortOrder:1})}return i.length>0&&o.push({key:"cron",label:"Cron",emoji:"⏰",sessions:v(i,n),sortOrder:2}),o}(R.trim()?w.filter(e=>{let t=R.toLowerCase();return e.id.toLowerCase().includes(t)||e.employee&&e.employee.toLowerCase().includes(t)||e.title&&e.title.toLowerCase().includes(t)}):w,V,k,F);return(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--sidebar-bg)",borderRight:"1px solid var(--separator)"},children:[(0,n.jsxs)("div",{style:{padding:"var(--space-4) var(--space-4) var(--space-3)",borderBottom:"1px solid var(--separator)",background:"var(--material-thick)",flexShrink:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"var(--space-3)"},children:[(0,n.jsx)("h2",{style:{fontSize:"var(--text-title3)",fontWeight:"var(--weight-bold)",letterSpacing:"-0.5px",color:"var(--text-primary)",margin:0},children:"Chats"}),(0,n.jsxs)("button",{onClick:o,"aria-label":"New chat",style:{padding:"var(--space-1) var(--space-3)",fontSize:"var(--text-footnote)",fontWeight:"var(--weight-semibold)",color:"var(--accent-contrast)",background:"var(--accent)",border:"none",borderRadius:"var(--radius-md)",cursor:"pointer",display:"flex",alignItems:"center",gap:"var(--space-1)"},children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,n.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New"]})]}),(0,n.jsxs)("div",{style:{background:"var(--fill-tertiary)",borderRadius:"var(--radius-md)",padding:"7px var(--space-3)",display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},"aria-hidden":"true",children:[(0,n.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,n.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),(0,n.jsx)("input",{type:"text",value:R,onChange:e=>L(e.target.value),placeholder:"Search sessions...","aria-label":"Search sessions",style:{flex:1,fontSize:"var(--text-footnote)",color:"var(--text-primary)",background:"transparent",border:"none",outline:"none",padding:0,margin:0,lineHeight:1.4}}),R.trim()&&(0,n.jsx)("button",{onClick:()=>L(""),"aria-label":"Clear search",style:{padding:2,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,background:"transparent",border:"none",cursor:"pointer",color:"var(--text-tertiary)"},children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),(0,n.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"var(--space-1) 0"},children:C?(0,n.jsx)("div",{style:{padding:"var(--space-8) var(--space-4)",textAlign:"center"},children:(0,n.jsx)("span",{style:{fontSize:"var(--text-caption1)",color:"var(--text-quaternary)"},children:"Loading sessions..."})}):0===$.length?(0,n.jsx)("div",{style:{padding:"var(--space-8) var(--space-4)",textAlign:"center"},children:(0,n.jsx)("span",{style:{fontSize:"var(--text-caption1)",color:"var(--text-quaternary)"},children:R.trim()?"No matching sessions":"No conversations yet"})}):$.map(e=>{let t=O.has(e.key);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{onMouseEnter:()=>A(e.key),onMouseLeave:()=>A(null),style:{display:"flex",alignItems:"center",marginTop:"var(--space-1)"},children:[(0,n.jsxs)("button",{onClick:()=>K(e.key),style:{flex:1,display:"flex",alignItems:"center",gap:"var(--space-2)",padding:"var(--space-2) var(--space-4)",paddingRight:"var(--space-1)",background:"transparent",border:"none",cursor:"pointer",textAlign:"left"},children:[(0,n.jsx)("span",{style:{fontSize:"var(--text-caption1)"},children:e.emoji}),(0,n.jsx)("span",{style:{fontSize:"var(--text-caption1)",fontWeight:"var(--weight-semibold)",color:"var(--text-secondary)",letterSpacing:"0.3px",textTransform:"uppercase",flex:1},children:e.label}),(0,n.jsx)("span",{style:{fontSize:"var(--text-caption2)",color:"var(--text-tertiary)",background:"var(--fill-tertiary)",borderRadius:"var(--radius-sm)",padding:"0 5px",lineHeight:"18px",minWidth:18,textAlign:"center"},children:e.sessions.length}),(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transition:"transform 150ms ease",transform:t?"rotate(-90deg)":"rotate(0deg)"},children:(0,n.jsx)("polyline",{points:"6 9 12 15 18 9"})})]}),E===e.key&&(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),T(e)},"aria-label":"Delete all sessions in ".concat(e.label),style:{padding:4,marginRight:"var(--space-3)",borderRadius:"var(--radius-sm)",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-tertiary)",display:"flex",alignItems:"center",flexShrink:0,transition:"color 150ms ease"},onMouseEnter:e=>e.currentTarget.style.color="var(--system-red)",onMouseLeave:e=>e.currentTarget.style.color="var(--text-tertiary)",children:(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]}),!t&&e.sessions.map(e=>{var t,a;let s,o=e.id===r,l=e.id===M,d="running"===e.status,c=U.has(e.id),u="error"===e.status,p=F.has(e.id),h=function(e){if(!e)return"";let t=new Date(e),r=Date.now()-t.getTime();return r<6e4?"now":r<36e5?"".concat(Math.floor(r/6e4),"m"):r<864e5?new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}):new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}(e.lastActivity||e.createdAt);return s=d?"var(--system-blue)":u?"var(--system-red)":c?"var(--text-quaternary)":"var(--system-green)",(0,n.jsxs)("button",{onClick:()=>i(e.id),onMouseEnter:()=>B(e.id),onMouseLeave:()=>B(null),style:{width:"100%",display:"flex",alignItems:"center",gap:"var(--space-3)",padding:"var(--space-3) var(--space-4)",paddingLeft:"calc(var(--space-4) + 8px)",background:o?"var(--fill-secondary)":"transparent",border:"none",cursor:"pointer",textAlign:"left",borderLeft:o?"2px solid var(--accent)":"2px solid transparent",position:"relative"},children:[(0,n.jsx)("div",{style:{width:8,height:8,borderRadius:"50%",background:s,flexShrink:0,animation:d?"sidebar-pulse 2s ease-in-out infinite":"none",boxShadow:d?"0 0 6px ".concat(s):"none"}}),(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:2},children:[(0,n.jsx)("span",{style:{fontSize:"var(--text-footnote)",fontWeight:c&&!o?"var(--weight-medium)":"var(--weight-semibold)",color:"var(--text-primary)",letterSpacing:"-0.2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:(t=e.title,a=e.employee,t?"Jinn"!==j&&t.startsWith("Jinn - ")?j+t.slice(4):t:a||j)}),(0,n.jsx)("span",{style:{fontSize:"var(--text-caption2)",color:"var(--text-tertiary)",flexShrink:0,marginLeft:"var(--space-1)"},children:h})]}),(0,n.jsx)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.employee||j})]}),p&&!l&&(0,n.jsx)("span",{style:{fontSize:11,flexShrink:0,opacity:.5},children:"\uD83D\uDCCC"}),l&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),Y(e.id)},"aria-label":p?"Unpin session":"Pin session",style:{padding:4,borderRadius:"var(--radius-sm)",background:"transparent",border:"none",cursor:"pointer",color:p?"var(--accent)":"var(--text-tertiary)",display:"flex",alignItems:"center",flexShrink:0,transition:"color 150ms ease"},onMouseEnter:e=>{p||(e.currentTarget.style.color="var(--accent)")},onMouseLeave:e=>{p||(e.currentTarget.style.color="var(--text-tertiary)")},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:p?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 17v5"}),(0,n.jsx)("path",{d:"M9 2h6l-1 7h4l-2 4H8l-2-4h4L9 2z"})]})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),z(e.id)},"aria-label":"Delete session",style:{padding:4,borderRadius:"var(--radius-sm)",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-tertiary)",display:"flex",alignItems:"center",flexShrink:0,transition:"color 150ms ease"},onMouseEnter:e=>e.currentTarget.style.color="var(--system-red)",onMouseLeave:e=>e.currentTarget.style.color="var(--text-tertiary)",children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]},e.id)})]},e.key)})}),W&&(0,n.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",zIndex:60,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>z(null),children:(0,n.jsxs)("div",{style:{background:"var(--bg)",borderRadius:"var(--radius-lg)",padding:"var(--space-6)",maxWidth:400,width:"90%",boxShadow:"var(--shadow-overlay)"},onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h3",{style:{fontSize:"var(--text-headline)",fontWeight:"var(--weight-bold)",color:"var(--text-primary)",marginBottom:"var(--space-2)"},children:"Delete Session?"}),(0,n.jsx)("p",{style:{fontSize:"var(--text-body)",color:"var(--text-secondary)",marginBottom:"var(--space-5)"},children:"This will permanently delete the session and all its messages."}),(0,n.jsxs)("div",{style:{display:"flex",gap:"var(--space-3)",justifyContent:"flex-end"},children:[(0,n.jsx)("button",{onClick:()=>z(null),style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--fill-tertiary)",color:"var(--text-primary)",border:"none",cursor:"pointer",fontSize:"var(--text-body)"},children:"Cancel"}),(0,n.jsx)("button",{onClick:()=>G(W),style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--system-red)",color:"#fff",border:"none",cursor:"pointer",fontSize:"var(--text-body)",fontWeight:"var(--weight-semibold)"},children:"Delete"})]})]})}),D&&(0,n.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",zIndex:60,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>T(null),children:(0,n.jsxs)("div",{style:{background:"var(--bg)",borderRadius:"var(--radius-lg)",padding:"var(--space-6)",maxWidth:400,width:"90%",boxShadow:"var(--shadow-overlay)"},onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h3",{style:{fontSize:"var(--text-headline)",fontWeight:"var(--weight-bold)",color:"var(--text-primary)",marginBottom:"var(--space-2)"},children:"Delete Group?"}),(0,n.jsxs)("p",{style:{fontSize:"var(--text-body)",color:"var(--text-secondary)",marginBottom:"var(--space-5)"},children:["Delete all ",D.sessions.length," chats in “",D.label,"”? This cannot be undone."]}),(0,n.jsxs)("div",{style:{display:"flex",gap:"var(--space-3)",justifyContent:"flex-end"},children:[(0,n.jsx)("button",{onClick:()=>T(null),style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--fill-tertiary)",color:"var(--text-primary)",border:"none",cursor:"pointer",fontSize:"var(--text-body)"},children:"Cancel"}),(0,n.jsxs)("button",{onClick:()=>X(D),style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--system-red)",color:"#fff",border:"none",cursor:"pointer",fontSize:"var(--text-body)",fontWeight:"var(--weight-semibold)"},children:["Delete ",D.sessions.length," Chats"]})]})]})}),(0,n.jsx)("style",{children:"\n @keyframes sidebar-pulse {\n 0%, 100% { opacity: 1; transform: scale(1); }\n 50% { opacity: 0.5; transform: scale(0.85); }\n }\n "})]})}let m="jinn-intermediate-";function y(e){try{localStorage.removeItem("".concat(m).concat(e))}catch(e){}}function f(e){let{name:t,size:r,mimeType:a,url:i,isUser:s}=e;return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-lg)",background:s?"var(--accent)":"var(--material-thin)",border:s?"none":"1px solid var(--separator)",maxWidth:280,minWidth:180},children:[(0,n.jsx)("div",{style:{width:36,height:36,borderRadius:"var(--radius-sm)",background:s?"rgba(0,0,0,0.15)":"var(--fill-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:s?"#000":"var(--text-secondary)"},children:function(e,t){var r;let a=(null==t||null==(r=t.split(".").pop())?void 0:r.toLowerCase())||"",i="application/pdf"===e||"pdf"===a,s=["doc","docx"].includes(a)||(null==e?void 0:e.includes("wordprocessingml")),o=["txt","csv","json","md"].includes(a)||(null==e?void 0:e.startsWith("text/")),l=["zip","tar","gz","rar","7z"].includes(a);return i?(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,n.jsx)("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}):s?(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,n.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),(0,n.jsx)("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),(0,n.jsx)("polyline",{points:"10 9 9 9 8 9"})]}):o?(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,n.jsx)("polyline",{points:"14 2 14 8 20 8"})]}):l?(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 8v13H3V8"}),(0,n.jsx)("path",{d:"M1 3h22v5H1z"}),(0,n.jsx)("path",{d:"M10 12h4"})]}):(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,n.jsx)("polyline",{points:"13 2 13 9 20 9"})]})}(a,t)}),(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)("div",{style:{fontSize:"var(--text-footnote)",fontWeight:"var(--weight-medium)",color:s?"#000":"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t}),null!=r&&(0,n.jsx)("div",{style:{fontSize:"var(--text-caption2)",color:s?"rgba(0,0,0,0.5)":"var(--text-tertiary)",marginTop:1},children:r<1024?"".concat(r," B"):r<1048576?"".concat((r/1024).toFixed(0)," KB"):"".concat((r/1048576).toFixed(1)," MB")})]}),(0,n.jsx)("a",{href:i,download:t,"aria-label":"Download ".concat(t),style:{width:28,height:28,borderRadius:"50%",background:s?"rgba(0,0,0,0.15)":"var(--fill-secondary)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:s?"#000":"var(--text-secondary)",textDecoration:"none"},children:(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,n.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,n.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})]})}function b(e){let{src:t,duration:r,waveform:i,isUser:s}=e,o=(0,a.useRef)(null),[l,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(0),[p,h]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=new Audio(t);return o.current=e,e.addEventListener("timeupdate",()=>{e.duration&&isFinite(e.duration)&&(u(e.currentTime/e.duration),h(e.currentTime))}),e.addEventListener("ended",()=>{d(!1),u(0),h(0)}),e.addEventListener("pause",()=>d(!1)),e.addEventListener("play",()=>d(!0)),()=>{e.pause(),e.src=""}},[t]);let g=(0,a.useCallback)(()=>{let e=o.current;e&&(l?e.pause():e.play().catch(()=>{}))},[l]),v=i.length>0?i:Array(50).fill(.1),x=l?p:r;return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-lg)",background:s?"var(--accent)":"var(--material-thin)",border:s?"none":"1px solid var(--separator)",maxWidth:280,minWidth:200},children:[(0,n.jsx)("button",{onClick:g,"aria-label":l?"Pause":"Play",style:{width:28,height:28,borderRadius:"50%",background:s?"rgba(0,0,0,0.2)":"var(--fill-secondary)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:s?"#000":"var(--text-primary)"},children:l?(0,n.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),(0,n.jsx)("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]}):(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("polygon",{points:"6,4 20,12 6,20"})})}),(0,n.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",gap:2,height:28},children:v.map((e,t)=>{let r=t/v.length<=c;return(0,n.jsx)("div",{style:{width:3,borderRadius:1.5,height:"".concat(Math.max(4,24*e),"px"),background:s?r?"rgba(0,0,0,0.7)":"rgba(0,0,0,0.25)":r?"var(--accent)":"var(--fill-primary)",transition:"background 100ms ease",flexShrink:0}},t)})}),(0,n.jsx)("span",{style:{fontSize:"var(--text-caption2)",color:s?"rgba(0,0,0,0.6)":"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",flexShrink:0,minWidth:28,textAlign:"right"},children:function(e){let t=Math.floor(e/60),r=Math.floor(e%60);return"".concat(t,":").concat(r.toString().padStart(2,"0"))}(x)})]})}function j(e){let{msgs:t,isActive:r}=e,[i,s]=(0,a.useState)(!1),o=t.every(e=>e.content.startsWith("Used ")),l=r&&!o?"".concat(t.length," tool").concat(1!==t.length?"s":""," running…"):"".concat(t.length," tool").concat(1!==t.length?"s":""," used");return(0,n.jsxs)("div",{style:{padding:"0 var(--space-4)",marginBottom:"var(--space-1)"},children:[(0,n.jsxs)("button",{onClick:()=>s(e=>!e),style:{display:"flex",alignItems:"center",gap:"var(--space-2)",padding:"5px var(--space-3)",borderRadius:"var(--radius-full, 999px)",background:"var(--fill-secondary)",border:"1px solid var(--separator)",fontSize:"var(--text-caption1)",color:"var(--text-secondary)",cursor:"pointer",transition:"background 150ms ease"},onMouseEnter:e=>e.currentTarget.style.background="var(--fill-tertiary)",onMouseLeave:e=>e.currentTarget.style.background="var(--fill-secondary)",children:[(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.6},children:(0,n.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),l,r&&!o&&(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--system-blue)",animation:"jinn-pulse 1.4s infinite"}}),(0,n.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:i?"rotate(180deg)":"rotate(0deg)",transition:"transform 150ms ease",opacity:.5},children:(0,n.jsx)("polyline",{points:"6 9 12 15 18 9"})})]}),i&&(0,n.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--space-1)",marginTop:"var(--space-1)",paddingLeft:"var(--space-1)"},children:t.map(e=>(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:"var(--radius-full, 999px)",background:"var(--fill-tertiary)",border:"1px solid var(--separator)",fontSize:"var(--text-caption2)",color:"var(--text-tertiary)"},children:e.toolCall},e.id))})]})}function k(e){let t,r=[],a=/(https?:\/\/[^\s<]+[^\s<.,;:!?)}\]'"])|(\*\*(.+?)\*\*)|(`([^`]+)`)|\*([^*]+)\*/g,i=0;for(;null!==(t=a.exec(e));)t.index>i&&r.push(e.slice(i,t.index)),t[1]?r.push((0,n.jsx)("a",{href:t[1],target:"_blank",rel:"noopener noreferrer",style:{color:"var(--system-blue)",textDecoration:"underline",textUnderlineOffset:2},children:t[1]},t.index)):t[2]?r.push((0,n.jsx)("strong",{style:{fontWeight:"var(--weight-bold)"},children:t[3]},t.index)):t[4]?r.push((0,n.jsx)("code",{style:{background:"var(--fill-secondary)",border:"1px solid var(--separator)",borderRadius:5,padding:"1px 5px",fontSize:"0.88em",fontFamily:'"SF Mono", Menlo, monospace',color:"var(--accent)"},children:t[5]},t.index)):t[6]&&r.push((0,n.jsx)("em",{style:{fontStyle:"italic",opacity:.85},children:t[6]},t.index)),i=t.index+t[0].length;return i<e.length&&r.push(e.slice(i)),1===r.length?r[0]:(0,n.jsx)(n.Fragment,{children:r})}function w(e){let{code:t,keyProp:r}=e,[i,s]=(0,a.useState)(!1);return(0,n.jsxs)("div",{style:{position:"relative",margin:"8px 0"},children:[(0,n.jsx)("button",{onClick:function(){navigator.clipboard.writeText(t).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})},"aria-label":"Copy code",style:{position:"absolute",top:8,right:8,padding:"2px 8px",fontSize:11,borderRadius:"var(--radius-sm)",background:"var(--fill-secondary)",color:"var(--text-secondary)",border:"1px solid var(--separator)",cursor:"pointer"},children:i?"Copied!":"Copy"}),(0,n.jsx)("pre",{className:"code-block",style:{background:"var(--fill-tertiary)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",padding:"var(--space-3) var(--space-4)",overflowX:"auto",fontSize:13,lineHeight:1.5,fontFamily:'"SF Mono", Menlo, monospace',color:"var(--text-primary)"},children:(0,n.jsx)("code",{children:t})})]},r)}function S(e){return/^\|[\s:|-]+\|$/.test(e.trim())}function C(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>e.trim())}function I(e){let{headerLine:t,rows:r,keyProp:a}=e,i=C(t),s=r.map(C);return(0,n.jsx)("div",{style:{margin:"10px 0",borderRadius:10,border:"1px solid var(--separator)",overflow:"hidden"},children:(0,n.jsx)("div",{style:{overflowX:"auto",WebkitOverflowScrolling:"touch"},children:(0,n.jsxs)("table",{style:{borderCollapse:"collapse",fontSize:"var(--text-footnote)",lineHeight:1.6,width:"100%",minWidth:"max-content"},children:[(0,n.jsx)("thead",{children:(0,n.jsx)("tr",{style:{background:"var(--fill-tertiary)"},children:i.map((e,t)=>(0,n.jsx)("th",{style:{textAlign:"left",padding:"10px 16px",fontWeight:600,color:"var(--text-primary)",borderBottom:"1px solid var(--separator)",maxWidth:280,wordBreak:"break-word"},children:k(e)},t))})}),(0,n.jsx)("tbody",{children:s.map((e,t)=>(0,n.jsx)("tr",{style:{background:t%2==1?"var(--fill-quaternary, transparent)":"transparent"},children:e.map((e,r)=>(0,n.jsx)("td",{style:{padding:"10px 16px",borderBottom:t<s.length-1?"1px solid var(--separator)":"none",color:"var(--text-primary)",maxWidth:280,wordBreak:"break-word"},children:k(e)},r))},t))})]})})},a)}function R(e){if(!e)return null;let t=e.split("\n"),r=[],a=!1,i=[];for(let e=0;e<t.length;e++){let o=t[e];if(o.startsWith("```")){a?(a=!1,r.push((0,n.jsx)(w,{keyProp:e,code:i.join("\n")},e))):a=!0,i=[];continue}if(a){i.push(o);continue}if(o.trim().startsWith("|")&&o.trim().endsWith("|")&&e+1<t.length&&S(t[e+1])){e++;let a=[];for(;e+1<t.length&&t[e+1].trim().startsWith("|")&&t[e+1].trim().endsWith("|")&&!S(t[e+1]);)e++,a.push(t[e]);r.push((0,n.jsx)(I,{keyProp:e,headerLine:o,rows:a},"table-".concat(e)));continue}if(""===o.trim()){r.push((0,n.jsx)("div",{style:{height:6}},"space-".concat(e)));continue}if(o.match(/^[-*] /)){r.push((0,n.jsxs)("div",{style:{display:"flex",gap:"var(--space-2)",marginBottom:2},children:[(0,n.jsx)("span",{style:{color:"var(--accent)",flexShrink:0,marginTop:1},children:"•"}),(0,n.jsx)("span",{children:k(o.slice(2))})]},e));continue}if(o.match(/^\d+\. /)){var s;let t=null==(s=o.match(/^(\d+)\. /))?void 0:s[1];r.push((0,n.jsxs)("div",{style:{display:"flex",gap:"var(--space-2)",marginBottom:2},children:[(0,n.jsxs)("span",{style:{color:"var(--accent)",flexShrink:0,fontWeight:"var(--weight-semibold)",minWidth:16},children:[t,"."]}),(0,n.jsx)("span",{children:k(o.replace(/^\d+\. /,""))})]},e));continue}if(o.startsWith("### ")){r.push((0,n.jsx)("div",{style:{fontWeight:"var(--weight-semibold)",fontSize:"var(--text-footnote)",marginTop:"var(--space-2)",marginBottom:2},children:k(o.slice(4))},e));continue}if(o.startsWith("## ")){r.push((0,n.jsx)("div",{style:{fontWeight:"var(--weight-bold)",fontSize:"var(--text-subheadline)",marginTop:"var(--space-3)",marginBottom:3},children:k(o.slice(3))},e));continue}if(o.startsWith("# ")){r.push((0,n.jsx)("div",{style:{fontWeight:"var(--weight-bold)",fontSize:"var(--text-body)",marginTop:"var(--space-3)",marginBottom:"var(--space-1)"},children:k(o.slice(2))},e));continue}r.push((0,n.jsx)("div",{style:{marginBottom:1},children:k(o)},e))}return a&&i.length>0&&r.push((0,n.jsx)(w,{keyProp:999,code:i.join("\n")},"trailing-code")),(0,n.jsx)(n.Fragment,{children:r})}function L(e){let t=new Date,r=new Date(e),n=t.toDateString()===r.toDateString(),a=new Date(t);a.setDate(a.getDate()-1);let i=a.toDateString()===r.toDateString(),s=r.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return n?"Today ".concat(s):i?"Yesterday ".concat(s):r.toLocaleDateString("en-US",{month:"short",day:"numeric"})+" ".concat(s)}function W(e,t){return 0===t||e[t].timestamp-e[t-1].timestamp>3e5}function z(e,t){let r=e.filter(e=>"image"===e.type),a=e.filter(e=>"audio"===e.type),i=e.filter(e=>"file"===e.type);return(0,n.jsxs)(n.Fragment,{children:[r.map((e,t)=>(0,n.jsx)("div",{style:{marginTop:"var(--space-2)",borderRadius:"var(--radius-lg)",overflow:"hidden",maxWidth:280},children:(0,n.jsx)("img",{src:e.url,alt:e.name||"Image",style:{width:"100%",display:"block",borderRadius:"var(--radius-lg)",cursor:"pointer"},onClick:()=>window.open(e.url,"_blank")})},"img-".concat(t))),a.map((e,r)=>(0,n.jsx)("div",{style:{marginTop:"var(--space-2)"},children:(0,n.jsx)(b,{src:e.url,duration:e.duration||0,waveform:e.waveform||[],isUser:t})},"audio-".concat(r))),i.map((e,r)=>(0,n.jsx)("div",{style:{marginTop:"var(--space-2)"},children:(0,n.jsx)(f,{name:e.name||"File",size:e.size,mimeType:e.mimeType,url:e.url,isUser:t})},"file-".concat(r)))]})}function D(e){var t,r;let{messages:i,loading:s,streamingText:o}=e,l=(0,a.useRef)(null),d=(0,a.useRef)(0);return((0,a.useEffect)(()=>{var e;let t=0===d.current&&i.length>0;null==(e=l.current)||e.scrollIntoView({behavior:t?"instant":"smooth"}),d.current=i.length},[i,s]),0!==i.length||s)?(0,n.jsxs)("div",{className:"chat-messages-scroll",style:{flex:1,overflowY:"auto",overflowX:"hidden",padding:"var(--space-3) 0 var(--space-6) 0",background:"var(--bg)",minHeight:0},children:[(function(e){let t=[],r=0;for(;r<e.length;)if("assistant"===e[r].role&&e[r].toolCall){let n=[],a=r;for(;r<e.length&&"assistant"===e[r].role&&e[r].toolCall;)n.push(e[r]),r++;t.push({kind:"tool-group",msgs:n,startIndex:a})}else t.push({kind:"message",msg:e[r],index:r}),r++;return t})(i).map(e=>{if("tool-group"===e.kind){let t=e.msgs[0],r=W(i,e.startIndex),a=e.startIndex>0?i[e.startIndex-1]:null,o=s&&e.startIndex+e.msgs.length===i.length;return(0,n.jsxs)("div",{children:[r&&(0,n.jsx)("div",{style:{textAlign:"center",padding:"var(--space-3) 0",fontSize:"var(--text-caption2)",color:"var(--text-tertiary)"},children:L(t.timestamp)}),!r&&a&&(0,n.jsx)("div",{style:{height:"assistant"!==a.role?"var(--space-4)":"var(--space-1)"}}),(0,n.jsx)(j,{msgs:e.msgs,isActive:o})]},"tg-".concat(e.startIndex))}let{msg:t,index:r}=e,a="user"===t.role,o=W(i,r),l=t.media||function(e){let t,r=[],n=/!\[([^\]]*)\]\((https?:\/\/[^)]+\.(jpg|jpeg|png|gif|webp|svg)(\?[^)]*)?)\)/gi;for(;null!==(t=n.exec(e));)r.push({type:"image",url:t[2],name:t[1]||"Image"});let a=RegExp("(?<!\\]\\()https?:\\/\\/\\S+\\.(jpg|jpeg|png|gif|webp)(\\?\\S*)?\\b","gi");for(;null!==(t=a.exec(e));){let e=t[0];r.find(t=>t.url===e)||r.push({type:"image",url:e})}let i=/https?:\/\/\S+\.(mp3|wav|ogg|m4a|aac)(\?\S*)?\b/gi;for(;null!==(t=i.exec(e));)r.push({type:"audio",url:t[0],name:t[0].split("/").pop()});return r}(t.content),d=t.content;return l.length>0&&!t.media&&(l.forEach(e=>{d=(d=d.replace(e.url,"")).replace(/!\[[^\]]*\]\([^)]+\)/g,"")}),d=d.trim()),t.media&&t.media.length>0&&d.startsWith("[")&&d.endsWith("]")&&(d=""),(0,n.jsxs)("div",{children:[o&&(0,n.jsx)("div",{style:{textAlign:"center",padding:"var(--space-3) 0",fontSize:"var(--text-caption2)",color:"var(--text-tertiary)"},children:L(t.timestamp)}),!o&&r>0&&(0,n.jsx)("div",{style:{height:i[r-1].role!==t.role?"var(--space-4)":"var(--space-1)"}}),a&&(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",padding:"0 var(--space-4)",marginBottom:"var(--space-1)"},children:[d&&(0,n.jsx)("div",{className:"user-msg-bubble",style:{padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg)",background:"var(--accent)",color:"var(--accent-contrast)",fontSize:"var(--text-subheadline)",lineHeight:"var(--leading-relaxed)",fontWeight:"var(--weight-medium)",boxShadow:"var(--shadow-subtle)"},children:R(d)}),l.length>0&&(0,n.jsx)("div",{className:"user-msg-bubble",children:z(l,!0)})]}),!a&&(0,n.jsx)("div",{className:"assistant-msg-row",style:{display:"flex",justifyContent:"flex-start",padding:"0 var(--space-4)",marginBottom:"var(--space-1)"},children:(0,n.jsxs)("div",{className:"assistant-msg-bubble",style:{display:"flex",flexDirection:"column"},children:[d&&(0,n.jsx)("div",{style:{padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-sm) var(--radius-lg) var(--radius-lg) var(--radius-lg)",background:"var(--material-thin)",border:"1px solid var(--separator)",color:"var(--text-primary)",fontSize:"var(--text-subheadline)",lineHeight:"var(--leading-relaxed)"},children:R(d)}),l.length>0&&z(l,!1)]})})]},t.id||r)}),o&&(0,n.jsx)("div",{style:{display:"flex",justifyContent:"flex-start",padding:"0 var(--space-4)",marginBottom:"var(--space-1)"},className:"assistant-msg-row",children:(0,n.jsx)("div",{className:"assistant-msg-bubble",style:{display:"flex",flexDirection:"column"},children:(0,n.jsx)("div",{style:{padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-sm) var(--radius-lg) var(--radius-lg) var(--radius-lg)",background:"var(--material-thin)",border:"1px solid var(--separator)",color:"var(--text-primary)",fontSize:"var(--text-subheadline)",lineHeight:"var(--leading-relaxed)"},children:R(function(e){let t=e,r=(t.match(/```/g)||[]).length;if(r%2!=0&&(t+="\n```"),r%2==0){let e=t.replace(/```[\s\S]*?```/g,"");(e.match(/`/g)||[]).length%2!=0&&(t+="`"),(e.match(/\*\*/g)||[]).length%2!=0&&(t+="**")}return t}(o))})})}),s&&!o&&i.length>0&&((null==(t=i[i.length-1])?void 0:t.role)==="user"||(null==(r=i[i.length-1])?void 0:r.toolCall))&&(0,n.jsx)("div",{style:{display:"flex",justifyContent:"flex-start",padding:"0 var(--space-4)",marginTop:"var(--space-2)"},children:(0,n.jsx)("div",{style:{padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-sm) var(--radius-lg) var(--radius-lg) var(--radius-lg)",background:"var(--material-thin)",border:"1px solid var(--separator)"},children:(0,n.jsxs)("div",{style:{display:"flex",gap:4,alignItems:"center",height:16},children:[(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--text-quaternary)",animation:"jinn-pulse 1.4s infinite",animationDelay:"0ms"}}),(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--text-quaternary)",animation:"jinn-pulse 1.4s infinite",animationDelay:"200ms"}}),(0,n.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--text-quaternary)",animation:"jinn-pulse 1.4s infinite",animationDelay:"400ms"}})]})})}),(0,n.jsx)("div",{ref:l}),(0,n.jsx)("style",{children:"\n @keyframes jinn-pulse {\n 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }\n 40% { opacity: 1; transform: scale(1); }\n }\n .assistant-msg-bubble { max-width: 100%; overflow-wrap: break-word; word-break: break-word; }\n .user-msg-bubble { max-width: 90%; overflow-wrap: break-word; word-break: break-word; }\n .assistant-msg-row { padding: 0 var(--space-2) !important; }\n @media (min-width: 1024px) {\n .assistant-msg-bubble { max-width: 75%; }\n .user-msg-bubble { max-width: 75%; }\n .assistant-msg-row { padding: 0 var(--space-4) !important; }\n }\n /* User message contrast fixes — ensure all child elements are visible on accent background */\n .user-msg-bubble code {\n background: rgba(255,255,255,0.2) !important;\n border-color: rgba(255,255,255,0.3) !important;\n color: inherit !important;\n }\n .user-msg-bubble .code-block,\n .user-msg-bubble pre {\n background: rgba(0,0,0,0.2) !important;\n border-color: rgba(255,255,255,0.15) !important;\n color: rgba(255,255,255,0.95) !important;\n }\n .user-msg-bubble a {\n color: inherit !important;\n text-decoration-color: rgba(255,255,255,0.6) !important;\n }\n .user-msg-bubble strong { color: inherit !important; }\n .user-msg-bubble em { color: inherit !important; opacity: 0.9; }\n .user-msg-bubble span { color: inherit !important; }\n .user-msg-bubble div { color: inherit !important; }\n .user-msg-bubble th, .user-msg-bubble td { color: inherit !important; }\n .user-msg-bubble table { border-color: rgba(255,255,255,0.2) !important; }\n .user-msg-bubble th { border-color: rgba(255,255,255,0.2) !important; }\n .user-msg-bubble td { border-color: rgba(255,255,255,0.15) !important; }\n .user-msg-bubble tr { background: transparent !important; }\n .user-msg-bubble thead tr { background: rgba(255,255,255,0.1) !important; }\n /* Selection visibility for user messages */\n .user-msg-bubble ::selection {\n background: rgba(255,255,255,0.35);\n color: inherit;\n }\n .user-msg-bubble ::-moz-selection {\n background: rgba(255,255,255,0.35);\n color: inherit;\n }\n "})]}):(0,n.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,n.jsxs)("div",{style:{textAlign:"center"},children:[(0,n.jsx)("div",{style:{fontSize:"var(--text-title3)",fontWeight:"var(--weight-semibold)",color:"var(--text-tertiary)"},children:"Start a conversation"}),(0,n.jsx)("div",{style:{fontSize:"var(--text-footnote)",color:"var(--text-quaternary)",marginTop:"var(--space-2)"},children:"Send a message or use /new to begin"})]})})}function T(e){let{attachments:t,onRemove:r}=e;return 0===t.length?null:(0,n.jsx)("div",{style:{display:"flex",gap:"var(--space-2)",padding:"var(--space-2) var(--space-3)",overflowX:"auto",overflowY:"hidden"},children:t.map((e,t)=>{var a,i;return(0,n.jsxs)("div",{style:{position:"relative",width:56,height:56,flexShrink:0,borderRadius:"var(--radius-sm)",overflow:"hidden",background:"var(--fill-tertiary)",border:"1px solid var(--separator)"},children:["image"===e.type?(0,n.jsx)("img",{src:e.url,alt:e.name||"Preview",style:{width:"100%",height:"100%",objectFit:"cover"}}):(0,n.jsxs)("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,padding:4},children:["audio"===e.type?(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,n.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,n.jsx)("circle",{cx:"18",cy:"16",r:"3"})]}):(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,n.jsx)("polyline",{points:"13 2 13 9 20 9"})]}),(0,n.jsx)("span",{style:{fontSize:8,color:"var(--text-quaternary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%",textAlign:"center"},children:(null==(i=e.name)||null==(a=i.split(".").pop())?void 0:a.toUpperCase())||e.type.toUpperCase()})]}),(0,n.jsx)("button",{onClick:()=>r(t),"aria-label":"Remove attachment",style:{position:"absolute",top:2,right:2,width:18,height:18,borderRadius:"50%",background:"rgba(0,0,0,0.6)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:11,lineHeight:1,padding:0},children:(0,n.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},t)})})}function M(e){let{open:t,progress:r,onDownload:a,onCancel:i}=e;if(!t)return null;let s=null!==r;return(0,n.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",zIndex:60,display:"flex",alignItems:"center",justifyContent:"center"},onClick:s?void 0:i,children:(0,n.jsxs)("div",{style:{background:"var(--bg)",borderRadius:"var(--radius-lg)",padding:"var(--space-6)",maxWidth:400,width:"90%",boxShadow:"var(--shadow-overlay)"},onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("div",{style:{width:48,height:48,borderRadius:"var(--radius-md)",background:"var(--fill-secondary)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"var(--space-4)"},children:(0,n.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),(0,n.jsx)("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),(0,n.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),(0,n.jsx)("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}),(0,n.jsx)("h3",{style:{fontSize:"var(--text-headline)",fontWeight:"var(--weight-bold)",color:"var(--text-primary)",marginBottom:"var(--space-2)"},children:"Enable voice input?"}),(0,n.jsx)("p",{style:{fontSize:"var(--text-body)",color:"var(--text-secondary)",marginBottom:"var(--space-5)",lineHeight:"var(--leading-relaxed)"},children:"This will download a speech recognition model (~500MB). Transcription runs locally on your server — no data leaves your network."}),s&&(0,n.jsxs)("div",{style:{marginBottom:"var(--space-5)"},children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"var(--space-2)",fontSize:"var(--text-footnote)",color:"var(--text-tertiary)"},children:[(0,n.jsx)("span",{children:"Downloading model…"}),(0,n.jsxs)("span",{children:[r,"%"]})]}),(0,n.jsx)("div",{style:{height:6,borderRadius:3,background:"var(--fill-tertiary)",overflow:"hidden"},children:(0,n.jsx)("div",{style:{height:"100%",width:"".concat(r,"%"),borderRadius:3,background:"var(--accent)",transition:"width 300ms ease"}})})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:"var(--space-3)",justifyContent:"flex-end"},children:[!s&&(0,n.jsx)("button",{onClick:i,style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--fill-tertiary)",color:"var(--text-primary)",border:"none",cursor:"pointer",fontSize:"var(--text-body)"},children:"Cancel"}),(0,n.jsx)("button",{onClick:a,disabled:s,style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:s?"var(--fill-tertiary)":"var(--accent)",color:s?"var(--text-tertiary)":"#000",border:"none",cursor:s?"default":"pointer",fontSize:"var(--text-body)",fontWeight:"var(--weight-semibold)"},children:s?"Downloading…":"Download"})]})]})})}function B(e){let{analyser:t,width:r=64,height:i=32,color:s="var(--system-red)"}=e,o=(0,a.useRef)(null),l=(0,a.useRef)(0);return(0,a.useEffect)(()=>{let e=o.current;if(!e||!t)return;let n=e.getContext("2d");if(!n)return;let a=t.frequencyBinCount,d=new Uint8Array(a),c=(r-22)/12;return!function e(){l.current=requestAnimationFrame(e),t.getByteFrequencyData(d),n.clearRect(0,0,r,i);for(let e=0;e<12;e++){let t=Math.max(3,d[Math.floor(e/12*(.6*a))]/255*i),r=e*(c+2),o=(i-t)/2;n.fillStyle=s,n.beginPath(),n.roundRect(r,o,c,t,1.5),n.fill()}}(),()=>{cancelAnimationFrame(l.current)}},[t,r,i,s]),(0,n.jsx)("canvas",{ref:o,width:r,height:i,style:{width:r,height:i,display:"block"}})}let E=[{name:"new",description:"Start a new chat session"},{name:"status",description:"Show current session info"}];async function A(e){let t,r=e.type.startsWith("image/"),n=e.type.startsWith("audio/");if(r)t=await new Promise((t,r)=>{let n=new Image,a=URL.createObjectURL(e);n.onload=()=>{URL.revokeObjectURL(a);let{width:i,height:s}=n;if(i>1200||s>1200){let e=1200/Math.max(i,s);i=Math.round(i*e),s=Math.round(s*e)}let o=document.createElement("canvas");o.width=i,o.height=s;let l=o.getContext("2d");if(!l)return void r(Error("no canvas context"));l.drawImage(n,0,0,i,s);let d=e.size>5e4?"image/jpeg":"image/png";t(o.toDataURL(d,"image/jpeg"===d?.85:void 0))},n.onerror=()=>{URL.revokeObjectURL(a),r(Error("image load failed"))},n.src=a});else t=await new Promise((t,r)=>{let n=new FileReader;n.onloadend=()=>t(n.result),n.onerror=r,n.readAsDataURL(e)});return{type:r?"image":n?"audio":"file",url:t,name:e.name,mimeType:e.type,size:t.length}}function U(e){let{disabled:t,loading:r,onSend:i,onInterrupt:o,onNewSession:l,onStatusRequest:d,skillsVersion:c,events:u}=e,[p,h]=(0,a.useState)(""),[g,v]=(0,a.useState)([]),[x,m]=(0,a.useState)(!1),[y,f]=(0,a.useState)(""),[b,j]=(0,a.useState)(0),[k,w]=(0,a.useState)(E),[S,C]=(0,a.useState)(!1),[I,R]=(0,a.useState)(""),[L,W]=(0,a.useState)(0),[z,D]=(0,a.useState)([]),U=(0,a.useRef)(null),N=(0,a.useRef)(null),F=(0,a.useRef)(new Map),H=function(e,t){let[r,n]=(0,a.useState)("idle"),[i,o]=(0,a.useState)(null),[l,d]=(0,a.useState)(null),[c,u]=(0,a.useState)(null),[p,h]=(0,a.useState)(["en"]),[g,v]=(0,a.useState)(null),[x,m]=(0,a.useState)(()=>localStorage.getItem("stt-language")||"en"),y=(0,a.useRef)(x);y.current=x;let f=(0,a.useRef)(null),b=(0,a.useRef)(null),j=(0,a.useRef)(null),k=(0,a.useRef)([]),w=(0,a.useRef)(null),S=(0,a.useRef)(null),C=(0,a.useRef)(t);C.current=t,(0,a.useEffect)(()=>{if(!e||0===e.length)return;let t=e[e.length-1];if(!t.event.startsWith("stt:"))return;let r=t.payload;"stt:download:progress"===t.event&&d(Number(r.progress)||0),"stt:download:complete"===t.event&&(d(null),o(!0),n("idle")),"stt:download:error"===t.event&&(d(null),n("idle"))},[e]);let I=(0,a.useCallback)(()=>{var e,t;null==(e=j.current)||e.getTracks().forEach(e=>e.stop()),j.current=null,null==(t=b.current)||t.close().catch(()=>{}),b.current=null,u(null),f.current=null},[]);(0,a.useEffect)(()=>()=>{var e,t,r;w.current&&clearTimeout(w.current),(null==(e=f.current)?void 0:e.state)==="recording"&&f.current.stop(),null==(t=j.current)||t.getTracks().forEach(e=>e.stop()),null==(r=b.current)||r.close().catch(()=>{})},[]);let R=(0,a.useCallback)(async()=>{try{var e;let t=await s.F.sttStatus();return o(t.available),t.downloading&&d(t.progress),(null==(e=t.languages)?void 0:e.length)>0&&(h(t.languages),m(e=>{if(!t.languages.includes(e)){let e=t.languages[0];return localStorage.setItem("stt-language",e),e}return e})),t.available}catch(e){return o(!1),!1}},[]),L=(0,a.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});j.current=e;let t=new AudioContext;b.current=t;let r=t.createMediaStreamSource(e),a=t.createAnalyser();a.fftSize=128,r.connect(a),u(a);let i=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",o=new MediaRecorder(e,i?{mimeType:i}:void 0);f.current=o,k.current=[],o.ondataavailable=e=>{e.data.size>0&&k.current.push(e.data)},o.onstop=async()=>{I(),n("transcribing");let e=new Blob(k.current,{type:o.mimeType||"audio/webm"});if(k.current=[],0===e.size){var t;n("idle"),null==(t=S.current)||t.call(S,null),S.current=null;return}try{let t=(await s.F.sttTranscribe(e,y.current)).text||null;n("idle"),v(null),S.current?(S.current(t),S.current=null):t&&C.current&&C.current(t)}catch(t){let e=t instanceof Error?t.message:"Transcription failed";v(e),n("error"),S.current&&(S.current(null),S.current=null)}},o.start(5e3),n("recording"),w.current=setTimeout(()=>{var e;(null==(e=f.current)?void 0:e.state)==="recording"&&f.current.stop()},18e5)}catch(e){I(),n("idle")}},[I]),W=(0,a.useCallback)(async()=>{"recording"!==r&&"transcribing"!==r&&("error"===r&&(v(null),n("idle")),await R()?await L():n("no-model"))},[r,R,L]),z=(0,a.useCallback)(async()=>{await L()},[L]),D=(0,a.useCallback)(async()=>f.current&&"inactive"!==f.current.state?(w.current&&(clearTimeout(w.current),w.current=null),new Promise(e=>{var t;S.current=e,(null==(t=f.current)?void 0:t.state)==="recording"?f.current.stop():(I(),n("idle"),S.current=null,e(null))})):(n("idle"),null),[I]),T=(0,a.useCallback)(()=>{var e;w.current&&(clearTimeout(w.current),w.current=null),(null==(e=f.current)?void 0:e.state)==="recording"&&f.current.stop(),I(),k.current=[],n("idle")},[I]),M=(0,a.useCallback)(()=>{d(0),s.F.sttDownload().catch(()=>{d(null)})},[]),B=(0,a.useCallback)(()=>{n("idle"),d(null)},[]),E=(0,a.useCallback)(()=>{n("idle"),v(null)},[]),A=(0,a.useCallback)(()=>{m(e=>{let t=p.indexOf(e),r=p[(t+1)%p.length];return localStorage.setItem("stt-language",r),r})},[p]);return{state:r,available:i,downloadProgress:l,analyser:c,languages:p,selectedLanguage:x,error:g,cycleLanguage:A,handleMicClick:W,startRecording:z,stopRecording:D,cancelRecording:T,startDownload:M,dismissDownload:B,dismissError:E}}(u,e=>{e&&h(t=>t?t+" "+e:e)});(0,a.useEffect)(()=>{s.F.getOrg().then(async e=>{let t=e.employees;Array.isArray(t)&&v(await Promise.all(t.map(async e=>{try{let t=await s.F.getEmployee(e);return{name:t.name,displayName:t.displayName,department:t.department,rank:t.rank,engine:t.engine}}catch(t){return{name:e}}})))}).catch(()=>{})},[]),(0,a.useEffect)(()=>{s.F.getSkills().then(e=>{if(!Array.isArray(e))return;let t=e.filter(e=>!E.some(t=>t.name===e.name)).map(e=>({name:e.name,description:e.description||"",needsEmployee:"sync"===e.name}));w([...E,...t])}).catch(()=>{})},[c]);let O=(0,a.useCallback)(e=>{var t;let r=p.lastIndexOf("@");-1!==r&&h(p.slice(0,r)+"@"+e+" "),m(!1),null==(t=U.current)||t.focus()},[p]),P=(0,a.useCallback)(e=>{var t;e.needsEmployee?(h("/"+e.name+" @"),C(!1),f(""),j(0),m(!0)):(h("/"+e.name),C(!1)),null==(t=U.current)||t.focus()},[]);function V(){let e=p.trim(),r=z.length>0;if(!e&&!r||t)return;if("/new"===e){h(""),l();return}if("/status"===e){h(""),d();return}let n=r?[...z]:void 0;h(""),D([]),m(!1),C(!1),U.current&&(U.current.style.height="auto"),i(e,n,!1)}async function q(e){let t=e.target.files;if(!t||0===t.length)return;let r=[];for(let e=0;e<t.length;e++)r.push(await A(t[e]));D(e=>[...e,...r]),e.target.value=""}async function J(e){var t;let r=null==(t=e.clipboardData)?void 0:t.items;if(r){for(let t=0;t<r.length;t++)if(r[t].type.startsWith("image/")){e.preventDefault();let n=r[t].getAsFile();if(n){let e=await A(n);D(t=>[...t,e])}return}}}let _=(0,a.useCallback)(e=>{e&&h(t=>t?t+" "+e:e)},[]);async function K(){if("recording"===H.state){var e;let t=await H.stopRecording();_(null!=t?t:""),null==(e=U.current)||e.focus()}else"transcribing"===H.state||H.handleMicClick()}(0,a.useEffect)(()=>{U.current&&(U.current.style.height="auto",U.current.style.height=Math.min(U.current.scrollHeight,120)+"px")},[p]);let Y=k.filter(e=>e.name.toLowerCase().startsWith(I)),X=g.filter(e=>e.name.toLowerCase().includes(y)),G=p.trim().length>0||z.length>0;return(0,n.jsxs)("div",{className:"px-3 sm:px-4",style:{paddingTop:"var(--space-3)",paddingBottom:"var(--space-3)",borderTop:"1px solid var(--separator)",background:"var(--material-regular)",flexShrink:0,position:"relative"},children:[S&&Y.length>0&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"100%",left:"var(--space-4)",right:"var(--space-4)",marginBottom:4,background:"var(--bg)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-lg)",maxHeight:240,overflowY:"auto",zIndex:10},children:Y.map((e,t)=>{let r=t===L;return(0,n.jsxs)("button",{ref:e=>{r&&e&&e.scrollIntoView({block:"nearest"})},onClick:()=>P(e),style:{width:"100%",textAlign:"left",padding:"var(--space-2) var(--space-3)",fontSize:"var(--text-footnote)",background:r?"var(--fill-secondary)":"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"var(--space-2)",color:"var(--text-primary)"},children:[(0,n.jsxs)("span",{style:{fontFamily:"var(--font-mono)",fontWeight:"var(--weight-semibold)",color:"var(--accent)",fontSize:"var(--text-footnote)"},children:["/",e.name]}),(0,n.jsx)("span",{style:{color:"var(--text-tertiary)",fontSize:"var(--text-caption1)"},children:e.description})]},e.name)})}),x&&X.length>0&&(0,n.jsx)("div",{style:{position:"absolute",bottom:"100%",left:"var(--space-4)",right:"var(--space-4)",marginBottom:4,background:"var(--bg)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-lg)",maxHeight:160,overflowY:"auto",zIndex:10},children:X.slice(0,8).map((e,t)=>{let r=t===b;return(0,n.jsxs)("button",{ref:e=>{e?F.current.set(t,e):F.current.delete(t),r&&e&&e.scrollIntoView({block:"nearest"})},onClick:()=>O(e.name),style:{width:"100%",textAlign:"left",padding:"var(--space-2) var(--space-3)",fontSize:"var(--text-footnote)",background:r?"var(--fill-secondary)":"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"var(--space-2)",color:"var(--text-primary)"},children:[(0,n.jsx)("span",{style:{fontSize:16,lineHeight:1},children:{executive:"\uD83C\uDFAF",manager:"\uD83D\uDCCB",senior:"⭐",employee:"\uD83D\uDC64"}[e.rank||"employee"]||"\uD83D\uDC64"}),(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[(0,n.jsx)("span",{style:{fontWeight:"var(--weight-semibold)"},children:e.displayName||e.name}),(0,n.jsxs)("span",{style:{fontFamily:"var(--font-mono)",fontSize:"var(--text-caption2)",color:"var(--text-tertiary)"},children:["@",e.name]})]}),e.department&&(0,n.jsxs)("div",{style:{fontSize:"var(--text-caption2)",color:"var(--text-quaternary)",display:"flex",gap:"var(--space-2)",marginTop:1},children:[(0,n.jsx)("span",{children:e.department}),e.engine&&(0,n.jsx)("span",{style:{color:"var(--accent)",fontWeight:"var(--weight-medium)"},children:e.engine})]})]})]},e.name)})}),z.length>0&&(0,n.jsx)("div",{style:{marginBottom:"var(--space-2)"},children:(0,n.jsx)(T,{attachments:z,onRemove:function(e){D(t=>t.filter((t,r)=>r!==e))}})}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",background:"var(--fill-secondary)",borderRadius:"var(--radius-lg)",padding:"6px var(--space-3)",border:r?"1px solid var(--accent)":"1px solid var(--separator)",minHeight:44,transition:"border-color 200ms ease"},children:[(0,n.jsx)("button",{"aria-label":"Attach file",onClick:()=>{var e;return null==(e=N.current)?void 0:e.click()},style:{width:32,height:32,flexShrink:0,borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-secondary)",marginBottom:0},children:(0,n.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),(0,n.jsx)("input",{ref:N,type:"file",accept:"image/*,audio/*,.pdf,.doc,.docx,.txt,.csv,.json,.zip",multiple:!0,style:{display:"none"},onChange:q}),(0,n.jsx)("textarea",{ref:U,value:p,onChange:function(e){let t=e.target.value;if(h(t),t.startsWith("/")&&!t.includes(" ")){R(t.slice(1).toLowerCase()),W(0),C(!0),m(!1);return}C(!1);let r=t.lastIndexOf("@");if(-1!==r){let e=t.slice(r+1);if(!e.includes(" ")&&!e.includes("\n")){f(e.toLowerCase()),j(0),m(!0);return}}m(!1)},onKeyDown:function(e){if(S&&Y.length>0){let t=Y.length;if("ArrowDown"===e.key){e.preventDefault(),W(e=>(e+1)%t);return}if("ArrowUp"===e.key){e.preventDefault(),W(e=>(e-1+t)%t);return}if("Tab"===e.key||"Enter"===e.key){e.preventDefault(),P(Y[L]);return}if("Escape"===e.key){e.preventDefault(),C(!1);return}}if(x&&X.length>0){let t=Math.min(X.length,8);if("ArrowDown"===e.key){e.preventDefault(),j(e=>(e+1)%t);return}if("ArrowUp"===e.key){e.preventDefault(),j(e=>(e-1+t)%t);return}if("Tab"===e.key||"Enter"===e.key){e.preventDefault(),O(X[b].name);return}if("Escape"===e.key){e.preventDefault(),m(!1);return}}"Enter"!==e.key||e.shiftKey||(e.preventDefault(),V())},onPaste:J,placeholder:t?"Waiting for response...":"Type a message...",rows:1,disabled:t,style:{flex:1,background:"transparent",border:"none",outline:"none",resize:"none",color:"var(--text-primary)",fontSize:"var(--text-subheadline)",lineHeight:"20px",maxHeight:120,minHeight:20,height:20,padding:0,margin:0,opacity:t?.5:1},onInput:e=>{let t=e.target;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,120)+"px"}}),H.languages.length>1&&(0,n.jsx)("button",{"aria-label":"STT language: ".concat(H.selectedLanguage.toUpperCase(),". Click to switch."),onClick:H.cycleLanguage,style:{height:24,padding:"0 6px",flexShrink:0,borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--fill-tertiary)",border:"none",cursor:"pointer",color:"var(--text-secondary)",fontSize:11,fontWeight:600,fontFamily:"var(--font-mono)",letterSpacing:"0.5px",textTransform:"uppercase",transition:"all 150ms ease"},title:"Transcription language: ".concat(H.selectedLanguage.toUpperCase(),". Click to cycle."),children:H.selectedLanguage}),(0,n.jsx)("button",{"aria-label":"recording"===H.state?"Stop recording":"transcribing"===H.state?"Transcribing…":"Voice input",onClick:K,disabled:"transcribing"===H.state,style:{width:32,height:32,flexShrink:0,borderRadius:"recording"===H.state?"999px":"var(--radius-sm)",display:"flex",alignItems:"center",justifyContent:"center",background:"recording"===H.state?"var(--system-red)":"transparent",border:"none",cursor:"transcribing"===H.state?"wait":"pointer",color:"recording"===H.state?"#fff":"var(--text-secondary)",transition:"all 150ms ease"},title:"recording"===H.state?"Stop recording":"transcribing"===H.state?"Transcribing…":"Voice input",children:"transcribing"===H.state?(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{animation:"stt-spin 1s linear infinite"},children:(0,n.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})}):(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),(0,n.jsx)("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),(0,n.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),(0,n.jsx)("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}),"recording"===H.state&&H.analyser&&(0,n.jsx)(B,{analyser:H.analyser,width:64,height:28}),r&&o&&(0,n.jsx)("button",{onClick:o,"aria-label":"Stop",style:{width:32,height:32,borderRadius:"50%",background:"var(--system-red)",color:"#fff",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 150ms ease"},children:(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),(0,n.jsx)("button",{onClick:V,disabled:!G||t,"aria-label":"Send message",style:{width:32,height:32,borderRadius:"50%",background:G?"var(--accent)":"var(--fill-tertiary)",color:G?"var(--accent-contrast)":"var(--text-quaternary)",border:"none",cursor:G?"pointer":"default",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 150ms ease"},children:(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),(0,n.jsx)("polyline",{points:"5 12 12 5 19 12"})]})})]}),(0,n.jsxs)("div",{className:"hidden sm:flex",style:{fontSize:"var(--text-caption2)",color:"var(--text-quaternary)",textAlign:"center",marginTop:"var(--space-1)",justifyContent:"center",gap:"var(--space-3)"},children:[(0,n.jsx)("span",{children:"Enter to send"}),(0,n.jsx)("span",{children:"/ - commands"}),(0,n.jsx)("span",{children:"@name - mention"})]}),"error"===H.state&&H.error&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",marginTop:"var(--space-2)",padding:"var(--space-2) var(--space-3)",background:"color-mix(in srgb, var(--system-red) 12%, transparent)",borderRadius:"var(--radius-sm)",fontSize:"var(--text-caption1)",color:"var(--system-red)"},children:[(0,n.jsxs)("span",{style:{flex:1},children:["Voice input error: ",H.error]}),(0,n.jsx)("button",{onClick:H.dismissError,style:{background:"none",border:"none",cursor:"pointer",color:"var(--system-red)",fontSize:"var(--text-caption1)",fontWeight:600,padding:"2px 6px"},children:"Dismiss"})]}),(0,n.jsx)(M,{open:"no-model"===H.state,progress:H.downloadProgress,onDownload:H.startDownload,onCancel:H.dismissDownload}),(0,n.jsx)("style",{children:"\n @keyframes stt-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n "})]})}function N(){return(0,n.jsx)(a.Suspense,{fallback:(0,n.jsx)(l.M,{children:(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--text-tertiary)"},children:"Loading..."})}),children:(0,n.jsx)(F,{})})}function F(){var e;let{settings:t}=(0,d.t0)(),r=null!=(e=t.portalName)?e:"Jinn",[c,u]=(0,a.useState)(null),[p,h]=(0,a.useState)([]),[g,v]=(0,a.useState)(!1),[f,b]=(0,a.useState)(0),[j,k]=(0,a.useState)("sidebar"),[w,S]=(0,a.useState)(null),C=(0,a.useRef)(""),[I,R]=(0,a.useState)(""),L=(0,a.useRef)(-1),W=(0,a.useRef)(!1),[z,T]=(0,a.useState)(!1),[M,B]=(0,a.useState)(null),[E,A]=(0,a.useState)(!1),N=(0,a.useRef)(null),{events:F,connectionSeq:H,skillsVersion:O}=(0,o.G)(),P=(0,i.useSearchParams)(),V=(0,a.useRef)(!1),q=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(z)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){N.current&&!N.current.contains(e.target)&&T(!1)}},[z]);let J=(0,a.useCallback)((e,t)=>{navigator.clipboard.writeText(e),B(t),T(!1),setTimeout(()=>B(null),1500)},[]);function _(){s.F.createStubSession({greeting:"Hey! \uD83D\uDC4B Say hi when you're ready to get started.",title:"Welcome"}).then(e=>{let t=String(e.id);q.current=!0,u(t),b(e=>e+1)}).catch(()=>{})}(0,a.useEffect)(()=>{V.current||("1"===P.get("onboarding")?(V.current=!0,_()):s.F.getOnboarding().then(e=>{e.needed&&!V.current&&(V.current=!0,_())}).catch(()=>{}))},[P]);let K=(0,a.useCallback)((e,t)=>{if(!t)return;let r=L.current;if(r<0)return;let n=e.slice(r);n.length>0&&function(e,t){try{localStorage.setItem("".concat(m).concat(e),JSON.stringify(t))}catch(e){}}(t,n)},[]);(0,a.useEffect)(()=>{if(0===F.length)return;let e=F[F.length-1],t=e.payload;if(c&&t.sessionId===c){if("session:delta"===e.event){let e=String(t.type||"text");if("text"===e){let e=String(t.content||"");C.current+=e,R(C.current)}else if("tool_use"===e){if(C.current){let e=C.current;C.current="",R(""),h(r=>{L.current<0&&(L.current=r.length);let n=[...r,{id:crypto.randomUUID(),role:"assistant",content:e,timestamp:Date.now()}];return K(n,c||t.sessionId),n})}let e=String(t.toolName||"tool");h(r=>{L.current<0&&(L.current=r.length);let n=[...r,{id:crypto.randomUUID(),role:"assistant",content:"Using ".concat(e),timestamp:Date.now(),toolCall:e}];return K(n,c||t.sessionId),n})}else"tool_result"===e&&h(e=>{let r=[...e],n=r[r.length-1];return n&&"assistant"===n.role&&n.toolCall&&(r[r.length-1]={...n,content:"Used ".concat(n.toolCall)}),K(r,c||t.sessionId),r})}if("session:interrupted"===e.event&&(C.current="",R("")),"session:completed"===e.event){C.current="",R(""),v(!1),L.current=-1;let e=c||(t.sessionId?String(t.sessionId):null);e&&y(e),t.result&&h(e=>{let r=[...e],n=r[r.length-1];return n&&"assistant"===n.role&&!n.toolCall&&r.pop(),[...r,{id:crypto.randomUUID(),role:"assistant",content:String(t.result),timestamp:Date.now()}]}),t.error&&!t.result&&h(e=>[...e,{id:crypto.randomUUID(),role:"assistant",content:"Error: ".concat(t.error),timestamp:Date.now()}]),b(e=>e+1)}}},[F,c,K]);let Y=(0,a.useCallback)(async e=>{try{let t=await s.F.getSession(e);S({engine:t.engine?String(t.engine):void 0,engineSessionId:t.engineSessionId?String(t.engineSessionId):void 0,model:t.model?String(t.model):void 0,title:t.title?String(t.title):void 0,employee:t.employee?String(t.employee):void 0});let r=t.messages||t.history||[],n=Array.isArray(r)?r.map(e=>({id:crypto.randomUUID(),role:e.role||"assistant",content:String(e.content||e.text||""),timestamp:e.timestamp?Number(e.timestamp):Date.now()})):[];if("error"===t.status&&t.lastError){let e=n[n.length-1],r="Error: ".concat(String(t.lastError));e&&"assistant"===e.role&&e.content===r||n.push({id:crypto.randomUUID(),role:"assistant",content:r,timestamp:Date.now()})}if("running"===t.status){let t=function(e){try{let t=localStorage.getItem("".concat(m).concat(e));return t?JSON.parse(t):[]}catch(e){return[]}}(e);t.length>0?(L.current=n.length,h([...n,...t])):(L.current=n.length,h(n)),v(!0)}else y(e),L.current=-1,h(n)}catch(e){h([]),S(null),L.current=-1}},[]);(0,a.useEffect)(()=>{H&&c&&Y(c)},[H,c,Y]),(0,a.useEffect)(()=>{if(!c||!g)return;let e=setInterval(async()=>{try{let e=await s.F.getSession(c);"running"!==e.status&&(await Y(c),v(!1))}catch(e){}},5e3);return()=>clearInterval(e)},[c,g,Y]);let X=(0,a.useCallback)(e=>{W.current=!1,u(e),h([]),v(!1),k("chat"),Y(e)},[Y]),G=(0,a.useCallback)(()=>{W.current=!0,u(null),h([]),v(!1),S(null),k("chat"),L.current=-1},[]),$=(0,a.useCallback)(e=>{c||V.current||W.current||!(e.length>0)||X(e[0].id)},[c,X]),Q=(0,a.useCallback)(async()=>{if(c)try{await s.F.sendMessage(c,{message:"",interrupt:!0})}catch(e){}},[c]),Z=(0,a.useCallback)(async(e,t,n)=>{let a={id:crypto.randomUUID(),role:"user",content:e,timestamp:Date.now(),media:t};h(e=>(L.current=e.length+1,[...e,a])),v(!0);try{let t=c;if(t&&q.current){q.current=!1;let n="This is your first time being activated. The user just set up ".concat(r," and opened the web dashboard for the first time.\n\nRead your CLAUDE.md instructions and the onboarding skill at ~/.jinn/skills/onboarding/SKILL.md, then follow the onboarding flow:\n- Greet the user warmly and introduce yourself as ").concat(r,"\n- Briefly explain what you can do (manage cron jobs, hire AI employees, connect to Slack, etc.)\n- Ask the user what they'd like to set up first\n\nThe user said: \"").concat(e,'"');await s.F.sendMessage(t,{message:n}),b(e=>e+1)}else if(t)await s.F.sendMessage(t,{message:e,interrupt:n||void 0}),b(e=>e+1);else{let r=await s.F.createSession({source:"web",prompt:e});t=String(r.id),u(t),b(e=>e+1)}}catch(e){v(!1),h(t=>[...t,{id:crypto.randomUUID(),role:"assistant",content:"Error: ".concat(e instanceof Error?e.message:"Failed to send message"),timestamp:Date.now()}])}},[c,r]),ee=(0,a.useCallback)(async e=>{try{await s.F.deleteSession(e),c===e&&(u(null),h([]),v(!1),S(null),C.current="",R(""),L.current=-1),y(e),b(e=>e+1)}catch(e){}A(!1),T(!1)},[c]),et=(0,a.useCallback)(async()=>{if(!c)return void h(e=>[...e,{id:crypto.randomUUID(),role:"assistant",content:"No active session. Send a message to start one.",timestamp:Date.now()}]);try{let e=await s.F.getSession(c),t=["**Session Info**","ID: `".concat(e.id,"`"),"Status: ".concat(e.status||"unknown"),e.employee?"Employee: ".concat(e.employee):null,e.engine?"Engine: ".concat(e.engine):null,e.model?"Model: ".concat(e.model):null,e.createdAt?"Created: ".concat(e.createdAt):null].filter(Boolean).join("\n");h(e=>[...e,{id:crypto.randomUUID(),role:"assistant",content:t,timestamp:Date.now()}])}catch(e){h(e=>[...e,{id:crypto.randomUUID(),role:"assistant",content:"Failed to fetch session status.",timestamp:Date.now()}])}},[c]);return(0,n.jsxs)(l.M,{children:[(0,n.jsxs)("div",{className:"h-[calc(100%-48px)] lg:h-full",style:{display:"flex",overflow:"hidden"},children:[(0,n.jsx)("div",{className:"hidden lg:block",style:{width:280,flexShrink:0,height:"100%"},children:(0,n.jsx)(x,{selectedId:c,onSelect:X,onNewChat:G,onDelete:ee,refreshKey:f,connectionSeq:H,onSessionsLoaded:$,events:F})}),(0,n.jsx)("div",{className:"sidebar"===j?"block lg:hidden":"hidden",style:{width:"100%",height:"100%"},children:(0,n.jsx)(x,{selectedId:c,onSelect:X,onNewChat:G,onDelete:ee,refreshKey:f,connectionSeq:H,onSessionsLoaded:$,events:F})}),(0,n.jsxs)("div",{style:{flex:1,flexDirection:"column",height:"100%",background:"var(--bg)",minWidth:0,overflow:"hidden"},className:"sidebar"===j?"hidden lg:flex":"flex",children:[(0,n.jsxs)("div",{style:{height:52,display:"flex",alignItems:"center",padding:"0 var(--space-4)",borderBottom:"1px solid var(--separator)",background:"var(--material-thick)",flexShrink:0},children:[(0,n.jsxs)("button",{className:"flex lg:hidden",onClick:()=>k("sidebar"),"aria-label":"Back to sessions",style:{padding:"var(--space-1) var(--space-2)",borderRadius:"var(--radius-sm)",marginRight:"var(--space-2)",fontSize:"var(--text-subheadline)",alignItems:"center",gap:"var(--space-1)",background:"transparent",border:"none",cursor:"pointer",color:"var(--accent)"},children:[(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"15 18 9 12 15 6"})}),"Back"]}),(0,n.jsx)("div",{style:{flex:1,minWidth:0},children:(0,n.jsx)("div",{style:{fontSize:"var(--text-subheadline)",fontWeight:"var(--weight-semibold)",color:"var(--text-primary)",letterSpacing:"-0.2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c?(null==w?void 0:w.title)||(null==w?void 0:w.employee)||r:"New Chat"})}),M&&(0,n.jsx)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--accent)",marginRight:"var(--space-2)",whiteSpace:"nowrap"},children:"Copied!"}),c&&(0,n.jsxs)("div",{ref:N,style:{position:"relative"},children:[(0,n.jsx)("button",{onClick:()=>T(e=>!e),"aria-label":"More options",style:{background:"transparent",border:"none",cursor:"pointer",padding:"var(--space-1)",borderRadius:"var(--radius-sm)",color:"var(--text-secondary)",display:"flex",alignItems:"center",transition:"color 150ms ease"},onMouseEnter:e=>e.currentTarget.style.color="var(--text-primary)",onMouseLeave:e=>e.currentTarget.style.color="var(--text-secondary)",children:(0,n.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,n.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,n.jsx)("circle",{cx:"12",cy:"19",r:"2"})]})}),z&&(0,n.jsxs)("div",{style:{position:"absolute",top:"100%",right:0,marginTop:4,background:"var(--material-thick)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:100,minWidth:200,overflow:"hidden"},children:[(0,n.jsx)("button",{onClick:()=>J(c,"id"),style:{display:"block",width:"100%",padding:"var(--space-2) var(--space-3)",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",fontSize:"var(--text-subheadline)",color:"var(--text-primary)"},onMouseEnter:e=>e.currentTarget.style.background="var(--fill-tertiary)",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:"Copy Session ID"}),(null==w?void 0:w.engineSessionId)&&(0,n.jsx)("button",{onClick:()=>{let e="codex"===w.engine?"codex":"claude";J("".concat(e," --resume ").concat(w.engineSessionId),"cli")},style:{display:"block",width:"100%",padding:"var(--space-2) var(--space-3)",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",fontSize:"var(--text-subheadline)",color:"var(--text-primary)"},onMouseEnter:e=>e.currentTarget.style.background="var(--fill-tertiary)",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:"Copy CLI Resume Command"}),(0,n.jsx)("div",{style:{borderTop:"1px solid var(--separator)",margin:"2px 0"}}),(0,n.jsxs)("button",{onClick:()=>{T(!1),A(!0)},style:{display:"flex",alignItems:"center",gap:"var(--space-2)",width:"100%",padding:"var(--space-2) var(--space-3)",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",fontSize:"var(--text-subheadline)",color:"var(--system-red)"},onMouseEnter:e=>e.currentTarget.style.background="var(--fill-tertiary)",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,n.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),"Delete Session"]})]})]})]}),(0,n.jsx)(D,{messages:p,loading:g,streamingText:I}),(0,n.jsx)(U,{disabled:!1,loading:g,onSend:Z,onInterrupt:Q,onNewSession:G,onStatusRequest:et,skillsVersion:O,events:F})]})]}),E&&c&&(0,n.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",zIndex:60,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>A(!1),children:(0,n.jsxs)("div",{style:{background:"var(--bg)",borderRadius:"var(--radius-lg)",padding:"var(--space-6)",maxWidth:400,width:"90%",boxShadow:"var(--shadow-overlay)"},onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h3",{style:{fontSize:"var(--text-headline)",fontWeight:"var(--weight-bold)",color:"var(--text-primary)",marginBottom:"var(--space-2)"},children:"Delete Session?"}),(0,n.jsx)("p",{style:{fontSize:"var(--text-body)",color:"var(--text-secondary)",marginBottom:"var(--space-5)"},children:"This will permanently delete the session and all its messages."}),(0,n.jsxs)("div",{style:{display:"flex",gap:"var(--space-3)",justifyContent:"flex-end"},children:[(0,n.jsx)("button",{onClick:()=>A(!1),style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--fill-tertiary)",color:"var(--text-primary)",border:"none",cursor:"pointer",fontSize:"var(--text-body)"},children:"Cancel"}),(0,n.jsx)("button",{onClick:()=>ee(c),style:{padding:"var(--space-2) var(--space-4)",borderRadius:"var(--radius-md)",background:"var(--system-red)",color:"#fff",border:"none",cursor:"pointer",fontSize:"var(--text-body)",fontWeight:"var(--weight-semibold)"},children:"Delete"})]})]})})]})}},7906:(e,t,r)=>{Promise.resolve().then(r.bind(r,3095))}},e=>{e.O(0,[282,700,814,743,358],()=>e(e.s=7906)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[783],{667:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>j});var a=r(8111),n=r(3073),s=r(5271),o=r(6059),l=r(3176);let i={"claude-sonnet-4-6":{inputPer1M:3,outputPer1M:15},"claude-sonnet-4-5":{inputPer1M:3,outputPer1M:15},"claude-haiku-4-5":{inputPer1M:.8,outputPer1M:4},"claude-opus-4-6":{inputPer1M:15,outputPer1M:75},"claude-3-5-sonnet":{inputPer1M:3,outputPer1M:15},"claude-3-5-haiku":{inputPer1M:.8,outputPer1M:4},"claude-3-haiku":{inputPer1M:.25,outputPer1M:1.25}},d={inputPer1M:3,outputPer1M:15};function c(e){if(i[e])return i[e];for(let t of Object.keys(i))if(e.startsWith(t))return i[t];return d}function u(e){if(0===e.length)return 0;let t=[...e].sort((e,t)=>e-t),r=Math.floor(t.length/2);return t.length%2!=0?t[r]:(t[r-1]+t[r])/2}function p(e){return e<.01&&e>0?"<$0.01":"$".concat(e.toFixed(2))}function h(e){return e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):String(e)}function m(e){let{label:t,children:r}=e;return(0,a.jsxs)("div",{style:{background:"var(--material-regular)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",padding:"var(--space-4)"},children:[(0,a.jsx)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",fontWeight:500,marginBottom:"var(--space-1)"},children:t}),r]})}function g(e){let{dailyCosts:t}=e,r=(0,s.useRef)(null),n=(0,s.useRef)(null),o=(0,s.useCallback)(()=>{let e=r.current,a=n.current;if(!e||!a||0===t.length)return;let s=window.devicePixelRatio||1,o=a.getBoundingClientRect().width;e.width=o*s,e.height=220*s,e.style.width="".concat(o,"px"),e.style.height="".concat(220,"px");let l=e.getContext("2d");if(!l)return;l.scale(s,s);let i=getComputedStyle(document.documentElement),d=i.getPropertyValue("--text-tertiary").trim()||"#888",c=i.getPropertyValue("--separator").trim()||"#333",u=i.getPropertyValue("--accent").trim()||"#007AFF",p=o-50-12,h=Math.max(...t.map(e=>e.cost),.01),m=Math.max(6,Math.min(40,(p-2*t.length)/t.length));for(let e of(l.clearRect(0,0,o,220),l.font="9px -apple-system, sans-serif",l.textAlign="right",[0,.25*h,.5*h,.75*h,h])){let t=192-e/h*180;l.strokeStyle=c,l.lineWidth=.5,l.beginPath(),l.moveTo(50,t),l.lineTo(o-12,t),l.stroke(),l.fillStyle=d,l.fillText("$".concat(e.toFixed(2)),44,t+3)}for(let e=0;e<t.length;e++){let r=t[e],a=r.cost/h*180,n=50+e*(m+2),s=192-a;l.fillStyle=u,l.globalAlpha=.8;let o=Math.max(1,a);l.beginPath(),l.moveTo(n+2,s),l.lineTo(n+m-2,s),l.quadraticCurveTo(n+m,s,n+m,s+2),l.lineTo(n+m,s+o),l.lineTo(n,s+o),l.lineTo(n,s+2),l.quadraticCurveTo(n,s,n+2,s),l.closePath(),l.fill(),l.globalAlpha=1,(0===e||e===t.length-1||e%7==0)&&(l.fillStyle=d,l.textAlign="center",l.font="8px -apple-system, sans-serif",l.fillText(r.date.slice(5),n+m/2,214))}},[t]);return((0,s.useEffect)(()=>(o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)),[o]),0===t.length)?null:(0,a.jsxs)("div",{ref:n,style:{background:"var(--material-regular)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",padding:"var(--space-4)"},children:[(0,a.jsx)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",fontWeight:500,marginBottom:"var(--space-3)"},children:"Daily Estimated Cost"}),(0,a.jsx)("canvas",{ref:r,style:{display:"block",width:"100%"}})]})}function x(e){let{breakdown:t}=e;if(0===t.length)return null;let r=["var(--system-blue)","var(--system-green)","var(--accent)","var(--system-orange)","var(--system-purple)"];return(0,a.jsxs)("div",{style:{background:"var(--material-regular)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",padding:"var(--space-4)"},children:[(0,a.jsx)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",fontWeight:500,marginBottom:"var(--space-3)"},children:"Model Breakdown"}),(0,a.jsx)("div",{style:{display:"flex",height:20,borderRadius:"var(--radius-sm)",overflow:"hidden",marginBottom:"var(--space-3)"},children:t.map((e,t)=>(0,a.jsx)("div",{style:{width:"".concat(e.pct,"%"),background:r[t%r.length],minWidth:2*(e.pct>0)}},e.model))}),(0,a.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--space-2)",fontSize:"var(--text-caption1)"},children:t.map((e,t)=>(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,a.jsx)("span",{style:{width:8,height:8,borderRadius:2,background:r[t%r.length],flexShrink:0}}),(0,a.jsx)("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:e.model}),(0,a.jsxs)("span",{style:{color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums"},children:[e.pct.toFixed(0),"% (",h(e.tokens),")"]})]},e.model))})]})}function v(e){let{jobCosts:t,jobName:r}=e,[n,o]=(0,s.useState)("totalCost"),[l,i]=(0,s.useState)("desc"),d=e=>{n===e?i(e=>"asc"===e?"desc":"asc"):(o(e),i("desc"))},c=[...t].sort((e,t)=>{let a=0;return a="jobId"===n?r(e.jobId).localeCompare(r(t.jobId)):e[n]-t[n],"asc"===l?a:-a}),u=e=>n!==e?"":"asc"===l?" ▲":" ▼",m={cursor:"pointer",userSelect:"none",fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",fontWeight:500};return 0===t.length?null:(0,a.jsxs)("div",{style:{background:"var(--material-regular)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",overflow:"hidden"},children:[(0,a.jsxs)("div",{className:"flex items-center",style:{padding:"var(--space-2) var(--space-4)",borderBottom:"1px solid var(--separator)",gap:"var(--space-3)"},children:[(0,a.jsxs)("span",{style:{...m,flex:2,minWidth:0},onClick:()=>d("jobId"),children:["Job",u("jobId")]}),(0,a.jsxs)("span",{style:{...m,width:50,textAlign:"right"},onClick:()=>d("runs"),children:["Runs",u("runs")]}),(0,a.jsx)("span",{style:{...m,width:80,textAlign:"right"},children:"Input"}),(0,a.jsx)("span",{style:{...m,width:80,textAlign:"right"},children:"Output"}),(0,a.jsx)("span",{className:"hidden-mobile",style:{...m,width:80,textAlign:"right"},children:"Cache"}),(0,a.jsxs)("span",{style:{...m,width:80,textAlign:"right"},onClick:()=>d("totalCost"),children:["Est. Cost",u("totalCost")]})]}),c.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center",style:{padding:"var(--space-3) var(--space-4)",borderBottom:t<c.length-1?"1px solid var(--separator)":void 0,fontSize:"var(--text-footnote)",color:"var(--text-primary)",gap:"var(--space-3)"},children:[(0,a.jsx)("span",{style:{flex:2,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500},children:r(e.jobId)}),(0,a.jsx)("span",{style:{width:50,textAlign:"right",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:e.runs}),(0,a.jsx)("span",{style:{width:80,textAlign:"right",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:h(e.totalInputTokens)}),(0,a.jsx)("span",{style:{width:80,textAlign:"right",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:h(e.totalOutputTokens)}),(0,a.jsx)("span",{className:"hidden-mobile",style:{width:80,textAlign:"right",color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums"},children:h(e.totalCacheTokens)}),(0,a.jsx)("span",{style:{width:80,textAlign:"right",fontWeight:600,fontVariantNumeric:"tabular-nums"},children:p(e.totalCost)})]},e.jobId))]})}function f(e){let{anomalies:t,jobName:r}=e;return 0===t.length?null:(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2)",padding:"var(--space-3) var(--space-4)",background:"rgba(255, 149, 0, 0.08)",border:"1px solid rgba(255, 149, 0, 0.25)",borderRadius:"var(--radius-md)",marginBottom:"var(--space-4)",fontSize:"var(--text-footnote)",color:"var(--system-orange)"},children:[(0,a.jsxs)("div",{style:{fontWeight:600,display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[(0,a.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,a.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),(0,a.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,a.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),t.length," anomal",1===t.length?"y":"ies"," ","detected"]}),t.map((e,t)=>(0,a.jsxs)("div",{style:{paddingLeft:24},children:[(0,a.jsx)("span",{style:{fontWeight:500},children:r(e.jobId)})," -- ",h(e.totalTokens)," tokens (",e.ratio.toFixed(1),"x median of"," ",h(e.medianTokens),") on ",new Date(e.ts).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]},"".concat(e.ts,"-").concat(e.jobId,"-").concat(t)))]})}function y(){let[e,t]=(0,s.useState)(null),[r,n]=(0,s.useState)({}),[i,d]=(0,s.useState)(!0),[y,j]=(0,s.useState)(null);(0,s.useEffect)(()=>{d(!0),j(null),l.F.getCronJobs().then(async e=>{let r={};for(let t of e)r[t.id]=t.name;n(r);let a=await Promise.allSettled(e.map(e=>l.F.getCronRuns(e.id).then(t=>t.map(t=>{var r;return{...t,jobId:null!=(r=t.jobId)?r:e.id}})))),s=[];for(let e of a)"fulfilled"===e.status&&s.push(...e.value);t(function(e){let t=function(e){let t=new Map;for(let a of e){var r;let e=null!=(r=t.get(a.jobId))?r:[];e.push(a),t.set(a.jobId,e)}let a=[];for(let[e,r]of t)a.push({jobId:e,runs:r.length,totalInputTokens:r.reduce((e,t)=>e+t.inputTokens,0),totalOutputTokens:r.reduce((e,t)=>e+t.outputTokens,0),totalCacheTokens:r.reduce((e,t)=>e+t.cacheTokens,0),totalCost:r.reduce((e,t)=>e+t.minCost,0),medianCost:u(r.map(e=>e.minCost))});return a.sort((e,t)=>t.totalCost-e.totalCost)}(e),r=function(e){let t=new Map;for(let a of e){var r;let e=new Date(a.ts).toISOString().slice(0,10),n=null!=(r=t.get(e))?r:{cost:0,runs:0};n.cost+=a.minCost,n.runs+=1,t.set(e,n)}return Array.from(t.entries()).map(e=>{let[t,r]=e;return{date:t,cost:r.cost,runs:r.runs}}).sort((e,t)=>e.date.localeCompare(t.date))}(e),a=function(e){let t=new Map,r=0;for(let n of e){var a;t.set(n.model,(null!=(a=t.get(n.model))?a:0)+n.totalTokens),r+=n.totalTokens}return 0===r?[]:Array.from(t.entries()).map(e=>{let[t,a]=e;return{model:t,tokens:a,pct:a/r*100}}).sort((e,t)=>t.tokens-e.tokens)}(e),n=function(e,t){var r,a,n;let s=new Map;for(let e of t)s.set(e.jobId,e.runs);let o=new Map;for(let t of e){let e=null!=(r=o.get(t.jobId))?r:[];e.push(t.totalTokens),o.set(t.jobId,e)}let l=new Map;for(let[e,t]of o)l.set(e,u(t));let i=[];for(let t of e){if((null!=(a=s.get(t.jobId))?a:0)<3)continue;let e=null!=(n=l.get(t.jobId))?n:0;if(0===e)continue;let r=t.totalTokens/e;r>5&&i.push({ts:t.ts,jobId:t.jobId,totalTokens:t.totalTokens,medianTokens:e,ratio:r})}return i.sort((e,t)=>t.ratio-e.ratio)}(e,t),s=t.reduce((e,t)=>e+t.totalCost,0),o=t.length>0?{jobId:t[0].jobId,cost:t[0].totalCost}:null,l=function(e){let t=Date.now(),r=t-6048e5,a=t-12096e5,n=0,s=0;for(let t of e)t.ts>=r?n+=t.minCost:t.ts>=a&&(s+=t.minCost);let o=s>0?(n-s)/s*100:null;return{thisWeek:n,lastWeek:s,changePct:o}}(e),i=function(e){let t=0,r=0;for(let a of e)if(a.cacheTokens>0){t+=a.cacheTokens;let e=c(a.model);r+=a.cacheTokens*e.inputPer1M/1e6}return{cacheTokens:t,estimatedSavings:r}}(e);return{totalCost:s,topSpender:o,anomalies:n,jobCosts:t,dailyCosts:r,modelBreakdown:a,runCosts:e,weekOverWeek:l,cacheSavings:i}}(function(e){let t=[];for(let n of e){var r,a;if(!n.usage)continue;let e=c(null!=(r=n.model)?r:""),s=n.usage.input_tokens,o=n.usage.output_tokens,l=n.usage.total_tokens,i=Math.max(0,l-s-o),d=(s*e.inputPer1M+o*e.outputPer1M)/1e6;t.push({ts:n.ts,jobId:n.jobId,model:null!=(a=n.model)?a:"unknown",inputTokens:s,outputTokens:o,totalTokens:l,cacheTokens:i,minCost:d})}return t}(s))),d(!1)}).catch(e=>{j(e instanceof Error?e.message:"Unknown error"),d(!1)})},[]);let b=e=>r[e]||e,k=e&&e.runCosts.length>0?{oldest:new Date(Math.min(...e.runCosts.map(e=>e.ts))),newest:new Date(Math.max(...e.runCosts.map(e=>e.ts)))}:null;return(0,a.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",style:{background:"var(--bg)"},children:[(0,a.jsxs)("header",{className:"sticky top-0 z-10 flex-shrink-0",style:{background:"var(--material-regular)",backdropFilter:"blur(40px) saturate(180%)",WebkitBackdropFilter:"blur(40px) saturate(180%)",borderBottom:"1px solid var(--separator)",padding:"var(--space-4) var(--space-6)"},children:[(0,a.jsx)("h1",{style:{fontSize:"var(--text-title1)",fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.5px",lineHeight:1.2},children:"Costs"}),!i&&e&&(0,a.jsxs)("p",{style:{fontSize:"var(--text-footnote)",color:"var(--text-secondary)",marginTop:"var(--space-1)"},children:[k?"".concat(k.oldest.toLocaleDateString()," - ").concat(k.newest.toLocaleDateString()):"No data"," \xb7 ",e.runCosts.length," run",1!==e.runCosts.length?"s":""," with cost data"]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto",style:{padding:"var(--space-4) var(--space-6) var(--space-6)",minHeight:0},children:[y&&(0,a.jsx)("div",{style:{textAlign:"center",padding:"var(--space-8)",color:"var(--system-red)",fontSize:"var(--text-footnote)"},children:y}),i&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"costs-summary-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"var(--space-3)",marginBottom:"var(--space-4)"},children:[1,2,3,4].map(e=>(0,a.jsxs)("div",{style:{background:"var(--material-regular)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",padding:"var(--space-4)"},children:[(0,a.jsx)(o.E,{style:{width:100,height:10,marginBottom:8}}),(0,a.jsx)(o.E,{style:{width:60,height:20}})]},e))}),(0,a.jsx)("div",{style:{background:"var(--material-regular)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",overflow:"hidden"},children:[1,2,3,4].map(e=>(0,a.jsxs)("div",{className:"flex items-center",style:{padding:"var(--space-3) var(--space-4)",borderBottom:e<4?"1px solid var(--separator)":void 0,gap:"var(--space-3)"},children:[(0,a.jsx)(o.E,{style:{width:140,height:14}}),(0,a.jsx)(o.E,{style:{width:60,height:14,flex:1}}),(0,a.jsx)(o.E,{style:{width:80,height:14}})]},e))})]}),!i&&!y&&(!e||0===e.runCosts.length)&&(0,a.jsx)("div",{style:{textAlign:"center",padding:"var(--space-8)",color:"var(--text-tertiary)",fontSize:"var(--text-footnote)"},children:"No cost data -- runs without usage metadata will not appear here."}),!i&&!y&&e&&e.runCosts.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(f,{anomalies:e.anomalies,jobName:b}),(0,a.jsxs)("div",{className:"costs-summary-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"var(--space-3)",marginBottom:"var(--space-4)"},children:[(0,a.jsx)(m,{label:"Total Estimated Cost",children:(0,a.jsx)("div",{className:"flex items-center",style:{gap:"var(--space-2)"},children:(0,a.jsx)("span",{style:{fontSize:"var(--text-title2)",color:"var(--text-primary)",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:p(e.totalCost)})})}),(0,a.jsx)(m,{label:"Top Spender",children:e.topSpender?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{style:{fontSize:"var(--text-footnote)",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b(e.topSpender.jobId)}),(0,a.jsx)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",marginTop:2},children:p(e.topSpender.cost)})]}):(0,a.jsx)("span",{style:{color:"var(--text-tertiary)"},children:"--"})}),(0,a.jsxs)(m,{label:"Week over Week",children:[(0,a.jsx)("div",{className:"flex items-center",style:{gap:"var(--space-2)"},children:(0,a.jsx)("span",{style:{fontSize:"var(--text-title2)",fontWeight:700,fontVariantNumeric:"tabular-nums",color:null!==e.weekOverWeek.changePct?e.weekOverWeek.changePct<=0?"var(--system-green)":"var(--system-red)":"var(--text-primary)"},children:null!==e.weekOverWeek.changePct?"".concat(e.weekOverWeek.changePct>0?"+":"").concat(e.weekOverWeek.changePct.toFixed(0),"%"):"--"})}),(0,a.jsxs)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",marginTop:2},children:[p(e.weekOverWeek.thisWeek)," vs"," ",p(e.weekOverWeek.lastWeek)]})]}),(0,a.jsxs)(m,{label:"Cache Savings",children:[(0,a.jsx)("div",{style:{fontSize:"var(--text-title2)",color:"var(--system-green)",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:p(e.cacheSavings.estimatedSavings)}),(0,a.jsxs)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",marginTop:2},children:[h(e.cacheSavings.cacheTokens)," cache tokens"]})]})]}),(0,a.jsxs)("div",{className:"charts-row",style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"var(--space-4)",marginBottom:"var(--space-4)"},children:[(0,a.jsx)(g,{dailyCosts:e.dailyCosts}),(0,a.jsx)(x,{breakdown:e.modelBreakdown})]}),(0,a.jsx)(v,{jobCosts:e.jobCosts,jobName:b})]})]}),(0,a.jsx)("style",{children:"\n @media (max-width: 768px) {\n .costs-summary-grid {\n grid-template-columns: repeat(2, 1fr) !important;\n }\n .charts-row {\n grid-template-columns: 1fr !important;\n }\n }\n @media (max-width: 640px) {\n .costs-summary-grid {\n grid-template-columns: 1fr !important;\n }\n .hidden-mobile { display: none !important; }\n }\n "})]})}function j(){return(0,a.jsx)(n.M,{children:(0,a.jsx)(y,{})})}},1397:(e,t,r)=>{"use strict";r.d(t,{cn:()=>s});var a=r(5242),n=r(3065);function s(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,n.QP)((0,a.$)(t))}},6059:(e,t,r)=>{"use strict";r.d(t,{E:()=>s});var a=r(8111),n=r(1397);function s(e){let{className:t,width:r,height:s,style:o,...l}=e;return(0,a.jsx)("div",{className:(0,n.cn)("animate-shimmer rounded-md",t),style:{background:"linear-gradient(90deg, var(--fill-secondary) 25%, var(--fill-tertiary) 50%, var(--fill-secondary) 75%)",backgroundSize:"200% 100%",width:r,height:s,...o},...l})}},6086:(e,t,r)=>{Promise.resolve().then(r.bind(r,667))}},e=>{e.O(0,[704,590,73,814,743,358],()=>e(e.s=6086)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[783],{667:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>j});var a=r(8111),n=r(8700),s=r(5271),o=r(6059),l=r(3176);let i={"claude-sonnet-4-6":{inputPer1M:3,outputPer1M:15},"claude-sonnet-4-5":{inputPer1M:3,outputPer1M:15},"claude-haiku-4-5":{inputPer1M:.8,outputPer1M:4},"claude-opus-4-6":{inputPer1M:15,outputPer1M:75},"claude-3-5-sonnet":{inputPer1M:3,outputPer1M:15},"claude-3-5-haiku":{inputPer1M:.8,outputPer1M:4},"claude-3-haiku":{inputPer1M:.25,outputPer1M:1.25}},d={inputPer1M:3,outputPer1M:15};function c(e){if(i[e])return i[e];for(let t of Object.keys(i))if(e.startsWith(t))return i[t];return d}function u(e){if(0===e.length)return 0;let t=[...e].sort((e,t)=>e-t),r=Math.floor(t.length/2);return t.length%2!=0?t[r]:(t[r-1]+t[r])/2}function p(e){return e<.01&&e>0?"<$0.01":"$".concat(e.toFixed(2))}function h(e){return e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):String(e)}function m(e){let{label:t,children:r}=e;return(0,a.jsxs)("div",{style:{background:"var(--material-regular)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",padding:"var(--space-4)"},children:[(0,a.jsx)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",fontWeight:500,marginBottom:"var(--space-1)"},children:t}),r]})}function g(e){let{dailyCosts:t}=e,r=(0,s.useRef)(null),n=(0,s.useRef)(null),o=(0,s.useCallback)(()=>{let e=r.current,a=n.current;if(!e||!a||0===t.length)return;let s=window.devicePixelRatio||1,o=a.getBoundingClientRect().width;e.width=o*s,e.height=220*s,e.style.width="".concat(o,"px"),e.style.height="".concat(220,"px");let l=e.getContext("2d");if(!l)return;l.scale(s,s);let i=getComputedStyle(document.documentElement),d=i.getPropertyValue("--text-tertiary").trim()||"#888",c=i.getPropertyValue("--separator").trim()||"#333",u=i.getPropertyValue("--accent").trim()||"#007AFF",p=o-50-12,h=Math.max(...t.map(e=>e.cost),.01),m=Math.max(6,Math.min(40,(p-2*t.length)/t.length));for(let e of(l.clearRect(0,0,o,220),l.font="9px -apple-system, sans-serif",l.textAlign="right",[0,.25*h,.5*h,.75*h,h])){let t=192-e/h*180;l.strokeStyle=c,l.lineWidth=.5,l.beginPath(),l.moveTo(50,t),l.lineTo(o-12,t),l.stroke(),l.fillStyle=d,l.fillText("$".concat(e.toFixed(2)),44,t+3)}for(let e=0;e<t.length;e++){let r=t[e],a=r.cost/h*180,n=50+e*(m+2),s=192-a;l.fillStyle=u,l.globalAlpha=.8;let o=Math.max(1,a);l.beginPath(),l.moveTo(n+2,s),l.lineTo(n+m-2,s),l.quadraticCurveTo(n+m,s,n+m,s+2),l.lineTo(n+m,s+o),l.lineTo(n,s+o),l.lineTo(n,s+2),l.quadraticCurveTo(n,s,n+2,s),l.closePath(),l.fill(),l.globalAlpha=1,(0===e||e===t.length-1||e%7==0)&&(l.fillStyle=d,l.textAlign="center",l.font="8px -apple-system, sans-serif",l.fillText(r.date.slice(5),n+m/2,214))}},[t]);return((0,s.useEffect)(()=>(o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)),[o]),0===t.length)?null:(0,a.jsxs)("div",{ref:n,style:{background:"var(--material-regular)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",padding:"var(--space-4)"},children:[(0,a.jsx)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",fontWeight:500,marginBottom:"var(--space-3)"},children:"Daily Estimated Cost"}),(0,a.jsx)("canvas",{ref:r,style:{display:"block",width:"100%"}})]})}function x(e){let{breakdown:t}=e;if(0===t.length)return null;let r=["var(--system-blue)","var(--system-green)","var(--accent)","var(--system-orange)","var(--system-purple)"];return(0,a.jsxs)("div",{style:{background:"var(--material-regular)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",padding:"var(--space-4)"},children:[(0,a.jsx)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",fontWeight:500,marginBottom:"var(--space-3)"},children:"Model Breakdown"}),(0,a.jsx)("div",{style:{display:"flex",height:20,borderRadius:"var(--radius-sm)",overflow:"hidden",marginBottom:"var(--space-3)"},children:t.map((e,t)=>(0,a.jsx)("div",{style:{width:"".concat(e.pct,"%"),background:r[t%r.length],minWidth:2*(e.pct>0)}},e.model))}),(0,a.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--space-2)",fontSize:"var(--text-caption1)"},children:t.map((e,t)=>(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,a.jsx)("span",{style:{width:8,height:8,borderRadius:2,background:r[t%r.length],flexShrink:0}}),(0,a.jsx)("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:e.model}),(0,a.jsxs)("span",{style:{color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums"},children:[e.pct.toFixed(0),"% (",h(e.tokens),")"]})]},e.model))})]})}function v(e){let{jobCosts:t,jobName:r}=e,[n,o]=(0,s.useState)("totalCost"),[l,i]=(0,s.useState)("desc"),d=e=>{n===e?i(e=>"asc"===e?"desc":"asc"):(o(e),i("desc"))},c=[...t].sort((e,t)=>{let a=0;return a="jobId"===n?r(e.jobId).localeCompare(r(t.jobId)):e[n]-t[n],"asc"===l?a:-a}),u=e=>n!==e?"":"asc"===l?" ▲":" ▼",m={cursor:"pointer",userSelect:"none",fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",fontWeight:500};return 0===t.length?null:(0,a.jsxs)("div",{style:{background:"var(--material-regular)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",overflow:"hidden"},children:[(0,a.jsxs)("div",{className:"flex items-center",style:{padding:"var(--space-2) var(--space-4)",borderBottom:"1px solid var(--separator)",gap:"var(--space-3)"},children:[(0,a.jsxs)("span",{style:{...m,flex:2,minWidth:0},onClick:()=>d("jobId"),children:["Job",u("jobId")]}),(0,a.jsxs)("span",{style:{...m,width:50,textAlign:"right"},onClick:()=>d("runs"),children:["Runs",u("runs")]}),(0,a.jsx)("span",{style:{...m,width:80,textAlign:"right"},children:"Input"}),(0,a.jsx)("span",{style:{...m,width:80,textAlign:"right"},children:"Output"}),(0,a.jsx)("span",{className:"hidden-mobile",style:{...m,width:80,textAlign:"right"},children:"Cache"}),(0,a.jsxs)("span",{style:{...m,width:80,textAlign:"right"},onClick:()=>d("totalCost"),children:["Est. Cost",u("totalCost")]})]}),c.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center",style:{padding:"var(--space-3) var(--space-4)",borderBottom:t<c.length-1?"1px solid var(--separator)":void 0,fontSize:"var(--text-footnote)",color:"var(--text-primary)",gap:"var(--space-3)"},children:[(0,a.jsx)("span",{style:{flex:2,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500},children:r(e.jobId)}),(0,a.jsx)("span",{style:{width:50,textAlign:"right",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:e.runs}),(0,a.jsx)("span",{style:{width:80,textAlign:"right",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:h(e.totalInputTokens)}),(0,a.jsx)("span",{style:{width:80,textAlign:"right",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:h(e.totalOutputTokens)}),(0,a.jsx)("span",{className:"hidden-mobile",style:{width:80,textAlign:"right",color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums"},children:h(e.totalCacheTokens)}),(0,a.jsx)("span",{style:{width:80,textAlign:"right",fontWeight:600,fontVariantNumeric:"tabular-nums"},children:p(e.totalCost)})]},e.jobId))]})}function f(e){let{anomalies:t,jobName:r}=e;return 0===t.length?null:(0,a.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2)",padding:"var(--space-3) var(--space-4)",background:"rgba(255, 149, 0, 0.08)",border:"1px solid rgba(255, 149, 0, 0.25)",borderRadius:"var(--radius-md)",marginBottom:"var(--space-4)",fontSize:"var(--text-footnote)",color:"var(--system-orange)"},children:[(0,a.jsxs)("div",{style:{fontWeight:600,display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[(0,a.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[(0,a.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),(0,a.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,a.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),t.length," anomal",1===t.length?"y":"ies"," ","detected"]}),t.map((e,t)=>(0,a.jsxs)("div",{style:{paddingLeft:24},children:[(0,a.jsx)("span",{style:{fontWeight:500},children:r(e.jobId)})," -- ",h(e.totalTokens)," tokens (",e.ratio.toFixed(1),"x median of"," ",h(e.medianTokens),") on ",new Date(e.ts).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]},"".concat(e.ts,"-").concat(e.jobId,"-").concat(t)))]})}function y(){let[e,t]=(0,s.useState)(null),[r,n]=(0,s.useState)({}),[i,d]=(0,s.useState)(!0),[y,j]=(0,s.useState)(null);(0,s.useEffect)(()=>{d(!0),j(null),l.F.getCronJobs().then(async e=>{let r={};for(let t of e)r[t.id]=t.name;n(r);let a=await Promise.allSettled(e.map(e=>l.F.getCronRuns(e.id).then(t=>t.map(t=>{var r;return{...t,jobId:null!=(r=t.jobId)?r:e.id}})))),s=[];for(let e of a)"fulfilled"===e.status&&s.push(...e.value);t(function(e){let t=function(e){let t=new Map;for(let a of e){var r;let e=null!=(r=t.get(a.jobId))?r:[];e.push(a),t.set(a.jobId,e)}let a=[];for(let[e,r]of t)a.push({jobId:e,runs:r.length,totalInputTokens:r.reduce((e,t)=>e+t.inputTokens,0),totalOutputTokens:r.reduce((e,t)=>e+t.outputTokens,0),totalCacheTokens:r.reduce((e,t)=>e+t.cacheTokens,0),totalCost:r.reduce((e,t)=>e+t.minCost,0),medianCost:u(r.map(e=>e.minCost))});return a.sort((e,t)=>t.totalCost-e.totalCost)}(e),r=function(e){let t=new Map;for(let a of e){var r;let e=new Date(a.ts).toISOString().slice(0,10),n=null!=(r=t.get(e))?r:{cost:0,runs:0};n.cost+=a.minCost,n.runs+=1,t.set(e,n)}return Array.from(t.entries()).map(e=>{let[t,r]=e;return{date:t,cost:r.cost,runs:r.runs}}).sort((e,t)=>e.date.localeCompare(t.date))}(e),a=function(e){let t=new Map,r=0;for(let n of e){var a;t.set(n.model,(null!=(a=t.get(n.model))?a:0)+n.totalTokens),r+=n.totalTokens}return 0===r?[]:Array.from(t.entries()).map(e=>{let[t,a]=e;return{model:t,tokens:a,pct:a/r*100}}).sort((e,t)=>t.tokens-e.tokens)}(e),n=function(e,t){var r,a,n;let s=new Map;for(let e of t)s.set(e.jobId,e.runs);let o=new Map;for(let t of e){let e=null!=(r=o.get(t.jobId))?r:[];e.push(t.totalTokens),o.set(t.jobId,e)}let l=new Map;for(let[e,t]of o)l.set(e,u(t));let i=[];for(let t of e){if((null!=(a=s.get(t.jobId))?a:0)<3)continue;let e=null!=(n=l.get(t.jobId))?n:0;if(0===e)continue;let r=t.totalTokens/e;r>5&&i.push({ts:t.ts,jobId:t.jobId,totalTokens:t.totalTokens,medianTokens:e,ratio:r})}return i.sort((e,t)=>t.ratio-e.ratio)}(e,t),s=t.reduce((e,t)=>e+t.totalCost,0),o=t.length>0?{jobId:t[0].jobId,cost:t[0].totalCost}:null,l=function(e){let t=Date.now(),r=t-6048e5,a=t-12096e5,n=0,s=0;for(let t of e)t.ts>=r?n+=t.minCost:t.ts>=a&&(s+=t.minCost);let o=s>0?(n-s)/s*100:null;return{thisWeek:n,lastWeek:s,changePct:o}}(e),i=function(e){let t=0,r=0;for(let a of e)if(a.cacheTokens>0){t+=a.cacheTokens;let e=c(a.model);r+=a.cacheTokens*e.inputPer1M/1e6}return{cacheTokens:t,estimatedSavings:r}}(e);return{totalCost:s,topSpender:o,anomalies:n,jobCosts:t,dailyCosts:r,modelBreakdown:a,runCosts:e,weekOverWeek:l,cacheSavings:i}}(function(e){let t=[];for(let n of e){var r,a;if(!n.usage)continue;let e=c(null!=(r=n.model)?r:""),s=n.usage.input_tokens,o=n.usage.output_tokens,l=n.usage.total_tokens,i=Math.max(0,l-s-o),d=(s*e.inputPer1M+o*e.outputPer1M)/1e6;t.push({ts:n.ts,jobId:n.jobId,model:null!=(a=n.model)?a:"unknown",inputTokens:s,outputTokens:o,totalTokens:l,cacheTokens:i,minCost:d})}return t}(s))),d(!1)}).catch(e=>{j(e instanceof Error?e.message:"Unknown error"),d(!1)})},[]);let b=e=>r[e]||e,k=e&&e.runCosts.length>0?{oldest:new Date(Math.min(...e.runCosts.map(e=>e.ts))),newest:new Date(Math.max(...e.runCosts.map(e=>e.ts)))}:null;return(0,a.jsxs)("div",{className:"h-full flex flex-col overflow-hidden",style:{background:"var(--bg)"},children:[(0,a.jsxs)("header",{className:"sticky top-0 z-10 flex-shrink-0",style:{background:"var(--material-regular)",backdropFilter:"blur(40px) saturate(180%)",WebkitBackdropFilter:"blur(40px) saturate(180%)",borderBottom:"1px solid var(--separator)",padding:"var(--space-4) var(--space-6)"},children:[(0,a.jsx)("h1",{style:{fontSize:"var(--text-title1)",fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.5px",lineHeight:1.2},children:"Costs"}),!i&&e&&(0,a.jsxs)("p",{style:{fontSize:"var(--text-footnote)",color:"var(--text-secondary)",marginTop:"var(--space-1)"},children:[k?"".concat(k.oldest.toLocaleDateString()," - ").concat(k.newest.toLocaleDateString()):"No data"," \xb7 ",e.runCosts.length," run",1!==e.runCosts.length?"s":""," with cost data"]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto",style:{padding:"var(--space-4) var(--space-6) var(--space-6)",minHeight:0},children:[y&&(0,a.jsx)("div",{style:{textAlign:"center",padding:"var(--space-8)",color:"var(--system-red)",fontSize:"var(--text-footnote)"},children:y}),i&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"costs-summary-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"var(--space-3)",marginBottom:"var(--space-4)"},children:[1,2,3,4].map(e=>(0,a.jsxs)("div",{style:{background:"var(--material-regular)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",padding:"var(--space-4)"},children:[(0,a.jsx)(o.E,{style:{width:100,height:10,marginBottom:8}}),(0,a.jsx)(o.E,{style:{width:60,height:20}})]},e))}),(0,a.jsx)("div",{style:{background:"var(--material-regular)",border:"1px solid var(--separator)",borderRadius:"var(--radius-md)",overflow:"hidden"},children:[1,2,3,4].map(e=>(0,a.jsxs)("div",{className:"flex items-center",style:{padding:"var(--space-3) var(--space-4)",borderBottom:e<4?"1px solid var(--separator)":void 0,gap:"var(--space-3)"},children:[(0,a.jsx)(o.E,{style:{width:140,height:14}}),(0,a.jsx)(o.E,{style:{width:60,height:14,flex:1}}),(0,a.jsx)(o.E,{style:{width:80,height:14}})]},e))})]}),!i&&!y&&(!e||0===e.runCosts.length)&&(0,a.jsx)("div",{style:{textAlign:"center",padding:"var(--space-8)",color:"var(--text-tertiary)",fontSize:"var(--text-footnote)"},children:"No cost data -- runs without usage metadata will not appear here."}),!i&&!y&&e&&e.runCosts.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(f,{anomalies:e.anomalies,jobName:b}),(0,a.jsxs)("div",{className:"costs-summary-grid",style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"var(--space-3)",marginBottom:"var(--space-4)"},children:[(0,a.jsx)(m,{label:"Total Estimated Cost",children:(0,a.jsx)("div",{className:"flex items-center",style:{gap:"var(--space-2)"},children:(0,a.jsx)("span",{style:{fontSize:"var(--text-title2)",color:"var(--text-primary)",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:p(e.totalCost)})})}),(0,a.jsx)(m,{label:"Top Spender",children:e.topSpender?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{style:{fontSize:"var(--text-footnote)",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b(e.topSpender.jobId)}),(0,a.jsx)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",marginTop:2},children:p(e.topSpender.cost)})]}):(0,a.jsx)("span",{style:{color:"var(--text-tertiary)"},children:"--"})}),(0,a.jsxs)(m,{label:"Week over Week",children:[(0,a.jsx)("div",{className:"flex items-center",style:{gap:"var(--space-2)"},children:(0,a.jsx)("span",{style:{fontSize:"var(--text-title2)",fontWeight:700,fontVariantNumeric:"tabular-nums",color:null!==e.weekOverWeek.changePct?e.weekOverWeek.changePct<=0?"var(--system-green)":"var(--system-red)":"var(--text-primary)"},children:null!==e.weekOverWeek.changePct?"".concat(e.weekOverWeek.changePct>0?"+":"").concat(e.weekOverWeek.changePct.toFixed(0),"%"):"--"})}),(0,a.jsxs)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",marginTop:2},children:[p(e.weekOverWeek.thisWeek)," vs"," ",p(e.weekOverWeek.lastWeek)]})]}),(0,a.jsxs)(m,{label:"Cache Savings",children:[(0,a.jsx)("div",{style:{fontSize:"var(--text-title2)",color:"var(--system-green)",fontWeight:700,fontVariantNumeric:"tabular-nums"},children:p(e.cacheSavings.estimatedSavings)}),(0,a.jsxs)("div",{style:{fontSize:"var(--text-caption1)",color:"var(--text-tertiary)",marginTop:2},children:[h(e.cacheSavings.cacheTokens)," cache tokens"]})]})]}),(0,a.jsxs)("div",{className:"charts-row",style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"var(--space-4)",marginBottom:"var(--space-4)"},children:[(0,a.jsx)(g,{dailyCosts:e.dailyCosts}),(0,a.jsx)(x,{breakdown:e.modelBreakdown})]}),(0,a.jsx)(v,{jobCosts:e.jobCosts,jobName:b})]})]}),(0,a.jsx)("style",{children:"\n @media (max-width: 768px) {\n .costs-summary-grid {\n grid-template-columns: repeat(2, 1fr) !important;\n }\n .charts-row {\n grid-template-columns: 1fr !important;\n }\n }\n @media (max-width: 640px) {\n .costs-summary-grid {\n grid-template-columns: 1fr !important;\n }\n .hidden-mobile { display: none !important; }\n }\n "})]})}function j(){return(0,a.jsx)(n.M,{children:(0,a.jsx)(y,{})})}},1397:(e,t,r)=>{"use strict";r.d(t,{cn:()=>s});var a=r(5242),n=r(3065);function s(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,n.QP)((0,a.$)(t))}},6059:(e,t,r)=>{"use strict";r.d(t,{E:()=>s});var a=r(8111),n=r(1397);function s(e){let{className:t,width:r,height:s,style:o,...l}=e;return(0,a.jsx)("div",{className:(0,n.cn)("animate-shimmer rounded-md",t),style:{background:"linear-gradient(90deg, var(--fill-secondary) 25%, var(--fill-tertiary) 50%, var(--fill-secondary) 75%)",backgroundSize:"200% 100%",width:r,height:s,...o},...l})}},6086:(e,t,r)=>{Promise.resolve().then(r.bind(r,667))}},e=>{e.O(0,[282,590,700,814,743,358],()=>e(e.s=6086)),_N_E=e.O()}]);