polyergon 0.1.0 → 0.1.1

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 (82) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +4 -4
  3. package/.next/app-path-routes-manifest.json +1 -1
  4. package/.next/build-manifest.json +4 -4
  5. package/.next/next-minimal-server.js.nft.json +1 -1
  6. package/.next/next-server.js.nft.json +1 -1
  7. package/.next/prerender-manifest.json +1 -1
  8. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  9. package/.next/server/app/_not-found.html +1 -1
  10. package/.next/server/app/_not-found.rsc +1 -1
  11. package/.next/server/app/api/automations/existing/route.js +1 -1
  12. package/.next/server/app/api/backends/route.js +1 -1
  13. package/.next/server/app/api/diff/route.js +1 -0
  14. package/.next/server/app/api/diff/route.js.nft.json +1 -0
  15. package/.next/server/app/api/limits/route.js +1 -1
  16. package/.next/server/app/api/models/route.js +1 -1
  17. package/.next/server/app/api/orgs/[id]/route.js +1 -1
  18. package/.next/server/app/api/orgs/route.js +1 -1
  19. package/.next/server/app/api/prs/inbox/route.js +1 -1
  20. package/.next/server/app/api/prs/inbox/route.js.nft.json +1 -1
  21. package/.next/server/app/api/prs/refresh/route.js +1 -1
  22. package/.next/server/app/api/prs/refresh/route.js.nft.json +1 -1
  23. package/.next/server/app/api/prs/route.js +1 -1
  24. package/.next/server/app/api/prs/route.js.nft.json +1 -1
  25. package/.next/server/app/api/sessions/[id]/route.js +1 -1
  26. package/.next/server/app/api/sessions/route.js +1 -1
  27. package/.next/server/app/api/settings/auth/route.js +1 -1
  28. package/.next/server/app/api/skills/[name]/route.js +1 -1
  29. package/.next/server/app/api/skills/marketplace/route.js +1 -1
  30. package/.next/server/app/api/skills/route.js +1 -1
  31. package/.next/server/app/api/skills/view/route.js +1 -1
  32. package/.next/server/app/api/slack/channels/route.js +1 -1
  33. package/.next/server/app/api/slack/configured/route.js +1 -1
  34. package/.next/server/app/api/slack/inbox/route.js +1 -1
  35. package/.next/server/app/api/tasks/route.js +1 -0
  36. package/.next/server/app/api/tasks/route.js.nft.json +1 -0
  37. package/.next/server/app/api/usage/route.js +1 -1
  38. package/.next/server/app/demo/page_client-reference-manifest.js +1 -1
  39. package/.next/server/app/demo.html +1 -1
  40. package/.next/server/app/demo.rsc +2 -2
  41. package/.next/server/app/favicon.ico/route.js +1 -1
  42. package/.next/server/app/index.html +1 -1
  43. package/.next/server/app/index.rsc +2 -2
  44. package/.next/server/app/page.js +10 -1
  45. package/.next/server/app/page_client-reference-manifest.js +1 -1
  46. package/.next/server/app-paths-manifest.json +18 -16
  47. package/.next/server/chunks/36.js +1 -0
  48. package/.next/server/chunks/590.js +1 -1
  49. package/.next/server/chunks/621.js +1 -1
  50. package/.next/server/chunks/904.js +1 -1
  51. package/.next/server/chunks/972.js +2 -2
  52. package/.next/server/functions-config-manifest.json +1 -1
  53. package/.next/server/middleware-build-manifest.js +1 -1
  54. package/.next/server/pages/404.html +1 -1
  55. package/.next/server/pages/500.html +1 -1
  56. package/.next/server/server-reference-manifest.json +1 -1
  57. package/.next/static/chunks/171-d325f9625379d70a.js +1 -0
  58. package/.next/static/chunks/app/page-fedaef1e63f186c2.js +1 -0
  59. package/.next/static/chunks/{main-960df1c7509a5a8b.js → main-e88dbd51c3bdafca.js} +1 -1
  60. package/.next/static/css/6e83ef44d507c857.css +3 -0
  61. package/.next/trace +23 -22
  62. package/.next/types/app/api/diff/route.ts +343 -0
  63. package/.next/types/app/api/tasks/route.ts +343 -0
  64. package/.server-dist/server.js +73 -27
  65. package/.server-dist/src/lib/backends.js +99 -1
  66. package/.server-dist/src/lib/diffReview.js +116 -0
  67. package/.server-dist/src/lib/liveSessionStore.js +1 -1
  68. package/.server-dist/src/lib/modelCatalog.js +10 -3
  69. package/.server-dist/src/lib/pipelines.js +34 -8
  70. package/.server-dist/src/lib/ptyManager.js +15 -6
  71. package/.server-dist/src/lib/statusDetector.js +4 -0
  72. package/.server-dist/src/lib/taskStore.js +42 -0
  73. package/.server-dist/src/lib/worktrees.js +42 -0
  74. package/.server-dist/tsconfig.server.tsbuildinfo +1 -1
  75. package/README.md +16 -4
  76. package/package.json +1 -1
  77. package/.next/server/chunks/348.js +0 -1
  78. package/.next/static/chunks/171-f72ed164561ba218.js +0 -1
  79. package/.next/static/chunks/app/page-cebeba7d6d08548a.js +0 -1
  80. package/.next/static/css/a537d3e86c0f36d2.css +0 -3
  81. /package/.next/static/{q-HMeHYZY36qljBJhsyS6 → 2gHioRND6aAzT4OB5OHDV}/_buildManifest.js +0 -0
  82. /package/.next/static/{q-HMeHYZY36qljBJhsyS6 → 2gHioRND6aAzT4OB5OHDV}/_ssgManifest.js +0 -0
@@ -1 +1,10 @@
1
- (()=>{var e={};e.id=931,e.ids=[931],e.modules={2934:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external.js")},4580:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external.js")},5869:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},5315:e=>{"use strict";e.exports=require("path")},7360:e=>{"use strict";e.exports=require("url")},6993:(e,t,s)=>{"use strict";s.r(t),s.d(t,{GlobalError:()=>n.a,__next_app__:()=>u,originalPathname:()=>x,pages:()=>c,routeModule:()=>m,tree:()=>d}),s(5480),s(2029),s(5866);var a=s(3191),r=s(8716),l=s(7922),n=s.n(l),i=s(5231),o={};for(let e in i)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(o[e]=()=>i[e]);s.d(t,o);let d=["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(s.bind(s,5480)),"/private/tmp/claude-503/-Users-ofiryehoshua/0b425a50-f3c5-49e8-a60e-788bd3aae351/scratchpad/npm-build/src/app/page.tsx"],metadata:{icon:[async e=>(await Promise.resolve().then(s.bind(s,3881))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(s.bind(s,2029)),"/private/tmp/claude-503/-Users-ofiryehoshua/0b425a50-f3c5-49e8-a60e-788bd3aae351/scratchpad/npm-build/src/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(s.t.bind(s,5866,23)),"next/dist/client/components/not-found-error"],metadata:{icon:[async e=>(await Promise.resolve().then(s.bind(s,3881))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}],c=["/private/tmp/claude-503/-Users-ofiryehoshua/0b425a50-f3c5-49e8-a60e-788bd3aae351/scratchpad/npm-build/src/app/page.tsx"],x="/page",u={require:s,loadChunk:()=>Promise.resolve()},m=new a.AppPageRouteModule({definition:{kind:r.x.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:d}})},1866:(e,t,s)=>{Promise.resolve().then(s.bind(s,6847))},3353:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return l}});let a=s(1174);s(326),s(7577);let r=a._(s(7028));function l(e,t){var s;let a={loading:e=>{let{error:t,isLoading:s,pastDelay:a}=e;return null}};"function"==typeof e&&(a.loader=e);let l={...a,...t};return(0,r.default)({...l,modules:null==(s=l.loadableGenerated)?void 0:s.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},933:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return r}});let a=s(4129);function r(e){let{reason:t,children:s}=e;throw new a.BailoutToCSRError(t)}},7028:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return d}});let a=s(326),r=s(7577),l=s(933),n=s(6618);function i(e){return{default:e&&"default"in e?e.default:e}}let o={loader:()=>Promise.resolve(i(()=>null)),loading:null,ssr:!0},d=function(e){let t={...o,...e},s=(0,r.lazy)(()=>t.loader().then(i)),d=t.loading;function c(e){let i=d?(0,a.jsx)(d,{isLoading:!0,pastDelay:!0,error:null}):null,o=t.ssr?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.PreloadCss,{moduleIds:t.modules}),(0,a.jsx)(s,{...e})]}):(0,a.jsx)(l.BailoutToCSR,{reason:"next/dynamic",children:(0,a.jsx)(s,{...e})});return(0,a.jsx)(r.Suspense,{fallback:i,children:o})}return c.displayName="LoadableComponent",c}},6618:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadCss",{enumerable:!0,get:function(){return l}});let a=s(326),r=s(4580);function l(e){let{moduleIds:t}=e,s=(0,r.getExpectedRequestStore)("next/dynamic css"),l=[];if(s.reactLoadableManifest&&t){let e=s.reactLoadableManifest;for(let s of t){if(!e[s])continue;let t=e[s].files.filter(e=>e.endsWith(".css"));l.push(...t)}}return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)("link",{precedence:"dynamic",rel:"stylesheet",href:s.assetPrefix+"/_next/"+encodeURI(e),as:"style"},e))})}},6847:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>eB});var a=s(326),r=s(7577),l=s(3353),n=s.n(l);function i(e,t,s){if("all"===t)return!0;let a=(e.split("/")[0]??"").toLowerCase(),r=s.find(e=>e.id===t),l=(r?.githubOrgs??[]).map(e=>e.toLowerCase());return l.length>0?l.includes(a):!new Set(s.filter(e=>e.id!==t).flatMap(e=>e.githubOrgs??[]).map(e=>e.toLowerCase())).has(a)}let o=e=>({name:e?.name??"",configDir:e?.configDir??"",model:e?.model??"",githubOrgs:(e?.githubOrgs??[]).join(", ")});function d({orgs:e,onClose:t,onChanged:s}){let[l,n]=(0,r.useState)(null),[i,d]=(0,r.useState)(o()),[c,x]=(0,r.useState)(null),[u,m]=(0,r.useState)(null);function g(t){n(t),x(null),d(o("new"===t?void 0:e.find(e=>e.id===t)))}async function p(){x(null);let e="default"===l,t={name:i.name,...e?{}:{configDir:i.configDir.trim()},model:i.model,githubOrgs:i.githubOrgs.split(",").map(e=>e.trim()).filter(Boolean)},a="new"===l?await fetch("/api/orgs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}):await fetch(`/api/orgs/${l}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await a.json().catch(()=>({}));if(!a.ok){x(r.error??"Could not save");return}"new"===l&&t.githubOrgs.length&&await fetch(`/api/orgs/${r.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({githubOrgs:t.githubOrgs})}),n(null),s()}async function h(e){m(null);let t=await fetch(`/api/orgs/${e}`,{method:"DELETE"});if(!t.ok){x((await t.json().catch(()=>({}))).error??"Could not remove");return}l===e&&n(null),s()}let b="w-full bg-gray-800 border border-gray-700 focus:border-gray-500 rounded-md px-2.5 py-1.5 text-sm text-white outline-none placeholder-gray-500 mt-1",y=(0,a.jsxs)("div",{className:"space-y-3 bg-gray-950/60 border border-gray-800 rounded-lg p-3 mt-2",children:[(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Name",a.jsx("input",{value:i.name,onChange:e=>d({...i,name:e.target.value}),placeholder:"Acme",className:b})]}),"default"!==l&&(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Claude config folder",a.jsx("input",{value:i.configDir,onChange:e=>d({...i,configDir:e.target.value}),placeholder:"/Users/you/.claude-acme",className:`${b} font-mono`}),(0,a.jsxs)("span",{className:"text-[11px] text-gray-500",children:["Each folder is a separate Claude login. Run ",a.jsx("code",{children:"CLAUDE_CONFIG_DIR=<folder> claude"})," once to sign in."]})]}),(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Default model (optional)",a.jsx("input",{value:i.model,onChange:e=>d({...i,model:e.target.value}),placeholder:"claude-opus-5-5",className:`${b} font-mono`})]}),(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["GitHub orgs for the PR inbox (optional, comma-separated)",a.jsx("input",{value:i.githubOrgs,onChange:e=>d({...i,githubOrgs:e.target.value}),placeholder:"acme, acme-labs",className:b})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{onClick:()=>n(null),className:"px-3 py-1.5 text-xs text-gray-400 hover:text-white",children:"Cancel"}),a.jsx("button",{onClick:p,className:"px-3 py-1.5 text-xs rounded-md bg-blue-600 hover:bg-blue-500",children:"new"===l?"Add org":"Save"})]})]});return a.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:t,children:(0,a.jsxs)("div",{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto bg-gray-900 border border-gray-700 rounded-xl p-5 text-white",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h2",{className:"text-base font-semibold",children:"Orgs"}),a.jsx("button",{onClick:t,className:"text-gray-500 hover:text-white","aria-label":"Close",children:"✕"})]}),a.jsx("ul",{className:"space-y-2",children:e.map(e=>(0,a.jsxs)("li",{className:"rounded-lg border border-gray-800 px-3 py-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium",children:e.name}),(0,a.jsxs)("p",{className:"text-[11px] text-gray-500 font-mono truncate",children:[e.configDir??"~/.claude (Claude Code default)",e.model?` \xb7 ${e.model}`:"",e.githubOrgs?.length?` \xb7 GitHub: ${e.githubOrgs.join(", ")}`:""]})]}),a.jsx("button",{onClick:()=>g(e.id),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Edit"}),"default"!==e.id&&(u===e.id?(0,a.jsxs)(a.Fragment,{children:[a.jsx("button",{onClick:()=>h(e.id),className:"text-xs px-2 py-1 rounded-md bg-red-600 hover:bg-red-500",children:"Remove"}),a.jsx("button",{onClick:()=>m(null),className:"text-xs text-gray-400",children:"Cancel"})]}):a.jsx("button",{onClick:()=>m(e.id),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-red-400 hover:bg-red-950/40",children:"Remove"}))]}),l===e.id&&y]},e.id))}),"new"===l?y:a.jsx("button",{onClick:()=>g("new"),className:"mt-3 w-full text-sm py-2 rounded-lg border border-dashed border-gray-700 text-gray-300 hover:bg-gray-800",children:"+ Add org"}),c&&a.jsx("p",{className:"text-xs text-red-400 mt-3",children:c}),a.jsx("p",{className:"text-[11px] text-gray-500 mt-4",children:"Removing an org keeps its sessions and meetings; they still show under All. Changes apply to sessions started after you save."})]})})}let c=!0;var x=s(1954);let u={thinking:"border-l-yellow-400",waiting:"border-l-green-400",idle:"border-l-gray-600"},m={thinking:"bg-yellow-400 animate-pulse",waiting:"bg-green-400 animate-pulse",idle:"bg-gray-600"},g={thinking:"thinking…",waiting:"waiting for input",idle:"idle"},p={thinking:"text-yellow-400",waiting:"text-green-400",idle:"text-gray-500"};function h(e){return e?"MERGED"===e.state?{label:"Merged",className:"bg-purple-500/20 text-purple-400"}:"CLOSED"===e.state?{label:"Closed",className:"bg-gray-800 text-gray-500"}:"CHANGES_REQUESTED"===e.reviewDecision?{label:"Changes requested",className:"bg-red-500/20 text-red-400"}:"failing"===e.checks?{label:"Checks failing",className:"bg-red-500/20 text-red-400"}:"APPROVED"===e.reviewDecision?{label:"Approved",className:"bg-green-500/20 text-green-400"}:"pending"===e.checks?{label:"Checks running",className:"bg-yellow-500/20 text-yellow-400"}:{label:"Review pending",className:"bg-gray-800 text-gray-400"}:{label:"Unknown",className:"bg-gray-800 text-gray-500"}}function b(e){let t=e.match(/github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+)/);return t?`${t[1]}#${t[2]}`:e}function y(e){return e.status?.updatedAt??e.sessionDate}function f(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:`${Math.round(e/1e3)}k`}function j(e){return e>=100?`$${Math.round(e)}`:e>=1||e>0?`$${e.toFixed(2)}`:"$0"}function N(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}function v(e){if(!e)return"";let t=Date.now()-e;return t<6e4?"just now":t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:t<2592e6?`${Math.round(t/864e5)}d ago`:new Date(e).toLocaleDateString()}function w(e,t,s){let a=e.sessionId,r=a?s.find(e=>e.sessionId===a):void 0;return(e.liveId?t[e.liveId]:void 0)??(a?t[a]:void 0)??r?.firstUserMessage??e.cwd?.split("/").at(-1)??b(e.prUrl)}function k({entry:e,title:t,isPinned:s,isDismissed:r,onTogglePin:l,onToggleDismiss:n,onRename:i,onAttachLive:o,onSelectHistory:d}){let c=h(e.status),x=b(e.prUrl);return a.jsx("div",{className:`group/pr rounded-lg bg-gray-900 hover:bg-gray-800/70 transition-all cursor-pointer ${s?"ring-1 ring-yellow-600/50":""} ${r?"opacity-50":""}`,onClick:function(){"live"===e.source&&e.liveId?o(e.liveId):e.sessionId&&d(e.sessionId,e.cwd,e.orgId)},children:(0,a.jsxs)("div",{className:"px-3 py-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[a.jsx("button",{onClick:t=>{t.stopPropagation(),l(e.prUrl)},className:`flex-shrink-0 text-sm leading-none ${s?"text-yellow-400":"text-gray-700 hover:text-gray-400"}`,title:s?"Unpin":"Pin this PR",children:"\uD83D\uDCCC"}),a.jsx(I,{value:t,onSave:t=>i(e,t),className:"text-sm text-gray-100 font-medium truncate"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[a.jsx("span",{className:`text-xs rounded-full px-2 py-0.5 font-medium whitespace-nowrap ${c.className}`,children:c.label}),a.jsx("button",{onClick:t=>{t.stopPropagation(),n(e.prUrl)},className:"opacity-0 group-hover/pr:opacity-100 text-gray-600 hover:text-gray-300 text-xs",title:r?"Show again (undo dismiss)":"Dismiss — no longer relevant",children:r?"↺":"\xd7"})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("span",{className:"text-xs text-gray-600 truncate",children:[e.status?.title??x,v(y(e))&&` \xb7 ${v(y(e))}`]}),a.jsx("a",{href:e.prUrl,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"text-xs text-blue-500 hover:text-blue-300 flex-shrink-0",children:x})]})]})})}function S({pr:e,isDismissed:t,onToggleDismiss:s,onAttachLive:r,onSelectHistory:l}){let n=h(e.status),i=e.url.match(/\/pull\/(\d+)/)?.[1],o=`${e.repo.split("/").at(-1)}#${i??"?"}`,d=!!(e.liveId||e.sessionId);return a.jsx("div",{className:`group/inpr rounded-lg bg-gray-900 hover:bg-gray-800/70 transition-all cursor-pointer ${t?"opacity-50":""}`,onClick:function(){e.liveId?r(e.liveId):e.sessionId?l(e.sessionId,e.cwd):window.open(e.url,"_blank","noopener")},children:(0,a.jsxs)("div",{className:"px-3 py-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-0.5",children:[a.jsx("span",{className:"text-sm text-gray-100 font-medium truncate flex-1",title:e.title,children:e.title}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.isDraft&&a.jsx("span",{className:"text-xs rounded-full px-2 py-0.5 bg-gray-800 text-gray-500",children:"Draft"}),a.jsx("span",{className:`text-xs rounded-full px-2 py-0.5 font-medium whitespace-nowrap ${n.className}`,children:n.label}),a.jsx("button",{onClick:t=>{t.stopPropagation(),s(e.url)},className:"opacity-0 group-hover/inpr:opacity-100 text-gray-600 hover:text-gray-300 text-xs",title:t?"Show again":"Dismiss",children:t?"↺":"\xd7"})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("span",{className:"text-xs text-gray-600 truncate",children:[v(e.status?.updatedAt??e.updatedAt),d&&a.jsx("span",{className:"text-blue-500/80",children:" \xb7 has session"})]}),a.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"text-xs text-blue-500 hover:text-blue-300 flex-shrink-0",children:o})]})]})})}function C(e,t,s){let a=e.claudeSessionId?s.find(t=>t.sessionId===e.claudeSessionId):void 0;return t[e.id]??(e.claudeSessionId?t[e.claudeSessionId]:void 0)??a?.firstUserMessage??e.cwd.split("/").at(-1)??e.cwd}function D({s:e,isActive:t,sessionNames:s,historySessions:l,cost:n,contextTokens:i,compactAt:o,pipeline:d,onAutomate:c,onRenameLive:h,onAttachLive:b,onKillLive:y,onDeleteLive:N,onResume:v,onCompact:w,onSetRemote:k,onRename:S}){let[D,$]=(0,r.useState)(!1),[I,A]=(0,r.useState)(""),[R,P]=(0,r.useState)(!1),O=(0,r.useRef)(null),M=s[e.id]??(e.claudeSessionId?s[e.claudeSessionId]:void 0),L=C(e,s,l),E=new Date(e.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),T=/\/General\/[^/]+$/.test(e.cwd)?null:e.cwd.split("/").at(-1)??null;function U(t){t.stopPropagation(),A(M??e.cwd.split("/").at(-1)??e.cwd),$(!0),setTimeout(()=>O.current?.focus(),0)}function F(){$(!1);let t=I.trim();t&&(S(e.id,t),e.claudeSessionId&&S(e.claudeSessionId,t),h(e.id,t))}return a.jsx("div",{className:`group/live rounded-lg border-l-2 cursor-pointer ${u[e.status]} transition-all ${t?"bg-gray-800 shadow-sm":"bg-gray-900 hover:bg-gray-800/70"}`,onClick:()=>b(e.id),children:(0,a.jsxs)("div",{className:"px-3 py-2.5 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${m[e.status]}`}),D?a.jsx("input",{ref:O,value:I,onChange:e=>A(e.target.value),onBlur:F,onKeyDown:e=>{"Enter"===e.key&&F(),"Escape"===e.key&&$(!1)},onClick:e=>e.stopPropagation(),className:"bg-gray-700 text-white rounded px-1 outline-none flex-1 text-sm min-w-0",autoFocus:!0}):a.jsx("span",{className:"text-sm text-gray-100 font-medium truncate flex-1",onDoubleClick:U,title:L,children:L}),!D&&a.jsx("button",{onClick:U,className:"opacity-0 group-hover/live:opacity-100 text-gray-600 hover:text-gray-300 text-xs flex-shrink-0",title:"Rename",children:"✎"}),a.jsx("button",{onClick:t=>{t.stopPropagation(),c(e.id)},className:`text-xs flex-shrink-0 ${(0,x.An)(d)?"text-blue-400":"opacity-0 group-hover/live:opacity-100 text-gray-500 hover:text-yellow-300"}`,title:"Automate: open a PR, post for review, handle feedback and CI",children:"⚡"}),e.rc&&e.rcUrl?a.jsx("a",{href:e.rcUrl,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),className:"text-xs flex-shrink-0",title:"Remote Control ON — open on your phone / claude.ai/code. Hover actions → Remote off.",children:"\uD83D\uDCF1"}):e.rc?a.jsx("span",{className:"text-xs flex-shrink-0 opacity-40 animate-pulse",title:"Remote Control pairing…",children:"\uD83D\uDCF1"}):a.jsx("button",{onClick:t=>{t.stopPropagation(),k(e.id,!0)},className:"opacity-0 group-hover/live:opacity-100 text-xs flex-shrink-0 grayscale hover:grayscale-0",title:"Enable Remote Control for this session (continue from your phone)",children:"\uD83D\uDCF1"})]}),d&&"stopped"!==d.phase&&0===d.prs.length&&(0,a.jsxs)("button",{onClick:t=>{t.stopPropagation(),c(e.id)},title:`Automation: ${(0,x.YY)(d)[0].label}. Click to open.`,className:"mt-1.5 ml-4 flex items-center gap-1.5 text-[10px] text-gray-400 hover:text-gray-200",children:[a.jsx("span",{className:"text-yellow-300",children:"⚡"}),a.jsx("span",{className:"flex items-center",children:(0,x.YY)(d).map((e,t)=>(0,a.jsxs)("span",{className:"flex items-center",children:[t>0&&a.jsx("span",{className:"w-2 h-px bg-gray-700"}),a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${e.current?d.suggestion?"bg-amber-400 animate-pulse":"bg-blue-400 animate-pulse":"bg-gray-700"}`})]},e.label))}),a.jsx("span",{className:"truncate",children:(0,x.YY)(d)[0].label})]}),d&&"stopped"!==d.phase&&d.prs.length>0&&a.jsx("div",{onClick:t=>{t.stopPropagation(),c(e.id)},className:"mt-1.5 ml-4 space-y-1 cursor-pointer",title:"Open automation",children:d.prs.slice(0,3).map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] text-gray-400",children:[a.jsx("span",{className:"tabular-nums w-14 truncate",children:(0,x.QV)(e.url).split("/").at(-1)}),a.jsx("span",{className:"flex items-center",children:(0,x.UA)(e,!!d.config.slackChannel).map((e,t)=>(0,a.jsxs)("span",{className:"flex items-center",title:e.label,children:[t>0&&a.jsx("span",{className:`w-2 h-px ${e.done||e.current?"bg-blue-500/70":"bg-gray-700"}`}),a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${e.done?"bg-emerald-400":e.current?"bg-blue-400 animate-pulse":"bg-gray-700"}`})]},e.label))}),a.jsx("span",{className:"flex -space-x-1 ml-1",children:[...(e.view?.reviews??[]).map(e=>({who:e.login,c:"APPROVED"===e.state?"bg-emerald-600":"CHANGES_REQUESTED"===e.state?"bg-red-600":"bg-gray-600"})),...(e.view?.requested??[]).map(e=>({who:e,c:"bg-gray-800 ring-gray-600"}))].slice(0,4).map(e=>a.jsx("span",{title:e.who,className:`w-3.5 h-3.5 rounded-full ring-1 ring-gray-900 text-[8px] leading-[14px] text-center text-white uppercase ${e.c}`,children:e.who[0]},e.who))}),e.view?.checks==="failing"&&a.jsx("span",{className:"text-red-400",title:"CI failing",children:"✗ CI"})]},e.url))}),d&&"stopped"!==d.phase&&(0,a.jsxs)("button",{onClick:t=>{t.stopPropagation(),c(e.id)},className:`mt-1.5 ml-4 text-[11px] px-1.5 py-0.5 rounded ${"done"===d.phase||d.prs.some(e=>"ready"===e.state)?"bg-emerald-500/15 text-emerald-300":"needs-you"===d.phase||d.prs.some(e=>"needs-you"===e.state)?"bg-amber-500/15 text-amber-300":"bg-blue-500/15 text-blue-300"}`,children:["⚡ ",(0,x.Vm)(d)]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mt-1.5 pl-4 text-[11px] min-w-0",children:[a.jsx("span",{className:`flex-shrink-0 font-medium ${p[e.status]}`,children:g[e.status]}),T&&(0,a.jsxs)(a.Fragment,{children:[a.jsx("span",{className:"text-gray-700",children:"\xb7"}),a.jsx("span",{className:"truncate text-gray-500",children:T})]}),E&&(0,a.jsxs)(a.Fragment,{children:[a.jsx("span",{className:"text-gray-700",children:"\xb7"}),a.jsx("span",{className:"flex-shrink-0 text-gray-600",children:E})]})]}),(void 0!==n&&n>0||!!i&&i>0)&&(()=>{let e=o??6e5,t=i?i>=e?2:i>=.8*e?1:0:0;return(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1.5 pl-4 text-[11px]",children:[void 0!==n&&n>0&&a.jsx("span",{className:"flex-shrink-0 px-1.5 py-px rounded bg-emerald-500/10 text-emerald-400 font-medium tabular-nums",title:"Estimated API-equivalent cost of this session",children:j(n)}),!!i&&i>0&&(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0",title:o?`Context on last turn: ${i.toLocaleString()} tokens. Auto-compact runs at ${f(o)} (Settings).`:`Context on last turn: ${i.toLocaleString()} tokens. Auto-compact is off. Quality drops past ~600k; compact it.`,children:[a.jsx("span",{className:"flex-1 h-1 rounded-full bg-gray-800 overflow-hidden max-w-[90px]",children:a.jsx("span",{className:`block h-full rounded-full ${2===t?"bg-red-400":1===t?"bg-amber-400":"bg-gray-500"}`,style:{width:`${Math.min(100,Math.max(4,i/e*100))}%`}})}),(0,a.jsxs)("span",{className:`flex-shrink-0 tabular-nums ${2===t?"text-red-300":1===t?"text-amber-300":"text-gray-500"}`,children:[f(i)," / ",f(e)]})]})]})})(),(0,a.jsxs)("div",{className:"flex items-center gap-3 pl-4 max-h-0 opacity-0 overflow-hidden group-hover/live:max-h-8 group-hover/live:opacity-100 group-hover/live:mt-2 transition-all duration-150",children:["waiting"===e.status&&!!i&&i>=(o?.8*o:4e5)&&a.jsx("button",{onClick:t=>{t.stopPropagation(),w(e.id)},className:"text-[11px] text-amber-400 hover:text-amber-200 font-medium",title:"Send /compact — summarizes the conversation to shrink context (cuts cache cost, restores quality)",children:"Compact"}),e.claudeSessionId&&a.jsx("button",{onClick:function(t){t.stopPropagation();let s=e.claudeSessionId;if(!s)return;let a=()=>{P(!0),setTimeout(()=>P(!1),1200)},r=()=>{try{let e=document.createElement("textarea");e.value=s,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e),a()}catch{}};navigator.clipboard?.writeText?navigator.clipboard.writeText(s).then(a).catch(r):r()},className:`text-[11px] ${R?"text-emerald-400":"text-gray-500 hover:text-gray-200"}`,title:"Copy this session's ID (for resuming it elsewhere)",children:R?"✓ Copied":"Copy ID"}),e.rc&&a.jsx("button",{onClick:t=>{t.stopPropagation(),k(e.id,!1)},className:"text-[11px] text-gray-500 hover:text-gray-200",title:"Turn Remote Control off for this session",children:"Remote off"}),"idle"===e.status&&e.claudeSessionId&&a.jsx("button",{onClick:t=>{t.stopPropagation(),v(e.id)},className:"text-[11px] text-blue-500 hover:text-blue-300",children:"Resume"}),a.jsx("button",{onClick:t=>{t.stopPropagation(),y(e.id)},className:"text-[11px] text-gray-500 hover:text-red-400 ml-auto",title:"Stops the live process. The conversation itself isn't deleted — it stays available in the History tab.",children:"Archive"}),a.jsx("button",{onClick:t=>{t.stopPropagation(),window.confirm(`Delete "${L}"? It moves to a trash folder (not permanently gone), but stops the live process and disappears from both Live and History.`)&&N(e.id,e.claudeSessionId)},className:"text-[11px] text-gray-500 hover:text-red-500",title:"Stops the live process and moves the conversation to a trash folder — no longer shown in Live/History, but recoverable.",children:"Delete"})]})]})})}function $(e,t){let[s,a]=(0,r.useState)(t);return[s,function(t){a(t);try{localStorage.setItem(e,JSON.stringify(t))}catch{}}]}function I({value:e,onSave:t,className:s,forceEdit:l,onEditDone:n}){let[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(e),x=(0,r.useRef)(null);function u(){o(!1),n?.();let s=d.trim();s&&s!==e?t(s):c(e)}return i||l?a.jsx("input",{ref:x,value:d,onChange:e=>c(e.target.value),onBlur:u,onKeyDown:t=>{"Enter"===t.key&&u(),"Escape"===t.key&&(o(!1),c(e),n?.())},onClick:e=>e.stopPropagation(),className:`bg-gray-700 text-white rounded px-1 outline-none w-full ${s}`}):a.jsx("span",{className:s,onDoubleClick:e=>{e.stopPropagation(),o(!0)},children:e})}function A({open:e}){return a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",className:"flex-shrink-0",children:e?a.jsx("path",{d:"M1.5 3A1.5 1.5 0 000 4.5v8A1.5 1.5 0 001.5 14h13a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H7.621a1.5 1.5 0 01-1.06-.44L5.5 3H1.5z"}):a.jsx("path",{d:"M.54 3.87L.5 3a2 2 0 012-2h3.672a2 2 0 011.414.586l.828.828A2 2 0 009.828 3h3.982a2 2 0 011.992 2.181l-.637 7A2 2 0 0113.174 14H2.826a2 2 0 01-1.991-1.819l-.637-7a1.99 1.99 0 01.342-1.31z"})})}function R({liveSessions:e,orgs:t,activeOrgId:s,onSwitchOrg:l,historySessions:n,historyLoading:o,activeSessionId:c,selectedHistoryId:u,sessionNameOverrides:m,onAttachLive:g,onKillLive:p,onDeleteLive:h,onResumeLive:y,onResumeAll:f,onCompact:R,onSetRemote:P,onNewSession:O,onSelectHistory:M,onDeleteSession:L,inbox:E,inboxLoading:T,inboxRefreshing:U,onRefreshInbox:F,onOpenPrDashboard:_,meetings:H,selectedMeetingId:J,onSelectMeeting:B,onRecordMeeting:q,onOpenMeetingLibrary:z,pipelines:W,onOrgsChanged:G,onRenameLive:K,notes:Y,setNotes:V,onOpenNotes:X,onOpenSkills:Q,onOpenSlack:Z,onOpenSettings:ee,onOpenAutomations:et,onHome:es,selectedNoteId:ea,selectedSkill:er,skillsVersion:el,onAutomate:en,usage:ei,onOpenUsage:eo}){let[ed,ec]=(0,r.useState)({}),ex=ed[s]??"",eu=e=>ec(t=>({...t,[s]:e})),{names:em,setName:eg}=function(){let[e,t]=(0,r.useState)({});return(0,r.useRef)(e).current=e,{names:e,setName:(0,r.useCallback)((e,s)=>{t(t=>{let a={...t};return s.trim()?a[e]=s.trim():delete a[e],a}),fetch("/api/session-names",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({key:e,name:s})}).catch(()=>{})},[])}}();(0,r.useRef)(em).current=em;let[ep,eh]=$("claude-group-names",{}),[eb,ey]=$("claude-group-collapsed",{}),[ef,ej]=$("claude-session-group-overrides",{}),[eN,ev]=$("claude-live-order",[]),[ew,ek]=$("claude-live-sort","custom"),[eS,eC]=$("claude-live-last-active",{});(0,r.useRef)(eS).current=eS;let[eD,e$]=$("claude-pinned-prs",{}),[eI,eA]=$("claude-dismissed-prs",{}),[eR,eP]=(0,r.useState)(!1),[eO,eM]=(0,r.useState)(!0),[eL,eE]=(0,r.useState)(null),[eT,eU]=(0,r.useState)(null),[eF,e_]=(0,r.useState)(null),[eH,eJ]=(0,r.useState)("live"),[eB,eq]=(0,r.useState)(!1),[ez,eW]=(0,r.useState)(null);function eG(e,t){eg(e,t)}let eK=e=>"all"===s||(e??"default")===s,eY=e.filter(e=>eK(e.orgId)),eV=n.filter(e=>eK(e.orgId)&&!e.headless),eX=H.filter(e=>eK(e.orgId)).filter(e=>"recording"===e.status).length,eQ=[...eY].sort((e,t)=>{if("recent"===ew){let s=eS[e.id]??e.createdAt;return(eS[t.id]??t.createdAt)-s}if("name"===ew)return C(e,em,n).localeCompare(C(t,em,n),void 0,{sensitivity:"base"});let s=eN.indexOf(e.id),a=eN.indexOf(t.id);return -1===s&&-1===a?0:-1===s?1:-1===a?-1:s-a}).filter(e=>{if(!ex)return!0;let t=C(e,em,n),s=e.cwd.split("/").at(-1)??e.cwd;return t.toLowerCase().includes(ex.toLowerCase())||s.toLowerCase().includes(ex.toLowerCase())});function eZ(e){e$({...eD,[e]:!eD[e]})}function e0(e){eA({...eI,[e]:!eI[e]})}function e1(e,t){e.liveId&&eG(e.liveId,t),e.sessionId&&eG(e.sessionId,t)}(0,r.useRef)(Y).current=Y;let[e5,e2]=(0,r.useState)(null),e3=(e,t)=>!ex||e.toLowerCase().includes(ex.toLowerCase())||t.toLowerCase().includes(ex.toLowerCase()),e4=e=>i(e.repo,s,t),e8=e=>e.filter(e=>e4(e)&&(eR||!eI[e.url])&&e3(e.title,e.repo)),e6=E?[{key:"needsReview",title:"Needs your review",accent:"text-red-400",items:e8(E.sections.needsReview)},{key:"returned",title:"Returned to you",accent:"text-orange-400",items:e8(E.sections.returned)},{key:"waiting",title:"Waiting on others",accent:"text-yellow-500",items:e8(E.sections.waiting)},{key:"mergedRecent",title:"Recently merged",accent:"text-purple-400",items:e8(E.sections.mergedRecent)}]:[],e7=(E?.fromSessions??[]).filter(e=>eK(e.orgId)&&(eR||!eI[e.prUrl])&&e3(w(e,em,n),b(e.prUrl))),e9=E?Object.values(E.sections).flat().filter(e4):[],te=E?[...e9.map(e=>e.url),...E.fromSessions.filter(e=>eK(e.orgId)).map(e=>e.prUrl)].filter(e=>eI[e]).length:0,tt=E?[...E.sections.needsReview,...E.sections.returned].filter(e=>e4(e)&&!eI[e.url]).length:0,ts=e9.filter(e=>!eI[e.url]).length,ta=eV.filter(e=>{let t=em[e.sessionId]??e.firstUserMessage??"",s=ef[e.sessionId]??e.gitRoot??e.cwd??e.projectEncoded,a=ep[s]??s.split("/").at(-1)??s;return t.toLowerCase().includes(ex.toLowerCase())||a.toLowerCase().includes(ex.toLowerCase())}),tr=new Map;for(let e of ta){let t=ef[e.sessionId]??e.gitRoot??e.cwd??e.projectEncoded;tr.has(t)||tr.set(t,[]),tr.get(t).push(e)}let tl=Array.from(tr.values()).sort((e,t)=>{let s=e[0].lastTimestamp??"",a=t[0].lastTimestamp??"";return a>s?1:a<s?-1:0});return(0,a.jsxs)("aside",{className:"w-full flex-shrink-0 bg-gray-950 text-white flex flex-col h-screen",children:[(0,a.jsxs)("div",{className:"px-3 pt-4 pb-3 border-b border-gray-800/60",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("span",{onClick:es,title:"Home",className:"cursor-pointer text-sm font-bold text-white tracking-tight px-1 hover:text-blue-300",children:["Polyergon","dev"===process.env.NEXT_PUBLIC_POLYERGON_ENV&&a.jsx("span",{className:"ml-2 text-[10px] font-semibold bg-amber-500 text-black rounded px-1.5 py-0.5",children:"DEV"})]}),(0,a.jsxs)("button",{onClick:ee,title:"Settings",className:"flex items-center gap-1.5 text-xs font-medium text-gray-200 bg-gray-800 hover:bg-gray-700 border border-gray-700 rounded-md px-2.5 py-1 transition-colors",children:[a.jsx("span",{className:"text-sm leading-none",children:"⚙"}),"Settings"]})]}),eB&&a.jsx(d,{orgs:t,onClose:()=>eq(!1),onChanged:G}),(0,a.jsxs)("div",{className:"flex gap-1 mt-3 bg-gray-900 rounded-lg p-1",children:[a.jsx("button",{onClick:()=>l("all"),className:`flex-1 py-1 rounded-md text-xs font-medium transition-colors truncate ${"all"===s?"bg-gray-700 text-white":"text-gray-500 hover:text-gray-300"}`,children:"All"}),t.map(e=>a.jsx("button",{onClick:()=>l(e.id),title:e.name,className:`flex-1 py-1 rounded-md text-xs font-medium transition-colors truncate ${s===e.id?"bg-purple-800/80 text-purple-100":"text-gray-500 hover:text-gray-300"}`,children:e.name},e.id)),a.jsx("button",{onClick:()=>eq(!0),title:"Add or edit orgs",className:"px-2 py-1 rounded-md text-xs text-gray-500 hover:text-white hover:bg-gray-800 flex-shrink-0",children:"+"})]}),(0,a.jsxs)("div",{className:"flex gap-2 mt-3",children:[(0,a.jsxs)("button",{onClick:O,className:"flex-1 bg-blue-600 hover:bg-blue-500 text-white rounded-lg px-3 py-2 text-sm font-medium transition-colors flex items-center justify-center gap-2",children:[a.jsx("span",{className:"text-base leading-none",children:"+"})," New Session"]}),a.jsx("button",{onClick:q,title:"Record a meeting",className:"bg-gray-800 hover:bg-red-900/60 text-red-400 rounded-lg px-3 py-2 text-sm font-medium transition-colors flex items-center justify-center",children:a.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-red-500"})})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_1fr_1.2fr] border-b border-gray-800/60",children:[(0,a.jsxs)("button",{onClick:()=>eJ("live"),className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"live"===eH?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:["Live",eY.length>0&&a.jsx("span",{className:`rounded-full px-1.5 py-0.5 text-xs font-medium ${"live"===eH?"bg-blue-500/20 text-blue-400":"bg-gray-800 text-gray-500"}`,children:eY.length})]}),(0,a.jsxs)("button",{onClick:()=>eJ("history"),className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"history"===eH?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:["History",tl.length>0&&a.jsx("span",{className:`rounded-full px-1.5 py-0.5 text-xs font-medium ${"history"===eH?"bg-blue-500/20 text-blue-400":"bg-gray-800 text-gray-500"}`,children:tl.length})]}),(0,a.jsxs)("button",{onClick:()=>eJ("prs"),className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"prs"===eH?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:["PRs",ts>0&&a.jsx("span",{className:`rounded-full px-1.5 py-0.5 text-xs font-medium ${tt>0?"bg-red-500/20 text-red-400":"prs"===eH?"bg-blue-500/20 text-blue-400":"bg-gray-800 text-gray-500"}`,children:tt>0?tt:ts})]}),a.jsx("button",{onClick:()=>{eJ("notes"),X(null)},className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"notes"===eH?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:"Notes"}),(0,a.jsxs)("button",{onClick:()=>{eJ("meetings"),z()},className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"meetings"===eH?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:["Meetings",eX>0&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"})]}),a.jsx("button",{onClick:()=>{eJ("usage"),eo()},className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"usage"===eH?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:"Usage"}),a.jsx("button",{onClick:()=>{eJ("skills"),Q(null)},className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"skills"===eH?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:"Skills"}),Z&&a.jsx("button",{onClick:()=>{eJ("slack"),Z()},className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"slack"===eH?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:"Slack"}),(0,a.jsxs)("button",{onClick:()=>{eJ("automations"),et()},className:`py-2.5 pr-1 text-xs font-semibold flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"automations"===eH?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:[a.jsx("span",{className:"whitespace-nowrap",children:"Automations"}),W.filter(x.An).length>0&&a.jsx("span",{title:`${W.filter(x.An).length} running`,className:`rounded-full px-1.5 py-0.5 text-xs font-medium ${"automations"===eH?"bg-blue-500/20 text-blue-400":"bg-gray-800 text-gray-500"}`,children:W.filter(x.An).length})]})]}),"notes"!==eH&&"meetings"!==eH&&"usage"!==eH&&"slack"!==eH&&"automations"!==eH&&"skills"!==eH&&a.jsx("div",{className:"px-3 py-2 border-b border-gray-800/40",children:(0,a.jsxs)("div",{className:"relative",children:[a.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-4.35-4.35M17 11A6 6 0 115 11a6 6 0 0112 0z"})}),a.jsx("input",{type:"text",placeholder:"live"===eH?"Search live sessions…":"prs"===eH?"Search PRs…":"Search sessions…",value:ex,onChange:e=>eu(e.target.value),className:"w-full bg-gray-900 text-white rounded-lg pl-8 pr-3 py-2 text-sm placeholder-gray-600 outline-none border border-gray-800 focus:border-gray-600 transition-colors"})]})}),"live"===eH&&(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[eY.length>1&&(0,a.jsxs)("div",{className:"flex items-center justify-end gap-1 mb-2 text-[11px]",children:[a.jsx("span",{className:"text-gray-600 mr-0.5",children:"Sort:"}),a.jsx("button",{onClick:()=>ek("custom"),className:"custom"===ew?"text-blue-400 font-medium":"text-gray-500 hover:text-gray-300",title:"Your manual drag order",children:"Custom"}),a.jsx("span",{className:"text-gray-700",children:"\xb7"}),a.jsx("button",{onClick:()=>ek("recent"),className:"recent"===ew?"text-blue-400 font-medium":"text-gray-500 hover:text-gray-300",title:"Most recently opened first",children:"Last used"}),a.jsx("span",{className:"text-gray-700",children:"\xb7"}),a.jsx("button",{onClick:()=>ek("name"),className:"name"===ew?"text-blue-400 font-medium":"text-gray-500 hover:text-gray-300",title:"Alphabetical by name",children:"Name"})]}),eY.filter(e=>"idle"===e.status&&e.claudeSessionId).length>1&&(0,a.jsxs)("button",{onClick:f,className:"w-full mb-2 bg-gray-800 hover:bg-gray-700 text-blue-400 rounded-lg px-3 py-1.5 text-xs font-medium",children:["⟳ Resume all (",eY.filter(e=>"idle"===e.status&&e.claudeSessionId).length," idle)"]}),0===eQ.length?a.jsx("p",{className:"text-xs text-gray-600 text-center mt-8",children:"No active sessions"}):a.jsx("div",{className:"flex flex-col gap-1.5",children:eQ.map(e=>a.jsx("div",{draggable:!0,onDragStart:t=>{t.dataTransfer.setData("text/live-session-id",e.id),t.dataTransfer.effectAllowed="move"},onDragOver:t=>{t.preventDefault(),e_(e.id)},onDragLeave:()=>e_(t=>t===e.id?null:t),onDrop:t=>{t.preventDefault(),e_(null);let s=t.dataTransfer.getData("text/live-session-id");s&&function(e,t){if(e===t)return;let s=eQ.map(e=>e.id).filter(t=>t!==e),a=s.indexOf(t);s.splice(a,0,e),ev(s)}(s,e.id)},className:`cursor-grab active:cursor-grabbing rounded-lg transition-colors ${eF===e.id?"ring-2 ring-blue-600":""}`,children:a.jsx(D,{s:e,isActive:c===e.id,sessionNames:em,historySessions:n,cost:e.claudeSessionId?ei?.sessions[e.claudeSessionId]?.costUSD:void 0,contextTokens:e.claudeSessionId?ei?.sessions[e.claudeSessionId]?.contextTokens:void 0,onCompact:R,pipeline:[...W].reverse().find(t=>t.liveId===e.id)??null,onAutomate:en,onSetRemote:P,onAttachLive:g,onKillLive:p,onDeleteLive:h,onResume:y,onRename:eG,onRenameLive:K,compactAt:ez})},e.id))})]}),"history"===eH&&a.jsx(a.Fragment,{children:(0,a.jsxs)("div",{className:"overflow-y-auto flex-1 px-2 pb-4",children:[o&&a.jsx("p",{className:"p-4 text-gray-600 text-xs",children:"Loading…"}),tl.map(e=>{let t=e[0].gitRoot??e[0].cwd??e[0].projectEncoded,s=e[0].gitRoot??e[0].cwd??e[0].projectPath,r=ep[t]??s.split("/").at(-1)??s,l=eb[t],n=eT===t;return(0,a.jsxs)("div",{className:"mt-3",children:[(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer group transition-colors ${n?"bg-blue-900/30 border border-dashed border-blue-600":"hover:bg-gray-800/50"}`,onClick:()=>{ey({...eb,[t]:!eb[t]})},onDragOver:e=>{e.preventDefault(),eU(t)},onDragLeave:()=>eU(null),onDrop:e=>{e.preventDefault(),eU(null);let s=e.dataTransfer.getData("text/session-id");s&&ej({...ef,[s]:t})},children:[a.jsx("span",{className:"text-gray-500 group-hover:text-gray-400 transition-colors",children:a.jsx(A,{open:!l})}),a.jsx(I,{value:r,onSave:e=>{eh({...ep,[t]:e})},className:"text-xs font-semibold text-gray-400 group-hover:text-gray-300 flex-1 truncate transition-colors"}),a.jsx("span",{className:"text-xs text-gray-700 bg-gray-800 rounded-full px-1.5 py-0.5 font-medium ml-auto flex-shrink-0",children:e.length})]}),!l&&a.jsx("div",{className:"ml-3 mt-0.5 border-l border-gray-800/60 pl-2",children:e.map(e=>{let t=em[e.sessionId]??e.title??e.firstUserMessage??"Empty session",s=u===e.sessionId,r=eL===e.sessionId;return(0,a.jsxs)("div",{draggable:!0,onDragStart:t=>{t.dataTransfer.setData("text/session-id",e.sessionId),t.dataTransfer.effectAllowed="move"},className:`group/session flex items-stretch rounded-md transition-colors cursor-grab active:cursor-grabbing ${s?"bg-gray-800 border-l-2 border-l-blue-500 -ml-px":"hover:bg-gray-800/50"}`,children:[(0,a.jsxs)("button",{onClick:()=>M(e.sessionId,e.cwd,e.orgId),className:"flex-1 text-left px-2 py-2 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[a.jsx(I,{value:t,onSave:t=>eG(e.sessionId,t),forceEdit:r,onEditDone:()=>eE(null),className:"text-xs text-gray-300 flex-1 truncate leading-relaxed"}),!r&&a.jsx("button",{onClick:t=>{t.stopPropagation(),eE(e.sessionId)},className:"opacity-0 group-hover/session:opacity-100 text-gray-600 hover:text-gray-300 text-xs flex-shrink-0",title:"Rename",children:"✎"})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-600 mt-0.5",children:[e.messageCount," msgs \xb7 ",e.lastTimestamp?new Date(e.lastTimestamp).toLocaleDateString():"—",(ei?.sessions[e.sessionId]?.costUSD??0)>0&&(0,a.jsxs)("span",{className:"text-emerald-700",children:[" \xb7 ",j(ei.sessions[e.sessionId].costUSD)]})]})]}),a.jsx("button",{onClick:s=>{s.stopPropagation(),window.confirm(`Delete "${t}"? It moves to a trash folder (not permanently gone), but disappears from here.`)&&L(e.sessionId)},className:"opacity-0 group-hover/session:opacity-100 px-2 text-gray-600 hover:text-red-400 transition-all flex-shrink-0 text-sm",title:"Delete session",children:"\xd7"})]},e.sessionId)})})]},t)})]})}),"prs"===eH&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"px-3 py-2 border-b border-gray-800/40 flex items-center justify-between gap-2",children:[a.jsx("span",{className:"text-xs text-gray-600",children:E?`${ts} open \xb7 updated ${v(E.fetchedAt)}`:"Loading your GitHub PRs…"}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[a.jsx("button",{onClick:_,className:"bg-gray-800 hover:bg-gray-700 text-gray-200 rounded px-2.5 py-1 text-xs font-medium",title:"Open PR dashboard",children:"\uD83D\uDCCA Stats"}),(0,a.jsxs)("button",{onClick:F,disabled:U,className:"bg-gray-800 hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-200 rounded px-2.5 py-1 text-xs font-medium flex items-center gap-1.5",children:[U&&a.jsx("span",{className:"inline-block w-3 h-3 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}),U?"Refreshing…":"Refresh"]})]})]}),E?.error&&a.jsx("div",{className:"px-3 py-1.5 border-b border-yellow-800/40 bg-yellow-900/20 text-yellow-500 text-xs",children:E.error}),te>0&&a.jsx("div",{className:"px-3 py-1.5 border-b border-gray-800/40",children:a.jsx("button",{onClick:()=>eP(e=>!e),className:"text-xs text-gray-600 hover:text-gray-400",children:eR?`Hide dismissed (${te})`:`Show ${te} dismissed`})}),a.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:T&&!E?a.jsx("p",{className:"text-xs text-gray-600 text-center mt-8",children:"Loading…"}):(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[e6.map(e=>{let t="mergedRecent"===e.key,s=t&&eO;return(0,a.jsxs)("div",{children:[(0,a.jsxs)("button",{onClick:t?()=>eM(e=>!e):void 0,className:`w-full flex items-center gap-2 mb-1.5 ${t?"cursor-pointer":"cursor-default"}`,children:[a.jsx("span",{className:`text-xs font-semibold uppercase tracking-wide ${e.accent}`,children:e.title}),a.jsx("span",{className:"text-xs text-gray-700 bg-gray-800 rounded-full px-1.5 py-0.5 font-medium",children:e.items.length}),t&&a.jsx("span",{className:"text-xs text-gray-600 ml-auto",children:s?"▸":"▾"})]}),!s&&(0===e.items.length?a.jsx("p",{className:"text-xs text-gray-700 pl-1",children:"Nothing here \uD83C\uDF89"}):a.jsx("div",{className:"flex flex-col gap-1.5",children:e.items.map(e=>a.jsx(S,{pr:e,isDismissed:!!eI[e.url],onToggleDismiss:e0,onAttachLive:g,onSelectHistory:M},e.url))}))]},e.key)}),e7.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500",children:"From sessions"}),a.jsx("span",{className:"text-xs text-gray-700 bg-gray-800 rounded-full px-1.5 py-0.5 font-medium",children:e7.length})]}),a.jsx("div",{className:"flex flex-col gap-1.5",children:e7.map(e=>a.jsx(k,{entry:e,title:w(e,em,n),isPinned:!!eD[e.prUrl],isDismissed:!!eI[e.prUrl],onTogglePin:eZ,onToggleDismiss:e0,onRename:e1,onAttachLive:g,onSelectHistory:M},e.prUrl+(e.liveId??e.sessionId??"")))})]})]})})]}),"usage"===eH&&a.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:ei?(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[t.filter(e=>"all"===s||e.id===s).map(e=>{let t=ei.orgs[e.id];return t?(0,a.jsxs)("div",{className:"rounded-lg bg-gray-900 px-3 py-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-gray-100 font-medium",children:e.name}),(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:[t.sessions," sessions"]})]}),a.jsx("div",{className:"grid grid-cols-3 gap-2 mb-2",children:[["5h",t.last5h],["24h",t.last24h],["7d",t.last7d]].map(([e,t])=>(0,a.jsxs)("div",{className:"rounded bg-gray-800/60 px-2 py-1.5 text-center",children:[a.jsx("p",{className:"text-[10px] text-gray-500 uppercase",children:e}),a.jsx("p",{className:"text-sm text-white font-semibold",children:j(t.costUSD)}),(0,a.jsxs)("p",{className:"text-[10px] text-gray-600",children:[N(t.outputTokens)," out"]})]},e))}),(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs text-gray-500",children:[(0,a.jsxs)("span",{children:["All-time value: ",a.jsx("span",{className:"text-gray-300 font-medium",children:j(t.totalCostUSD)})]}),(0,a.jsxs)("span",{children:[N(t.totalTokens.input+t.totalTokens.output)," in+out \xb7 ",N(t.totalTokens.cacheRead)," cached"]})]})]},e.id):(0,a.jsxs)("div",{className:"rounded-lg bg-gray-900 px-3 py-2.5",children:[a.jsx("p",{className:"text-sm text-gray-100 font-medium",children:e.name}),a.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"No usage recorded"})]},e.id)}),(0,a.jsxs)("p",{className:"text-[10px] text-gray-700 leading-relaxed px-1",children:["Costs are estimated API-equivalent value computed from transcripts (you pay via subscription). The 5h and 7d windows mirror your plan's rate-limit windows — for official remaining quota run",a.jsx("code",{className:"text-gray-500",children:" /usage"})," inside any Claude session."]})]}):a.jsx("p",{className:"text-xs text-gray-600 text-center mt-8",children:"Scanning transcripts…"})}),e5&&(0,a.jsxs)("div",{className:"fixed bottom-4 left-4 z-50 w-80 rounded-lg border border-amber-700/60 bg-gray-900 shadow-xl p-3",children:[a.jsx("p",{className:"text-[11px] uppercase tracking-wide text-amber-400 mb-1",children:"⏰ Reminder"}),a.jsx("p",{className:"text-sm text-gray-100 whitespace-pre-wrap break-words max-h-32 overflow-y-auto",children:e5.text}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-3 mt-2 text-xs",children:[a.jsx("button",{onClick:()=>{(function(e,t){let s=t?new Date(t).getTime():void 0;V(t=>t.map(t=>t.id===e?{...t,remindAt:s,reminderDone:!1}:t))})(e5.id,function(e){let t=new Date(e);return new Date(t.getTime()-6e4*t.getTimezoneOffset()).toISOString().slice(0,16)}(Date.now()+6e5)),e2(null)},className:"text-gray-400 hover:text-white",children:"Snooze 10m"}),a.jsx("button",{onClick:()=>e2(null),className:"px-3 py-1 rounded bg-amber-600 hover:bg-amber-500 text-white font-medium",children:"Dismiss"})]})]})]})}var P=s(444);let O=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,M=({text:e})=>a.jsx("span",{title:e,"aria-label":e,className:"ml-1 inline-flex items-center justify-center w-3.5 h-3.5 rounded-full border border-gray-600 text-[9px] text-gray-400 cursor-help align-middle",children:"?"});function L({knownCwds:e,orgs:t,defaultOrgId:s,onAddOrg:l,onConfirm:n,onResumeById:i,onCancel:o}){let[d,c]=(0,r.useState)(""),[x,u]=(0,r.useState)(!1),[m,g]=(0,r.useState)(""),[p,h]=(0,r.useState)(!1),[b,y]=(0,r.useState)(""),[f,j]=(0,r.useState)(s??"default"),[N,v]=(0,r.useState)(""),[w,k]=(0,r.useState)([{id:"claude",label:"Claude"}]),[S,C]=(0,r.useState)("claude"),[D,$]=(0,r.useState)([]),[I,A]=(0,r.useState)(""),[R,L]=(0,r.useState)(!1),[E,T]=(0,r.useState)(null),[U,F]=(0,r.useState)({}),[_,H]=(0,r.useState)(!1),[J,B]=(0,r.useState)(!1),[q,z]=(0,r.useState)(""),[W,G]=(0,r.useState)(""),[K,Y]=(0,r.useState)(""),[V,X]=(0,r.useState)(null),Q=(0,r.useMemo)(()=>{let t=e=>/\/General(\/[^/]+)?$/.test(e)||/\/\.(claude-session-manager|polyergon[^/]*)(\/|$)/.test(e)||/^\/private\/(tmp|var\/folders)\//.test(e)||"/tmp"===e;return Array.from(new Set(e.filter(Boolean))).filter(e=>!t(e)).sort((e,t)=>{let s=e.split("/").at(-1)??e,a=t.split("/").at(-1)??t;return s.localeCompare(a)})},[e]),Z=U.backend===S&&U.model===I&&!!I,[ee,et]=(0,r.useState)(!1),[es,ea]=(0,r.useState)(""),[er,el]=(0,r.useState)(null),[en,ei]=(0,r.useState)(""),[eo,ed]=(0,r.useState)(""),ec=/^https:\/\/[\w.-]+\.slack\.com\/archives\//.test(en.trim()),ex=(er?.name??es).replace(/^#/,"").trim();function eu(e){localStorage.setItem("lastCwd",e),n(e,b.trim(),f,S,I)}async function em(){X(null);try{let e=await l(q.trim(),W.trim(),K.trim()||void 0);j(e.id),B(!1),z(""),G(""),Y("")}catch(e){X(e instanceof Error?e.message:"Failed to add org")}}return a.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:o,children:(0,a.jsxs)("div",{className:"bg-gray-900 border border-gray-700 rounded-lg p-6 w-[480px] max-h-[92vh] overflow-y-auto shadow-xl",onClick:e=>e.stopPropagation(),children:[a.jsx("h2",{className:"text-white font-semibold mb-1",children:"New Session"}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 mb-4",children:["Pick how to start. ",a.jsx("b",{className:"text-gray-400",children:"Just chat"})," works for most things; pick a folder only when Claude should work on that code."]}),a.jsx("input",{type:"text",value:b,onChange:e=>y(e.target.value),placeholder:"Session name (optional)",title:"Shown on the session card, in History and in Remote Control. Leave empty and Claude names it from your first message.",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 placeholder-gray-600 mb-4",autoFocus:!0}),(0,a.jsxs)("div",{className:"mb-3",children:[(0,a.jsxs)("label",{className:"text-xs text-gray-500 mb-1 block",children:["Org",a.jsx(M,{text:"Which Claude account runs this session. Each org has its own login, billing, skills, Slack and integrations."})]}),a.jsx("select",{value:f,onChange:e=>j(e.target.value),className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500",children:t.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))}),J?(0,a.jsxs)("div",{className:"mt-2 space-y-2 border border-dashed border-gray-700 rounded p-3",children:[a.jsx("input",{type:"text",value:q,onChange:e=>z(e.target.value),placeholder:"Org name (e.g. Claude Teams)",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 placeholder-gray-600"}),a.jsx("input",{type:"text",value:W,onChange:e=>G(e.target.value),placeholder:"/Users/you/.claude-teams",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none font-mono border border-gray-700 focus:border-blue-500 placeholder-gray-600"}),a.jsx("input",{type:"text",value:K,onChange:e=>Y(e.target.value),placeholder:"Default model (optional, e.g. claude-opus-4-8)",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none font-mono border border-gray-700 focus:border-blue-500 placeholder-gray-600"}),a.jsx("p",{className:"text-xs text-gray-500",children:"A folder where this org's Claude settings and login live (it's created if missing). After adding, sign in from Settings → Claude sign-in."}),V&&a.jsx("p",{className:"text-xs text-red-400",children:V}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:()=>{B(!1),X(null)},className:"text-xs text-gray-500 hover:text-gray-300",children:"← Back"}),a.jsx("button",{onClick:em,disabled:!q.trim()||!W.trim().startsWith("/"),className:"px-3 py-1 text-xs bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded font-medium",children:"Add org"})]})]}):a.jsx("button",{onClick:()=>B(!0),className:"w-full text-left px-3 py-2 mt-2 text-sm text-gray-500 hover:text-gray-300 border border-dashed border-gray-700 rounded hover:border-gray-500 transition-colors",children:a.jsx("span",{title:"Add another Claude account (e.g. a second company) with its own config folder.",children:"+ Register new org…"})})]}),(0,a.jsxs)("div",{className:"mb-3 grid grid-cols-2 gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs text-gray-500 mb-1 block",children:["Agent",a.jsx(M,{text:"The CLI that runs the session: Claude Code, or GitHub Copilot CLI when installed."})]}),a.jsx("select",{value:S,onChange:e=>C(e.target.value),disabled:w.length<2,className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 disabled:opacity-60",children:w.map(e=>a.jsx("option",{value:e.id,children:e.label},e.id))})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs text-gray-500 mb-1 block",children:["Model",a.jsx(M,{text:"The model the session starts with. You can switch later inside the session with /model."})]}),(0,a.jsxs)("select",{value:I,onChange:e=>A(e.target.value),disabled:R||0===D.length,className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 disabled:opacity-60",children:[R&&a.jsx("option",{children:"Loading…"}),!R&&0===D.length&&a.jsx("option",{value:"",children:E??"No models"}),D.map(e=>a.jsx("option",{value:e.id,children:e.displayName},e.id))]})]})]}),a.jsx("div",{className:"flex items-center gap-2 mb-3 -mt-1",children:a.jsx("button",{onClick:function(){if(!I)return;let e={backend:S,model:I};try{localStorage.setItem("claude-session-default",JSON.stringify(e))}catch{}F(e),H(!0),setTimeout(()=>H(!1),1500)},title:"Pre-select this agent and model every time you open New Session",disabled:!I||Z,className:"text-xs text-gray-500 hover:text-blue-400 disabled:hover:text-gray-500 disabled:opacity-50 transition-colors",children:_?"✓ Saved as default":Z?"✓ This is your default":"☆ Set as default agent & model"})}),E&&D.length>0&&(0,a.jsxs)("p",{className:"text-xs text-amber-500/80 -mt-2 mb-3",children:["Showing cached models — ",E]}),!x&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{onClick:()=>eu("general"),title:"Starts in a private scratch folder. Good for questions, research, Slack, docs and one-off tasks.",className:"w-full text-left px-3 py-2.5 mb-3 flex items-center gap-3 rounded border border-gray-700 hover:bg-gray-800 hover:border-gray-600 transition-colors",children:[a.jsx("span",{className:"text-lg leading-none",children:"\uD83D\uDCAC"}),(0,a.jsxs)("span",{className:"flex flex-col",children:[a.jsx("span",{className:"text-sm text-white font-medium",children:"Just chat"}),a.jsx("span",{className:"text-xs text-gray-500",children:"Ask a question or run a quick task — not tied to a project"})]})]}),ee?(0,a.jsxs)("div",{className:"mb-3 rounded border border-purple-800/60 bg-purple-950/20 p-3 space-y-2",children:[a.jsx("p",{className:"text-xs text-gray-300 font-medium",children:"Start from Slack"}),a.jsx(P.a,{value:es,onChange:(e,t)=>{ea(e),el(t),ei("")},className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 placeholder-gray-600"}),a.jsx("input",{value:en,onChange:e=>{ei(e.target.value),e.target.value&&(ea(""),el(null))},placeholder:"…or paste a link to a message, thread or DM",title:"In Slack: hover a message → ⋮ → Copy link",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 placeholder-gray-600"}),en&&!ec&&a.jsx("p",{className:"text-[11px] text-red-400",children:"Paste a Slack link (https://…slack.com/archives/…)"}),a.jsx("input",{value:eo,onChange:e=>ed(e.target.value),placeholder:"What should Claude do with it? (optional)",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 placeholder-gray-600"}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:()=>et(!1),className:"text-xs text-gray-500 hover:text-gray-300",children:"← Back"}),a.jsx("button",{onClick:function(){let e=ec?`the Slack message, thread or DM at ${en.trim()} (read the whole thread)`:`the Slack channel ${er?.id?`${er.id} (#${ex})`:`#${ex}`} (the last 2 days, including thread replies)`,t=`Use the Slack connector to read ${e}. Give me a short summary: what it is about, the open questions, and what is asked of me. `+(eo.trim()?`Then: ${eo.trim()}`:"Then wait for my instructions.")+" Do not post anything to Slack unless I approve it.";n(N&&"general"!==N?N:"general",b.trim()||(ec?"From Slack thread":`Slack #${ex}`),f,S,I,t)},disabled:!I||!(ec||ex),className:"ml-auto px-3 py-1 text-xs bg-purple-600 hover:bg-purple-500 disabled:opacity-50 text-white rounded font-medium",children:"Start with this context"})]}),a.jsx("p",{className:"text-[11px] text-gray-500",children:"The session reads it first and summarizes. Nothing is posted to Slack."})]}):(0,a.jsxs)("button",{onClick:()=>et(!0),title:"The new session reads a Slack channel, thread or DM first, so it starts with the context",className:"w-full text-left px-3 py-2.5 mb-3 flex items-center gap-3 rounded border border-gray-700 hover:bg-gray-800 hover:border-gray-600 transition-colors",children:[a.jsx("span",{className:"text-lg leading-none",children:"#"}),(0,a.jsxs)("span",{className:"flex flex-col",children:[a.jsx("span",{className:"text-sm text-white font-medium",children:"Start from Slack"}),a.jsx("span",{className:"text-xs text-gray-500",children:"A channel, thread or DM becomes the session's context"})]})]}),Q.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"text-[11px] uppercase tracking-wide text-gray-600 mb-1",children:["Or work in a folder",a.jsx(M,{text:"Claude starts inside this folder: it reads and edits its files, runs commands there, and loads the folder's CLAUDE.md. Listed: folders you used before."})]}),a.jsx("div",{className:"max-h-56 overflow-y-auto rounded border border-gray-700 mb-3",children:Q.map(e=>{let t=e.split("/").at(-1)||e;return(0,a.jsxs)("button",{onClick:()=>eu(e),title:`Start Claude inside ${e}`,className:"w-full text-left px-3 py-2.5 flex flex-col border-b border-gray-800 last:border-0 hover:bg-gray-800 transition-colors",children:[a.jsx("span",{className:"text-sm text-gray-200 font-medium",children:t}),a.jsx("span",{className:"text-xs text-gray-500 truncate",children:e})]},e)})})]})]}),x?(0,a.jsxs)("div",{className:"mb-3",children:[a.jsx("input",{type:"text",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&d.trim()&&eu(d.trim()),"Escape"===e.key&&(u(!1),c(""))},placeholder:"/Users/you/your-project",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none font-mono border border-gray-700 focus:border-blue-500",autoFocus:!0}),(0,a.jsxs)("div",{className:"flex items-center gap-3 mt-2",children:[a.jsx("button",{onClick:()=>{u(!1),c("")},className:"text-xs text-gray-500 hover:text-gray-300",children:"← Back"}),a.jsx("button",{onClick:()=>d.trim()&&eu(d.trim()),disabled:!d.trim(),className:"px-3 py-1 text-xs bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded font-medium",children:"Start"})]})]}):a.jsx("button",{onClick:()=>u(!0),title:"Type the full path of any folder on this Mac, e.g. a repo you haven't used here yet",className:"w-full text-left px-3 py-2 text-sm text-gray-500 hover:text-gray-300 border border-dashed border-gray-700 rounded hover:border-gray-500 transition-colors mb-3",children:"+ Open a different folder…"}),a.jsx("div",{className:"border-t border-gray-700/50 pt-3",children:p?(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs text-gray-500 mb-1 block",children:"Session ID"}),a.jsx("input",{type:"text",value:m,onChange:e=>g(e.target.value.trim()),onKeyDown:e=>{"Enter"===e.key&&O.test(m)&&i(m,b.trim(),f,S,I),"Escape"===e.key&&(h(!1),g(""))},placeholder:"6a047330-816f-45a1-86fc-9fba8280f12c",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none font-mono border border-gray-700 focus:border-blue-500",autoFocus:!0}),m&&!O.test(m)&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:"Paste a valid session UUID"}),(0,a.jsxs)("div",{className:"flex items-center gap-3 mt-2",children:[a.jsx("button",{onClick:()=>{h(!1),g("")},className:"text-xs text-gray-500 hover:text-gray-300",children:"← Back"}),a.jsx("button",{onClick:()=>i(m,b.trim(),f,S,I),disabled:!O.test(m),className:"px-3 py-1 text-xs bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded font-medium",children:"Resume"})]})]}):a.jsx("button",{onClick:()=>h(!0),title:"Continue an existing Claude conversation (from the terminal or another app) by pasting its session ID",className:"w-full text-left px-3 py-2 text-sm text-gray-500 hover:text-gray-300 border border-dashed border-gray-700 rounded hover:border-gray-500 transition-colors",children:"↩ Resume by session ID…"})}),(0,a.jsxs)("div",{className:"flex justify-end items-center gap-2 mt-4",children:[a.jsx("button",{onClick:o,className:"px-4 py-2 text-sm text-gray-400 hover:text-white",children:"Cancel"}),(0,a.jsxs)("button",{onClick:()=>eu(N||"general"),disabled:!I,className:"px-4 py-2 text-sm bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded font-medium",children:["Start ",N&&"general"!==N?`\xb7 ${N.split("/").at(-1)}`:"chat"]})]})]})})}function E({orgs:e,defaultOrgId:t,onStart:s,onCancel:l,onMicTest:n}){let[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(t),[x,u]=(0,r.useState)(!1),[m,g]=(0,r.useState)(null);async function p(){u(!0),g(null),g(await n()),u(!1)}let h=m?.level!==void 0?Math.min(10,Math.round(100*m.level)):0;return a.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:l,children:(0,a.jsxs)("div",{className:"bg-gray-900 border border-gray-700 rounded-lg p-6 w-[440px] shadow-xl",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("h2",{className:"text-white font-semibold mb-1 flex items-center gap-2",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-red-500"})," Record Meeting"]}),a.jsx("p",{className:"text-xs text-gray-500 mb-4",children:'Captures meeting audio (via BlackHole) + your mic. Set your Mac\'s sound output to "Claude Playback" first so you hear the meeting while it records.'}),a.jsx("input",{type:"text",value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&s(i.trim(),d)},placeholder:"Meeting title (optional)",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-red-500 placeholder-gray-600 mb-3",autoFocus:!0}),a.jsx("label",{className:"text-xs text-gray-500 mb-1 block",children:"Org"}),a.jsx("select",{value:d,onChange:e=>c(e.target.value),className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-red-500 mb-4",children:e.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))}),(0,a.jsxs)("div",{className:"border border-gray-800 rounded-lg p-3 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("button",{onClick:p,disabled:x,className:"bg-gray-800 hover:bg-gray-700 disabled:opacity-50 text-gray-200 rounded px-3 py-1.5 text-xs font-medium",children:x?"Listening… (2s)":"Test audio"}),a.jsx("div",{className:"flex items-end gap-0.5 h-5 flex-1 justify-end",children:Array.from({length:10},(e,t)=>a.jsx("span",{className:`w-1.5 rounded-sm ${t<h?t<7?"bg-green-500":"bg-yellow-400":"bg-gray-800"}`,style:{height:`${6+1.5*t}px`}},t))})]}),m?.error&&a.jsx("p",{className:"text-xs text-red-400 mt-2",children:m.error}),m?.level!==void 0&&m.level<.004&&a.jsx("p",{className:"text-xs text-yellow-500 mt-2",children:"Silence detected — check the aggregate device and that audio is playing."}),m?.level!==void 0&&m.level>=.004&&a.jsx("p",{className:"text-xs text-green-500 mt-2",children:"Audio detected ✓"})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-3",children:[a.jsx("button",{onClick:l,className:"px-4 py-2 text-sm text-gray-400 hover:text-white",children:"Cancel"}),(0,a.jsxs)("button",{onClick:()=>s(i.trim(),d),className:"px-4 py-2 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg font-medium flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 rounded-full bg-white animate-pulse"})," Start recording"]})]})]})})}function T(e){return e.split(/(\*\*[^*]+\*\*|`[^`]+`)/g).map((e,t)=>e.startsWith("**")&&e.endsWith("**")?a.jsx("strong",{className:"text-gray-100 font-semibold",children:e.slice(2,-2)},t):e.startsWith("`")&&e.endsWith("`")?a.jsx("code",{className:"bg-gray-800 rounded px-1 text-[0.9em]",children:e.slice(1,-1)},t):a.jsx(r.Fragment,{children:e},t))}function U({text:e}){let t=[],s=[],r=()=>{s.length&&t.push({kind:"p",text:s.join(" ")}),s=[]};for(let a of e.split("\n")){let e=a.match(/^(#{1,4})\s+(.*)/),l=a.match(/^(\s*)([-*]|\d+[.)])\s+(.*)/),n=t.at(-1);e?(r(),t.push({kind:"h",text:e[2]})):l?(r(),t.push({kind:"li",indent:l[1].length,marker:l[2],text:l[3]})):a.trim()?!s.length&&n?.kind==="li"&&/^\s+\S/.test(a)?n.text+=" "+a.trim():s.push(a.trim()):r()}return r(),a.jsx("div",{className:"text-sm text-gray-300 leading-relaxed",children:t.map((e,t)=>"h"===e.kind?a.jsx("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mt-5 mb-2 first:mt-0",children:T(e.text)},t):"li"===e.kind?(0,a.jsxs)("div",{className:"flex gap-2 mb-1.5",style:{paddingLeft:8*Math.min(e.indent,8)},children:[a.jsx("span",{className:"text-gray-500 flex-shrink-0 w-4 text-right",children:/\d/.test(e.marker)?e.marker:"•"}),a.jsx("span",{children:T(e.text)})]},t):a.jsx("p",{className:"mb-3",children:T(e.text)},t))})}var F=s(9532);function _({meetingId:e,title:t,onClose:s}){let[l,n]=(0,r.useState)(null),[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(null),[x,u]=(0,r.useState)("idle"),[m,g]=(0,r.useState)("");async function p(){let t=(d?.name??i).replace(/^#/,"").trim();if(!t)return;u("sending"),g("");let s=await fetch(`/api/meetings/${e}/slack`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:{id:d?.id??"",name:t}})}),a=await s.json().catch(()=>({}));s.ok?u("sent"):(g(a.error??"Could not send"),u("error"))}return a.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:s,children:(0,a.jsxs)("div",{className:"w-full max-w-xl max-h-[90vh] overflow-y-auto bg-gray-900 border border-gray-700 rounded-xl p-5 text-white",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("h2",{className:"text-base font-semibold truncate",children:["Send summary to Slack \xb7 ",t]}),a.jsx("button",{onClick:s,className:"text-gray-500 hover:text-white","aria-label":"Close",children:"✕"})]}),a.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Channel"}),a.jsx(P.a,{value:i,onChange:(e,t)=>{o(e),c(t),"sending"!==x&&u("idle")},onEnter:p,className:"w-full bg-gray-800 border border-gray-700 focus:border-gray-500 rounded-md px-2.5 py-1.5 text-sm text-white outline-none placeholder-gray-500"}),a.jsx("p",{className:"text-xs text-gray-400 mt-4 mb-1",children:"Message"}),a.jsx("pre",{className:"text-xs text-gray-300 bg-gray-950 border border-gray-800 rounded-md p-3 whitespace-pre-wrap max-h-72 overflow-y-auto font-sans",children:l??("error"===x?"":"Loading…")}),"error"===x&&a.jsx("p",{className:"text-xs text-red-400 mt-3",children:m}),"sent"===x&&(0,a.jsxs)("p",{className:"text-xs text-green-400 mt-3",children:["Posted to #",(d?.name??i).replace(/^#/,""),"."]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[a.jsx("button",{onClick:s,className:"px-3 py-1.5 text-sm text-gray-400 hover:text-white",children:"sent"===x?"Close":"Cancel"}),"sent"!==x&&a.jsx("button",{onClick:p,disabled:!l||!i.trim()||"sending"===x,className:"px-3 py-1.5 text-sm rounded-md bg-blue-600 hover:bg-blue-500 disabled:opacity-40",children:"sending"===x?"Sending…":"Send"})]})]})})}function H(e){let t=Math.floor(e/1e3),s=Math.floor(t/3600),a=Math.floor(t%3600/60);return s>0?`${s}h ${a}m`:`${a}m ${t%60}s`}function J(e){let t=Math.max(0,Math.floor(e/1e3)),s=Math.floor(t/3600),a=String(Math.floor(t%3600/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");return s?`${s}:${a}:${r}`:`${a}:${r}`}function B({text:e,q:t}){if(!t)return a.jsx(a.Fragment,{children:e});let s=RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return a.jsx(a.Fragment,{children:e.split(s).map((e,t)=>t%2?a.jsx("mark",{className:"bg-amber-400/25 text-amber-100 rounded-sm px-0.5",children:e},t):e)})}function q({notes:e}){let t=(e,t,s)=>t.length>0&&(0,a.jsxs)("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[(0,a.jsxs)("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-3",children:[e," ",a.jsx("span",{className:"text-gray-600",children:t.length})]}),a.jsx("ul",{className:"space-y-2",children:t.map((e,t)=>(0,a.jsxs)("li",{className:"flex gap-2.5 text-sm text-gray-300 leading-relaxed",children:[a.jsx("span",{className:"text-gray-500 flex-shrink-0",children:s}),a.jsx("span",{children:e})]},t))})]});return(0,a.jsxs)("div",{className:"space-y-4",children:[t("Decisions",e.decisions,"✓"),t("Action items",e.actionItems,"☐"),t("Topics",e.topics,"•")]})}let z=[{kind:"link",label:"Link / file"},{kind:"slack",label:"Slack channel"},{kind:"text",label:"Paste text"},{kind:"session",label:"Session"},{kind:"meeting",label:"Past meeting"}],W={loading:"⏳",loaded:"✓",failed:"⚠"};function G({items:e,isLive:t,onAdd:s,sessionOptions:l,meetingOptions:n}){let[i,o]=(0,r.useState)("link"),[d,c]=(0,r.useState)(""),[x,u]=(0,r.useState)(""),m="w-full bg-gray-900 text-white rounded-lg px-2.5 py-1.5 text-xs outline-none border border-gray-800 focus:border-blue-600 placeholder-gray-600",g="session"===i?l:n;function p(){d.trim()&&(s(i,d),c(""),u(""))}return(0,a.jsxs)("div",{children:[a.jsx("p",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-2",children:"Context"}),0===e.length&&!t&&a.jsx("p",{className:"text-xs text-gray-600",children:"No extra context was added."}),a.jsx("ul",{className:"space-y-1.5 mb-2",children:e.map(e=>(0,a.jsxs)("li",{className:"text-xs rounded-md bg-gray-900 px-2.5 py-1.5",title:"text"===e.kind?e.value.slice(0,500):e.value,children:[(0,a.jsxs)("div",{className:"flex gap-1.5",children:[a.jsx("span",{className:"failed"===e.status?"text-amber-400":"loaded"===e.status?"text-green-400":"",children:W[e.status]}),a.jsx("span",{className:"text-gray-200 truncate",children:e.label})]}),e.summary&&a.jsx("p",{className:`mt-0.5 leading-snug ${"failed"===e.status?"text-amber-400/80":"text-gray-500"}`,children:e.summary}),"loading"===e.status&&a.jsx("p",{className:"mt-0.5 text-gray-600 italic",children:"Claude is reading it…"})]},e.id))}),t&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[a.jsx("div",{className:"flex flex-wrap gap-1",children:z.map(e=>a.jsx("button",{onClick:()=>{o(e.kind),c(""),u("")},className:`px-2 py-0.5 rounded text-[11px] border ${i===e.kind?"bg-gray-700 border-gray-500 text-gray-100":"border-gray-800 text-gray-500 hover:text-gray-300"}`,children:e.label},e.kind))}),"text"===i&&a.jsx("textarea",{value:d,onChange:e=>c(e.target.value),rows:3,placeholder:"Paste an agenda, email, doc excerpt…",className:`${m} resize-none`}),"slack"===i&&a.jsx(P.a,{value:d,onChange:e=>c(e),onEnter:p,className:m}),"link"===i&&a.jsx("input",{value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&p()},placeholder:"URL, file path, or Slack / Notion / Drive link",className:m}),("session"===i||"meeting"===i)&&(0,a.jsxs)(a.Fragment,{children:[a.jsx(F.h,{options:g,value:x,onChange:e=>{u(e),c("")},onPick:e=>{u(e.label),c(e.id)},onEnter:p,placeholder:g.length?`Type to find a ${"session"===i?"session":"meeting"}…`:"None available",className:m}),x&&!d&&a.jsx("p",{className:"text-[11px] text-gray-500",children:"Pick one of the suggestions."})]}),a.jsx("button",{onClick:p,disabled:!d.trim(),className:"w-full text-xs rounded-md bg-gray-800 hover:bg-gray-700 border border-gray-700 py-1 disabled:opacity-40",children:"+ Add context"})]})]})}function K({meeting:e,live:t,orgName:s,onStop:l,onResume:n,onAsk:i,onAddContext:o,onBack:d,sessionOptions:c,meetingOptions:x}){let[u,m]=(0,r.useState)([]),[g,p]=(0,r.useState)(null),[h,b]=(0,r.useState)(null),[y,f]=(0,r.useState)([]),[j,N]=(0,r.useState)(""),[v,w]=(0,r.useState)({}),[k,S]=(0,r.useState)(!1),[C,D]=(0,r.useState)(!1),[$,I]=(0,r.useState)(!1),[A,R]=(0,r.useState)(Date.now()),P="recording"===e.status,[O,M]=(0,r.useState)(P?"transcript":"summary"),[L,E]=(0,r.useState)(""),T=(0,r.useRef)(null),F=(0,r.useMemo)(()=>{let e=t?.transcript??[],s=u.at(-1)?.t??0;return[...u,...e.filter(e=>e.t>s)]},[u,t?.transcript]),z=t?.notes??g,W=t?.context??y,K=L.trim(),Y=K?F.filter(e=>e.text.toLowerCase().includes(K.toLowerCase())):F,V=(t?.suggestions??[]).filter(e=>!v[e.id]),X=t?.qa??[],Q=(e,t)=>a.jsx("button",{onClick:()=>M(e),className:`px-1 pb-2.5 pt-1 text-sm border-b-2 transition-colors ${O===e?"border-blue-500 text-white":"border-transparent text-gray-500 hover:text-gray-300"}`,children:t});return(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col bg-gray-950 overflow-hidden",children:[(0,a.jsxs)("div",{className:"px-6 pt-4 pb-3 border-b border-gray-800 flex-shrink-0",children:[a.jsx("button",{onClick:d,className:"text-xs text-gray-500 hover:text-gray-300 mb-2",children:"← Recordings"}),(0,a.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[P&&a.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-red-500 animate-pulse flex-shrink-0"}),a.jsx("h1",{className:"text-xl font-semibold text-white truncate",children:e.title}),s&&a.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-900/50 text-purple-300 text-[10px] font-medium flex-shrink-0",children:s})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 mt-1 tabular-nums",children:[new Date(e.startedAt).toLocaleString(void 0,{weekday:"short",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})," \xb7 ",P?(0,a.jsxs)("span",{className:"text-red-400",children:["Recording ",H(A-e.startedAt)]}):e.endedAt?H(e.endedAt-e.startedAt):"","interrupted"===e.status&&a.jsx("span",{className:"text-amber-400",children:" \xb7 interrupted"}),z&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 ",z.decisions.length," decisions \xb7 ",z.actionItems.length," action items"]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!P&&a.jsx("button",{onClick:()=>n(e.id),className:"text-xs bg-red-600/90 hover:bg-red-500 text-white rounded-md px-3 py-1.5 font-medium",children:"● Continue recording"}),!P&&h&&a.jsx("button",{onClick:()=>I(!0),className:"text-xs border border-gray-700 hover:bg-gray-800 text-gray-200 rounded-md px-3 py-1.5",children:"Send to Slack"}),!P&&a.jsx("button",{onClick:function(){let t=[`# ${e.title}`,`_${new Date(e.startedAt).toLocaleString()}${e.endedAt?` — ${H(e.endedAt-e.startedAt)}`:""}_`,"",h??"","","## Transcript",...F.map(t=>`- **${J(t.t-e.startedAt)}** ${t.text}`)].join("\n");navigator.clipboard.writeText(t).then(()=>{D(!0),setTimeout(()=>D(!1),1500)}).catch(()=>{})},className:"text-xs border border-gray-700 hover:bg-gray-800 text-gray-200 rounded-md px-3 py-1.5",children:C?"Copied ✓":"Copy as Markdown"}),P&&a.jsx("button",{onClick:()=>{S(!0),l(e.id)},disabled:k,className:"text-xs bg-red-600 hover:bg-red-500 disabled:opacity-60 text-white rounded-md px-3 py-1.5 font-medium",children:k?"Stopping — writing summary…":"■ Stop recording"})]})]})]}),$&&a.jsx(_,{meetingId:e.id,title:e.title,onClose:()=>I(!1)}),t?.lastError&&a.jsx("div",{className:"px-6 py-1.5 bg-amber-900/20 border-b border-amber-800/30 text-amber-400 text-xs flex-shrink-0",children:t.lastError}),(0,a.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,a.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,a.jsxs)("div",{className:"px-6 pt-2 border-b border-gray-800 flex items-end gap-5 flex-shrink-0",children:[Q("summary",P?"Live notes":"Summary"),Q("transcript",`Transcript${F.length?` \xb7 ${F.length}`:""}`),"transcript"===O&&F.length>0&&a.jsx("input",{value:L,onChange:e=>E(e.target.value),placeholder:"Find in transcript",className:"ml-auto mb-2 w-56 bg-gray-900 border border-gray-800 focus:border-gray-600 rounded-md px-2.5 py-1 text-xs outline-none placeholder-gray-600"})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto",children:["summary"===O&&a.jsx("div",{className:"px-6 py-5 max-w-3xl",children:h?a.jsx(U,{text:h}):z?a.jsx(q,{notes:z}):a.jsx("p",{className:"text-sm text-gray-500",children:P?"Notes appear here every couple of minutes while people talk.":"No summary was generated for this meeting."})}),"transcript"===O&&(0,a.jsxs)("div",{className:"px-6 py-4 max-w-4xl",children:[0===Y.length?a.jsx("p",{className:"text-sm text-gray-500",children:K?`No lines contain “${K}”.`:P?"Listening… text appears a few seconds after people speak.":"No transcript captured."}):Y.map((t,s)=>(0,a.jsxs)("div",{className:"flex gap-4 py-1.5 group",children:[a.jsx("span",{className:"text-[11px] text-gray-600 font-mono pt-0.5 w-14 flex-shrink-0 text-right tabular-nums",title:new Date(t.t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:J(t.t-e.startedAt)}),a.jsx("p",{className:"text-sm text-gray-300 leading-relaxed",children:a.jsx(B,{text:t.text,q:K})})]},s)),a.jsx("div",{ref:T})]})]})]}),(0,a.jsxs)("div",{className:"w-[360px] flex-shrink-0 border-l border-gray-800 flex flex-col min-h-0 bg-gray-900/20",children:[a.jsx("div",{className:"max-h-[45%] overflow-y-auto px-4 py-4 border-b border-gray-800 flex-shrink-0",children:a.jsx(G,{items:W,isLive:P,onAdd:(t,s)=>o(e.id,t,s),sessionOptions:c,meetingOptions:x.filter(t=>t.id!==e.id)})}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-2.5",children:[a.jsx("p",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide",children:"Assistant"}),V.map(e=>a.jsx("div",{className:"rounded-lg bg-blue-950/50 border border-blue-800/40 px-3 py-2.5",children:(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsxs)("p",{className:"text-xs text-blue-200 leading-relaxed flex-1",children:["\uD83D\uDCA1 ",e.text]}),a.jsx("button",{onClick:()=>w(t=>({...t,[e.id]:!0})),className:"text-blue-700 hover:text-blue-400 text-xs flex-shrink-0","aria-label":"Dismiss",children:"✕"})]})},e.id)),X.map((e,t)=>(0,a.jsxs)("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"ml-8 rounded-lg bg-blue-600/90 text-white text-xs px-3 py-2 leading-relaxed",children:e.question}),a.jsx("div",{className:"mr-4 rounded-lg bg-gray-800/80 px-3 py-2",children:null===e.answer?a.jsx("p",{className:"text-xs text-gray-500 italic",children:"Thinking…"}):a.jsx("p",{className:"text-xs text-gray-200 whitespace-pre-wrap leading-relaxed",children:e.answer})})]},t)),0===V.length&&0===X.length&&a.jsx("p",{className:"text-xs text-gray-600",children:P?"Ask anything about the meeting so far. Suggestions appear here when Claude has something useful.":"Questions asked during the meeting appear here."})]}),P&&a.jsx("div",{className:"px-3 py-3 border-t border-gray-800 flex-shrink-0",children:a.jsx("input",{type:"text",value:j,onChange:e=>N(e.target.value),onKeyDown:t=>{"Enter"===t.key&&function(){let t=j.trim();t&&(N(""),i(e.id,t))}()},placeholder:"Ask Claude… (Enter to send)",className:"w-full bg-gray-900 text-white rounded-lg px-3 py-2 text-sm outline-none border border-gray-800 focus:border-blue-600 placeholder-gray-600"})})]})]})]})]})}function Y(e){return e.endedAt?e.endedAt-e.startedAt:0}function V({text:e,words:t}){if(!t.length)return a.jsx(a.Fragment,{children:e});let s=RegExp(`(${t.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})`,"gi");return a.jsx(a.Fragment,{children:e.split(s).map((e,t)=>t%2?a.jsx("mark",{className:"bg-amber-400/25 text-amber-100 rounded-sm px-0.5",children:e},t):e)})}let X={recording:"bg-red-500/15 text-red-300 ring-red-500/30",ended:"bg-emerald-500/10 text-emerald-300 ring-emerald-500/25",interrupted:"bg-amber-500/10 text-amber-300 ring-amber-500/25"},Q=[["all","Any time"],["7","7 days"],["30","30 days"],["90","90 days"]];function Z({orgs:e,activeOrgId:t,refreshKey:s,onOpen:l,onDeleted:n}){let[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(""),[x,u]=(0,r.useState)("all"),[m,g]=(0,r.useState)("all"),[p,h]=(0,r.useState)({key:"when",desc:!0}),[b,y]=(0,r.useState)(null),[f,j]=(0,r.useState)(!1),[N,v]=(0,r.useState)(null),[w,k]=(0,r.useState)(null),[S,C]=(0,r.useState)(0),[D,$]=(0,r.useState)(null);async function I(e){v(null);let t=await fetch(`/api/meetings/${e}`,{method:"DELETE"});if(!t.ok){k((await t.json().catch(()=>({}))).error??"Could not delete");return}k(null),C(e=>e+1),n()}let A=d.toLowerCase().split(/\s+/).filter(Boolean),R="all"===m?0:Date.now()-864e5*Number(m),P=(b??[]).filter(e=>("all"===t||(e.orgId??"default")===t)&&("all"===x||e.status===x)&&e.startedAt>=R).sort((e,t)=>{let s="when"===p.key?e.startedAt-t.startedAt:Y(e)-Y(t);return p.desc?-s:s}),O=e=>`px-2.5 py-1 rounded-md text-xs transition-colors ${e?"bg-gray-700 text-gray-100":"text-gray-400 hover:text-gray-200 hover:bg-gray-800/60"}`,M="px-4 py-2.5 text-[11px] font-semibold uppercase tracking-wider text-gray-500 whitespace-nowrap",L=(e,t,s="")=>a.jsx("th",{className:`${M} ${s}`,children:(0,a.jsxs)("button",{onClick:()=>h(t=>({key:e,desc:t.key!==e||!t.desc})),className:"hover:text-gray-300 uppercase tracking-wider",children:[t,p.key===e?p.desc?" ▾":" ▴":""]})});return(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col bg-gray-950 text-gray-100",children:[D&&a.jsx(_,{meetingId:D.id,title:D.title,onClose:()=>$(null)}),(0,a.jsxs)("div",{className:"px-6 pt-5 pb-4 flex flex-col gap-3 flex-shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-baseline gap-3",children:[a.jsx("h1",{className:"text-lg font-semibold",children:"Recordings"}),a.jsx("span",{className:"text-xs text-gray-500",children:b?`${P.length} of ${b.length}`:"Loading…"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("div",{className:"relative flex-1 min-w-[260px]",children:[a.jsx("span",{className:"absolute left-3 top-2 text-gray-500 text-sm",children:"⌕"}),a.jsx("input",{autoFocus:!0,value:i,onChange:e=>o(e.target.value),placeholder:"Search titles, summaries, notes and transcripts",className:"w-full bg-gray-900 border border-gray-800 focus:border-gray-600 rounded-lg pl-8 pr-24 py-2 text-sm outline-none placeholder-gray-600"}),f&&a.jsx("span",{className:"absolute right-3 top-2.5 text-xs text-gray-500",children:"searching…"})]}),a.jsx("div",{className:"flex gap-1 bg-gray-900 border border-gray-800 rounded-lg p-0.5",children:["all","ended","interrupted","recording"].map(e=>a.jsx("button",{onClick:()=>u(e),className:O(x===e),children:"all"===e?"All":e[0].toUpperCase()+e.slice(1)},e))}),a.jsx("div",{className:"flex gap-1 bg-gray-900 border border-gray-800 rounded-lg p-0.5",children:Q.map(([e,t])=>a.jsx("button",{onClick:()=>g(e),className:O(m===e),children:t},e))})]}),w&&a.jsx("p",{className:"text-xs text-red-400",children:w})]}),a.jsx("div",{className:"flex-1 overflow-auto px-6 pb-6",children:(0,a.jsxs)("div",{className:"rounded-xl border border-gray-800 bg-gray-900/40 overflow-hidden",children:[(0,a.jsxs)("table",{className:"w-full text-sm border-collapse",children:[a.jsx("thead",{className:"sticky top-0 bg-gray-900 z-10 border-b border-gray-800",children:(0,a.jsxs)("tr",{className:"text-left",children:[L("when","When"),a.jsx("th",{className:M,children:"Meeting"}),L("length","Length","text-right"),a.jsx("th",{className:`${M} text-right`,children:"Decisions"}),a.jsx("th",{className:`${M} text-right`,children:"Action items"}),a.jsx("th",{className:M,children:"Status"}),a.jsx("th",{className:M})]})}),a.jsx("tbody",{children:P.map(t=>{var s;let r="default"!==t.orgId?e.find(e=>e.id===t.orgId)?.name:null;return(0,a.jsxs)("tr",{onClick:()=>l(t.id),className:"border-b border-gray-800/70 last:border-0 hover:bg-gray-800/40 cursor-pointer group",children:[a.jsx("td",{className:"px-4 py-3 text-gray-300 whitespace-nowrap align-top tabular-nums",children:function(e){let t=new Date(e),s=t.getFullYear()===new Date().getFullYear();return t.toLocaleString(void 0,{month:"short",day:"numeric",...s?{}:{year:"numeric"},hour:"2-digit",minute:"2-digit"})}(t.startedAt)}),(0,a.jsxs)("td",{className:"px-4 py-3 align-top max-w-0 w-full",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:["recording"===t.status&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse flex-shrink-0"}),a.jsx("span",{className:"font-medium text-gray-100 truncate",children:a.jsx(V,{text:t.title,words:A})}),r&&a.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-900/50 text-purple-300 text-[10px] font-medium flex-shrink-0",children:r})]}),t.match?a.jsx("p",{className:"text-xs text-gray-400 mt-1 truncate",children:a.jsx(V,{text:t.match,words:A})}):t.snippet&&a.jsx("p",{className:"text-xs text-gray-500 mt-1 truncate",children:t.snippet})]}),a.jsx("td",{className:"px-4 py-3 text-right text-gray-300 whitespace-nowrap align-top tabular-nums",title:`Audio: ${t.audio.chunks} chunks \xb7 ${(s=t.audio.bytes)>=1e9?`${(s/1e9).toFixed(1)} GB`:`${Math.max(1,Math.round(s/1e6))} MB`}`,children:function(e){if(!e)return"—";let t=Math.max(1,Math.round(e/6e4));return t>=60?`${Math.floor(t/60)}h ${String(t%60).padStart(2,"0")}m`:`${t}m`}(Y(t))}),a.jsx("td",{className:"px-4 py-3 text-right text-gray-300 align-top tabular-nums",children:t.counts.decisions||a.jsx("span",{className:"text-gray-600",children:"—"})}),a.jsx("td",{className:"px-4 py-3 text-right text-gray-300 align-top tabular-nums",children:t.counts.actionItems||a.jsx("span",{className:"text-gray-600",children:"—"})}),a.jsx("td",{className:"px-4 py-3 align-top",children:a.jsx("span",{className:`px-2 py-0.5 rounded-full text-[11px] font-medium ring-1 ring-inset capitalize ${X[t.status]}`,children:t.status})}),a.jsx("td",{className:"px-4 py-3 align-top whitespace-nowrap text-right",onClick:e=>e.stopPropagation(),children:N===t.id?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[a.jsx("span",{className:"text-xs text-gray-400",children:"Delete?"}),a.jsx("button",{onClick:()=>I(t.id),className:"text-xs px-2 py-1 rounded-md bg-red-600 hover:bg-red-500 text-white",children:"Delete"}),a.jsx("button",{onClick:()=>v(null),className:"text-xs px-2 py-1 rounded-md text-gray-400 hover:text-white",children:"Cancel"})]}):(0,a.jsxs)("span",{className:"inline-flex gap-1.5",children:[a.jsx("button",{onClick:()=>l(t.id),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-gray-200 hover:bg-gray-800",children:"Open"}),a.jsx("button",{onClick:()=>$(t),disabled:!t.snippet,title:t.snippet?"Send the summary to a Slack channel":"No summary yet",className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-gray-200 hover:bg-gray-800 disabled:opacity-30 disabled:hover:bg-transparent",children:"Slack"}),a.jsx("button",{onClick:()=>v(t.id),disabled:"recording"===t.status,className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-red-400 hover:bg-red-950/40 disabled:opacity-30 disabled:hover:bg-transparent",children:"Delete"})]})})]},t.id)})})]}),b&&0===P.length&&a.jsx("p",{className:"text-sm text-gray-500 text-center py-16",children:d?`No recordings match “${d}”`:"No recordings for these filters"})]})})]})}var ee=s(3814);function et({editing:e,onClose:t,onSaved:s,inline:l=!1}){let[n,i]=(0,r.useState)(e?"raw":"form"),[o,d]=(0,r.useState)(""),[c,x]=(0,r.useState)(""),[u,m]=(0,r.useState)(""),[g,p]=(0,r.useState)(""),[h,b]=(0,r.useState)(null),[y,f]=(0,r.useState)(!1),[j,N]=(0,r.useState)(!1);async function v(){f(!0),b(null);let a="raw"===n?{raw:g}:{name:o.trim().toLowerCase().replace(/\s+/g,"-"),description:c,instructions:u},r=await fetch(e?`/api/skills/${e}`:"/api/skills",{method:e?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),l=await r.json().catch(()=>({}));if(f(!1),!r.ok){b(l.error??"Could not save");return}s(),t()}async function w(){if(e){if(!(await fetch((0,ee.X)(`/api/skills/${e}`),{method:"DELETE"})).ok){b("Could not delete");return}s(),t()}}let k="w-full bg-gray-800 border border-gray-700 focus:border-gray-500 rounded-md px-2.5 py-1.5 text-sm text-white outline-none placeholder-gray-500",S=(e,t)=>a.jsx("button",{onClick:()=>i(e),className:`px-2.5 py-1 rounded-md text-xs ${n===e?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-200"}`,children:t});return a.jsx("div",{className:l?"":"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:l?void 0:t,children:(0,a.jsxs)("div",{className:l?"text-white":"w-full max-w-2xl max-h-[90vh] overflow-y-auto bg-gray-900 border border-gray-700 rounded-xl p-5 text-white",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("h2",{className:"text-base font-semibold",children:e?`Edit skill: ${e}`:"New skill"}),!l&&a.jsx("button",{onClick:t,className:"text-gray-500 hover:text-white","aria-label":"Close",children:"✕"})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 mb-4",children:["Saved to ",a.jsx("code",{children:"~/.claude/skills/<name>/SKILL.md"}),". Claude Code loads it in sessions started after you save."]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mb-4 bg-gray-950/60 border border-gray-800 rounded-lg p-0.5 w-fit",children:[!e&&S("form","Write it"),S("raw",e?"SKILL.md":"Paste SKILL.md"),(0,a.jsxs)("label",{className:"px-2.5 py-1 rounded-md text-xs text-gray-400 hover:text-gray-200 cursor-pointer",children:["Import file…",a.jsx("input",{type:"file",accept:".md,text/markdown,text/plain",className:"hidden",onChange:e=>{var t;(t=e.target.files?.[0])&&t.text().then(e=>{p(e),i("raw")})}})]})]}),"form"===n?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Name",a.jsx("input",{value:o,onChange:e=>d(e.target.value),placeholder:"release-notes",className:`${k} mt-1 font-mono`})]}),(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["When should Claude use it?",a.jsx("input",{value:c,onChange:e=>x(e.target.value),placeholder:"Use when writing release notes from merged PRs",className:`${k} mt-1`})]}),(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Instructions (markdown)",a.jsx("textarea",{value:u,onChange:e=>m(e.target.value),rows:12,placeholder:"# Release notes\n\n1. List PRs merged since the last tag\n2. Group them by area\n3. …",className:`${k} mt-1 font-mono text-xs resize-y`})]})]}):a.jsx("textarea",{value:g,onChange:e=>p(e.target.value),rows:l?26:18,spellCheck:!1,placeholder:"---\nname: release-notes\ndescription: Use when writing release notes\n---\n\n# Instructions…",className:`${k} font-mono text-xs resize-y`}),h&&a.jsx("p",{className:"text-xs text-red-400 mt-3",children:h}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-4",children:[e&&(j?(0,a.jsxs)("span",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"text-gray-400",children:"Delete this skill?"}),a.jsx("button",{onClick:w,className:"px-2.5 py-1 rounded-md bg-red-600 hover:bg-red-500",children:"Delete"}),a.jsx("button",{onClick:()=>N(!1),className:"text-gray-400 hover:text-white",children:"Cancel"})]}):a.jsx("button",{onClick:()=>N(!0),className:"text-xs text-red-400 hover:text-red-300",children:"Delete skill"})),(0,a.jsxs)("div",{className:"ml-auto flex gap-2",children:[a.jsx("button",{onClick:t,className:"px-3 py-1.5 text-sm text-gray-400 hover:text-white",children:"Cancel"}),a.jsx("button",{onClick:v,disabled:y,className:"px-3 py-1.5 text-sm rounded-md bg-blue-600 hover:bg-blue-500 disabled:opacity-40",children:y?"Saving…":"Save skill"})]})]})]})})}function es({onClose:e,onInstalled:t,inline:s=!1}){let[l,n]=(0,r.useState)(null),[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)("all"),[x,u]=(0,r.useState)(null),[m,g]=(0,r.useState)(null),p=()=>fetch((0,ee.X)("/api/skills/marketplace")).then(e=>e.json()).then(e=>n(e.plugins??[])).catch(()=>n([]));async function h(e){let s=`${e.name}@${e.marketplace}`;u(s),g(null);let a=await fetch((0,ee.X)("/api/skills/marketplace"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,marketplace:e.marketplace})}),r=await a.json().catch(()=>({}));u(null),g({id:s,ok:a.ok,text:a.ok?"Installed. New sessions will have it.":r.error??"Install failed"}),a.ok&&(p(),t())}let b=Array.from(new Set((l??[]).map(e=>e.marketplace))).sort(),y=i.toLowerCase(),f=(l??[]).filter(e=>("all"===d||e.marketplace===d)&&(!y||e.name.toLowerCase().includes(y)||e.description.toLowerCase().includes(y)));return a.jsx("div",{className:s?"h-full":"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:s?void 0:e,children:(0,a.jsxs)("div",{className:s?"h-full flex flex-col text-white":"w-full max-w-2xl h-[80vh] flex flex-col bg-gray-900 border border-gray-700 rounded-xl p-5 text-white",onClick:e=>e.stopPropagation(),children:[!s&&(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("h2",{className:"text-base font-semibold",children:"Skills marketplace"}),a.jsx("button",{onClick:e,className:"text-gray-500 hover:text-white","aria-label":"Close",children:"✕"})]}),a.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"Plugins from the marketplaces your Claude Code knows. A plugin can bundle skills, commands and tools, and runs as you. Install only ones you trust."}),(0,a.jsxs)("div",{className:"flex gap-2 mb-3",children:[a.jsx("input",{autoFocus:!0,value:i,onChange:e=>o(e.target.value),placeholder:"Search plugins",className:"flex-1 bg-gray-800 border border-gray-700 focus:border-gray-500 rounded-md px-2.5 py-1.5 text-sm outline-none placeholder-gray-500"}),(0,a.jsxs)("select",{value:d,onChange:e=>c(e.target.value),className:"bg-gray-800 border border-gray-700 rounded-md px-2 text-xs",children:[a.jsx("option",{value:"all",children:"All marketplaces"}),b.map(e=>a.jsx("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-1.5 pr-1",children:[null===l&&a.jsx("p",{className:"text-xs text-gray-500",children:"Loading…"}),l&&0===f.length&&a.jsx("p",{className:"text-xs text-gray-500",children:"No plugins match."}),f.map(e=>{let t=`${e.name}@${e.marketplace}`;return(0,a.jsxs)("div",{className:"rounded-lg border border-gray-800 px-3 py-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium truncate",children:e.name}),a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-gray-800 text-gray-400 flex-shrink-0",children:e.marketplace}),e.category&&a.jsx("span",{className:"text-[10px] text-gray-500 flex-shrink-0",children:e.category}),a.jsx("span",{className:"ml-auto flex-shrink-0",children:e.installed?a.jsx("span",{className:"text-[11px] text-emerald-400",children:"✓ Installed"}):a.jsx("button",{onClick:()=>h(e),disabled:!!x,className:"text-xs px-2.5 py-1 rounded-md bg-blue-600 hover:bg-blue-500 disabled:opacity-40",children:x===t?"Installing…":"Install"})})]}),e.description&&a.jsx("p",{className:"text-xs text-gray-500 mt-1 line-clamp-2",children:e.description}),m?.id===t&&a.jsx("p",{className:`text-xs mt-1 ${m.ok?"text-emerald-400":"text-amber-400"}`,children:m.text})]},t)})]})]})})}function ea({selected:e,onSelect:t,onChanged:s}){let[l,n]=(0,r.useState)("installed"),[i,o]=(0,r.useState)(null),[d,c]=(0,r.useState)(""),[x,u]=(0,r.useState)("all"),[m,g]=(0,r.useState)(null),[p,h]=(0,r.useState)("view"),[b,y]=(0,r.useState)(0),f=()=>{y(e=>e+1),s()},j=d.toLowerCase(),N=(i??[]).filter(e=>("all"===x||e.source===x)&&(!j||e.name.toLowerCase().includes(j)||e.description.toLowerCase().includes(j))),v=m?.raw.replace(/^---[\s\S]*?\n---\s*/,"")??"",w=e=>`px-2.5 py-1 rounded-md text-xs ${e?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-200"}`,k=(e,t)=>a.jsx("button",{onClick:()=>n(e),className:`px-1 pb-2.5 pt-1 text-sm border-b-2 ${l===e?"border-blue-500 text-white":"border-transparent text-gray-500 hover:text-gray-300"}`,children:t});return(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col bg-gray-950 text-gray-100",children:[(0,a.jsxs)("div",{className:"px-6 pt-5 border-b border-gray-800 flex-shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h1",{className:"text-lg font-semibold",children:"Skills"}),a.jsx("button",{onClick:()=>{n("installed"),t(null),h("new")},className:"text-xs font-medium bg-blue-600 hover:bg-blue-500 rounded-md px-3 py-1.5",children:"+ New skill"})]}),(0,a.jsxs)("div",{className:"flex gap-5",children:[k("installed",`Installed${i?` \xb7 ${i.length}`:""}`),k("marketplace","Marketplace")]})]}),"marketplace"===l?a.jsx("div",{className:"flex-1 min-h-0 px-6 py-4",children:a.jsx(es,{inline:!0,onClose:()=>{},onInstalled:f})}):(0,a.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,a.jsxs)("div",{className:"w-[380px] flex-shrink-0 border-r border-gray-800 flex flex-col min-h-0",children:[(0,a.jsxs)("div",{className:"p-3 space-y-2 border-b border-gray-800",children:[a.jsx("input",{value:d,onChange:e=>c(e.target.value),placeholder:"Search skills",className:"w-full bg-gray-900 border border-gray-800 focus:border-gray-600 rounded-md px-2.5 py-1.5 text-sm outline-none placeholder-gray-600"}),(0,a.jsxs)("div",{className:"flex gap-1 bg-gray-900 border border-gray-800 rounded-lg p-0.5 w-fit",children:[a.jsx("button",{onClick:()=>u("all"),className:w("all"===x),children:"All"}),a.jsx("button",{onClick:()=>u("user"),className:w("user"===x),children:"Mine"}),a.jsx("button",{onClick:()=>u("plugin"),className:w("plugin"===x),children:"From plugins"})]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[null===i&&a.jsx("p",{className:"text-xs text-gray-500 p-4",children:"Loading…"}),N.map(s=>(0,a.jsxs)("button",{onClick:()=>t(s.name),className:`w-full text-left px-4 py-2.5 border-b border-gray-800/60 ${e===s.name?"bg-gray-800":"hover:bg-gray-900"}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium truncate flex-1",children:s.name}),a.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${"user"===s.source?"bg-blue-900/50 text-blue-300":"bg-gray-800 text-gray-400"}`,children:"plugin"===s.source?s.plugin??"plugin":"mine"})]}),s.description&&a.jsx("p",{className:"text-xs text-gray-500 mt-0.5 line-clamp-2",children:s.description})]},s.path))]})]}),a.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto px-8 py-6",children:"new"===p?a.jsx("div",{className:"max-w-3xl",children:a.jsx(et,{inline:!0,editing:null,onClose:()=>h("view"),onSaved:f})}):"edit"===p&&m?a.jsx("div",{className:"max-w-3xl",children:a.jsx(et,{inline:!0,editing:m.skill.name,onClose:()=>h("view"),onSaved:f})}):m?(0,a.jsxs)("div",{className:"max-w-3xl",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-4 mb-1",children:[a.jsx("h2",{className:"text-xl font-semibold font-mono",children:m.skill.name}),"user"===m.skill.source?a.jsx("button",{onClick:()=>h("edit"),className:"text-xs border border-gray-700 hover:bg-gray-800 rounded-md px-3 py-1.5 flex-shrink-0",children:"Edit"}):(0,a.jsxs)("span",{className:"text-xs text-gray-500 flex-shrink-0",children:["From plugin ",m.skill.plugin," \xb7 read-only"]})]}),a.jsx("p",{className:"text-sm text-gray-400 mb-1",children:m.skill.description}),a.jsx("p",{className:"text-[11px] text-gray-600 font-mono mb-6 truncate",children:m.skill.path}),a.jsx(U,{text:v})]}):a.jsx("div",{className:"text-sm text-gray-500 mt-20 text-center",children:"Pick a skill to read it, or create a new one."})})]})]})}let er=e=>e.text.split("\n").find(e=>e.trim())?.trim()||"Untitled";function el({notes:e,setNotes:t,orgs:s,activeOrgId:l,selected:n,onSelect:i}){var o;let[d,c]=(0,r.useState)(""),[x,u]=(0,r.useState)(!1),m=(0,r.useRef)(null),g=e=>"all"===l||(e??"default")===l,p=d.toLowerCase(),h=e.filter(e=>g(e.orgId)&&(!p||e.text.toLowerCase().includes(p))),b=e.find(e=>e.id===n)??null,y=e=>b&&t(t=>t.map(t=>t.id===b.id?{...t,...e}:t));return(0,a.jsxs)("div",{className:"absolute inset-0 flex bg-gray-950 text-gray-100",children:[(0,a.jsxs)("div",{className:"w-[340px] flex-shrink-0 border-r border-gray-800 flex flex-col min-h-0",children:[(0,a.jsxs)("div",{className:"px-4 pt-5 pb-3 border-b border-gray-800 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("h1",{className:"text-lg font-semibold",children:"Notes"}),a.jsx("button",{onClick:function(){let e={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,text:"",createdAt:Date.now(),..."all"!==l?{orgId:l}:{}};t(t=>[e,...t]),i(e.id),setTimeout(()=>m.current?.focus(),50)},className:"text-xs font-medium bg-blue-600 hover:bg-blue-500 rounded-md px-3 py-1.5",children:"+ New note"})]}),a.jsx("input",{value:d,onChange:e=>c(e.target.value),placeholder:"Search notes",className:"w-full bg-gray-900 border border-gray-800 focus:border-gray-600 rounded-md px-2.5 py-1.5 text-sm outline-none placeholder-gray-600"})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[0===h.length&&a.jsx("p",{className:"text-xs text-gray-500 p-4",children:d?"No notes match.":"No notes yet."}),h.map(e=>(0,a.jsxs)("button",{onClick:()=>i(e.id),className:`w-full text-left px-4 py-3 border-b border-gray-800/60 ${n===e.id?"bg-gray-800":"hover:bg-gray-900"}`,children:[a.jsx("p",{className:"text-sm font-medium truncate",children:er(e)}),a.jsx("p",{className:"text-xs text-gray-500 truncate mt-0.5",children:e.text.split("\n").filter(e=>e.trim()).slice(1).join(" ")||"\xa0"}),(0,a.jsxs)("p",{className:"text-[11px] text-gray-600 mt-1",children:[new Date(e.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"}),e.remindAt&&!e.reminderDone&&(0,a.jsxs)("span",{className:"text-amber-400",children:[" \xb7 ⏰ ",new Date(e.remindAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]})]},e.id))]})]}),a.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:b?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"px-8 py-3 border-b border-gray-800 flex items-center gap-4 text-xs text-gray-500 flex-shrink-0",children:[a.jsx("span",{children:new Date(b.createdAt).toLocaleString()}),(0,a.jsxs)("label",{className:`flex items-center gap-1.5 ${b.remindAt&&!b.reminderDone?"text-amber-400":""}`,children:["⏰ Remind me",a.jsx("input",{type:"datetime-local",value:b.remindAt?new Date((o=b.remindAt)-6e4*new Date(o).getTimezoneOffset()).toISOString().slice(0,16):"",onChange:e=>y({remindAt:e.target.value?new Date(e.target.value).getTime():void 0,reminderDone:!1}),className:"bg-gray-900 border border-gray-800 rounded px-1.5 py-0.5 text-xs text-gray-200 [color-scheme:dark]"}),b.remindAt&&a.jsx("button",{onClick:()=>y({remindAt:void 0,reminderDone:!1}),className:"text-gray-500 hover:text-white",children:"clear"})]}),b.orgId&&"default"!==b.orgId&&a.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-900/50 text-purple-300 text-[10px]",children:s.find(e=>e.id===b.orgId)?.name??"org"}),a.jsx("span",{className:"ml-auto",children:x?(0,a.jsxs)("span",{className:"flex items-center gap-2",children:["Delete this note?",a.jsx("button",{onClick:()=>{t(e=>e.filter(e=>e.id!==b.id)),i(null)},className:"px-2 py-1 rounded-md bg-red-600 hover:bg-red-500 text-white",children:"Delete"}),a.jsx("button",{onClick:()=>u(!1),className:"hover:text-white",children:"Cancel"})]}):a.jsx("button",{onClick:()=>u(!0),className:"text-red-400 hover:text-red-300",children:"Delete"})})]}),a.jsx("textarea",{ref:m,value:b.text,onChange:e=>y({text:e.target.value}),placeholder:"Start typing. The first line is the title.",className:"flex-1 w-full resize-none bg-transparent px-8 py-6 text-[15px] leading-relaxed text-gray-100 outline-none placeholder-gray-600"})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-gray-500",children:"Pick a note, or create a new one."})})]})}function en({items:e,onOpenChange:t}){let[s,l]=(0,r.useState)(!1),[n,i]=(0,r.useState)(""),[o,d]=(0,r.useState)(0),c=(0,r.useRef)(null),x=(0,r.useMemo)(()=>s?e():[],[s,e]),u=(0,r.useMemo)(()=>{let e=n.toLowerCase().split(/\s+/).filter(Boolean),t=new Map;return x.filter(s=>{let a=`${s.label} ${s.hint??""} ${s.group}`.toLowerCase();if(!e.every(e=>a.includes(e)))return!1;let r=t.get(s.group)??0;return!(r>=(e.length?6:4))&&(t.set(s.group,r+1),!0)})},[x,n]);if(!s)return null;let m=e=>{e&&(l(!1),e.run())};return a.jsx("div",{className:"fixed inset-0 z-[60] bg-black/50 flex justify-center pt-[12vh] px-4",onClick:()=>l(!1),children:(0,a.jsxs)("div",{className:"w-full max-w-xl h-fit max-h-[70vh] flex flex-col bg-gray-900 border border-gray-700 rounded-xl shadow-2xl overflow-hidden",onClick:e=>e.stopPropagation(),children:[a.jsx("input",{ref:c,value:n,onChange:e=>{i(e.target.value),d(0)},onKeyDown:e=>{"ArrowDown"===e.key?(e.preventDefault(),d(e=>Math.min(e+1,u.length-1))):"ArrowUp"===e.key?(e.preventDefault(),d(e=>Math.max(e-1,0))):"Enter"===e.key?(e.preventDefault(),m(u[o])):"Escape"===e.key&&l(!1)},placeholder:"Search sessions, meetings, notes, skills, actions…",className:"w-full bg-transparent px-4 py-3.5 text-base text-white outline-none border-b border-gray-800 placeholder-gray-500"}),(0,a.jsxs)("div",{className:"overflow-y-auto py-1",children:[0===u.length&&a.jsx("p",{className:"px-4 py-6 text-sm text-gray-500 text-center",children:"No results"}),u.map((e,t)=>(0,a.jsxs)("div",{children:[(0===t||u[t-1].group!==e.group)&&a.jsx("p",{className:"px-4 pt-2.5 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-500",children:e.group}),(0,a.jsxs)("button",{onMouseEnter:()=>d(t),onClick:()=>m(e),className:`w-full text-left px-4 py-2 flex items-center gap-3 ${t===o?"bg-blue-600/80 text-white":"text-gray-200"}`,children:[a.jsx("span",{className:"truncate flex-1 text-sm",children:e.label}),e.hint&&a.jsx("span",{className:"text-[11px] opacity-60 flex-shrink-0 truncate max-w-[40%]",children:e.hint})]})]},`${e.group}:${e.id}`))]}),a.jsx("p",{className:"px-4 py-2 border-t border-gray-800 text-[11px] text-gray-500",children:"↑ ↓ to move \xb7 Enter to open \xb7 Esc to close \xb7 ⌘K to toggle"})]})})}var ei=s(9849);let eo=[["thumbsup","\uD83D\uDC4D"],["eyes","\uD83D\uDC40"],["white_check_mark","✅"],["pray","\uD83D\uDE4F"],["heart","❤️"],["joy","\uD83D\uDE02"],["raised_hands","\uD83D\uDE4C"],["fire","\uD83D\uDD25"]],ed=["bg-rose-600","bg-amber-600","bg-emerald-600","bg-sky-600","bg-violet-600","bg-pink-600","bg-teal-600"],ec=e=>ed[[...e].reduce((e,t)=>e+t.charCodeAt(0),0)%ed.length],ex="polyergon:slack-links";function eu({m:e,onGone:t,onAgent:s,suggesting:l,sessions:n,onOpenSession:i,onAskSession:o}){let[d,c]=(0,r.useState)(null),[x,u]=(0,r.useState)(!1),[m,g]=(0,r.useState)(!1),p=n.find(e=>e.id===d)??null,h=t=>{(function(e,t){try{let s=function(){try{return JSON.parse(localStorage.getItem(ex)??"{}")}catch{return{}}}();t?s[e]=t:delete s[e],localStorage.setItem(ex,JSON.stringify(s))}catch{}})(e.permalink,t),c(t),u(!1),g(!1)},[b,y]=(0,r.useState)(!1),[f,j]=(0,r.useState)(""),[N,v]=(0,r.useState)(null),[w,k]=(0,r.useState)(""),[S,C]=(0,r.useState)(!1),[D,$]=(0,r.useState)(!1),[I,A]=(0,r.useState)([]);async function R(t,s={}){v("reply"===t?"send":"react"===t?null:t),k("");let a=await fetch((0,ee.X)("/api/slack/inbox"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,permalink:e.permalink,...s})}),r=await a.json().catch(()=>({}));return(v(null),a.ok)?r:(k(r.error??"Failed"),null)}return(0,a.jsxs)("div",{className:`relative rounded-xl border border-gray-800 bg-gray-900/60 p-4 flex flex-col transition-opacity ${!1===e.checked?"opacity-80":""}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[!1===e.checked&&a.jsx("span",{className:"absolute top-3 right-3 text-[10px] text-gray-500 animate-pulse",children:"checking…"}),a.jsx("span",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-semibold text-white flex-shrink-0 ${ec(e.author)}`,children:(e.author||"?")[0].toUpperCase()}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm font-medium text-gray-100 truncate",children:e.author}),(0,a.jsxs)("p",{className:"text-[11px] text-gray-500 truncate",children:[e.isDm?"Direct message":`#${e.channel}`," \xb7 ",function(e){let t=Date.parse(e);if(Number.isNaN(t))return"";let s=Math.round((Date.now()-t)/6e4);return s<60?`${Math.max(1,s)}m ago`:s<1440?`${Math.round(s/60)}h ago`:`${Math.round(s/1440)}d ago`}(e.time)]})]}),!1!==e.checked&&a.jsx("a",{href:e.permalink,target:"_blank",rel:"noreferrer",className:"text-[11px] text-blue-400 hover:underline flex-shrink-0",children:"Open in Slack"})]}),a.jsx("p",{dir:"auto",onClick:()=>C(e=>!e),className:`text-sm text-gray-300 mt-3 whitespace-pre-wrap [overflow-wrap:anywhere] leading-relaxed cursor-pointer ${S?"":"line-clamp-5"}`,children:e.text}),!b&&e.suggestion&&(0,a.jsxs)("div",{className:"mt-3 rounded-lg bg-blue-950/40 border border-blue-900/50 px-3 py-2",children:[a.jsx("p",{className:"text-[10px] font-semibold text-blue-300/80 uppercase tracking-wide mb-1",children:"\uD83D\uDCA1 Suggested reply"}),a.jsx("p",{dir:"auto",className:"text-xs text-blue-100/90 whitespace-pre-wrap leading-relaxed line-clamp-4",children:e.suggestion}),a.jsx("button",{onClick:()=>{j(e.suggestion),y(!0)},className:"mt-1.5 text-[11px] text-blue-300 hover:text-blue-200",children:"Use it (you can edit before sending) →"})]}),!b&&e.checked&&!e.suggestion&&l&&a.jsx("p",{className:"mt-3 text-[11px] text-gray-500 animate-pulse",children:"\uD83D\uDCA1 Writing a suggested reply…"}),b&&(0,a.jsxs)("div",{className:"mt-3 space-y-2",children:[a.jsx("textarea",{dir:"auto",value:f,onChange:e=>j(e.target.value),rows:4,autoFocus:!0,placeholder:"Write a reply…",className:"w-full bg-gray-950 border border-gray-800 focus:border-gray-600 rounded-md px-2.5 py-2 text-sm text-gray-100 outline-none resize-y placeholder-gray-600"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:async()=>{let e=await R("draft",p?{session:{resumeId:p.resumeId,cwd:p.cwd}}:{});e?.text&&j(e.text)},disabled:!!N,className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-gray-200 hover:bg-gray-800 disabled:opacity-40",children:"draft"===N?p?"Drafting from session…":"Drafting…":"✨ Draft with Claude"}),a.jsx("button",{onClick:async()=>{await R("reply",{text:f})&&t()},disabled:!!N||!f.trim(),className:"ml-auto text-xs px-3 py-1 rounded-md bg-blue-600 hover:bg-blue-500 text-white disabled:opacity-40",children:"send"===N?"Sending…":"Send in thread"})]})]}),p&&(0,a.jsxs)("div",{className:"mt-3 flex items-center gap-2 rounded-lg border border-emerald-900/60 bg-emerald-950/30 px-2.5 py-1.5 text-xs",children:[(0,a.jsxs)("button",{onClick:()=>i(p.id),title:"Open this session",className:"text-emerald-200 hover:underline truncate flex-1 text-left",children:["\uD83D\uDD17 ",p.label]}),a.jsx("button",{onClick:()=>{o(p.id,e),g(!0)},disabled:m,title:"Send this Slack thread into the session (when it's idle) and ask it to look into it and draft a reply. Nothing is posted to Slack.",className:"px-2 py-0.5 rounded border border-emerald-800 text-emerald-200 hover:bg-emerald-900/40 disabled:opacity-50 flex-shrink-0",children:m?"Sent ✓":"Ask session"}),a.jsx("button",{onClick:()=>h(null),title:"Unlink",className:"text-gray-500 hover:text-gray-200 flex-shrink-0",children:"✕"})]}),x&&(0,a.jsxs)("select",{autoFocus:!0,defaultValue:"",onChange:e=>e.target.value&&h(e.target.value),onBlur:()=>u(!1),className:"mt-3 w-full bg-gray-950 border border-gray-700 rounded-md px-2 py-1.5 text-xs text-gray-200",children:[a.jsx("option",{value:"",disabled:!0,children:n.length?"Which session is this about?":"No running sessions in this org"}),n.map(e=>a.jsx("option",{value:e.id,children:e.label},e.id))]}),I.length>0&&(0,a.jsxs)("p",{className:"text-xs text-gray-400 mt-2",children:["You reacted ",I.join(" ")]}),D&&a.jsx("div",{className:"flex gap-1 mt-2 bg-gray-950 border border-gray-800 rounded-lg p-1 w-fit",children:eo.map(([e,t])=>a.jsx("button",{title:`:${e}:`,onClick:async()=>{$(!1),A(e=>[...e,t]),await R("react",{emoji:e})||A(e=>e.filter(e=>e!==t))},className:"w-8 h-8 rounded-md text-lg hover:bg-gray-800",children:t},e))}),w&&a.jsx("p",{className:"text-xs text-red-400 mt-2",children:w}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 pt-3 whitespace-nowrap",children:[!b&&a.jsx("button",{onClick:()=>y(!0),className:"text-xs px-3 h-7 rounded-md bg-blue-600 hover:bg-blue-500 text-white",children:"Reply"}),a.jsx("button",{onClick:()=>$(e=>!e),className:"text-sm w-8 h-7 rounded-md border border-gray-700 hover:bg-gray-800 flex items-center justify-center disabled:opacity-40",title:"React with an emoji",children:"\uD83D\uDE42"}),a.jsx("button",{onClick:()=>s(e),className:"text-sm w-8 h-7 rounded-md border border-gray-700 hover:bg-gray-800 flex items-center justify-center disabled:opacity-40",title:"Send an agent: a NEW Claude session reads the thread, looks into it and drafts a reply for you",children:"\uD83E\uDD16"}),a.jsx("button",{onClick:()=>u(e=>!e),className:`text-sm w-8 h-7 rounded-md border hover:bg-gray-800 flex items-center justify-center ${p?"border-emerald-700":"border-gray-700"}`,title:"Related session: link this message to a running session. Drafts then use what that session knows, and you can ask it directly.",children:"\uD83D\uDD17"}),a.jsx("button",{onClick:async()=>{await R("done",{react:!0})&&t()},disabled:!!N,className:"text-sm w-8 h-7 rounded-md border border-gray-700 hover:bg-gray-800 flex items-center justify-center disabled:opacity-40 ml-auto",title:"Done: adds a ✅ reaction in Slack and hides it here",children:"done"===N?"…":"✅"}),a.jsx("button",{onClick:async()=>{await R("done",{react:!1})&&t()},disabled:!!N,className:"text-xs w-7 h-7 rounded-md text-gray-500 hover:text-gray-200 hover:bg-gray-800",title:"Hide here only; nothing is posted to Slack",children:"✕"})]})]})}function em({onSendAgent:e,orgName:t,sessions:s,onOpenSession:l,onAskSession:n}){let[i,o]=(0,r.useState)(null),[d,c]=(0,r.useState)(Date.now()),[x,u]=(0,r.useState)(new Set),[m,g]=(0,r.useState)("all"),p=(e=!1)=>fetch((0,ee.X)(`/api/slack/inbox${e?"?refresh=1":""}`)).then(e=>e.json()).then(o).catch(()=>{}),h=i?.refreshing?Math.max(0,Math.round((d-i.startedAt)/1e3)):0,b=(i?.items??[]).filter(e=>!x.has(e.permalink)&&("all"===m||"dm"===m===e.isDm)),y=e=>`px-2.5 py-1 rounded-md text-xs ${e?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-200"}`;return(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col bg-gray-950 text-gray-100",children:[(0,a.jsxs)("div",{className:"px-6 pt-5 pb-4 flex flex-wrap items-center gap-3 flex-shrink-0",children:[a.jsx("h1",{className:"text-lg font-semibold",children:"Slack"}),a.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-900/50 text-purple-300 text-[10px] font-medium",title:"Slack workspace of this org's Claude setup",children:t}),a.jsx("span",{className:"text-xs text-gray-500",children:i?`${b.length} waiting on you`:"Loading…"}),(0,a.jsxs)("div",{className:"flex gap-1 bg-gray-900 border border-gray-800 rounded-lg p-0.5",children:[a.jsx("button",{onClick:()=>g("all"),className:y("all"===m),children:"All"}),a.jsx("button",{onClick:()=>g("channels"),className:y("channels"===m),children:"Mentions"}),a.jsx("button",{onClick:()=>g("dm"),className:y("dm"===m),children:"DMs"})]}),a.jsx("span",{className:"ml-auto text-[11px] text-gray-500",children:!i?.refreshing&&i?.fetchedAt?`Updated ${new Date(i.fetchedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`:""}),a.jsx("button",{onClick:()=>p(!0),disabled:i?.refreshing,className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800 disabled:opacity-40",children:"↻ Refresh"})]}),i?.refreshing&&(0,a.jsxs)("div",{className:"mx-6 mb-4 rounded-lg border border-blue-900/60 bg-blue-950/30 px-4 py-2.5 flex items-center gap-4 text-xs flex-shrink-0",children:[a.jsx("span",{className:"w-3.5 h-3.5 rounded-full border-2 border-blue-400 border-t-transparent animate-spin"}),a.jsx("span",{className:"searching"===i.stage?"text-blue-200 font-medium":"text-gray-500",children:"searching"===i.stage?"1. Finding your mentions and DMs…":"✓ Found your mentions and DMs"}),a.jsx("span",{className:"checking"===i.stage?"text-blue-200 font-medium":"suggesting"===i.stage?"text-gray-500":"text-gray-600",children:"suggesting"===i.stage?"✓ Checked which you answered":`2. Checking which you already answered${"checking"===i.stage?"…":""}`}),(0,a.jsxs)("span",{className:"suggesting"===i.stage?"text-blue-200 font-medium":"text-gray-600",children:["3. Suggesting replies","suggesting"===i.stage?"…":""]}),(0,a.jsxs)("span",{className:"ml-auto text-gray-500 tabular-nums",children:[h,"s"]})]}),i?.error&&!i.refreshing&&a.jsx("div",{className:"mx-6 mb-4 flex-shrink-0",children:a.jsx(ei.hR,{problem:i.problem??"other",detail:i.error,org:t,onRetry:()=>p(!0)})}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-6 pb-6",children:[i&&!i.refreshing&&0===b.length&&(i.error?null:a.jsx("p",{className:"text-sm text-gray-500 text-center mt-20",children:i.fetchedAt?"Nothing waiting on you. \uD83C\uDF89":"Click Refresh to check Slack."})),(0,a.jsxs)("div",{className:"grid gap-4 items-start",style:{gridTemplateColumns:"repeat(auto-fill, minmax(340px, 1fr))"},children:[i?.refreshing&&0===b.length&&Array.from({length:6},(e,t)=>(0,a.jsxs)("div",{className:"rounded-xl border border-gray-800 bg-gray-900/40 p-4 animate-pulse",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[a.jsx("span",{className:"w-8 h-8 rounded-full bg-gray-800"}),a.jsx("span",{className:"h-3 w-32 rounded bg-gray-800"})]}),(0,a.jsxs)("div",{className:"mt-4 space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-gray-800"}),a.jsx("div",{className:"h-2.5 rounded bg-gray-800 w-5/6"}),a.jsx("div",{className:"h-2.5 rounded bg-gray-800 w-2/3"})]})]},t)),b.map(t=>a.jsx(eu,{m:t,suggesting:i?.stage==="suggesting",onGone:()=>u(e=>new Set(e).add(t.permalink)),onAgent:e,sessions:s,onOpenSession:l,onAskSession:n},t.permalink))]})]})]})}var eg=s(6620);let ep=e=>e?e<3600?`every ${Math.round(e/60)} min`:`every ${Math.round(e/3600)} h`:null,eh=e=>e.replace(/^com\.[^.]+\.(loop\.)?/,"");function eb({l:e,onRun:t}){let[s,l]=(0,r.useState)("none"),[n,i]=(0,r.useState)(""),[o,d]=(0,r.useState)(null);async function c(){l("log"===s?"none":"log"),i((await fetch(`/api/automations/existing?log=${encodeURIComponent(e.label)}`).then(e=>e.json()).catch(()=>({log:""}))).log)}return(0,a.jsxs)("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4 flex flex-col",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${e.running?"bg-blue-400 animate-pulse":e.lastExit?"bg-red-400":"bg-emerald-500"}`}),(0,a.jsxs)("span",{className:"text-sm font-medium",children:["\uD83D\uDD01 ",eh(e.label)]}),a.jsx("span",{className:"text-xs text-gray-500",children:ep(e.everySec)??(e.calendar?"on a schedule":"")}),e.model&&a.jsx("span",{className:"ml-auto text-[10px] px-1.5 py-0.5 rounded bg-gray-800 text-gray-400",children:e.model.replace(/^claude-/,"")})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 mt-1.5",children:[e.running?a.jsx("span",{className:"text-blue-300",children:"Running now"}):e.lastExit?(0,a.jsxs)("span",{className:"text-red-400",children:["Last run failed (exit ",e.lastExit,")"]}):"Idle",e.lastRun&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 last run ",e.lastRun.at.slice(5,16)]})]}),e.lastRun?.output&&a.jsx("p",{className:"text-xs text-gray-300 mt-2 whitespace-pre-wrap line-clamp-3 bg-gray-950/60 rounded px-2 py-1.5 font-mono",children:e.lastRun.output}),"prompt"===s&&e.prompt&&a.jsx("pre",{className:"text-[11px] text-gray-300 mt-2 whitespace-pre-wrap bg-gray-950 border border-gray-800 rounded p-2 max-h-60 overflow-y-auto",children:e.prompt}),"log"===s&&a.jsx("pre",{className:"text-[11px] text-gray-300 mt-2 whitespace-pre-wrap bg-gray-950 border border-gray-800 rounded p-2 max-h-60 overflow-y-auto",children:n||"Loading…"}),o&&a.jsx("p",{className:"text-xs text-gray-400 mt-2",children:o}),(0,a.jsxs)("div",{className:"flex gap-2 mt-3",children:[a.jsx("button",{onClick:async()=>d(await t()),disabled:e.running,className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800 disabled:opacity-40",children:"▶ Run now"}),e.prompt&&a.jsx("button",{onClick:()=>l("prompt"===s?"none":"prompt"),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Prompt"}),e.logFile&&a.jsx("button",{onClick:c,className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Log"})]}),a.jsx("p",{className:"text-[10px] text-gray-600 mt-2 font-mono truncate",title:e.command,children:e.label})]})}function ey(){let[e,t]=(0,r.useState)(null),s=()=>fetch("/api/automations/existing").then(e=>e.json()).then(t).catch(()=>{});if(!e||!e.loops.length&&!e.hooks.length)return null;async function l(e){let t=await fetch("/api/automations/existing",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"run",label:e})});return setTimeout(s,1500),t.ok?"Started.":(await t.json().catch(()=>({}))).error??"Could not start"}return(0,a.jsxs)("section",{children:[a.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-2",children:"Already running on this Mac"}),a.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(340px, 1fr))"},children:e.loops.map(e=>a.jsx(eb,{l:e,onRun:()=>l(e.label)},e.label))}),e.hooks.length>0&&(0,a.jsxs)("details",{className:"mt-3",children:[(0,a.jsxs)("summary",{className:"text-xs text-gray-400 cursor-pointer",children:["Claude Code hooks (",e.hooks.length,")"]}),a.jsx("ul",{className:"mt-2 space-y-1",children:e.hooks.map((e,t)=>(0,a.jsxs)("li",{className:"text-xs text-gray-400 flex gap-2",children:[(0,a.jsxs)("span",{className:"text-gray-200 w-40 flex-shrink-0",children:[e.event,e.matcher&&"*"!==e.matcher?` (${e.matcher})`:""]}),a.jsx("span",{className:"text-gray-500 flex-shrink-0",children:e.org}),a.jsx("code",{className:"truncate text-gray-500",children:e.command})]},t))})]})]})}function ef({it:e,onSend:t,onDismiss:s,onRedraft:l}){let[n,i]=(0,r.useState)(e.draft??""),[o,d]=(0,r.useState)(!1),[c,x]=(0,r.useState)(!1);return(0,a.jsxs)("div",{className:"rounded-lg border border-gray-800 bg-gray-950/50 p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"font-medium text-gray-200",children:e.author}),a.jsx("a",{href:e.permalink,target:"_blank",rel:"noreferrer",className:"ml-auto text-blue-400 hover:underline",children:"Open in Slack"})]}),a.jsx("p",{dir:"auto",className:"text-sm text-gray-300 mt-1.5 line-clamp-4 whitespace-pre-wrap [overflow-wrap:anywhere]",children:e.text}),"drafting"===e.state&&a.jsx("p",{className:"text-xs text-gray-500 mt-2 animate-pulse",children:"Drafting a reply…"}),"failed"===e.state&&(0,a.jsxs)("p",{className:"text-xs text-red-400 mt-2",children:["Draft failed: ",e.error," ",a.jsx("button",{onClick:l,className:"underline",children:"Try again"})]}),"sent"===e.state&&(0,a.jsxs)("p",{className:"text-xs text-emerald-400 mt-2",children:["✓ Answered: ",a.jsx("span",{className:"text-gray-400",children:e.draft})]}),"sending"===e.state&&a.jsx("p",{className:"text-xs text-blue-300 mt-2 animate-pulse",children:"Posting in Slack…"}),"pending"===e.state&&(0,a.jsxs)("div",{className:"mt-2 rounded-md bg-blue-950/40 border border-blue-900/50 p-2",children:[a.jsx("p",{className:"text-[10px] font-semibold text-blue-300/80 uppercase tracking-wide mb-1",children:"\uD83D\uDCA1 Draft reply"}),o?a.jsx("textarea",{dir:"auto",value:n,onChange:e=>i(e.target.value),rows:4,className:"w-full bg-gray-950 border border-gray-800 rounded px-2 py-1.5 text-xs text-gray-100 outline-none"}):a.jsx("p",{dir:"auto",className:"text-xs text-blue-100/90 whitespace-pre-wrap",children:e.draft}),(0,a.jsxs)("div",{className:"flex gap-2 mt-2",children:[a.jsx("button",{onClick:()=>{x(!0),t(o?n:e.draft??"")},disabled:c,className:"text-xs px-2.5 py-1 rounded-md bg-blue-600 hover:bg-blue-500 text-white disabled:opacity-50",children:c?"Posting…":"Send in thread"}),!o&&a.jsx("button",{onClick:()=>{i(e.draft??""),d(!0)},className:"text-xs px-2 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Edit"}),a.jsx("button",{onClick:l,className:"text-xs px-2 py-1 rounded-md text-gray-400 hover:text-white",children:"Redraft"}),a.jsx("button",{onClick:s,className:"ml-auto text-xs px-2 py-1 rounded-md text-gray-500 hover:text-white",children:"Dismiss"})]})]})]})}function ej({log:e}){if(!e.length)return null;let t=e=>new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return(0,a.jsxs)("details",{className:"mt-3 group",children:[(0,a.jsxs)("summary",{className:"text-xs text-gray-400 hover:text-gray-200 cursor-pointer select-none list-none",children:[a.jsx("span",{className:"inline-block transition-transform group-open:rotate-90",children:"▸"})," Activity log (",e.length,")"]}),a.jsx("ol",{className:"mt-2 border-l border-gray-800 ml-1.5 pl-3 space-y-1.5",children:[...e].reverse().map((e,s)=>(0,a.jsxs)("li",{className:"text-xs",children:[a.jsx("span",{className:"text-gray-500 tabular-nums mr-2",children:t(e.t)}),a.jsx("span",{className:"text-gray-300",children:e.text}),e.link&&a.jsx("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"ml-2 text-blue-400 hover:underline",children:"Slack ↗"}),e.detail&&(0,a.jsxs)("details",{className:"mt-1",children:[a.jsx("summary",{className:"text-[11px] text-gray-500 hover:text-gray-300 cursor-pointer",children:"show text"}),a.jsx("p",{dir:"auto",className:"mt-1 whitespace-pre-wrap text-gray-400 bg-gray-950/60 border border-gray-800 rounded px-2 py-1.5 [overflow-wrap:anywhere]",children:e.detail})]})]},e.t+":"+s))})]})}function eN({pipelines:e,watchers:t,sessions:s,nameOf:l,onOpen:n,onStop:i,onNewWatcher:o,onEditWatcher:d,watcherCmd:c,showMacLoops:u}){let[m,g]=(0,r.useState)(""),p=[...e].sort((e,t)=>Number((0,x.An)(t))-Number((0,x.An)(e))||t.updatedAt-e.updatedAt),h=[...t].sort((e,t)=>Number("running"===t.status)-Number("running"===e.status)),b="rounded-xl border border-gray-800 bg-gray-900/50 p-4 flex flex-col gap-2",y=e.filter(x.An).length+t.filter(e=>"running"===e.status).length;return(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col bg-gray-950 text-gray-100",children:[(0,a.jsxs)("div",{className:"px-6 pt-5 pb-3 flex items-baseline gap-3 flex-shrink-0",children:[a.jsx("h1",{className:"text-lg font-semibold",children:"Automations"}),(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:[y," running"]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-6 pb-6 space-y-6",children:[(0,a.jsxs)("section",{children:[a.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-2",children:"Create an automation"}),(0,a.jsxs)("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))"},children:[(0,a.jsxs)("div",{className:b,children:[a.jsx("p",{className:"text-sm font-medium",children:"\uD83D\uDEA2 Ship it"}),a.jsx("p",{className:"text-xs text-gray-400",children:"Watches a session's PRs: posts them for review in Slack, tracks reviewers and CI, and suggests fixes for you to send."}),a.jsx(F.h,{options:s,value:m,onChange:g,onPick:e=>{g(""),n(e.id)},placeholder:"Pick a session to start…",className:"w-full bg-gray-800 border border-gray-700 rounded-md px-2.5 py-1.5 text-xs outline-none placeholder-gray-500"})]}),(0,a.jsxs)("div",{className:b,children:[a.jsx("p",{className:"text-sm font-medium",children:"\uD83D\uDC42 Slack channel watcher"}),a.jsx("p",{className:"text-xs text-gray-400",children:"Finds new unanswered questions in a channel and drafts replies, optionally with a session's knowledge. You approve or let it answer."}),a.jsx("button",{onClick:o,className:"mt-auto text-xs px-3 py-1.5 rounded-md bg-blue-600 hover:bg-blue-500 w-fit",children:"Set up"})]}),[["\uD83D\uDCF0 Daily digest","Every morning: your open PRs, Slack mentions and meetings in one summary."],["⏰ Review nudges","Pings reviewers in Slack when a PR has waited for review over a day."]].map(([e,t])=>(0,a.jsxs)("div",{className:`${b} opacity-60`,children:[(0,a.jsxs)("p",{className:"text-sm font-medium",children:[e," ",a.jsx("span",{className:"text-[10px] text-gray-500 font-normal",children:"soon"})]}),a.jsx("p",{className:"text-xs text-gray-400",children:t})]},e))]})]}),u&&a.jsx(ey,{}),h.map(e=>{let t=e.items.filter(e=>"pending"===e.state||"drafting"===e.state||"sending"===e.state||"failed"===e.state),r="text-[11px] px-2 py-0.5 rounded-full border border-gray-700 text-gray-400 whitespace-nowrap",n=(e.knowledge??"").split("\n").map(e=>e.trim()).filter(Boolean);return(0,a.jsxs)("section",{className:"rounded-xl border border-gray-800 bg-gray-900/40 p-4",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 flex-wrap",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${"running"===e.status?"bg-emerald-400":"bg-gray-600"}`,title:"running"===e.status?"Running":"Stopped"}),(0,a.jsxs)("span",{className:"text-sm font-semibold",children:["Slack watcher \xb7 #",e.channel.name]}),e.checking&&a.jsx("span",{className:"text-[11px] text-blue-300 animate-pulse",children:"checking…"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mt-2 flex-wrap",children:[(0,a.jsxs)("select",{value:e.liveId??"",onChange:t=>c("watcher-set-session",{id:e.id,liveId:t.target.value||null}),title:"Session whose knowledge drafts use (a copy; the session is never touched)",className:"text-[11px] bg-gray-900 border border-gray-700 rounded-full px-2 py-0.5 text-gray-300 max-w-[240px]",children:[a.jsx("option",{value:"",children:"\uD83E\uDDE0 General knowledge"}),e.liveId&&!s.some(t=>t.id===e.liveId)&&(0,a.jsxs)("option",{value:e.liveId,children:["\uD83E\uDDE0 ",l(e.liveId)]}),s.map(e=>(0,a.jsxs)("option",{value:e.id,children:["\uD83E\uDDE0 ",e.label]},e.id))]}),a.jsx("span",{className:`${r} ${"auto"===e.mode?"border-amber-700/60 text-amber-300":""}`,children:"auto"===e.mode?"Answers automatically":"You approve each reply"}),(0,a.jsxs)("span",{className:r,children:["Every ",e.intervalMin," min"]}),(0,a.jsxs)("span",{className:r,title:n.join("\n")||"No extra sources. Edit to add links, folders, channels or notes.",children:["\uD83D\uDCDA ",n.length," source",1===n.length?"":"s"]}),e.instructions&&a.jsx("span",{className:r,title:e.instructions,children:"\uD83D\uDCDD Rules"})]})]}),(0,a.jsxs)("span",{className:"flex gap-2 flex-shrink-0",children:["running"===e.status&&a.jsx("button",{onClick:()=>c("watcher-run",{id:e.id}),disabled:e.checking,className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800 disabled:opacity-40",children:"Check now"}),a.jsx("button",{onClick:()=>d(e),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Edit"}),"running"===e.status&&a.jsx("button",{onClick:()=>c("watcher-stop",{id:e.id}),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-red-400 hover:bg-red-950/40",children:"Stop"})]})]}),a.jsx("div",{className:"mt-3",children:t.length?a.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(360px, 1fr))"},children:t.map(t=>a.jsx(ef,{it:t,onSend:s=>c("watcher-send",{id:e.id,permalink:t.permalink,text:s}),onDismiss:()=>c("watcher-dismiss",{id:e.id,permalink:t.permalink}),onRedraft:()=>c("watcher-redraft",{id:e.id,permalink:t.permalink})},t.permalink))}):(0,a.jsxs)("p",{className:"text-xs text-gray-500",children:["Nothing waiting on you. Last: ",e.log.at(-1)?.text??"no checks yet"]})}),a.jsx(ej,{log:e.log})]},e.id)}),p.map(e=>(0,a.jsxs)("section",{className:"rounded-xl border border-gray-800 bg-gray-900/40 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${(0,x.An)(e)?"bg-blue-400 animate-pulse":"bg-gray-600"}`}),(0,a.jsxs)("button",{onClick:()=>n(e.liveId),className:"text-sm font-medium hover:underline truncate",children:["\uD83D\uDEA2 ",l(e.liveId)]}),a.jsx("span",{className:"text-xs text-gray-500 truncate",children:(0,x.Vm)(e)}),(0,a.jsxs)("span",{className:"ml-auto flex gap-2 flex-shrink-0",children:[a.jsx("button",{onClick:()=>n(e.liveId),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Open"}),(0,x.An)(e)&&a.jsx("button",{onClick:()=>i(e.id),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-red-400 hover:bg-red-950/40",children:"Stop"})]})]}),e.prs.length>0?a.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(420px, 1fr))"},children:e.prs.map(t=>a.jsx(eg.G0,{t:t,slackSet:!!e.config.slackChannel,max:e.config.maxRounds},t.url))}):a.jsx("p",{className:"text-xs text-gray-500",children:e.log.at(-1)?.text})]},e.id))]})]})}function ev({orgName:e,live:t,nameOf:s,meetings:l,notes:n,pipelines:i,watchers:o,inbox:d,usageOrg:c,onAttach:u,onOpen:m,onNewSession:g,onRecord:p}){let[h,b]=(0,r.useState)(null),[y,f]=(0,r.useState)(!1);if(!y)return a.jsx("div",{className:"absolute inset-0 bg-gray-950"});let j=t.filter(e=>"waiting"===e.status),N=t.filter(e=>"thinking"===e.status),v=i.reduce((e,t)=>e+(t.suggestion?1:0)+t.prs.filter(e=>e.suggestion).length,0),w=i.flatMap(e=>e.prs.filter(e=>"ready"===e.state)),k=o.reduce((e,t)=>e+t.items.filter(e=>"pending"===e.state).length,0),S=d?.sections.needsReview.length??0,C=d?.sections.returned.length??0,D=n.filter(e=>e.remindAt&&!e.reminderDone&&e.remindAt>Date.now()).sort((e,t)=>e.remindAt-t.remindAt).slice(0,4),$=[...l].sort((e,t)=>t.startedAt-e.startedAt).slice(0,4),I=new Date().getHours(),A=[...j.slice(0,6).map(e=>({key:`w-${e.id}`,text:s(e.id),sub:"waiting for your input",tone:"text-green-300",go:()=>u(e.id)})),...C?[{key:"ret",text:`${C} PR${C>1?"s":""} back with you`,sub:"changes requested or CI failing",tone:"text-red-300",go:()=>m("prdash")}]:[],...S?[{key:"rev",text:`${S} review request${S>1?"s":""}`,sub:"PRs waiting for your review",tone:"text-amber-300",go:()=>m("prdash")}]:[],...w.length?[{key:"ready",text:`${w.length} PR${w.length>1?"s":""} ready to merge`,sub:"approved, CI green",tone:"text-emerald-300",go:()=>m("automations")}]:[],...v?[{key:"sug",text:`${v} automation suggestion${v>1?"s":""}`,sub:"review and send to the session",tone:"text-amber-300",go:()=>m("automations")}]:[],...k?[{key:"drafts",text:`${k} Slack draft${k>1?"s":""} to approve`,sub:"from channel watchers",tone:"text-blue-300",go:()=>m("automations")}]:[],...h?[{key:"slack",text:`${h} Slack message${h>1?"s":""} waiting on you`,sub:"mentions and DMs not answered",tone:"text-blue-300",go:()=>m("slack")}]:[]],R=(e,t,s,r)=>(0,a.jsxs)("button",{onClick:r,disabled:!r,className:"text-left rounded-xl border border-gray-800 bg-gray-900/50 p-4 hover:enabled:border-gray-600 transition-colors",children:[a.jsx("p",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:e}),a.jsx("p",{className:"text-2xl font-semibold text-gray-100 mt-1 tabular-nums",children:t}),a.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:s})]});return a.jsx("div",{className:"absolute inset-0 overflow-y-auto bg-gray-950 text-gray-100",children:(0,a.jsxs)("div",{className:"max-w-6xl mx-auto px-6 py-6 space-y-6",children:[(0,a.jsxs)("div",{className:"flex items-end gap-3 flex-wrap",children:[(0,a.jsxs)("div",{children:[a.jsx("h1",{className:"text-2xl font-semibold",children:I<12?"Good morning":I<18?"Good afternoon":"Good evening"}),(0,a.jsxs)("p",{className:"text-sm text-gray-500 mt-0.5",children:[new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})," \xb7 ",a.jsx("span",{className:"text-purple-300",children:e})]})]}),(0,a.jsxs)("div",{className:"ml-auto flex gap-2",children:[a.jsx("button",{onClick:g,className:"text-sm px-3 py-1.5 rounded-md bg-blue-600 hover:bg-blue-500",children:"+ New session"}),a.jsx("button",{onClick:p,className:"text-sm px-3 py-1.5 rounded-md border border-gray-700 hover:bg-gray-800",children:"● Record meeting"}),a.jsx("span",{className:"text-xs text-gray-500 self-center hidden md:inline",children:"⌘K to search"})]})]}),(0,a.jsxs)("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(190px, 1fr))"},children:[R("Sessions",t.length,`${N.length} working \xb7 ${j.length} waiting`),R("Spend today",c?`$${c.today.toFixed(2)}`:"—",c?`$${c.week.toFixed(0)} this week`:"API-equivalent",()=>m("usagedash")),R("Pull requests",(d?.sections.waiting.length??0)+C,`${C} need you \xb7 ${d?.sections.mergedRecent.length??0} merged this week`,()=>m("prdash")),R("Automations",i.filter(x.An).length+o.filter(e=>"running"===e.status).length,"running",()=>m("automations")),R("Slack",h??"—","waiting on you",()=>m("slack"))]}),(0,a.jsxs)("div",{className:"grid gap-6 lg:grid-cols-3",children:[(0,a.jsxs)("section",{className:"lg:col-span-2 rounded-xl border border-gray-800 bg-gray-900/40 p-4",children:[a.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-3",children:"Needs you"}),0===A.length?a.jsx("p",{className:"text-sm text-gray-500 py-6 text-center",children:"You're all caught up. \uD83C\uDF89"}):a.jsx("ul",{className:"divide-y divide-gray-800/70",children:A.map(e=>a.jsx("li",{children:(0,a.jsxs)("button",{onClick:e.go,className:"w-full text-left py-2.5 flex items-center gap-3 hover:bg-gray-800/30 rounded px-2 -mx-2",children:[a.jsx("span",{className:`text-sm font-medium truncate ${e.tone}`,children:e.text}),e.sub&&a.jsx("span",{className:"text-xs text-gray-500 truncate",children:e.sub}),a.jsx("span",{className:"ml-auto text-gray-600",children:"→"})]})},e.key))}),N.length>0&&(0,a.jsxs)("div",{className:"mt-4",children:[a.jsx("p",{className:"text-[11px] uppercase tracking-wide text-gray-500 mb-1.5",children:"Working now"}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:N.slice(0,12).map(e=>(0,a.jsxs)("button",{onClick:()=>u(e.id),className:"text-xs px-2 py-1 rounded-md bg-gray-800 hover:bg-gray-700 text-gray-300 max-w-[220px] truncate",children:[a.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-yellow-400 animate-pulse mr-1.5"}),s(e.id)]},e.id))})]})]}),(0,a.jsxs)("section",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"rounded-xl border border-gray-800 bg-gray-900/40 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center mb-2",children:[a.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide",children:"Recent meetings"}),a.jsx("button",{onClick:()=>m("meetinglib"),className:"ml-auto text-xs text-blue-400 hover:underline",children:"All"})]}),0===$.length?a.jsx("p",{className:"text-xs text-gray-500",children:"No recordings yet."}):a.jsx("ul",{className:"space-y-1.5",children:$.map(e=>a.jsx("li",{children:(0,a.jsxs)("button",{onClick:()=>m({meetingId:e.id}),className:"w-full text-left flex gap-2 text-sm hover:text-white text-gray-300",children:["recording"===e.status&&a.jsx("span",{className:"w-2 h-2 mt-1.5 rounded-full bg-red-500 animate-pulse"}),a.jsx("span",{className:"truncate",children:e.title}),a.jsx("span",{className:"ml-auto text-xs text-gray-500 flex-shrink-0",children:new Date(e.startedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]})},e.id))})]}),(0,a.jsxs)("div",{className:"rounded-xl border border-gray-800 bg-gray-900/40 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center mb-2",children:[a.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide",children:"Reminders"}),a.jsx("button",{onClick:()=>m("notes"),className:"ml-auto text-xs text-blue-400 hover:underline",children:"Notes"})]}),0===D.length?a.jsx("p",{className:"text-xs text-gray-500",children:"No upcoming reminders."}):a.jsx("ul",{className:"space-y-1.5",children:D.map(e=>(0,a.jsxs)("li",{className:"flex gap-2 text-sm text-gray-300",children:[a.jsx("span",{className:"truncate",children:e.text.split("\n").find(e=>e.trim())??"Note"}),(0,a.jsxs)("span",{className:"ml-auto text-xs text-amber-400 flex-shrink-0",children:["⏰ ",new Date(e.remindAt).toLocaleString(void 0,{weekday:"short",hour:"2-digit",minute:"2-digit"})]})]},e.id))})]})]})]})]})})}function ew({sessions:e,error:t,onCreate:s,onClose:l,initial:n}){let[i,o]=(0,r.useState)(n?n.channel.name:""),[d,c]=(0,r.useState)(n?.channel??null),[x,u]=(0,r.useState)(n?.liveId??null),[m,g]=(0,r.useState)(n?.mode??"approve"),[p,h]=(0,r.useState)(n?.intervalMin??5),[b,y]=(0,r.useState)(n?.knowledge??""),[f,j]=(0,r.useState)(n?.instructions??""),N="w-full bg-gray-800 border border-gray-700 focus:border-gray-500 rounded-md px-2.5 py-1.5 text-sm text-white outline-none placeholder-gray-500",v=(d?.name??i).replace(/^#/,"").trim();return a.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:l,children:(0,a.jsxs)("div",{className:"w-full max-w-lg bg-gray-900 border border-gray-700 rounded-xl p-5 text-white",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("h2",{className:"text-base font-semibold",children:n?`Edit #${n.channel.name} watcher`:"Watch a Slack channel"}),a.jsx("button",{onClick:l,className:"text-gray-500 hover:text-white","aria-label":"Close",children:"✕"})]}),a.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"Every few minutes it finds new questions in the channel that nobody answered and drafts a reply."}),a.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Channel"}),n?(0,a.jsxs)("p",{className:"text-sm text-gray-200",children:["#",n.channel.name]}):a.jsx(P.a,{value:i,onChange:(e,t)=>{o(e),c(t)},className:N}),a.jsx("label",{className:"block text-xs text-gray-400 mt-4 mb-1",children:"Answer with the knowledge of a session (optional)"}),(0,a.jsxs)("select",{value:x??"",onChange:e=>u(e.target.value||null),className:N,title:"Pick a running session whose work the channel is about. Drafts then use that session's conversation and code.",children:[a.jsx("option",{value:"",children:"None: general knowledge only"}),e.map(e=>a.jsx("option",{value:e.id,children:e.label},e.id))]}),0===e.length&&a.jsx("p",{className:"text-[11px] text-amber-400/80 mt-1",children:"No running sessions in this org. Start one from New Session to use its knowledge."}),a.jsx("p",{className:"text-[11px] text-gray-500 mt-1",children:"Drafts come from a copy of that session's conversation and code. Your session itself is never touched."}),a.jsx("label",{className:"block text-xs text-gray-400 mt-4 mb-1",title:"Claude checks these before drafting. Web pages, files or folders on this Mac, other Slack channels, or plain notes.",children:"Knowledge sources (optional)"}),a.jsx("textarea",{value:b,onChange:e=>y(e.target.value),rows:3,placeholder:"One per line, e.g.\nhttps://docs.example.com/runbook\n/Users/you/repos/infra/docs\n#deployment-runbooks\nProd cluster is aks-tstr-prod-eus2",className:`${N} font-mono text-xs`}),a.jsx("label",{className:"block text-xs text-gray-400 mt-3 mb-1",title:"Rules for every reply: tone, what never to promise, who to tag",children:"How to answer (optional)"}),a.jsx("textarea",{value:f,onChange:e=>j(e.target.value),rows:2,placeholder:"e.g. Never say a deploy is done. Tag @devops for prod changes. Keep it short.",className:`${N} text-xs`}),(0,a.jsxs)("div",{className:"flex gap-4 mt-4 text-sm",children:[(0,a.jsxs)("label",{className:"flex items-center gap-1.5",children:[a.jsx("input",{type:"radio",checked:"approve"===m,onChange:()=>g("approve")}),"I approve each reply"]}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5",children:[a.jsx("input",{type:"radio",checked:"auto"===m,onChange:()=>g("auto")}),"Answer automatically"]})]}),"auto"===m&&a.jsx("p",{className:"text-[11px] text-amber-400 mt-1",children:"Replies are posted in Slack as you, without review."}),(0,a.jsxs)("label",{className:"block text-xs text-gray-400 mt-4",children:["Check every",(0,a.jsxs)("span",{className:"flex items-center gap-2 mt-1",children:[a.jsx("input",{type:"number",min:2,max:60,value:p,onChange:e=>h(Number(e.target.value)),className:`${N} w-20`})," minutes"]})]}),t&&a.jsx("p",{className:"text-xs text-red-400 mt-3",children:t}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 mt-5",children:[a.jsx("button",{onClick:l,className:"px-3 py-1.5 text-sm text-gray-400 hover:text-white",children:"Cancel"}),a.jsx("button",{disabled:!v,onClick:()=>{s({channel:{id:d?.id??"",name:v},liveId:x,mode:m,intervalMin:p,knowledge:b,instructions:f}),l()},className:"px-3 py-1.5 text-sm rounded-md bg-blue-600 hover:bg-blue-500 disabled:opacity-40",children:n?"Save":"Start watching"})]})]})})}let ek=[["account","Claude account"],["sessions","Sessions"],["power","Power"],["notifications","Notifications"],["meetings","Meetings"]];function eS({id:e,title:t,desc:s,children:r}){return(0,a.jsxs)("section",{id:`settings-${e}`,className:"scroll-mt-6 rounded-xl border border-gray-800 bg-gray-900/40 p-5",children:[a.jsx("h2",{className:"text-sm font-semibold text-gray-100",children:t}),a.jsx("p",{className:"text-xs text-gray-500 mt-0.5 mb-4",children:s}),a.jsx("div",{className:"space-y-3",children:r})]})}function eC({onClose:e}){let[t,s]=(0,r.useState)(!0),[l,n]=(0,r.useState)(300),[i,o]=(0,r.useState)(!1),[d,x]=(0,r.useState)(!0),[u,m]=(0,r.useState)(!1),[g,p]=(0,r.useState)(!1),[h,b]=(0,r.useState)("unsupported"),[y,f]=(0,r.useState)("idle"),[j,N]=(0,r.useState)(""),[v,w]=(0,r.useState)(null),[k,S]=(0,r.useState)("none"),[C,D]=(0,r.useState)(""),[$,I]=(0,r.useState)(""),[A,R]=(0,r.useState)(""),[P,O]=(0,r.useState)(!1),[M,L]=(0,r.useState)(null),[E,T]=(0,r.useState)("login"),[U,F]=(0,r.useState)(""),[_,H]=(0,r.useState)(!1),J=e=>t=>{e(t),O(!0),f("idle")},B=l>=100&&l<=1e3;async function q(){f("saving");try{if(!(await fetch("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoCompact:{enabled:t,windowTokens:1e3*l},notifications:{enabled:d},sessions:{skipPermissions:u},power:{keepAwake:g}})})).ok)throw Error("Could not save settings");if(P){let e="azure"===k?{provider:"azure",endpoint:C,deployment:$,apiKey:A}:"openai"===k?{provider:"openai",apiKey:A}:{provider:"none"},t=await fetch("/api/settings/transcription",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();if(!t.ok)throw Error(s.error??"Could not save transcription");w(s),R(""),O(!1)}if(_){let e=await fetch("/api/settings/auth",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify("apiKey"===E?{mode:"apiKey",apiKey:U}:{mode:"login"})}),t=await e.json();if(!e.ok)throw Error(t.error??"Could not save sign-in");L(t),F(""),H(!1)}c=d,window.dispatchEvent(new CustomEvent("polyergon:settings-changed")),f("saved")}catch(e){N(e.message||"Could not save settings"),f("error")}}return(0,a.jsxs)("div",{className:"absolute inset-0 flex bg-gray-950 text-gray-100",children:[(0,a.jsxs)("nav",{className:"hidden md:flex flex-col gap-0.5 w-48 flex-shrink-0 border-r border-gray-800 px-3 py-6",children:[a.jsx("h1",{className:"text-lg font-semibold px-2 mb-3",children:"Settings"}),ek.map(([e,t])=>a.jsx("button",{onClick:()=>document.getElementById(`settings-${e}`)?.scrollIntoView({behavior:"smooth"}),className:"text-left text-sm px-2 py-1.5 rounded-md text-gray-400 hover:text-gray-100 hover:bg-gray-800/60",children:t},e))]}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[a.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6",children:(0,a.jsxs)("div",{className:"max-w-2xl space-y-5",children:[a.jsx("h1",{className:"text-lg font-semibold md:hidden",children:"Settings"}),(0,a.jsxs)(eS,{id:"account",title:"Claude account",desc:"How sessions sign in to Claude. Each org has its own login.",children:[(0,a.jsxs)("div",{className:"flex gap-4 text-sm",children:[(0,a.jsxs)("label",{className:"flex items-center gap-1.5",children:[a.jsx("input",{type:"radio",checked:"login"===E,onChange:()=>{T("login"),H(!0),f("idle")}}),"Claude login"]}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5",children:[a.jsx("input",{type:"radio",checked:"apiKey"===E,onChange:()=>{T("apiKey"),H(!0),f("idle")}}),"API key"]})]}),"login"===E&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs rounded border border-gray-800 bg-gray-900/60 px-2.5 py-2",children:[M?M.login?.loggedIn?(0,a.jsxs)("span",{className:"text-emerald-300 flex-1",children:["✓ Signed in",M.login.email?` as ${M.login.email}`:"",M.login.orgName?` \xb7 ${M.login.orgName}`:"",M.login.plan?` \xb7 ${M.login.plan}`:""]}):M.login?a.jsx("span",{className:"text-amber-300 flex-1",children:"Not signed in. Sessions in this org will ask you to log in."}):a.jsx("span",{className:"text-gray-500 flex-1",children:"Couldn't check sign-in (is the claude CLI installed?)"}):a.jsx("span",{className:"text-gray-500",children:"Checking sign-in…"}),M&&a.jsx("button",{type:"button",onClick:()=>{(0,ei.w0)(),e()},title:"Opens a new session in this org running /login. Follow the browser sign-in, then come back.",className:"px-2 py-1 rounded border border-gray-700 text-gray-200 hover:bg-gray-800",children:M.login?.loggedIn?"Switch account":"Sign in"})]}),"apiKey"===E&&(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Anthropic API key",a.jsx("input",{type:"password",autoComplete:"off",value:U,onChange:e=>{F(e.target.value),H(!0),f("idle")},placeholder:M?.keyHint?`Saved (${M.keyHint}). Leave blank to keep it.`:"sk-ant-…",className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-white mt-1"})]}),a.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"login"===E?"Sessions use the account you logged in with in Claude Code (subscription or SSO). Each org has its own login.":"Sessions bill this API key at API rates. Claude Code may ask once, in the session, to confirm using the key. Applies to sessions started, resumed or restarted after you save."})]}),(0,a.jsxs)(eS,{id:"sessions",title:"Sessions",desc:"How new Claude and Copilot sessions run.",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm font-medium",children:[a.jsx("input",{type:"checkbox",checked:t,disabled:!i,onChange:e=>{s(e.target.checked),f("idle")}}),"Auto-compact Claude sessions"]}),(0,a.jsxs)("label",{className:`block text-sm ${t?"":"opacity-40"}`,children:[a.jsx("span",{className:"text-gray-400",children:"Compact when context reaches"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[a.jsx("input",{type:"number",min:100,max:1e3,step:50,value:l,disabled:!t||!i,onChange:e=>{n(Number(e.target.value)),f("idle")},className:"w-28 bg-gray-800 border border-gray-700 rounded px-2 py-1 text-white"}),a.jsx("span",{className:"text-gray-400",children:"k tokens"})]}),!B&&(0,a.jsxs)("p",{className:"text-xs text-red-400 mt-1",children:["Pick a value from ",100,"k to ",1e3,"k."]})]}),a.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Claude compacts on its own between turns, a little before this limit. Recommended: 250k–300k. Applies to sessions started, resumed or restarted after you save. Copilot sessions are not affected."}),a.jsx("div",{className:"border-t border-gray-800 pt-3"}),(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm font-medium",children:[a.jsx("input",{type:"checkbox",checked:u,disabled:!i,onChange:e=>{m(e.target.checked),f("idle")}}),"Skip permission prompts"]}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 leading-relaxed",children:["Sessions run commands and edit files without asking (Claude ",a.jsx("code",{children:"bypassPermissions"}),", Copilot ",a.jsx("code",{children:"--allow-all"}),"). Applies to sessions started, resumed or restarted after you save."]}),u&&a.jsx("p",{className:"text-xs text-amber-400",children:"Only use this with folders and tasks you trust."})]}),(0,a.jsxs)(eS,{id:"power",title:"Power",desc:"Keep sessions and automations running when you step away.",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm font-medium",title:"Uses macOS caffeinate while Polyergon runs",children:[a.jsx("input",{type:"checkbox",checked:g,disabled:!i,onChange:e=>{p(e.target.checked),f("idle")}}),"Keep working while the Mac is locked or idle"]}),a.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Stops the Mac from going to sleep on its own, so sessions, Slack watchers and automations keep running. The screen can still lock and turn off. Closing the lid still puts the Mac to sleep. Uses more battery; turns off when Polyergon stops."}),a.jsx("p",{className:"text-xs text-gray-500",children:"Locking the screen alone never stops Polyergon; only sleep does."})]}),(0,a.jsxs)(eS,{id:"notifications",title:"Notifications",desc:"Desktop alerts from this browser.",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm font-medium",children:[a.jsx("input",{type:"checkbox",checked:d,disabled:!i,onChange:e=>{x(e.target.checked),f("idle")}}),"Desktop notifications"]}),a.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Alerts when a session needs your input, and for note reminders."}),d&&"default"===h&&a.jsx("button",{onClick:function(){"undefined"!=typeof Notification&&Notification.requestPermission().then(b)},className:"text-xs px-2.5 py-1 rounded-md bg-gray-800 hover:bg-gray-700 border border-gray-700",children:"Allow notifications in Chrome"}),d&&"denied"===h&&a.jsx("p",{className:"text-xs text-amber-400",children:"Chrome is blocking notifications for this site. Click the icon left of the address bar, then allow Notifications."}),d&&"granted"===h&&a.jsx("p",{className:"text-xs text-green-400",children:"Chrome permission: allowed"}),"unsupported"===h&&a.jsx("p",{className:"text-xs text-gray-500",children:"This browser does not support notifications."})]}),(0,a.jsxs)(eS,{id:"meetings",title:"Meetings",desc:"Speech-to-text for recorded meetings.",children:[a.jsx("p",{className:"text-sm font-medium",children:"Transcription service"}),(0,a.jsxs)("select",{value:k,onChange:e=>J(S)(e.target.value),className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-white mt-1",children:[a.jsx("option",{value:"none",children:"Not configured"}),a.jsx("option",{value:"openai",children:"OpenAI"}),a.jsx("option",{value:"azure",children:"Azure OpenAI"})]}),"azure"===k&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Endpoint",a.jsx("input",{value:C,onChange:e=>J(D)(e.target.value),placeholder:"https://your-resource.openai.azure.com",className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-white mt-1"})]}),(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Deployment",a.jsx("input",{value:$,onChange:e=>J(I)(e.target.value),placeholder:"gpt-4o-transcribe",className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-white mt-1"})]})]}),"none"!==k&&(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["API key",a.jsx("input",{type:"password",autoComplete:"off",value:A,onChange:e=>J(R)(e.target.value),placeholder:v?.provider===k&&v.keyHint?`Saved (${v.keyHint}). Leave blank to keep it.`:"Paste your key",className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-white mt-1"})]}),v?.fromEnv&&a.jsx("p",{className:"text-xs text-gray-500",children:"Using OPENAI_API_KEY from the environment."}),a.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Stored only on this computer, readable by your user only. Never sent to the browser."})]})]})}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2 px-6 py-3 border-t border-gray-800 bg-gray-950/95",children:["saved"===y&&a.jsx("span",{className:"text-xs text-green-400 mr-auto",children:"Saved"}),"error"===y&&a.jsx("span",{className:"text-xs text-red-400 mr-auto",children:j||"Could not save settings"}),a.jsx("button",{onClick:q,disabled:!i||!B||"saving"===y,className:"px-3 py-1.5 text-sm rounded-md bg-blue-600 hover:bg-blue-500 disabled:opacity-40",children:"saving"===y?"Saving…":"Save"})]})]})]})}var eD=s(9952);let e$={needsReview:"#3987e5",returned:"#d95926",waiting:"#199e70",muted:"#898781"},eI=["#86b6ef","#5598e7","#3987e5","#256abf","#184f95"],eA=[{key:"needsReview",label:"Needs your review",color:e$.needsReview},{key:"returned",label:"Returned to you",color:e$.returned},{key:"waiting",label:"Waiting on others",color:e$.waiting}],eR=[{label:"<2d",min:0,max:1728e5},{label:"2–7d",min:1728e5,max:6048e5},{label:"1–2w",min:6048e5,max:12096e5},{label:"2–4w",min:12096e5,max:24192e5},{label:">4w",min:24192e5,max:1/0}];function eP(e){let t=Math.floor(e/864e5);return t<1?"today":t<14?`${t}d`:`${Math.floor(t/7)}w`}function eO({label:e,value:t,accent:s,selected:r,onClick:l}){return(0,a.jsxs)("button",{onClick:l,className:`bg-gray-900 rounded-lg px-5 py-4 flex-1 min-w-[140px] text-left transition-all ${l?"hover:bg-gray-800/80 cursor-pointer":"cursor-default"} ${r?"ring-2 ring-blue-500":""}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[s&&a.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:s}}),a.jsx("span",{className:"text-xs text-gray-500",children:e})]}),a.jsx("p",{className:"text-4xl font-semibold text-white mt-1.5",children:t})]})}function eM({inbox:e,orgs:t,activeOrgId:s,refreshing:l,onRefresh:n,onAttachLive:o,onSelectHistory:d,onReviewWithClaude:c}){let[x,u]=(0,r.useState)(null),[m,g]=(0,r.useState)(null),p=e=>i(e.repo,s,t),h="all"===s?null:t.find(e=>e.id===s)?.name??null,b=(0,r.useMemo)(()=>[...e.sections.needsReview.filter(p).map(e=>({...e,sect:"needsReview"})),...e.sections.returned.filter(p).map(e=>({...e,sect:"returned"})),...e.sections.waiting.filter(p).map(e=>({...e,sect:"waiting"}))],[e,s,t]),y=(0,r.useMemo)(()=>(e.mergedWindow??[]).filter(p),[e,s,t]),f=(0,r.useMemo)(()=>{let e=new Map;for(let t of b){let s=t.repo.split("/").at(-1)??t.repo;e.has(s)||e.set(s,{needsReview:0,returned:0,waiting:0}),e.get(s)[t.sect]++}return Array.from(e.entries()).map(([e,t])=>({repo:e,...t,total:t.needsReview+t.returned+t.waiting})).sort((e,t)=>t.total-e.total).slice(0,10)},[b]),j=(0,r.useMemo)(()=>{let e=Date.now();return eR.map(t=>({label:t.label,count:b.filter(s=>{let a=e-(s.createdAt||e);return a>=t.min&&a<t.max}).length}))},[b]),N=(0,r.useMemo)(()=>e.mergedByWeek.map(e=>({...e,count:y.filter(t=>t.closedAt&&t.closedAt>=e.weekStart&&t.closedAt<e.weekStart+6048e5).length})),[e.mergedByWeek,y]),v=Math.max(1,...N.map(e=>e.count)),w=Math.max(1,...j.map(e=>e.count)),k=Math.max(1,...f.map(e=>e.total)),S=y.filter(e=>(e.closedAt??0)>=Date.now()-6048e5).length,C=(0,r.useMemo)(()=>{if(m?.weekStart!==void 0)return y.filter(e=>e.closedAt&&e.closedAt>=m.weekStart&&e.closedAt<m.weekStart+6048e5);let e=b;if(m?.section&&(e=e.filter(e=>e.sect===m.section)),m?.repo&&(e=e.filter(e=>(e.repo.split("/").at(-1)??e.repo)===m.repo)),m?.ageBucket){let t=eR.find(e=>e.label===m.ageBucket),s=Date.now();e=e.filter(e=>{let a=s-(e.createdAt||s);return a>=t.min&&a<t.max})}return m?[...e].sort((e,t)=>e.createdAt-t.createdAt):[...e].sort((e,t)=>e.createdAt-t.createdAt).slice(0,5)},[m,b,y]),D=[];m?.section&&D.push({label:eA.find(e=>e.key===m.section).label,clear:()=>g(e=>({...e,section:void 0}))}),m?.repo&&D.push({label:m.repo,clear:()=>g(e=>({...e,repo:void 0}))}),m?.ageBucket&&D.push({label:`age ${m.ageBucket}`,clear:()=>g(e=>({...e,ageBucket:void 0}))}),m?.weekStart!==void 0&&D.push({label:`merged week of ${new Date(m.weekStart).toLocaleDateString([],{month:"short",day:"numeric"})}`,clear:()=>g(null)});let $=0===D.length?null:m,I=D.length>0;function A(e,t){let s=e.currentTarget.closest("[data-dash-root]")?.getBoundingClientRect();s&&u({x:e.clientX-s.left+12,y:e.clientY-s.top+12,lines:t})}return(0,a.jsxs)("div",{"data-dash-root":!0,className:"absolute inset-0 overflow-y-auto bg-gray-950",children:[(0,a.jsxs)("div",{className:"max-w-4xl mx-auto px-6 py-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-5",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("h2",{className:"text-white font-semibold text-lg flex items-center gap-2",children:["PR Dashboard",h&&a.jsx("span",{className:"px-2 py-0.5 rounded bg-purple-900/50 text-purple-300 text-xs font-medium",children:h})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-600",children:["Your GitHub workload \xb7 updated ",new Date(e.fetchedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})," \xb7 click any tile or bar to drill in"]})]}),a.jsx("button",{onClick:n,disabled:l,className:"bg-gray-800 hover:bg-gray-700 disabled:opacity-50 text-gray-200 rounded px-3 py-1.5 text-xs font-medium",children:l?"Refreshing…":"Refresh"})]}),(0,a.jsxs)("div",{className:"flex gap-3 flex-wrap mb-6",children:[eA.map(e=>a.jsx(eO,{label:e.label,value:b.filter(t=>t.sect===e.key).length,accent:e.color,selected:$?.section===e.key,onClick:()=>{var t;return t=e.key,void g(e=>e?.section===t?{...e,section:void 0,weekStart:void 0}:{...e,section:t,weekStart:void 0})}},e.key)),a.jsx(eO,{label:"Merged \xb7 7d",value:S})]}),(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5 mb-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium",children:"Open PRs by repo"}),a.jsx("div",{className:"flex items-center gap-3",children:eA.map(e=>(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-gray-500",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-sm",style:{background:e.color}}),e.label]},e.key))})]}),a.jsx("div",{className:"space-y-1.5",children:f.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("button",{className:`text-xs w-44 truncate text-right flex-shrink-0 hover:text-white ${$?.repo===e.repo?"text-white font-medium":"text-gray-400"}`,title:`Filter to ${e.repo}`,onClick:()=>g(t=>t?.repo===e.repo?{...t,repo:void 0,weekStart:void 0}:{...t,repo:e.repo,weekStart:void 0}),children:e.repo}),(0,a.jsxs)("div",{className:"flex-1 flex items-center h-4",style:{gap:2},children:[eA.map(t=>e[t.key]>0&&a.jsx("button",{className:"h-4 rounded-[4px] hover:brightness-125",style:{width:`${e[t.key]/k*100}%`,background:t.color,minWidth:6},onMouseMove:s=>A(s,[`${e.repo} — ${t.label}`,`${e[t.key]} PR${1===e[t.key]?"":"s"} \xb7 click to drill in`]),onMouseLeave:()=>u(null),onClick:()=>{u(null),g({section:t.key,repo:e.repo})}},t.key)),a.jsx("span",{className:"text-xs text-gray-500 ml-1.5",children:e.total})]})]},e.repo))})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-6 mb-6",children:[(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium mb-3",children:"Age of open PRs"}),a.jsx("div",{className:"flex items-end justify-between gap-2 h-32",children:j.map((e,t)=>(0,a.jsxs)("button",{className:"flex-1 flex flex-col items-center justify-end h-full group",onClick:()=>g(t=>t?.ageBucket===e.label?{...t,ageBucket:void 0}:{...t,ageBucket:e.label,weekStart:void 0}),children:[e.count>0&&a.jsx("span",{className:"text-xs text-gray-400 mb-1",children:e.count}),a.jsx("div",{className:"w-full rounded-t-[4px] group-hover:brightness-125",style:{height:`${e.count/w*82}%`,background:eI[t],minHeight:e.count>0?4:0},onMouseMove:t=>A(t,[`${e.label} old`,`${e.count} open PR${1===e.count?"":"s"} \xb7 click to drill in`]),onMouseLeave:()=>u(null)}),a.jsx("span",{className:`text-[10px] mt-1.5 ${$?.ageBucket===e.label?"text-white font-medium":""}`,style:$?.ageBucket===e.label?{}:{color:e$.muted},children:e.label})]},e.label))})]}),(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium mb-3",children:"Merged per week"}),a.jsx("div",{className:"flex items-end justify-between gap-2 h-32",children:N.map((e,t)=>{let s=t===N.length-1,r=new Date(e.weekStart).toLocaleDateString([],{month:"short",day:"numeric"}),l=$?.weekStart===e.weekStart;return(0,a.jsxs)("button",{className:"flex-1 flex flex-col items-center justify-end h-full group",onClick:()=>g(t=>t?.weekStart===e.weekStart?null:{weekStart:e.weekStart}),children:[(e.count===v||s)&&e.count>0&&a.jsx("span",{className:"text-xs text-gray-400 mb-1",children:e.count}),a.jsx("div",{className:"w-full rounded-t-[4px] group-hover:brightness-125",style:{height:`${e.count/v*82}%`,background:e$.needsReview,opacity:l||s?1:.85,minHeight:e.count>0?4:0},onMouseMove:t=>A(t,[`Week of ${r}`,`${e.count} merged \xb7 click to drill in`]),onMouseLeave:()=>u(null)}),a.jsx("span",{className:`text-[10px] mt-1.5 whitespace-nowrap ${l?"text-white font-medium":""}`,style:l?{}:{color:e$.muted},children:r})]},e.weekStart)})})]})]}),(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium",children:I?`${C.length} PR${1===C.length?"":"s"}`:"Oldest open PRs"}),D.map(e=>(0,a.jsxs)("button",{onClick:e.clear,className:"flex items-center gap-1 text-xs bg-gray-800 hover:bg-gray-700 text-gray-300 rounded-full px-2.5 py-0.5",children:[e.label," ",a.jsx("span",{className:"text-gray-500",children:"\xd7"})]},e.label)),I&&a.jsx("button",{onClick:()=>g(null),className:"text-xs text-gray-600 hover:text-gray-400",children:"clear all"})]}),0===C.length?a.jsx("p",{className:"text-xs text-gray-600",children:"Nothing matches \uD83C\uDF89"}):a.jsx("div",{className:"space-y-0.5",children:C.map(e=>{let t="sect"in e?eA.find(t=>t.key===e.sect):null,s=e.url.match(/\/pull\/(\d+)/)?.[1];return(0,a.jsxs)("div",{className:"group/row flex items-center gap-3 px-2 py-1.5 rounded hover:bg-gray-800/70",children:[a.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:t?.color??"#6b21a8"},title:t?.label??"Merged"}),a.jsx("button",{onClick:()=>{e.liveId?o(e.liveId):e.sessionId?d(e.sessionId,e.cwd):window.open(e.url,"_blank","noopener")},className:"text-sm text-gray-200 truncate flex-1 text-left hover:text-white",title:e.title,children:e.title}),(e.liveId||e.sessionId)&&a.jsx("span",{className:"text-[10px] text-blue-500/80 flex-shrink-0",children:"session"}),(0,a.jsxs)("span",{className:"text-xs text-gray-600 flex-shrink-0 w-40 truncate text-right",children:[e.repo.split("/").at(-1),"#",s]}),a.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0 w-10 text-right",children:e.closedAt?eP(Date.now()-e.closedAt):eP(Date.now()-e.createdAt)}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0 opacity-0 group-hover/row:opacity-100 transition-opacity",children:[!e.closedAt&&a.jsx("button",{onClick:()=>c(e.url),className:"text-xs bg-blue-600/80 hover:bg-blue-500 text-white rounded px-2 py-0.5",title:"Start a Claude session that reviews this PR (cr <url>)",children:"Review"}),a.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-gray-500 hover:text-white px-1",title:"Open on GitHub",children:"↗"})]})]},e.url)})})]})]}),x&&a.jsx("div",{className:"absolute z-30 pointer-events-none bg-gray-800 border border-gray-700 rounded px-2.5 py-1.5 shadow-lg",style:{left:x.x,top:x.y},children:x.lines.map((e,t)=>a.jsx("p",{className:0===t?"text-xs text-gray-400":"text-xs text-white font-medium",children:e},t))})]})}let eL=["#3987e5","#d95926","#199e70","#c98500"];function eE(e){return e>=1e3?`$${(e/1e3).toFixed(1)}k`:e>=100?`$${Math.round(e)}`:`$${e.toFixed(2)}`}function eT(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}function eU({label:e,value:t,sub:s}){return(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg px-5 py-4 flex-1 min-w-[130px]",children:[a.jsx("span",{className:"text-xs text-gray-500",children:e}),a.jsx("p",{className:"text-3xl font-semibold text-white mt-1",children:t}),s&&a.jsx("p",{className:"text-xs text-gray-600 mt-0.5",children:s})]})}function eF({label:e,percent:t,resetsAt:s,severity:r}){let l="critical"===r||t>=95?"#d03b3b":"warning"===r||t>=80?"#fab219":"#0ca30c";return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-baseline justify-between mb-1",children:[a.jsx("span",{className:"text-xs text-gray-400",children:e}),(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:[(0,a.jsxs)("span",{className:"font-semibold",style:{color:l},children:[t,"%"]})," used \xb7 ",100-t,"% left \xb7 ",function(e){if(!e)return"";let t=Date.parse(e)-Date.now();if(Number.isNaN(t)||t<=0)return"resetting…";let s=Math.floor(t/36e5),a=Math.floor(t%36e5/6e4);return s>=48?`resets in ${Math.round(s/24)}d`:s>0?`resets in ${s}h ${a}m`:`resets in ${a}m`}(s)]})]}),a.jsx("div",{className:"h-2 rounded-full bg-gray-800 overflow-hidden",children:a.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.min(100,t)}%`,background:l,minWidth:t>0?4:0}})})]})}function e_({usage:e,limits:t,orgs:s,activeOrgId:l,historySessions:n,liveSessions:i,onAttachLive:o,onSelectHistory:d}){let[c,x]=(0,r.useState)(null),u=s.filter(t=>("all"===l||t.id===l)&&e.orgs[t.id]),m=e=>eL[Math.max(0,s.findIndex(t=>t.id===e))%eL.length],g=u.reduce((t,s)=>{let a=e.orgs[s.id];return t.c5h+=a.last5h.costUSD,t.c24h+=a.last24h.costUSD,t.c7d+=a.last7d.costUSD,t.total+=a.totalCostUSD,t.sessions+=a.sessions,t.out+=a.totalTokens.output,t.inp+=a.totalTokens.input,t.cache+=a.totalTokens.cacheRead,t},{c5h:0,c24h:0,c7d:0,total:0,sessions:0,out:0,inp:0,cache:0}),p=(e.orgs[u[0]?.id]?.daily.map(e=>e.dayStart)??[]).map((t,s)=>({dayStart:t,parts:u.map(t=>({orgId:t.id,name:t.name,cost:e.orgs[t.id].daily[s]?.costUSD??0})),total:u.reduce((t,a)=>t+(e.orgs[a.id].daily[s]?.costUSD??0),0)})),h=Math.max(1,...p.map(e=>e.total)),b=(0,r.useMemo)(()=>{try{return JSON.parse(localStorage.getItem("claude-session-names")??"{}")}catch{return{}}},[]),y=(0,r.useMemo)(()=>Object.entries(e.sessions).filter(([,e])=>"all"===l||e.orgId===l).sort((e,t)=>t[1].costUSD-e[1].costUSD).slice(0,12).map(([e,t])=>{let s=n.find(t=>t.sessionId===e),a=i.find(t=>t.claudeSessionId===e),r=a&&b[a.id]||b[e]||s?.firstUserMessage||e.slice(0,8);return{sessionId:e,name:r,cost:t.costUSD,tokens:t.tokens,orgId:t.orgId,liveId:a?.id??null,cwd:s?.cwd??a?.cwd??null}}),[e,l,n,i,b]),f="all"===l?null:s.find(e=>e.id===l)?.name??null;return(0,a.jsxs)("div",{"data-usage-root":!0,className:"absolute inset-0 overflow-y-auto bg-gray-950",children:[(0,a.jsxs)("div",{className:"max-w-4xl mx-auto px-6 py-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,a.jsxs)("h2",{className:"text-white font-semibold text-lg flex items-center gap-2",children:["Usage",f&&a.jsx("span",{className:"px-2 py-0.5 rounded bg-purple-900/50 text-purple-300 text-xs font-medium",children:f})]}),(0,a.jsxs)("span",{className:"text-xs text-gray-600",children:["scanned ",new Date(e.scannedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-600 mb-5",children:[a.jsx("span",{className:"text-gray-400 font-medium",children:"Dollar figures are value, not bills"})," — what your usage would cost at API prices. On a subscription you pay only the flat plan fee; limits throttle, they don't charge (unless an org has extra-usage billing on)."]}),t&&u.some(e=>t.orgs[e.id])&&(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5 mb-6",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium mb-4",children:"Plan limits (official, live)"}),a.jsx("div",{className:`grid gap-6 ${u.length>1?"grid-cols-2":"grid-cols-1"}`,children:u.map(e=>{let s=t.orgs[e.id];return s?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:m(e.id)}}),a.jsx("span",{className:"text-sm text-gray-200 font-medium",children:e.name}),e.plan?.name&&(0,a.jsxs)("span",{className:"text-xs text-gray-600",children:["\xb7 ",e.plan.name]})]}),s.error?a.jsx("p",{className:"text-xs text-yellow-600",children:s.error}):(0,a.jsxs)("div",{className:"space-y-3",children:[s.fiveHour&&a.jsx(eF,{label:"Session (5h window)",percent:s.fiveHour.percent,resetsAt:s.fiveHour.resetsAt,severity:s.fiveHour.severity}),s.weekly&&a.jsx(eF,{label:"Weekly (all models)",percent:s.weekly.percent,resetsAt:s.weekly.resetsAt,severity:s.weekly.severity}),s.scoped.map(e=>a.jsx(eF,{label:`Weekly \xb7 ${e.name}`,percent:e.percent,resetsAt:e.resetsAt,severity:e.severity},e.name)),s.extraUsage&&(s.extraUsage.enabled?(0,a.jsxs)("div",{className:"flex items-baseline justify-between rounded bg-red-950/40 border border-red-900/40 px-2.5 py-1.5",children:[a.jsx("span",{className:"text-xs text-red-300 font-medium",children:"Extra usage ON — overage bills real money"}),(0,a.jsxs)("span",{className:"text-xs text-red-200 font-semibold",children:[null!=s.extraUsage.usedUSD?`$${s.extraUsage.usedUSD.toLocaleString(void 0,{maximumFractionDigits:0})} billed`:"",s.extraUsage.spendLimitReached?" \xb7 spend limit reached":""]})]}):a.jsx("p",{className:"text-[11px] text-gray-600",children:"Extra usage off — hard cap at the subscription; hitting a limit only throttles, never bills."}))]})]},e.id):null})})]}),(0,a.jsxs)("div",{className:"flex gap-3 flex-wrap mb-6",children:[a.jsx(eU,{label:"Last 5 hours",value:eE(g.c5h),sub:"rate-limit window"}),a.jsx(eU,{label:"Last 24 hours",value:eE(g.c24h)}),a.jsx(eU,{label:"Last 7 days",value:eE(g.c7d),sub:"weekly-cap window"}),a.jsx(eU,{label:"All-time",value:eE(g.total),sub:`${g.sessions} sessions`})]}),(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5 mb-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsxs)("h3",{className:"text-sm text-gray-200 font-medium",children:["Value per day ",a.jsx("span",{className:"text-xs text-gray-600 font-normal",children:"(API-equivalent, not billed)"})]}),u.length>1&&a.jsx("div",{className:"flex items-center gap-3",children:u.map(e=>(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-gray-500",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-sm",style:{background:m(e.id)}}),e.name]},e.id))})]}),a.jsx("div",{className:"flex items-end justify-between gap-3 h-40",children:p.map(e=>{let t=new Date(e.dayStart).toLocaleDateString([],{weekday:"short"});return(0,a.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-end h-full",children:[e.total>0&&a.jsx("span",{className:"text-xs text-gray-400 mb-1",children:eE(e.total)}),a.jsx("div",{className:"w-full flex flex-col-reverse",style:{height:`${e.total/h*80}%`,gap:2},children:e.parts.map((s,r)=>s.cost>0&&a.jsx("div",{className:"w-full hover:brightness-125",style:{flex:`${s.cost} 0 auto`,background:m(s.orgId),borderRadius:r===e.parts.filter(e=>e.cost>0).length-1?"4px 4px 0 0":0,minHeight:3},onMouseMove:e=>(function(e,t){let s=e.currentTarget.closest("[data-usage-root]")?.getBoundingClientRect();s&&x({x:e.clientX-s.left+12,y:e.clientY-s.top+12,lines:t})})(e,[`${s.name} — ${t}`,eE(s.cost)]),onMouseLeave:()=>x(null)},s.orgId))}),a.jsx("span",{className:"text-[10px] mt-1.5",style:{color:"#898781"},children:t})]},e.dayStart)})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-6 mb-6",children:[(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium mb-3",children:"By org"}),a.jsx("div",{className:"space-y-3",children:u.map(t=>{let s=e.orgs[t.id],r=s.last7d.costUSD*(30.4375/7),l=t.plan?.monthlyUSD?r/t.plan.monthlyUSD:null;return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:m(t.id)}}),a.jsx("span",{className:"text-sm text-gray-200 font-medium flex-1",children:t.name}),a.jsx("span",{className:"text-sm text-white font-semibold",children:eE(s.totalCostUSD)})]}),(0,a.jsxs)("div",{className:"flex gap-2 text-xs text-gray-500 pl-4 flex-wrap",children:[(0,a.jsxs)("span",{children:["5h ",eE(s.last5h.costUSD)]}),"\xb7",(0,a.jsxs)("span",{children:["24h ",eE(s.last24h.costUSD)]}),"\xb7",(0,a.jsxs)("span",{children:["7d ",eE(s.last7d.costUSD)]}),"\xb7",(0,a.jsxs)("span",{children:[s.sessions," sessions"]})]}),t.plan?.monthlyUSD?(0,a.jsxs)("div",{className:"text-xs pl-4 mt-0.5",children:[(0,a.jsxs)("span",{className:"text-gray-500",children:[t.plan.name??"Plan"," ",eE(t.plan.monthlyUSD),"/mo \xb7 run-rate ",eE(r),"/mo → "]}),(0,a.jsxs)("span",{className:`font-semibold ${l>=1?"text-emerald-500":"text-yellow-500"}`,children:[l.toFixed(1),"\xd7 plan value"]})]}):a.jsx("div",{className:"text-[10px] text-gray-700 pl-4 mt-0.5",children:"Set plan.monthlyUSD in orgs.json to see ROI vs subscription"})]},t.id)})})]}),(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium mb-3",children:"Tokens (all-time)"}),a.jsx("div",{className:"space-y-2.5",children:[["Output",g.out,"what the models wrote"],["Input (fresh)",g.inp,"uncached prompt tokens"],["Cache reads",g.cache,"context served from cache at ~0.1\xd7 price"]].map(([e,t,s])=>(0,a.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,a.jsxs)("div",{children:[a.jsx("span",{className:"text-sm text-gray-300",children:e}),a.jsx("span",{className:"text-xs text-gray-600 ml-2",children:s})]}),a.jsx("span",{className:"text-sm text-white font-semibold",children:eT(t)})]},e))})]})]}),(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium mb-3",children:"Most expensive sessions"}),0===y.length?a.jsx("p",{className:"text-xs text-gray-600",children:"No usage recorded"}):a.jsx("div",{className:"space-y-0.5",children:y.map(e=>(0,a.jsxs)("button",{onClick:()=>e.liveId?o(e.liveId):d(e.sessionId,e.cwd,e.orgId),className:"w-full flex items-center gap-3 px-2 py-1.5 rounded hover:bg-gray-800/70 text-left",children:[a.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:m(e.orgId)}}),a.jsx("span",{className:"text-sm text-gray-200 truncate flex-1",title:e.name,children:e.name}),e.liveId&&a.jsx("span",{className:"text-[10px] text-blue-500/80 flex-shrink-0",children:"live"}),(0,a.jsxs)("span",{className:"text-xs text-gray-600 flex-shrink-0 w-20 text-right",children:[eT(e.tokens.output)," out"]}),a.jsx("span",{className:"text-sm text-emerald-500 font-medium flex-shrink-0 w-16 text-right",children:eE(e.cost)})]},e.sessionId))})]})]}),c&&a.jsx("div",{className:"absolute z-30 pointer-events-none bg-gray-800 border border-gray-700 rounded px-2.5 py-1.5 shadow-lg",style:{left:c.x,top:c.y},children:c.lines.map((e,t)=>a.jsx("p",{className:0===t?"text-xs text-gray-400":"text-xs text-white font-medium",children:e},t))})]})}let eH={transcript:[],notes:null,suggestions:[],qa:[],lastError:null,context:null},eJ=n()(async()=>{},{loadableGenerated:{modules:["app/page.tsx -> ./components/Terminal"]},ssr:!1});function eB(){let{sessions:e,loading:t,deleteSession:s,refresh:l}=function(){let[e,t]=(0,r.useState)([]),[s,a]=(0,r.useState)(!0);return{sessions:e,loading:s,deleteSession:async function(e){t(t=>t.filter(t=>t.sessionId!==e)),await fetch(`/api/sessions/${e}`,{method:"DELETE"})},refresh:(0,r.useCallback)(()=>fetch("/api/sessions").then(e=>e.json()).then(e=>{t(e.map(e=>e.title?{...e,firstUserMessage:e.title}:e)),a(!1)}).catch(()=>a(!1)),[])}}(),{permission:n,enabled:i,requestPermission:o,notifyNeedsInput:d}=function(){let[e,t]=(0,r.useState)("unsupported"),[s,a]=(0,r.useState)(!0);return{permission:e,enabled:s,requestPermission:(0,r.useCallback)(()=>"undefined"==typeof Notification?Promise.resolve():Notification.requestPermission().then(t),[]),notifyNeedsInput:(0,r.useCallback)((e,t,s)=>{if(!c||"undefined"==typeof Notification||"granted"!==Notification.permission)return;let a=new Notification(e,{body:t,icon:"/favicon.ico"});s&&(a.onclick=()=>{window.focus(),s(),a.close()})},[])}}(),{sendToLive:x,ws:u,liveSessions:m,activeSessionId:g,lastCreatedId:p,sessionError:h,setSessionError:b,attachSession:y,createSession:f,resumeSession:j,resumeAllSessions:N,killLiveSession:v,compactSession:w,setRemote:k}=function(){let e=(0,r.useRef)(null),[t,s]=(0,r.useState)(null),[a,l]=(0,r.useState)([]),[n,i]=(0,r.useState)(null),[o,d]=(0,r.useState)("idle"),[c,x]=(0,r.useState)(null),[u,m]=(0,r.useState)(null),g=(0,r.useRef)(null),p=(0,r.useCallback)((t,s,a,r,l,n)=>{e.current?.send(JSON.stringify({type:"create",cwd:t,orgId:s,name:a,backend:r,model:l,prompt:n}))},[]),h=(0,r.useCallback)((t,s,a,r,l,n)=>{e.current?.send(JSON.stringify({type:"resume",cwd:t,claudeSessionId:s,orgId:a,name:r,backend:l,model:n}))},[]),b=(0,r.useCallback)(()=>{l(e=>e.map(e=>"idle"===e.status&&e.claudeSessionId?{...e,status:"thinking"}:e)),e.current?.send(JSON.stringify({type:"resume-all"}))},[]),y=(0,r.useCallback)(t=>{i(t),g.current=t,e.current?.send(JSON.stringify({type:"attach",sessionId:t}))},[]),f=(0,r.useCallback)((t,s)=>{e.current?.send(JSON.stringify({type:"set-rc",sessionId:t,on:s}))},[]),j=(0,r.useCallback)(t=>{e.current?.send(JSON.stringify({type:"restart",sessionId:t}))},[]),N=(0,r.useCallback)(t=>{e.current?.send(JSON.stringify({type:"compact",sessionId:t}))},[]),v=(0,r.useCallback)(t=>{e.current?.send(JSON.stringify({type:"kill",sessionId:t})),l(e=>e.filter(e=>e.id!==t)),g.current===t&&(i(null),g.current=null)},[]);return{sendToLive:(0,r.useCallback)((t,s)=>{e.current?.send(JSON.stringify({type:"send-to-live",id:t,text:s}))},[]),ws:t,liveSessions:a,activeSessionId:n,activeStatus:o,lastCreatedId:u,sessionError:c,setSessionError:x,createSession:p,resumeSession:h,resumeAllSessions:b,attachSession:y,killLiveSession:v,compactSession:N,restartSession:j,setRemote:f}}(),{watchers:S,watcherError:C,watcherCmd:D}=function(e,t){let[s,a]=(0,r.useState)([]),[l,n]=(0,r.useState)(null),i=(0,r.useRef)(e);return i.current=e,(0,r.useRef)(t).current=t,{watchers:s,watcherError:l,watcherCmd:(0,r.useCallback)((e,t={})=>{n(null),i.current?.send(JSON.stringify({type:e,...t}))},[])}}(u,(e,t)=>d(`👂 ${e}`,t)),[$,I]=(0,r.useState)(!1),[A,P]=(0,r.useState)(null),{setPipelineAuto:O,pipelines:M,pipelineError:T,startPipeline:U,stopPipeline:F,addPipelinePr:_,actPipeline:H,dismissPipeline:J}=function(e,t){let[s,a]=(0,r.useState)([]),[l,n]=(0,r.useState)(null),i=(0,r.useRef)(e);i.current=e,(0,r.useRef)(t).current=t;let o=(0,r.useCallback)((e,t)=>{n(null),i.current?.send(JSON.stringify({type:"pipeline-start",liveId:e,config:t}))},[]),d=(0,r.useCallback)((e,t,s)=>{n(null),i.current?.send(JSON.stringify({type:"pipeline-add-pr",id:e,liveId:t,url:s}))},[]),c=(0,r.useCallback)((e,t,s)=>{n(null),i.current?.send(JSON.stringify({type:"pipeline-act",id:e,liveId:t,prUrl:s}))},[]),x=(0,r.useCallback)((e,t)=>{i.current?.send(JSON.stringify({type:"pipeline-dismiss",id:e,prUrl:t}))},[]);return{setPipelineAuto:(0,r.useCallback)((e,t)=>{i.current?.send(JSON.stringify({type:"pipeline-auto",id:e,auto:t}))},[]),pipelines:s,pipelineError:l,startPipeline:o,stopPipeline:(0,r.useCallback)(e=>{i.current?.send(JSON.stringify({type:"pipeline-stop",id:e}))},[]),addPipelinePr:d,actPipeline:c,dismissPipeline:x}}(u,(e,t)=>d(`⚡ ${e}`,t)),{entries:B}=function(e){let[t,s]=(0,r.useState)([]),[a,l]=(0,r.useState)(!0),[n,i]=(0,r.useState)(!1);return(0,r.useCallback)(()=>fetch("/api/prs").then(e=>e.json()).then(s).catch(()=>{}).finally(()=>l(!1)),[]),{entries:t,loading:a,refreshing:n,refresh:(0,r.useCallback)(async()=>{i(!0);try{let e=await fetch("/api/prs/refresh",{method:"POST"});s(await e.json())}catch{}finally{i(!1)}},[])}}(0),{inbox:q,loading:z,refreshing:W,refresh:G}=function(e){let[t,s]=(0,r.useState)(null),[a,l]=(0,r.useState)(!0),[n,i]=(0,r.useState)(!1),o=(0,r.useCallback)((e=!1)=>fetch(`/api/prs/inbox${e?"?refresh=1":""}`).then(e=>e.json()).then(s).catch(()=>{}).finally(()=>l(!1)),[]);return{inbox:t,loading:a,refreshing:n,refresh:(0,r.useCallback)(async()=>{i(!0);try{await o(!0)}finally{i(!1)}},[o])}}(0),{orgs:Y,addOrg:V,refreshOrgs:X}=function(){let[e,t]=(0,r.useState)([]),s=(0,r.useCallback)(()=>fetch("/api/orgs").then(e=>e.json()).then(t).catch(()=>{}),[]);return{orgs:e,addOrg:(0,r.useCallback)(async(e,s,a)=>{let r=await fetch("/api/orgs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,configDir:s,model:a})});if(!r.ok)throw Error((await r.json().catch(()=>null))?.error??"Failed to add org");let l=await r.json();return t(e=>[...e,l]),l},[]),refreshOrgs:s}}(),{notes:Q,setNotes:et}=function(){let[e,t]=(0,r.useState)([]),[s,a]=(0,r.useState)(!1),l=(0,r.useRef)(e);l.current=e;let n=(0,r.useRef)(null);return{notes:e,setNotes:(0,r.useCallback)(e=>{let s="function"==typeof e?e(l.current):e;l.current=s,t(s),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{fetch("/api/notes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notes:l.current})}).catch(()=>{})},300)},[]),loaded:s}}(),[es,er]=(0,r.useState)(0),{meetings:ei,live:eo,activeMeeting:ed,startMeeting:ec,resumeMeeting:ex,stopMeeting:eu,askMeeting:eg,addMeetingContext:ep,micTest:eh,refreshMeetings:eb}=function(e){let[t,s]=(0,r.useState)([]),[a,l]=(0,r.useState)({}),n=(0,r.useRef)(e);n.current=e;let i=(0,r.useCallback)(()=>fetch("/api/meetings").then(e=>e.json()).then(s).catch(()=>{}),[]),o=(0,r.useCallback)((e,t)=>{n.current?.send(JSON.stringify({type:"meeting-start",title:e,orgId:t}))},[]),d=(0,r.useCallback)(e=>{n.current?.send(JSON.stringify({type:"meeting-resume",meetingId:e}))},[]),c=(0,r.useCallback)(e=>{n.current?.send(JSON.stringify({type:"meeting-stop",meetingId:e}))},[]),x=(0,r.useCallback)((e,t)=>{l(s=>{let a=s[e]??eH;return{...s,[e]:{...a,qa:[...a.qa,{question:t,answer:null,t:Date.now()}]}}}),n.current?.send(JSON.stringify({type:"meeting-ask",meetingId:e,question:t}))},[]),u=(0,r.useCallback)((e,t,s)=>{n.current?.send(JSON.stringify({type:"meeting-add-context",meetingId:e,kind:t,value:s}))},[]),m=(0,r.useCallback)(()=>new Promise(e=>{let t=n.current;if(!t||t.readyState!==WebSocket.OPEN){e({error:"Not connected"});return}let s=setTimeout(()=>{t.removeEventListener("message",a),e({error:"Mic test timed out"})},15e3);function a(r){try{let l=JSON.parse(r.data);"meeting-mic-test-result"===l.type&&(clearTimeout(s),t.removeEventListener("message",a),e(l))}catch{}}t.addEventListener("message",a),t.send(JSON.stringify({type:"meeting-mic-test"}))}),[]),g=t.find(e=>"recording"===e.status)??null;return{meetings:t,live:a,activeMeeting:g,startMeeting:o,resumeMeeting:d,stopMeeting:c,askMeeting:x,addMeetingContext:u,micTest:m,refreshMeetings:i}}(u),{usage:ey}=function(){let[e,t]=(0,r.useState)(null),[s,a]=(0,r.useState)(!0);return{usage:e,loading:s,refreshUsage:(0,r.useCallback)(()=>fetch("/api/usage").then(e=>e.json()).then(t).catch(()=>{}).finally(()=>a(!1)),[])}}(),{limits:ef}=function(){let[e,t]=(0,r.useState)(null);return(0,r.useCallback)(()=>fetch("/api/limits").then(e=>e.json()).then(t).catch(()=>{}),[]),{limits:e}}(),[ej,ek]=(0,r.useState)({mode:"empty"}),[eS,e$]=(0,r.useState)(!1),[eI,eA]=(0,r.useState)(!1),eR=(0,r.useRef)(!1),[eP,eO]=(0,r.useState)(288),[eL,eE]=(0,r.useState)([]),[eT,eU]=(0,r.useState)("all");(0,ee.n)(eT);let eF=(0,r.useRef)(!1),eB=(0,r.useRef)(""),eq=e=>e&&ek({mode:"pipeline",liveId:e}),[ez,eW]=(0,r.useState)(!1),[eG,eK]=(0,r.useState)({});(0,r.useRef)({}),(0,r.useRef)({}),(0,r.useRef)({}),(0,r.useRef)(null);let eY=(0,r.useCallback)(e=>{e.preventDefault(),eF.current=!0;let t=e.clientX;function s(e){eF.current&&eO(Math.min(600,Math.max(160,eP+e.clientX-t)))}window.addEventListener("mousemove",s),window.addEventListener("mouseup",function e(){eF.current=!1,window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",e)})},[eP]);function eV(e,t,s){t?j(t,e,s):f("")}let[eX,eQ]=(0,r.useState)(!1);function eZ(e){y(e),ek({mode:"live"})}let e0=(0,r.useRef)(null),e1=(0,r.useCallback)(()=>{let t=(t,s,a)=>eG[t]||s&&eG[s]||e.find(e=>e.sessionId===s)?.firstUserMessage||a.split("/").at(-1)||"Session",s=new Set(m.map(e=>e.claudeSessionId)),a=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"});return[{id:"home",group:"Actions",label:"Home",run:()=>ek({mode:"empty"})},{id:"new-session",group:"Actions",label:"New session",run:()=>e$(!0)},{id:"record",group:"Actions",label:"Record a meeting",run:()=>eA(!0)},{id:"recordings",group:"Actions",label:"Open recordings",run:()=>ek({mode:"meetinglib"})},{id:"notes",group:"Actions",label:"Open notes",run:()=>ek({mode:"notes",id:null})},{id:"settings",group:"Actions",label:"Open settings",run:()=>ek({mode:"settings"})},{id:"skills",group:"Actions",label:"Open skills",run:()=>ek({mode:"skills",name:null})},{id:"usage",group:"Actions",label:"Open usage",run:()=>ek({mode:"usagedash"})},{id:"prs",group:"Actions",label:"Open PR dashboard",run:()=>ek({mode:"prdash"})},{id:"slack",group:"Actions",label:"Open Slack inbox",run:()=>ek({mode:"slack"})},{id:"automations",group:"Actions",label:"Open automations",run:()=>ek({mode:"automations"})},...m.map(e=>({id:e.id,group:"Live sessions",label:t(e.id,e.claudeSessionId,e.cwd).slice(0,90),hint:e.status,run:()=>eZ(e.id)})),...e.filter(e=>!e.headless&&!s.has(e.sessionId)).map(e=>({id:e.sessionId,group:"History",label:(eG[e.sessionId]||e.firstUserMessage||e.cwd?.split("/").at(-1)||"Session").slice(0,90),hint:e.lastTimestamp?a(e.lastTimestamp):void 0,run:()=>eV(e.sessionId,e.cwd,e.orgId)})),...ei.map(e=>({id:e.id,group:"Meetings",label:e.title,hint:a(e.startedAt),run:()=>ek({mode:"meeting",meetingId:e.id})})),...Q.map(e=>({id:e.id,group:"Notes",label:e.text.split("\n").find(e=>e.trim())?.trim().slice(0,90)||"Untitled",hint:a(e.createdAt),run:()=>ek({mode:"notes",id:e.id})})),...(e0.current??[]).map(e=>({id:e.name,group:"Skills",label:e.name,hint:e.description.slice(0,60),run:()=>ek({mode:"skills",name:e.name})}))]},[m,e,ei,Q,eG]),e5="meeting"===ej.mode?ei.find(e=>e.id===ej.meetingId)??null:null;return(0,a.jsxs)("div",{className:"flex h-screen bg-[#0d1117] text-white overflow-hidden",children:[a.jsx("div",{style:{width:eP,flexShrink:0},className:"h-screen overflow-hidden",children:a.jsx(R,{liveSessions:m,orgs:Y,activeOrgId:eT,onSwitchOrg:function(e){eU(e);try{localStorage.setItem("claude-active-org",e)}catch{}},historySessions:e,historyLoading:t,activeSessionId:g,selectedHistoryId:null,sessionNameOverrides:eG,onAttachLive:eZ,onKillLive:v,onDeleteLive:function(e,t){v(e),t&&s(t)},onResumeLive:function(e){let t=m.find(t=>t.id===e);t?.claudeSessionId&&j(t.cwd,t.claudeSessionId)},onResumeAll:N,onCompact:w,onSetRemote:k,onNewSession:()=>e$(!0),onSelectHistory:eV,onDeleteSession:s,inbox:q,inboxLoading:z,inboxRefreshing:W,onRefreshInbox:G,onOpenPrDashboard:()=>ek({mode:"prdash"}),meetings:ei,selectedMeetingId:"meeting"===ej.mode?ej.meetingId:null,onSelectMeeting:e=>ek({mode:"meeting",meetingId:e}),onRecordMeeting:()=>eA(!0),onOpenMeetingLibrary:()=>ek({mode:"meetinglib"}),pipelines:M,onOrgsChanged:X,onRenameLive:(e,t)=>u?.send(JSON.stringify({type:"rename-live",id:e,name:t})),notes:Q,setNotes:et,onOpenNotes:e=>ek({mode:"notes",id:e}),onOpenSkills:e=>ek({mode:"skills",name:e}),onOpenSettings:()=>ek({mode:"settings"}),onOpenSlack:eX?()=>ek({mode:"slack"}):void 0,onOpenAutomations:()=>ek({mode:"automations"}),onHome:()=>ek({mode:"empty"}),selectedNoteId:"notes"===ej.mode?ej.id:null,selectedSkill:"skills"===ej.mode?ej.name:null,skillsVersion:es,onAutomate:eq,usage:ey,onOpenUsage:()=>ek({mode:"usagedash"})})}),a.jsx("div",{onMouseDown:eY,className:"w-1 flex-shrink-0 bg-gray-800 hover:bg-blue-500 cursor-col-resize transition-colors"}),(0,a.jsxs)("div",{className:"flex-1 relative overflow-hidden",children:[ed&&!("meeting"===ej.mode&&ej.meetingId===ed.id)&&(0,a.jsxs)("button",{onClick:()=>ek({mode:"meeting",meetingId:ed.id}),className:"absolute top-0 left-0 right-0 z-20 bg-red-900/90 hover:bg-red-800 text-red-100 text-xs py-1 flex items-center justify-center gap-2 transition-colors",children:[a.jsx("span",{className:"w-2 h-2 rounded-full bg-red-400 animate-pulse"}),"Recording — ",ed.title]}),a.jsx(eJ,{visible:"live"===ej.mode,ws:u}),"usagedash"===ej.mode&&ey&&a.jsx(e_,{usage:ey,limits:ef,orgs:Y,activeOrgId:eT,historySessions:e,liveSessions:m,onAttachLive:eZ,onSelectHistory:eV}),"prdash"===ej.mode&&q&&a.jsx(eM,{inbox:q,orgs:Y,activeOrgId:eT,refreshing:W,onRefresh:G,onAttachLive:eZ,onSelectHistory:eV,onReviewWithClaude:function(e){let t=`CR ${e.match(/([\w.-]+)\/pull\/(\d+)/)?.[0]??""}`.trim();eB.current=t,f("general","all"===eT?void 0:eT,t,void 0,void 0,`cr ${e}`)}}),"slack"===ej.mode&&a.jsx(em,{onSendAgent:function(e){let t=`Someone needs me on Slack. ${e.isDm?`Direct message from ${e.author}`:`${e.author} in #${e.channel}`}: ${e.permalink} . Read the message and its whole thread with the Slack connector, figure out what they need, and look into it (code, docs, data) as far as you can. Then show me a draft reply. Do not post anything to Slack until I approve it.`,s=`Slack: ${e.author}${e.isDm?"":` #${e.channel}`}`.slice(0,60);eB.current=s,f("general","all"===eT?void 0:eT,s,void 0,void 0,t)},sessions:m.filter(e=>e.claudeSessionId&&("all"===eT||(e.orgId??"default")===eT)).map(t=>({id:t.id,resumeId:t.claudeSessionId,cwd:t.cwd,label:(eG[t.id]||eG[t.claudeSessionId]||e.find(e=>e.sessionId===t.claudeSessionId)?.firstUserMessage||t.cwd.split("/").at(-1)||"Session").slice(0,70)})),onOpenSession:eZ,onAskSession:(e,t)=>x(e,`${t.isDm?`${t.author} sent me a Slack DM`:`${t.author} tagged me in Slack #${t.channel}`} about this work: ${t.permalink} . Read the message and its thread with the Slack connector, check it against what we did here, and draft a reply for me. Do not post anything to Slack until I approve it.`),orgName:"all"===eT?"Default":Y.find(e=>e.id===eT)?.name??"Default"},eT),"automations"===ej.mode&&a.jsx(eN,{pipelines:M.filter(e=>"all"===eT||(m.find(t=>t.id===e.liveId)?.orgId??"default")===eT),watchers:S.filter(e=>"all"===eT||(e.orgId??"default")===eT),showMacLoops:"all"===eT||"default"===eT,watcherCmd:D,onNewWatcher:()=>I(!0),onEditWatcher:e=>P(e),sessions:m.filter(e=>e.claudeSessionId&&("all"===eT||(e.orgId??"default")===eT)).map(t=>({id:t.id,label:(eG[t.id]||t.claudeSessionId&&eG[t.claudeSessionId]||e.find(e=>e.sessionId===t.claudeSessionId)?.firstUserMessage||t.cwd.split("/").at(-1)||"Session").slice(0,70)})),nameOf:t=>{let s=m.find(e=>e.id===t);return s&&(eG[s.id]||s.claudeSessionId&&eG[s.claudeSessionId]||e.find(e=>e.sessionId===s.claudeSessionId)?.firstUserMessage||s.cwd.split("/").at(-1))||"Session"},onOpen:e=>eq(e),onStop:F}),"pipeline"===ej.mode&&(()=>{let t=ej.liveId,s=m.find(e=>e.id===t),r=s&&(eG[s.id]||s.claudeSessionId&&eG[s.claudeSessionId]||e.find(e=>e.sessionId===s.claudeSessionId)?.firstUserMessage||s.cwd.split("/").at(-1))||"Session";return a.jsx(eD.C,{sessionName:r,pipeline:[...M].reverse().find(e=>e.liveId===t)??null,error:T?.liveId===t?T.message:null,onOpenSession:()=>eZ(t),onStart:e=>U(t,e),onStop:F,onAddPr:(e,s)=>_(e,t,s),onAct:(e,s)=>H(e,t,s),onDismiss:J,onSetAuto:O},t)})(),"settings"===ej.mode&&a.jsx(eC,{onClose:()=>ek({mode:"empty"})},eT),"skills"===ej.mode&&a.jsx(ea,{selected:ej.name,onSelect:e=>ek({mode:"skills",name:e}),onChanged:()=>er(e=>e+1)},eT),"notes"===ej.mode&&a.jsx(el,{notes:Q,setNotes:et,orgs:Y,activeOrgId:eT,selected:ej.id,onSelect:e=>ek({mode:"notes",id:e})}),"meetinglib"===ej.mode&&a.jsx(Z,{orgs:Y,activeOrgId:eT,refreshKey:ei.map(e=>e.id+e.status).join(),onOpen:e=>ek({mode:"meeting",meetingId:e}),onDeleted:eb}),"meeting"===ej.mode&&e5&&a.jsx(K,{meeting:e5,live:eo[e5.id],orgName:"default"!==e5.orgId?Y.find(e=>e.id===e5.orgId)?.name??null:null,onStop:eu,onResume:ex,onAsk:eg,onAddContext:ep,onBack:()=>ek({mode:"meetinglib"}),sessionOptions:e.filter(e=>!e.headless).sort((e,t)=>(t.lastTimestamp??"").localeCompare(e.lastTimestamp??"")).map(e=>{let t=m.find(t=>t.claudeSessionId===e.sessionId),s=t&&eG[t.id]||eG[e.sessionId]||e.firstUserMessage||e.cwd?.split("/").at(-1)||"Session",a=s.length>60?s.slice(0,60)+"…":s,r=e.lastTimestamp?new Date(e.lastTimestamp).toLocaleDateString(void 0,{month:"short",day:"numeric"}):"";return{id:e.sessionId,label:a,hint:r}}),meetingOptions:ei.filter(e=>"recording"!==e.status).map(e=>({id:e.id,label:e.title,hint:new Date(e.startedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}))}),"empty"===ej.mode&&(()=>{let t=e=>"all"===eT||(e??"default")===eT,s=ey?"all"===eT?Object.values(ey.orgs):[ey.orgs[eT]].filter(Boolean):[],r=new Date().setHours(0,0,0,0);return a.jsx(ev,{orgName:"all"===eT?"All orgs":Y.find(e=>e.id===eT)?.name??"Default",live:m.filter(e=>t(e.orgId)),nameOf:t=>{let s=m.find(e=>e.id===t);return s&&(eG[s.id]||s.claudeSessionId&&eG[s.claudeSessionId]||e.find(e=>e.sessionId===s.claudeSessionId)?.firstUserMessage||s.cwd.split("/").at(-1))||"Session"},meetings:ei.filter(e=>t(e.orgId)),notes:Q.filter(e=>t(e.orgId)),pipelines:M.filter(e=>t(m.find(t=>t.id===e.liveId)?.orgId)),watchers:S.filter(e=>t(e.orgId)),inbox:q,usageOrg:s.length?{today:s.reduce((e,t)=>e+(t.daily.find(e=>e.dayStart===r)?.costUSD??0),0),week:s.reduce((e,t)=>e+t.last7d.costUSD,0)}:null,onAttach:eZ,onOpen:e=>ek("object"==typeof e?{mode:"meeting",meetingId:e.meetingId}:"notes"===e?{mode:"notes",id:null}:{mode:e}),onNewSession:()=>e$(!0),onRecord:()=>eA(!0)})})(),h&&(0,a.jsxs)("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 bg-red-900/90 border border-red-700 text-red-200 text-sm px-4 py-2 rounded shadow-lg flex items-center gap-3 z-10",children:[a.jsx("span",{children:h}),a.jsx("button",{onClick:()=>b(null),className:"text-red-400 hover:text-white font-bold",children:"\xd7"})]}),i&&"default"===n&&!ez&&(0,a.jsxs)("div",{className:"absolute bottom-4 right-4 bg-gray-900/95 border border-gray-700 text-sm px-4 py-2 rounded-lg shadow-lg flex items-center gap-3 z-10",children:[a.jsx("span",{className:"text-gray-300",children:"Get notified when a session needs input"}),a.jsx("button",{onClick:o,className:"bg-blue-600 hover:bg-blue-500 text-white rounded px-2 py-1 text-xs font-medium",children:"Enable notifications"}),a.jsx("button",{onClick:()=>eW(!0),className:"text-gray-500 hover:text-white","aria-label":"Dismiss",children:"✕"})]})]}),a.jsx(en,{items:e1}),A&&a.jsx(ew,{initial:A,sessions:m.filter(e=>e.claudeSessionId&&(e.orgId??"default")===(A.orgId??"default")).map(t=>({id:t.id,label:(eG[t.id]||t.claudeSessionId&&eG[t.claudeSessionId]||e.find(e=>e.sessionId===t.claudeSessionId)?.firstUserMessage||t.cwd.split("/").at(-1)||"Session").slice(0,70)})),error:C,onCreate:({liveId:e,mode:t,intervalMin:s,knowledge:a,instructions:r})=>D("watcher-update",{id:A.id,patch:{liveId:e,mode:t,intervalMin:s,knowledge:a,instructions:r}}),onClose:()=>P(null)}),$&&a.jsx(ew,{sessions:m.filter(e=>e.claudeSessionId&&("all"===eT||(e.orgId??"default")===eT)).map(t=>({id:t.id,label:(eG[t.id]||t.claudeSessionId&&eG[t.claudeSessionId]||e.find(e=>e.sessionId===t.claudeSessionId)?.firstUserMessage||t.cwd.split("/").at(-1)||"Session").slice(0,70)})),error:C,onCreate:e=>D("watcher-create",{...e,orgId:"all"===eT?"default":eT}),onClose:()=>I(!1)}),eI&&a.jsx(E,{orgs:Y,defaultOrgId:"all"===eT?"default":eT,onStart:function(e,t){eA(!1),eR.current=!0,ec(e,t)},onCancel:()=>eA(!1),onMicTest:eh}),eS&&a.jsx(L,{knownCwds:Array.from(new Set([...e.map(e=>e.cwd).filter(Boolean),...eL])),orgs:Y,defaultOrgId:"all"===eT?"default":eT,onAddOrg:V,onConfirm:function(t,s,a,r,l,n){if(e$(!1),eB.current=s,"general"!==t&&!e.some(e=>e.cwd===t)){let e=Array.from(new Set([t,...eL])).slice(0,20);eE(e);try{localStorage.setItem("customPaths",JSON.stringify(e))}catch{}}f(t,a,s,r,l,n)},onResumeById:function(e,t,s,a,r){e$(!1),eB.current=t,j("general",e,s,t,a,r)},onCancel:()=>e$(!1)})]})}},5480:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>a});let a=(0,s(8570).createProxy)(String.raw`/private/tmp/claude-503/-Users-ofiryehoshua/0b425a50-f3c5-49e8-a60e-788bd3aae351/scratchpad/npm-build/src/app/page.tsx#default`)}};var t=require("../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),a=t.X(0,[948,471,621,904],()=>s(6993));module.exports=a})();
1
+ (()=>{var e={};e.id=931,e.ids=[931],e.modules={2934:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external.js")},4580:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external.js")},5869:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},5315:e=>{"use strict";e.exports=require("path")},7360:e=>{"use strict";e.exports=require("url")},6993:(e,t,s)=>{"use strict";s.r(t),s.d(t,{GlobalError:()=>n.a,__next_app__:()=>u,originalPathname:()=>x,pages:()=>c,routeModule:()=>m,tree:()=>d}),s(5480),s(2029),s(5866);var a=s(3191),r=s(8716),l=s(7922),n=s.n(l),i=s(5231),o={};for(let e in i)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(o[e]=()=>i[e]);s.d(t,o);let d=["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(s.bind(s,5480)),"/private/tmp/claude-503/-Users-ofiryehoshua/0b425a50-f3c5-49e8-a60e-788bd3aae351/scratchpad/npm-build/src/app/page.tsx"],metadata:{icon:[async e=>(await Promise.resolve().then(s.bind(s,3881))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(s.bind(s,2029)),"/private/tmp/claude-503/-Users-ofiryehoshua/0b425a50-f3c5-49e8-a60e-788bd3aae351/scratchpad/npm-build/src/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(s.t.bind(s,5866,23)),"next/dist/client/components/not-found-error"],metadata:{icon:[async e=>(await Promise.resolve().then(s.bind(s,3881))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}],c=["/private/tmp/claude-503/-Users-ofiryehoshua/0b425a50-f3c5-49e8-a60e-788bd3aae351/scratchpad/npm-build/src/app/page.tsx"],x="/page",u={require:s,loadChunk:()=>Promise.resolve()},m=new a.AppPageRouteModule({definition:{kind:r.x.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:d}})},1866:(e,t,s)=>{Promise.resolve().then(s.bind(s,1908))},3353:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return l}});let a=s(1174);s(326),s(7577);let r=a._(s(7028));function l(e,t){var s;let a={loading:e=>{let{error:t,isLoading:s,pastDelay:a}=e;return null}};"function"==typeof e&&(a.loader=e);let l={...a,...t};return(0,r.default)({...l,modules:null==(s=l.loadableGenerated)?void 0:s.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},933:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return r}});let a=s(4129);function r(e){let{reason:t,children:s}=e;throw new a.BailoutToCSRError(t)}},7028:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return d}});let a=s(326),r=s(7577),l=s(933),n=s(6618);function i(e){return{default:e&&"default"in e?e.default:e}}let o={loader:()=>Promise.resolve(i(()=>null)),loading:null,ssr:!0},d=function(e){let t={...o,...e},s=(0,r.lazy)(()=>t.loader().then(i)),d=t.loading;function c(e){let i=d?(0,a.jsx)(d,{isLoading:!0,pastDelay:!0,error:null}):null,o=t.ssr?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.PreloadCss,{moduleIds:t.modules}),(0,a.jsx)(s,{...e})]}):(0,a.jsx)(l.BailoutToCSR,{reason:"next/dynamic",children:(0,a.jsx)(s,{...e})});return(0,a.jsx)(r.Suspense,{fallback:i,children:o})}return c.displayName="LoadableComponent",c}},6618:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadCss",{enumerable:!0,get:function(){return l}});let a=s(326),r=s(4580);function l(e){let{moduleIds:t}=e,s=(0,r.getExpectedRequestStore)("next/dynamic css"),l=[];if(s.reactLoadableManifest&&t){let e=s.reactLoadableManifest;for(let s of t){if(!e[s])continue;let t=e[s].files.filter(e=>e.endsWith(".css"));l.push(...t)}}return 0===l.length?null:(0,a.jsx)(a.Fragment,{children:l.map(e=>(0,a.jsx)("link",{precedence:"dynamic",rel:"stylesheet",href:s.assetPrefix+"/_next/"+encodeURI(e),as:"style"},e))})}},1908:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>eK});var a=s(326),r=s(7577),l=s(3353),n=s.n(l);function i(e,t,s){if("all"===t)return!0;let a=(e.split("/")[0]??"").toLowerCase(),r=s.find(e=>e.id===t),l=(r?.githubOrgs??[]).map(e=>e.toLowerCase());return l.length>0?l.includes(a):!new Set(s.filter(e=>e.id!==t).flatMap(e=>e.githubOrgs??[]).map(e=>e.toLowerCase())).has(a)}let o=e=>({name:e?.name??"",configDir:e?.configDir??"",model:e?.model??"",githubOrgs:(e?.githubOrgs??[]).join(", ")});function d({orgs:e,onClose:t,onChanged:s}){let[l,n]=(0,r.useState)(null),[i,d]=(0,r.useState)(o()),[c,x]=(0,r.useState)(null),[u,m]=(0,r.useState)(null);function p(t){n(t),x(null),d(o("new"===t?void 0:e.find(e=>e.id===t)))}async function g(){x(null);let e="default"===l,t={name:i.name,...e?{}:{configDir:i.configDir.trim()},model:i.model,githubOrgs:i.githubOrgs.split(",").map(e=>e.trim()).filter(Boolean)},a="new"===l?await fetch("/api/orgs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}):await fetch(`/api/orgs/${l}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await a.json().catch(()=>({}));if(!a.ok){x(r.error??"Could not save");return}"new"===l&&t.githubOrgs.length&&await fetch(`/api/orgs/${r.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({githubOrgs:t.githubOrgs})}),n(null),s()}async function h(e){m(null);let t=await fetch(`/api/orgs/${e}`,{method:"DELETE"});if(!t.ok){x((await t.json().catch(()=>({}))).error??"Could not remove");return}l===e&&n(null),s()}let b="w-full bg-gray-800 border border-gray-700 focus:border-gray-500 rounded-md px-2.5 py-1.5 text-sm text-white outline-none placeholder-gray-500 mt-1",y=(0,a.jsxs)("div",{className:"space-y-3 bg-gray-950/60 border border-gray-800 rounded-lg p-3 mt-2",children:[(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Name",a.jsx("input",{value:i.name,onChange:e=>d({...i,name:e.target.value}),placeholder:"Acme",className:b})]}),"default"!==l&&(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Claude config folder",a.jsx("input",{value:i.configDir,onChange:e=>d({...i,configDir:e.target.value}),placeholder:"/Users/you/.claude-acme",className:`${b} font-mono`}),(0,a.jsxs)("span",{className:"text-[11px] text-gray-500",children:["Each folder is a separate Claude login. Run ",a.jsx("code",{children:"CLAUDE_CONFIG_DIR=<folder> claude"})," once to sign in."]})]}),(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Default model (optional)",a.jsx("input",{value:i.model,onChange:e=>d({...i,model:e.target.value}),placeholder:"claude-opus-5-5",className:`${b} font-mono`})]}),(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["GitHub orgs for the PR inbox (optional, comma-separated)",a.jsx("input",{value:i.githubOrgs,onChange:e=>d({...i,githubOrgs:e.target.value}),placeholder:"acme, acme-labs",className:b})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{onClick:()=>n(null),className:"px-3 py-1.5 text-xs text-gray-400 hover:text-white",children:"Cancel"}),a.jsx("button",{onClick:g,className:"px-3 py-1.5 text-xs rounded-md bg-blue-600 hover:bg-blue-500",children:"new"===l?"Add org":"Save"})]})]});return a.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:t,children:(0,a.jsxs)("div",{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto bg-gray-900 border border-gray-700 rounded-xl p-5 text-white",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h2",{className:"text-base font-semibold",children:"Orgs"}),a.jsx("button",{onClick:t,className:"text-gray-500 hover:text-white","aria-label":"Close",children:"✕"})]}),a.jsx("ul",{className:"space-y-2",children:e.map(e=>(0,a.jsxs)("li",{className:"rounded-lg border border-gray-800 px-3 py-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium",children:e.name}),(0,a.jsxs)("p",{className:"text-[11px] text-gray-500 font-mono truncate",children:[e.configDir??"~/.claude (Claude Code default)",e.model?` \xb7 ${e.model}`:"",e.githubOrgs?.length?` \xb7 GitHub: ${e.githubOrgs.join(", ")}`:""]})]}),a.jsx("button",{onClick:()=>p(e.id),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Edit"}),"default"!==e.id&&(u===e.id?(0,a.jsxs)(a.Fragment,{children:[a.jsx("button",{onClick:()=>h(e.id),className:"text-xs px-2 py-1 rounded-md bg-red-600 hover:bg-red-500",children:"Remove"}),a.jsx("button",{onClick:()=>m(null),className:"text-xs text-gray-400",children:"Cancel"})]}):a.jsx("button",{onClick:()=>m(e.id),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-red-400 hover:bg-red-950/40",children:"Remove"}))]}),l===e.id&&y]},e.id))}),"new"===l?y:a.jsx("button",{onClick:()=>p("new"),className:"mt-3 w-full text-sm py-2 rounded-lg border border-dashed border-gray-700 text-gray-300 hover:bg-gray-800",children:"+ Add org"}),c&&a.jsx("p",{className:"text-xs text-red-400 mt-3",children:c}),a.jsx("p",{className:"text-[11px] text-gray-500 mt-4",children:"Removing an org keeps its sessions and meetings; they still show under All. Changes apply to sessions started after you save."})]})})}let c=!0;var x=s(1954);let u={thinking:"border-l-yellow-400",waiting:"border-l-green-400",idle:"border-l-gray-600"},m={thinking:"bg-yellow-400 animate-pulse",waiting:"bg-green-400 animate-pulse",idle:"bg-gray-600"},p={thinking:"thinking…",waiting:"waiting for input",idle:"idle"},g={thinking:"text-yellow-400",waiting:"text-green-400",idle:"text-gray-500"};function h(e){return e?"MERGED"===e.state?{label:"Merged",className:"bg-purple-500/20 text-purple-400"}:"CLOSED"===e.state?{label:"Closed",className:"bg-gray-800 text-gray-500"}:"CHANGES_REQUESTED"===e.reviewDecision?{label:"Changes requested",className:"bg-red-500/20 text-red-400"}:"failing"===e.checks?{label:"Checks failing",className:"bg-red-500/20 text-red-400"}:"APPROVED"===e.reviewDecision?{label:"Approved",className:"bg-green-500/20 text-green-400"}:"pending"===e.checks?{label:"Checks running",className:"bg-yellow-500/20 text-yellow-400"}:{label:"Review pending",className:"bg-gray-800 text-gray-400"}:{label:"Unknown",className:"bg-gray-800 text-gray-500"}}function b(e){let t=e.match(/github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+)/);return t?`${t[1]}#${t[2]}`:e}function y(e){return e.status?.updatedAt??e.sessionDate}function f(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:`${Math.round(e/1e3)}k`}function j(e){return e>=100?`$${Math.round(e)}`:e>=1||e>0?`$${e.toFixed(2)}`:"$0"}function N(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}function v(e){if(!e)return"";let t=Date.now()-e;return t<6e4?"just now":t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:t<2592e6?`${Math.round(t/864e5)}d ago`:new Date(e).toLocaleDateString()}function w(e,t,s){let a=e.sessionId,r=a?s.find(e=>e.sessionId===a):void 0;return(e.liveId?t[e.liveId]:void 0)??(a?t[a]:void 0)??r?.firstUserMessage??e.cwd?.split("/").at(-1)??b(e.prUrl)}function k({entry:e,title:t,isPinned:s,isDismissed:r,onTogglePin:l,onToggleDismiss:n,onRename:i,onAttachLive:o,onSelectHistory:d}){let c=h(e.status),x=b(e.prUrl);return a.jsx("div",{className:`group/pr rounded-lg bg-gray-900 hover:bg-gray-800/70 transition-all cursor-pointer ${s?"ring-1 ring-yellow-600/50":""} ${r?"opacity-50":""}`,onClick:function(){"live"===e.source&&e.liveId?o(e.liveId):e.sessionId&&d(e.sessionId,e.cwd,e.orgId)},children:(0,a.jsxs)("div",{className:"px-3 py-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[a.jsx("button",{onClick:t=>{t.stopPropagation(),l(e.prUrl)},className:`flex-shrink-0 text-sm leading-none ${s?"text-yellow-400":"text-gray-700 hover:text-gray-400"}`,title:s?"Unpin":"Pin this PR",children:"\uD83D\uDCCC"}),a.jsx(I,{value:t,onSave:t=>i(e,t),className:"text-sm text-gray-100 font-medium truncate"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[a.jsx("span",{className:`text-xs rounded-full px-2 py-0.5 font-medium whitespace-nowrap ${c.className}`,children:c.label}),a.jsx("button",{onClick:t=>{t.stopPropagation(),n(e.prUrl)},className:"opacity-0 group-hover/pr:opacity-100 text-gray-600 hover:text-gray-300 text-xs",title:r?"Show again (undo dismiss)":"Dismiss — no longer relevant",children:r?"↺":"\xd7"})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("span",{className:"text-xs text-gray-600 truncate",children:[e.status?.title??x,v(y(e))&&` \xb7 ${v(y(e))}`]}),a.jsx("a",{href:e.prUrl,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"text-xs text-blue-500 hover:text-blue-300 flex-shrink-0",children:x})]})]})})}function S({pr:e,isDismissed:t,onToggleDismiss:s,onAttachLive:r,onSelectHistory:l}){let n=h(e.status),i=e.url.match(/\/pull\/(\d+)/)?.[1],o=`${e.repo.split("/").at(-1)}#${i??"?"}`,d=!!(e.liveId||e.sessionId);return a.jsx("div",{className:`group/inpr rounded-lg bg-gray-900 hover:bg-gray-800/70 transition-all cursor-pointer ${t?"opacity-50":""}`,onClick:function(){e.liveId?r(e.liveId):e.sessionId?l(e.sessionId,e.cwd):window.open(e.url,"_blank","noopener")},children:(0,a.jsxs)("div",{className:"px-3 py-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 mb-0.5",children:[a.jsx("span",{className:"text-sm text-gray-100 font-medium truncate flex-1",title:e.title,children:e.title}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.isDraft&&a.jsx("span",{className:"text-xs rounded-full px-2 py-0.5 bg-gray-800 text-gray-500",children:"Draft"}),a.jsx("span",{className:`text-xs rounded-full px-2 py-0.5 font-medium whitespace-nowrap ${n.className}`,children:n.label}),a.jsx("button",{onClick:t=>{t.stopPropagation(),s(e.url)},className:"opacity-0 group-hover/inpr:opacity-100 text-gray-600 hover:text-gray-300 text-xs",title:t?"Show again":"Dismiss",children:t?"↺":"\xd7"})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)("span",{className:"text-xs text-gray-600 truncate",children:[v(e.status?.updatedAt??e.updatedAt),d&&a.jsx("span",{className:"text-blue-500/80",children:" \xb7 has session"})]}),a.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"text-xs text-blue-500 hover:text-blue-300 flex-shrink-0",children:o})]})]})})}function C(e,t,s){let a=e.claudeSessionId?s.find(t=>t.sessionId===e.claudeSessionId):void 0;return t[e.id]??(e.claudeSessionId?t[e.claudeSessionId]:void 0)??a?.firstUserMessage??e.cwd.split("/").at(-1)??e.cwd}function D({s:e,isActive:t,sessionNames:s,historySessions:l,cost:n,contextTokens:i,compactAt:o,pipeline:d,onAutomate:c,onRenameLive:h,onAttachLive:b,onKillLive:y,onRemoveWorktree:N,onReview:v,onDeleteLive:w,onResume:k,onCompact:S,onSetRemote:D,onRename:$}){let[I,A]=(0,r.useState)(!1),[R,O]=(0,r.useState)(""),[P,M]=(0,r.useState)(!1),L=(0,r.useRef)(null),T=s[e.id]??(e.claudeSessionId?s[e.claudeSessionId]:void 0),E=C(e,s,l),U=new Date(e.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),F=/\/General\/[^/]+$/.test(e.cwd)?null:e.cwd.split("/").at(-1)??null;function _(t){t.stopPropagation(),O(T??e.cwd.split("/").at(-1)??e.cwd),A(!0),setTimeout(()=>L.current?.focus(),0)}function J(){A(!1);let t=R.trim();t&&($(e.id,t),e.claudeSessionId&&$(e.claudeSessionId,t),h(e.id,t))}return a.jsx("div",{className:`group/live rounded-lg border-l-2 cursor-pointer ${u[e.status]} transition-all ${t?"bg-gray-800 shadow-sm":"bg-gray-900 hover:bg-gray-800/70"}`,onClick:()=>b(e.id),children:(0,a.jsxs)("div",{className:"px-3 py-2.5 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${m[e.status]}`}),I?a.jsx("input",{ref:L,value:R,onChange:e=>O(e.target.value),onBlur:J,onKeyDown:e=>{"Enter"===e.key&&J(),"Escape"===e.key&&A(!1)},onClick:e=>e.stopPropagation(),className:"bg-gray-700 text-white rounded px-1 outline-none flex-1 text-sm min-w-0",autoFocus:!0}):a.jsx("span",{className:"text-sm text-gray-100 font-medium truncate flex-1",onDoubleClick:_,title:E,children:E}),!I&&a.jsx("button",{onClick:_,className:"opacity-0 group-hover/live:opacity-100 text-gray-600 hover:text-gray-300 text-xs flex-shrink-0",title:"Rename",children:"✎"}),a.jsx("button",{onClick:t=>{t.stopPropagation(),c(e.id)},className:`text-xs flex-shrink-0 ${(0,x.An)(d)?"text-blue-400":"opacity-0 group-hover/live:opacity-100 text-gray-500 hover:text-yellow-300"}`,title:"Automate: open a PR, post for review, handle feedback and CI",children:"⚡"}),e.rc&&e.rcUrl?a.jsx("a",{href:e.rcUrl,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),className:"text-xs flex-shrink-0",title:"Remote Control ON — open on your phone / claude.ai/code. Hover actions → Remote off.",children:"\uD83D\uDCF1"}):e.rc?a.jsx("span",{className:"text-xs flex-shrink-0 opacity-40 animate-pulse",title:"Remote Control pairing…",children:"\uD83D\uDCF1"}):a.jsx("button",{onClick:t=>{t.stopPropagation(),D(e.id,!0)},className:"opacity-0 group-hover/live:opacity-100 text-xs flex-shrink-0 grayscale hover:grayscale-0",title:"Enable Remote Control for this session (continue from your phone)",children:"\uD83D\uDCF1"})]}),d&&"stopped"!==d.phase&&0===d.prs.length&&(0,a.jsxs)("button",{onClick:t=>{t.stopPropagation(),c(e.id)},title:`Automation: ${(0,x.YY)(d)[0].label}. Click to open.`,className:"mt-1.5 ml-4 flex items-center gap-1.5 text-[10px] text-gray-400 hover:text-gray-200",children:[a.jsx("span",{className:"text-yellow-300",children:"⚡"}),a.jsx("span",{className:"flex items-center",children:(0,x.YY)(d).map((e,t)=>(0,a.jsxs)("span",{className:"flex items-center",children:[t>0&&a.jsx("span",{className:"w-2 h-px bg-gray-700"}),a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${e.current?d.suggestion?"bg-amber-400 animate-pulse":"bg-blue-400 animate-pulse":"bg-gray-700"}`})]},e.label))}),a.jsx("span",{className:"truncate",children:(0,x.YY)(d)[0].label})]}),d&&"stopped"!==d.phase&&d.prs.length>0&&a.jsx("div",{onClick:t=>{t.stopPropagation(),c(e.id)},className:"mt-1.5 ml-4 space-y-1 cursor-pointer",title:"Open automation",children:d.prs.slice(0,3).map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] text-gray-400",children:[a.jsx("span",{className:"tabular-nums w-14 truncate",children:(0,x.QV)(e.url).split("/").at(-1)}),a.jsx("span",{className:"flex items-center",children:(0,x.UA)(e,!!d.config.slackChannel).map((e,t)=>(0,a.jsxs)("span",{className:"flex items-center",title:e.label,children:[t>0&&a.jsx("span",{className:`w-2 h-px ${e.done||e.current?"bg-blue-500/70":"bg-gray-700"}`}),a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${e.done?"bg-emerald-400":e.current?"bg-blue-400 animate-pulse":"bg-gray-700"}`})]},e.label))}),a.jsx("span",{className:"flex -space-x-1 ml-1",children:[...(e.view?.reviews??[]).map(e=>({who:e.login,c:"APPROVED"===e.state?"bg-emerald-600":"CHANGES_REQUESTED"===e.state?"bg-red-600":"bg-gray-600"})),...(e.view?.requested??[]).map(e=>({who:e,c:"bg-gray-800 ring-gray-600"}))].slice(0,4).map(e=>a.jsx("span",{title:e.who,className:`w-3.5 h-3.5 rounded-full ring-1 ring-gray-900 text-[8px] leading-[14px] text-center text-white uppercase ${e.c}`,children:e.who[0]},e.who))}),e.view?.checks==="failing"&&a.jsx("span",{className:"text-red-400",title:"CI failing",children:"✗ CI"})]},e.url))}),d&&"stopped"!==d.phase&&(0,a.jsxs)("button",{onClick:t=>{t.stopPropagation(),c(e.id)},className:`mt-1.5 ml-4 text-[11px] px-1.5 py-0.5 rounded ${"done"===d.phase||d.prs.some(e=>"ready"===e.state)?"bg-emerald-500/15 text-emerald-300":"needs-you"===d.phase||d.prs.some(e=>"needs-you"===e.state)?"bg-amber-500/15 text-amber-300":"bg-blue-500/15 text-blue-300"}`,children:["⚡ ",(0,x.Vm)(d)]}),!!(e.gitRoot||e.prUrl||d?.prs.length)&&(0,a.jsxs)("button",{onClick:t=>{t.stopPropagation(),v(e.id)},className:"mt-1.5 ml-4 flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-300 hover:bg-emerald-500/20",title:"See what this session changed, comment on lines, then send feedback or approve",children:[a.jsx("span",{className:"font-mono",children:"\xb1"})," Review changes"]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mt-1.5 pl-4 text-[11px] min-w-0",children:[a.jsx("span",{className:`flex-shrink-0 font-medium ${g[e.status]}`,children:p[e.status]}),e.worktree?(0,a.jsxs)(a.Fragment,{children:[a.jsx("span",{className:"text-gray-700",children:"\xb7"}),(0,a.jsxs)("span",{className:"truncate text-emerald-400/80",title:`Own worktree of ${e.worktree.repo} on branch ${e.worktree.branch}`,children:["⑂ ",e.worktree.branch.replace(/^polyergon\//,"")]})]}):F&&(0,a.jsxs)(a.Fragment,{children:[a.jsx("span",{className:"text-gray-700",children:"\xb7"}),a.jsx("span",{className:"truncate text-gray-500",children:F})]}),U&&(0,a.jsxs)(a.Fragment,{children:[a.jsx("span",{className:"text-gray-700",children:"\xb7"}),a.jsx("span",{className:"flex-shrink-0 text-gray-600",children:U})]})]}),(void 0!==n&&n>0||!!i&&i>0)&&(()=>{let e=o??6e5,t=i?i>=e?2:i>=.8*e?1:0:0;return(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1.5 pl-4 text-[11px]",children:[void 0!==n&&n>0&&a.jsx("span",{className:"flex-shrink-0 px-1.5 py-px rounded bg-emerald-500/10 text-emerald-400 font-medium tabular-nums",title:"Estimated API-equivalent cost of this session",children:j(n)}),!!i&&i>0&&(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0",title:o?`Context on last turn: ${i.toLocaleString()} tokens. Auto-compact runs at ${f(o)} (Settings).`:`Context on last turn: ${i.toLocaleString()} tokens. Auto-compact is off. Quality drops past ~600k; compact it.`,children:[a.jsx("span",{className:"flex-1 h-1 rounded-full bg-gray-800 overflow-hidden max-w-[90px]",children:a.jsx("span",{className:`block h-full rounded-full ${2===t?"bg-red-400":1===t?"bg-amber-400":"bg-gray-500"}`,style:{width:`${Math.min(100,Math.max(4,i/e*100))}%`}})}),(0,a.jsxs)("span",{className:`flex-shrink-0 tabular-nums ${2===t?"text-red-300":1===t?"text-amber-300":"text-gray-500"}`,children:[f(i)," / ",f(e)]})]})]})})(),(0,a.jsxs)("div",{className:"flex items-center gap-3 pl-4 max-h-0 opacity-0 overflow-hidden group-hover/live:max-h-8 group-hover/live:opacity-100 group-hover/live:mt-2 transition-all duration-150",children:["waiting"===e.status&&!!i&&i>=(o?.8*o:4e5)&&a.jsx("button",{onClick:t=>{t.stopPropagation(),S(e.id)},className:"text-[11px] text-amber-400 hover:text-amber-200 font-medium",title:"Send /compact — summarizes the conversation to shrink context (cuts cache cost, restores quality)",children:"Compact"}),e.claudeSessionId&&a.jsx("button",{onClick:function(t){t.stopPropagation();let s=e.claudeSessionId;if(!s)return;let a=()=>{M(!0),setTimeout(()=>M(!1),1200)},r=()=>{try{let e=document.createElement("textarea");e.value=s,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e),a()}catch{}};navigator.clipboard?.writeText?navigator.clipboard.writeText(s).then(a).catch(r):r()},className:`text-[11px] ${P?"text-emerald-400":"text-gray-500 hover:text-gray-200"}`,title:"Copy this session's ID (for resuming it elsewhere)",children:P?"✓ Copied":"Copy ID"}),e.rc&&a.jsx("button",{onClick:t=>{t.stopPropagation(),D(e.id,!1)},className:"text-[11px] text-gray-500 hover:text-gray-200",title:"Turn Remote Control off for this session",children:"Remote off"}),"idle"===e.status&&e.claudeSessionId&&a.jsx("button",{onClick:t=>{t.stopPropagation(),k(e.id)},className:"text-[11px] text-blue-500 hover:text-blue-300",children:"Resume"}),a.jsx("button",{onClick:t=>{t.stopPropagation(),y(e.id)},className:"text-[11px] text-gray-500 hover:text-red-400 ml-auto",title:"Stops the live process. The conversation itself isn't deleted — it stays available in the History tab.",children:"Archive"}),e.worktree&&a.jsx("button",{onClick:t=>{t.stopPropagation(),window.confirm(`Remove the worktree for branch ${e.worktree.branch}? The session stops and its folder is deleted. The branch and any commits stay. Uncommitted changes block this.`)&&N(e.id)},className:"text-[11px] text-gray-500 hover:text-red-400",title:"Stop the session and delete its worktree folder. The branch and its commits are kept.",children:"Remove worktree"}),a.jsx("button",{onClick:t=>{t.stopPropagation(),window.confirm(`Delete "${E}"? It moves to a trash folder (not permanently gone), but stops the live process and disappears from both Live and History.`)&&w(e.id,e.claudeSessionId)},className:"text-[11px] text-gray-500 hover:text-red-500",title:"Stops the live process and moves the conversation to a trash folder — no longer shown in Live/History, but recoverable.",children:"Delete"})]})]})})}function $(e,t){let[s,a]=(0,r.useState)(t);return[s,function(t){a(t);try{localStorage.setItem(e,JSON.stringify(t))}catch{}}]}function I({value:e,onSave:t,className:s,forceEdit:l,onEditDone:n}){let[i,o]=(0,r.useState)(!1),[d,c]=(0,r.useState)(e),x=(0,r.useRef)(null);function u(){o(!1),n?.();let s=d.trim();s&&s!==e?t(s):c(e)}return i||l?a.jsx("input",{ref:x,value:d,onChange:e=>c(e.target.value),onBlur:u,onKeyDown:t=>{"Enter"===t.key&&u(),"Escape"===t.key&&(o(!1),c(e),n?.())},onClick:e=>e.stopPropagation(),className:`bg-gray-700 text-white rounded px-1 outline-none w-full ${s}`}):a.jsx("span",{className:s,onDoubleClick:e=>{e.stopPropagation(),o(!0)},children:e})}function A({open:e}){return a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",className:"flex-shrink-0",children:e?a.jsx("path",{d:"M1.5 3A1.5 1.5 0 000 4.5v8A1.5 1.5 0 001.5 14h13a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H7.621a1.5 1.5 0 01-1.06-.44L5.5 3H1.5z"}):a.jsx("path",{d:"M.54 3.87L.5 3a2 2 0 012-2h3.672a2 2 0 011.414.586l.828.828A2 2 0 009.828 3h3.982a2 2 0 011.992 2.181l-.637 7A2 2 0 0113.174 14H2.826a2 2 0 01-1.991-1.819l-.637-7a1.99 1.99 0 01.342-1.31z"})})}function R({liveSessions:e,orgs:t,activeOrgId:s,onSwitchOrg:l,historySessions:n,historyLoading:o,activeSessionId:c,selectedHistoryId:u,sessionNameOverrides:m,onAttachLive:p,onKillLive:g,onDeleteLive:h,onRemoveWorktree:y,onReview:f,onResumeLive:R,onResumeAll:O,onCompact:P,onSetRemote:M,onNewSession:L,onSelectHistory:T,onDeleteSession:E,inbox:U,inboxLoading:F,inboxRefreshing:_,onRefreshInbox:J,onOpenPrDashboard:B,meetings:H,selectedMeetingId:W,onSelectMeeting:z,onRecordMeeting:q,onOpenMeetingLibrary:G,pipelines:K,onOrgsChanged:Y,onRenameLive:V,notes:X,setNotes:Q,onOpenNotes:Z,onOpenSkills:ee,onOpenSlack:et,onOpenSettings:es,onOpenBoard:ea,onOpenAutomations:er,onHome:el,selectedNoteId:en,selectedSkill:ei,skillsVersion:eo,onAutomate:ed,usage:ec,onOpenUsage:ex}){let[eu,em]=(0,r.useState)({}),ep=eu[s]??"",eg=e=>em(t=>({...t,[s]:e})),{names:eh,setName:eb}=function(){let[e,t]=(0,r.useState)({});return(0,r.useRef)(e).current=e,{names:e,setName:(0,r.useCallback)((e,s)=>{t(t=>{let a={...t};return s.trim()?a[e]=s.trim():delete a[e],a}),fetch("/api/session-names",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({key:e,name:s})}).catch(()=>{})},[])}}();(0,r.useRef)(eh).current=eh;let[ey,ef]=$("claude-group-names",{}),[ej,eN]=$("claude-group-collapsed",{}),[ev,ew]=$("claude-session-group-overrides",{}),[ek,eS]=$("claude-live-order",[]),[eC,eD]=$("claude-live-sort","custom"),[e$,eI]=$("claude-live-last-active",{});(0,r.useRef)(e$).current=e$;let[eA,eR]=$("claude-pinned-prs",{}),[eO,eP]=$("claude-dismissed-prs",{}),[eM,eL]=(0,r.useState)(!1),[eT,eE]=(0,r.useState)(!0),[eU,eF]=(0,r.useState)(null),[e_,eJ]=(0,r.useState)(null),[eB,eH]=(0,r.useState)(null),[eW,ez]=(0,r.useState)("live"),[eq,eG]=(0,r.useState)(!1),[eK,eY]=(0,r.useState)(null);function eV(e,t){eb(e,t)}let eX=e=>"all"===s||(e??"default")===s,eQ=e.filter(e=>eX(e.orgId)),eZ=n.filter(e=>eX(e.orgId)&&!e.headless),e0=H.filter(e=>eX(e.orgId)).filter(e=>"recording"===e.status).length,e1=[...eQ].sort((e,t)=>{if("recent"===eC){let s=e$[e.id]??e.createdAt;return(e$[t.id]??t.createdAt)-s}if("name"===eC)return C(e,eh,n).localeCompare(C(t,eh,n),void 0,{sensitivity:"base"});let s=ek.indexOf(e.id),a=ek.indexOf(t.id);return -1===s&&-1===a?0:-1===s?1:-1===a?-1:s-a}).filter(e=>{if(!ep)return!0;let t=C(e,eh,n),s=e.cwd.split("/").at(-1)??e.cwd;return t.toLowerCase().includes(ep.toLowerCase())||s.toLowerCase().includes(ep.toLowerCase())});function e5(e){eR({...eA,[e]:!eA[e]})}function e2(e){eP({...eO,[e]:!eO[e]})}function e3(e,t){e.liveId&&eV(e.liveId,t),e.sessionId&&eV(e.sessionId,t)}(0,r.useRef)(X).current=X;let[e4,e8]=(0,r.useState)(null),e6=(e,t)=>!ep||e.toLowerCase().includes(ep.toLowerCase())||t.toLowerCase().includes(ep.toLowerCase()),e7=e=>i(e.repo,s,t),e9=e=>e.filter(e=>e7(e)&&(eM||!eO[e.url])&&e6(e.title,e.repo)),te=U?[{key:"needsReview",title:"Needs your review",accent:"text-red-400",items:e9(U.sections.needsReview)},{key:"returned",title:"Returned to you",accent:"text-orange-400",items:e9(U.sections.returned)},{key:"waiting",title:"Waiting on others",accent:"text-yellow-500",items:e9(U.sections.waiting)},{key:"mergedRecent",title:"Recently merged",accent:"text-purple-400",items:e9(U.sections.mergedRecent)}]:[],tt=(U?.fromSessions??[]).filter(e=>eX(e.orgId)&&(eM||!eO[e.prUrl])&&e6(w(e,eh,n),b(e.prUrl))),ts=U?Object.values(U.sections).flat().filter(e7):[],ta=U?[...ts.map(e=>e.url),...U.fromSessions.filter(e=>eX(e.orgId)).map(e=>e.prUrl)].filter(e=>eO[e]).length:0,tr=U?[...U.sections.needsReview,...U.sections.returned].filter(e=>e7(e)&&!eO[e.url]).length:0,tl=ts.filter(e=>!eO[e.url]).length,tn=eZ.filter(e=>{let t=eh[e.sessionId]??e.firstUserMessage??"",s=ev[e.sessionId]??e.gitRoot??e.cwd??e.projectEncoded,a=ey[s]??s.split("/").at(-1)??s;return t.toLowerCase().includes(ep.toLowerCase())||a.toLowerCase().includes(ep.toLowerCase())}),ti=new Map;for(let e of tn){let t=ev[e.sessionId]??e.gitRoot??e.cwd??e.projectEncoded;ti.has(t)||ti.set(t,[]),ti.get(t).push(e)}let to=Array.from(ti.values()).sort((e,t)=>{let s=e[0].lastTimestamp??"",a=t[0].lastTimestamp??"";return a>s?1:a<s?-1:0});return(0,a.jsxs)("aside",{className:"w-full flex-shrink-0 bg-gray-950 text-white flex flex-col h-screen",children:[(0,a.jsxs)("div",{className:"px-3 pt-4 pb-3 border-b border-gray-800/60",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("span",{onClick:el,title:"Home",className:"cursor-pointer text-sm font-bold text-white tracking-tight px-1 hover:text-blue-300",children:["Polyergon","dev"===process.env.NEXT_PUBLIC_POLYERGON_ENV&&a.jsx("span",{className:"ml-2 text-[10px] font-semibold bg-amber-500 text-black rounded px-1.5 py-0.5",children:"DEV"})]}),(0,a.jsxs)("button",{onClick:es,title:"Settings",className:"flex items-center gap-1.5 text-xs font-medium text-gray-200 bg-gray-800 hover:bg-gray-700 border border-gray-700 rounded-md px-2.5 py-1 transition-colors",children:[a.jsx("span",{className:"text-sm leading-none",children:"⚙"}),"Settings"]})]}),eq&&a.jsx(d,{orgs:t,onClose:()=>eG(!1),onChanged:Y}),(0,a.jsxs)("div",{className:"flex gap-1 mt-3 bg-gray-900 rounded-lg p-1",children:[a.jsx("button",{onClick:()=>l("all"),className:`flex-1 py-1 rounded-md text-xs font-medium transition-colors truncate ${"all"===s?"bg-gray-700 text-white":"text-gray-500 hover:text-gray-300"}`,children:"All"}),t.map(e=>a.jsx("button",{onClick:()=>l(e.id),title:e.name,className:`flex-1 py-1 rounded-md text-xs font-medium transition-colors truncate ${s===e.id?"bg-purple-800/80 text-purple-100":"text-gray-500 hover:text-gray-300"}`,children:e.name},e.id)),a.jsx("button",{onClick:()=>eG(!0),title:"Add or edit orgs",className:"px-2 py-1 rounded-md text-xs text-gray-500 hover:text-white hover:bg-gray-800 flex-shrink-0",children:"+"})]}),(0,a.jsxs)("div",{className:"flex gap-2 mt-3",children:[(0,a.jsxs)("button",{onClick:L,className:"flex-1 bg-blue-600 hover:bg-blue-500 text-white rounded-lg px-3 py-2 text-sm font-medium transition-colors flex items-center justify-center gap-2",children:[a.jsx("span",{className:"text-base leading-none",children:"+"})," New Session"]}),(0,a.jsxs)("button",{onClick:ea,title:"Task board: plan tasks and follow each one from session to merged PR",className:"bg-gray-800 hover:bg-gray-700 text-gray-200 rounded-lg px-3 py-2 text-sm font-medium transition-colors flex items-center justify-center gap-1.5",children:[a.jsx("span",{className:"text-gray-400",children:"▦"})," Board"]}),a.jsx("button",{onClick:q,title:"Record a meeting",className:"bg-gray-800 hover:bg-red-900/60 text-red-400 rounded-lg px-3 py-2 text-sm font-medium transition-colors flex items-center justify-center",children:a.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-red-500"})})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_1fr_1.2fr] border-b border-gray-800/60",children:[(0,a.jsxs)("button",{onClick:()=>ez("live"),className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"live"===eW?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:["Live",eQ.length>0&&a.jsx("span",{className:`rounded-full px-1.5 py-0.5 text-xs font-medium ${"live"===eW?"bg-blue-500/20 text-blue-400":"bg-gray-800 text-gray-500"}`,children:eQ.length})]}),(0,a.jsxs)("button",{onClick:()=>ez("history"),className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"history"===eW?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:["History",to.length>0&&a.jsx("span",{className:`rounded-full px-1.5 py-0.5 text-xs font-medium ${"history"===eW?"bg-blue-500/20 text-blue-400":"bg-gray-800 text-gray-500"}`,children:to.length})]}),(0,a.jsxs)("button",{onClick:()=>ez("prs"),className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"prs"===eW?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:["PRs",tl>0&&a.jsx("span",{className:`rounded-full px-1.5 py-0.5 text-xs font-medium ${tr>0?"bg-red-500/20 text-red-400":"prs"===eW?"bg-blue-500/20 text-blue-400":"bg-gray-800 text-gray-500"}`,children:tr>0?tr:tl})]}),a.jsx("button",{onClick:()=>{ez("notes"),Z(null)},className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"notes"===eW?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:"Notes"}),(0,a.jsxs)("button",{onClick:()=>{ez("meetings"),G()},className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"meetings"===eW?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:["Meetings",e0>0&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse"})]}),a.jsx("button",{onClick:()=>{ez("usage"),ex()},className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"usage"===eW?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:"Usage"}),a.jsx("button",{onClick:()=>{ez("skills"),ee(null)},className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"skills"===eW?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:"Skills"}),et&&a.jsx("button",{onClick:()=>{ez("slack"),et()},className:`py-2.5 text-xs font-semibold tracking-wide flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"slack"===eW?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:"Slack"}),(0,a.jsxs)("button",{onClick:()=>{ez("automations"),er()},className:`py-2.5 pr-1 text-xs font-semibold flex items-center justify-center gap-1.5 transition-colors border-b-2 ${"automations"===eW?"border-blue-500 text-blue-400":"border-transparent text-gray-500 hover:text-gray-300"}`,children:[a.jsx("span",{className:"whitespace-nowrap",children:"Automations"}),K.filter(x.An).length>0&&a.jsx("span",{title:`${K.filter(x.An).length} running`,className:`rounded-full px-1.5 py-0.5 text-xs font-medium ${"automations"===eW?"bg-blue-500/20 text-blue-400":"bg-gray-800 text-gray-500"}`,children:K.filter(x.An).length})]})]}),"notes"!==eW&&"meetings"!==eW&&"usage"!==eW&&"slack"!==eW&&"automations"!==eW&&"skills"!==eW&&a.jsx("div",{className:"px-3 py-2 border-b border-gray-800/40",children:(0,a.jsxs)("div",{className:"relative",children:[a.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-4.35-4.35M17 11A6 6 0 115 11a6 6 0 0112 0z"})}),a.jsx("input",{type:"text",placeholder:"live"===eW?"Search live sessions…":"prs"===eW?"Search PRs…":"Search sessions…",value:ep,onChange:e=>eg(e.target.value),className:"w-full bg-gray-900 text-white rounded-lg pl-8 pr-3 py-2 text-sm placeholder-gray-600 outline-none border border-gray-800 focus:border-gray-600 transition-colors"})]})}),"live"===eW&&(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[eQ.length>1&&(0,a.jsxs)("div",{className:"flex items-center justify-end gap-1 mb-2 text-[11px]",children:[a.jsx("span",{className:"text-gray-600 mr-0.5",children:"Sort:"}),a.jsx("button",{onClick:()=>eD("custom"),className:"custom"===eC?"text-blue-400 font-medium":"text-gray-500 hover:text-gray-300",title:"Your manual drag order",children:"Custom"}),a.jsx("span",{className:"text-gray-700",children:"\xb7"}),a.jsx("button",{onClick:()=>eD("recent"),className:"recent"===eC?"text-blue-400 font-medium":"text-gray-500 hover:text-gray-300",title:"Most recently opened first",children:"Last used"}),a.jsx("span",{className:"text-gray-700",children:"\xb7"}),a.jsx("button",{onClick:()=>eD("name"),className:"name"===eC?"text-blue-400 font-medium":"text-gray-500 hover:text-gray-300",title:"Alphabetical by name",children:"Name"})]}),eQ.filter(e=>"idle"===e.status&&e.claudeSessionId).length>1&&(0,a.jsxs)("button",{onClick:O,className:"w-full mb-2 bg-gray-800 hover:bg-gray-700 text-blue-400 rounded-lg px-3 py-1.5 text-xs font-medium",children:["⟳ Resume all (",eQ.filter(e=>"idle"===e.status&&e.claudeSessionId).length," idle)"]}),0===e1.length?a.jsx("p",{className:"text-xs text-gray-600 text-center mt-8",children:"No active sessions"}):a.jsx("div",{className:"flex flex-col gap-1.5",children:e1.map(e=>a.jsx("div",{draggable:!0,onDragStart:t=>{t.dataTransfer.setData("text/live-session-id",e.id),t.dataTransfer.effectAllowed="move"},onDragOver:t=>{t.preventDefault(),eH(e.id)},onDragLeave:()=>eH(t=>t===e.id?null:t),onDrop:t=>{t.preventDefault(),eH(null);let s=t.dataTransfer.getData("text/live-session-id");s&&function(e,t){if(e===t)return;let s=e1.map(e=>e.id).filter(t=>t!==e),a=s.indexOf(t);s.splice(a,0,e),eS(s)}(s,e.id)},className:`cursor-grab active:cursor-grabbing rounded-lg transition-colors ${eB===e.id?"ring-2 ring-blue-600":""}`,children:a.jsx(D,{s:e,isActive:c===e.id,sessionNames:eh,historySessions:n,cost:e.claudeSessionId?ec?.sessions[e.claudeSessionId]?.costUSD:void 0,contextTokens:e.claudeSessionId?ec?.sessions[e.claudeSessionId]?.contextTokens:void 0,onCompact:P,pipeline:[...K].reverse().find(t=>t.liveId===e.id)??null,onAutomate:ed,onSetRemote:M,onAttachLive:p,onKillLive:g,onRemoveWorktree:y,onReview:f,onDeleteLive:h,onResume:R,onRename:eV,onRenameLive:V,compactAt:eK})},e.id))})]}),"history"===eW&&a.jsx(a.Fragment,{children:(0,a.jsxs)("div",{className:"overflow-y-auto flex-1 px-2 pb-4",children:[o&&a.jsx("p",{className:"p-4 text-gray-600 text-xs",children:"Loading…"}),to.map(e=>{let t=e[0].gitRoot??e[0].cwd??e[0].projectEncoded,s=e[0].gitRoot??e[0].cwd??e[0].projectPath,r=ey[t]??s.split("/").at(-1)??s,l=ej[t],n=e_===t;return(0,a.jsxs)("div",{className:"mt-3",children:[(0,a.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer group transition-colors ${n?"bg-blue-900/30 border border-dashed border-blue-600":"hover:bg-gray-800/50"}`,onClick:()=>{eN({...ej,[t]:!ej[t]})},onDragOver:e=>{e.preventDefault(),eJ(t)},onDragLeave:()=>eJ(null),onDrop:e=>{e.preventDefault(),eJ(null);let s=e.dataTransfer.getData("text/session-id");s&&ew({...ev,[s]:t})},children:[a.jsx("span",{className:"text-gray-500 group-hover:text-gray-400 transition-colors",children:a.jsx(A,{open:!l})}),a.jsx(I,{value:r,onSave:e=>{ef({...ey,[t]:e})},className:"text-xs font-semibold text-gray-400 group-hover:text-gray-300 flex-1 truncate transition-colors"}),a.jsx("span",{className:"text-xs text-gray-700 bg-gray-800 rounded-full px-1.5 py-0.5 font-medium ml-auto flex-shrink-0",children:e.length})]}),!l&&a.jsx("div",{className:"ml-3 mt-0.5 border-l border-gray-800/60 pl-2",children:e.map(e=>{let t=eh[e.sessionId]??e.title??e.firstUserMessage??"Empty session",s=u===e.sessionId,r=eU===e.sessionId;return(0,a.jsxs)("div",{draggable:!0,onDragStart:t=>{t.dataTransfer.setData("text/session-id",e.sessionId),t.dataTransfer.effectAllowed="move"},className:`group/session flex items-stretch rounded-md transition-colors cursor-grab active:cursor-grabbing ${s?"bg-gray-800 border-l-2 border-l-blue-500 -ml-px":"hover:bg-gray-800/50"}`,children:[(0,a.jsxs)("button",{onClick:()=>T(e.sessionId,e.cwd,e.orgId),className:"flex-1 text-left px-2 py-2 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[a.jsx(I,{value:t,onSave:t=>eV(e.sessionId,t),forceEdit:r,onEditDone:()=>eF(null),className:"text-xs text-gray-300 flex-1 truncate leading-relaxed"}),!r&&a.jsx("button",{onClick:t=>{t.stopPropagation(),eF(e.sessionId)},className:"opacity-0 group-hover/session:opacity-100 text-gray-600 hover:text-gray-300 text-xs flex-shrink-0",title:"Rename",children:"✎"})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-600 mt-0.5",children:[e.messageCount," msgs \xb7 ",e.lastTimestamp?new Date(e.lastTimestamp).toLocaleDateString():"—",(ec?.sessions[e.sessionId]?.costUSD??0)>0&&(0,a.jsxs)("span",{className:"text-emerald-700",children:[" \xb7 ",j(ec.sessions[e.sessionId].costUSD)]})]})]}),a.jsx("button",{onClick:s=>{s.stopPropagation(),window.confirm(`Delete "${t}"? It moves to a trash folder (not permanently gone), but disappears from here.`)&&E(e.sessionId)},className:"opacity-0 group-hover/session:opacity-100 px-2 text-gray-600 hover:text-red-400 transition-all flex-shrink-0 text-sm",title:"Delete session",children:"\xd7"})]},e.sessionId)})})]},t)})]})}),"prs"===eW&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"px-3 py-2 border-b border-gray-800/40 flex items-center justify-between gap-2",children:[a.jsx("span",{className:"text-xs text-gray-600",children:U?`${tl} open \xb7 updated ${v(U.fetchedAt)}`:"Loading your GitHub PRs…"}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[a.jsx("button",{onClick:B,className:"bg-gray-800 hover:bg-gray-700 text-gray-200 rounded px-2.5 py-1 text-xs font-medium",title:"Open PR dashboard",children:"\uD83D\uDCCA Stats"}),(0,a.jsxs)("button",{onClick:J,disabled:_,className:"bg-gray-800 hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-200 rounded px-2.5 py-1 text-xs font-medium flex items-center gap-1.5",children:[_&&a.jsx("span",{className:"inline-block w-3 h-3 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}),_?"Refreshing…":"Refresh"]})]})]}),U?.error&&a.jsx("div",{className:"px-3 py-1.5 border-b border-yellow-800/40 bg-yellow-900/20 text-yellow-500 text-xs",children:U.error}),ta>0&&a.jsx("div",{className:"px-3 py-1.5 border-b border-gray-800/40",children:a.jsx("button",{onClick:()=>eL(e=>!e),className:"text-xs text-gray-600 hover:text-gray-400",children:eM?`Hide dismissed (${ta})`:`Show ${ta} dismissed`})}),a.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:F&&!U?a.jsx("p",{className:"text-xs text-gray-600 text-center mt-8",children:"Loading…"}):(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[te.map(e=>{let t="mergedRecent"===e.key,s=t&&eT;return(0,a.jsxs)("div",{children:[(0,a.jsxs)("button",{onClick:t?()=>eE(e=>!e):void 0,className:`w-full flex items-center gap-2 mb-1.5 ${t?"cursor-pointer":"cursor-default"}`,children:[a.jsx("span",{className:`text-xs font-semibold uppercase tracking-wide ${e.accent}`,children:e.title}),a.jsx("span",{className:"text-xs text-gray-700 bg-gray-800 rounded-full px-1.5 py-0.5 font-medium",children:e.items.length}),t&&a.jsx("span",{className:"text-xs text-gray-600 ml-auto",children:s?"▸":"▾"})]}),!s&&(0===e.items.length?a.jsx("p",{className:"text-xs text-gray-700 pl-1",children:"Nothing here \uD83C\uDF89"}):a.jsx("div",{className:"flex flex-col gap-1.5",children:e.items.map(e=>a.jsx(S,{pr:e,isDismissed:!!eO[e.url],onToggleDismiss:e2,onAttachLive:p,onSelectHistory:T},e.url))}))]},e.key)}),tt.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500",children:"From sessions"}),a.jsx("span",{className:"text-xs text-gray-700 bg-gray-800 rounded-full px-1.5 py-0.5 font-medium",children:tt.length})]}),a.jsx("div",{className:"flex flex-col gap-1.5",children:tt.map(e=>a.jsx(k,{entry:e,title:w(e,eh,n),isPinned:!!eA[e.prUrl],isDismissed:!!eO[e.prUrl],onTogglePin:e5,onToggleDismiss:e2,onRename:e3,onAttachLive:p,onSelectHistory:T},e.prUrl+(e.liveId??e.sessionId??"")))})]})]})})]}),"usage"===eW&&a.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:ec?(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[t.filter(e=>"all"===s||e.id===s).map(e=>{let t=ec.orgs[e.id];return t?(0,a.jsxs)("div",{className:"rounded-lg bg-gray-900 px-3 py-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm text-gray-100 font-medium",children:e.name}),(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:[t.sessions," sessions"]})]}),a.jsx("div",{className:"grid grid-cols-3 gap-2 mb-2",children:[["5h",t.last5h],["24h",t.last24h],["7d",t.last7d]].map(([e,t])=>(0,a.jsxs)("div",{className:"rounded bg-gray-800/60 px-2 py-1.5 text-center",children:[a.jsx("p",{className:"text-[10px] text-gray-500 uppercase",children:e}),a.jsx("p",{className:"text-sm text-white font-semibold",children:j(t.costUSD)}),(0,a.jsxs)("p",{className:"text-[10px] text-gray-600",children:[N(t.outputTokens)," out"]})]},e))}),(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs text-gray-500",children:[(0,a.jsxs)("span",{children:["All-time value: ",a.jsx("span",{className:"text-gray-300 font-medium",children:j(t.totalCostUSD)})]}),(0,a.jsxs)("span",{children:[N(t.totalTokens.input+t.totalTokens.output)," in+out \xb7 ",N(t.totalTokens.cacheRead)," cached"]})]})]},e.id):(0,a.jsxs)("div",{className:"rounded-lg bg-gray-900 px-3 py-2.5",children:[a.jsx("p",{className:"text-sm text-gray-100 font-medium",children:e.name}),a.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"No usage recorded"})]},e.id)}),(0,a.jsxs)("p",{className:"text-[10px] text-gray-700 leading-relaxed px-1",children:["Costs are estimated API-equivalent value computed from transcripts (you pay via subscription). The 5h and 7d windows mirror your plan's rate-limit windows — for official remaining quota run",a.jsx("code",{className:"text-gray-500",children:" /usage"})," inside any Claude session."]})]}):a.jsx("p",{className:"text-xs text-gray-600 text-center mt-8",children:"Scanning transcripts…"})}),e4&&(0,a.jsxs)("div",{className:"fixed bottom-4 left-4 z-50 w-80 rounded-lg border border-amber-700/60 bg-gray-900 shadow-xl p-3",children:[a.jsx("p",{className:"text-[11px] uppercase tracking-wide text-amber-400 mb-1",children:"⏰ Reminder"}),a.jsx("p",{className:"text-sm text-gray-100 whitespace-pre-wrap break-words max-h-32 overflow-y-auto",children:e4.text}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-3 mt-2 text-xs",children:[a.jsx("button",{onClick:()=>{(function(e,t){let s=t?new Date(t).getTime():void 0;Q(t=>t.map(t=>t.id===e?{...t,remindAt:s,reminderDone:!1}:t))})(e4.id,function(e){let t=new Date(e);return new Date(t.getTime()-6e4*t.getTimezoneOffset()).toISOString().slice(0,16)}(Date.now()+6e5)),e8(null)},className:"text-gray-400 hover:text-white",children:"Snooze 10m"}),a.jsx("button",{onClick:()=>e8(null),className:"px-3 py-1 rounded bg-amber-600 hover:bg-amber-500 text-white font-medium",children:"Dismiss"})]})]})]})}var O=s(444);let P=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,M=({text:e})=>a.jsx("span",{title:e,"aria-label":e,className:"ml-1 inline-flex items-center justify-center w-3.5 h-3.5 rounded-full border border-gray-600 text-[9px] text-gray-400 cursor-help align-middle",children:"?"});function L({knownCwds:e,orgs:t,defaultOrgId:s,onAddOrg:l,onConfirm:n,onResumeById:i,onCancel:o}){let[d,c]=(0,r.useState)(""),[x,u]=(0,r.useState)(!1),[m,p]=(0,r.useState)(""),[g,h]=(0,r.useState)(!1),[b,y]=(0,r.useState)(""),[f,j]=(0,r.useState)(s??"default"),[N,v]=(0,r.useState)(""),[w,k]=(0,r.useState)([{id:"claude",label:"Claude"}]),[S,C]=(0,r.useState)("claude"),[D,$]=(0,r.useState)([]),[I,A]=(0,r.useState)(""),[R,L]=(0,r.useState)(!1),[T,E]=(0,r.useState)(null),[U,F]=(0,r.useState)({}),[_,J]=(0,r.useState)(!1),[B,H]=(0,r.useState)(!1),[W,z]=(0,r.useState)(""),[q,G]=(0,r.useState)(""),[K,Y]=(0,r.useState)(""),[V,X]=(0,r.useState)(null),Q=(0,r.useMemo)(()=>{let t=e=>/\/General(\/[^/]+)?$/.test(e)||/\/\.(claude-session-manager|polyergon[^/]*)(\/|$)/.test(e)||/^\/private\/(tmp|var\/folders)\//.test(e)||"/tmp"===e;return Array.from(new Set(e.filter(Boolean))).filter(e=>!t(e)).sort((e,t)=>{let s=e.split("/").at(-1)??e,a=t.split("/").at(-1)??t;return s.localeCompare(a)})},[e]),Z=U.backend===S&&U.model===I&&!!I,[ee,et]=(0,r.useState)(!1),[es,ea]=(0,r.useState)(""),[er,el]=(0,r.useState)(null),[en,ei]=(0,r.useState)(""),[eo,ed]=(0,r.useState)(""),ec=/^https:\/\/[\w.-]+\.slack\.com\/archives\//.test(en.trim()),ex=(er?.name??es).replace(/^#/,"").trim(),[eu,em]=(0,r.useState)(!1);function ep(e){localStorage.setItem("lastCwd",e),n(e,b.trim(),f,S,I,void 0,"general"!==e&&eu)}async function eg(){X(null);try{let e=await l(W.trim(),q.trim(),K.trim()||void 0);j(e.id),H(!1),z(""),G(""),Y("")}catch(e){X(e instanceof Error?e.message:"Failed to add org")}}return a.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:o,children:(0,a.jsxs)("div",{className:"bg-gray-900 border border-gray-700 rounded-lg p-6 w-[480px] max-h-[92vh] overflow-y-auto shadow-xl",onClick:e=>e.stopPropagation(),children:[a.jsx("h2",{className:"text-white font-semibold mb-1",children:"New Session"}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 mb-4",children:["Pick how to start. ",a.jsx("b",{className:"text-gray-400",children:"Just chat"})," works for most things; pick a folder only when Claude should work on that code."]}),a.jsx("input",{type:"text",value:b,onChange:e=>y(e.target.value),placeholder:"Session name (optional)",title:"Shown on the session card, in History and in Remote Control. Leave empty and Claude names it from your first message.",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 placeholder-gray-600 mb-4",autoFocus:!0}),(0,a.jsxs)("div",{className:"mb-3",children:[(0,a.jsxs)("label",{className:"text-xs text-gray-500 mb-1 block",children:["Org",a.jsx(M,{text:"Which Claude account runs this session. Each org has its own login, billing, skills, Slack and integrations."})]}),a.jsx("select",{value:f,onChange:e=>j(e.target.value),className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500",children:t.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))}),B?(0,a.jsxs)("div",{className:"mt-2 space-y-2 border border-dashed border-gray-700 rounded p-3",children:[a.jsx("input",{type:"text",value:W,onChange:e=>z(e.target.value),placeholder:"Org name (e.g. Claude Teams)",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 placeholder-gray-600"}),a.jsx("input",{type:"text",value:q,onChange:e=>G(e.target.value),placeholder:"/Users/you/.claude-teams",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none font-mono border border-gray-700 focus:border-blue-500 placeholder-gray-600"}),a.jsx("input",{type:"text",value:K,onChange:e=>Y(e.target.value),placeholder:"Default model (optional, e.g. claude-opus-4-8)",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none font-mono border border-gray-700 focus:border-blue-500 placeholder-gray-600"}),a.jsx("p",{className:"text-xs text-gray-500",children:"A folder where this org's Claude settings and login live (it's created if missing). After adding, sign in from Settings → Claude sign-in."}),V&&a.jsx("p",{className:"text-xs text-red-400",children:V}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:()=>{H(!1),X(null)},className:"text-xs text-gray-500 hover:text-gray-300",children:"← Back"}),a.jsx("button",{onClick:eg,disabled:!W.trim()||!q.trim().startsWith("/"),className:"px-3 py-1 text-xs bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded font-medium",children:"Add org"})]})]}):a.jsx("button",{onClick:()=>H(!0),className:"w-full text-left px-3 py-2 mt-2 text-sm text-gray-500 hover:text-gray-300 border border-dashed border-gray-700 rounded hover:border-gray-500 transition-colors",children:a.jsx("span",{title:"Add another Claude account (e.g. a second company) with its own config folder.",children:"+ Register new org…"})})]}),(0,a.jsxs)("div",{className:"mb-3 grid grid-cols-2 gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs text-gray-500 mb-1 block",children:["Agent",a.jsx(M,{text:"The CLI that runs the session: Claude Code, or GitHub Copilot CLI when installed."})]}),a.jsx("select",{value:S,onChange:e=>C(e.target.value),disabled:w.length<2,className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 disabled:opacity-60",children:w.map(e=>a.jsx("option",{value:e.id,children:e.label},e.id))})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs text-gray-500 mb-1 block",children:["Model",a.jsx(M,{text:"The model the session starts with. You can switch later inside the session with /model."})]}),(0,a.jsxs)("select",{value:I,onChange:e=>A(e.target.value),disabled:R||0===D.length,className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 disabled:opacity-60",children:[R&&a.jsx("option",{children:"Loading…"}),!R&&0===D.length&&a.jsx("option",{value:"",children:T??"No models"}),D.map(e=>a.jsx("option",{value:e.id,children:e.displayName},e.id))]})]})]}),a.jsx("div",{className:"flex items-center gap-2 mb-3 -mt-1",children:a.jsx("button",{onClick:function(){if(!I)return;let e={backend:S,model:I};try{localStorage.setItem("claude-session-default",JSON.stringify(e))}catch{}F(e),J(!0),setTimeout(()=>J(!1),1500)},title:"Pre-select this agent and model every time you open New Session",disabled:!I||Z,className:"text-xs text-gray-500 hover:text-blue-400 disabled:hover:text-gray-500 disabled:opacity-50 transition-colors",children:_?"✓ Saved as default":Z?"✓ This is your default":"☆ Set as default agent & model"})}),T&&D.length>0&&(0,a.jsxs)("p",{className:"text-xs text-amber-500/80 -mt-2 mb-3",children:["Showing cached models — ",T]}),!x&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{onClick:()=>ep("general"),title:"Starts in a private scratch folder. Good for questions, research, Slack, docs and one-off tasks.",className:"w-full text-left px-3 py-2.5 mb-3 flex items-center gap-3 rounded border border-gray-700 hover:bg-gray-800 hover:border-gray-600 transition-colors",children:[a.jsx("span",{className:"text-lg leading-none",children:"\uD83D\uDCAC"}),(0,a.jsxs)("span",{className:"flex flex-col",children:[a.jsx("span",{className:"text-sm text-white font-medium",children:"Just chat"}),a.jsx("span",{className:"text-xs text-gray-500",children:"Ask a question or run a quick task — not tied to a project"})]})]}),ee?(0,a.jsxs)("div",{className:"mb-3 rounded border border-purple-800/60 bg-purple-950/20 p-3 space-y-2",children:[a.jsx("p",{className:"text-xs text-gray-300 font-medium",children:"Start from Slack"}),a.jsx(O.a,{value:es,onChange:(e,t)=>{ea(e),el(t),ei("")},className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 placeholder-gray-600"}),a.jsx("input",{value:en,onChange:e=>{ei(e.target.value),e.target.value&&(ea(""),el(null))},placeholder:"…or paste a link to a message, thread or DM",title:"In Slack: hover a message → ⋮ → Copy link",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 placeholder-gray-600"}),en&&!ec&&a.jsx("p",{className:"text-[11px] text-red-400",children:"Paste a Slack link (https://…slack.com/archives/…)"}),a.jsx("input",{value:eo,onChange:e=>ed(e.target.value),placeholder:"What should Claude do with it? (optional)",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-blue-500 placeholder-gray-600"}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:()=>et(!1),className:"text-xs text-gray-500 hover:text-gray-300",children:"← Back"}),a.jsx("button",{onClick:function(){let e=ec?`the Slack message, thread or DM at ${en.trim()} (read the whole thread)`:`the Slack channel ${er?.id?`${er.id} (#${ex})`:`#${ex}`} (the last 2 days, including thread replies)`,t=`Use the Slack connector to read ${e}. Give me a short summary: what it is about, the open questions, and what is asked of me. `+(eo.trim()?`Then: ${eo.trim()}`:"Then wait for my instructions.")+" Do not post anything to Slack unless I approve it.";n(N&&"general"!==N?N:"general",b.trim()||(ec?"From Slack thread":`Slack #${ex}`),f,S,I,t)},disabled:!I||!(ec||ex),className:"ml-auto px-3 py-1 text-xs bg-purple-600 hover:bg-purple-500 disabled:opacity-50 text-white rounded font-medium",children:"Start with this context"})]}),a.jsx("p",{className:"text-[11px] text-gray-500",children:"The session reads it first and summarizes. Nothing is posted to Slack."})]}):(0,a.jsxs)("button",{onClick:()=>et(!0),title:"The new session reads a Slack channel, thread or DM first, so it starts with the context",className:"w-full text-left px-3 py-2.5 mb-3 flex items-center gap-3 rounded border border-gray-700 hover:bg-gray-800 hover:border-gray-600 transition-colors",children:[a.jsx("span",{className:"text-lg leading-none",children:"#"}),(0,a.jsxs)("span",{className:"flex flex-col",children:[a.jsx("span",{className:"text-sm text-white font-medium",children:"Start from Slack"}),a.jsx("span",{className:"text-xs text-gray-500",children:"A channel, thread or DM becomes the session's context"})]})]}),Q.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("label",{className:"flex items-start gap-2 mb-2 text-xs text-gray-300 cursor-pointer",title:"Creates a new branch and a separate copy of the repo for this session (git worktree). Other sessions in the same repo won't touch its files. Remove it from the session card when you're done.",children:[a.jsx("input",{type:"checkbox",checked:eu,onChange:e=>em(e.target.checked),className:"mt-0.5"}),(0,a.jsxs)("span",{children:["Isolated copy ",a.jsx("span",{className:"text-gray-500",children:"\xb7 new branch + worktree, so parallel sessions in the same repo don't collide (git repos only)"})]})]}),(0,a.jsxs)("p",{className:"text-[11px] uppercase tracking-wide text-gray-600 mb-1",children:["Or work in a folder",a.jsx(M,{text:"Claude starts inside this folder: it reads and edits its files, runs commands there, and loads the folder's CLAUDE.md. Listed: folders you used before."})]}),a.jsx("div",{className:"max-h-56 overflow-y-auto rounded border border-gray-700 mb-3",children:Q.map(e=>{let t=e.split("/").at(-1)||e;return(0,a.jsxs)("button",{onClick:()=>ep(e),title:`Start Claude inside ${e}`,className:"w-full text-left px-3 py-2.5 flex flex-col border-b border-gray-800 last:border-0 hover:bg-gray-800 transition-colors",children:[a.jsx("span",{className:"text-sm text-gray-200 font-medium",children:t}),a.jsx("span",{className:"text-xs text-gray-500 truncate",children:e})]},e)})})]})]}),x?(0,a.jsxs)("div",{className:"mb-3",children:[a.jsx("input",{type:"text",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&d.trim()&&ep(d.trim()),"Escape"===e.key&&(u(!1),c(""))},placeholder:"/Users/you/your-project",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none font-mono border border-gray-700 focus:border-blue-500",autoFocus:!0}),(0,a.jsxs)("div",{className:"flex items-center gap-3 mt-2",children:[a.jsx("button",{onClick:()=>{u(!1),c("")},className:"text-xs text-gray-500 hover:text-gray-300",children:"← Back"}),a.jsx("button",{onClick:()=>d.trim()&&ep(d.trim()),disabled:!d.trim(),className:"px-3 py-1 text-xs bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded font-medium",children:"Start"})]})]}):a.jsx("button",{onClick:()=>u(!0),title:"Type the full path of any folder on this Mac, e.g. a repo you haven't used here yet",className:"w-full text-left px-3 py-2 text-sm text-gray-500 hover:text-gray-300 border border-dashed border-gray-700 rounded hover:border-gray-500 transition-colors mb-3",children:"+ Open a different folder…"}),a.jsx("div",{className:"border-t border-gray-700/50 pt-3",children:g?(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs text-gray-500 mb-1 block",children:"Session ID"}),a.jsx("input",{type:"text",value:m,onChange:e=>p(e.target.value.trim()),onKeyDown:e=>{"Enter"===e.key&&P.test(m)&&i(m,b.trim(),f,S,I),"Escape"===e.key&&(h(!1),p(""))},placeholder:"6a047330-816f-45a1-86fc-9fba8280f12c",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none font-mono border border-gray-700 focus:border-blue-500",autoFocus:!0}),m&&!P.test(m)&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:"Paste a valid session UUID"}),(0,a.jsxs)("div",{className:"flex items-center gap-3 mt-2",children:[a.jsx("button",{onClick:()=>{h(!1),p("")},className:"text-xs text-gray-500 hover:text-gray-300",children:"← Back"}),a.jsx("button",{onClick:()=>i(m,b.trim(),f,S,I),disabled:!P.test(m),className:"px-3 py-1 text-xs bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded font-medium",children:"Resume"})]})]}):a.jsx("button",{onClick:()=>h(!0),title:"Continue an existing Claude conversation (from the terminal or another app) by pasting its session ID",className:"w-full text-left px-3 py-2 text-sm text-gray-500 hover:text-gray-300 border border-dashed border-gray-700 rounded hover:border-gray-500 transition-colors",children:"↩ Resume by session ID…"})}),(0,a.jsxs)("div",{className:"flex justify-end items-center gap-2 mt-4",children:[a.jsx("button",{onClick:o,className:"px-4 py-2 text-sm text-gray-400 hover:text-white",children:"Cancel"}),(0,a.jsxs)("button",{onClick:()=>ep(N||"general"),disabled:!I,className:"px-4 py-2 text-sm bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded font-medium",children:["Start ",N&&"general"!==N?`\xb7 ${N.split("/").at(-1)}`:"chat"]})]})]})})}function T({orgs:e,defaultOrgId:t,onStart:s,onCancel:l,onMicTest:n}){let[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(t),[x,u]=(0,r.useState)(!1),[m,p]=(0,r.useState)(null);async function g(){u(!0),p(null),p(await n()),u(!1)}let h=m?.level!==void 0?Math.min(10,Math.round(100*m.level)):0;return a.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:l,children:(0,a.jsxs)("div",{className:"bg-gray-900 border border-gray-700 rounded-lg p-6 w-[440px] shadow-xl",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("h2",{className:"text-white font-semibold mb-1 flex items-center gap-2",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-red-500"})," Record Meeting"]}),a.jsx("p",{className:"text-xs text-gray-500 mb-4",children:'Captures meeting audio (via BlackHole) + your mic. Set your Mac\'s sound output to "Claude Playback" first so you hear the meeting while it records.'}),a.jsx("input",{type:"text",value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key&&s(i.trim(),d)},placeholder:"Meeting title (optional)",className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-red-500 placeholder-gray-600 mb-3",autoFocus:!0}),a.jsx("label",{className:"text-xs text-gray-500 mb-1 block",children:"Org"}),a.jsx("select",{value:d,onChange:e=>c(e.target.value),className:"w-full bg-gray-800 text-white rounded px-3 py-2 text-sm outline-none border border-gray-700 focus:border-red-500 mb-4",children:e.map(e=>a.jsx("option",{value:e.id,children:e.name},e.id))}),(0,a.jsxs)("div",{className:"border border-gray-800 rounded-lg p-3 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("button",{onClick:g,disabled:x,className:"bg-gray-800 hover:bg-gray-700 disabled:opacity-50 text-gray-200 rounded px-3 py-1.5 text-xs font-medium",children:x?"Listening… (2s)":"Test audio"}),a.jsx("div",{className:"flex items-end gap-0.5 h-5 flex-1 justify-end",children:Array.from({length:10},(e,t)=>a.jsx("span",{className:`w-1.5 rounded-sm ${t<h?t<7?"bg-green-500":"bg-yellow-400":"bg-gray-800"}`,style:{height:`${6+1.5*t}px`}},t))})]}),m?.error&&a.jsx("p",{className:"text-xs text-red-400 mt-2",children:m.error}),m?.level!==void 0&&m.level<.004&&a.jsx("p",{className:"text-xs text-yellow-500 mt-2",children:"Silence detected — check the aggregate device and that audio is playing."}),m?.level!==void 0&&m.level>=.004&&a.jsx("p",{className:"text-xs text-green-500 mt-2",children:"Audio detected ✓"})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-3",children:[a.jsx("button",{onClick:l,className:"px-4 py-2 text-sm text-gray-400 hover:text-white",children:"Cancel"}),(0,a.jsxs)("button",{onClick:()=>s(i.trim(),d),className:"px-4 py-2 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg font-medium flex items-center gap-2",children:[a.jsx("span",{className:"w-2 h-2 rounded-full bg-white animate-pulse"})," Start recording"]})]})]})})}function E(e){return e.split(/(\*\*[^*]+\*\*|`[^`]+`)/g).map((e,t)=>e.startsWith("**")&&e.endsWith("**")?a.jsx("strong",{className:"text-gray-100 font-semibold",children:e.slice(2,-2)},t):e.startsWith("`")&&e.endsWith("`")?a.jsx("code",{className:"bg-gray-800 rounded px-1 text-[0.9em]",children:e.slice(1,-1)},t):a.jsx(r.Fragment,{children:e},t))}function U({text:e}){let t=[],s=[],r=()=>{s.length&&t.push({kind:"p",text:s.join(" ")}),s=[]};for(let a of e.split("\n")){let e=a.match(/^(#{1,4})\s+(.*)/),l=a.match(/^(\s*)([-*]|\d+[.)])\s+(.*)/),n=t.at(-1);e?(r(),t.push({kind:"h",text:e[2]})):l?(r(),t.push({kind:"li",indent:l[1].length,marker:l[2],text:l[3]})):a.trim()?!s.length&&n?.kind==="li"&&/^\s+\S/.test(a)?n.text+=" "+a.trim():s.push(a.trim()):r()}return r(),a.jsx("div",{className:"text-sm text-gray-300 leading-relaxed",children:t.map((e,t)=>"h"===e.kind?a.jsx("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mt-5 mb-2 first:mt-0",children:E(e.text)},t):"li"===e.kind?(0,a.jsxs)("div",{className:"flex gap-2 mb-1.5",style:{paddingLeft:8*Math.min(e.indent,8)},children:[a.jsx("span",{className:"text-gray-500 flex-shrink-0 w-4 text-right",children:/\d/.test(e.marker)?e.marker:"•"}),a.jsx("span",{children:E(e.text)})]},t):a.jsx("p",{className:"mb-3",children:E(e.text)},t))})}var F=s(9532);function _({meetingId:e,title:t,onClose:s}){let[l,n]=(0,r.useState)(null),[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(null),[x,u]=(0,r.useState)("idle"),[m,p]=(0,r.useState)("");async function g(){let t=(d?.name??i).replace(/^#/,"").trim();if(!t)return;u("sending"),p("");let s=await fetch(`/api/meetings/${e}/slack`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channel:{id:d?.id??"",name:t}})}),a=await s.json().catch(()=>({}));s.ok?u("sent"):(p(a.error??"Could not send"),u("error"))}return a.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:s,children:(0,a.jsxs)("div",{className:"w-full max-w-xl max-h-[90vh] overflow-y-auto bg-gray-900 border border-gray-700 rounded-xl p-5 text-white",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("h2",{className:"text-base font-semibold truncate",children:["Send summary to Slack \xb7 ",t]}),a.jsx("button",{onClick:s,className:"text-gray-500 hover:text-white","aria-label":"Close",children:"✕"})]}),a.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Channel"}),a.jsx(O.a,{value:i,onChange:(e,t)=>{o(e),c(t),"sending"!==x&&u("idle")},onEnter:g,className:"w-full bg-gray-800 border border-gray-700 focus:border-gray-500 rounded-md px-2.5 py-1.5 text-sm text-white outline-none placeholder-gray-500"}),a.jsx("p",{className:"text-xs text-gray-400 mt-4 mb-1",children:"Message"}),a.jsx("pre",{className:"text-xs text-gray-300 bg-gray-950 border border-gray-800 rounded-md p-3 whitespace-pre-wrap max-h-72 overflow-y-auto font-sans",children:l??("error"===x?"":"Loading…")}),"error"===x&&a.jsx("p",{className:"text-xs text-red-400 mt-3",children:m}),"sent"===x&&(0,a.jsxs)("p",{className:"text-xs text-green-400 mt-3",children:["Posted to #",(d?.name??i).replace(/^#/,""),"."]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[a.jsx("button",{onClick:s,className:"px-3 py-1.5 text-sm text-gray-400 hover:text-white",children:"sent"===x?"Close":"Cancel"}),"sent"!==x&&a.jsx("button",{onClick:g,disabled:!l||!i.trim()||"sending"===x,className:"px-3 py-1.5 text-sm rounded-md bg-blue-600 hover:bg-blue-500 disabled:opacity-40",children:"sending"===x?"Sending…":"Send"})]})]})})}function J(e){let t=Math.floor(e/1e3),s=Math.floor(t/3600),a=Math.floor(t%3600/60);return s>0?`${s}h ${a}m`:`${a}m ${t%60}s`}function B(e){let t=Math.max(0,Math.floor(e/1e3)),s=Math.floor(t/3600),a=String(Math.floor(t%3600/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");return s?`${s}:${a}:${r}`:`${a}:${r}`}function H({text:e,q:t}){if(!t)return a.jsx(a.Fragment,{children:e});let s=RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return a.jsx(a.Fragment,{children:e.split(s).map((e,t)=>t%2?a.jsx("mark",{className:"bg-amber-400/25 text-amber-100 rounded-sm px-0.5",children:e},t):e)})}function W({notes:e}){let t=(e,t,s)=>t.length>0&&(0,a.jsxs)("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[(0,a.jsxs)("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-3",children:[e," ",a.jsx("span",{className:"text-gray-600",children:t.length})]}),a.jsx("ul",{className:"space-y-2",children:t.map((e,t)=>(0,a.jsxs)("li",{className:"flex gap-2.5 text-sm text-gray-300 leading-relaxed",children:[a.jsx("span",{className:"text-gray-500 flex-shrink-0",children:s}),a.jsx("span",{children:e})]},t))})]});return(0,a.jsxs)("div",{className:"space-y-4",children:[t("Decisions",e.decisions,"✓"),t("Action items",e.actionItems,"☐"),t("Topics",e.topics,"•")]})}let z=[{kind:"link",label:"Link / file"},{kind:"slack",label:"Slack channel"},{kind:"text",label:"Paste text"},{kind:"session",label:"Session"},{kind:"meeting",label:"Past meeting"}],q={loading:"⏳",loaded:"✓",failed:"⚠"};function G({items:e,isLive:t,onAdd:s,sessionOptions:l,meetingOptions:n}){let[i,o]=(0,r.useState)("link"),[d,c]=(0,r.useState)(""),[x,u]=(0,r.useState)(""),m="w-full bg-gray-900 text-white rounded-lg px-2.5 py-1.5 text-xs outline-none border border-gray-800 focus:border-blue-600 placeholder-gray-600",p="session"===i?l:n;function g(){d.trim()&&(s(i,d),c(""),u(""))}return(0,a.jsxs)("div",{children:[a.jsx("p",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-2",children:"Context"}),0===e.length&&!t&&a.jsx("p",{className:"text-xs text-gray-600",children:"No extra context was added."}),a.jsx("ul",{className:"space-y-1.5 mb-2",children:e.map(e=>(0,a.jsxs)("li",{className:"text-xs rounded-md bg-gray-900 px-2.5 py-1.5",title:"text"===e.kind?e.value.slice(0,500):e.value,children:[(0,a.jsxs)("div",{className:"flex gap-1.5",children:[a.jsx("span",{className:"failed"===e.status?"text-amber-400":"loaded"===e.status?"text-green-400":"",children:q[e.status]}),a.jsx("span",{className:"text-gray-200 truncate",children:e.label})]}),e.summary&&a.jsx("p",{className:`mt-0.5 leading-snug ${"failed"===e.status?"text-amber-400/80":"text-gray-500"}`,children:e.summary}),"loading"===e.status&&a.jsx("p",{className:"mt-0.5 text-gray-600 italic",children:"Claude is reading it…"})]},e.id))}),t&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[a.jsx("div",{className:"flex flex-wrap gap-1",children:z.map(e=>a.jsx("button",{onClick:()=>{o(e.kind),c(""),u("")},className:`px-2 py-0.5 rounded text-[11px] border ${i===e.kind?"bg-gray-700 border-gray-500 text-gray-100":"border-gray-800 text-gray-500 hover:text-gray-300"}`,children:e.label},e.kind))}),"text"===i&&a.jsx("textarea",{value:d,onChange:e=>c(e.target.value),rows:3,placeholder:"Paste an agenda, email, doc excerpt…",className:`${m} resize-none`}),"slack"===i&&a.jsx(O.a,{value:d,onChange:e=>c(e),onEnter:g,className:m}),"link"===i&&a.jsx("input",{value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&g()},placeholder:"URL, file path, or Slack / Notion / Drive link",className:m}),("session"===i||"meeting"===i)&&(0,a.jsxs)(a.Fragment,{children:[a.jsx(F.h,{options:p,value:x,onChange:e=>{u(e),c("")},onPick:e=>{u(e.label),c(e.id)},onEnter:g,placeholder:p.length?`Type to find a ${"session"===i?"session":"meeting"}…`:"None available",className:m}),x&&!d&&a.jsx("p",{className:"text-[11px] text-gray-500",children:"Pick one of the suggestions."})]}),a.jsx("button",{onClick:g,disabled:!d.trim(),className:"w-full text-xs rounded-md bg-gray-800 hover:bg-gray-700 border border-gray-700 py-1 disabled:opacity-40",children:"+ Add context"})]})]})}function K({meeting:e,live:t,orgName:s,onStop:l,onResume:n,onAsk:i,onAddContext:o,onBack:d,sessionOptions:c,meetingOptions:x}){let[u,m]=(0,r.useState)([]),[p,g]=(0,r.useState)(null),[h,b]=(0,r.useState)(null),[y,f]=(0,r.useState)([]),[j,N]=(0,r.useState)(""),[v,w]=(0,r.useState)({}),[k,S]=(0,r.useState)(!1),[C,D]=(0,r.useState)(!1),[$,I]=(0,r.useState)(!1),[A,R]=(0,r.useState)(Date.now()),O="recording"===e.status,[P,M]=(0,r.useState)(O?"transcript":"summary"),[L,T]=(0,r.useState)(""),E=(0,r.useRef)(null),F=(0,r.useMemo)(()=>{let e=t?.transcript??[],s=u.at(-1)?.t??0;return[...u,...e.filter(e=>e.t>s)]},[u,t?.transcript]),z=t?.notes??p,q=t?.context??y,K=L.trim(),Y=K?F.filter(e=>e.text.toLowerCase().includes(K.toLowerCase())):F,V=(t?.suggestions??[]).filter(e=>!v[e.id]),X=t?.qa??[],Q=(e,t)=>a.jsx("button",{onClick:()=>M(e),className:`px-1 pb-2.5 pt-1 text-sm border-b-2 transition-colors ${P===e?"border-blue-500 text-white":"border-transparent text-gray-500 hover:text-gray-300"}`,children:t});return(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col bg-gray-950 overflow-hidden",children:[(0,a.jsxs)("div",{className:"px-6 pt-4 pb-3 border-b border-gray-800 flex-shrink-0",children:[a.jsx("button",{onClick:d,className:"text-xs text-gray-500 hover:text-gray-300 mb-2",children:"← Recordings"}),(0,a.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[O&&a.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-red-500 animate-pulse flex-shrink-0"}),a.jsx("h1",{className:"text-xl font-semibold text-white truncate",children:e.title}),s&&a.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-900/50 text-purple-300 text-[10px] font-medium flex-shrink-0",children:s})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 mt-1 tabular-nums",children:[new Date(e.startedAt).toLocaleString(void 0,{weekday:"short",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})," \xb7 ",O?(0,a.jsxs)("span",{className:"text-red-400",children:["Recording ",J(A-e.startedAt)]}):e.endedAt?J(e.endedAt-e.startedAt):"","interrupted"===e.status&&a.jsx("span",{className:"text-amber-400",children:" \xb7 interrupted"}),z&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 ",z.decisions.length," decisions \xb7 ",z.actionItems.length," action items"]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!O&&a.jsx("button",{onClick:()=>n(e.id),className:"text-xs bg-red-600/90 hover:bg-red-500 text-white rounded-md px-3 py-1.5 font-medium",children:"● Continue recording"}),!O&&h&&a.jsx("button",{onClick:()=>I(!0),className:"text-xs border border-gray-700 hover:bg-gray-800 text-gray-200 rounded-md px-3 py-1.5",children:"Send to Slack"}),!O&&a.jsx("button",{onClick:function(){let t=[`# ${e.title}`,`_${new Date(e.startedAt).toLocaleString()}${e.endedAt?` — ${J(e.endedAt-e.startedAt)}`:""}_`,"",h??"","","## Transcript",...F.map(t=>`- **${B(t.t-e.startedAt)}** ${t.text}`)].join("\n");navigator.clipboard.writeText(t).then(()=>{D(!0),setTimeout(()=>D(!1),1500)}).catch(()=>{})},className:"text-xs border border-gray-700 hover:bg-gray-800 text-gray-200 rounded-md px-3 py-1.5",children:C?"Copied ✓":"Copy as Markdown"}),O&&a.jsx("button",{onClick:()=>{S(!0),l(e.id)},disabled:k,className:"text-xs bg-red-600 hover:bg-red-500 disabled:opacity-60 text-white rounded-md px-3 py-1.5 font-medium",children:k?"Stopping — writing summary…":"■ Stop recording"})]})]})]}),$&&a.jsx(_,{meetingId:e.id,title:e.title,onClose:()=>I(!1)}),t?.lastError&&a.jsx("div",{className:"px-6 py-1.5 bg-amber-900/20 border-b border-amber-800/30 text-amber-400 text-xs flex-shrink-0",children:t.lastError}),(0,a.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,a.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[(0,a.jsxs)("div",{className:"px-6 pt-2 border-b border-gray-800 flex items-end gap-5 flex-shrink-0",children:[Q("summary",O?"Live notes":"Summary"),Q("transcript",`Transcript${F.length?` \xb7 ${F.length}`:""}`),"transcript"===P&&F.length>0&&a.jsx("input",{value:L,onChange:e=>T(e.target.value),placeholder:"Find in transcript",className:"ml-auto mb-2 w-56 bg-gray-900 border border-gray-800 focus:border-gray-600 rounded-md px-2.5 py-1 text-xs outline-none placeholder-gray-600"})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto",children:["summary"===P&&a.jsx("div",{className:"px-6 py-5 max-w-3xl",children:h?a.jsx(U,{text:h}):z?a.jsx(W,{notes:z}):a.jsx("p",{className:"text-sm text-gray-500",children:O?"Notes appear here every couple of minutes while people talk.":"No summary was generated for this meeting."})}),"transcript"===P&&(0,a.jsxs)("div",{className:"px-6 py-4 max-w-4xl",children:[0===Y.length?a.jsx("p",{className:"text-sm text-gray-500",children:K?`No lines contain “${K}”.`:O?"Listening… text appears a few seconds after people speak.":"No transcript captured."}):Y.map((t,s)=>(0,a.jsxs)("div",{className:"flex gap-4 py-1.5 group",children:[a.jsx("span",{className:"text-[11px] text-gray-600 font-mono pt-0.5 w-14 flex-shrink-0 text-right tabular-nums",title:new Date(t.t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:B(t.t-e.startedAt)}),a.jsx("p",{className:"text-sm text-gray-300 leading-relaxed",children:a.jsx(H,{text:t.text,q:K})})]},s)),a.jsx("div",{ref:E})]})]})]}),(0,a.jsxs)("div",{className:"w-[360px] flex-shrink-0 border-l border-gray-800 flex flex-col min-h-0 bg-gray-900/20",children:[a.jsx("div",{className:"max-h-[45%] overflow-y-auto px-4 py-4 border-b border-gray-800 flex-shrink-0",children:a.jsx(G,{items:q,isLive:O,onAdd:(t,s)=>o(e.id,t,s),sessionOptions:c,meetingOptions:x.filter(t=>t.id!==e.id)})}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-2.5",children:[a.jsx("p",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide",children:"Assistant"}),V.map(e=>a.jsx("div",{className:"rounded-lg bg-blue-950/50 border border-blue-800/40 px-3 py-2.5",children:(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsxs)("p",{className:"text-xs text-blue-200 leading-relaxed flex-1",children:["\uD83D\uDCA1 ",e.text]}),a.jsx("button",{onClick:()=>w(t=>({...t,[e.id]:!0})),className:"text-blue-700 hover:text-blue-400 text-xs flex-shrink-0","aria-label":"Dismiss",children:"✕"})]})},e.id)),X.map((e,t)=>(0,a.jsxs)("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"ml-8 rounded-lg bg-blue-600/90 text-white text-xs px-3 py-2 leading-relaxed",children:e.question}),a.jsx("div",{className:"mr-4 rounded-lg bg-gray-800/80 px-3 py-2",children:null===e.answer?a.jsx("p",{className:"text-xs text-gray-500 italic",children:"Thinking…"}):a.jsx("p",{className:"text-xs text-gray-200 whitespace-pre-wrap leading-relaxed",children:e.answer})})]},t)),0===V.length&&0===X.length&&a.jsx("p",{className:"text-xs text-gray-600",children:O?"Ask anything about the meeting so far. Suggestions appear here when Claude has something useful.":"Questions asked during the meeting appear here."})]}),O&&a.jsx("div",{className:"px-3 py-3 border-t border-gray-800 flex-shrink-0",children:a.jsx("input",{type:"text",value:j,onChange:e=>N(e.target.value),onKeyDown:t=>{"Enter"===t.key&&function(){let t=j.trim();t&&(N(""),i(e.id,t))}()},placeholder:"Ask Claude… (Enter to send)",className:"w-full bg-gray-900 text-white rounded-lg px-3 py-2 text-sm outline-none border border-gray-800 focus:border-blue-600 placeholder-gray-600"})})]})]})]})]})}function Y(e){return e.endedAt?e.endedAt-e.startedAt:0}function V({text:e,words:t}){if(!t.length)return a.jsx(a.Fragment,{children:e});let s=RegExp(`(${t.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})`,"gi");return a.jsx(a.Fragment,{children:e.split(s).map((e,t)=>t%2?a.jsx("mark",{className:"bg-amber-400/25 text-amber-100 rounded-sm px-0.5",children:e},t):e)})}let X={recording:"bg-red-500/15 text-red-300 ring-red-500/30",ended:"bg-emerald-500/10 text-emerald-300 ring-emerald-500/25",interrupted:"bg-amber-500/10 text-amber-300 ring-amber-500/25"},Q=[["all","Any time"],["7","7 days"],["30","30 days"],["90","90 days"]];function Z({orgs:e,activeOrgId:t,refreshKey:s,onOpen:l,onDeleted:n}){let[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)(""),[x,u]=(0,r.useState)("all"),[m,p]=(0,r.useState)("all"),[g,h]=(0,r.useState)({key:"when",desc:!0}),[b,y]=(0,r.useState)(null),[f,j]=(0,r.useState)(!1),[N,v]=(0,r.useState)(null),[w,k]=(0,r.useState)(null),[S,C]=(0,r.useState)(0),[D,$]=(0,r.useState)(null);async function I(e){v(null);let t=await fetch(`/api/meetings/${e}`,{method:"DELETE"});if(!t.ok){k((await t.json().catch(()=>({}))).error??"Could not delete");return}k(null),C(e=>e+1),n()}let A=d.toLowerCase().split(/\s+/).filter(Boolean),R="all"===m?0:Date.now()-864e5*Number(m),O=(b??[]).filter(e=>("all"===t||(e.orgId??"default")===t)&&("all"===x||e.status===x)&&e.startedAt>=R).sort((e,t)=>{let s="when"===g.key?e.startedAt-t.startedAt:Y(e)-Y(t);return g.desc?-s:s}),P=e=>`px-2.5 py-1 rounded-md text-xs transition-colors ${e?"bg-gray-700 text-gray-100":"text-gray-400 hover:text-gray-200 hover:bg-gray-800/60"}`,M="px-4 py-2.5 text-[11px] font-semibold uppercase tracking-wider text-gray-500 whitespace-nowrap",L=(e,t,s="")=>a.jsx("th",{className:`${M} ${s}`,children:(0,a.jsxs)("button",{onClick:()=>h(t=>({key:e,desc:t.key!==e||!t.desc})),className:"hover:text-gray-300 uppercase tracking-wider",children:[t,g.key===e?g.desc?" ▾":" ▴":""]})});return(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col bg-gray-950 text-gray-100",children:[D&&a.jsx(_,{meetingId:D.id,title:D.title,onClose:()=>$(null)}),(0,a.jsxs)("div",{className:"px-6 pt-5 pb-4 flex flex-col gap-3 flex-shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-baseline gap-3",children:[a.jsx("h1",{className:"text-lg font-semibold",children:"Recordings"}),a.jsx("span",{className:"text-xs text-gray-500",children:b?`${O.length} of ${b.length}`:"Loading…"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("div",{className:"relative flex-1 min-w-[260px]",children:[a.jsx("span",{className:"absolute left-3 top-2 text-gray-500 text-sm",children:"⌕"}),a.jsx("input",{autoFocus:!0,value:i,onChange:e=>o(e.target.value),placeholder:"Search titles, summaries, notes and transcripts",className:"w-full bg-gray-900 border border-gray-800 focus:border-gray-600 rounded-lg pl-8 pr-24 py-2 text-sm outline-none placeholder-gray-600"}),f&&a.jsx("span",{className:"absolute right-3 top-2.5 text-xs text-gray-500",children:"searching…"})]}),a.jsx("div",{className:"flex gap-1 bg-gray-900 border border-gray-800 rounded-lg p-0.5",children:["all","ended","interrupted","recording"].map(e=>a.jsx("button",{onClick:()=>u(e),className:P(x===e),children:"all"===e?"All":e[0].toUpperCase()+e.slice(1)},e))}),a.jsx("div",{className:"flex gap-1 bg-gray-900 border border-gray-800 rounded-lg p-0.5",children:Q.map(([e,t])=>a.jsx("button",{onClick:()=>p(e),className:P(m===e),children:t},e))})]}),w&&a.jsx("p",{className:"text-xs text-red-400",children:w})]}),a.jsx("div",{className:"flex-1 overflow-auto px-6 pb-6",children:(0,a.jsxs)("div",{className:"rounded-xl border border-gray-800 bg-gray-900/40 overflow-hidden",children:[(0,a.jsxs)("table",{className:"w-full text-sm border-collapse",children:[a.jsx("thead",{className:"sticky top-0 bg-gray-900 z-10 border-b border-gray-800",children:(0,a.jsxs)("tr",{className:"text-left",children:[L("when","When"),a.jsx("th",{className:M,children:"Meeting"}),L("length","Length","text-right"),a.jsx("th",{className:`${M} text-right`,children:"Decisions"}),a.jsx("th",{className:`${M} text-right`,children:"Action items"}),a.jsx("th",{className:M,children:"Status"}),a.jsx("th",{className:M})]})}),a.jsx("tbody",{children:O.map(t=>{var s;let r="default"!==t.orgId?e.find(e=>e.id===t.orgId)?.name:null;return(0,a.jsxs)("tr",{onClick:()=>l(t.id),className:"border-b border-gray-800/70 last:border-0 hover:bg-gray-800/40 cursor-pointer group",children:[a.jsx("td",{className:"px-4 py-3 text-gray-300 whitespace-nowrap align-top tabular-nums",children:function(e){let t=new Date(e),s=t.getFullYear()===new Date().getFullYear();return t.toLocaleString(void 0,{month:"short",day:"numeric",...s?{}:{year:"numeric"},hour:"2-digit",minute:"2-digit"})}(t.startedAt)}),(0,a.jsxs)("td",{className:"px-4 py-3 align-top max-w-0 w-full",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:["recording"===t.status&&a.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 animate-pulse flex-shrink-0"}),a.jsx("span",{className:"font-medium text-gray-100 truncate",children:a.jsx(V,{text:t.title,words:A})}),r&&a.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-900/50 text-purple-300 text-[10px] font-medium flex-shrink-0",children:r})]}),t.match?a.jsx("p",{className:"text-xs text-gray-400 mt-1 truncate",children:a.jsx(V,{text:t.match,words:A})}):t.snippet&&a.jsx("p",{className:"text-xs text-gray-500 mt-1 truncate",children:t.snippet})]}),a.jsx("td",{className:"px-4 py-3 text-right text-gray-300 whitespace-nowrap align-top tabular-nums",title:`Audio: ${t.audio.chunks} chunks \xb7 ${(s=t.audio.bytes)>=1e9?`${(s/1e9).toFixed(1)} GB`:`${Math.max(1,Math.round(s/1e6))} MB`}`,children:function(e){if(!e)return"—";let t=Math.max(1,Math.round(e/6e4));return t>=60?`${Math.floor(t/60)}h ${String(t%60).padStart(2,"0")}m`:`${t}m`}(Y(t))}),a.jsx("td",{className:"px-4 py-3 text-right text-gray-300 align-top tabular-nums",children:t.counts.decisions||a.jsx("span",{className:"text-gray-600",children:"—"})}),a.jsx("td",{className:"px-4 py-3 text-right text-gray-300 align-top tabular-nums",children:t.counts.actionItems||a.jsx("span",{className:"text-gray-600",children:"—"})}),a.jsx("td",{className:"px-4 py-3 align-top",children:a.jsx("span",{className:`px-2 py-0.5 rounded-full text-[11px] font-medium ring-1 ring-inset capitalize ${X[t.status]}`,children:t.status})}),a.jsx("td",{className:"px-4 py-3 align-top whitespace-nowrap text-right",onClick:e=>e.stopPropagation(),children:N===t.id?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[a.jsx("span",{className:"text-xs text-gray-400",children:"Delete?"}),a.jsx("button",{onClick:()=>I(t.id),className:"text-xs px-2 py-1 rounded-md bg-red-600 hover:bg-red-500 text-white",children:"Delete"}),a.jsx("button",{onClick:()=>v(null),className:"text-xs px-2 py-1 rounded-md text-gray-400 hover:text-white",children:"Cancel"})]}):(0,a.jsxs)("span",{className:"inline-flex gap-1.5",children:[a.jsx("button",{onClick:()=>l(t.id),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-gray-200 hover:bg-gray-800",children:"Open"}),a.jsx("button",{onClick:()=>$(t),disabled:!t.snippet,title:t.snippet?"Send the summary to a Slack channel":"No summary yet",className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-gray-200 hover:bg-gray-800 disabled:opacity-30 disabled:hover:bg-transparent",children:"Slack"}),a.jsx("button",{onClick:()=>v(t.id),disabled:"recording"===t.status,className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-red-400 hover:bg-red-950/40 disabled:opacity-30 disabled:hover:bg-transparent",children:"Delete"})]})})]},t.id)})})]}),b&&0===O.length&&a.jsx("p",{className:"text-sm text-gray-500 text-center py-16",children:d?`No recordings match “${d}”`:"No recordings for these filters"})]})})]})}var ee=s(3814);function et({editing:e,onClose:t,onSaved:s,inline:l=!1}){let[n,i]=(0,r.useState)(e?"raw":"form"),[o,d]=(0,r.useState)(""),[c,x]=(0,r.useState)(""),[u,m]=(0,r.useState)(""),[p,g]=(0,r.useState)(""),[h,b]=(0,r.useState)(null),[y,f]=(0,r.useState)(!1),[j,N]=(0,r.useState)(!1);async function v(){f(!0),b(null);let a="raw"===n?{raw:p}:{name:o.trim().toLowerCase().replace(/\s+/g,"-"),description:c,instructions:u},r=await fetch(e?`/api/skills/${e}`:"/api/skills",{method:e?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),l=await r.json().catch(()=>({}));if(f(!1),!r.ok){b(l.error??"Could not save");return}s(),t()}async function w(){if(e){if(!(await fetch((0,ee.X)(`/api/skills/${e}`),{method:"DELETE"})).ok){b("Could not delete");return}s(),t()}}let k="w-full bg-gray-800 border border-gray-700 focus:border-gray-500 rounded-md px-2.5 py-1.5 text-sm text-white outline-none placeholder-gray-500",S=(e,t)=>a.jsx("button",{onClick:()=>i(e),className:`px-2.5 py-1 rounded-md text-xs ${n===e?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-200"}`,children:t});return a.jsx("div",{className:l?"":"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:l?void 0:t,children:(0,a.jsxs)("div",{className:l?"text-white":"w-full max-w-2xl max-h-[90vh] overflow-y-auto bg-gray-900 border border-gray-700 rounded-xl p-5 text-white",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("h2",{className:"text-base font-semibold",children:e?`Edit skill: ${e}`:"New skill"}),!l&&a.jsx("button",{onClick:t,className:"text-gray-500 hover:text-white","aria-label":"Close",children:"✕"})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 mb-4",children:["Saved to ",a.jsx("code",{children:"~/.claude/skills/<name>/SKILL.md"}),". Claude Code loads it in sessions started after you save."]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mb-4 bg-gray-950/60 border border-gray-800 rounded-lg p-0.5 w-fit",children:[!e&&S("form","Write it"),S("raw",e?"SKILL.md":"Paste SKILL.md"),(0,a.jsxs)("label",{className:"px-2.5 py-1 rounded-md text-xs text-gray-400 hover:text-gray-200 cursor-pointer",children:["Import file…",a.jsx("input",{type:"file",accept:".md,text/markdown,text/plain",className:"hidden",onChange:e=>{var t;(t=e.target.files?.[0])&&t.text().then(e=>{g(e),i("raw")})}})]})]}),"form"===n?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Name",a.jsx("input",{value:o,onChange:e=>d(e.target.value),placeholder:"release-notes",className:`${k} mt-1 font-mono`})]}),(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["When should Claude use it?",a.jsx("input",{value:c,onChange:e=>x(e.target.value),placeholder:"Use when writing release notes from merged PRs",className:`${k} mt-1`})]}),(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Instructions (markdown)",a.jsx("textarea",{value:u,onChange:e=>m(e.target.value),rows:12,placeholder:"# Release notes\n\n1. List PRs merged since the last tag\n2. Group them by area\n3. …",className:`${k} mt-1 font-mono text-xs resize-y`})]})]}):a.jsx("textarea",{value:p,onChange:e=>g(e.target.value),rows:l?26:18,spellCheck:!1,placeholder:"---\nname: release-notes\ndescription: Use when writing release notes\n---\n\n# Instructions…",className:`${k} font-mono text-xs resize-y`}),h&&a.jsx("p",{className:"text-xs text-red-400 mt-3",children:h}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-4",children:[e&&(j?(0,a.jsxs)("span",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"text-gray-400",children:"Delete this skill?"}),a.jsx("button",{onClick:w,className:"px-2.5 py-1 rounded-md bg-red-600 hover:bg-red-500",children:"Delete"}),a.jsx("button",{onClick:()=>N(!1),className:"text-gray-400 hover:text-white",children:"Cancel"})]}):a.jsx("button",{onClick:()=>N(!0),className:"text-xs text-red-400 hover:text-red-300",children:"Delete skill"})),(0,a.jsxs)("div",{className:"ml-auto flex gap-2",children:[a.jsx("button",{onClick:t,className:"px-3 py-1.5 text-sm text-gray-400 hover:text-white",children:"Cancel"}),a.jsx("button",{onClick:v,disabled:y,className:"px-3 py-1.5 text-sm rounded-md bg-blue-600 hover:bg-blue-500 disabled:opacity-40",children:y?"Saving…":"Save skill"})]})]})]})})}function es({onClose:e,onInstalled:t,inline:s=!1}){let[l,n]=(0,r.useState)(null),[i,o]=(0,r.useState)(""),[d,c]=(0,r.useState)("all"),[x,u]=(0,r.useState)(null),[m,p]=(0,r.useState)(null),g=()=>fetch((0,ee.X)("/api/skills/marketplace")).then(e=>e.json()).then(e=>n(e.plugins??[])).catch(()=>n([]));async function h(e){let s=`${e.name}@${e.marketplace}`;u(s),p(null);let a=await fetch((0,ee.X)("/api/skills/marketplace"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,marketplace:e.marketplace})}),r=await a.json().catch(()=>({}));u(null),p({id:s,ok:a.ok,text:a.ok?"Installed. New sessions will have it.":r.error??"Install failed"}),a.ok&&(g(),t())}let b=Array.from(new Set((l??[]).map(e=>e.marketplace))).sort(),y=i.toLowerCase(),f=(l??[]).filter(e=>("all"===d||e.marketplace===d)&&(!y||e.name.toLowerCase().includes(y)||e.description.toLowerCase().includes(y)));return a.jsx("div",{className:s?"h-full":"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:s?void 0:e,children:(0,a.jsxs)("div",{className:s?"h-full flex flex-col text-white":"w-full max-w-2xl h-[80vh] flex flex-col bg-gray-900 border border-gray-700 rounded-xl p-5 text-white",onClick:e=>e.stopPropagation(),children:[!s&&(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("h2",{className:"text-base font-semibold",children:"Skills marketplace"}),a.jsx("button",{onClick:e,className:"text-gray-500 hover:text-white","aria-label":"Close",children:"✕"})]}),a.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"Plugins from the marketplaces your Claude Code knows. A plugin can bundle skills, commands and tools, and runs as you. Install only ones you trust."}),(0,a.jsxs)("div",{className:"flex gap-2 mb-3",children:[a.jsx("input",{autoFocus:!0,value:i,onChange:e=>o(e.target.value),placeholder:"Search plugins",className:"flex-1 bg-gray-800 border border-gray-700 focus:border-gray-500 rounded-md px-2.5 py-1.5 text-sm outline-none placeholder-gray-500"}),(0,a.jsxs)("select",{value:d,onChange:e=>c(e.target.value),className:"bg-gray-800 border border-gray-700 rounded-md px-2 text-xs",children:[a.jsx("option",{value:"all",children:"All marketplaces"}),b.map(e=>a.jsx("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-1.5 pr-1",children:[null===l&&a.jsx("p",{className:"text-xs text-gray-500",children:"Loading…"}),l&&0===f.length&&a.jsx("p",{className:"text-xs text-gray-500",children:"No plugins match."}),f.map(e=>{let t=`${e.name}@${e.marketplace}`;return(0,a.jsxs)("div",{className:"rounded-lg border border-gray-800 px-3 py-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium truncate",children:e.name}),a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-gray-800 text-gray-400 flex-shrink-0",children:e.marketplace}),e.category&&a.jsx("span",{className:"text-[10px] text-gray-500 flex-shrink-0",children:e.category}),a.jsx("span",{className:"ml-auto flex-shrink-0",children:e.installed?a.jsx("span",{className:"text-[11px] text-emerald-400",children:"✓ Installed"}):a.jsx("button",{onClick:()=>h(e),disabled:!!x,className:"text-xs px-2.5 py-1 rounded-md bg-blue-600 hover:bg-blue-500 disabled:opacity-40",children:x===t?"Installing…":"Install"})})]}),e.description&&a.jsx("p",{className:"text-xs text-gray-500 mt-1 line-clamp-2",children:e.description}),m?.id===t&&a.jsx("p",{className:`text-xs mt-1 ${m.ok?"text-emerald-400":"text-amber-400"}`,children:m.text})]},t)})]})]})})}function ea({selected:e,onSelect:t,onChanged:s}){let[l,n]=(0,r.useState)("installed"),[i,o]=(0,r.useState)(null),[d,c]=(0,r.useState)(""),[x,u]=(0,r.useState)("all"),[m,p]=(0,r.useState)(null),[g,h]=(0,r.useState)("view"),[b,y]=(0,r.useState)(0),f=()=>{y(e=>e+1),s()},j=d.toLowerCase(),N=(i??[]).filter(e=>("all"===x||e.source===x)&&(!j||e.name.toLowerCase().includes(j)||e.description.toLowerCase().includes(j))),v=m?.raw.replace(/^---[\s\S]*?\n---\s*/,"")??"",w=e=>`px-2.5 py-1 rounded-md text-xs ${e?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-200"}`,k=(e,t)=>a.jsx("button",{onClick:()=>n(e),className:`px-1 pb-2.5 pt-1 text-sm border-b-2 ${l===e?"border-blue-500 text-white":"border-transparent text-gray-500 hover:text-gray-300"}`,children:t});return(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col bg-gray-950 text-gray-100",children:[(0,a.jsxs)("div",{className:"px-6 pt-5 border-b border-gray-800 flex-shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h1",{className:"text-lg font-semibold",children:"Skills"}),a.jsx("button",{onClick:()=>{n("installed"),t(null),h("new")},className:"text-xs font-medium bg-blue-600 hover:bg-blue-500 rounded-md px-3 py-1.5",children:"+ New skill"})]}),(0,a.jsxs)("div",{className:"flex gap-5",children:[k("installed",`Installed${i?` \xb7 ${i.length}`:""}`),k("marketplace","Marketplace")]})]}),"marketplace"===l?a.jsx("div",{className:"flex-1 min-h-0 px-6 py-4",children:a.jsx(es,{inline:!0,onClose:()=>{},onInstalled:f})}):(0,a.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,a.jsxs)("div",{className:"w-[380px] flex-shrink-0 border-r border-gray-800 flex flex-col min-h-0",children:[(0,a.jsxs)("div",{className:"p-3 space-y-2 border-b border-gray-800",children:[a.jsx("input",{value:d,onChange:e=>c(e.target.value),placeholder:"Search skills",className:"w-full bg-gray-900 border border-gray-800 focus:border-gray-600 rounded-md px-2.5 py-1.5 text-sm outline-none placeholder-gray-600"}),(0,a.jsxs)("div",{className:"flex gap-1 bg-gray-900 border border-gray-800 rounded-lg p-0.5 w-fit",children:[a.jsx("button",{onClick:()=>u("all"),className:w("all"===x),children:"All"}),a.jsx("button",{onClick:()=>u("user"),className:w("user"===x),children:"Mine"}),a.jsx("button",{onClick:()=>u("plugin"),className:w("plugin"===x),children:"From plugins"})]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[null===i&&a.jsx("p",{className:"text-xs text-gray-500 p-4",children:"Loading…"}),N.map(s=>(0,a.jsxs)("button",{onClick:()=>t(s.name),className:`w-full text-left px-4 py-2.5 border-b border-gray-800/60 ${e===s.name?"bg-gray-800":"hover:bg-gray-900"}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium truncate flex-1",children:s.name}),a.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${"user"===s.source?"bg-blue-900/50 text-blue-300":"bg-gray-800 text-gray-400"}`,children:"plugin"===s.source?s.plugin??"plugin":"mine"})]}),s.description&&a.jsx("p",{className:"text-xs text-gray-500 mt-0.5 line-clamp-2",children:s.description})]},s.path))]})]}),a.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto px-8 py-6",children:"new"===g?a.jsx("div",{className:"max-w-3xl",children:a.jsx(et,{inline:!0,editing:null,onClose:()=>h("view"),onSaved:f})}):"edit"===g&&m?a.jsx("div",{className:"max-w-3xl",children:a.jsx(et,{inline:!0,editing:m.skill.name,onClose:()=>h("view"),onSaved:f})}):m?(0,a.jsxs)("div",{className:"max-w-3xl",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-4 mb-1",children:[a.jsx("h2",{className:"text-xl font-semibold font-mono",children:m.skill.name}),"user"===m.skill.source?a.jsx("button",{onClick:()=>h("edit"),className:"text-xs border border-gray-700 hover:bg-gray-800 rounded-md px-3 py-1.5 flex-shrink-0",children:"Edit"}):(0,a.jsxs)("span",{className:"text-xs text-gray-500 flex-shrink-0",children:["From plugin ",m.skill.plugin," \xb7 read-only"]})]}),a.jsx("p",{className:"text-sm text-gray-400 mb-1",children:m.skill.description}),a.jsx("p",{className:"text-[11px] text-gray-600 font-mono mb-6 truncate",children:m.skill.path}),a.jsx(U,{text:v})]}):a.jsx("div",{className:"text-sm text-gray-500 mt-20 text-center",children:"Pick a skill to read it, or create a new one."})})]})]})}let er=e=>e.text.split("\n").find(e=>e.trim())?.trim()||"Untitled";function el({notes:e,setNotes:t,orgs:s,activeOrgId:l,selected:n,onSelect:i}){var o;let[d,c]=(0,r.useState)(""),[x,u]=(0,r.useState)(!1),m=(0,r.useRef)(null),p=e=>"all"===l||(e??"default")===l,g=d.toLowerCase(),h=e.filter(e=>p(e.orgId)&&(!g||e.text.toLowerCase().includes(g))),b=e.find(e=>e.id===n)??null,y=e=>b&&t(t=>t.map(t=>t.id===b.id?{...t,...e}:t));return(0,a.jsxs)("div",{className:"absolute inset-0 flex bg-gray-950 text-gray-100",children:[(0,a.jsxs)("div",{className:"w-[340px] flex-shrink-0 border-r border-gray-800 flex flex-col min-h-0",children:[(0,a.jsxs)("div",{className:"px-4 pt-5 pb-3 border-b border-gray-800 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("h1",{className:"text-lg font-semibold",children:"Notes"}),a.jsx("button",{onClick:function(){let e={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,text:"",createdAt:Date.now(),..."all"!==l?{orgId:l}:{}};t(t=>[e,...t]),i(e.id),setTimeout(()=>m.current?.focus(),50)},className:"text-xs font-medium bg-blue-600 hover:bg-blue-500 rounded-md px-3 py-1.5",children:"+ New note"})]}),a.jsx("input",{value:d,onChange:e=>c(e.target.value),placeholder:"Search notes",className:"w-full bg-gray-900 border border-gray-800 focus:border-gray-600 rounded-md px-2.5 py-1.5 text-sm outline-none placeholder-gray-600"})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[0===h.length&&a.jsx("p",{className:"text-xs text-gray-500 p-4",children:d?"No notes match.":"No notes yet."}),h.map(e=>(0,a.jsxs)("button",{onClick:()=>i(e.id),className:`w-full text-left px-4 py-3 border-b border-gray-800/60 ${n===e.id?"bg-gray-800":"hover:bg-gray-900"}`,children:[a.jsx("p",{className:"text-sm font-medium truncate",children:er(e)}),a.jsx("p",{className:"text-xs text-gray-500 truncate mt-0.5",children:e.text.split("\n").filter(e=>e.trim()).slice(1).join(" ")||"\xa0"}),(0,a.jsxs)("p",{className:"text-[11px] text-gray-600 mt-1",children:[new Date(e.createdAt).toLocaleDateString(void 0,{month:"short",day:"numeric"}),e.remindAt&&!e.reminderDone&&(0,a.jsxs)("span",{className:"text-amber-400",children:[" \xb7 ⏰ ",new Date(e.remindAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]})]},e.id))]})]}),a.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:b?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"px-8 py-3 border-b border-gray-800 flex items-center gap-4 text-xs text-gray-500 flex-shrink-0",children:[a.jsx("span",{children:new Date(b.createdAt).toLocaleString()}),(0,a.jsxs)("label",{className:`flex items-center gap-1.5 ${b.remindAt&&!b.reminderDone?"text-amber-400":""}`,children:["⏰ Remind me",a.jsx("input",{type:"datetime-local",value:b.remindAt?new Date((o=b.remindAt)-6e4*new Date(o).getTimezoneOffset()).toISOString().slice(0,16):"",onChange:e=>y({remindAt:e.target.value?new Date(e.target.value).getTime():void 0,reminderDone:!1}),className:"bg-gray-900 border border-gray-800 rounded px-1.5 py-0.5 text-xs text-gray-200 [color-scheme:dark]"}),b.remindAt&&a.jsx("button",{onClick:()=>y({remindAt:void 0,reminderDone:!1}),className:"text-gray-500 hover:text-white",children:"clear"})]}),b.orgId&&"default"!==b.orgId&&a.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-900/50 text-purple-300 text-[10px]",children:s.find(e=>e.id===b.orgId)?.name??"org"}),a.jsx("span",{className:"ml-auto",children:x?(0,a.jsxs)("span",{className:"flex items-center gap-2",children:["Delete this note?",a.jsx("button",{onClick:()=>{t(e=>e.filter(e=>e.id!==b.id)),i(null)},className:"px-2 py-1 rounded-md bg-red-600 hover:bg-red-500 text-white",children:"Delete"}),a.jsx("button",{onClick:()=>u(!1),className:"hover:text-white",children:"Cancel"})]}):a.jsx("button",{onClick:()=>u(!0),className:"text-red-400 hover:text-red-300",children:"Delete"})})]}),a.jsx("textarea",{ref:m,value:b.text,onChange:e=>y({text:e.target.value}),placeholder:"Start typing. The first line is the title.",className:"flex-1 w-full resize-none bg-transparent px-8 py-6 text-[15px] leading-relaxed text-gray-100 outline-none placeholder-gray-600"})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-gray-500",children:"Pick a note, or create a new one."})})]})}function en({items:e,onOpenChange:t}){let[s,l]=(0,r.useState)(!1),[n,i]=(0,r.useState)(""),[o,d]=(0,r.useState)(0),c=(0,r.useRef)(null),x=(0,r.useMemo)(()=>s?e():[],[s,e]),u=(0,r.useMemo)(()=>{let e=n.toLowerCase().split(/\s+/).filter(Boolean),t=new Map;return x.filter(s=>{let a=`${s.label} ${s.hint??""} ${s.group}`.toLowerCase();if(!e.every(e=>a.includes(e)))return!1;let r=t.get(s.group)??0;return!(r>=(e.length?6:4))&&(t.set(s.group,r+1),!0)})},[x,n]);if(!s)return null;let m=e=>{e&&(l(!1),e.run())};return a.jsx("div",{className:"fixed inset-0 z-[60] bg-black/50 flex justify-center pt-[12vh] px-4",onClick:()=>l(!1),children:(0,a.jsxs)("div",{className:"w-full max-w-xl h-fit max-h-[70vh] flex flex-col bg-gray-900 border border-gray-700 rounded-xl shadow-2xl overflow-hidden",onClick:e=>e.stopPropagation(),children:[a.jsx("input",{ref:c,value:n,onChange:e=>{i(e.target.value),d(0)},onKeyDown:e=>{"ArrowDown"===e.key?(e.preventDefault(),d(e=>Math.min(e+1,u.length-1))):"ArrowUp"===e.key?(e.preventDefault(),d(e=>Math.max(e-1,0))):"Enter"===e.key?(e.preventDefault(),m(u[o])):"Escape"===e.key&&l(!1)},placeholder:"Search sessions, meetings, notes, skills, actions…",className:"w-full bg-transparent px-4 py-3.5 text-base text-white outline-none border-b border-gray-800 placeholder-gray-500"}),(0,a.jsxs)("div",{className:"overflow-y-auto py-1",children:[0===u.length&&a.jsx("p",{className:"px-4 py-6 text-sm text-gray-500 text-center",children:"No results"}),u.map((e,t)=>(0,a.jsxs)("div",{children:[(0===t||u[t-1].group!==e.group)&&a.jsx("p",{className:"px-4 pt-2.5 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-500",children:e.group}),(0,a.jsxs)("button",{onMouseEnter:()=>d(t),onClick:()=>m(e),className:`w-full text-left px-4 py-2 flex items-center gap-3 ${t===o?"bg-blue-600/80 text-white":"text-gray-200"}`,children:[a.jsx("span",{className:"truncate flex-1 text-sm",children:e.label}),e.hint&&a.jsx("span",{className:"text-[11px] opacity-60 flex-shrink-0 truncate max-w-[40%]",children:e.hint})]})]},`${e.group}:${e.id}`))]}),a.jsx("p",{className:"px-4 py-2 border-t border-gray-800 text-[11px] text-gray-500",children:"↑ ↓ to move \xb7 Enter to open \xb7 Esc to close \xb7 ⌘K to toggle"})]})})}var ei=s(9849);let eo=[["thumbsup","\uD83D\uDC4D"],["eyes","\uD83D\uDC40"],["white_check_mark","✅"],["pray","\uD83D\uDE4F"],["heart","❤️"],["joy","\uD83D\uDE02"],["raised_hands","\uD83D\uDE4C"],["fire","\uD83D\uDD25"]],ed=["bg-rose-600","bg-amber-600","bg-emerald-600","bg-sky-600","bg-violet-600","bg-pink-600","bg-teal-600"],ec=e=>ed[[...e].reduce((e,t)=>e+t.charCodeAt(0),0)%ed.length],ex="polyergon:slack-links";function eu({m:e,onGone:t,onAgent:s,suggesting:l,sessions:n,onOpenSession:i,onAskSession:o}){let[d,c]=(0,r.useState)(null),[x,u]=(0,r.useState)(!1),[m,p]=(0,r.useState)(!1),g=n.find(e=>e.id===d)??null,h=t=>{(function(e,t){try{let s=function(){try{return JSON.parse(localStorage.getItem(ex)??"{}")}catch{return{}}}();t?s[e]=t:delete s[e],localStorage.setItem(ex,JSON.stringify(s))}catch{}})(e.permalink,t),c(t),u(!1),p(!1)},[b,y]=(0,r.useState)(!1),[f,j]=(0,r.useState)(""),[N,v]=(0,r.useState)(null),[w,k]=(0,r.useState)(""),[S,C]=(0,r.useState)(!1),[D,$]=(0,r.useState)(!1),[I,A]=(0,r.useState)([]);async function R(t,s={}){v("reply"===t?"send":"react"===t?null:t),k("");let a=await fetch((0,ee.X)("/api/slack/inbox"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,permalink:e.permalink,...s})}),r=await a.json().catch(()=>({}));return(v(null),a.ok)?r:(k(r.error??"Failed"),null)}return(0,a.jsxs)("div",{className:`relative rounded-xl border border-gray-800 bg-gray-900/60 p-4 flex flex-col transition-opacity ${!1===e.checked?"opacity-80":""}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[!1===e.checked&&a.jsx("span",{className:"absolute top-3 right-3 text-[10px] text-gray-500 animate-pulse",children:"checking…"}),a.jsx("span",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-semibold text-white flex-shrink-0 ${ec(e.author)}`,children:(e.author||"?")[0].toUpperCase()}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm font-medium text-gray-100 truncate",children:e.author}),(0,a.jsxs)("p",{className:"text-[11px] text-gray-500 truncate",children:[e.isDm?"Direct message":`#${e.channel}`," \xb7 ",function(e){let t=Date.parse(e);if(Number.isNaN(t))return"";let s=Math.round((Date.now()-t)/6e4);return s<60?`${Math.max(1,s)}m ago`:s<1440?`${Math.round(s/60)}h ago`:`${Math.round(s/1440)}d ago`}(e.time)]})]}),!1!==e.checked&&a.jsx("a",{href:e.permalink,target:"_blank",rel:"noreferrer",className:"text-[11px] text-blue-400 hover:underline flex-shrink-0",children:"Open in Slack"})]}),a.jsx("p",{dir:"auto",onClick:()=>C(e=>!e),className:`text-sm text-gray-300 mt-3 whitespace-pre-wrap [overflow-wrap:anywhere] leading-relaxed cursor-pointer ${S?"":"line-clamp-5"}`,children:e.text}),!b&&e.suggestion&&(0,a.jsxs)("div",{className:"mt-3 rounded-lg bg-blue-950/40 border border-blue-900/50 px-3 py-2",children:[a.jsx("p",{className:"text-[10px] font-semibold text-blue-300/80 uppercase tracking-wide mb-1",children:"\uD83D\uDCA1 Suggested reply"}),a.jsx("p",{dir:"auto",className:"text-xs text-blue-100/90 whitespace-pre-wrap leading-relaxed line-clamp-4",children:e.suggestion}),a.jsx("button",{onClick:()=>{j(e.suggestion),y(!0)},className:"mt-1.5 text-[11px] text-blue-300 hover:text-blue-200",children:"Use it (you can edit before sending) →"})]}),!b&&e.checked&&!e.suggestion&&l&&a.jsx("p",{className:"mt-3 text-[11px] text-gray-500 animate-pulse",children:"\uD83D\uDCA1 Writing a suggested reply…"}),b&&(0,a.jsxs)("div",{className:"mt-3 space-y-2",children:[a.jsx("textarea",{dir:"auto",value:f,onChange:e=>j(e.target.value),rows:4,autoFocus:!0,placeholder:"Write a reply…",className:"w-full bg-gray-950 border border-gray-800 focus:border-gray-600 rounded-md px-2.5 py-2 text-sm text-gray-100 outline-none resize-y placeholder-gray-600"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:async()=>{let e=await R("draft",g?{session:{resumeId:g.resumeId,cwd:g.cwd}}:{});e?.text&&j(e.text)},disabled:!!N,className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-gray-200 hover:bg-gray-800 disabled:opacity-40",children:"draft"===N?g?"Drafting from session…":"Drafting…":"✨ Draft with Claude"}),a.jsx("button",{onClick:async()=>{await R("reply",{text:f})&&t()},disabled:!!N||!f.trim(),className:"ml-auto text-xs px-3 py-1 rounded-md bg-blue-600 hover:bg-blue-500 text-white disabled:opacity-40",children:"send"===N?"Sending…":"Send in thread"})]})]}),g&&(0,a.jsxs)("div",{className:"mt-3 flex items-center gap-2 rounded-lg border border-emerald-900/60 bg-emerald-950/30 px-2.5 py-1.5 text-xs",children:[(0,a.jsxs)("button",{onClick:()=>i(g.id),title:"Open this session",className:"text-emerald-200 hover:underline truncate flex-1 text-left",children:["\uD83D\uDD17 ",g.label]}),a.jsx("button",{onClick:()=>{o(g.id,e),p(!0)},disabled:m,title:"Send this Slack thread into the session (when it's idle) and ask it to look into it and draft a reply. Nothing is posted to Slack.",className:"px-2 py-0.5 rounded border border-emerald-800 text-emerald-200 hover:bg-emerald-900/40 disabled:opacity-50 flex-shrink-0",children:m?"Sent ✓":"Ask session"}),a.jsx("button",{onClick:()=>h(null),title:"Unlink",className:"text-gray-500 hover:text-gray-200 flex-shrink-0",children:"✕"})]}),x&&(0,a.jsxs)("select",{autoFocus:!0,defaultValue:"",onChange:e=>e.target.value&&h(e.target.value),onBlur:()=>u(!1),className:"mt-3 w-full bg-gray-950 border border-gray-700 rounded-md px-2 py-1.5 text-xs text-gray-200",children:[a.jsx("option",{value:"",disabled:!0,children:n.length?"Which session is this about?":"No running sessions in this org"}),n.map(e=>a.jsx("option",{value:e.id,children:e.label},e.id))]}),I.length>0&&(0,a.jsxs)("p",{className:"text-xs text-gray-400 mt-2",children:["You reacted ",I.join(" ")]}),D&&a.jsx("div",{className:"flex gap-1 mt-2 bg-gray-950 border border-gray-800 rounded-lg p-1 w-fit",children:eo.map(([e,t])=>a.jsx("button",{title:`:${e}:`,onClick:async()=>{$(!1),A(e=>[...e,t]),await R("react",{emoji:e})||A(e=>e.filter(e=>e!==t))},className:"w-8 h-8 rounded-md text-lg hover:bg-gray-800",children:t},e))}),w&&a.jsx("p",{className:"text-xs text-red-400 mt-2",children:w}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 pt-3 whitespace-nowrap",children:[!b&&a.jsx("button",{onClick:()=>y(!0),className:"text-xs px-3 h-7 rounded-md bg-blue-600 hover:bg-blue-500 text-white",children:"Reply"}),a.jsx("button",{onClick:()=>$(e=>!e),className:"text-sm w-8 h-7 rounded-md border border-gray-700 hover:bg-gray-800 flex items-center justify-center disabled:opacity-40",title:"React with an emoji",children:"\uD83D\uDE42"}),a.jsx("button",{onClick:()=>s(e),className:"text-sm w-8 h-7 rounded-md border border-gray-700 hover:bg-gray-800 flex items-center justify-center disabled:opacity-40",title:"Send an agent: a NEW Claude session reads the thread, looks into it and drafts a reply for you",children:"\uD83E\uDD16"}),a.jsx("button",{onClick:()=>u(e=>!e),className:`text-sm w-8 h-7 rounded-md border hover:bg-gray-800 flex items-center justify-center ${g?"border-emerald-700":"border-gray-700"}`,title:"Related session: link this message to a running session. Drafts then use what that session knows, and you can ask it directly.",children:"\uD83D\uDD17"}),a.jsx("button",{onClick:async()=>{await R("done",{react:!0})&&t()},disabled:!!N,className:"text-sm w-8 h-7 rounded-md border border-gray-700 hover:bg-gray-800 flex items-center justify-center disabled:opacity-40 ml-auto",title:"Done: adds a ✅ reaction in Slack and hides it here",children:"done"===N?"…":"✅"}),a.jsx("button",{onClick:async()=>{await R("done",{react:!1})&&t()},disabled:!!N,className:"text-xs w-7 h-7 rounded-md text-gray-500 hover:text-gray-200 hover:bg-gray-800",title:"Hide here only; nothing is posted to Slack",children:"✕"})]})]})}function em({onSendAgent:e,orgName:t,sessions:s,onOpenSession:l,onAskSession:n}){let[i,o]=(0,r.useState)(null),[d,c]=(0,r.useState)(Date.now()),[x,u]=(0,r.useState)(new Set),[m,p]=(0,r.useState)("all"),g=(e=!1)=>fetch((0,ee.X)(`/api/slack/inbox${e?"?refresh=1":""}`)).then(e=>e.json()).then(o).catch(()=>{}),h=i?.refreshing?Math.max(0,Math.round((d-i.startedAt)/1e3)):0,b=(i?.items??[]).filter(e=>!x.has(e.permalink)&&("all"===m||"dm"===m===e.isDm)),y=e=>`px-2.5 py-1 rounded-md text-xs ${e?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-200"}`;return(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col bg-gray-950 text-gray-100",children:[(0,a.jsxs)("div",{className:"px-6 pt-5 pb-4 flex flex-wrap items-center gap-3 flex-shrink-0",children:[a.jsx("h1",{className:"text-lg font-semibold",children:"Slack"}),a.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-900/50 text-purple-300 text-[10px] font-medium",title:"Slack workspace of this org's Claude setup",children:t}),a.jsx("span",{className:"text-xs text-gray-500",children:i?`${b.length} waiting on you`:"Loading…"}),(0,a.jsxs)("div",{className:"flex gap-1 bg-gray-900 border border-gray-800 rounded-lg p-0.5",children:[a.jsx("button",{onClick:()=>p("all"),className:y("all"===m),children:"All"}),a.jsx("button",{onClick:()=>p("channels"),className:y("channels"===m),children:"Mentions"}),a.jsx("button",{onClick:()=>p("dm"),className:y("dm"===m),children:"DMs"})]}),a.jsx("span",{className:"ml-auto text-[11px] text-gray-500",children:!i?.refreshing&&i?.fetchedAt?`Updated ${new Date(i.fetchedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`:""}),a.jsx("button",{onClick:()=>g(!0),disabled:i?.refreshing,className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800 disabled:opacity-40",children:"↻ Refresh"})]}),i?.refreshing&&(0,a.jsxs)("div",{className:"mx-6 mb-4 rounded-lg border border-blue-900/60 bg-blue-950/30 px-4 py-2.5 flex items-center gap-4 text-xs flex-shrink-0",children:[a.jsx("span",{className:"w-3.5 h-3.5 rounded-full border-2 border-blue-400 border-t-transparent animate-spin"}),a.jsx("span",{className:"searching"===i.stage?"text-blue-200 font-medium":"text-gray-500",children:"searching"===i.stage?"1. Finding your mentions and DMs…":"✓ Found your mentions and DMs"}),a.jsx("span",{className:"checking"===i.stage?"text-blue-200 font-medium":"suggesting"===i.stage?"text-gray-500":"text-gray-600",children:"suggesting"===i.stage?"✓ Checked which you answered":`2. Checking which you already answered${"checking"===i.stage?"…":""}`}),(0,a.jsxs)("span",{className:"suggesting"===i.stage?"text-blue-200 font-medium":"text-gray-600",children:["3. Suggesting replies","suggesting"===i.stage?"…":""]}),(0,a.jsxs)("span",{className:"ml-auto text-gray-500 tabular-nums",children:[h,"s"]})]}),i?.error&&!i.refreshing&&a.jsx("div",{className:"mx-6 mb-4 flex-shrink-0",children:a.jsx(ei.hR,{problem:i.problem??"other",detail:i.error,org:t,onRetry:()=>g(!0)})}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-6 pb-6",children:[i&&!i.refreshing&&0===b.length&&(i.error?null:a.jsx("p",{className:"text-sm text-gray-500 text-center mt-20",children:i.fetchedAt?"Nothing waiting on you. \uD83C\uDF89":"Click Refresh to check Slack."})),(0,a.jsxs)("div",{className:"grid gap-4 items-start",style:{gridTemplateColumns:"repeat(auto-fill, minmax(340px, 1fr))"},children:[i?.refreshing&&0===b.length&&Array.from({length:6},(e,t)=>(0,a.jsxs)("div",{className:"rounded-xl border border-gray-800 bg-gray-900/40 p-4 animate-pulse",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[a.jsx("span",{className:"w-8 h-8 rounded-full bg-gray-800"}),a.jsx("span",{className:"h-3 w-32 rounded bg-gray-800"})]}),(0,a.jsxs)("div",{className:"mt-4 space-y-2",children:[a.jsx("div",{className:"h-2.5 rounded bg-gray-800"}),a.jsx("div",{className:"h-2.5 rounded bg-gray-800 w-5/6"}),a.jsx("div",{className:"h-2.5 rounded bg-gray-800 w-2/3"})]})]},t)),b.map(t=>a.jsx(eu,{m:t,suggesting:i?.stage==="suggesting",onGone:()=>u(e=>new Set(e).add(t.permalink)),onAgent:e,sessions:s,onOpenSession:l,onAskSession:n},t.permalink))]})]})]})}var ep=s(6620);let eg=e=>e?e<3600?`every ${Math.round(e/60)} min`:`every ${Math.round(e/3600)} h`:null,eh=e=>e.replace(/^com\.[^.]+\.(loop\.)?/,"");function eb({l:e,onRun:t}){let[s,l]=(0,r.useState)("none"),[n,i]=(0,r.useState)(""),[o,d]=(0,r.useState)(null);async function c(){l("log"===s?"none":"log"),i((await fetch(`/api/automations/existing?log=${encodeURIComponent(e.label)}`).then(e=>e.json()).catch(()=>({log:""}))).log)}return(0,a.jsxs)("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4 flex flex-col",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${e.running?"bg-blue-400 animate-pulse":e.lastExit?"bg-red-400":"bg-emerald-500"}`}),(0,a.jsxs)("span",{className:"text-sm font-medium",children:["\uD83D\uDD01 ",eh(e.label)]}),a.jsx("span",{className:"text-xs text-gray-500",children:eg(e.everySec)??(e.calendar?"on a schedule":"")}),e.model&&a.jsx("span",{className:"ml-auto text-[10px] px-1.5 py-0.5 rounded bg-gray-800 text-gray-400",children:e.model.replace(/^claude-/,"")})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 mt-1.5",children:[e.running?a.jsx("span",{className:"text-blue-300",children:"Running now"}):e.lastExit?(0,a.jsxs)("span",{className:"text-red-400",children:["Last run failed (exit ",e.lastExit,")"]}):"Idle",e.lastRun&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 last run ",e.lastRun.at.slice(5,16)]})]}),e.lastRun?.output&&a.jsx("p",{className:"text-xs text-gray-300 mt-2 whitespace-pre-wrap line-clamp-3 bg-gray-950/60 rounded px-2 py-1.5 font-mono",children:e.lastRun.output}),"prompt"===s&&e.prompt&&a.jsx("pre",{className:"text-[11px] text-gray-300 mt-2 whitespace-pre-wrap bg-gray-950 border border-gray-800 rounded p-2 max-h-60 overflow-y-auto",children:e.prompt}),"log"===s&&a.jsx("pre",{className:"text-[11px] text-gray-300 mt-2 whitespace-pre-wrap bg-gray-950 border border-gray-800 rounded p-2 max-h-60 overflow-y-auto",children:n||"Loading…"}),o&&a.jsx("p",{className:"text-xs text-gray-400 mt-2",children:o}),(0,a.jsxs)("div",{className:"flex gap-2 mt-3",children:[a.jsx("button",{onClick:async()=>d(await t()),disabled:e.running,className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800 disabled:opacity-40",children:"▶ Run now"}),e.prompt&&a.jsx("button",{onClick:()=>l("prompt"===s?"none":"prompt"),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Prompt"}),e.logFile&&a.jsx("button",{onClick:c,className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Log"})]}),a.jsx("p",{className:"text-[10px] text-gray-600 mt-2 font-mono truncate",title:e.command,children:e.label})]})}function ey(){let[e,t]=(0,r.useState)(null),s=()=>fetch("/api/automations/existing").then(e=>e.json()).then(t).catch(()=>{});if(!e||!e.loops.length&&!e.hooks.length)return null;async function l(e){let t=await fetch("/api/automations/existing",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"run",label:e})});return setTimeout(s,1500),t.ok?"Started.":(await t.json().catch(()=>({}))).error??"Could not start"}return(0,a.jsxs)("section",{children:[a.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-2",children:"Already running on this Mac"}),a.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(340px, 1fr))"},children:e.loops.map(e=>a.jsx(eb,{l:e,onRun:()=>l(e.label)},e.label))}),e.hooks.length>0&&(0,a.jsxs)("details",{className:"mt-3",children:[(0,a.jsxs)("summary",{className:"text-xs text-gray-400 cursor-pointer",children:["Claude Code hooks (",e.hooks.length,")"]}),a.jsx("ul",{className:"mt-2 space-y-1",children:e.hooks.map((e,t)=>(0,a.jsxs)("li",{className:"text-xs text-gray-400 flex gap-2",children:[(0,a.jsxs)("span",{className:"text-gray-200 w-40 flex-shrink-0",children:[e.event,e.matcher&&"*"!==e.matcher?` (${e.matcher})`:""]}),a.jsx("span",{className:"text-gray-500 flex-shrink-0",children:e.org}),a.jsx("code",{className:"truncate text-gray-500",children:e.command})]},t))})]})]})}function ef({it:e,onSend:t,onDismiss:s,onRedraft:l}){let[n,i]=(0,r.useState)(e.draft??""),[o,d]=(0,r.useState)(!1),[c,x]=(0,r.useState)(!1);return(0,a.jsxs)("div",{className:"rounded-lg border border-gray-800 bg-gray-950/50 p-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:"font-medium text-gray-200",children:e.author}),a.jsx("a",{href:e.permalink,target:"_blank",rel:"noreferrer",className:"ml-auto text-blue-400 hover:underline",children:"Open in Slack"})]}),a.jsx("p",{dir:"auto",className:"text-sm text-gray-300 mt-1.5 line-clamp-4 whitespace-pre-wrap [overflow-wrap:anywhere]",children:e.text}),"drafting"===e.state&&a.jsx("p",{className:"text-xs text-gray-500 mt-2 animate-pulse",children:"Drafting a reply…"}),"failed"===e.state&&(0,a.jsxs)("p",{className:"text-xs text-red-400 mt-2",children:["Draft failed: ",e.error," ",a.jsx("button",{onClick:l,className:"underline",children:"Try again"})]}),"sent"===e.state&&(0,a.jsxs)("p",{className:"text-xs text-emerald-400 mt-2",children:["✓ Answered: ",a.jsx("span",{className:"text-gray-400",children:e.draft})]}),"sending"===e.state&&a.jsx("p",{className:"text-xs text-blue-300 mt-2 animate-pulse",children:"Posting in Slack…"}),"pending"===e.state&&(0,a.jsxs)("div",{className:"mt-2 rounded-md bg-blue-950/40 border border-blue-900/50 p-2",children:[a.jsx("p",{className:"text-[10px] font-semibold text-blue-300/80 uppercase tracking-wide mb-1",children:"\uD83D\uDCA1 Draft reply"}),o?a.jsx("textarea",{dir:"auto",value:n,onChange:e=>i(e.target.value),rows:4,className:"w-full bg-gray-950 border border-gray-800 rounded px-2 py-1.5 text-xs text-gray-100 outline-none"}):a.jsx("p",{dir:"auto",className:"text-xs text-blue-100/90 whitespace-pre-wrap",children:e.draft}),(0,a.jsxs)("div",{className:"flex gap-2 mt-2",children:[a.jsx("button",{onClick:()=>{x(!0),t(o?n:e.draft??"")},disabled:c,className:"text-xs px-2.5 py-1 rounded-md bg-blue-600 hover:bg-blue-500 text-white disabled:opacity-50",children:c?"Posting…":"Send in thread"}),!o&&a.jsx("button",{onClick:()=>{i(e.draft??""),d(!0)},className:"text-xs px-2 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Edit"}),a.jsx("button",{onClick:l,className:"text-xs px-2 py-1 rounded-md text-gray-400 hover:text-white",children:"Redraft"}),a.jsx("button",{onClick:s,className:"ml-auto text-xs px-2 py-1 rounded-md text-gray-500 hover:text-white",children:"Dismiss"})]})]})]})}function ej({log:e}){if(!e.length)return null;let t=e=>new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return(0,a.jsxs)("details",{className:"mt-3 group",children:[(0,a.jsxs)("summary",{className:"text-xs text-gray-400 hover:text-gray-200 cursor-pointer select-none list-none",children:[a.jsx("span",{className:"inline-block transition-transform group-open:rotate-90",children:"▸"})," Activity log (",e.length,")"]}),a.jsx("ol",{className:"mt-2 border-l border-gray-800 ml-1.5 pl-3 space-y-1.5",children:[...e].reverse().map((e,s)=>(0,a.jsxs)("li",{className:"text-xs",children:[a.jsx("span",{className:"text-gray-500 tabular-nums mr-2",children:t(e.t)}),a.jsx("span",{className:"text-gray-300",children:e.text}),e.link&&a.jsx("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"ml-2 text-blue-400 hover:underline",children:"Slack ↗"}),e.detail&&(0,a.jsxs)("details",{className:"mt-1",children:[a.jsx("summary",{className:"text-[11px] text-gray-500 hover:text-gray-300 cursor-pointer",children:"show text"}),a.jsx("p",{dir:"auto",className:"mt-1 whitespace-pre-wrap text-gray-400 bg-gray-950/60 border border-gray-800 rounded px-2 py-1.5 [overflow-wrap:anywhere]",children:e.detail})]})]},e.t+":"+s))})]})}function eN({pipelines:e,watchers:t,sessions:s,nameOf:l,onOpen:n,onStop:i,onNewWatcher:o,onEditWatcher:d,watcherCmd:c,showMacLoops:u}){let[m,p]=(0,r.useState)(""),g=[...e].sort((e,t)=>Number((0,x.An)(t))-Number((0,x.An)(e))||t.updatedAt-e.updatedAt),h=[...t].sort((e,t)=>Number("running"===t.status)-Number("running"===e.status)),b="rounded-xl border border-gray-800 bg-gray-900/50 p-4 flex flex-col gap-2",y=e.filter(x.An).length+t.filter(e=>"running"===e.status).length;return(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col bg-gray-950 text-gray-100",children:[(0,a.jsxs)("div",{className:"px-6 pt-5 pb-3 flex items-baseline gap-3 flex-shrink-0",children:[a.jsx("h1",{className:"text-lg font-semibold",children:"Automations"}),(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:[y," running"]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-6 pb-6 space-y-6",children:[(0,a.jsxs)("section",{children:[a.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-2",children:"Create an automation"}),(0,a.jsxs)("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))"},children:[(0,a.jsxs)("div",{className:b,children:[a.jsx("p",{className:"text-sm font-medium",children:"\uD83D\uDEA2 Ship it"}),a.jsx("p",{className:"text-xs text-gray-400",children:"Watches a session's PRs: posts them for review in Slack, tracks reviewers and CI, and suggests fixes for you to send."}),a.jsx(F.h,{options:s,value:m,onChange:p,onPick:e=>{p(""),n(e.id)},placeholder:"Pick a session to start…",className:"w-full bg-gray-800 border border-gray-700 rounded-md px-2.5 py-1.5 text-xs outline-none placeholder-gray-500"})]}),(0,a.jsxs)("div",{className:b,children:[a.jsx("p",{className:"text-sm font-medium",children:"\uD83D\uDC42 Slack channel watcher"}),a.jsx("p",{className:"text-xs text-gray-400",children:"Finds new unanswered questions in a channel and drafts replies, optionally with a session's knowledge. You approve or let it answer."}),a.jsx("button",{onClick:o,className:"mt-auto text-xs px-3 py-1.5 rounded-md bg-blue-600 hover:bg-blue-500 w-fit",children:"Set up"})]}),[["\uD83D\uDCF0 Daily digest","Every morning: your open PRs, Slack mentions and meetings in one summary."],["⏰ Review nudges","Pings reviewers in Slack when a PR has waited for review over a day."]].map(([e,t])=>(0,a.jsxs)("div",{className:`${b} opacity-60`,children:[(0,a.jsxs)("p",{className:"text-sm font-medium",children:[e," ",a.jsx("span",{className:"text-[10px] text-gray-500 font-normal",children:"soon"})]}),a.jsx("p",{className:"text-xs text-gray-400",children:t})]},e))]})]}),u&&a.jsx(ey,{}),h.map(e=>{let t=e.items.filter(e=>"pending"===e.state||"drafting"===e.state||"sending"===e.state||"failed"===e.state),r="text-[11px] px-2 py-0.5 rounded-full border border-gray-700 text-gray-400 whitespace-nowrap",n=(e.knowledge??"").split("\n").map(e=>e.trim()).filter(Boolean);return(0,a.jsxs)("section",{className:"rounded-xl border border-gray-800 bg-gray-900/40 p-4",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 flex-wrap",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${"running"===e.status?"bg-emerald-400":"bg-gray-600"}`,title:"running"===e.status?"Running":"Stopped"}),(0,a.jsxs)("span",{className:"text-sm font-semibold",children:["Slack watcher \xb7 #",e.channel.name]}),e.checking&&a.jsx("span",{className:"text-[11px] text-blue-300 animate-pulse",children:"checking…"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mt-2 flex-wrap",children:[(0,a.jsxs)("select",{value:e.liveId??"",onChange:t=>c("watcher-set-session",{id:e.id,liveId:t.target.value||null}),title:"Session whose knowledge drafts use (a copy; the session is never touched)",className:"text-[11px] bg-gray-900 border border-gray-700 rounded-full px-2 py-0.5 text-gray-300 max-w-[240px]",children:[a.jsx("option",{value:"",children:"\uD83E\uDDE0 General knowledge"}),e.liveId&&!s.some(t=>t.id===e.liveId)&&(0,a.jsxs)("option",{value:e.liveId,children:["\uD83E\uDDE0 ",l(e.liveId)]}),s.map(e=>(0,a.jsxs)("option",{value:e.id,children:["\uD83E\uDDE0 ",e.label]},e.id))]}),a.jsx("span",{className:`${r} ${"auto"===e.mode?"border-amber-700/60 text-amber-300":""}`,children:"auto"===e.mode?"Answers automatically":"You approve each reply"}),(0,a.jsxs)("span",{className:r,children:["Every ",e.intervalMin," min"]}),(0,a.jsxs)("span",{className:r,title:n.join("\n")||"No extra sources. Edit to add links, folders, channels or notes.",children:["\uD83D\uDCDA ",n.length," source",1===n.length?"":"s"]}),e.instructions&&a.jsx("span",{className:r,title:e.instructions,children:"\uD83D\uDCDD Rules"})]})]}),(0,a.jsxs)("span",{className:"flex gap-2 flex-shrink-0",children:["running"===e.status&&a.jsx("button",{onClick:()=>c("watcher-run",{id:e.id}),disabled:e.checking,className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800 disabled:opacity-40",children:"Check now"}),a.jsx("button",{onClick:()=>d(e),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Edit"}),"running"===e.status&&a.jsx("button",{onClick:()=>c("watcher-stop",{id:e.id}),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-red-400 hover:bg-red-950/40",children:"Stop"})]})]}),a.jsx("div",{className:"mt-3",children:t.length?a.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(360px, 1fr))"},children:t.map(t=>a.jsx(ef,{it:t,onSend:s=>c("watcher-send",{id:e.id,permalink:t.permalink,text:s}),onDismiss:()=>c("watcher-dismiss",{id:e.id,permalink:t.permalink}),onRedraft:()=>c("watcher-redraft",{id:e.id,permalink:t.permalink})},t.permalink))}):(0,a.jsxs)("p",{className:"text-xs text-gray-500",children:["Nothing waiting on you. Last: ",e.log.at(-1)?.text??"no checks yet"]})}),a.jsx(ej,{log:e.log})]},e.id)}),g.map(e=>(0,a.jsxs)("section",{className:"rounded-xl border border-gray-800 bg-gray-900/40 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${(0,x.An)(e)?"bg-blue-400 animate-pulse":"bg-gray-600"}`}),(0,a.jsxs)("button",{onClick:()=>n(e.liveId),className:"text-sm font-medium hover:underline truncate",children:["\uD83D\uDEA2 ",l(e.liveId)]}),a.jsx("span",{className:"text-xs text-gray-500 truncate",children:(0,x.Vm)(e)}),(0,a.jsxs)("span",{className:"ml-auto flex gap-2 flex-shrink-0",children:[a.jsx("button",{onClick:()=>n(e.liveId),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Open"}),(0,x.An)(e)&&a.jsx("button",{onClick:()=>i(e.id),className:"text-xs px-2.5 py-1 rounded-md border border-gray-700 text-red-400 hover:bg-red-950/40",children:"Stop"})]})]}),e.prs.length>0?a.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(420px, 1fr))"},children:e.prs.map(t=>a.jsx(ep.G0,{t:t,slackSet:!!e.config.slackChannel,max:e.config.maxRounds},t.url))}):a.jsx("p",{className:"text-xs text-gray-500",children:e.log.at(-1)?.text})]},e.id))]})]})}function ev({orgName:e,live:t,nameOf:s,meetings:l,notes:n,pipelines:i,watchers:o,inbox:d,usageOrg:c,onAttach:u,onOpen:m,onNewSession:p,onRecord:g}){let[h,b]=(0,r.useState)(null),[y,f]=(0,r.useState)(!1);if(!y)return a.jsx("div",{className:"absolute inset-0 bg-gray-950"});let j=t.filter(e=>"waiting"===e.status),N=t.filter(e=>"thinking"===e.status),v=i.reduce((e,t)=>e+(t.suggestion?1:0)+t.prs.filter(e=>e.suggestion).length,0),w=i.flatMap(e=>e.prs.filter(e=>"ready"===e.state)),k=o.reduce((e,t)=>e+t.items.filter(e=>"pending"===e.state).length,0),S=d?.sections.needsReview.length??0,C=d?.sections.returned.length??0,D=n.filter(e=>e.remindAt&&!e.reminderDone&&e.remindAt>Date.now()).sort((e,t)=>e.remindAt-t.remindAt).slice(0,4),$=[...l].sort((e,t)=>t.startedAt-e.startedAt).slice(0,4),I=new Date().getHours(),A=[...j.slice(0,6).map(e=>({key:`w-${e.id}`,text:s(e.id),sub:"waiting for your input",tone:"text-green-300",go:()=>u(e.id)})),...C?[{key:"ret",text:`${C} PR${C>1?"s":""} back with you`,sub:"changes requested or CI failing",tone:"text-red-300",go:()=>m("prdash")}]:[],...S?[{key:"rev",text:`${S} review request${S>1?"s":""}`,sub:"PRs waiting for your review",tone:"text-amber-300",go:()=>m("prdash")}]:[],...w.length?[{key:"ready",text:`${w.length} PR${w.length>1?"s":""} ready to merge`,sub:"approved, CI green",tone:"text-emerald-300",go:()=>m("automations")}]:[],...v?[{key:"sug",text:`${v} automation suggestion${v>1?"s":""}`,sub:"review and send to the session",tone:"text-amber-300",go:()=>m("automations")}]:[],...k?[{key:"drafts",text:`${k} Slack draft${k>1?"s":""} to approve`,sub:"from channel watchers",tone:"text-blue-300",go:()=>m("automations")}]:[],...h?[{key:"slack",text:`${h} Slack message${h>1?"s":""} waiting on you`,sub:"mentions and DMs not answered",tone:"text-blue-300",go:()=>m("slack")}]:[]],R=(e,t,s,r)=>(0,a.jsxs)("button",{onClick:r,disabled:!r,className:"text-left rounded-xl border border-gray-800 bg-gray-900/50 p-4 hover:enabled:border-gray-600 transition-colors",children:[a.jsx("p",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:e}),a.jsx("p",{className:"text-2xl font-semibold text-gray-100 mt-1 tabular-nums",children:t}),a.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:s})]});return a.jsx("div",{className:"absolute inset-0 overflow-y-auto bg-gray-950 text-gray-100",children:(0,a.jsxs)("div",{className:"max-w-6xl mx-auto px-6 py-6 space-y-6",children:[(0,a.jsxs)("div",{className:"flex items-end gap-3 flex-wrap",children:[(0,a.jsxs)("div",{children:[a.jsx("h1",{className:"text-2xl font-semibold",children:I<12?"Good morning":I<18?"Good afternoon":"Good evening"}),(0,a.jsxs)("p",{className:"text-sm text-gray-500 mt-0.5",children:[new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})," \xb7 ",a.jsx("span",{className:"text-purple-300",children:e})]})]}),(0,a.jsxs)("div",{className:"ml-auto flex gap-2",children:[a.jsx("button",{onClick:p,className:"text-sm px-3 py-1.5 rounded-md bg-blue-600 hover:bg-blue-500",children:"+ New session"}),a.jsx("button",{onClick:g,className:"text-sm px-3 py-1.5 rounded-md border border-gray-700 hover:bg-gray-800",children:"● Record meeting"}),a.jsx("span",{className:"text-xs text-gray-500 self-center hidden md:inline",children:"⌘K to search"})]})]}),(0,a.jsxs)("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(190px, 1fr))"},children:[R("Sessions",t.length,`${N.length} working \xb7 ${j.length} waiting`),R("Spend today",c?`$${c.today.toFixed(2)}`:"—",c?`$${c.week.toFixed(0)} this week`:"API-equivalent",()=>m("usagedash")),R("Pull requests",(d?.sections.waiting.length??0)+C,`${C} need you \xb7 ${d?.sections.mergedRecent.length??0} merged this week`,()=>m("prdash")),R("Automations",i.filter(x.An).length+o.filter(e=>"running"===e.status).length,"running",()=>m("automations")),R("Slack",h??"—","waiting on you",()=>m("slack"))]}),(0,a.jsxs)("div",{className:"grid gap-6 lg:grid-cols-3",children:[(0,a.jsxs)("section",{className:"lg:col-span-2 rounded-xl border border-gray-800 bg-gray-900/40 p-4",children:[a.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-3",children:"Needs you"}),0===A.length?a.jsx("p",{className:"text-sm text-gray-500 py-6 text-center",children:"You're all caught up. \uD83C\uDF89"}):a.jsx("ul",{className:"divide-y divide-gray-800/70",children:A.map(e=>a.jsx("li",{children:(0,a.jsxs)("button",{onClick:e.go,className:"w-full text-left py-2.5 flex items-center gap-3 hover:bg-gray-800/30 rounded px-2 -mx-2",children:[a.jsx("span",{className:`text-sm font-medium truncate ${e.tone}`,children:e.text}),e.sub&&a.jsx("span",{className:"text-xs text-gray-500 truncate",children:e.sub}),a.jsx("span",{className:"ml-auto text-gray-600",children:"→"})]})},e.key))}),N.length>0&&(0,a.jsxs)("div",{className:"mt-4",children:[a.jsx("p",{className:"text-[11px] uppercase tracking-wide text-gray-500 mb-1.5",children:"Working now"}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:N.slice(0,12).map(e=>(0,a.jsxs)("button",{onClick:()=>u(e.id),className:"text-xs px-2 py-1 rounded-md bg-gray-800 hover:bg-gray-700 text-gray-300 max-w-[220px] truncate",children:[a.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-yellow-400 animate-pulse mr-1.5"}),s(e.id)]},e.id))})]})]}),(0,a.jsxs)("section",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"rounded-xl border border-gray-800 bg-gray-900/40 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center mb-2",children:[a.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide",children:"Recent meetings"}),a.jsx("button",{onClick:()=>m("meetinglib"),className:"ml-auto text-xs text-blue-400 hover:underline",children:"All"})]}),0===$.length?a.jsx("p",{className:"text-xs text-gray-500",children:"No recordings yet."}):a.jsx("ul",{className:"space-y-1.5",children:$.map(e=>a.jsx("li",{children:(0,a.jsxs)("button",{onClick:()=>m({meetingId:e.id}),className:"w-full text-left flex gap-2 text-sm hover:text-white text-gray-300",children:["recording"===e.status&&a.jsx("span",{className:"w-2 h-2 mt-1.5 rounded-full bg-red-500 animate-pulse"}),a.jsx("span",{className:"truncate",children:e.title}),a.jsx("span",{className:"ml-auto text-xs text-gray-500 flex-shrink-0",children:new Date(e.startedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]})},e.id))})]}),(0,a.jsxs)("div",{className:"rounded-xl border border-gray-800 bg-gray-900/40 p-4",children:[(0,a.jsxs)("div",{className:"flex items-center mb-2",children:[a.jsx("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide",children:"Reminders"}),a.jsx("button",{onClick:()=>m("notes"),className:"ml-auto text-xs text-blue-400 hover:underline",children:"Notes"})]}),0===D.length?a.jsx("p",{className:"text-xs text-gray-500",children:"No upcoming reminders."}):a.jsx("ul",{className:"space-y-1.5",children:D.map(e=>(0,a.jsxs)("li",{className:"flex gap-2 text-sm text-gray-300",children:[a.jsx("span",{className:"truncate",children:e.text.split("\n").find(e=>e.trim())??"Note"}),(0,a.jsxs)("span",{className:"ml-auto text-xs text-amber-400 flex-shrink-0",children:["⏰ ",new Date(e.remindAt).toLocaleString(void 0,{weekday:"short",hour:"2-digit",minute:"2-digit"})]})]},e.id))})]})]})]})]})})}function ew({sessions:e,error:t,onCreate:s,onClose:l,initial:n}){let[i,o]=(0,r.useState)(n?n.channel.name:""),[d,c]=(0,r.useState)(n?.channel??null),[x,u]=(0,r.useState)(n?.liveId??null),[m,p]=(0,r.useState)(n?.mode??"approve"),[g,h]=(0,r.useState)(n?.intervalMin??5),[b,y]=(0,r.useState)(n?.knowledge??""),[f,j]=(0,r.useState)(n?.instructions??""),N="w-full bg-gray-800 border border-gray-700 focus:border-gray-500 rounded-md px-2.5 py-1.5 text-sm text-white outline-none placeholder-gray-500",v=(d?.name??i).replace(/^#/,"").trim();return a.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:l,children:(0,a.jsxs)("div",{className:"w-full max-w-lg bg-gray-900 border border-gray-700 rounded-xl p-5 text-white",onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("h2",{className:"text-base font-semibold",children:n?`Edit #${n.channel.name} watcher`:"Watch a Slack channel"}),a.jsx("button",{onClick:l,className:"text-gray-500 hover:text-white","aria-label":"Close",children:"✕"})]}),a.jsx("p",{className:"text-xs text-gray-500 mb-4",children:"Every few minutes it finds new questions in the channel that nobody answered and drafts a reply."}),a.jsx("label",{className:"block text-xs text-gray-400 mb-1",children:"Channel"}),n?(0,a.jsxs)("p",{className:"text-sm text-gray-200",children:["#",n.channel.name]}):a.jsx(O.a,{value:i,onChange:(e,t)=>{o(e),c(t)},className:N}),a.jsx("label",{className:"block text-xs text-gray-400 mt-4 mb-1",children:"Answer with the knowledge of a session (optional)"}),(0,a.jsxs)("select",{value:x??"",onChange:e=>u(e.target.value||null),className:N,title:"Pick a running session whose work the channel is about. Drafts then use that session's conversation and code.",children:[a.jsx("option",{value:"",children:"None: general knowledge only"}),e.map(e=>a.jsx("option",{value:e.id,children:e.label},e.id))]}),0===e.length&&a.jsx("p",{className:"text-[11px] text-amber-400/80 mt-1",children:"No running sessions in this org. Start one from New Session to use its knowledge."}),a.jsx("p",{className:"text-[11px] text-gray-500 mt-1",children:"Drafts come from a copy of that session's conversation and code. Your session itself is never touched."}),a.jsx("label",{className:"block text-xs text-gray-400 mt-4 mb-1",title:"Claude checks these before drafting. Web pages, files or folders on this Mac, other Slack channels, or plain notes.",children:"Knowledge sources (optional)"}),a.jsx("textarea",{value:b,onChange:e=>y(e.target.value),rows:3,placeholder:"One per line, e.g.\nhttps://docs.example.com/runbook\n/Users/you/repos/infra/docs\n#deployment-runbooks\nProd cluster is aks-tstr-prod-eus2",className:`${N} font-mono text-xs`}),a.jsx("label",{className:"block text-xs text-gray-400 mt-3 mb-1",title:"Rules for every reply: tone, what never to promise, who to tag",children:"How to answer (optional)"}),a.jsx("textarea",{value:f,onChange:e=>j(e.target.value),rows:2,placeholder:"e.g. Never say a deploy is done. Tag @devops for prod changes. Keep it short.",className:`${N} text-xs`}),(0,a.jsxs)("div",{className:"flex gap-4 mt-4 text-sm",children:[(0,a.jsxs)("label",{className:"flex items-center gap-1.5",children:[a.jsx("input",{type:"radio",checked:"approve"===m,onChange:()=>p("approve")}),"I approve each reply"]}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5",children:[a.jsx("input",{type:"radio",checked:"auto"===m,onChange:()=>p("auto")}),"Answer automatically"]})]}),"auto"===m&&a.jsx("p",{className:"text-[11px] text-amber-400 mt-1",children:"Replies are posted in Slack as you, without review."}),(0,a.jsxs)("label",{className:"block text-xs text-gray-400 mt-4",children:["Check every",(0,a.jsxs)("span",{className:"flex items-center gap-2 mt-1",children:[a.jsx("input",{type:"number",min:2,max:60,value:g,onChange:e=>h(Number(e.target.value)),className:`${N} w-20`})," minutes"]})]}),t&&a.jsx("p",{className:"text-xs text-red-400 mt-3",children:t}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 mt-5",children:[a.jsx("button",{onClick:l,className:"px-3 py-1.5 text-sm text-gray-400 hover:text-white",children:"Cancel"}),a.jsx("button",{disabled:!v,onClick:()=>{s({channel:{id:d?.id??"",name:v},liveId:x,mode:m,intervalMin:g,knowledge:b,instructions:f}),l()},className:"px-3 py-1.5 text-sm rounded-md bg-blue-600 hover:bg-blue-500 disabled:opacity-40",children:n?"Save":"Start watching"})]})]})})}let ek=[["account","Claude account"],["sessions","Sessions"],["power","Power"],["notifications","Notifications"],["meetings","Meetings"]];function eS({id:e,title:t,desc:s,children:r}){return(0,a.jsxs)("section",{id:`settings-${e}`,className:"scroll-mt-6 rounded-xl border border-gray-800 bg-gray-900/40 p-5",children:[a.jsx("h2",{className:"text-sm font-semibold text-gray-100",children:t}),a.jsx("p",{className:"text-xs text-gray-500 mt-0.5 mb-4",children:s}),a.jsx("div",{className:"space-y-3",children:r})]})}function eC({onClose:e}){let[t,s]=(0,r.useState)(!0),[l,n]=(0,r.useState)(300),[i,o]=(0,r.useState)(!1),[d,x]=(0,r.useState)(!0),[u,m]=(0,r.useState)(!1),[p,g]=(0,r.useState)(!1),[h,b]=(0,r.useState)("unsupported"),[y,f]=(0,r.useState)("idle"),[j,N]=(0,r.useState)(""),[v,w]=(0,r.useState)(null),[k,S]=(0,r.useState)("none"),[C,D]=(0,r.useState)(""),[$,I]=(0,r.useState)(""),[A,R]=(0,r.useState)(""),[O,P]=(0,r.useState)(!1),[M,L]=(0,r.useState)(null),[T,E]=(0,r.useState)("login"),[U,F]=(0,r.useState)(""),[_,J]=(0,r.useState)(!1),B=e=>t=>{e(t),P(!0),f("idle")},H=l>=100&&l<=1e3;async function W(){f("saving");try{if(!(await fetch("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoCompact:{enabled:t,windowTokens:1e3*l},notifications:{enabled:d},sessions:{skipPermissions:u},power:{keepAwake:p}})})).ok)throw Error("Could not save settings");if(O){let e="azure"===k?{provider:"azure",endpoint:C,deployment:$,apiKey:A}:"openai"===k?{provider:"openai",apiKey:A}:{provider:"none"},t=await fetch("/api/settings/transcription",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();if(!t.ok)throw Error(s.error??"Could not save transcription");w(s),R(""),P(!1)}if(_){let e=await fetch("/api/settings/auth",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify("apiKey"===T?{mode:"apiKey",apiKey:U}:{mode:"login"})}),t=await e.json();if(!e.ok)throw Error(t.error??"Could not save sign-in");L(t),F(""),J(!1)}c=d,window.dispatchEvent(new CustomEvent("polyergon:settings-changed")),f("saved")}catch(e){N(e.message||"Could not save settings"),f("error")}}return(0,a.jsxs)("div",{className:"absolute inset-0 flex bg-gray-950 text-gray-100",children:[(0,a.jsxs)("nav",{className:"hidden md:flex flex-col gap-0.5 w-48 flex-shrink-0 border-r border-gray-800 px-3 py-6",children:[a.jsx("h1",{className:"text-lg font-semibold px-2 mb-3",children:"Settings"}),ek.map(([e,t])=>a.jsx("button",{onClick:()=>document.getElementById(`settings-${e}`)?.scrollIntoView({behavior:"smooth"}),className:"text-left text-sm px-2 py-1.5 rounded-md text-gray-400 hover:text-gray-100 hover:bg-gray-800/60",children:t},e))]}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col min-w-0",children:[a.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6",children:(0,a.jsxs)("div",{className:"max-w-2xl space-y-5",children:[a.jsx("h1",{className:"text-lg font-semibold md:hidden",children:"Settings"}),(0,a.jsxs)(eS,{id:"account",title:"Claude account",desc:"How sessions sign in to Claude. Each org has its own login.",children:[(0,a.jsxs)("div",{className:"flex gap-4 text-sm",children:[(0,a.jsxs)("label",{className:"flex items-center gap-1.5",children:[a.jsx("input",{type:"radio",checked:"login"===T,onChange:()=>{E("login"),J(!0),f("idle")}}),"Claude login"]}),(0,a.jsxs)("label",{className:"flex items-center gap-1.5",children:[a.jsx("input",{type:"radio",checked:"apiKey"===T,onChange:()=>{E("apiKey"),J(!0),f("idle")}}),"API key"]})]}),"login"===T&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs rounded border border-gray-800 bg-gray-900/60 px-2.5 py-2",children:[M?M.login?.loggedIn?(0,a.jsxs)("span",{className:"text-emerald-300 flex-1",children:["✓ Signed in",M.login.email?` as ${M.login.email}`:"",M.login.orgName?` \xb7 ${M.login.orgName}`:"",M.login.plan?` \xb7 ${M.login.plan}`:""]}):M.login?a.jsx("span",{className:"text-amber-300 flex-1",children:"Not signed in. Sessions in this org will ask you to log in."}):a.jsx("span",{className:"text-gray-500 flex-1",children:"Couldn't check sign-in (is the claude CLI installed?)"}):a.jsx("span",{className:"text-gray-500",children:"Checking sign-in…"}),M&&a.jsx("button",{type:"button",onClick:()=>{(0,ei.w0)(),e()},title:"Opens a new session in this org running /login. Follow the browser sign-in, then come back.",className:"px-2 py-1 rounded border border-gray-700 text-gray-200 hover:bg-gray-800",children:M.login?.loggedIn?"Switch account":"Sign in"})]}),"apiKey"===T&&(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Anthropic API key",a.jsx("input",{type:"password",autoComplete:"off",value:U,onChange:e=>{F(e.target.value),J(!0),f("idle")},placeholder:M?.keyHint?`Saved (${M.keyHint}). Leave blank to keep it.`:"sk-ant-…",className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-white mt-1"})]}),a.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"login"===T?"Sessions use the account you logged in with in Claude Code (subscription or SSO). Each org has its own login.":"Sessions bill this API key at API rates. Claude Code may ask once, in the session, to confirm using the key. Applies to sessions started, resumed or restarted after you save."})]}),(0,a.jsxs)(eS,{id:"sessions",title:"Sessions",desc:"How new Claude and Copilot sessions run.",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm font-medium",children:[a.jsx("input",{type:"checkbox",checked:t,disabled:!i,onChange:e=>{s(e.target.checked),f("idle")}}),"Auto-compact Claude sessions"]}),(0,a.jsxs)("label",{className:`block text-sm ${t?"":"opacity-40"}`,children:[a.jsx("span",{className:"text-gray-400",children:"Compact when context reaches"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[a.jsx("input",{type:"number",min:100,max:1e3,step:50,value:l,disabled:!t||!i,onChange:e=>{n(Number(e.target.value)),f("idle")},className:"w-28 bg-gray-800 border border-gray-700 rounded px-2 py-1 text-white"}),a.jsx("span",{className:"text-gray-400",children:"k tokens"})]}),!H&&(0,a.jsxs)("p",{className:"text-xs text-red-400 mt-1",children:["Pick a value from ",100,"k to ",1e3,"k."]})]}),a.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Claude compacts on its own between turns, a little before this limit. Recommended: 250k–300k. Applies to sessions started, resumed or restarted after you save. Copilot sessions are not affected."}),a.jsx("div",{className:"border-t border-gray-800 pt-3"}),(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm font-medium",children:[a.jsx("input",{type:"checkbox",checked:u,disabled:!i,onChange:e=>{m(e.target.checked),f("idle")}}),"Skip permission prompts"]}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 leading-relaxed",children:["Sessions run commands and edit files without asking (Claude ",a.jsx("code",{children:"bypassPermissions"}),", Copilot ",a.jsx("code",{children:"--allow-all"}),"). Applies to sessions started, resumed or restarted after you save."]}),u&&a.jsx("p",{className:"text-xs text-amber-400",children:"Only use this with folders and tasks you trust."})]}),(0,a.jsxs)(eS,{id:"power",title:"Power",desc:"Keep sessions and automations running when you step away.",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm font-medium",title:"Uses macOS caffeinate while Polyergon runs",children:[a.jsx("input",{type:"checkbox",checked:p,disabled:!i,onChange:e=>{g(e.target.checked),f("idle")}}),"Keep working while the Mac is locked or idle"]}),a.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Stops the Mac from going to sleep on its own, so sessions, Slack watchers and automations keep running. The screen can still lock and turn off. Closing the lid still puts the Mac to sleep. Uses more battery; turns off when Polyergon stops."}),a.jsx("p",{className:"text-xs text-gray-500",children:"Locking the screen alone never stops Polyergon; only sleep does."})]}),(0,a.jsxs)(eS,{id:"notifications",title:"Notifications",desc:"Desktop alerts from this browser.",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-sm font-medium",children:[a.jsx("input",{type:"checkbox",checked:d,disabled:!i,onChange:e=>{x(e.target.checked),f("idle")}}),"Desktop notifications"]}),a.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Alerts when a session needs your input, and for note reminders."}),d&&"default"===h&&a.jsx("button",{onClick:function(){"undefined"!=typeof Notification&&Notification.requestPermission().then(b)},className:"text-xs px-2.5 py-1 rounded-md bg-gray-800 hover:bg-gray-700 border border-gray-700",children:"Allow notifications in Chrome"}),d&&"denied"===h&&a.jsx("p",{className:"text-xs text-amber-400",children:"Chrome is blocking notifications for this site. Click the icon left of the address bar, then allow Notifications."}),d&&"granted"===h&&a.jsx("p",{className:"text-xs text-green-400",children:"Chrome permission: allowed"}),"unsupported"===h&&a.jsx("p",{className:"text-xs text-gray-500",children:"This browser does not support notifications."})]}),(0,a.jsxs)(eS,{id:"meetings",title:"Meetings",desc:"Speech-to-text for recorded meetings.",children:[a.jsx("p",{className:"text-sm font-medium",children:"Transcription service"}),(0,a.jsxs)("select",{value:k,onChange:e=>B(S)(e.target.value),className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-white mt-1",children:[a.jsx("option",{value:"none",children:"Not configured"}),a.jsx("option",{value:"openai",children:"OpenAI"}),a.jsx("option",{value:"azure",children:"Azure OpenAI"})]}),"azure"===k&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Endpoint",a.jsx("input",{value:C,onChange:e=>B(D)(e.target.value),placeholder:"https://your-resource.openai.azure.com",className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-white mt-1"})]}),(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["Deployment",a.jsx("input",{value:$,onChange:e=>B(I)(e.target.value),placeholder:"gpt-4o-transcribe",className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-white mt-1"})]})]}),"none"!==k&&(0,a.jsxs)("label",{className:"block text-xs text-gray-400",children:["API key",a.jsx("input",{type:"password",autoComplete:"off",value:A,onChange:e=>B(R)(e.target.value),placeholder:v?.provider===k&&v.keyHint?`Saved (${v.keyHint}). Leave blank to keep it.`:"Paste your key",className:"w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-sm text-white mt-1"})]}),v?.fromEnv&&a.jsx("p",{className:"text-xs text-gray-500",children:"Using OPENAI_API_KEY from the environment."}),a.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Stored only on this computer, readable by your user only. Never sent to the browser."})]})]})}),(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2 px-6 py-3 border-t border-gray-800 bg-gray-950/95",children:["saved"===y&&a.jsx("span",{className:"text-xs text-green-400 mr-auto",children:"Saved"}),"error"===y&&a.jsx("span",{className:"text-xs text-red-400 mr-auto",children:j||"Could not save settings"}),a.jsx("button",{onClick:W,disabled:!i||!H||"saving"===y,className:"px-3 py-1.5 text-sm rounded-md bg-blue-600 hover:bg-blue-500 disabled:opacity-40",children:"saving"===y?"Saving…":"Save"})]})]})]})}var eD=s(9952);let e$=(e,t)=>`${e}:${null!=t.newNo?t.newNo:`-${t.oldNo}`}`,eI={added:["A","text-emerald-400"],deleted:["D","text-red-400"],modified:["M","text-amber-300"],renamed:["R","text-blue-300"]};function eA({sessionName:e,liveId:t,hasRepo:s,prUrls:l,onSend:n,onOpenSession:i}){let[o,d]=(0,r.useState)(null),[c,x]=(0,r.useState)(null),[u,m]=(0,r.useState)(!0),[p,g]=(0,r.useState)(0),[h,b]=(0,r.useState)({}),[y,f]=(0,r.useState)(null),[j,N]=(0,r.useState)(""),[v,w]=(0,r.useState)(""),[k,S]=(0,r.useState)(new Set),[C,D]=(0,r.useState)(null),$=(0,r.useRef)({}),[I,A]=(0,r.useState)(s||!l.length?"local":l[0]),R=(0,r.useMemo)(()=>(o?.files??[]).reduce((e,t)=>({add:e.add+t.additions,del:e.del+t.deletions}),{add:0,del:0}),[o]),O=Object.values(h);function P(e,t,s){j.trim()&&b(a=>({...a,[e]:{path:t,line:null!=s.newNo?String(s.newNo):`old ${s.oldNo}`,code:s.text.trim().slice(0,120),text:j.trim()}})),f(null),N("")}return(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col bg-gray-950 text-gray-100",children:[(0,a.jsxs)("header",{className:"flex items-center gap-4 px-6 py-4 border-b border-gray-800 flex-wrap",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-[11px] text-gray-500",children:"Review changes"}),a.jsx("h1",{className:"text-lg font-semibold truncate",children:e}),o&&(0,a.jsxs)("p",{className:"text-xs text-gray-400 mt-0.5",children:[a.jsx("span",{className:"font-mono text-gray-300",children:o.branch})," vs ",o.baseLabel," \xb7 ",o.files.length," file",1===o.files.length?"":"s"," \xb7 ",(0,a.jsxs)("span",{className:"text-emerald-400",children:["+",R.add]})," ",(0,a.jsxs)("span",{className:"text-red-400",children:["−",R.del]})]})]}),(s?1:0)+l.length>1&&(0,a.jsxs)("select",{value:I,onChange:e=>{A(e.target.value),b({}),D(null)},className:"text-sm bg-gray-900 border border-gray-700 rounded-lg px-2.5 py-1.5",title:"What to review",children:[s&&a.jsx("option",{value:"local",children:"Local changes"}),l.map(e=>(0,a.jsxs)("option",{value:e,children:["PR ",e.replace("https://github.com/","").replace("/pull/","#")]},e))]}),a.jsx("button",{onClick:()=>g(e=>e+1),className:"text-sm px-3 py-1.5 rounded-lg border border-gray-700 hover:bg-gray-800",children:"Refresh"}),a.jsx("button",{onClick:i,className:"text-sm px-3 py-1.5 rounded-lg border border-gray-700 hover:bg-gray-800",children:"Open session"})]}),u&&!o?a.jsx("p",{className:"p-8 text-sm text-gray-500 animate-pulse",children:"Reading the changes…"}):c?a.jsx("p",{className:"p-8 text-sm text-amber-300",children:c}):o&&!o.files.length?(0,a.jsxs)("p",{className:"p-8 text-sm text-gray-400",children:["No changes yet since ",o.baseLabel,"."]}):o&&(0,a.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,a.jsxs)("nav",{className:"w-64 flex-shrink-0 border-r border-gray-800 overflow-y-auto py-2 hidden md:block",children:[o.files.map(e=>(0,a.jsxs)("button",{onClick:()=>$.current[e.path]?.scrollIntoView({behavior:"smooth"}),className:"w-full text-left px-3 py-1.5 text-xs hover:bg-gray-900 flex items-center gap-2 min-w-0",title:e.path,children:[a.jsx("span",{className:`font-mono w-3 ${eI[e.status][1]}`,children:eI[e.status][0]}),a.jsx("span",{className:"truncate flex-1 text-gray-300",dir:"rtl",children:e.path}),O.some(t=>t.path===e.path)&&a.jsx("span",{className:"text-amber-300",children:"●"}),(0,a.jsxs)("span",{className:"text-emerald-400/80 tabular-nums",children:["+",e.additions]}),(0,a.jsxs)("span",{className:"text-red-400/80 tabular-nums",children:["−",e.deletions]})]},e.path)),o.truncated&&a.jsx("p",{className:"px-3 py-2 text-[11px] text-amber-300/80",children:"Very large diff: only the first part is shown."})]}),a.jsx("main",{className:"flex-1 overflow-y-auto p-4 space-y-4 min-w-0",children:o.files.map(e=>(0,a.jsxs)("section",{ref:t=>{$.current[e.path]=t},className:"rounded-xl border border-gray-800 overflow-hidden",children:[(0,a.jsxs)("button",{onClick:()=>S(t=>{let s=new Set(t);return s.has(e.path)?s.delete(e.path):s.add(e.path),s}),className:"w-full flex items-center gap-2 px-3 py-2 bg-gray-900 border-b border-gray-800 text-left sticky top-0 z-10",children:[a.jsx("span",{className:"text-gray-500 text-xs",children:k.has(e.path)?"▸":"▾"}),a.jsx("span",{className:"font-mono text-xs text-gray-200 truncate flex-1",children:e.path}),(0,a.jsxs)("span",{className:"text-[11px] text-emerald-400",children:["+",e.additions]}),(0,a.jsxs)("span",{className:"text-[11px] text-red-400",children:["−",e.deletions]})]}),!k.has(e.path)&&(e.binary?a.jsx("p",{className:"px-4 py-3 text-xs text-gray-500",children:"Binary or large file, not shown."}):a.jsx("div",{className:"overflow-x-auto",children:a.jsx("table",{className:"w-full text-xs font-mono border-collapse",children:a.jsx("tbody",{children:e.lines.map((t,s)=>{if("hunk"===t.kind)return a.jsx("tr",{children:a.jsx("td",{colSpan:3,className:"px-3 py-1 bg-blue-950/30 text-blue-300/70",children:t.text})},s);let r=e$(e.path,t),l=h[r],n="add"===t.kind?"bg-emerald-950/40":"del"===t.kind?"bg-red-950/40":"";return[(0,a.jsxs)("tr",{className:`group ${n}`,children:[a.jsx("td",{className:"w-10 text-right pr-2 text-gray-600 select-none align-top",children:t.oldNo??""}),(0,a.jsxs)("td",{className:"w-10 text-right pr-2 text-gray-600 select-none align-top relative",children:[a.jsx("button",{onClick:()=>{f(r),N(l?.text??"")},title:"Comment on this line",className:"absolute -left-1 top-0 w-4 h-4 rounded bg-blue-600 text-white leading-4 text-[11px] opacity-0 group-hover:opacity-100",children:"+"}),t.newNo??""]}),(0,a.jsxs)("td",{className:`pl-2 pr-4 whitespace-pre ${"add"===t.kind?"text-emerald-100":"del"===t.kind?"text-red-100":"text-gray-300"}`,children:[a.jsx("span",{className:"select-none text-gray-600 mr-1",children:"add"===t.kind?"+":"del"===t.kind?"-":" "}),t.text]})]},s),(y===r||l)&&a.jsx("tr",{children:a.jsx("td",{colSpan:3,className:"px-3 py-2 bg-gray-900 border-y border-gray-800 font-sans",children:y===r?(0,a.jsxs)("div",{className:"max-w-2xl space-y-2",children:[a.jsx("textarea",{autoFocus:!0,value:j,onChange:e=>N(e.target.value),rows:3,placeholder:"What should change here?",onKeyDown:s=>{"Enter"===s.key&&(s.metaKey||s.ctrlKey)&&P(r,e.path,t),"Escape"===s.key&&f(null)},className:"w-full bg-gray-950 border border-gray-700 focus:border-blue-500 rounded-md px-2.5 py-2 text-sm outline-none"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>P(r,e.path,t),className:"text-xs px-3 py-1 rounded-md bg-blue-600 hover:bg-blue-500",children:"Add comment"}),a.jsx("button",{onClick:()=>f(null),className:"text-xs px-2 py-1 text-gray-400 hover:text-white",children:"Cancel"}),a.jsx("span",{className:"text-[11px] text-gray-500 self-center",children:"⌘↵ to add"})]})]}):l&&(0,a.jsxs)("div",{className:"flex items-start gap-2 max-w-2xl rounded-md border border-amber-800/60 bg-amber-950/30 px-3 py-2",children:[a.jsx("p",{className:"text-sm text-amber-100 whitespace-pre-wrap flex-1",children:l.text}),a.jsx("button",{onClick:()=>{f(r),N(l.text)},className:"text-xs text-gray-400 hover:text-white",children:"Edit"}),a.jsx("button",{onClick:()=>b(e=>{let t={...e};return delete t[r],t}),className:"text-xs text-gray-400 hover:text-red-300",children:"Delete"})]})})},`${s}c`)]})})})}))]},e.path))})]}),o&&o.files.length>0&&(0,a.jsxs)("footer",{className:"border-t border-gray-800 px-6 py-3 flex items-center gap-3 flex-wrap bg-gray-950",children:[a.jsx("input",{value:v,onChange:e=>w(e.target.value),placeholder:"Overall comment (optional)",className:"flex-1 min-w-[240px] bg-gray-900 border border-gray-700 focus:border-blue-500 rounded-lg px-3 py-2 text-sm outline-none"}),C&&a.jsx("span",{className:"text-xs text-emerald-400",children:"approve"===C?"Approval sent to the session":"Feedback sent to the session"}),(0,a.jsxs)("button",{onClick:function(){let e=O.map((e,t)=>`${t+1}. ${e.path}:${e.line}${e.code?` (\`${e.code}\`)`:""}
2
+ ${e.text.replace(/\n/g,"\n ")}`),t="local"===I?o?` (branch ${o.branch})`:"":` in ${I}`;n(`Review feedback on your changes${t}:
3
+
4
+ ${e.join("\n")}${v.trim()?`
5
+
6
+ Overall: ${v.trim()}`:""}
7
+
8
+ Please address each point, then tell me what you changed.`),D("feedback"),b({}),w("")},disabled:!O.length&&!v.trim(),title:"Sends your line comments to the session as one message (when it's idle)",className:"text-sm px-4 py-2 rounded-lg bg-amber-600 hover:bg-amber-500 disabled:opacity-40 font-medium whitespace-nowrap",children:["Send feedback",O.length?` (${O.length})`:""]}),a.jsx("button",{onClick:function(){n("local"===I?`I reviewed your changes${o?` on ${o.branch}`:""} and they look good.${v.trim()?` ${v.trim()}`:""} Commit anything uncommitted with a clear message and push the branch.`:`I reviewed ${I} and it looks good.${v.trim()?` ${v.trim()}`:""} Make sure everything is pushed.`),D("approve"),w("")},title:"Tells the session the changes look good: commit and push",className:"text-sm px-4 py-2 rounded-lg bg-emerald-600 hover:bg-emerald-500 font-medium whitespace-nowrap",children:"Approve"})]})]})}let eR=[["todo","To do","Not started yet"],["running","In progress","A session is working on it"],["review","Your review","Check the changes, then open the PR"],["pr","PR in review","Reviewers and CI; fixes go back to the session"],["merge","Ready to merge","Approved, green, no open threads"],["done","Done","Merged or finished"]];function eO({orgId:e,folders:t,liveSessions:s,pipelines:l,onStart:n,onOpenSession:i,onReview:o,onAutomate:d,onAct:c,onDismiss:u}){let[m,p]=(0,r.useState)([]),[g,h]=(0,r.useState)(!1),[b,y]=(0,r.useState)(""),[f,j]=(0,r.useState)(""),[N,v]=(0,r.useState)("general"),[w,k]=(0,r.useState)(!1),[S,C]=(0,r.useState)(!0),[D,$]=(0,r.useState)(""),[I,A]=(0,r.useState)(null),[R,P]=(0,r.useState)(null),[M,L]=(0,r.useState)(null),[T,E]=(0,r.useState)(null),U=(0,r.useCallback)(()=>{fetch("/api/tasks").then(e=>e.json()).then(p).catch(()=>{})},[]);async function F(e,t){await fetch("/api/tasks",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,...t})}),U()}async function _(){let t=await fetch("/api/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:b,details:f,cwd:N,worktree:"general"!==N&&w,ship:"general"!==N&&S,slackChannel:D.replace(/^#/,"").trim()?{id:I?.id??"",name:D.replace(/^#/,"").trim()}:null,orgId:"all"===e?"default":e})});if(!t.ok){P((await t.json().catch(()=>({}))).error??"Could not add the task");return}y(""),j(""),k(!1),h(!1),P(null),U()}async function J(e){await fetch(`/api/tasks?id=${encodeURIComponent(e)}`,{method:"DELETE"}),U()}let B=m.filter(t=>"all"===e||t.orgId===e),H=e=>e.liveId?[...l].reverse().find(t=>t.liveId===e.liveId):void 0,W="w-full bg-gray-950 border border-gray-700 focus:border-blue-500 rounded-md px-2.5 py-1.5 text-sm outline-none placeholder-gray-600";return(0,a.jsxs)("div",{className:"absolute inset-0 flex flex-col bg-gray-950 text-gray-100",children:[(0,a.jsxs)("header",{className:"px-6 pt-5 pb-3 flex items-baseline gap-3",children:[a.jsx("h1",{className:"text-lg font-semibold",children:"Board"}),(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:[B.filter(e=>!e.done).length," open \xb7 cards move on their own as sessions work"]})]}),a.jsx("div",{className:"flex-1 grid grid-flow-col auto-cols-[minmax(210px,1fr)] gap-3 px-6 pb-6 min-h-0 overflow-x-auto",children:eR.map(([e,r,l])=>{let p=B.filter(t=>(function(e,t,s){if(e.done||s?.phase==="done")return"done";if(!e.liveId)return"todo";let a=s?.prs.filter(e=>"done"!==e.state)??[];return a.length?a.some(e=>"ready"===e.state)?"merge":"pr":t?.status==="thinking"?"running":"review"})(t,s.find(e=>e.id===t.liveId),H(t))===e).sort((t,s)=>"done"===e?(s.doneAt??0)-(t.doneAt??0):t.createdAt-s.createdAt);return(0,a.jsxs)("section",{onDragOver:t=>{t.preventDefault(),E(e)},onDragLeave:()=>E(t=>t===e?null:t),onDrop:()=>(function(e){let t=m.find(e=>e.id===M);L(null),E(null),t&&("done"!==e||t.done?"done"!==e&&t.done&&F(t.id,{done:!1}):F(t.id,{done:!0}))})(e),className:`flex flex-col min-h-0 rounded-xl border bg-gray-900/40 transition-colors ${T===e?"border-blue-500/60 bg-blue-950/20":"border-gray-800"}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-gray-800",children:[a.jsx("h2",{className:"text-sm font-semibold",title:l,children:r}),a.jsx("span",{className:"text-xs text-gray-500 tabular-nums",children:p.length}),"todo"===e&&!g&&a.jsx("button",{onClick:()=>h(!0),className:"ml-auto text-xs px-2 py-0.5 rounded-md bg-blue-600 hover:bg-blue-500",children:"+ Task"})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto p-2.5 space-y-2.5",children:["todo"===e&&g&&(0,a.jsxs)("div",{className:"rounded-lg border border-blue-800/60 bg-gray-900 p-3 space-y-2",children:[a.jsx("input",{autoFocus:!0,value:b,onChange:e=>y(e.target.value),placeholder:"Title, e.g. Add retries to webhook delivery",className:W,onKeyDown:e=>{"Enter"===e.key&&b.trim()&&_(),"Escape"===e.key&&h(!1)}}),a.jsx("textarea",{value:f,onChange:e=>j(e.target.value),rows:3,placeholder:"Details for the agent (optional)",className:W}),(0,a.jsxs)("select",{value:N,onChange:e=>v(e.target.value),className:W,title:"Where the session works",children:[a.jsx("option",{value:"general",children:"Just chat (no folder)"}),t.map(e=>(0,a.jsxs)("option",{value:e,children:[e.split("/").at(-1)," \xb7 ",e]},e))]}),"general"!==N&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 text-xs text-gray-300",title:"New branch + separate copy of the repo, so parallel tasks don't collide",children:[a.jsx("input",{type:"checkbox",checked:w,onChange:e=>k(e.target.checked)})," Isolated copy (new branch + worktree)"]}),(0,a.jsxs)("label",{className:"flex items-start gap-2 text-xs text-gray-300",title:"After your review: opens the PR, sends review comments and CI failures back to the session, and asks you before merging",children:[a.jsx("input",{type:"checkbox",checked:S,onChange:e=>C(e.target.checked),className:"mt-0.5"})," ",(0,a.jsxs)("span",{children:["Ship it when done ",a.jsx("span",{className:"text-gray-500",children:"(PR, review fixes, CI fixes; you merge)"})]})]}),S&&a.jsx(O.a,{value:D,onChange:(e,t)=>{$(e),A(t)},className:W})]}),R&&a.jsx("p",{className:"text-xs text-red-400",children:R}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:_,disabled:!b.trim(),className:"text-xs px-3 py-1 rounded-md bg-blue-600 hover:bg-blue-500 disabled:opacity-40",children:"Add"}),a.jsx("button",{onClick:()=>{h(!1),P(null)},className:"text-xs px-2 py-1 text-gray-400 hover:text-white",children:"Cancel"})]})]}),p.map(t=>{let r=s.find(e=>e.id===t.liveId),l=H(t),m={...x.dc,...l?.config.auto},p=Array.from(new Set([...r?.prUrl?[r.prUrl]:[],...l?.prs.map(e=>e.url)??[]]));return(0,a.jsxs)("article",{draggable:!0,onDragStart:()=>L(t.id),onDragEnd:()=>{L(null),E(null)},className:`group rounded-lg border bg-gray-900 p-3 cursor-grab active:cursor-grabbing ${M===t.id?"opacity-50":""} ${"review"===e?"border-amber-800/50":"border-gray-800"}`,children:[(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[a.jsx("p",{className:`text-sm font-medium flex-1 ${t.done?"text-gray-400 line-through":"text-gray-100"}`,children:t.title}),a.jsx("button",{onClick:()=>J(t.id),className:"opacity-0 group-hover:opacity-100 text-gray-600 hover:text-red-400 text-xs",title:"Delete task (the session, if any, keeps running)",children:"✕"})]}),t.details&&a.jsx("p",{className:"text-xs text-gray-400 mt-1 line-clamp-3 whitespace-pre-wrap",children:t.details}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 mt-2 text-[11px]",children:[a.jsx("span",{className:"px-1.5 py-0.5 rounded bg-gray-800 text-gray-400",children:"general"===t.cwd?"chat":t.cwd.split("/").at(-1)}),r?.worktree&&(0,a.jsxs)("span",{className:"px-1.5 py-0.5 rounded bg-emerald-950/60 text-emerald-300",children:["⑂ ",r.worktree.branch.replace(/^polyergon\//,"")]}),r?.status==="thinking"&&"done"!==e&&(0,a.jsxs)("span",{className:"flex items-center gap-1 text-blue-300",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-full border-2 border-blue-300 border-t-transparent animate-spin motion-reduce:animate-none"}),"working"]}),"review"===e&&(r?a.jsx("span",{className:"text-amber-300",children:"waiting for you"}):a.jsx("span",{className:"text-gray-500",children:"session closed"})),l&&(0,x.An)(l)&&a.jsx("button",{onClick:()=>r&&d(r.id),className:"text-blue-300 hover:underline",title:"Open the full pipeline",children:"⚡ Ship it"}),!l?.prs.length&&p.map(e=>a.jsx("a",{href:e,target:"_blank",rel:"noreferrer",className:"text-blue-400 hover:underline",children:(0,x.QV)(e)},e))]}),l?.prs.filter(t=>"done"===e||"done"!==t.state).map(e=>a.jsxs("div",{className:"mt-2 rounded-md bg-gray-950/70 border border-gray-800 px-2 py-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[a.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 hover:underline",children:x.QV(e.url).split("/").at(-1)}),a.jsx("span",{className:"flex items-center",children:x.UA(e,!!l.config.slackChannel).map((e,t)=>a.jsxs("span",{className:"flex items-center",title:e.label,children:[t>0&&a.jsx("span",{className:`w-2.5 h-px ${e.done||e.current?"bg-blue-500/70":"bg-gray-700"}`}),a.jsx("span",{className:`w-2 h-2 rounded-full ${e.done?"bg-emerald-400":e.current?"bg-blue-400":"bg-gray-700"}`})]},e.label))}),a.jsxs("span",{className:`ml-auto ${e.view?.checks==="failing"?"text-red-400":e.view?.checks==="passing"?"text-emerald-400":"text-gray-500"}`,children:["CI ",e.view?.checks??"…"]})]}),(e.view?.isDraft||!!e.view?.unresolved)&&a.jsx("p",{className:"text-[11px] text-amber-300 mt-0.5",children:[e.view?.isDraft&&"draft",e.view?.unresolved&&`${e.view.unresolved} unresolved thread${e.view.unresolved>1?"s":""}`].filter(Boolean).join(" \xb7 ")}),e.suggestion&&("merge"!==e.suggestion.kind||m.merge?"merge"!==e.suggestion.kind&&"open-pr"!==e.suggestion.kind&&m[e.suggestion.kind]&&("review"===e.suggestion.kind?e.reviewRounds:e.ciFixes)<l.config.maxRounds?a.jsxs("p",{className:"text-[11px] text-blue-300/80 mt-1",children:["review"===e.suggestion.kind?"Review comments":"CI failure"," going to the session…"]}):a.jsxs("div",{className:"flex gap-1.5 mt-1.5 items-center",children:[a.jsx("span",{className:"text-[11px] text-amber-300 flex-1",children:"review"===e.suggestion.kind?"Review comments":"ci"===e.suggestion.kind?"CI failing":"Ready"}),a.jsx("button",{onClick:()=>r&&c(l.id,r.id,e.url),className:"text-xs px-2 py-0.5 rounded-md bg-amber-600 hover:bg-amber-500",children:"Send to session"})]}):a.jsxs("div",{className:"flex gap-1.5 mt-1.5",children:[a.jsx("button",{onClick:()=>r&&c(l.id,r.id,e.url),className:"text-xs px-2.5 py-0.5 rounded-md bg-emerald-600 hover:bg-emerald-500",children:"Merge"}),a.jsx("button",{onClick:()=>u(l.id,e.url),className:"text-xs px-1.5 text-gray-500 hover:text-gray-200",children:"Not yet"})]}))]},e.url)),(0,a.jsxs)("div",{className:"flex flex-wrap gap-1.5 mt-2.5",children:["todo"===e&&a.jsx("button",{onClick:()=>n(t),className:"text-xs px-2.5 py-1 rounded-md bg-blue-600 hover:bg-blue-500",children:"Start"}),"review"===e&&l?.suggestion?.kind==="open-pr"&&r&&a.jsx("button",{onClick:()=>c(l.id,r.id,null),className:"text-xs px-2.5 py-1 rounded-md bg-blue-600 hover:bg-blue-500",title:"Ask the session to commit, push and open the PR",children:"Open PR"}),r&&a.jsx("button",{onClick:()=>i(r.id),className:"text-xs px-2 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"Open session"}),r&&"review"===e&&(r.gitRoot||p.length>0)&&a.jsx("button",{onClick:()=>o(r.id),className:"text-xs px-2 py-1 rounded-md border border-emerald-800 text-emerald-300 hover:bg-emerald-950/40",children:"\xb1 Review"}),r&&"review"===e&&!!r.gitRoot&&!(l&&(0,x.An)(l))&&(r.backend??"claude")==="claude"&&a.jsx("button",{onClick:()=>d(r.id),className:"text-xs px-2 py-1 rounded-md border border-gray-700 hover:bg-gray-800",title:"Open the PR, get it reviewed, fix feedback and CI",children:"⚡ Ship it"}),r&&("pr"===e||"merge"===e)&&a.jsx("button",{onClick:()=>o(r.id),className:"text-xs px-2 py-1 rounded-md border border-gray-700 hover:bg-gray-800",children:"\xb1 Diff"}),!t.done&&t.liveId&&a.jsx("button",{onClick:()=>F(t.id,{done:!0}),className:"text-xs px-2 py-1 rounded-md text-gray-400 hover:text-emerald-300",children:"✓ Done"}),t.done&&a.jsx("button",{onClick:()=>F(t.id,{done:!1}),className:"text-xs px-2 py-1 rounded-md text-gray-500 hover:text-gray-200",children:"Reopen"})]})]},t.id)}),!p.length&&!("todo"===e&&g)&&a.jsx("p",{className:"text-xs text-gray-600 text-center py-6",children:"todo"===e?"Add a task, then Start it to open a session":"done"===e?"Drag finished cards here":l})]})]},e)})})]})}let eP={needsReview:"#3987e5",returned:"#d95926",waiting:"#199e70",muted:"#898781"},eM=["#86b6ef","#5598e7","#3987e5","#256abf","#184f95"],eL=[{key:"needsReview",label:"Needs your review",color:eP.needsReview},{key:"returned",label:"Returned to you",color:eP.returned},{key:"waiting",label:"Waiting on others",color:eP.waiting}],eT=[{label:"<2d",min:0,max:1728e5},{label:"2–7d",min:1728e5,max:6048e5},{label:"1–2w",min:6048e5,max:12096e5},{label:"2–4w",min:12096e5,max:24192e5},{label:">4w",min:24192e5,max:1/0}];function eE(e){let t=Math.floor(e/864e5);return t<1?"today":t<14?`${t}d`:`${Math.floor(t/7)}w`}function eU({label:e,value:t,accent:s,selected:r,onClick:l}){return(0,a.jsxs)("button",{onClick:l,className:`bg-gray-900 rounded-lg px-5 py-4 flex-1 min-w-[140px] text-left transition-all ${l?"hover:bg-gray-800/80 cursor-pointer":"cursor-default"} ${r?"ring-2 ring-blue-500":""}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[s&&a.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:s}}),a.jsx("span",{className:"text-xs text-gray-500",children:e})]}),a.jsx("p",{className:"text-4xl font-semibold text-white mt-1.5",children:t})]})}function eF({inbox:e,orgs:t,activeOrgId:s,refreshing:l,onRefresh:n,onAttachLive:o,onSelectHistory:d,onReviewWithClaude:c}){let[x,u]=(0,r.useState)(null),[m,p]=(0,r.useState)(null),g=e=>i(e.repo,s,t),h="all"===s?null:t.find(e=>e.id===s)?.name??null,b=(0,r.useMemo)(()=>[...e.sections.needsReview.filter(g).map(e=>({...e,sect:"needsReview"})),...e.sections.returned.filter(g).map(e=>({...e,sect:"returned"})),...e.sections.waiting.filter(g).map(e=>({...e,sect:"waiting"}))],[e,s,t]),y=(0,r.useMemo)(()=>(e.mergedWindow??[]).filter(g),[e,s,t]),f=(0,r.useMemo)(()=>{let e=new Map;for(let t of b){let s=t.repo.split("/").at(-1)??t.repo;e.has(s)||e.set(s,{needsReview:0,returned:0,waiting:0}),e.get(s)[t.sect]++}return Array.from(e.entries()).map(([e,t])=>({repo:e,...t,total:t.needsReview+t.returned+t.waiting})).sort((e,t)=>t.total-e.total).slice(0,10)},[b]),j=(0,r.useMemo)(()=>{let e=Date.now();return eT.map(t=>({label:t.label,count:b.filter(s=>{let a=e-(s.createdAt||e);return a>=t.min&&a<t.max}).length}))},[b]),N=(0,r.useMemo)(()=>e.mergedByWeek.map(e=>({...e,count:y.filter(t=>t.closedAt&&t.closedAt>=e.weekStart&&t.closedAt<e.weekStart+6048e5).length})),[e.mergedByWeek,y]),v=Math.max(1,...N.map(e=>e.count)),w=Math.max(1,...j.map(e=>e.count)),k=Math.max(1,...f.map(e=>e.total)),S=y.filter(e=>(e.closedAt??0)>=Date.now()-6048e5).length,C=(0,r.useMemo)(()=>{if(m?.weekStart!==void 0)return y.filter(e=>e.closedAt&&e.closedAt>=m.weekStart&&e.closedAt<m.weekStart+6048e5);let e=b;if(m?.section&&(e=e.filter(e=>e.sect===m.section)),m?.repo&&(e=e.filter(e=>(e.repo.split("/").at(-1)??e.repo)===m.repo)),m?.ageBucket){let t=eT.find(e=>e.label===m.ageBucket),s=Date.now();e=e.filter(e=>{let a=s-(e.createdAt||s);return a>=t.min&&a<t.max})}return m?[...e].sort((e,t)=>e.createdAt-t.createdAt):[...e].sort((e,t)=>e.createdAt-t.createdAt).slice(0,5)},[m,b,y]),D=[];m?.section&&D.push({label:eL.find(e=>e.key===m.section).label,clear:()=>p(e=>({...e,section:void 0}))}),m?.repo&&D.push({label:m.repo,clear:()=>p(e=>({...e,repo:void 0}))}),m?.ageBucket&&D.push({label:`age ${m.ageBucket}`,clear:()=>p(e=>({...e,ageBucket:void 0}))}),m?.weekStart!==void 0&&D.push({label:`merged week of ${new Date(m.weekStart).toLocaleDateString([],{month:"short",day:"numeric"})}`,clear:()=>p(null)});let $=0===D.length?null:m,I=D.length>0;function A(e,t){let s=e.currentTarget.closest("[data-dash-root]")?.getBoundingClientRect();s&&u({x:e.clientX-s.left+12,y:e.clientY-s.top+12,lines:t})}return(0,a.jsxs)("div",{"data-dash-root":!0,className:"absolute inset-0 overflow-y-auto bg-gray-950",children:[(0,a.jsxs)("div",{className:"max-w-4xl mx-auto px-6 py-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-5",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("h2",{className:"text-white font-semibold text-lg flex items-center gap-2",children:["PR Dashboard",h&&a.jsx("span",{className:"px-2 py-0.5 rounded bg-purple-900/50 text-purple-300 text-xs font-medium",children:h})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-600",children:["Your GitHub workload \xb7 updated ",new Date(e.fetchedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})," \xb7 click any tile or bar to drill in"]})]}),a.jsx("button",{onClick:n,disabled:l,className:"bg-gray-800 hover:bg-gray-700 disabled:opacity-50 text-gray-200 rounded px-3 py-1.5 text-xs font-medium",children:l?"Refreshing…":"Refresh"})]}),(0,a.jsxs)("div",{className:"flex gap-3 flex-wrap mb-6",children:[eL.map(e=>a.jsx(eU,{label:e.label,value:b.filter(t=>t.sect===e.key).length,accent:e.color,selected:$?.section===e.key,onClick:()=>{var t;return t=e.key,void p(e=>e?.section===t?{...e,section:void 0,weekStart:void 0}:{...e,section:t,weekStart:void 0})}},e.key)),a.jsx(eU,{label:"Merged \xb7 7d",value:S})]}),(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5 mb-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium",children:"Open PRs by repo"}),a.jsx("div",{className:"flex items-center gap-3",children:eL.map(e=>(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-gray-500",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-sm",style:{background:e.color}}),e.label]},e.key))})]}),a.jsx("div",{className:"space-y-1.5",children:f.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("button",{className:`text-xs w-44 truncate text-right flex-shrink-0 hover:text-white ${$?.repo===e.repo?"text-white font-medium":"text-gray-400"}`,title:`Filter to ${e.repo}`,onClick:()=>p(t=>t?.repo===e.repo?{...t,repo:void 0,weekStart:void 0}:{...t,repo:e.repo,weekStart:void 0}),children:e.repo}),(0,a.jsxs)("div",{className:"flex-1 flex items-center h-4",style:{gap:2},children:[eL.map(t=>e[t.key]>0&&a.jsx("button",{className:"h-4 rounded-[4px] hover:brightness-125",style:{width:`${e[t.key]/k*100}%`,background:t.color,minWidth:6},onMouseMove:s=>A(s,[`${e.repo} — ${t.label}`,`${e[t.key]} PR${1===e[t.key]?"":"s"} \xb7 click to drill in`]),onMouseLeave:()=>u(null),onClick:()=>{u(null),p({section:t.key,repo:e.repo})}},t.key)),a.jsx("span",{className:"text-xs text-gray-500 ml-1.5",children:e.total})]})]},e.repo))})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-6 mb-6",children:[(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium mb-3",children:"Age of open PRs"}),a.jsx("div",{className:"flex items-end justify-between gap-2 h-32",children:j.map((e,t)=>(0,a.jsxs)("button",{className:"flex-1 flex flex-col items-center justify-end h-full group",onClick:()=>p(t=>t?.ageBucket===e.label?{...t,ageBucket:void 0}:{...t,ageBucket:e.label,weekStart:void 0}),children:[e.count>0&&a.jsx("span",{className:"text-xs text-gray-400 mb-1",children:e.count}),a.jsx("div",{className:"w-full rounded-t-[4px] group-hover:brightness-125",style:{height:`${e.count/w*82}%`,background:eM[t],minHeight:e.count>0?4:0},onMouseMove:t=>A(t,[`${e.label} old`,`${e.count} open PR${1===e.count?"":"s"} \xb7 click to drill in`]),onMouseLeave:()=>u(null)}),a.jsx("span",{className:`text-[10px] mt-1.5 ${$?.ageBucket===e.label?"text-white font-medium":""}`,style:$?.ageBucket===e.label?{}:{color:eP.muted},children:e.label})]},e.label))})]}),(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium mb-3",children:"Merged per week"}),a.jsx("div",{className:"flex items-end justify-between gap-2 h-32",children:N.map((e,t)=>{let s=t===N.length-1,r=new Date(e.weekStart).toLocaleDateString([],{month:"short",day:"numeric"}),l=$?.weekStart===e.weekStart;return(0,a.jsxs)("button",{className:"flex-1 flex flex-col items-center justify-end h-full group",onClick:()=>p(t=>t?.weekStart===e.weekStart?null:{weekStart:e.weekStart}),children:[(e.count===v||s)&&e.count>0&&a.jsx("span",{className:"text-xs text-gray-400 mb-1",children:e.count}),a.jsx("div",{className:"w-full rounded-t-[4px] group-hover:brightness-125",style:{height:`${e.count/v*82}%`,background:eP.needsReview,opacity:l||s?1:.85,minHeight:e.count>0?4:0},onMouseMove:t=>A(t,[`Week of ${r}`,`${e.count} merged \xb7 click to drill in`]),onMouseLeave:()=>u(null)}),a.jsx("span",{className:`text-[10px] mt-1.5 whitespace-nowrap ${l?"text-white font-medium":""}`,style:l?{}:{color:eP.muted},children:r})]},e.weekStart)})})]})]}),(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium",children:I?`${C.length} PR${1===C.length?"":"s"}`:"Oldest open PRs"}),D.map(e=>(0,a.jsxs)("button",{onClick:e.clear,className:"flex items-center gap-1 text-xs bg-gray-800 hover:bg-gray-700 text-gray-300 rounded-full px-2.5 py-0.5",children:[e.label," ",a.jsx("span",{className:"text-gray-500",children:"\xd7"})]},e.label)),I&&a.jsx("button",{onClick:()=>p(null),className:"text-xs text-gray-600 hover:text-gray-400",children:"clear all"})]}),0===C.length?a.jsx("p",{className:"text-xs text-gray-600",children:"Nothing matches \uD83C\uDF89"}):a.jsx("div",{className:"space-y-0.5",children:C.map(e=>{let t="sect"in e?eL.find(t=>t.key===e.sect):null,s=e.url.match(/\/pull\/(\d+)/)?.[1];return(0,a.jsxs)("div",{className:"group/row flex items-center gap-3 px-2 py-1.5 rounded hover:bg-gray-800/70",children:[a.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:t?.color??"#6b21a8"},title:t?.label??"Merged"}),a.jsx("button",{onClick:()=>{e.liveId?o(e.liveId):e.sessionId?d(e.sessionId,e.cwd):window.open(e.url,"_blank","noopener")},className:"text-sm text-gray-200 truncate flex-1 text-left hover:text-white",title:e.title,children:e.title}),(e.liveId||e.sessionId)&&a.jsx("span",{className:"text-[10px] text-blue-500/80 flex-shrink-0",children:"session"}),(0,a.jsxs)("span",{className:"text-xs text-gray-600 flex-shrink-0 w-40 truncate text-right",children:[e.repo.split("/").at(-1),"#",s]}),a.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0 w-10 text-right",children:e.closedAt?eE(Date.now()-e.closedAt):eE(Date.now()-e.createdAt)}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0 opacity-0 group-hover/row:opacity-100 transition-opacity",children:[!e.closedAt&&a.jsx("button",{onClick:()=>c(e.url),className:"text-xs bg-blue-600/80 hover:bg-blue-500 text-white rounded px-2 py-0.5",title:"Start a Claude session that reviews this PR (cr <url>)",children:"Review"}),a.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-gray-500 hover:text-white px-1",title:"Open on GitHub",children:"↗"})]})]},e.url)})})]})]}),x&&a.jsx("div",{className:"absolute z-30 pointer-events-none bg-gray-800 border border-gray-700 rounded px-2.5 py-1.5 shadow-lg",style:{left:x.x,top:x.y},children:x.lines.map((e,t)=>a.jsx("p",{className:0===t?"text-xs text-gray-400":"text-xs text-white font-medium",children:e},t))})]})}let e_=["#3987e5","#d95926","#199e70","#c98500"];function eJ(e){return e>=1e3?`$${(e/1e3).toFixed(1)}k`:e>=100?`$${Math.round(e)}`:`$${e.toFixed(2)}`}function eB(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}function eH({label:e,value:t,sub:s}){return(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg px-5 py-4 flex-1 min-w-[130px]",children:[a.jsx("span",{className:"text-xs text-gray-500",children:e}),a.jsx("p",{className:"text-3xl font-semibold text-white mt-1",children:t}),s&&a.jsx("p",{className:"text-xs text-gray-600 mt-0.5",children:s})]})}function eW({label:e,percent:t,resetsAt:s,severity:r}){let l="critical"===r||t>=95?"#d03b3b":"warning"===r||t>=80?"#fab219":"#0ca30c";return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-baseline justify-between mb-1",children:[a.jsx("span",{className:"text-xs text-gray-400",children:e}),(0,a.jsxs)("span",{className:"text-xs text-gray-500",children:[(0,a.jsxs)("span",{className:"font-semibold",style:{color:l},children:[t,"%"]})," used \xb7 ",100-t,"% left \xb7 ",function(e){if(!e)return"";let t=Date.parse(e)-Date.now();if(Number.isNaN(t)||t<=0)return"resetting…";let s=Math.floor(t/36e5),a=Math.floor(t%36e5/6e4);return s>=48?`resets in ${Math.round(s/24)}d`:s>0?`resets in ${s}h ${a}m`:`resets in ${a}m`}(s)]})]}),a.jsx("div",{className:"h-2 rounded-full bg-gray-800 overflow-hidden",children:a.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.min(100,t)}%`,background:l,minWidth:t>0?4:0}})})]})}function ez({usage:e,limits:t,orgs:s,activeOrgId:l,historySessions:n,liveSessions:i,onAttachLive:o,onSelectHistory:d}){let[c,x]=(0,r.useState)(null),u=s.filter(t=>("all"===l||t.id===l)&&e.orgs[t.id]),m=e=>e_[Math.max(0,s.findIndex(t=>t.id===e))%e_.length],p=u.reduce((t,s)=>{let a=e.orgs[s.id];return t.c5h+=a.last5h.costUSD,t.c24h+=a.last24h.costUSD,t.c7d+=a.last7d.costUSD,t.total+=a.totalCostUSD,t.sessions+=a.sessions,t.out+=a.totalTokens.output,t.inp+=a.totalTokens.input,t.cache+=a.totalTokens.cacheRead,t},{c5h:0,c24h:0,c7d:0,total:0,sessions:0,out:0,inp:0,cache:0}),g=(e.orgs[u[0]?.id]?.daily.map(e=>e.dayStart)??[]).map((t,s)=>({dayStart:t,parts:u.map(t=>({orgId:t.id,name:t.name,cost:e.orgs[t.id].daily[s]?.costUSD??0})),total:u.reduce((t,a)=>t+(e.orgs[a.id].daily[s]?.costUSD??0),0)})),h=Math.max(1,...g.map(e=>e.total)),b=(0,r.useMemo)(()=>{try{return JSON.parse(localStorage.getItem("claude-session-names")??"{}")}catch{return{}}},[]),y=(0,r.useMemo)(()=>Object.entries(e.sessions).filter(([,e])=>"all"===l||e.orgId===l).sort((e,t)=>t[1].costUSD-e[1].costUSD).slice(0,12).map(([e,t])=>{let s=n.find(t=>t.sessionId===e),a=i.find(t=>t.claudeSessionId===e),r=a&&b[a.id]||b[e]||s?.firstUserMessage||e.slice(0,8);return{sessionId:e,name:r,cost:t.costUSD,tokens:t.tokens,orgId:t.orgId,liveId:a?.id??null,cwd:s?.cwd??a?.cwd??null}}),[e,l,n,i,b]),f="all"===l?null:s.find(e=>e.id===l)?.name??null;return(0,a.jsxs)("div",{"data-usage-root":!0,className:"absolute inset-0 overflow-y-auto bg-gray-950",children:[(0,a.jsxs)("div",{className:"max-w-4xl mx-auto px-6 py-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,a.jsxs)("h2",{className:"text-white font-semibold text-lg flex items-center gap-2",children:["Usage",f&&a.jsx("span",{className:"px-2 py-0.5 rounded bg-purple-900/50 text-purple-300 text-xs font-medium",children:f})]}),(0,a.jsxs)("span",{className:"text-xs text-gray-600",children:["scanned ",new Date(e.scannedAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]}),(0,a.jsxs)("p",{className:"text-xs text-gray-600 mb-5",children:[a.jsx("span",{className:"text-gray-400 font-medium",children:"Dollar figures are value, not bills"})," — what your usage would cost at API prices. On a subscription you pay only the flat plan fee; limits throttle, they don't charge (unless an org has extra-usage billing on)."]}),t&&u.some(e=>t.orgs[e.id])&&(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5 mb-6",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium mb-4",children:"Plan limits (official, live)"}),a.jsx("div",{className:`grid gap-6 ${u.length>1?"grid-cols-2":"grid-cols-1"}`,children:u.map(e=>{let s=t.orgs[e.id];return s?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:m(e.id)}}),a.jsx("span",{className:"text-sm text-gray-200 font-medium",children:e.name}),e.plan?.name&&(0,a.jsxs)("span",{className:"text-xs text-gray-600",children:["\xb7 ",e.plan.name]})]}),s.error?a.jsx("p",{className:"text-xs text-yellow-600",children:s.error}):(0,a.jsxs)("div",{className:"space-y-3",children:[s.fiveHour&&a.jsx(eW,{label:"Session (5h window)",percent:s.fiveHour.percent,resetsAt:s.fiveHour.resetsAt,severity:s.fiveHour.severity}),s.weekly&&a.jsx(eW,{label:"Weekly (all models)",percent:s.weekly.percent,resetsAt:s.weekly.resetsAt,severity:s.weekly.severity}),s.scoped.map(e=>a.jsx(eW,{label:`Weekly \xb7 ${e.name}`,percent:e.percent,resetsAt:e.resetsAt,severity:e.severity},e.name)),s.extraUsage&&(s.extraUsage.enabled?(0,a.jsxs)("div",{className:"flex items-baseline justify-between rounded bg-red-950/40 border border-red-900/40 px-2.5 py-1.5",children:[a.jsx("span",{className:"text-xs text-red-300 font-medium",children:"Extra usage ON — overage bills real money"}),(0,a.jsxs)("span",{className:"text-xs text-red-200 font-semibold",children:[null!=s.extraUsage.usedUSD?`$${s.extraUsage.usedUSD.toLocaleString(void 0,{maximumFractionDigits:0})} billed`:"",s.extraUsage.spendLimitReached?" \xb7 spend limit reached":""]})]}):a.jsx("p",{className:"text-[11px] text-gray-600",children:"Extra usage off — hard cap at the subscription; hitting a limit only throttles, never bills."}))]})]},e.id):null})})]}),(0,a.jsxs)("div",{className:"flex gap-3 flex-wrap mb-6",children:[a.jsx(eH,{label:"Last 5 hours",value:eJ(p.c5h),sub:"rate-limit window"}),a.jsx(eH,{label:"Last 24 hours",value:eJ(p.c24h)}),a.jsx(eH,{label:"Last 7 days",value:eJ(p.c7d),sub:"weekly-cap window"}),a.jsx(eH,{label:"All-time",value:eJ(p.total),sub:`${p.sessions} sessions`})]}),(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5 mb-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsxs)("h3",{className:"text-sm text-gray-200 font-medium",children:["Value per day ",a.jsx("span",{className:"text-xs text-gray-600 font-normal",children:"(API-equivalent, not billed)"})]}),u.length>1&&a.jsx("div",{className:"flex items-center gap-3",children:u.map(e=>(0,a.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-gray-500",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-sm",style:{background:m(e.id)}}),e.name]},e.id))})]}),a.jsx("div",{className:"flex items-end justify-between gap-3 h-40",children:g.map(e=>{let t=new Date(e.dayStart).toLocaleDateString([],{weekday:"short"});return(0,a.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-end h-full",children:[e.total>0&&a.jsx("span",{className:"text-xs text-gray-400 mb-1",children:eJ(e.total)}),a.jsx("div",{className:"w-full flex flex-col-reverse",style:{height:`${e.total/h*80}%`,gap:2},children:e.parts.map((s,r)=>s.cost>0&&a.jsx("div",{className:"w-full hover:brightness-125",style:{flex:`${s.cost} 0 auto`,background:m(s.orgId),borderRadius:r===e.parts.filter(e=>e.cost>0).length-1?"4px 4px 0 0":0,minHeight:3},onMouseMove:e=>(function(e,t){let s=e.currentTarget.closest("[data-usage-root]")?.getBoundingClientRect();s&&x({x:e.clientX-s.left+12,y:e.clientY-s.top+12,lines:t})})(e,[`${s.name} — ${t}`,eJ(s.cost)]),onMouseLeave:()=>x(null)},s.orgId))}),a.jsx("span",{className:"text-[10px] mt-1.5",style:{color:"#898781"},children:t})]},e.dayStart)})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-6 mb-6",children:[(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium mb-3",children:"By org"}),a.jsx("div",{className:"space-y-3",children:u.map(t=>{let s=e.orgs[t.id],r=s.last7d.costUSD*(30.4375/7),l=t.plan?.monthlyUSD?r/t.plan.monthlyUSD:null;return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:m(t.id)}}),a.jsx("span",{className:"text-sm text-gray-200 font-medium flex-1",children:t.name}),a.jsx("span",{className:"text-sm text-white font-semibold",children:eJ(s.totalCostUSD)})]}),(0,a.jsxs)("div",{className:"flex gap-2 text-xs text-gray-500 pl-4 flex-wrap",children:[(0,a.jsxs)("span",{children:["5h ",eJ(s.last5h.costUSD)]}),"\xb7",(0,a.jsxs)("span",{children:["24h ",eJ(s.last24h.costUSD)]}),"\xb7",(0,a.jsxs)("span",{children:["7d ",eJ(s.last7d.costUSD)]}),"\xb7",(0,a.jsxs)("span",{children:[s.sessions," sessions"]})]}),t.plan?.monthlyUSD?(0,a.jsxs)("div",{className:"text-xs pl-4 mt-0.5",children:[(0,a.jsxs)("span",{className:"text-gray-500",children:[t.plan.name??"Plan"," ",eJ(t.plan.monthlyUSD),"/mo \xb7 run-rate ",eJ(r),"/mo → "]}),(0,a.jsxs)("span",{className:`font-semibold ${l>=1?"text-emerald-500":"text-yellow-500"}`,children:[l.toFixed(1),"\xd7 plan value"]})]}):a.jsx("div",{className:"text-[10px] text-gray-700 pl-4 mt-0.5",children:"Set plan.monthlyUSD in orgs.json to see ROI vs subscription"})]},t.id)})})]}),(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium mb-3",children:"Tokens (all-time)"}),a.jsx("div",{className:"space-y-2.5",children:[["Output",p.out,"what the models wrote"],["Input (fresh)",p.inp,"uncached prompt tokens"],["Cache reads",p.cache,"context served from cache at ~0.1\xd7 price"]].map(([e,t,s])=>(0,a.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,a.jsxs)("div",{children:[a.jsx("span",{className:"text-sm text-gray-300",children:e}),a.jsx("span",{className:"text-xs text-gray-600 ml-2",children:s})]}),a.jsx("span",{className:"text-sm text-white font-semibold",children:eB(t)})]},e))})]})]}),(0,a.jsxs)("div",{className:"bg-gray-900 rounded-lg p-5",children:[a.jsx("h3",{className:"text-sm text-gray-200 font-medium mb-3",children:"Most expensive sessions"}),0===y.length?a.jsx("p",{className:"text-xs text-gray-600",children:"No usage recorded"}):a.jsx("div",{className:"space-y-0.5",children:y.map(e=>(0,a.jsxs)("button",{onClick:()=>e.liveId?o(e.liveId):d(e.sessionId,e.cwd,e.orgId),className:"w-full flex items-center gap-3 px-2 py-1.5 rounded hover:bg-gray-800/70 text-left",children:[a.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:m(e.orgId)}}),a.jsx("span",{className:"text-sm text-gray-200 truncate flex-1",title:e.name,children:e.name}),e.liveId&&a.jsx("span",{className:"text-[10px] text-blue-500/80 flex-shrink-0",children:"live"}),(0,a.jsxs)("span",{className:"text-xs text-gray-600 flex-shrink-0 w-20 text-right",children:[eB(e.tokens.output)," out"]}),a.jsx("span",{className:"text-sm text-emerald-500 font-medium flex-shrink-0 w-16 text-right",children:eJ(e.cost)})]},e.sessionId))})]})]}),c&&a.jsx("div",{className:"absolute z-30 pointer-events-none bg-gray-800 border border-gray-700 rounded px-2.5 py-1.5 shadow-lg",style:{left:c.x,top:c.y},children:c.lines.map((e,t)=>a.jsx("p",{className:0===t?"text-xs text-gray-400":"text-xs text-white font-medium",children:e},t))})]})}let eq={transcript:[],notes:null,suggestions:[],qa:[],lastError:null,context:null},eG=n()(async()=>{},{loadableGenerated:{modules:["app/page.tsx -> ./components/Terminal"]},ssr:!1});function eK(){let{sessions:e,loading:t,deleteSession:s,refresh:l}=function(){let[e,t]=(0,r.useState)([]),[s,a]=(0,r.useState)(!0);return{sessions:e,loading:s,deleteSession:async function(e){t(t=>t.filter(t=>t.sessionId!==e)),await fetch(`/api/sessions/${e}`,{method:"DELETE"})},refresh:(0,r.useCallback)(()=>fetch("/api/sessions").then(e=>e.json()).then(e=>{t(e.map(e=>e.title?{...e,firstUserMessage:e.title}:e)),a(!1)}).catch(()=>a(!1)),[])}}(),{permission:n,enabled:i,requestPermission:o,notifyNeedsInput:d}=function(){let[e,t]=(0,r.useState)("unsupported"),[s,a]=(0,r.useState)(!0);return{permission:e,enabled:s,requestPermission:(0,r.useCallback)(()=>"undefined"==typeof Notification?Promise.resolve():Notification.requestPermission().then(t),[]),notifyNeedsInput:(0,r.useCallback)((e,t,s)=>{if(!c||"undefined"==typeof Notification||"granted"!==Notification.permission)return;let a=new Notification(e,{body:t,icon:"/favicon.ico"});s&&(a.onclick=()=>{window.focus(),s(),a.close()})},[])}}(),{removeWorktree:x,sendToLive:u,ws:m,liveSessions:p,activeSessionId:g,lastCreatedId:h,sessionError:b,setSessionError:y,attachSession:f,createSession:j,resumeSession:N,resumeAllSessions:v,killLiveSession:w,compactSession:k,setRemote:S}=function(){let e=(0,r.useRef)(null),[t,s]=(0,r.useState)(null),[a,l]=(0,r.useState)([]),[n,i]=(0,r.useState)(null),[o,d]=(0,r.useState)("idle"),[c,x]=(0,r.useState)(null),[u,m]=(0,r.useState)(null),p=(0,r.useRef)(null),g=(0,r.useCallback)((t,s,a,r,l,n,i,o)=>{e.current?.send(JSON.stringify({type:"create",cwd:t,orgId:s,name:a,backend:r,model:l,prompt:n,worktree:!!i,taskId:o}))},[]),h=(0,r.useCallback)(t=>{e.current?.send(JSON.stringify({type:"worktree-remove",sessionId:t}))},[]),b=(0,r.useCallback)((t,s,a,r,l,n)=>{e.current?.send(JSON.stringify({type:"resume",cwd:t,claudeSessionId:s,orgId:a,name:r,backend:l,model:n}))},[]),y=(0,r.useCallback)(()=>{l(e=>e.map(e=>"idle"===e.status&&e.claudeSessionId?{...e,status:"thinking"}:e)),e.current?.send(JSON.stringify({type:"resume-all"}))},[]),f=(0,r.useCallback)(t=>{i(t),p.current=t,e.current?.send(JSON.stringify({type:"attach",sessionId:t}))},[]),j=(0,r.useCallback)((t,s)=>{e.current?.send(JSON.stringify({type:"set-rc",sessionId:t,on:s}))},[]),N=(0,r.useCallback)(t=>{e.current?.send(JSON.stringify({type:"restart",sessionId:t}))},[]),v=(0,r.useCallback)(t=>{e.current?.send(JSON.stringify({type:"compact",sessionId:t}))},[]),w=(0,r.useCallback)(t=>{e.current?.send(JSON.stringify({type:"kill",sessionId:t})),l(e=>e.filter(e=>e.id!==t)),p.current===t&&(i(null),p.current=null)},[]);return{removeWorktree:h,sendToLive:(0,r.useCallback)((t,s)=>{e.current?.send(JSON.stringify({type:"send-to-live",id:t,text:s}))},[]),ws:t,liveSessions:a,activeSessionId:n,activeStatus:o,lastCreatedId:u,sessionError:c,setSessionError:x,createSession:g,resumeSession:b,resumeAllSessions:y,attachSession:f,killLiveSession:w,compactSession:v,restartSession:N,setRemote:j}}(),{watchers:C,watcherError:D,watcherCmd:$}=function(e,t){let[s,a]=(0,r.useState)([]),[l,n]=(0,r.useState)(null),i=(0,r.useRef)(e);return i.current=e,(0,r.useRef)(t).current=t,{watchers:s,watcherError:l,watcherCmd:(0,r.useCallback)((e,t={})=>{n(null),i.current?.send(JSON.stringify({type:e,...t}))},[])}}(m,(e,t)=>d(`👂 ${e}`,t)),[I,A]=(0,r.useState)(!1),[O,P]=(0,r.useState)(null),{setPipelineAuto:M,pipelines:E,pipelineError:U,startPipeline:F,stopPipeline:_,addPipelinePr:J,actPipeline:B,dismissPipeline:H}=function(e,t){let[s,a]=(0,r.useState)([]),[l,n]=(0,r.useState)(null),i=(0,r.useRef)(e);i.current=e,(0,r.useRef)(t).current=t;let o=(0,r.useCallback)((e,t)=>{n(null),i.current?.send(JSON.stringify({type:"pipeline-start",liveId:e,config:t}))},[]),d=(0,r.useCallback)((e,t,s)=>{n(null),i.current?.send(JSON.stringify({type:"pipeline-add-pr",id:e,liveId:t,url:s}))},[]),c=(0,r.useCallback)((e,t,s)=>{n(null),i.current?.send(JSON.stringify({type:"pipeline-act",id:e,liveId:t,prUrl:s}))},[]),x=(0,r.useCallback)((e,t)=>{i.current?.send(JSON.stringify({type:"pipeline-dismiss",id:e,prUrl:t}))},[]);return{setPipelineAuto:(0,r.useCallback)((e,t)=>{i.current?.send(JSON.stringify({type:"pipeline-auto",id:e,auto:t}))},[]),pipelines:s,pipelineError:l,startPipeline:o,stopPipeline:(0,r.useCallback)(e=>{i.current?.send(JSON.stringify({type:"pipeline-stop",id:e}))},[]),addPipelinePr:d,actPipeline:c,dismissPipeline:x}}(m,(e,t)=>d(`⚡ ${e}`,t)),{entries:W}=function(e){let[t,s]=(0,r.useState)([]),[a,l]=(0,r.useState)(!0),[n,i]=(0,r.useState)(!1);return(0,r.useCallback)(()=>fetch("/api/prs").then(e=>e.json()).then(s).catch(()=>{}).finally(()=>l(!1)),[]),{entries:t,loading:a,refreshing:n,refresh:(0,r.useCallback)(async()=>{i(!0);try{let e=await fetch("/api/prs/refresh",{method:"POST"});s(await e.json())}catch{}finally{i(!1)}},[])}}(0),{inbox:z,loading:q,refreshing:G,refresh:Y}=function(e){let[t,s]=(0,r.useState)(null),[a,l]=(0,r.useState)(!0),[n,i]=(0,r.useState)(!1),o=(0,r.useCallback)((e=!1)=>fetch(`/api/prs/inbox${e?"?refresh=1":""}`).then(e=>e.json()).then(s).catch(()=>{}).finally(()=>l(!1)),[]);return{inbox:t,loading:a,refreshing:n,refresh:(0,r.useCallback)(async()=>{i(!0);try{await o(!0)}finally{i(!1)}},[o])}}(0),{orgs:V,addOrg:X,refreshOrgs:Q}=function(){let[e,t]=(0,r.useState)([]),s=(0,r.useCallback)(()=>fetch("/api/orgs").then(e=>e.json()).then(t).catch(()=>{}),[]);return{orgs:e,addOrg:(0,r.useCallback)(async(e,s,a)=>{let r=await fetch("/api/orgs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,configDir:s,model:a})});if(!r.ok)throw Error((await r.json().catch(()=>null))?.error??"Failed to add org");let l=await r.json();return t(e=>[...e,l]),l},[]),refreshOrgs:s}}(),{notes:et,setNotes:es}=function(){let[e,t]=(0,r.useState)([]),[s,a]=(0,r.useState)(!1),l=(0,r.useRef)(e);l.current=e;let n=(0,r.useRef)(null);return{notes:e,setNotes:(0,r.useCallback)(e=>{let s="function"==typeof e?e(l.current):e;l.current=s,t(s),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{fetch("/api/notes",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notes:l.current})}).catch(()=>{})},300)},[]),loaded:s}}(),[er,ei]=(0,r.useState)(0),{meetings:eo,live:ed,activeMeeting:ec,startMeeting:ex,resumeMeeting:eu,stopMeeting:ep,askMeeting:eg,addMeetingContext:eh,micTest:eb,refreshMeetings:ey}=function(e){let[t,s]=(0,r.useState)([]),[a,l]=(0,r.useState)({}),n=(0,r.useRef)(e);n.current=e;let i=(0,r.useCallback)(()=>fetch("/api/meetings").then(e=>e.json()).then(s).catch(()=>{}),[]),o=(0,r.useCallback)((e,t)=>{n.current?.send(JSON.stringify({type:"meeting-start",title:e,orgId:t}))},[]),d=(0,r.useCallback)(e=>{n.current?.send(JSON.stringify({type:"meeting-resume",meetingId:e}))},[]),c=(0,r.useCallback)(e=>{n.current?.send(JSON.stringify({type:"meeting-stop",meetingId:e}))},[]),x=(0,r.useCallback)((e,t)=>{l(s=>{let a=s[e]??eq;return{...s,[e]:{...a,qa:[...a.qa,{question:t,answer:null,t:Date.now()}]}}}),n.current?.send(JSON.stringify({type:"meeting-ask",meetingId:e,question:t}))},[]),u=(0,r.useCallback)((e,t,s)=>{n.current?.send(JSON.stringify({type:"meeting-add-context",meetingId:e,kind:t,value:s}))},[]),m=(0,r.useCallback)(()=>new Promise(e=>{let t=n.current;if(!t||t.readyState!==WebSocket.OPEN){e({error:"Not connected"});return}let s=setTimeout(()=>{t.removeEventListener("message",a),e({error:"Mic test timed out"})},15e3);function a(r){try{let l=JSON.parse(r.data);"meeting-mic-test-result"===l.type&&(clearTimeout(s),t.removeEventListener("message",a),e(l))}catch{}}t.addEventListener("message",a),t.send(JSON.stringify({type:"meeting-mic-test"}))}),[]),p=t.find(e=>"recording"===e.status)??null;return{meetings:t,live:a,activeMeeting:p,startMeeting:o,resumeMeeting:d,stopMeeting:c,askMeeting:x,addMeetingContext:u,micTest:m,refreshMeetings:i}}(m),{usage:ef}=function(){let[e,t]=(0,r.useState)(null),[s,a]=(0,r.useState)(!0);return{usage:e,loading:s,refreshUsage:(0,r.useCallback)(()=>fetch("/api/usage").then(e=>e.json()).then(t).catch(()=>{}).finally(()=>a(!1)),[])}}(),{limits:ej}=function(){let[e,t]=(0,r.useState)(null);return(0,r.useCallback)(()=>fetch("/api/limits").then(e=>e.json()).then(t).catch(()=>{}),[]),{limits:e}}(),[ek,eS]=(0,r.useState)({mode:"empty"}),[e$,eI]=(0,r.useState)(!1),[eR,eP]=(0,r.useState)(!1),eM=(0,r.useRef)(!1),[eL,eT]=(0,r.useState)(288),[eE,eU]=(0,r.useState)([]),[e_,eJ]=(0,r.useState)("all");(0,ee.n)(e_);let eB=(0,r.useRef)(!1),eH=(0,r.useRef)(""),eW=e=>e&&eS({mode:"pipeline",liveId:e}),[eK,eY]=(0,r.useState)(!1),[eV,eX]=(0,r.useState)({});(0,r.useRef)({}),(0,r.useRef)({}),(0,r.useRef)({}),(0,r.useRef)(null);let eQ=(0,r.useCallback)(e=>{e.preventDefault(),eB.current=!0;let t=e.clientX;function s(e){eB.current&&eT(Math.min(600,Math.max(160,eL+e.clientX-t)))}window.addEventListener("mousemove",s),window.addEventListener("mouseup",function e(){eB.current=!1,window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",e)})},[eL]);function eZ(e,t,s){t?N(t,e,s):j("")}let[e0,e1]=(0,r.useState)(!1);function e5(e){f(e),eS({mode:"live"})}let e2=(0,r.useRef)(null),e3=(0,r.useCallback)(()=>{let t=(t,s,a)=>eV[t]||s&&eV[s]||e.find(e=>e.sessionId===s)?.firstUserMessage||a.split("/").at(-1)||"Session",s=new Set(p.map(e=>e.claudeSessionId)),a=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"});return[{id:"home",group:"Actions",label:"Home",run:()=>eS({mode:"empty"})},{id:"new-session",group:"Actions",label:"New session",run:()=>eI(!0)},{id:"record",group:"Actions",label:"Record a meeting",run:()=>eP(!0)},{id:"recordings",group:"Actions",label:"Open recordings",run:()=>eS({mode:"meetinglib"})},{id:"notes",group:"Actions",label:"Open notes",run:()=>eS({mode:"notes",id:null})},{id:"settings",group:"Actions",label:"Open settings",run:()=>eS({mode:"settings"})},{id:"board",group:"Actions",label:"Open task board",run:()=>eS({mode:"board"})},{id:"skills",group:"Actions",label:"Open skills",run:()=>eS({mode:"skills",name:null})},{id:"usage",group:"Actions",label:"Open usage",run:()=>eS({mode:"usagedash"})},{id:"prs",group:"Actions",label:"Open PR dashboard",run:()=>eS({mode:"prdash"})},{id:"slack",group:"Actions",label:"Open Slack inbox",run:()=>eS({mode:"slack"})},{id:"automations",group:"Actions",label:"Open automations",run:()=>eS({mode:"automations"})},...p.map(e=>({id:e.id,group:"Live sessions",label:t(e.id,e.claudeSessionId,e.cwd).slice(0,90),hint:e.status,run:()=>e5(e.id)})),...e.filter(e=>!e.headless&&!s.has(e.sessionId)).map(e=>({id:e.sessionId,group:"History",label:(eV[e.sessionId]||e.firstUserMessage||e.cwd?.split("/").at(-1)||"Session").slice(0,90),hint:e.lastTimestamp?a(e.lastTimestamp):void 0,run:()=>eZ(e.sessionId,e.cwd,e.orgId)})),...eo.map(e=>({id:e.id,group:"Meetings",label:e.title,hint:a(e.startedAt),run:()=>eS({mode:"meeting",meetingId:e.id})})),...et.map(e=>({id:e.id,group:"Notes",label:e.text.split("\n").find(e=>e.trim())?.trim().slice(0,90)||"Untitled",hint:a(e.createdAt),run:()=>eS({mode:"notes",id:e.id})})),...(e2.current??[]).map(e=>({id:e.name,group:"Skills",label:e.name,hint:e.description.slice(0,60),run:()=>eS({mode:"skills",name:e.name})}))]},[p,e,eo,et,eV]),e4="meeting"===ek.mode?eo.find(e=>e.id===ek.meetingId)??null:null;return(0,a.jsxs)("div",{className:"flex h-screen bg-[#0d1117] text-white overflow-hidden",children:[a.jsx("div",{style:{width:eL,flexShrink:0},className:"h-screen overflow-hidden",children:a.jsx(R,{liveSessions:p,orgs:V,activeOrgId:e_,onSwitchOrg:function(e){eJ(e);try{localStorage.setItem("claude-active-org",e)}catch{}},historySessions:e,historyLoading:t,activeSessionId:g,selectedHistoryId:null,sessionNameOverrides:eV,onAttachLive:e5,onKillLive:w,onRemoveWorktree:x,onReview:e=>eS({mode:"diff",liveId:e}),onDeleteLive:function(e,t){w(e),t&&s(t)},onResumeLive:function(e){let t=p.find(t=>t.id===e);t?.claudeSessionId&&N(t.cwd,t.claudeSessionId)},onResumeAll:v,onCompact:k,onSetRemote:S,onNewSession:()=>eI(!0),onSelectHistory:eZ,onDeleteSession:s,inbox:z,inboxLoading:q,inboxRefreshing:G,onRefreshInbox:Y,onOpenPrDashboard:()=>eS({mode:"prdash"}),meetings:eo,selectedMeetingId:"meeting"===ek.mode?ek.meetingId:null,onSelectMeeting:e=>eS({mode:"meeting",meetingId:e}),onRecordMeeting:()=>eP(!0),onOpenMeetingLibrary:()=>eS({mode:"meetinglib"}),pipelines:E,onOrgsChanged:Q,onRenameLive:(e,t)=>m?.send(JSON.stringify({type:"rename-live",id:e,name:t})),notes:et,setNotes:es,onOpenNotes:e=>eS({mode:"notes",id:e}),onOpenSkills:e=>eS({mode:"skills",name:e}),onOpenSettings:()=>eS({mode:"settings"}),onOpenBoard:()=>eS({mode:"board"}),onOpenSlack:e0?()=>eS({mode:"slack"}):void 0,onOpenAutomations:()=>eS({mode:"automations"}),onHome:()=>eS({mode:"empty"}),selectedNoteId:"notes"===ek.mode?ek.id:null,selectedSkill:"skills"===ek.mode?ek.name:null,skillsVersion:er,onAutomate:eW,usage:ef,onOpenUsage:()=>eS({mode:"usagedash"})})}),a.jsx("div",{onMouseDown:eQ,className:"w-1 flex-shrink-0 bg-gray-800 hover:bg-blue-500 cursor-col-resize transition-colors"}),(0,a.jsxs)("div",{className:"flex-1 relative overflow-hidden",children:[ec&&!("meeting"===ek.mode&&ek.meetingId===ec.id)&&(0,a.jsxs)("button",{onClick:()=>eS({mode:"meeting",meetingId:ec.id}),className:"absolute top-0 left-0 right-0 z-20 bg-red-900/90 hover:bg-red-800 text-red-100 text-xs py-1 flex items-center justify-center gap-2 transition-colors",children:[a.jsx("span",{className:"w-2 h-2 rounded-full bg-red-400 animate-pulse"}),"Recording — ",ec.title]}),a.jsx(eG,{visible:"live"===ek.mode,ws:m}),"usagedash"===ek.mode&&ef&&a.jsx(ez,{usage:ef,limits:ej,orgs:V,activeOrgId:e_,historySessions:e,liveSessions:p,onAttachLive:e5,onSelectHistory:eZ}),"prdash"===ek.mode&&z&&a.jsx(eF,{inbox:z,orgs:V,activeOrgId:e_,refreshing:G,onRefresh:Y,onAttachLive:e5,onSelectHistory:eZ,onReviewWithClaude:function(e){let t=`CR ${e.match(/([\w.-]+)\/pull\/(\d+)/)?.[0]??""}`.trim();eH.current=t,j("general","all"===e_?void 0:e_,t,void 0,void 0,`cr ${e}`)}}),"slack"===ek.mode&&a.jsx(em,{onSendAgent:function(e){let t=`Someone needs me on Slack. ${e.isDm?`Direct message from ${e.author}`:`${e.author} in #${e.channel}`}: ${e.permalink} . Read the message and its whole thread with the Slack connector, figure out what they need, and look into it (code, docs, data) as far as you can. Then show me a draft reply. Do not post anything to Slack until I approve it.`,s=`Slack: ${e.author}${e.isDm?"":` #${e.channel}`}`.slice(0,60);eH.current=s,j("general","all"===e_?void 0:e_,s,void 0,void 0,t)},sessions:p.filter(e=>e.claudeSessionId&&("all"===e_||(e.orgId??"default")===e_)).map(t=>({id:t.id,resumeId:t.claudeSessionId,cwd:t.cwd,label:(eV[t.id]||eV[t.claudeSessionId]||e.find(e=>e.sessionId===t.claudeSessionId)?.firstUserMessage||t.cwd.split("/").at(-1)||"Session").slice(0,70)})),onOpenSession:e5,onAskSession:(e,t)=>u(e,`${t.isDm?`${t.author} sent me a Slack DM`:`${t.author} tagged me in Slack #${t.channel}`} about this work: ${t.permalink} . Read the message and its thread with the Slack connector, check it against what we did here, and draft a reply for me. Do not post anything to Slack until I approve it.`),orgName:"all"===e_?"Default":V.find(e=>e.id===e_)?.name??"Default"},e_),"automations"===ek.mode&&a.jsx(eN,{pipelines:E.filter(e=>"all"===e_||(p.find(t=>t.id===e.liveId)?.orgId??"default")===e_),watchers:C.filter(e=>"all"===e_||(e.orgId??"default")===e_),showMacLoops:"all"===e_||"default"===e_,watcherCmd:$,onNewWatcher:()=>A(!0),onEditWatcher:e=>P(e),sessions:p.filter(e=>e.claudeSessionId&&("all"===e_||(e.orgId??"default")===e_)).map(t=>({id:t.id,label:(eV[t.id]||t.claudeSessionId&&eV[t.claudeSessionId]||e.find(e=>e.sessionId===t.claudeSessionId)?.firstUserMessage||t.cwd.split("/").at(-1)||"Session").slice(0,70)})),nameOf:t=>{let s=p.find(e=>e.id===t);return s&&(eV[s.id]||s.claudeSessionId&&eV[s.claudeSessionId]||e.find(e=>e.sessionId===s.claudeSessionId)?.firstUserMessage||s.cwd.split("/").at(-1))||"Session"},onOpen:e=>eW(e),onStop:_}),"board"===ek.mode&&a.jsx(eO,{orgId:e_,folders:Array.from(new Set([...e.map(e=>e.cwd).filter(Boolean),...eE])).filter(e=>!/\/General(\/[^/]+)?$|\/\.(claude-session-manager|polyergon[^/]*)(\/|$)|^\/private\/(tmp|var\/folders)\//.test(e)).sort((e,t)=>(e.split("/").at(-1)??e).localeCompare(t.split("/").at(-1)??t)),liveSessions:p,pipelines:E,onStart:e=>{eH.current=e.title.slice(0,60),j(e.cwd,e.orgId,e.title.slice(0,60),void 0,void 0,e.details?`${e.title}
9
+
10
+ ${e.details}`:e.title,e.worktree,e.id)},onOpenSession:e5,onReview:e=>eS({mode:"diff",liveId:e}),onAutomate:e=>eS({mode:"pipeline",liveId:e}),onAct:(e,t,s)=>B(e,t,s),onDismiss:H}),"diff"===ek.mode&&(()=>{let t=ek.liveId,s=p.find(e=>e.id===t),r=s&&(eV[s.id]||s.claudeSessionId&&eV[s.claudeSessionId]||e.find(e=>e.sessionId===s.claudeSessionId)?.firstUserMessage||s.cwd.split("/").at(-1))||"Session",l=Array.from(new Set([...s?.prUrl?[s.prUrl]:[],...E.filter(e=>e.liveId===t).flatMap(e=>e.prs.map(e=>e.url))]));return a.jsx(eA,{liveId:t,sessionName:r,hasRepo:!!s?.gitRoot,prUrls:l,onSend:e=>u(t,e),onOpenSession:()=>e5(t)},t)})(),"pipeline"===ek.mode&&(()=>{let t=ek.liveId,s=p.find(e=>e.id===t),r=s&&(eV[s.id]||s.claudeSessionId&&eV[s.claudeSessionId]||e.find(e=>e.sessionId===s.claudeSessionId)?.firstUserMessage||s.cwd.split("/").at(-1))||"Session";return a.jsx(eD.C,{sessionName:r,pipeline:[...E].reverse().find(e=>e.liveId===t)??null,error:U?.liveId===t?U.message:null,onOpenSession:()=>e5(t),onReview:()=>eS({mode:"diff",liveId:t}),onStart:e=>F(t,e),onStop:_,onAddPr:(e,s)=>J(e,t,s),onAct:(e,s)=>B(e,t,s),onDismiss:H,onSetAuto:M},t)})(),"settings"===ek.mode&&a.jsx(eC,{onClose:()=>eS({mode:"empty"})},e_),"skills"===ek.mode&&a.jsx(ea,{selected:ek.name,onSelect:e=>eS({mode:"skills",name:e}),onChanged:()=>ei(e=>e+1)},e_),"notes"===ek.mode&&a.jsx(el,{notes:et,setNotes:es,orgs:V,activeOrgId:e_,selected:ek.id,onSelect:e=>eS({mode:"notes",id:e})}),"meetinglib"===ek.mode&&a.jsx(Z,{orgs:V,activeOrgId:e_,refreshKey:eo.map(e=>e.id+e.status).join(),onOpen:e=>eS({mode:"meeting",meetingId:e}),onDeleted:ey}),"meeting"===ek.mode&&e4&&a.jsx(K,{meeting:e4,live:ed[e4.id],orgName:"default"!==e4.orgId?V.find(e=>e.id===e4.orgId)?.name??null:null,onStop:ep,onResume:eu,onAsk:eg,onAddContext:eh,onBack:()=>eS({mode:"meetinglib"}),sessionOptions:e.filter(e=>!e.headless).sort((e,t)=>(t.lastTimestamp??"").localeCompare(e.lastTimestamp??"")).map(e=>{let t=p.find(t=>t.claudeSessionId===e.sessionId),s=t&&eV[t.id]||eV[e.sessionId]||e.firstUserMessage||e.cwd?.split("/").at(-1)||"Session",a=s.length>60?s.slice(0,60)+"…":s,r=e.lastTimestamp?new Date(e.lastTimestamp).toLocaleDateString(void 0,{month:"short",day:"numeric"}):"";return{id:e.sessionId,label:a,hint:r}}),meetingOptions:eo.filter(e=>"recording"!==e.status).map(e=>({id:e.id,label:e.title,hint:new Date(e.startedAt).toLocaleDateString(void 0,{month:"short",day:"numeric"})}))}),"empty"===ek.mode&&(()=>{let t=e=>"all"===e_||(e??"default")===e_,s=ef?"all"===e_?Object.values(ef.orgs):[ef.orgs[e_]].filter(Boolean):[],r=new Date().setHours(0,0,0,0);return a.jsx(ev,{orgName:"all"===e_?"All orgs":V.find(e=>e.id===e_)?.name??"Default",live:p.filter(e=>t(e.orgId)),nameOf:t=>{let s=p.find(e=>e.id===t);return s&&(eV[s.id]||s.claudeSessionId&&eV[s.claudeSessionId]||e.find(e=>e.sessionId===s.claudeSessionId)?.firstUserMessage||s.cwd.split("/").at(-1))||"Session"},meetings:eo.filter(e=>t(e.orgId)),notes:et.filter(e=>t(e.orgId)),pipelines:E.filter(e=>t(p.find(t=>t.id===e.liveId)?.orgId)),watchers:C.filter(e=>t(e.orgId)),inbox:z,usageOrg:s.length?{today:s.reduce((e,t)=>e+(t.daily.find(e=>e.dayStart===r)?.costUSD??0),0),week:s.reduce((e,t)=>e+t.last7d.costUSD,0)}:null,onAttach:e5,onOpen:e=>eS("object"==typeof e?{mode:"meeting",meetingId:e.meetingId}:"notes"===e?{mode:"notes",id:null}:{mode:e}),onNewSession:()=>eI(!0),onRecord:()=>eP(!0)})})(),b&&(0,a.jsxs)("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 bg-red-900/90 border border-red-700 text-red-200 text-sm px-4 py-2 rounded shadow-lg flex items-center gap-3 z-10",children:[a.jsx("span",{children:b}),a.jsx("button",{onClick:()=>y(null),className:"text-red-400 hover:text-white font-bold",children:"\xd7"})]}),i&&"default"===n&&!eK&&(0,a.jsxs)("div",{className:"absolute bottom-4 right-4 bg-gray-900/95 border border-gray-700 text-sm px-4 py-2 rounded-lg shadow-lg flex items-center gap-3 z-10",children:[a.jsx("span",{className:"text-gray-300",children:"Get notified when a session needs input"}),a.jsx("button",{onClick:o,className:"bg-blue-600 hover:bg-blue-500 text-white rounded px-2 py-1 text-xs font-medium",children:"Enable notifications"}),a.jsx("button",{onClick:()=>eY(!0),className:"text-gray-500 hover:text-white","aria-label":"Dismiss",children:"✕"})]})]}),a.jsx(en,{items:e3}),O&&a.jsx(ew,{initial:O,sessions:p.filter(e=>e.claudeSessionId&&(e.orgId??"default")===(O.orgId??"default")).map(t=>({id:t.id,label:(eV[t.id]||t.claudeSessionId&&eV[t.claudeSessionId]||e.find(e=>e.sessionId===t.claudeSessionId)?.firstUserMessage||t.cwd.split("/").at(-1)||"Session").slice(0,70)})),error:D,onCreate:({liveId:e,mode:t,intervalMin:s,knowledge:a,instructions:r})=>$("watcher-update",{id:O.id,patch:{liveId:e,mode:t,intervalMin:s,knowledge:a,instructions:r}}),onClose:()=>P(null)}),I&&a.jsx(ew,{sessions:p.filter(e=>e.claudeSessionId&&("all"===e_||(e.orgId??"default")===e_)).map(t=>({id:t.id,label:(eV[t.id]||t.claudeSessionId&&eV[t.claudeSessionId]||e.find(e=>e.sessionId===t.claudeSessionId)?.firstUserMessage||t.cwd.split("/").at(-1)||"Session").slice(0,70)})),error:D,onCreate:e=>$("watcher-create",{...e,orgId:"all"===e_?"default":e_}),onClose:()=>A(!1)}),eR&&a.jsx(T,{orgs:V,defaultOrgId:"all"===e_?"default":e_,onStart:function(e,t){eP(!1),eM.current=!0,ex(e,t)},onCancel:()=>eP(!1),onMicTest:eb}),e$&&a.jsx(L,{knownCwds:Array.from(new Set([...e.map(e=>e.cwd).filter(Boolean),...eE])),orgs:V,defaultOrgId:"all"===e_?"default":e_,onAddOrg:X,onConfirm:function(t,s,a,r,l,n,i){if(eI(!1),eH.current=s,"general"!==t&&!e.some(e=>e.cwd===t)){let e=Array.from(new Set([t,...eE])).slice(0,20);eU(e);try{localStorage.setItem("customPaths",JSON.stringify(e))}catch{}}j(t,a,s,r,l,n,i)},onResumeById:function(e,t,s,a,r){eI(!1),eH.current=t,N("general",e,s,t,a,r)},onCancel:()=>eI(!1)})]})}},5480:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>a});let a=(0,s(8570).createProxy)(String.raw`/private/tmp/claude-503/-Users-ofiryehoshua/0b425a50-f3c5-49e8-a60e-788bd3aae351/scratchpad/npm-build/src/app/page.tsx#default`)}};var t=require("../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),a=t.X(0,[948,471,621,904],()=>s(6993));module.exports=a})();