agent-log-viewer 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 (121) hide show
  1. package/README.md +24 -25
  2. package/bin/tailscale.mjs +58 -3
  3. package/dist/standalone/.next/BUILD_ID +1 -1
  4. package/dist/standalone/.next/app-path-routes-manifest.json +8 -2
  5. package/dist/standalone/.next/build-manifest.json +2 -2
  6. package/dist/standalone/.next/prerender-manifest.json +3 -3
  7. package/dist/standalone/.next/routes-manifest.json +40 -1
  8. package/dist/standalone/.next/server/app/_global-error/page.js +3 -3
  9. package/dist/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  10. package/dist/standalone/.next/server/app/_global-error.html +1 -1
  11. package/dist/standalone/.next/server/app/_global-error.rsc +1 -1
  12. package/dist/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  13. package/dist/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  14. package/dist/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  15. package/dist/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  16. package/dist/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  17. package/dist/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  18. package/dist/standalone/.next/server/app/_not-found/page.js +2 -2
  19. package/dist/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  20. package/dist/standalone/.next/server/app/_not-found.html +1 -1
  21. package/dist/standalone/.next/server/app/_not-found.rsc +2 -2
  22. package/dist/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  23. package/dist/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  24. package/dist/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  25. package/dist/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  26. package/dist/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  27. package/dist/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  28. package/dist/standalone/.next/server/app/api/access/route.js +1 -1
  29. package/dist/standalone/.next/server/app/api/answer/route.js +1 -0
  30. package/dist/standalone/.next/server/app/api/answer/route.js.nft.json +1 -0
  31. package/dist/standalone/.next/server/app/api/answer/route_client-reference-manifest.js +1 -0
  32. package/dist/standalone/.next/server/app/api/files/route.js +1 -1
  33. package/dist/standalone/.next/server/app/api/files/route.js.nft.json +1 -1
  34. package/dist/standalone/.next/server/app/api/flows/[id]/route.js +1 -0
  35. package/dist/standalone/.next/server/app/api/flows/[id]/route.js.nft.json +1 -0
  36. package/dist/standalone/.next/server/app/api/flows/[id]/route_client-reference-manifest.js +1 -0
  37. package/dist/standalone/.next/server/app/api/flows/route.js +1 -0
  38. package/dist/standalone/.next/server/app/api/flows/route.js.nft.json +1 -0
  39. package/dist/standalone/.next/server/app/api/flows/route_client-reference-manifest.js +1 -0
  40. package/dist/standalone/.next/server/app/api/inbox/route.js +1 -0
  41. package/dist/standalone/.next/server/app/api/inbox/route.js.nft.json +1 -0
  42. package/dist/standalone/.next/server/app/api/inbox/route_client-reference-manifest.js +1 -0
  43. package/dist/standalone/.next/server/app/api/limits/route.js +1 -0
  44. package/dist/standalone/.next/server/app/api/limits/route.js.nft.json +1 -0
  45. package/dist/standalone/.next/server/app/api/limits/route_client-reference-manifest.js +1 -0
  46. package/dist/standalone/.next/server/app/api/log/route.js +1 -1
  47. package/dist/standalone/.next/server/app/api/log/route.js.nft.json +1 -1
  48. package/dist/standalone/.next/server/app/api/proc/route.js +1 -1
  49. package/dist/standalone/.next/server/app/api/proc/route.js.nft.json +1 -1
  50. package/dist/standalone/.next/server/app/api/push/route.js +1 -0
  51. package/dist/standalone/.next/server/app/api/push/route.js.nft.json +1 -0
  52. package/dist/standalone/.next/server/app/api/push/route_client-reference-manifest.js +1 -0
  53. package/dist/standalone/.next/server/app/api/spawn/route.js +1 -1
  54. package/dist/standalone/.next/server/app/api/spawn/route.js.nft.json +1 -1
  55. package/dist/standalone/.next/server/app/api/timeline/route.js +1 -1
  56. package/dist/standalone/.next/server/app/api/timeline/route.js.nft.json +1 -1
  57. package/dist/standalone/.next/server/app/api/tmux/route.js +2 -2
  58. package/dist/standalone/.next/server/app/api/tmux/route.js.nft.json +1 -1
  59. package/dist/standalone/.next/server/app/api/transcribe/route.js +1 -1
  60. package/dist/standalone/.next/server/app/favicon.ico/route.js +1 -1
  61. package/dist/standalone/.next/server/app/index.html +1 -1
  62. package/dist/standalone/.next/server/app/index.rsc +3 -3
  63. package/dist/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  64. package/dist/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
  65. package/dist/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  66. package/dist/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
  67. package/dist/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  68. package/dist/standalone/.next/server/app/page.js +6 -3
  69. package/dist/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  70. package/dist/standalone/.next/server/app-paths-manifest.json +8 -2
  71. package/dist/standalone/.next/server/chunks/871.js +4 -0
  72. package/dist/standalone/.next/server/functions-config-manifest.json +6 -0
  73. package/dist/standalone/.next/server/middleware-build-manifest.js +1 -1
  74. package/dist/standalone/.next/server/pages/404.html +1 -1
  75. package/dist/standalone/.next/server/pages/500.html +1 -1
  76. package/dist/standalone/.next/server/server-reference-manifest.json +1 -1
  77. package/dist/standalone/.next/static/0YxRBiEgYCSV92_fZOmmC/_buildManifest.js +1 -0
  78. package/dist/standalone/.next/static/chunks/703-1f675e3bf3e228de.js +1 -0
  79. package/dist/standalone/.next/static/chunks/app/_global-error/page-b58291c8001879c8.js +1 -0
  80. package/dist/standalone/.next/static/chunks/app/api/access/route-b58291c8001879c8.js +1 -0
  81. package/dist/standalone/.next/static/chunks/app/api/answer/route-b58291c8001879c8.js +1 -0
  82. package/dist/standalone/.next/static/chunks/app/api/files/route-b58291c8001879c8.js +1 -0
  83. package/dist/standalone/.next/static/chunks/app/api/flows/[id]/route-b58291c8001879c8.js +1 -0
  84. package/dist/standalone/.next/static/chunks/app/api/flows/route-b58291c8001879c8.js +1 -0
  85. package/dist/standalone/.next/static/chunks/app/api/inbox/route-b58291c8001879c8.js +1 -0
  86. package/dist/standalone/.next/static/chunks/app/api/limits/route-b58291c8001879c8.js +1 -0
  87. package/dist/standalone/.next/static/chunks/app/api/log/route-b58291c8001879c8.js +1 -0
  88. package/dist/standalone/.next/static/chunks/app/api/proc/route-b58291c8001879c8.js +1 -0
  89. package/dist/standalone/.next/static/chunks/app/api/push/route-b58291c8001879c8.js +1 -0
  90. package/dist/standalone/.next/static/chunks/app/api/spawn/route-b58291c8001879c8.js +1 -0
  91. package/dist/standalone/.next/static/chunks/app/api/timeline/route-b58291c8001879c8.js +1 -0
  92. package/dist/standalone/.next/static/chunks/app/api/tmux/route-b58291c8001879c8.js +1 -0
  93. package/dist/standalone/.next/static/chunks/app/api/transcribe/route-b58291c8001879c8.js +1 -0
  94. package/dist/standalone/.next/static/chunks/app/page-169f116d08445993.js +5 -0
  95. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-b58291c8001879c8.js +1 -0
  96. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-b58291c8001879c8.js +1 -0
  97. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-b58291c8001879c8.js +1 -0
  98. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-b58291c8001879c8.js +1 -0
  99. package/dist/standalone/.next/static/css/e3457e19c8be328e.css +1 -0
  100. package/dist/standalone/package.json +1 -1
  101. package/package.json +1 -1
  102. package/dist/standalone/.next/server/chunks/344.js +0 -1
  103. package/dist/standalone/.next/server/chunks/459.js +0 -1
  104. package/dist/standalone/.next/static/OlOoOx99h_Y7pD3fJA_ji/_buildManifest.js +0 -1
  105. package/dist/standalone/.next/static/chunks/206-33d2c732d1a7b380.js +0 -1
  106. package/dist/standalone/.next/static/chunks/app/_global-error/page-a6af3b0a9feab800.js +0 -1
  107. package/dist/standalone/.next/static/chunks/app/api/access/route-a6af3b0a9feab800.js +0 -1
  108. package/dist/standalone/.next/static/chunks/app/api/files/route-a6af3b0a9feab800.js +0 -1
  109. package/dist/standalone/.next/static/chunks/app/api/log/route-a6af3b0a9feab800.js +0 -1
  110. package/dist/standalone/.next/static/chunks/app/api/proc/route-a6af3b0a9feab800.js +0 -1
  111. package/dist/standalone/.next/static/chunks/app/api/spawn/route-a6af3b0a9feab800.js +0 -1
  112. package/dist/standalone/.next/static/chunks/app/api/timeline/route-a6af3b0a9feab800.js +0 -1
  113. package/dist/standalone/.next/static/chunks/app/api/tmux/route-a6af3b0a9feab800.js +0 -1
  114. package/dist/standalone/.next/static/chunks/app/api/transcribe/route-a6af3b0a9feab800.js +0 -1
  115. package/dist/standalone/.next/static/chunks/app/page-6fed5a912688e46f.js +0 -2
  116. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-a6af3b0a9feab800.js +0 -1
  117. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-a6af3b0a9feab800.js +0 -1
  118. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-a6af3b0a9feab800.js +0 -1
  119. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-a6af3b0a9feab800.js +0 -1
  120. package/dist/standalone/.next/static/css/6295a760ad8588f2.css +0 -1
  121. /package/dist/standalone/.next/static/{OlOoOx99h_Y7pD3fJA_ji → 0YxRBiEgYCSV92_fZOmmC}/_ssgManifest.js +0 -0
@@ -1,3 +1,6 @@
1
- (()=>{var a={};a.id=974,a.ids=[974],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4494:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>f});var d=c(5735),e=c(27074);function f(){return(0,d.jsx)(e.Viewer,{})}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{"use strict";a.exports=require("assert")},17891:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/get-segment-param")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},23655:(a,b,c)=>{"use strict";c.r(b),c.d(b,{__next_app__:()=>O,handler:()=>Q,routeModule:()=>P});var d=c(7553),e=c(84006),f=c(67798),g=c(34775),h=c(99373),i=c(73461),j=c(1020),k=c(26349),l=c(54365),m=c(16023),n=c(14965),o=c(63747),p=c(24235),q=c(23938),r=c(261),s=c(66758),t=c(77243),u=c(26713),v=c(37527),w=c(22820),x=c(88216),y=c(47929),z=c(79551),A=c(71797),B=c(89125),C=c(86439),D=c(77068),E=c(27269),F=c(37525),G=c(61287),H=c(81494),I=c(70722),J=c(70753),K=c(43954),L=c(17891),M={};for(let a in G)0>["default","__next_app__","routeModule","handler"].indexOf(a)&&(M[a]=()=>G[a]);c.d(b,M);let N={children:["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,4494)),"/home/latand/.agents/tools/live-log-viewer-next/src/app/page.tsx"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(c.bind(c,76537)),"/home/latand/.agents/tools/live-log-viewer-next/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.t.bind(c,95547,23)),"next/dist/client/components/builtin/global-error.js"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,55091,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,45270,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,28193,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}},[]]}.children,O={require:c,loadChunk:()=>Promise.resolve()},P=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:N},distDir:".next",relativeProjectDir:""});async function Q(a,b,d){var M,R,S,T,U;d.requestMeta&&(0,h.setRequestMeta)(a,d.requestMeta),P.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let V=!!(0,h.getRequestMeta)(a,"minimalMode"),W="/page";"/index"===W&&(W="/");let X=await P.prepare(a,b,{srcPage:W,multiZoneDraftMode:!1});if(!X)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:Y,query:Z,params:$,pageIsDynamic:_,buildManifest:aa,nextFontManifest:ab,reactLoadableManifest:ac,serverActionsManifest:ad,clientReferenceManifest:ae,subresourceIntegrityManifest:af,prerenderManifest:ag,isDraftMode:ah,resolvedPathname:ai,revalidateOnlyGenerated:aj,routerServerContext:ak,nextConfig:al,parsedUrl:am,interceptionRoutePatterns:an,deploymentId:ao,clientAssetToken:ap}=X,aq=(0,r.normalizeAppPath)(W),{isOnDemandRevalidate:ar}=X,as=al.experimental.ppr&&!al.cacheComponents&&(0,K.isInterceptionRouteAppPath)(ai)?null:P.match(ai,ag),at=(null==as?void 0:as.route)??null,au=!!ag.routes[ai],av=a.headers["user-agent"]||"",aw=(0,u.getBotType)(av),ax=(0,q.isHtmlBotRequest)(a),ay=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[t.NEXT_ROUTER_PREFETCH_HEADER],az=(0,h.getRequestMeta)(a,"isRSCRequest")??(0,n.f)(a.headers[t.RSC_HEADER]),aA=(0,s.getIsPossibleServerAction)(a),aB=(0,m.checkIsAppPPREnabled)(al.experimental.ppr),aC=a.headers[y.NEXT_RESUME_STATE_LENGTH_HEADER];if(!(0,h.getRequestMeta)(a,"postponed")&&V&&aB&&aA&&aC&&"string"==typeof aC){let e=parseInt(aC,10),{maxPostponedStateSize:f,maxPostponedStateSizeBytes:g}=(0,E.getMaxPostponedStateSize)(al.experimental.maxPostponedStateSize);if(!isNaN(e)&&e>0){if(e>g)return b.statusCode=413,b.end((0,E.getPostponedStateExceededErrorMessage)(f)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let i="1 MB",j=(null==(U=al.experimental.serverActions)?void 0:U.bodySizeLimit)??i,k=e+(j!==i?c(95726).parse(j):1048576),l=await (0,E.readBodyWithSizeLimit)(a,k);if(null===l)return b.statusCode=413,b.end("Request body exceeded limit. To configure the body size limit for Server Actions, see: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;if(l.length>=e){let b=l.subarray(0,e).toString("utf8");(0,h.addRequestMeta)(a,"postponed",b);let c=l.subarray(e);(0,h.addRequestMeta)(a,"actionBody",c)}else throw Object.defineProperty(Error(`invariant: expected ${e} bytes of postponed state but only received ${l.length} bytes`),"__NEXT_ERROR_CODE",{value:"E979",enumerable:!1,configurable:!0})}}if(!(0,h.getRequestMeta)(a,"postponed")&&aB&&"1"===a.headers[y.NEXT_RESUME_HEADER]&&"POST"===a.method){let{maxPostponedStateSize:c,maxPostponedStateSizeBytes:e}=(0,E.getMaxPostponedStateSize)(al.experimental.maxPostponedStateSize),f=await (0,E.readBodyWithSizeLimit)(a,e);if(null===f)return b.statusCode=413,b.end((0,E.getPostponedStateExceededErrorMessage)(c)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let g=f.toString("utf8");(0,h.addRequestMeta)(a,"postponed",g)}let aD=!0===P.isDev||!0===al.experimental.exposeTestingApiInProductionBuild,aE=aD&&("1"===a.headers[t.NEXT_INSTANT_PREFETCH_HEADER]||!(0,n.f)(a.headers[t.RSC_HEADER])&&"string"==typeof a.headers.cookie&&a.headers.cookie.includes(t.NEXT_INSTANT_TEST_COOKIE+"=")),aF=(aB||aE)&&((null==(M=ag.routes[aq]??ag.dynamicRoutes[aq])?void 0:M.renderingMode)==="PARTIALLY_STATIC"||aE&&(aD||(null==ak?void 0:ak.experimentalTestProxy)===!0)),aG=aE&&aF,aH=aG&&!0===P.isDev,aI=!1,aJ=aF?(0,h.getRequestMeta)(a,"postponed"):void 0,aK=null==(R=ag.routes[ai])?void 0:R.prefetchDataRoute,aL=aF&&az&&!ay&&!aK;V&&(aL=aL&&!!aJ);let aM=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),aN=(!aw||!aF)&&(!av||(0,q.shouldServeStreamingMetadata)(av,al.htmlLimitedBots)),aO=!!((at||au||ag.routes[aq])&&!(aw&&aF)),aP=aF&&!0===al.cacheComponents,aQ=!0===P.isDev||!aO||"string"==typeof aJ||(aP&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?aL&&!V:aL),aR=!!aw&&aF,aS=(null==at?void 0:at.remainingPrerenderableParams)??[],aT=(null==at?void 0:at.fallback)===null&&((null==(S=at.fallbackRootParams)?void 0:S.length)??0)>0,aU=null;if(!ah&&aO&&!aQ&&!aA&&!aJ&&!aL){let a=as?"string"==typeof(null==at?void 0:at.fallback)?at.fallback:as.source:null;if(!0===al.experimental.partialFallbacks&&a&&(null==at?void 0:at.fallbackRouteParams)&&!aT){if(aS.length>0){let b,c=(b=new Map(aS.map(a=>[a.paramName,a])),a.split("/").map(a=>{let c=(0,L.getSegmentParam)(a);if(!c)return a;let d=b.get(c.paramName);if(!d)return a;let e=null==$?void 0:$[d.paramName];if(!e)return a;let f=Array.isArray(e)?e.map(a=>encodeURIComponent(a)).join("/"):encodeURIComponent(e);return a.replace((0,o.buildDynamicSegmentPlaceholder)(d),f)}).join("/")||"/");aU=c!==a?c:null}}else aU=ai}let aV=aU;!aV&&(P.isDev||aO&&_&&(null==at?void 0:at.fallbackRouteParams)&&!aA)&&(aV=ai),P.isDev||ah||!aO||!az||aL||(0,k.d)(a.headers);let aW={...G,tree:N,handler:Q,routeModule:P,__next_app__:O};ad&&ae&&(0,p.setManifestsSingleton)({page:W,clientReferenceManifest:ae,serverActionsManifest:ad});let aX=a.method||"GET",aY=(0,g.getTracer)(),aZ=aY.getActiveScopeSpan(),a$=!!(null==ak?void 0:ak.isWrappedByNextServer),a_=!0===al.experimental.partialFallbacks&&aS.length>0?(null==at||null==(T=at.fallbackRouteParams)?void 0:T.filter(a=>!aS.some(b=>b.paramName===a.paramName)))??[]:[],a0=async()=>((null==ak?void 0:ak.render404)?await ak.render404(a,b,am,!1):b.end("This page could not be found"),null);try{let k,m=P.getVaryHeader(ai,an);b.setHeader("Vary",m);let n=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return P.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aY.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aX} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a),k&&k!==c&&(k.setAttribute("http.route",d),k.updateName(a))}else c.updateName(`${aX} ${W}`)})},p=(0,h.getRequestMeta)(a,"incrementalCache")||await P.getIncrementalCache(a,al,ag,V);null==p||p.resetRequestCache(),globalThis.__incrementalCache=p;let q=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let k={query:Z,params:$,page:aq,sharedContext:{buildId:Y,deploymentId:ao,clientAssetToken:ap},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aW,Component:(0,j.T)(aW),params:$,routeModule:P,page:W,postponed:f,shouldWaitOnAllReady:aR,serveStreamingMetadata:aN,supportsDynamicResponse:"string"==typeof f||aQ,buildManifest:aa,nextFontManifest:ab,reactLoadableManifest:ac,subresourceIntegrityManifest:af,setCacheStatus:null==ak?void 0:ak.setCacheStatus,setIsrStatus:null==ak?void 0:ak.setIsrStatus,setReactDebugChannel:null==ak?void 0:ak.setReactDebugChannel,sendErrorsToBrowser:null==ak?void 0:ak.sendErrorsToBrowser,dir:c(33873).join(process.cwd(),P.relativeProjectDir),isDraftMode:ah,botType:aw,isOnDemandRevalidate:ar,isPossibleServerAction:aA,assetPrefix:al.assetPrefix,nextConfigOutput:al.output,crossOrigin:al.crossOrigin,trailingSlash:al.trailingSlash,images:al.images,previewProps:ag.preview,enableTainting:al.experimental.taint,htmlLimitedBots:al.htmlLimitedBots,reactMaxHeadersLength:al.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:p,cacheLifeProfiles:al.cacheLife,basePath:al.basePath,serverActions:al.experimental.serverActions,logServerFunctions:"object"==typeof al.logging&&!!al.logging.serverFunctions,...aG||aH||aI?{isBuildTimePrerendering:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:aH}:{},cacheComponents:!!al.cacheComponents,experimental:{isRoutePPREnabled:aF,expireTime:al.expireTime,staleTimes:al.experimental.staleTimes,dynamicOnHover:!!al.experimental.dynamicOnHover,optimisticRouting:!!al.experimental.optimisticRouting,inlineCss:!!al.experimental.inlineCss,prefetchInlining:al.experimental.prefetchInlining??!1,authInterrupts:!!al.experimental.authInterrupts,cachedNavigations:!!al.experimental.cachedNavigations,clientTraceMetadata:al.experimental.clientTraceMetadata||[],clientParamParsingOrigins:al.experimental.clientParamParsingOrigins,maxPostponedStateSizeBytes:(0,D.parseMaxPostponedStateSize)(al.experimental.maxPostponedStateSize)},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>P.onRequestError(a,b,d,e,ak),err:(0,h.getRequestMeta)(a,"invokeError")}};i&&(k.renderOpts.supportsDynamicResponse=!1);let l=await n(e,k),{metadata:m}=l,{cacheControl:o,headers:q={},fetchTags:r,fetchMetrics:s}=m;if(r&&(q[y.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,aO&&(null==o?void 0:o.revalidate)===0&&!P.isDev&&!aF){let a=m.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${ai}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
2
- see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:v.CachedRouteKind.APP_PAGE,html:l,headers:q,rscData:m.flightData,postponed:m.postponed,status:m.statusCode,segmentData:m.segmentData},cacheControl:o}},r=async({hasResolved:c,previousCacheEntry:g,isRevalidating:i,span:j,forceStaticRender:k=!1})=>{let l=!1===P.isDev,m=c||b.writableEnded;try{var n;let f;if(ar&&aj&&!g&&!V)return(null==ak?void 0:ak.render404)?await ak.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(at&&(f=(0,w.parseFallbackField)(at.fallback)),!0===al.experimental.partialFallbacks&&(null==at?void 0:at.fallback)===null&&!aT&&aS.length>0&&(f=w.FallbackMode.PRERENDER),f===w.FallbackMode.PRERENDER&&(0,u.isBot)(av)&&(!aF||ax)&&(f=w.FallbackMode.BLOCKING_STATIC_RENDER),(null==g?void 0:g.isStale)===-1&&(ar=!0),ar&&(f!==w.FallbackMode.NOT_FOUND||g)&&(f=w.FallbackMode.BLOCKING_STATIC_RENDER),!V&&f!==w.FallbackMode.BLOCKING_STATIC_RENDER&&aV&&!m&&!ah&&_&&(l||!au)){if((l||at)&&f===w.FallbackMode.NOT_FOUND){if(al.adapterPath)return await a0();throw new C.NoFallbackError}if(aF&&(al.cacheComponents?!aL:!az)){let b=l&&"string"==typeof(null==at?void 0:at.fallback)?at.fallback:aq,f=(l||aG)&&(null==at?void 0:at.fallbackRouteParams)?(0,o.createOpaqueFallbackRouteParams)(at.fallbackRouteParams):aI?(0,o.getFallbackRouteParams)(aq,P):null;aG&&f&&(0,h.addRequestMeta)(a,"fallbackParams",f);let g=await P.handleResponse({cacheKey:b,req:a,nextConfig:al,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:ag,isRoutePPREnabled:aF,responseGenerator:async()=>q({span:j,postponed:void 0,fallbackRouteParams:f,forceStaticRender:!0}),waitUntil:d.waitUntil,isMinimalMode:V});if(null===g)return null;if(g)return V||!aF||!(aS.length>0)||!0!==al.experimental.partialFallbacks||!aU||!p||ar||aI||aD||aE||ay||(0,J.scheduleOnNextTick)(async()=>{let b=P.getResponseCache(a);try{await b.revalidate(aU,p,aF,!1,a=>q({span:a.span,postponed:void 0,fallbackRouteParams:a_.length>0?(0,o.createOpaqueFallbackRouteParams)(a_):null,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}),delete g.cacheControl,g}}let s=ar||i||!aJ?void 0:aJ;if(aP&&!V&&p&&(aL||aA)&&!k){let b=await p.get(ai,{kind:v.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===v.CachedRouteKind.APP_PAGE&&(s=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,J.scheduleOnNextTick)(async()=>{let b=P.getResponseCache(a);try{await b.revalidate(ai,p,aF,!1,a=>r({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if((aG||aH)&&void 0!==s)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:v.CachedRouteKind.PAGES,html:x.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let t=!P.isDev&&_&&(null==at?void 0:at.fallbackRouteParams)?(0,o.getPlaceholderFallbackRouteParams)($,at.fallbackRouteParams):null,y=t&&t.length>0?t:null==at?void 0:at.fallbackRouteParams,z=null!=t&&t.length>0,A=null;if(al.cacheComponents&&(null==at?void 0:at.fallbackRouteParams)){let b=(0,h.getRequestMeta)(a,"resolvedRouteParamKeys");b&&b.size>0&&(A=at.fallbackRouteParams.filter(a=>!b.has(a.paramName)))}let B=(l&&(0,h.getRequestMeta)(a,"renderFallbackShell")||z||aG&&!au)&&y?(0,o.createOpaqueFallbackRouteParams)(y):A&&A.length>0&&A.length<((null==at||null==(n=at.fallbackRouteParams)?void 0:n.length)??0)?(0,o.createOpaqueFallbackRouteParams)(A):aI?(0,o.getFallbackRouteParams)(aq,P):null;if((l||aG)&&al.cacheComponents&&!au&&(null==at?void 0:at.fallbackRouteParams)){let b=(0,o.createOpaqueFallbackRouteParams)(y??at.fallbackRouteParams);b&&(0,h.addRequestMeta)(a,"fallbackParams",b)}return q({span:j,postponed:s,fallbackRouteParams:B,forceStaticRender:k})}catch(b){throw(null==g?void 0:g.isStale)&&await P.onRequestError(a,b,{routerKind:"App Router",routePath:W,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aO,isOnDemandRevalidate:ar})},!1,ak),b}},s=async c=>{var f,g,i,j,k,l;let m,n=await P.handleResponse({cacheKey:aU,responseGenerator:a=>r({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ar,isRoutePPREnabled:aF,req:a,nextConfig:al,prerenderManifest:ag,waitUntil:d.waitUntil,isMinimalMode:V});if(ah&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),P.isDev&&b.setHeader("Cache-Control","no-cache, must-revalidate"),!n){if(aU)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=n.value)?void 0:f.kind)!==v.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=n.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let o="string"==typeof n.value.postponed;az&&!aA&&ao&&b.setHeader(y.NEXT_NAV_DEPLOYMENT_ID_HEADER,ao),aO&&!aL&&(!o||ay)&&(V||b.setHeader("x-nextjs-cache",ar?"REVALIDATED":n.isMiss?"MISS":n.isStale?"STALE":"HIT"),b.setHeader(t.NEXT_IS_PRERENDER_HEADER,"1"));let{value:p}=n;if(aJ)m={revalidate:0,expire:void 0};else if(aL)m={revalidate:0,expire:void 0};else if(!P.isDev)if(ah)m={revalidate:0,expire:void 0};else if(aO){if(n.cacheControl)if("number"==typeof n.cacheControl.revalidate){if(n.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${n.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});m={revalidate:n.cacheControl.revalidate,expire:(null==(j=n.cacheControl)?void 0:j.expire)??al.expireTime}}else m={revalidate:y.CACHE_ONE_YEAR_SECONDS,expire:void 0}}else b.getHeader("Cache-Control")||(m={revalidate:0,expire:void 0});if(n.cacheControl=m,"string"==typeof aM&&(null==p?void 0:p.kind)===v.CachedRouteKind.APP_PAGE&&p.segmentData){b.setHeader(t.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=p.headers)?void 0:k[y.NEXT_CACHE_TAGS_HEADER];V&&aO&&c&&"string"==typeof c&&b.setHeader(y.NEXT_CACHE_TAGS_HEADER,c);let d=p.segmentData.get(aM);return void 0!==d?(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:x.default.fromStatic(d,t.RSC_CONTENT_TYPE_HEADER),cacheControl:n.cacheControl}):(b.statusCode=204,(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:x.default.EMPTY,cacheControl:n.cacheControl}))}let s=aP?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(s){let b=(0,h.getRequestMeta)(a,"initURL")??a.url,c=b?(null==(l=(0,F.parseUrl)(b))?void 0:l.pathname)??b:void 0;if(await s(n,{url:c}))return null}if(p.headers){let a={...p.headers};for(let[c,d]of(V&&aO||delete a[y.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let u=null==(g=p.headers)?void 0:g[y.NEXT_CACHE_TAGS_HEADER];if(V&&aO&&u&&"string"==typeof u&&b.setHeader(y.NEXT_CACHE_TAGS_HEADER,u),!p.status||az&&aF||(b.statusCode=p.status),!V&&p.status&&H.RedirectStatusCode[p.status]&&az&&(b.statusCode=200),o&&!aL&&b.setHeader(t.NEXT_DID_POSTPONE_HEADER,"1"),az&&!ah){if(void 0===p.rscData){if(p.html.contentType!==t.RSC_CONTENT_TYPE_HEADER)if(al.cacheComponents)return b.statusCode=404,(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:x.default.EMPTY,cacheControl:n.cacheControl});else throw Object.defineProperty(new I.InvariantError(`Expected RSC response, got ${p.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:p.html,cacheControl:n.cacheControl})}return(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:x.default.fromStatic(p.rscData,t.RSC_CONTENT_TYPE_HEADER),cacheControl:n.cacheControl})}let w=p.html;if(aE&&aG){let c=!0===P.isDev?crypto.randomUUID():null;return w.pipeThrough(await (0,A.createInstantTestScriptInsertionTransformStream)(c)),(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:w,cacheControl:{revalidate:0,expire:void 0}})}if(!o||V||az)return(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:w,cacheControl:n.cacheControl});if(aG||aH)return w.push(new ReadableStream({start(a){a.enqueue(z.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:w,cacheControl:{revalidate:0,expire:void 0}});let C=new TransformStream;return w.push(C.readable),q({span:c,postponed:p.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==v.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(C.writable)}).catch(a=>{C.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:w,cacheControl:{revalidate:0,expire:void 0}})};if(!a$||!aZ)return k=aY.getActiveScopeSpan(),await aY.withPropagatedContext(a.headers,()=>aY.trace(i.BaseServerSpan.handleRequest,{spanName:`${aX} ${W}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aX,"http.target":a.url}},s),void 0,!a$);await s(aZ)}catch(b){throw b instanceof C.NoFallbackError||await P.onRequestError(a,b,{routerKind:"App Router",routePath:W,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aO,isOnDemandRevalidate:ar})},!1,ak),b}}},25880:()=>{},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},26896:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,95547,23)),Promise.resolve().then(c.t.bind(c,15098,23)),Promise.resolve().then(c.t.bind(c,47644,23)),Promise.resolve().then(c.t.bind(c,33859,23)),Promise.resolve().then(c.t.bind(c,98099,23)),Promise.resolve().then(c.t.bind(c,16237,23)),Promise.resolve().then(c.t.bind(c,98562,23)),Promise.resolve().then(c.t.bind(c,36675,23))},27074:(a,b,c)=>{"use strict";c.d(b,{Viewer:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call Viewer() from the server but Viewer is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/latand/.agents/tools/live-log-viewer-next/src/components/Viewer.tsx","Viewer")},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},30366:(a,b,c)=>{"use strict";c.d(b,{Viewer:()=>bQ});var d=c(48249),e=c(67484);let f="__overview__",g=a=>Math.floor(a/300);function h(a){return"live"===a.activity?0:"recent"===a.activity?1:"stalled"===a.activity?2:3}function i(a){return"claude-projects"===a.root?"сесія"===a.kind&&!a.parent:"codex-sessions"===a.root&&!a.parent}function j(a){return"claude-projects"===a.root&&"субагент"===a.kind}function k(a){return!!j(a)||"codex-sessions"===a.root&&!!a.parent}function l(a){return"shell"===a.engine||"codex-jobs"===a.root}function m(a){return a.project||"інше"}function n(a){let b=new Map;for(let c of a){let a=m(c),d=b.get(a);d||(d={project:a,liveCount:0,conversations:0,smt:0},b.set(a,d)),"live"===c.activity&&(d.liveCount+=1),i(c)&&(d.conversations+=1),d.smt=Math.max(d.smt,c.mtime)}return[...b.values()].sort((a,b)=>{let c=a.liveCount>0;return c!==b.liveCount>0?c?-1:1:g(b.smt)-g(a.smt)||a.project.localeCompare(b.project)})}function o(a){let b=new Map;for(let c of a){if(!c.parent)continue;let a=b.get(c.parent);a?a.push(c):b.set(c.parent,[c])}return b}function p(a,b){let c=[],d=[...b.get(a.path)??[]],e=new Set([a.path]);for(;d.length;){let a=d.pop();e.has(a.path)||(e.add(a.path),c.push(a),d.push(...b.get(a.path)??[]))}return c}function q(a){return!l(a)&&("live"===a.activity||"recent"===a.activity&&k(a))}function r(a,b){let c=new Map(a.map(a=>[a.path,a])),d=o(a),e=new Map,f=new Map;for(let d of a)if(m(d)===b){if("live"===d.activity||"recent"===d.activity&&k(d)){let a=function(a,b){let c=new Set,d=a;for(;d.parent&&!c.has(d.path);){c.add(d.path);let a=b.get(d.parent);if(!a)break;d=a}return d}(d,c);l(a)?f.set(a.path,a):e.set(a.path,a);continue}"recent"===d.activity&&i(d)&&e.set(d.path,d)}let h=[...e.values()].map(a=>(function(a,b,c){let d=p(a,b),e=d.filter(q).sort((a,b)=>("live"!==a.activity)-("live"!==b.activity)||g(b.mtime)-g(a.mtime)||a.path.localeCompare(b.path)),f=d.filter(a=>l(a)&&"live"===a.activity).sort((a,b)=>g(b.mtime)-g(a.mtime)||a.path.localeCompare(b.path)),h=[a,...e].map(a=>({file:a,tasks:[]})),i=new Map(h.map(a=>[a.file.path,a]));for(let a of f)(a.parent&&i.get(a.parent)||h[0]).tasks.push(a);let j=new Set([...i.keys(),...f.map(a=>a.path)]),m=d.filter(a=>!j.has(a.path)).sort((a,b)=>b.mtime-a.mtime),n=m.filter(a=>k(a)&&function(a,b){let c=new Set([a.path]),d=a;for(;d.parent&&!c.has(d.parent);){let a=b.get(d.parent);if(!a)break;if(c.add(a.path),"сесія"===a.kind)return"live"===a.activity||"recent"===a.activity;d=a}return!1}(a,c)),o=new Set(n.map(a=>a.path)),r=m.filter(a=>!o.has(a.path)),s=Math.max(...h.map(a=>a.file.mtime),...f.map(a=>a.mtime));return{key:a.path,columns:h,returnable:n,finished:r,smt:s,orphanTask:!1}})(a,d,c));for(let a of f.values())h.push({key:a.path,columns:[{file:a,tasks:[]}],returnable:[],finished:[],smt:a.mtime,orphanTask:!0});return h.sort((a,b)=>a.orphanTask!==b.orphanTask?a.orphanTask?1:-1:g(b.smt)-g(a.smt)||a.key.localeCompare(b.key))}function s(a,b=160){let c=a.replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/[*_~#>]+/g,"").replace(/\s+/g," ").trim().replace(/(?:\/[^\s)]+){3,}/g,a=>{if(a.length<=40)return a;let b=a.split("/").filter(Boolean);return b.length>=2?".../"+b.slice(-2).join("/"):a}).replace(/\s+/g," ").trim();return c.length>b?c.slice(0,b-1).trimEnd()+"…":c}function t(a){let b=Date.now()/1e3-a;return b<90?Math.round(b)+" с тому":b<5400?Math.round(b/60)+" хв тому":b<129600?Math.round(b/3600)+" год тому":Math.round(b/86400)+" д тому"}function u(a){if("string"!=typeof a&&"number"!=typeof a)return"";let b=new Date(a);return Number.isNaN(b.getTime())?"":b.toLocaleTimeString("uk",{hour12:!1})}function v(a,b,c,d){let e=a%10,f=a%100;return 1===e&&11!==f?b:e>=2&&e<=4&&(f<12||f>14)?c:d}function w(a){return"live"===a?"animate-pulse bg-ok":"recent"===a?"bg-[#d29a2f]":"stalled"===a?"bg-err":"bg-[#c9c9d1]"}let x={codex:{color:"#2f6fd0",soft:"#e8f0fb"},claude:{color:"#d97757",soft:"#faeee9"}},y={color:"#9a9aa4",soft:"#ececf1"},z=[[/fable|mythos/,{color:"#c2410c",soft:"#fbeade"}],[/opus/,{color:"#8a5ad6",soft:"#f1ebfb"}],[/sonnet/,{color:"#e0913f",soft:"#fbf1e4"}],[/haiku/,{color:"#d9a58c",soft:"#f9f1ec"}]],A=[[/spark/,{color:"#5ea3e4",soft:"#ecf4fd"}],[/mini|nano/,{color:"#7fb1e8",soft:"#eff6fd"}],[/codex/,{color:"#1d55ab",soft:"#e4edfa"}]];function B(a){let b=x[a.engine];if(!b)return y;let c=(a.model??"").toLowerCase();for(let[b,d]of"codex"===a.engine?A:z)if(b.test(c))return d;return b}function C(a){return B(a).color}function D(a){let b={codex:"Codex",claude:"Claude",shell:"Bash"}[a.engine]??a.engine,c=x[a.engine]??y;return{label:b,style:{backgroundColor:c.soft,color:c.color}}}function E({files:a,onSelectProject:b,onSelectFile:c}){let f=function(){let[a,b]=(0,e.useState)(3);return a}(),g=(0,e.useMemo)(()=>n(a),[a]),h=(0,e.useMemo)(()=>g.reduce((a,b)=>a+b.liveCount,0),[g]),i=g.filter(a=>a.liveCount>0).length,j=(0,e.useMemo)(()=>g.map(b=>{let c=r(a,b.project).flatMap(a=>a.columns.flatMap(a=>[a.file,...a.tasks])).filter(a=>"live"===a.activity),d=c.slice(0,4),e=a.filter(a=>m(a)===b.project).sort((a,b)=>b.mtime-a.mtime)[0];return{summary:b,liveBranches:d,moreLive:c.length-d.length,latest:e}}),[a,g]);return(0,d.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,d.jsxs)("div",{className:"flex h-10 shrink-0 items-center gap-2.5 border-b border-line bg-panel px-4",children:[(0,d.jsx)("h1",{className:"text-[13.5px] font-bold",children:"Огляд"}),(0,d.jsx)("span",{className:"text-[11.5px] text-dim",children:h?`${h} ${v(h,"гілка працює","гілки працюють","гілок працюють")} у ${i} ${v(i,"проєкті","проєктах","проєктах")}`:"зараз нічого не працює"})]}),(0,d.jsxs)("div",{className:"grid flex-1 auto-rows-min gap-2.5 overflow-y-auto p-3",style:{gridTemplateColumns:`repeat(${f}, minmax(0, 1fr))`},children:[j.map(({summary:a,liveBranches:e,moreLive:f,latest:g})=>(0,d.jsxs)("button",{className:"flex flex-col gap-1.5 rounded-[10px] border border-line bg-panel p-3 text-left shadow-card hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>b(a.project),children:[(0,d.jsxs)("span",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:`h-2 w-2 shrink-0 rounded-full ${a.liveCount?"animate-pulse bg-ok":"bg-[#d6d6dd]"}`}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[13px] font-bold",children:a.project}),a.liveCount?(0,d.jsx)("span",{className:"shrink-0 rounded-full bg-[#e5f6ea] px-1.5 py-0.5 text-[10.5px] font-bold text-ok",children:a.liveCount}):null,(0,d.jsx)("span",{className:"shrink-0 text-[11px] font-semibold text-dim",children:a.conversations})]}),e.length?(0,d.jsxs)("span",{className:"flex flex-col gap-1",children:[e.map(a=>{let b=D(a);return(0,d.jsxs)("span",{className:"flex cursor-pointer items-center gap-1.5 rounded-[8px] px-1 py-0.5 text-[11.5px] hover:bg-bg",role:"link",tabIndex:0,title:s(a.title),onClick:b=>{b.stopPropagation(),c(a)},onKeyDown:b=>{"Enter"===b.key&&(b.stopPropagation(),c(a))},children:[(0,d.jsx)("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${w(a.activity)}`}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 text-[9px] font-bold",style:b.style,children:b.label}),(0,d.jsx)("span",{className:"truncate font-semibold",children:s(a.title,70)})]},a.path)}),f>0?(0,d.jsxs)("span",{className:"px-1 text-[10.5px] font-semibold text-dim",children:["ще ",f," live"]}):null]}):(0,d.jsxs)("span",{className:"text-[11px] text-dim",children:["тихо \xb7 остання активність ",g?t(g.mtime):"—"]})]},a.project)),g.length?null:(0,d.jsx)("div",{className:"col-span-full mt-[20vh] text-center text-dim",children:"Логів поки нема"})]})]})}let F=(...a)=>a.filter((a,b,c)=>!!a&&""!==a.trim()&&c.indexOf(a)===b).join(" ").trim(),G=a=>{let b=a.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,b,c)=>c?c.toUpperCase():b.toLowerCase());return b.charAt(0).toUpperCase()+b.slice(1)};var H={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let I=(0,e.createContext)({}),J=(0,e.forwardRef)(({color:a,size:b,strokeWidth:c,absoluteStrokeWidth:d,className:f="",children:g,iconNode:h,...i},j)=>{let{size:k=24,strokeWidth:l=2,absoluteStrokeWidth:m=!1,color:n="currentColor",className:o=""}=(0,e.useContext)(I)??{},p=d??m?24*Number(c??l)/Number(b??k):c??l;return(0,e.createElement)("svg",{ref:j,...H,width:b??k??H.width,height:b??k??H.height,stroke:a??n,strokeWidth:p,className:F("lucide",o,f),...!g&&!(a=>{for(let b in a)if(b.startsWith("aria-")||"role"===b||"title"===b)return!0;return!1})(i)&&{"aria-hidden":"true"},...i},[...h.map(([a,b])=>(0,e.createElement)(a,b)),...Array.isArray(g)?g:[g]])}),K=(a,b)=>{let c=(0,e.forwardRef)(({className:c,...d},f)=>(0,e.createElement)(J,{ref:f,iconNode:b,className:F(`lucide-${G(a).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${a}`,c),...d}));return c.displayName=G(a),c},L=K("corner-down-right",[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]),M=K("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),N=K("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),O=K("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),P=K("arrow-up-to-line",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]),Q=K("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]),R=K("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),S=K("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),T=K("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),U=K("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),V=K("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),W=K("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),X=K("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),Y=K("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]),Z=K("message-circle",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]]),$=K("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]),_=K("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),aa=K("sparkle",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}]]),ab=K("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),ac=K("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),ad=K("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),ae=K("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),af=K("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),ag=K("binary",[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]]),ah=K("pencil-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),ai=K("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),aj=K("power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]),ak=K("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]),al=K("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),am={shell:T,tool:ae,"cmd-group":af,codex:W,claude:aa,image:X,blob:ag,note:ah,citation:ai,message:Y,shutdown:aj,plan:ak};function an({name:a,className:b}){let c=am[a];return(0,d.jsx)(c,{className:b??"h-3.5 w-3.5","aria-hidden":!0})}function ao({className:a,style:b,enter:c="scale",children:f}){let g=(0,e.useRef)(null);return!function(a="scale"){(0,e.useRef)(new Map),(0,e.useRef)(new WeakMap),(0,e.useRef)(!0)}(c),(0,d.jsx)("div",{ref:g,className:a,style:b,children:f})}let ap=K("arrow-right-left",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]),aq=K("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);function ar({file:a}){return"running"===a.proc?(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-[#e5f6ea] px-2 py-0.5 text-[11px] font-bold text-ok",children:[(0,d.jsx)(_,{className:"h-3 w-3","aria-hidden":!0})," PID ",a.pid]}):"killed"===a.proc||"stalled"===a.activity?(0,d.jsx)("span",{className:"inline-flex items-center gap-1 rounded-full bg-[#f7e8e8] px-2 py-0.5 text-[11px] font-bold text-err",children:"перервано"}):"done"===a.proc?(0,d.jsx)("span",{className:"inline-flex items-center gap-1 rounded-full bg-chip px-2 py-0.5 text-[11px] font-bold text-dim",children:"завершено"}):null}function as({file:a,compact:b=!1}){let[c,f]=(0,e.useState)(!1),[g,h]=(0,e.useState)(!1),[i,j]=(0,e.useState)(""),[k,l]=(0,e.useState)(!1),m=(0,d.jsx)(ar,{file:a}),n=async()=>{h(!0),j("");try{let b=await fetch("/api/proc",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:a.path,force:k})}),c=await b.json();if(!b.ok||!c.ok){j(c.error??"помилка зупинки"),l(!0);return}j(`надіслано ${k?"SIGKILL":"SIGTERM"} PID ${c.pid}`),f(!1)}catch{j("сервер недоступний"),l(!0)}finally{h(!1)}};return(0,d.jsxs)("span",{className:`inline-flex min-w-0 flex-wrap items-center gap-1.5 ${b?"text-[10.5px]":"text-xs"}`,children:[m,"running"===a.proc?c?(0,d.jsxs)("span",{className:"inline-flex max-w-full items-center gap-1 rounded-[10px] border border-err/30 bg-[#fff5f5] px-1.5 py-0.5",children:[b?null:(0,d.jsxs)("span",{className:"truncate px-1 text-[11px] font-semibold text-err",children:["Точно вбити PID ",a.pid,"?"]}),(0,d.jsx)("button",{className:"rounded-lg bg-err px-2 py-0.5 text-[11px] font-bold text-white disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-err/50",disabled:g,onClick:n,children:k?"SIGKILL":b?`Вбити ${a.pid}`:"Так, вбити"}),(0,d.jsx)("button",{className:"rounded-lg border border-line bg-panel px-2 py-0.5 text-[11px] font-semibold text-dim focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>f(!1),children:b?"Ні":"Скасувати"})]}):(0,d.jsx)("button",{className:"rounded-full border border-line bg-panel px-2 py-0.5 text-[11px] font-semibold text-dim hover:border-err/40 hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":`Зупинити процес PID ${a.pid}`,onClick:()=>f(!0),children:"Вбити"}):null,i?(0,d.jsx)("span",{className:"max-w-[220px] truncate text-[11px] font-semibold text-dim",children:i}):null]})}function at({file:a,files:b,onSelect:c}){if("codex-jobs"===a.root){let e=b.find(b=>"codex-sessions"===b.root&&b.parent===a.path);return(0,d.jsxs)("div",{className:"mb-4 mt-1 rounded-[14px] border border-line bg-panel px-4 py-3 shadow-card",children:[(0,d.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:(0,d.jsx)(ar,{file:a})}),e?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"mb-2 whitespace-pre-line text-[13.5px] font-semibold",children:"Це короткий джоб-лог (лише службові події). Реальна робота Codex — у повній сесії:"}),(0,d.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-[10px] border border-line bg-bg px-3 py-1.5 text-[13px] font-semibold text-codex hover:bg-codex-soft",onClick:()=>c(e),children:[(0,d.jsx)(W,{className:"h-3.5 w-3.5","aria-hidden":!0})," Відкрити сесію Codex (",(e.size/1024).toFixed(0)," kB","live"===e.activity?", працює":"stalled"===e.activity?", перервано":"recent"===e.activity?", закінчив":"",")"]})]}):(0,d.jsx)("div",{className:"text-[13.5px] text-dim",children:"Це короткий джоб-лог. Повна rollout-сесія Codex ще не з'явилась у списку"})]})}return"claude-tasks"!==a.root?null:(0,d.jsxs)("div",{className:"mb-4 mt-1 rounded-[14px] border border-line bg-panel px-4 py-3 shadow-card",children:[(0,d.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:(0,d.jsx)(ar,{file:a})}),a.cmd?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"mb-1 text-[13.5px] font-semibold",children:a.cmdDesc||"Фонова команда"}),(0,d.jsxs)("code",{className:"block whitespace-pre-wrap break-words rounded-lg border border-line bg-[#fafafc] px-2.5 py-2 font-mono text-[12.5px]",children:["$ ",a.cmd]})]}):(0,d.jsx)("div",{className:"text-[13.5px] text-dim",children:"Команду, що запустила цю фонову задачу, не знайдено у транскриптах сесії"})]})}let au=[{key:"claude",label:"Claude"},{key:"codex",label:"Codex"}];function av({file:a,paneRef:b}){let c=(0,e.useRef)(null),f=(0,e.useRef)({target:88,current:88,raf:0}),g=(0,e.useRef)(!1),h=(0,e.useRef)(null),i=(0,e.useRef)(null),[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)({top:-18,maxH:480}),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)("codex"===a.engine?"codex":"claude"),[r,t]=(0,e.useState)(""),[u,v]=(0,e.useState)([]),[w,z]=(0,e.useState)(()=>`Прочитай розмову агента у файлі ${a.path} і продовж роботу звідти: `),[A,C]=(0,e.useState)(!1),[E,F]=(0,e.useState)(null),[G,H]=(0,e.useState)(!1),I=(0,e.useId)(),J=a=>{g.current=a,k(a)},K=()=>{if(g.current)return;let a=b.current;if(a){let b=a.getBoundingClientRect().height,c=f.current.current;if(c>.55*b){let a=Math.min(c+18,b-8);m({bottom:c-a,maxH:a-8})}else{let a=Math.max(8,c-18);m({top:a-c,maxH:b-a-8})}}J(!0)},L=async()=>{if(!A&&r.trim()){C(!0),F(null);try{let a=await fetch("/api/spawn",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:p,cwd:r.trim(),prompt:w})}),b=await a.json();if(!a.ok||!b.ok)return void F({kind:"err",text:b.error??"не вдалося запустити"});F({kind:"ok",text:`запущено в tmux ${b.target??""} — скоро з'явиться в списку`})}catch{F({kind:"err",text:"сервер недоступний"})}finally{C(!1)}}},M=D(a);return(0,d.jsxs)("div",{ref:c,className:"pointer-events-none absolute left-1.5 top-0 z-40 h-0 w-0",style:{transform:"translate3d(0, 88px, 0)",willChange:"transform"},children:[(0,d.jsx)("button",{type:"button","aria-expanded":j,"aria-label":"Перекинути розмову іншому агенту",title:"перекинути розмову іншому агенту",onPointerEnter:()=>{n&&!g.current&&(h.current&&window.clearTimeout(h.current),h.current=window.setTimeout(K,130))},onPointerLeave:()=>{h.current&&window.clearTimeout(h.current),h.current=null},onClick:()=>{h.current&&window.clearTimeout(h.current),g.current?J(!1):K()},className:`pointer-events-auto absolute left-0 top-0 flex h-9 w-6 -translate-y-1/2 items-center justify-center rounded-full border bg-panel shadow-card transition-[opacity,border-color,color] duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 ${j?"border-accent/50 text-accent opacity-100":"border-line text-dim opacity-60 hover:border-accent/45 hover:text-accent hover:opacity-100"}`,children:(0,d.jsx)(ap,{className:"h-3.5 w-3.5","aria-hidden":!0})}),j?(0,d.jsxs)("div",{className:"pointer-events-auto absolute left-8 z-50 flex w-[340px] cursor-default flex-col gap-2.5 overflow-y-auto rounded-[12px] border border-line bg-panel p-3 shadow-[0_8px_28px_rgba(20,20,30,0.14)] [&>*]:shrink-0",style:{top:l.top,bottom:l.bottom,maxHeight:l.maxH},children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)(ap,{className:"h-3.5 w-3.5 shrink-0 text-accent","aria-hidden":!0}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12px] font-bold",children:"перекинути розмову іншому агенту"}),(0,d.jsx)("button",{type:"button","aria-label":"Закрити картку передачі",onClick:()=>J(!1),className:"inline-flex shrink-0 items-center rounded-[8px] border border-line bg-bg px-1.5 py-0.5 text-dim hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",children:(0,d.jsx)(ad,{className:"h-3 w-3","aria-hidden":!0})})]}),(0,d.jsx)("div",{className:"truncate text-[10.5px] font-semibold text-dim",title:s(a.title),children:s(a.title,70)}),(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 rounded-[8px] border border-line bg-bg px-2 py-2",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:"w-[64px] shrink-0 text-[10px] font-semibold text-dim",children:"агент"}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 py-0.5 text-[9.5px] font-bold",style:M.style,children:M.label}),a.model?(0,d.jsx)("span",{className:"min-w-0 truncate rounded-full px-1.5 py-0.5 font-mono text-[9px] font-semibold",style:{backgroundColor:B(a).soft,color:B(a).color},children:a.model}):null,(0,d.jsx)(ar,{file:a})]}),(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:"w-[64px] shrink-0 text-[10px] font-semibold text-dim",children:"транскрипт"}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-ink",title:a.path,children:a.path}),(0,d.jsx)("button",{type:"button","aria-label":"Скопіювати шлях транскрипта",onClick:()=>{navigator.clipboard?.writeText(a.path).then(()=>{H(!0),i.current&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>H(!1),1500)}).catch(()=>{})},className:`inline-flex shrink-0 items-center rounded-[8px] border border-line bg-panel px-1.5 py-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 ${G?"text-ok":"text-dim hover:text-accent"}`,children:G?(0,d.jsx)(S,{className:"h-3 w-3","aria-hidden":!0}):(0,d.jsx)(aq,{className:"h-3 w-3","aria-hidden":!0})})]}),a.kind?(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:"w-[64px] shrink-0 text-[10px] font-semibold text-dim",children:"тип"}),(0,d.jsx)("span",{className:"min-w-0 truncate text-[10.5px] font-semibold text-ink",children:a.kind})]}):null]}),(0,d.jsx)("div",{className:"flex items-center gap-1.5",role:"radiogroup","aria-label":"Кому передати розмову",children:au.map(({key:a,label:b})=>{let c;return(0,d.jsx)("button",{type:"button",role:"radio","aria-checked":p===a,onClick:()=>q(a),style:p===a?{backgroundColor:(c=x[a]??y).soft,color:c.color,borderColor:c.color}:void 0,className:`flex-1 rounded-[8px] border px-2 py-1.5 text-[12px] font-bold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 ${p===a?"":"border-line bg-bg text-dim hover:text-ink"}`,children:b},a)})}),(0,d.jsxs)("label",{className:"flex flex-col gap-1 text-[10.5px] font-semibold text-dim",children:["директорія (успадкована)",(0,d.jsx)("input",{value:r,onChange:a=>t(a.target.value),list:I,placeholder:"/home/…/Projects/…","aria-label":"Робоча директорія нового агента",className:"rounded-[8px] border border-line bg-bg px-2 py-1.5 font-mono text-[11.5px] font-normal text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40"}),(0,d.jsx)("datalist",{id:I,children:u.map(a=>(0,d.jsx)("option",{value:a},a))})]}),(0,d.jsxs)("label",{className:"flex flex-col gap-1 text-[10.5px] font-semibold text-dim",children:["промпт для нового агента",(0,d.jsx)("textarea",{value:w,onChange:a=>z(a.target.value),rows:4,placeholder:"що зробити далі…","aria-label":"Промпт для нового агента",className:"resize-y rounded-[8px] border border-line bg-bg px-2 py-1.5 text-[12px] font-normal text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40"})]}),(0,d.jsx)("div",{className:"flex items-center",children:(0,d.jsx)("button",{type:"button",disabled:A||!r.trim(),onClick:()=>void L(),className:"ml-auto rounded-[8px] border border-accent bg-accent px-3 py-1.5 text-[12px] font-bold text-white hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40",children:A?"перекидаю…":"▶ Перекинути"})}),A?(0,d.jsx)("span",{className:"text-[10.5px] text-dim",children:"чекаю, поки CLI підніметься (до хвилини)…"}):null,E?(0,d.jsx)("span",{className:`text-[11px] font-semibold ${"ok"===E.kind?"text-ok":"text-err"}`,children:E.text}):null]}):null]})}let aw=K("arrow-down-to-line",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);function ax(a,b){return Math.floor(b.smt/300)-Math.floor(a.smt/300)||a.file.path.localeCompare(b.file.path)}function ay(a){return j(a)&&"running"!==a.proc}function az(a,b=Date.now()/1e3){return"stalled"===a.activity?!ay(a)&&b-a.mtime<=7200:"recent"===a.activity&&("claude"===a.engine||"codex"===a.engine)&&i(a)&&!j(a)}function aA(a,b,c,d,f=aB){return(0,e.useMemo)(()=>{let e=function(a){let b=o(a),c=new Map;for(let d of a){let a=[...b.get(d.path)??[]],e=new Set,f=0;for(;a.length;){let c=a.pop();e.has(c.path)||(e.add(c.path),f+=1,a.push(...b.get(c.path)??[]))}c.set(d.path,f)}return c}(a),g=new Map;for(let a of b){let b=g.get(a.file);(!b||a.ts>b.ts)&&g.set(a.file,a)}let h=c.trim().toLowerCase(),j=a.filter(a=>!f.has(a.path)&&(i(a)||"live"===a.activity||"stalled"===a.activity||"recent"===a.activity&&!l(a))).map(a=>{let b,c=m(a),f=s(a.title),h=d-a.mtime,i="live"===a.activity?"working":az(a,d)?"waiting":h<=86400?"recent":"older";return{file:a,project:c,title:f,descendants:e.get(a.path)??0,smt:a.mtime,kind:i,statusLine:(b=g.get(a.path))?`${b.label} \xb7 ${t(b.ts)}`:"live"===a.activity?"працює…":ay(a)?"повернувся з результатом":"stalled"===a.activity?"перервано або чекає дозволу":az(a)?"закінчив хід — чекає відповіді":""}}).filter(a=>!h||`${a.title} ${a.project}`.toLowerCase().includes(h)),k=(a,b)=>b.smt-a.smt||a.file.path.localeCompare(b.file.path),n=j.filter(a=>"waiting"===a.kind).sort(k),p=j.filter(a=>"working"===a.kind).sort(k);return{waiting:n,working:p,recent:j.filter(a=>"recent"===a.kind).sort(ax),older:j.filter(a=>"older"===a.kind).sort(ax),livePreview:p.slice(0,3)}},[a,b,c,d,f])}let aB=new Set,aC=K("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),aD=K("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);function aE({src:a,alt:b,caption:c,onClose:f}){let[g,h]=(0,e.useState)(1),[i,j]=(0,e.useState)(0),[k,l]=(0,e.useState)(0),[m,n]=(0,e.useState)(!1),o=(0,e.useRef)(null),p=(a,b=0,c=0)=>{let d=Math.min(8,Math.max(.25,g*a)),e=d/g;h(d),j(b-(b-i)*e),l(c-(c-k)*e)},q=()=>{h(1),j(0),l(0)};return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/85 backdrop-blur-sm",role:"dialog","aria-modal":"true","aria-label":b,onClick:f,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2.5",onClick:a=>a.stopPropagation(),children:[(0,d.jsx)("span",{className:"min-w-0 truncate text-[12.5px] font-semibold text-white/85",children:c??b}),(0,d.jsxs)("span",{className:"ml-auto flex items-center gap-1.5",children:[(0,d.jsx)("button",{className:"inline-flex items-center rounded-lg border border-white/25 bg-white/10 px-2.5 py-1 text-white hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60","aria-label":"Зменшити",onClick:()=>p(1/1.4),children:(0,d.jsx)(aC,{className:"h-4 w-4","aria-hidden":!0})}),(0,d.jsxs)("button",{className:"rounded-lg border border-white/25 bg-white/10 px-2 py-1 text-[11.5px] font-semibold text-white hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60","aria-label":"Скинути масштаб",onClick:q,children:[Math.round(100*g),"%"]}),(0,d.jsx)("button",{className:"inline-flex items-center rounded-lg border border-white/25 bg-white/10 px-2.5 py-1 text-white hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60","aria-label":"Збільшити",onClick:()=>p(1.4),children:(0,d.jsx)(aD,{className:"h-4 w-4","aria-hidden":!0})}),(0,d.jsx)("button",{className:"ml-1 inline-flex items-center rounded-lg border border-white/25 bg-white/10 px-2.5 py-1 text-white hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60","aria-label":"Закрити",onClick:f,children:(0,d.jsx)(ad,{className:"h-4 w-4","aria-hidden":!0})})]})]}),(0,d.jsx)("div",{className:"min-h-0 flex-1 touch-none overflow-hidden",onClick:a=>a.stopPropagation(),onWheel:a=>{let b=a.currentTarget.getBoundingClientRect(),c=a.clientX-b.left-b.width/2,d=a.clientY-b.top-b.height/2;p(a.deltaY<0?1.18:1/1.18,c,d)},onPointerDown:a=>{a.currentTarget.setPointerCapture(a.pointerId),o.current={x:a.clientX,y:a.clientY,tx:i,ty:k},n(!0)},onPointerMove:a=>{o.current&&(j(o.current.tx+(a.clientX-o.current.x)),l(o.current.ty+(a.clientY-o.current.y)))},onPointerUp:()=>{o.current=null,n(!1)},onPointerCancel:()=>{o.current=null,n(!1)},onDoubleClick:()=>1===g?p(2):q(),children:(0,d.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,d.jsx)("img",{src:a,alt:b,draggable:!1,className:`max-h-full max-w-full select-none ${m?"":"transition-transform duration-75"} ${g>1?"cursor-grab active:cursor-grabbing":"cursor-zoom-in"}`,style:{transform:`translate(${i}px, ${k}px) scale(${g})`}})})})]})}let aF=/<oai-mem-citation>\s*<citation_entries>([\s\S]*?)<\/citation_entries>\s*<rollout_ids>([\s\S]*?)<\/rollout_ids>\s*<\/oai-mem-citation>/g,aG=/^\s*(REQUEST_CHANGES|APPROVE|COMMENT)\b/m,aH=/(?:\/\.codex\/sessions\/|\/\.claude\/projects\/|\/\.claude\/plugins\/data\/codex-openai-codex\/state\/|^\/tmp\/claude-\d+\/)/,aI=/^\s*(\d+)[.)]\s+(.*)$/,aJ=/(?:\[(P[0-3])\]|\b(Critical|High|Medium|Low|Info|P[0-3])\b)/i,aK=/((?:\.{1,2}\/|\/|~\/)?[\w@.+-][\w@.+\-/]*\.(?:tsx?|jsx?|mjs|cjs|mts|cts|py|go|rs|md|json|ya?ml|toml|css|scss|html|sql|sh|env|ftl|txt))(?::(\d+))?/i,aL=/\[([^\]]+)\]\(([^)\s]+)\)/,aM=/([\w.-]*(?:api[_-]?key|access[_-]?token|refresh[_-]?token|authorization|bearer|secret|password|passwd|pwd|token))\b(\s*[:=]\s*)(["']?)[^\s"',}]+/gi;function aN(a){return"number"==typeof a&&Number.isFinite(a)?a:void 0}let aO=/<(teammate-message|agent-message)\b([^>]*)>([\s\S]*?)<\/\1>/g,aP=/^\s*(?:<[a-zA-Z][\w:-]*|Caveat: The messages below|\[Request interrupted|This came from another Claude session)/;function aQ(a){let b=a.match(/^\s*<([a-zA-Z][\w:-]*)/)?.[1];return b||(/^\s*Caveat:/.test(a)?"caveat":"системне")}function aR(a,b){return a.match(RegExp(`${b}="([^"]*)"`))?.[1]??""}function aS(a){return"string"==typeof a?a:""}function aT(a){return a&&"object"==typeof a&&!Array.isArray(a)?a:{}}function aU(a){return Array.isArray(a)?a.filter(a=>a&&"object"==typeof a&&!Array.isArray(a)):[]}let aV=/(`[^`]+`|\*\*[^*]+\*\*|\[[^\]]+\]\([^)\s]+\)|https?:\/\/[^\s<>"')\]]+)/g;function aW({href:a,label:b}){return(0,d.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",title:a,className:"break-all text-accent underline decoration-accent/40 underline-offset-2 hover:decoration-accent",children:b})}function aX(a){return a.split(aV).map((a,b)=>{if(!a)return null;if(a.startsWith("`")&&a.endsWith("`"))return(0,d.jsx)("span",{className:"rounded-md bg-chip px-1.5 py-0.5 font-mono",children:a.slice(1,-1)},b);if(a.startsWith("**")&&a.endsWith("**"))return(0,d.jsx)("b",{children:a.slice(2,-2)},b);let c=a.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);if(c){let a=c[2].replace(/\\([()])/g,"$1");return/^https?:\/\//.test(a)?(0,d.jsx)(aW,{href:a,label:c[1]},b):(0,d.jsx)("span",{className:"rounded-md bg-chip px-1.5 py-0.5 font-mono",children:c[1]},b)}if(/^https?:\/\//.test(a)){let c=a.replace(/[.,;:!?…»)]+$/,""),e=a.slice(c.length),f=c.length>72?c.slice(0,69)+"…":c;return(0,d.jsxs)("span",{children:[(0,d.jsx)(aW,{href:c,label:f}),e]},b)}return a})}let aY=/^\s*\|.*\|\s*$/,aZ=/^:?-{1,}:?$/;function a$({rows:a}){let b=a.map(a=>a.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(a=>a.trim())),c=b.length>1&&b[1].every(a=>aZ.test(a)),e=c?b[0]:null,f=c?b.slice(2):b;return(0,d.jsx)("div",{className:"my-1.5 max-w-full overflow-x-auto",children:(0,d.jsxs)("table",{className:"border-collapse text-[12.5px]",children:[e?(0,d.jsx)("thead",{children:(0,d.jsx)("tr",{children:e.map((a,b)=>(0,d.jsx)("th",{className:"border border-line bg-chip px-2.5 py-1 text-left font-semibold",children:aX(a)},b))})}):null,(0,d.jsx)("tbody",{children:f.map((a,b)=>(0,d.jsx)("tr",{children:a.map((a,b)=>(0,d.jsx)("td",{className:"border border-line px-2.5 py-1 align-top",children:aX(a)},b))},b))})]})})}function a_(a){let b=a.split("\n"),c=[],f=0;for(;f<b.length;){if(/^\s*```/.test(b[f])){let a=f;for(f++;f<b.length&&!/^\s*```\s*$/.test(b[f]);)f++;let e=b.slice(a+1,f).join("\n");f<b.length&&f++,"\n"===c[c.length-1]&&c.pop(),c.push((0,d.jsx)("pre",{className:"my-1.5 max-w-full overflow-x-auto rounded-[10px] border border-line bg-bg px-3 py-2 font-mono text-[11.5px]",children:e},`c${a}`));continue}if(aY.test(b[f])){let a=f;for(;f<b.length&&aY.test(b[f]);)f++;"\n"===c[c.length-1]&&c.pop(),c.push((0,d.jsx)(a$,{rows:b.slice(a,f)},`t${a}`));continue}let a=b[f],g=a.match(/^#{1,6}\s+(.*)$/),h=a.match(/^>\s?(.*)$/);g?c.push((0,d.jsx)("span",{className:"text-[14px] font-bold",children:aX(g[1])},f)):h?c.push((0,d.jsx)("span",{className:"border-l-2 border-line pl-2 text-dim",children:aX(h[1])},f)):c.push((0,d.jsx)(e.Fragment,{children:aX(a)},f)),++f<b.length&&c.push("\n")}return c}function a0(a){return a.replace(aM,(a,b,c,d)=>`${b}${c}${d}[redacted]`)}function a1(a){let b=a0(a);return{raw:b.slice(0,24e3),truncated:b.length>24e3}}function a2(a){let b=a.match(/^(.*?):(\d+(?:-\d+)?)$/);return b?{target:b[1]??a,line:b[2]}:{target:a}}function a3(a,b){let c=a.match(aG)?.[1];if(!c)return null;let d=[],e=[],f=null,g=()=>{let a,b,c,e=f?.trim();e&&d.push((a=function(a){let b=a.toUpperCase();if("P0"===b||"P1"===b||"P2"===b||"P3"===b)return b;let c=a.toLowerCase();return"critical"===c?"Critical":"high"===c?"High":"medium"===c?"Medium":"low"===c?"Low":"Info"}(e.match(aJ)?.[1]??e.match(aJ)?.[2]??"Info"),b=function(a){let b=a.match(aL);if(b){let a=a2((b[2]??"").replace(/^file:\/\//,"")),c=a.line?Number(a.line.split("-",1)[0]):void 0;return{file:a.target||b[1],line:Number.isFinite(c)?c:void 0}}let c=a.match(aK);if(!c)return{};let d=c[2]?Number(c[2]):void 0;return{file:c[1],line:Number.isFinite(d)?d:void 0}}(e),c=function(a){let b=a,c=b.match(aJ);if(c&&void 0!==c.index){let a=b.slice(c.index+c[0].length).replace(/^[\s.:–—-]+/,"");a&&(b=a)}return b.replace(aL,"$1").replace(/`([^`]*)`/g,"$1").replace(/\s+/g," ").trim().slice(0,200)}(e)||e.slice(0,200)||"Finding",{severity:a,file:b.file,line:b.line,title:c,body:a1(e).raw})),f=null};for(let b of a.split("\n")){let a=b.trimEnd(),c=a.match(aI);if(c){g(),f=c[2]??"";continue}let h=a.trim();if(null!==f){h?f=`${f}
3
- ${h}`:g();continue}!(!h||aG.test(a)||/^(findings?|summary|open questions?|tests?|residual risk)\s*:?\s*$/i.test(h))&&0===d.length&&e.length<3&&h.length<=240&&e.push(h)}g();let h=d.filter(a=>aJ.test(a.body)).length;return c||/^findings?\s*:?$/im.test(a)||h>=2||h>=1&&/\b(review|request_changes|approve|comment)\b/i.test(a)?{kind:"review",ts:b,verdict:c,findings:d,summary:e,raw:a1(a).raw}:null}function a4(a,b,c){let d=b.split("\n").map(a=>a.trim()).filter(Boolean).map(a=>{let b=a.match(/\|note=\[(.*)\]$/)?.[1],c=a2(a.replace(/\|note=\[.*\]$/,""));return{target:c.target,line:c.line,note:b,raw:a}}),e=c.split(/\s+/).map(a=>a.trim()).filter(a=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(a)),f=a1(a);return{kind:"mem-citation",entries:d,rolloutIds:e,raw:f.raw,truncated:f.truncated}}function a5(a,b,c){if(!a)return null;let d=b.match(/exited with code (\d+)/)?.[1],e=b.replace(/^Chunk ID:[^\n]*\n/,"").replace(/Wall time:[^\n]*\n/,"").replace(/Original token count:[^\n]*\n?/,"").trim(),f=!0===c||void 0!==d&&"0"!==d;return a.status=f?"err":"ok",a.label=f?d&&"0"!==d?"exit "+d:"помилка":"ok",a.open||=f,e&&(a.output=(a.output+"\n"+a0(e)).trim().slice(-(f?6e4:12e3))),a}function a6({media:a,data:b,w:c,h:f,bytes:g}){let[h,i]=(0,e.useState)("thumb"),j=Math.round((g??3*b.length/4)/1024),k=c&&f?`${c}\xd7${f}`:"зображення";if("chip"===h)return(0,d.jsxs)("button",{type:"button",onClick:()=>i("thumb"),className:"my-2 ml-9 flex items-center gap-2 rounded-[14px] border border-line bg-panel px-3.5 py-2 text-[13px] shadow-card",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(an,{name:"image",className:"h-4 w-4"})}),(0,d.jsx)("span",{className:"font-semibold",children:k}),(0,d.jsxs)("span",{className:"text-dim",children:["\xb7 ",j," КБ"]}),(0,d.jsx)("span",{className:"ml-1 text-[12px] font-semibold text-accent",children:"показати"})]});let l=`data:${a};base64,${b}`;return(0,d.jsxs)("div",{className:"my-2 ml-9",children:[(0,d.jsx)("img",{src:l,alt:`зображення ${k}`,onClick:()=>i("full"),className:"max-h-[240px] cursor-zoom-in rounded-[14px] border border-line"}),(0,d.jsx)("button",{type:"button",onClick:()=>i("chip"),className:"mt-1 block text-[12px] text-dim",children:"згорнути"}),"full"===h?(0,d.jsx)(aE,{src:l,alt:`зображення ${k}`,caption:`${k} \xb7 ${j} КБ`,onClose:()=>i("thumb")}):null]})}function a7({label:a,text:b}){let c=b.length>=2048?`${(b.length/1024).toFixed(1)} кБ`:`${b.length} симв.`;return(0,d.jsxs)("details",{className:"group my-1.5 ml-9",children:[(0,d.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-[11px] font-semibold text-dim hover:text-ink [&::-webkit-details-marker]:hidden",children:[(0,d.jsx)("span",{className:"flex h-4.5 w-4.5 items-center justify-center rounded-md bg-chip",children:(0,d.jsx)(an,{name:"cmd-group",className:"h-3 w-3"})}),(0,d.jsx)("span",{className:"rounded-full bg-chip px-1.5 py-0.5 font-mono text-[9.5px]",children:a}),(0,d.jsxs)("span",{children:["системне \xb7 ",c]}),(0,d.jsx)("span",{className:"text-accent group-open:hidden",children:"показати"}),(0,d.jsx)("span",{className:"hidden text-dim group-open:inline",children:"згорнути"})]}),(0,d.jsx)("pre",{className:"mt-1 max-h-[320px] overflow-auto whitespace-pre-wrap break-words rounded-[10px] border border-line bg-bg px-3 py-2 font-mono text-[11px] text-[#555]",children:b})]})}function a8({bytes:a,text:b}){let[c,f]=(0,e.useState)(!1),g=Math.round(a/1024);return c?(0,d.jsxs)("div",{className:"my-2 ml-9 overflow-hidden rounded-[14px] border border-line bg-panel shadow-card",children:[(0,d.jsx)("pre",{className:"max-h-[340px] overflow-auto whitespace-pre-wrap break-all bg-[#fafafc] px-3.5 py-2.5 font-mono text-[11.5px]",children:b}),(0,d.jsx)("button",{type:"button",onClick:()=>f(!1),className:"block w-full border-t border-line px-3.5 py-1.5 text-[12px] text-dim",children:"згорнути"})]}):(0,d.jsxs)("button",{type:"button",onClick:()=>f(!0),className:"my-2 ml-9 flex items-center gap-2 rounded-[14px] border border-line bg-panel px-3.5 py-2 text-[13px] shadow-card",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(an,{name:"blob",className:"h-4 w-4"})}),(0,d.jsxs)("span",{className:"font-semibold",children:["даних ",g," КБ"]}),(0,d.jsx)("span",{className:"ml-1 text-[12px] font-semibold text-accent",children:"показати"})]})}function a9({verdict:a}){return(0,d.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,d.jsx)("REQUEST_CHANGES"===a?Q:"APPROVE"===a?V:Z,{className:"h-3.5 w-3.5","aria-hidden":!0}),"REQUEST_CHANGES"===a?"REQUEST_CHANGES":"APPROVE"===a?"APPROVE":"COMMENT"]})}function ba({status:a,className:b}){let c=b??"h-3.5 w-3.5";return"ok"===a?(0,d.jsx)(S,{className:c,"aria-hidden":!0}):"err"===a?(0,d.jsx)(ad,{className:c,"aria-hidden":!0}):(0,d.jsx)(al,{className:`${c} animate-spin`,"aria-hidden":!0})}function bb({file:a,line:b}){let c=b?`${a}:${b}`:a,e="inline-block min-w-0 max-w-full truncate rounded-md bg-chip px-1.5 py-0.5 align-bottom font-mono text-[11.5px]";return aH.test(a)?(0,d.jsx)("a",{href:`#f=${encodeURIComponent(a)}`,className:`${e} text-accent underline decoration-dotted`,title:c,children:c}):(0,d.jsx)("code",{className:e,title:c,children:c})}function bc({item:a}){let b=Object.entries(a.byTool).map(([a,b])=>`${a} \xd7${b}`).join(" \xb7 "),c=u(a.t0),e=u(a.t1),f=c&&e&&c!==e?`${c}–${e}`:c||e;return(0,d.jsxs)("details",{className:`my-2.5 ml-9 overflow-hidden rounded-[14px] border shadow-card ${a.hasErr?"border-err/35 bg-[#fff4f4]":"border-line bg-panel"}`,open:a.hasErr,children:[(0,d.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-2.5 px-3.5 py-2",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(an,{name:"cmd-group",className:"h-4 w-4"})}),(0,d.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate text-[12.5px]",children:[a.calls.length," ",v(a.calls.length,"команда","команди","команд"),b?" \xb7 "+b:""," \xb7",(0,d.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-ok",children:[(0,d.jsx)(S,{className:"h-3.5 w-3.5","aria-hidden":!0}),a.okCount]}),a.errCount?(0,d.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-err",children:[(0,d.jsx)(ad,{className:"h-3.5 w-3.5","aria-hidden":!0}),a.errCount]}):null]}),f?(0,d.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-dim",children:f}):null]}),(0,d.jsx)("div",{className:"space-y-1 border-t border-line bg-[#fafafc] px-2 py-1.5",children:a.calls.map((b,c)=>{let e="ok"===b.status?"text-ok":"err"===b.status?"text-err":"text-dim";return(0,d.jsxs)("details",{className:"overflow-hidden rounded-[10px] border border-line bg-panel",open:b.open,children:[(0,d.jsxs)("summary",{className:"flex h-6 cursor-pointer list-none items-center gap-2 px-2.5 text-[11.5px]",children:[(0,d.jsx)("span",{className:"flex h-4.5 w-4.5 shrink-0 items-center justify-center rounded-md bg-chip",children:(0,d.jsx)(an,{name:b.icon,className:"h-3 w-3"})}),(0,d.jsx)("code",{className:"min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap rounded-md bg-chip px-1.5 py-0.5 font-mono text-[11px]",children:b.display}),(0,d.jsxs)("span",{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[10.5px] font-semibold ${e}`,children:[(0,d.jsx)(ba,{status:b.status,className:"h-3 w-3"}),b.label]})]}),(0,d.jsx)("pre",{className:"max-h-[280px] overflow-auto whitespace-pre-wrap border-t border-line bg-[#fafafc] px-3 py-2 font-mono text-[11.5px]",children:"$ "+b.cmd+(b.output?"\n"+b.output:"")})]},a.ids[c])})})]})}function bd({item:a}){var b;let c=a.findings.length,e=a.findings.slice(0,12);return(0,d.jsxs)("div",{className:"my-3.5 ml-9 overflow-hidden rounded-[14px] border border-codex/20 bg-panel shadow-card",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-line px-3.5 py-2.5",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-lg bg-codex-soft text-codex",children:(0,d.jsx)(W,{className:"h-4 w-4","aria-hidden":!0})}),(0,d.jsx)("span",{className:"text-[13.5px] font-bold",children:"Codex review"}),a.verdict?(0,d.jsx)("span",{className:`rounded-full border px-2.5 py-0.5 text-[11.5px] font-extrabold ${"REQUEST_CHANGES"===(b=a.verdict)?"bg-[#fff0f0] text-err border-err/25":"APPROVE"===b?"bg-[#eefaf1] text-ok border-ok/25":"bg-chip text-[#555] border-line"}`,children:(0,d.jsx)(a9,{verdict:a.verdict})}):null,(0,d.jsx)("span",{className:"text-[11px] text-dim",children:c?`${c} finding${1===c?"":"s"}`:"без findings"}),u(a.ts)?(0,d.jsx)("span",{className:"ml-auto text-[11px] text-dim",children:u(a.ts)}):null]}),(0,d.jsxs)("div",{className:"px-3.5 py-2.5",children:[a.summary.length?(0,d.jsx)("div",{className:"mb-2 whitespace-pre-wrap break-words text-[13px] text-[#444]",children:a_(a.summary.join("\n"))}):null,e.length?(0,d.jsx)("div",{className:"space-y-2",children:e.map((a,b)=>{var c;return(0,d.jsxs)("div",{className:"rounded-[10px] border border-line bg-[#fbfbfd] px-3 py-2",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("span",{className:`rounded-full border px-2 py-0.5 text-[10.5px] font-extrabold ${"Critical"===(c=a.severity)||"High"===c||"P0"===c||"P1"===c?"border-err/30 bg-[#fff4f4] text-err":"Medium"===c||"P2"===c?"border-[#d89b21]/35 bg-[#fff9ea] text-[#9a6500]":"Low"===c||"P3"===c?"border-line bg-chip text-[#555]":"border-line bg-panel text-dim"}`,children:a.severity}),a.file?(0,d.jsx)(bb,{file:a.file,line:a.line}):null]}),(0,d.jsx)("div",{className:"mt-1.5 whitespace-pre-wrap break-words text-[13px]",children:aX(a.title)}),a.body&&a.body!==a.title?(0,d.jsxs)("details",{className:"mt-1 text-[12px] text-dim",children:[(0,d.jsx)("summary",{className:"cursor-pointer list-none font-semibold text-accent",children:"details"}),(0,d.jsx)("div",{className:"mt-1 whitespace-pre-wrap break-words",children:a_(a.body)})]}):null]},b)})}):null,a.findings.length>e.length?(0,d.jsxs)("div",{className:"mt-2 text-[12px] text-dim",children:["ще ",a.findings.length-e.length," findings у raw"]}):null,(0,d.jsxs)("details",{className:"mt-2 rounded-[10px] border border-line bg-[#fafafc] text-[12px]",children:[(0,d.jsx)("summary",{className:"cursor-pointer list-none px-3 py-1.5 font-semibold text-dim",children:"raw review text"}),(0,d.jsx)("pre",{className:"max-h-[320px] overflow-auto whitespace-pre-wrap border-t border-line px-3 py-2 font-mono text-[11.5px] text-[#555]",children:a.raw})]})]})]})}function be({item:a}){let b=a.entries.slice(0,8),c=a.rolloutIds.slice(0,6);return(0,d.jsxs)("details",{className:"group my-2 ml-9 overflow-hidden rounded-[14px] border border-line bg-panel text-[12px] shadow-card",children:[(0,d.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-2 px-3.5 py-2",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(an,{name:"citation",className:"h-4 w-4"})}),(0,d.jsxs)("span",{className:"text-[13px] font-semibold",children:["цитати пам'яті (",a.entries.length,")"]}),(0,d.jsx)("span",{className:"ml-auto text-[11px] font-semibold text-accent group-open:hidden",children:"показати"}),(0,d.jsx)("span",{className:"ml-auto hidden text-[11px] font-semibold text-accent group-open:inline",children:"згорнути"})]}),(0,d.jsxs)("div",{className:"border-t border-line px-3.5 py-2.5",children:[b.length?(0,d.jsx)("div",{className:"space-y-1.5",children:b.map((a,b)=>(0,d.jsxs)("div",{className:"min-w-0 rounded-[9px] bg-[#fbfbfd] px-2.5 py-1.5",children:[(0,d.jsx)(bb,{file:a.target,line:a.line?Number(a.line.split("-",1)[0]):void 0}),a.note?(0,d.jsx)("div",{className:"mt-1 whitespace-pre-wrap break-words text-[12px] text-[#555]",children:a.note}):null]},b))}):(0,d.jsx)("div",{className:"text-[12px] text-dim",children:"без citation entries"}),a.entries.length>b.length?(0,d.jsxs)("div",{className:"mt-1.5 text-[12px] text-dim",children:["ще ",a.entries.length-b.length," entries у raw"]}):null,c.length?(0,d.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] text-dim",children:"rollout:"}),c.map(a=>(0,d.jsx)("code",{className:"rounded-full bg-chip px-2 py-0.5 font-mono text-[10.5px] text-dim",title:a,children:a.slice(0,8)},a)),a.rolloutIds.length>c.length?(0,d.jsxs)("span",{className:"text-[11px] text-dim",children:["+",a.rolloutIds.length-c.length]}):null]}):null,(0,d.jsxs)("details",{className:"mt-2 rounded-[10px] border border-line bg-[#fafafc] text-[12px]",children:[(0,d.jsxs)("summary",{className:"cursor-pointer list-none px-3 py-1.5 font-semibold text-dim",children:["raw citation block",a.truncated?" \xb7 обрізано":""]}),(0,d.jsx)("pre",{className:"max-h-[260px] overflow-auto whitespace-pre-wrap border-t border-line px-3 py-2 font-mono text-[11.5px] text-[#555]",children:a.raw})]})]})]})}let bf={shutdown_request:{icon:"shutdown",label:"запит на завершення",tone:"amber"},shutdown_response:{icon:"shutdown",label:"відповідь на завершення",tone:"amber"},plan_approval_request:{icon:"plan",label:"запит на затвердження плану",tone:"accent"},plan_approval_response:{icon:"plan",label:"вердикт по плану",tone:"accent"}};function bg(a){return"string"==typeof a&&a.length?a:void 0}function bh({approve:a}){return(0,d.jsx)("span",{className:`rounded-full border px-2 py-0.5 text-[10.5px] font-extrabold ${a?"border-ok/25 bg-[#eefaf1] text-ok":"border-err/25 bg-[#fff0f0] text-err"}`,children:a?"схвалено":"відхилено"})}function bi({payload:a}){let b=bg(a.from),c=bg(a.requestId),e=u(a.timestamp);return b||c||e?(0,d.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-[11px] text-dim",children:[b?(0,d.jsxs)("span",{children:["від ",b]}):null,c?(0,d.jsx)("span",{className:"truncate font-mono",title:c,children:c.length>40?c.slice(0,40)+"…":c}):null,e?(0,d.jsx)("span",{children:e}):null]}):null}function bj({payload:a}){let b=bg(a.type),c=b?bf[b]:void 0;if(!c)return(0,d.jsxs)("div",{className:"text-[13px]",children:[(0,d.jsx)("div",{className:"text-dim",children:"структуроване повідомлення"}),(0,d.jsxs)("details",{className:"mt-1 text-[12px]",children:[(0,d.jsx)("summary",{className:"cursor-pointer list-none font-semibold text-accent",children:"показати JSON"}),(0,d.jsx)("pre",{className:"mt-1 max-h-[280px] overflow-auto whitespace-pre-wrap rounded-md bg-chip px-2.5 py-2 font-mono text-[11.5px]",children:JSON.stringify(a,null,2)})]})]});let e="boolean"==typeof a.approve?a.approve:void 0,f=bg(a.reason)??bg(a.feedback);return(0,d.jsxs)("div",{className:"text-[13px]",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsxs)("span",{className:`inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-[11.5px] font-bold ${"amber"===c.tone?"border-[#d89b21]/35 bg-[#fff9ea] text-[#9a6500]":"border-accent/25 bg-accent/10 text-accent"}`,children:[(0,d.jsx)(an,{name:c.icon,className:"h-3.5 w-3.5"}),c.label]}),void 0!==e?(0,d.jsx)(bh,{approve:e}):null]}),f?(0,d.jsx)("div",{className:"mt-1.5 whitespace-pre-wrap break-words",children:a_(f)}):null,(0,d.jsx)(bi,{payload:a})]})}function bk({item:a}){if("image"===a.kind)return(0,d.jsx)(a6,{media:a.media,data:a.data,w:a.w,h:a.h,bytes:a.bytes});if("blob"===a.kind)return(0,d.jsx)(a8,{bytes:a.bytes,text:a.text});if("sysmsg"===a.kind)return(0,d.jsx)(a7,{label:a.label,text:a.text});if("review"===a.kind)return(0,d.jsx)(bd,{item:a});if("mem-citation"===a.kind)return(0,d.jsx)(be,{item:a});if("prose"===a.kind){let b="codex"===a.engine?"bg-codex":"bg-claude",c="codex"===a.engine?W:aa;return(0,d.jsxs)("div",{className:"my-3.5 flex gap-2.5",children:[(0,d.jsx)("div",{className:`mt-1 flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-full text-white ${b}`,children:(0,d.jsx)(c,{className:"h-3.5 w-3.5","aria-hidden":!0})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1 whitespace-pre-wrap break-words",children:[u(a.ts)?(0,d.jsx)("div",{className:"mb-0.5 text-[11px] text-dim",children:u(a.ts)}):null,a_(a.text)]})]})}if("user"===a.kind){let b=a.text.length>500;return(0,d.jsx)("div",{className:"my-3.5 flex justify-end",children:(0,d.jsx)("div",{className:"max-w-[75%] whitespace-pre-wrap break-words rounded-2xl bg-user px-4 py-2.5",children:b?(0,d.jsxs)("details",{className:"group/usr",children:[(0,d.jsxs)("summary",{className:"cursor-pointer list-none [&::-webkit-details-marker]:hidden",children:[(0,d.jsxs)("span",{className:"group-open/usr:hidden",children:[a.text.slice(0,180),"… ",(0,d.jsxs)("span",{className:"font-semibold text-accent",children:["(",a.text.length," симв.)"]})]}),(0,d.jsxs)("span",{className:"hidden items-center gap-1 text-[11px] font-semibold text-dim group-open/usr:inline-flex",children:["згорнути ",(0,d.jsx)(U,{className:"h-3 w-3","aria-hidden":!0})]})]}),a_(a.text)]}):a_(a.text)})})}if("cmd"===a.kind){let b="ok"===a.call.status?"text-ok":"err"===a.call.status?"text-err":"text-dim";return(0,d.jsxs)("details",{className:"my-2.5 ml-9 overflow-hidden rounded-[14px] border border-line bg-panel shadow-card",open:a.call.open,children:[(0,d.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-2.5 px-3.5 py-2",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(an,{name:a.call.icon,className:"h-4 w-4"})}),(0,d.jsx)("code",{className:"max-w-[70%] overflow-hidden text-ellipsis whitespace-nowrap rounded-md bg-chip px-2 py-0.5 font-mono text-[12.5px]",children:a.call.display}),(0,d.jsxs)("span",{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-xs font-semibold ${b}`,children:[(0,d.jsx)(ba,{status:a.call.status}),a.call.label]})]}),(0,d.jsx)("pre",{className:"max-h-[340px] overflow-auto whitespace-pre-wrap border-t border-line bg-[#fafafc] px-3.5 py-2.5 font-mono text-[12.5px]",children:"$ "+a.call.cmd+(a.call.output?"\n"+a.call.output:"\n(вивід у цьому лог-файлі відсутній — повний є в rollout-сесії Codex)")})]})}if("cmd-group"===a.kind)return(0,d.jsx)(bc,{item:a});if("edit"===a.kind)return(0,d.jsxs)("div",{className:"my-2.5 ml-9 flex items-center gap-3 rounded-[14px] border border-line bg-panel px-3.5 py-2.5 shadow-card",children:[(0,d.jsx)("span",{className:"flex h-7.5 w-7.5 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(an,{name:"note",className:"h-4 w-4"})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[13.5px] font-semibold",children:a.files}),(0,d.jsx)("div",{className:"text-xs text-dim",children:"файли змінені"})]})]});if("tmsg"===a.kind){let b=function(a){let b=a.trim();if((b.startsWith('"')&&b.endsWith('"')||b.startsWith("'")&&b.endsWith("'"))&&(b=b.slice(1,-1).trim()),!b.startsWith("{"))return null;try{let a=JSON.parse(b);if(null!==a&&"object"==typeof a&&!Array.isArray(a))return a}catch{}return null}(a.text),c=a.text.length>420||a.text.split("\n").length>6;return(0,d.jsxs)("div",{className:"my-2.5 ml-9 overflow-hidden rounded-[14px] border border-accent/25 bg-[#f8f8fd] shadow-card",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3.5 pt-2",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-lg bg-[#ecebfb] text-accent",children:(0,d.jsx)(Y,{className:"h-3.5 w-3.5","aria-hidden":!0})}),(0,d.jsx)("span",{className:"text-[11px] font-semibold text-dim",children:"out"===a.dir?"до":"від"}),(0,d.jsx)("span",{className:"rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-bold text-accent",children:a.peer}),a.delivery?(0,d.jsxs)("span",{className:`inline-flex shrink-0 items-center gap-1 text-[10.5px] font-semibold ${"ok"===a.delivery?"text-ok":"text-err"}`,title:a.msgId?`msg_id: ${a.msgId}`:void 0,children:["ok"===a.delivery?(0,d.jsx)(S,{className:"h-3 w-3","aria-hidden":!0}):(0,d.jsx)(ad,{className:"h-3 w-3","aria-hidden":!0}),"ok"===a.delivery?"доставлено":"не доставлено"]}):null,u(a.ts)?(0,d.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-dim",children:u(a.ts)}):null]}),(0,d.jsx)("div",{className:"px-3.5 pb-2.5 pt-1",children:b?(0,d.jsx)(bj,{payload:b}):(0,d.jsxs)(d.Fragment,{children:[a.summary?(0,d.jsx)("div",{className:"text-[13px] font-bold",children:aX(a.summary)}):null,c?(0,d.jsxs)("details",{className:"group/tmsg mt-0.5 whitespace-pre-wrap break-words text-[13px]",children:[(0,d.jsxs)("summary",{className:"cursor-pointer list-none text-[12.5px] text-[#555] [&::-webkit-details-marker]:hidden",children:[(0,d.jsxs)("span",{className:"group-open/tmsg:hidden",children:[a.text.slice(0,260).trimEnd(),"… ",(0,d.jsx)("span",{className:"font-semibold text-accent",children:"показати все"})]}),(0,d.jsxs)("span",{className:"hidden items-center gap-1 text-[11px] font-semibold text-dim group-open/tmsg:inline-flex",children:["згорнути ",(0,d.jsx)(U,{className:"h-3 w-3","aria-hidden":!0})]})]}),a_(a.text)]}):(0,d.jsx)("div",{className:"mt-0.5 whitespace-pre-wrap break-words text-[13px]",children:a_(a.text)})]})})]})}if("tnote"===a.kind)return(0,d.jsxs)("div",{className:"my-1 ml-9 flex items-center gap-1.5 text-[11.5px] text-dim",children:[(0,d.jsx)(Y,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),a.text]});if("think"===a.kind){let b=a.text.length>150;return(0,d.jsxs)("details",{className:"my-1 ml-9 text-[11.5px] italic text-dim",children:[(0,d.jsxs)("summary",{className:`flex list-none items-center gap-1.5 truncate ${b?"cursor-pointer":""}`,title:"міркування агента",children:[(0,d.jsx)(R,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,d.jsxs)("span",{className:"truncate",children:[a.text.slice(0,150),b?"…":""]})]}),b?(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words pt-1 not-italic",children:a_(a.text)}):null]})}return"svc"===a.kind?(0,d.jsx)("div",{className:"my-1 break-words text-[11.5px] text-dim",children:a.text}):"note"===a.kind?(0,d.jsx)("div",{className:"my-2 break-words text-[12.5px] text-dim",children:aX(a.text)}):(0,d.jsx)("div",{className:`my-0.5 break-words text-[12.5px] ${a.err?"text-err":"text-[#555]"}`,children:a.text})}function bl({icon:a,label:b}){return(0,d.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-[12px] font-semibold text-ok",children:[(0,d.jsxs)("span",{className:"flex items-center gap-0.5","aria-hidden":!0,children:[(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-ok"}),(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-ok [animation-delay:150ms]"}),(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-ok [animation-delay:300ms]"})]}),(0,d.jsx)(a,{className:"h-3.5 w-3.5","aria-hidden":!0}),b]})}function bm({file:a,files:b,onSelect:c,showSvc:f,lineFilter:g,onStatus:h,paused:i,follow:k,setFollow:l,compact:m=!1}){let[n,o]=(0,e.useState)(k),p=function(a,b=!1,c=2500){(0,e.useRef)(c);let[d,f]=(0,e.useState)([]),[g,h]=(0,e.useState)(0),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(null),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(0),w=(0,e.useRef)(0),x=(0,e.useRef)(0),y=(0,e.useRef)(""),z=(0,e.useRef)(!0),A=(0,e.useRef)(0);(0,e.useRef)(!1);let B=(0,e.useRef)(!1);return{lines:d,size:g,loading:i,error:k,tickTime:m,paused:o,setPaused:p,clear:(0,e.useCallback)(()=>{f([]),w.current=0,x.current=0,y.current="",z.current=!0,r(!1)},[]),hasMore:q,loadingOlder:s,loadOlder:(0,e.useCallback)(async()=>{if(!a||B.current||x.current<=0)return 0;B.current=!0,t(!0);let b=A.current;try{let c="",d=x.current;for(let e=0;e<4;e+=1){let e=await fetch(`/api/log?path=${encodeURIComponent(a.path)}&before=${d}`),f=await e.json();if(b!==A.current||"error"in f&&f.error)return 0;if(c=f.data+c,d=f.start,0===d||c.slice(0,-1).includes("\n"))break}let e=d;if(d>0){let a,b=c.indexOf("\n");if(b<0||b===c.length-1)return 0;e=d+(a=c.slice(0,b+1),new TextEncoder().encode(a).length),c=c.slice(b+1)}let g=c.split("\n");""===g.at(-1)&&g.pop();let h=g.map(a=>a.trim()).filter(Boolean);return x.current=e,r(e>0),h.length&&(f(a=>h.concat(a)),v(a=>a+1)),h.length}catch{return 0}finally{B.current=!1,t(!1)}},[a?.path]),prependGen:u}}(a,i,n&&m?2500:0),q=(0,e.useRef)(null),r=(0,e.useRef)(null),[s,t]=(0,e.useState)(1500),[v,w]=(0,e.useState)(0),[x,y]=(0,e.useState)(!1),z=(0,e.useRef)(n);(0,e.useRef)(0),(0,e.useRef)(0);let A=(0,e.useRef)(null),B=(a,b=!1)=>{z.current=a,o(a),l(a),a&&w(0),b&&(y(!0),A.current&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>y(!1),450))},C=(0,e.useMemo)(()=>a?function(a,b,c,d){let e=new Map,f=new Map,g=[],h=0,i="",j=a=>!!(!(a.length<=2e4)&&(a.match(/\s/g)?.length??0)/a.length<.02)&&(g.push({kind:"blob",bytes:a.length,text:a0(a).slice(0,2e5)}),!0),k=(a,b)=>{let c=aT(a.source),d=aS(c.data)||aS(b.base64);if(!d)return;let e=aS(c.media_type)||aS(b.type),f=e.startsWith("image/")?e:"image/png",h=aT(b.dimensions);g.push({kind:"image",media:f,data:d,w:aN(h.originalWidth),h:aN(h.originalHeight),bytes:aN(b.originalSize)})},l=(a,b,c)=>{aF.lastIndex=0;let d=aF.test(b);if(aF.lastIndex=0,!d){let c=a3(b.trim(),a);return!!c&&(g.push(c),!0)}let e=!1,f=0,h=b=>{let d=b.trim();if(!d)return;let f=a3(d,a);f?(g.push(f),e=!0):c(d)};for(let a of b.matchAll(aF)){let c=a[0],d=a.index??0;h(b.slice(f,d)),g.push(a4(c,a[1]??"",a[2]??"")),e=!0,f=d+c.length}return h(b.slice(f)),e},m=a=>{let b=[];return aF.lastIndex=0,{cleaned:a.replace(aF,(a,c,d)=>(b.push(a4(a,c,d)),"")).trim(),cites:b}},n=(b,c)=>{if(!c.trim()||c===i||(i=c,j(c)))return;let d="codex"===a.engine?"codex":"claude";l(b,c,a=>g.push({kind:"prose",ts:b,text:a,engine:d}))||g.push({kind:"prose",ts:b,text:c,engine:d})},o=(a,b,c,d)=>{let f=c||"plain-"+g.length+"-"+String(a??""),h=function(a,b="shell"){let c=a0(a);return{cmd:c,display:function(a){let b,c=a.match(/^([A-Za-z][\w.]*): /),d=c?c[0]:"",e=d?a.slice(d.length):a;do b=e,e=(e=(e=(e=e.replace(/^export PATH=[^;]+;\s*/,"")).replace(/^cd\s+\S+\s*&&\s*/,"")).replace(/^\/usr\/bin\/zsh -lc\s+/,"")).replace(/^(["'])([\s\S]*)\1$/,(a,b,c)=>RegExp(`(?<!\\\\)${b}`).test(c)?a:c);while(e!==b);let f=e.match(/^([\w./-]+(?:\s+-)?)\s*<<\s*['"]?(\w+)['"]?/);return f&&(e=`${f[1].trim()} \xabheredoc\xbb`),(d+(e=e.replace(/\s+/g," ").trim())).slice(0,160)}(c),icon:b,output:"",status:"run",label:"виконується…",open:!1}}(b,d);return e.set(f,h),g.push({kind:"cmd",id:f,call:h,ts:a}),h},p=(a,b,d)=>{if(!a)return;let h=f.get(a);if(h){h.delivery=d||/"success"\s*:\s*false/.test(b)?"err":"ok",h.msgId=b.match(/"msg_id"\s*:\s*"([^"]+)"/)?.[1];return}!a5(e.get(a),b,d)&&b&&c&&g.push({kind:"svc",text:"output: "+a0(b).slice(0,200)})},q=a=>{c?g.push({kind:"svc",text:a.slice(0,300)}):h+=1},r=a=>{g.push({kind:"note",text:a})},s=(a,b)=>{let c=b.replace(aO,(b,c,d,e)=>{let f=aR(d,"teammate_id")||aR(d,"from")||"тімейт",h=aR(d,"summary"),i=e.trim();if(i.startsWith("{"))try{let a=JSON.parse(i);if("idle_notification"===a.type){let b=u(a.timestamp);return g.push({kind:"tnote",text:`${f}: звільнився${b?" \xb7 "+b:""}`}),""}}catch{}let{cleaned:j,cites:k}=m(i),l=/^(REQUEST_CHANGES|APPROVE|COMMENT)\b/.test(j)?a3(j,a):null;for(let b of(g.push({kind:"tmsg",ts:a,dir:"in",peer:f,summary:h,text:l?"":j}),l&&g.push(l),k))g.push(b);return""}).replace(/Another Claude session sent a message:\s*/g,"").trim();!c||j(c)||(aP.test(c)?g.push({kind:"sysmsg",label:aQ(c),text:c}):l(a,c,b=>g.push({kind:"user",ts:a,text:b}))||g.push({kind:"user",ts:a,text:c}))},t=a=>{let b=aT(a.payload),c=a.timestamp;if("session_meta"===a.type)return r(`Сесія Codex створена \xb7 ${aS(b.model)} \xb7 ${aS(b.cwd)}`);if("event_msg"===a.type){if("agent_message"===b.type&&b.message)return n(c,aS(b.message));if("user_message"===b.type&&b.message){let a=aS(b.message);return aP.test(a)?g.push({kind:"sysmsg",label:aQ(a),text:a}):g.push({kind:"user",ts:c,text:a})}return"task_started"===b.type?r("Задача стартувала"+(c?" \xb7 "+u(c):"")):"task_complete"===b.type?r("Задачу завершено"+(c?" \xb7 "+u(c):"")):q(aS(b.type)||"event")}if("response_item"===a.type){if("message"===b.type){let a=aU(b.content).map(a=>aS(a.text)||aS(a.input_text)).join(" ").trim();return a?"user"!==b.role?n(c,a):aP.test(a)?g.push({kind:"sysmsg",label:aQ(a),text:a}):g.push({kind:"user",ts:c,text:a}):q("message "+aS(b.role))}if("function_call"===b.type){let a={};try{a=JSON.parse(aS(b.arguments)||"{}")}catch{a={}}let d=aS(b.name);if("exec_command"===d||"shell"===d)return o(c,String(a.cmd??a.command??"").replace(/^\/usr\/bin\/zsh -lc /,""),aS(b.call_id));if("apply_patch"===d){let b=String(a.input??"").match(/(Add|Update|Delete) File: [^\n]+/g);g.push({kind:"edit",files:b?b.join(", ").replace(/(Add|Update|Delete) File: /g,""):"патч"});return}return"write_stdin"===d?q("stdin → сесія "+String(a.session_id??"")):o(c,d+" "+JSON.stringify(a).slice(0,120),aS(b.call_id),"tool")}if("function_call_output"===b.type)return p(aS(b.call_id),"string"==typeof b.output?b.output:JSON.stringify(b.output??""));if("custom_tool_call"===b.type&&"apply_patch"===aS(b.name)){let a=aS(b.input).match(/(Add|Update|Delete) File: [^\n]+/g);g.push({kind:"edit",files:a?a.join(", ").replace(/(Add|Update|Delete) File: /g,""):"патч"});return}return"custom_tool_call_output"===b.type?p(aS(b.call_id),"string"==typeof b.output?b.output:JSON.stringify(b.output??"")):"reasoning"===b.type?q("reasoning"):q(aS(b.type)||"item")}q(aS(a.type)||"запис")},v=a=>{let b=a.timestamp;if("user"===a.type&&a.message){let c=aT(a.message).content,d=aT(aT(a.toolUseResult).file);if("string"==typeof c)s(b,c);else for(let a of aU(c))if("text"===a.type)s(b,aS(a.text));else if("image"===a.type)k(a,d);else if("tool_result"===a.type){let b=aU(a.content);for(let a of b)"image"===a.type&&k(a,d);let c="string"==typeof a.content?a.content:b.filter(a=>"image"!==a.type).map(a=>aS(a.text)).join(" ");p(aS(a.tool_use_id),c,!0===a.is_error)}return}if("assistant"===a.type&&a.message){for(let c of aU(aT(a.message).content))if("text"===c.type&&aS(c.text).trim())n(b,aS(c.text));else if("thinking"===c.type&&aS(c.thinking).trim())g.push({kind:"think",text:aS(c.thinking).replace(/\s+/g," ").trim()});else if("tool_use"===c.type&&"SendMessage"===aS(c.name)){let a=aT(c.input),d=a.message;if("string"==typeof d){let{cleaned:e,cites:h}=m(d),i=/^(REQUEST_CHANGES|APPROVE|COMMENT)\b/.test(e)?a3(e,b):null,j={kind:"tmsg",ts:b,dir:"out",peer:String(a.to??""),summary:String(a.summary??""),text:i?"":e};for(let a of(g.push(j),i&&g.push(i),h))g.push(a);aS(c.id)&&f.set(aS(c.id),j)}else q(`SendMessage → ${String(a.to??"")} \xb7 ${aS(aT(d).type)||"протокол"}`)}else if("tool_use"===c.type){let a=aT(c.input),d=String(a.command??a.file_path??a.prompt??JSON.stringify(a));o(b,aS(c.name)+": "+d.slice(0,160),aS(c.id),"tool")}return}q(aS(a.type)||"запис")},w=null,x=()=>{if(!w)return;let a=w.join("\n").trim();if(w=null,!a)return;let b=a=>{for(let b of a.split("\n"))b.trim()&&g.push({kind:"raw",text:a0(b),err:/error|failed|traceback|exception/i.test(b)})};l(null,a,b)||b(a)},y=a=>{let b=a.replace(/\x1b\][^\x07]*(\x07|\x1b\\)/g,"").replace(/\x1b\[[0-9;?]*[A-Za-z]/g,"");if(w)if(!/^\[codex\]/.test(b))return void w.push(b);else x();if(/Assistant message$/.test(b))return;let c=b.match(/^\[([^\]]+)\]\s*(.*)$/),d=c?.[1]??null,f=c?.[2]??b;if(!(!f||/^Assistant message captured/.test(f))){if(!c&&(aG.test(b)||b.startsWith("<oai-mem-citation>"))){w=[b];return}if(/^Running command: /.test(f))return o(d,f.replace(/^Running command: /,"").replace(/^\/usr\/bin\/zsh -lc /,""));if(/^Command (completed|failed)/.test(f)){let a=[...e.values()].at(-1);a&&a5(a,/^Command failed/.test(f)?f+"\n(це джоб-лог: він не містить stdout команд; повний вивід — у rollout-сесії Codex у списку зліва)":f,/^Command failed/.test(f));return}return/^Applying \d+ file/.test(f)?g.push({kind:"edit",files:f}):c&&!/^(Running|Command|Applying)/.test(f)?n(d,f):void(!j(b)&&g.push({kind:"raw",text:a0(b),err:/error|failed|traceback|exception/i.test(b)}))}};for(let c of b)if(!d||c.toLowerCase().includes(d))if("claude"===a.fmt||"codex"===a.fmt)try{let b=JSON.parse(c);b&&"object"==typeof b&&!Array.isArray(b)&&("claude"===a.fmt?v(b):t(b))}catch{y(c)}else y(c);return x(),{items:function(a,b){let c=[],d=0;for(;d<a.length;){if("cmd"!==a[d].kind){c.push(a[d]),d+=1;continue}let f=d,g=[];for(;f<a.length;){let b=a[f];if("cmd"===b.kind)g.push(b);else if("think"!==b.kind)break;f+=1}let h=f===a.length;if(g.length>=4&&!(b&&h)){let a={},b=0,h=0;for(let c of g){var e;let d=(e=c.call.cmd,e.match(/^([A-Za-z][\w.]*): /)?.[1]??"cmd");a[d]=(a[d]??0)+1,"ok"===c.call.status?b+=1:"err"===c.call.status&&(h+=1)}c.push({kind:"cmd-group",ids:g.map(a=>a.id),calls:g.map(a=>a.call),t0:g[0]?.ts,t1:g.at(-1)?.ts,byTool:a,okCount:b,errCount:h,hasErr:h>0}),d=f}else c.push(a[d]),d+=1}return c}(g,"live"===a.activity),hiddenServiceCount:h}}(a,p.lines,f,g.toLowerCase()):{items:[],hiddenServiceCount:0},[a,p.lines,f,g]),D=Math.max(0,C.items.length-s),E=D?C.items.slice(-s):C.items,F=()=>{let a=q.current;a&&(r.current={top:a.scrollTop,height:a.scrollHeight}),D?t(a=>a+1500):p.hasMore&&p.loadOlder().then(()=>t(a=>a+1500))},G=D>0||p.hasMore,H=C.items.at(-1),I=H?.kind==="cmd"&&"run"===H.call.status?{icon:ae,label:`виконує ${H.call.cmd.split(/[\s:]/,1)[0]||"інструмент"}…`}:H?.kind==="think"?{icon:aa,label:"думає…"}:{icon:aa,label:"працює…"};return(0,d.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[a&&C.items.length?n?"live"===a.activity?(0,d.jsxs)("div",{className:`pointer-events-none absolute bottom-2 right-3 z-10 inline-flex items-center gap-1 rounded-full bg-ok px-2 py-0.5 text-[10px] font-bold text-white shadow-card transition-transform duration-200 ${x?"scale-125":"scale-100"}`,children:[(0,d.jsx)(aw,{className:"h-3 w-3","aria-hidden":!0})," живий хвіст"]}):null:(0,d.jsxs)("button",{className:"absolute bottom-2 right-3 z-10 inline-flex items-center gap-1 rounded-full border border-line bg-panel px-2.5 py-1 text-[11px] font-semibold text-ink shadow-card hover:border-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":"Повернутись до живого хвоста",onClick:()=>{let a=q.current;a&&(a.scrollTop=a.scrollHeight),B(!0,!0)},children:[(0,d.jsx)(N,{className:"h-3.5 w-3.5","aria-hidden":!0})," ",v?`${v} нових`:"вниз"]}):null,(0,d.jsx)("div",{ref:q,className:m?"min-h-0 flex-1 overflow-y-auto py-3":"min-h-0 flex-1 overflow-y-auto py-6",onScroll:a=>{let b=a.currentTarget,c=b.scrollTop+b.clientHeight>=b.scrollHeight-50;c&&!z.current?B(!0,!0):!c&&z.current&&B(!1),b.scrollTop<120&&G&&!p.loadingOlder&&!p.loading&&F()},children:(0,d.jsx)("div",{className:m?"px-3 pb-4 text-[13px]":"mx-auto w-full max-w-[1060px] px-6 pb-16",children:a?(0,d.jsxs)(d.Fragment,{children:[m&&G?(0,d.jsx)("button",{className:"mb-2 flex w-full items-center justify-center gap-1.5 rounded-[8px] border border-dashed border-line bg-bg px-2 py-1 text-[11px] font-semibold text-dim hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",disabled:p.loadingOlder,onClick:F,children:p.loadingOlder?"завантаження…":(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(U,{className:"h-3.5 w-3.5","aria-hidden":!0})," показати раніше"]})}):null,!m&&G&&C.items.length?(0,d.jsx)("button",{className:"mb-3 flex w-full items-center justify-center gap-1.5 rounded-[10px] border border-dashed border-line bg-panel px-3 py-1.5 text-[12px] font-semibold text-dim hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",disabled:p.loadingOlder,onClick:F,children:p.loadingOlder?"завантаження…":D?`показати раніше (сховано ${D})`:"завантажити раніше з файлу"}):null,m||G||!C.items.length?null:(0,d.jsx)("div",{className:"mb-3 text-center text-[11px] text-dim",children:"початок розмови"}),m?null:(0,d.jsx)(at,{file:a,files:b,onSelect:c}),C.items.length?(0,d.jsxs)(d.Fragment,{children:[E.map((a,b)=>(0,d.jsx)(bk,{item:a},b+C.items.length-E.length)),"live"===a.activity?(0,d.jsx)(bl,{icon:I.icon,label:I.label}):null,"recent"===a.activity&&az(a)?(0,d.jsx)("div",{className:"mt-2 text-[11.5px] font-semibold text-[#b8860b]",children:"закінчив хід — чекає відповіді"}):"recent"===a.activity&&j(a)&&"running"!==a.proc?(0,d.jsxs)("div",{className:"mt-2 flex items-center gap-1 text-[11.5px] font-semibold text-dim",children:[(0,d.jsx)(L,{className:"h-3.5 w-3.5","aria-hidden":!0})," повернувся з результатом"]}):null]}):(0,d.jsxs)("div",{className:"mt-[14vh] text-center text-dim",children:[p.loading?"Завантаження…":0===p.size?"Ще без виводу — файл поки порожній":C.hiddenServiceCount?`Видимих повідомлень нема — лише службові записи (${C.hiddenServiceCount}). Натисни \xabСлужбові\xbb`:"Порожньо (немає рядків для показу)",!p.loading&&(a.cmdDesc||a.cmd)?(0,d.jsxs)("div",{className:"mx-auto mt-3 max-w-[560px]",children:[a.cmdDesc?(0,d.jsx)("div",{className:"text-[12.5px] font-semibold text-ink",children:a.cmdDesc}):null,a.cmd?(0,d.jsx)("pre",{className:"mt-1.5 overflow-x-auto whitespace-pre-wrap break-words rounded-[10px] border border-line bg-bg px-3 py-2 text-left font-mono text-[11.5px] text-ink",children:a.cmd}):null]}):null]})]}):(0,d.jsx)("div",{className:"mt-[20vh] text-center text-dim",children:"Вибери лог зліва — стрічка оновлюється сама"})})})]})}function bn({onError:a,onUnclaimedText:b}){let[c,d]=(0,e.useState)("idle"),[f,g]=(0,e.useState)(0),h=(0,e.useRef)(null),i=(0,e.useRef)([]),j=(0,e.useRef)(!1),k=(0,e.useRef)(null),l=(0,e.useRef)(null),m=(0,e.useRef)(null),n=(0,e.useRef)(null),o=(0,e.useRef)(!1),p=async()=>{let c;null!==k.current&&(clearInterval(k.current),k.current=null),c=m.current,m.current=null,c&&(cancelAnimationFrame(c.raf),c.ctx.close().catch(()=>void 0));let e=h.current;h.current=null,e?.stream.getTracks().forEach(a=>a.stop());let f=new Blob(i.current,{type:"audio/webm"});i.current=[];let g=n.current;if(n.current=null,j.current||f.size<2e3){d("idle"),g?.(null);return}d("busy");try{let c=new FormData;c.append("file",f,"dictation.webm");let d=await fetch("/api/transcribe",{method:"POST",body:c}),e=await d.json();if(!d.ok||"string"!=typeof e.text){a(e.error??"не вдалося розпізнати"),g?.(null);return}let h=e.text.trim();h?g?g(h):b(h):(a("тиша — нічого не розпізналось"),g?.(null))}catch{a("сервер недоступний"),g?.(null)}finally{d("idle")}},q=async()=>{let b;if(o.current||h.current)return;o.current=!0;try{b=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1}})}catch{a("немає доступу до мікрофона");return}finally{o.current=!1}let c=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm",e=new MediaRecorder(b,{mimeType:c});i.current=[],j.current=!1,e.ondataavailable=a=>{a.data.size&&i.current.push(a.data)},e.onstop=()=>{p()},e.start(250),h.current=e,(a=>{let b;try{b=new AudioContext}catch{return}let c=b.createAnalyser();c.fftSize=128,c.smoothingTimeConstant=.7,b.createMediaStreamSource(a).connect(c);let d=new Uint8Array(c.frequencyBinCount),e=()=>{if(!m.current)return;m.current.raf=requestAnimationFrame(e),c.getByteFrequencyData(d);let a=l.current;a&&function(a,b){let c=window.devicePixelRatio||1;(a.width!==56*c||a.height!==16*c)&&(a.width=56*c,a.height=16*c);let d=a.getContext("2d");if(!d)return;d.setTransform(c,0,0,c,0,0),d.clearRect(0,0,56,16);let e=Math.max(13,Math.floor(.65*b.length))/13;for(let a=0;a<13;a+=1){let c=Math.floor(a*e),f=Math.max(c+1,Math.floor((a+1)*e)),g=0;for(let a=c;a<f;a+=1)g+=b[a]??0;let h=g/(f-c)/255,i=Math.max(1.5,16*h);d.fillStyle=`rgba(198, 40, 40, ${(.35+.65*h).toFixed(3)})`,d.fillRect(4.3076923076923075*a+1,(16-i)/2,2.3076923076923075,i)}}(a,d)};m.current={ctx:b,raf:requestAnimationFrame(e)}})(b),g(0),d("rec"),k.current=window.setInterval(()=>{g(a=>{let b=a+1;return b>=120&&h.current?.state==="recording"&&h.current.stop(),b})},1e3)};return{phase:c,elapsed:f,canvasRef:l,start:q,stop:()=>new Promise(a=>{let b=h.current;b&&"recording"===b.state?(n.current=a,b.stop()):a(null)}),discard:()=>{j.current=!0,h.current?.state==="recording"&&h.current.stop()}}}let bo={"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/webp":"webp"};function bp(a){return new Promise((b,c)=>{let d=new FileReader;d.onload=()=>{let e=String(d.result),f=e.indexOf(",");f<0?c(Error("не вдалося прочитати картинку")):b({base64:e.slice(f+1),mime:a.type||"image/png",preview:e})},d.onerror=()=>c(d.error??Error("не вдалося прочитати картинку")),d.onabort=()=>c(Error("читання картинки перервано")),d.readAsDataURL(a)})}function bq(a){let[b,c]=(0,e.useState)([]),d=b=>{if(!b.length)return;let d=[];for(let c of b){if(null===(bo[c.type]??null)){a.onError(`непідтримуваний формат картинки: ${c.name||c.type||"невідомий файл"}`);continue}if(c.size>0xa00000){a.onError(`${c.name||"картинка"}: завелика (ліміт 10 МБ)`);continue}d.push(c)}if(!d.length)return;let e=d.length<b.length;Promise.all(d.map(bp)).then(b=>{c(a=>[...a,...b]),e||a.onAdded?.()}).catch(b=>{a.onError(b instanceof Error?b.message:"помилка картинки")})};return{images:b,addFiles:d,handlePaste:a=>{let b=Array.from(a.clipboardData.items).filter(a=>a.type.startsWith("image/")).map(a=>a.getAsFile()).filter(a=>null!==a);b.length&&(a.preventDefault(),d(b))},removeAt:a=>c(b=>b.filter((b,c)=>c!==a)),clear:()=>c([])}}function br({images:a,onRemove:b}){return a.length?(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.map((a,c)=>(0,d.jsxs)("div",{className:"group/img relative",children:[(0,d.jsx)("img",{src:a.preview,alt:`прев'ю картинки ${c+1}`,className:"h-10 w-10 rounded border border-line object-cover"}),(0,d.jsx)("button",{type:"button",onClick:()=>b(c),"aria-label":`Прибрати картинку ${c+1}`,className:"absolute -right-1 -top-1 hidden h-4 w-4 items-center justify-center rounded-full border border-line bg-panel text-dim shadow-card hover:text-err group-hover/img:flex focus-visible:flex focus-visible:outline-none",children:(0,d.jsx)(ad,{className:"h-2.5 w-2.5","aria-hidden":!0})})]},c)),(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10.5px] font-semibold text-dim",children:[a.length," ",1===a.length?"картинка":"картинки"," ",(0,d.jsx)(O,{className:"h-3 w-3","aria-hidden":!0})," шляхами до файлів"]})]}):null}function bs({onFiles:a,ariaLabel:b,className:c}){let f=(0,e.useRef)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("input",{ref:f,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:b=>{a(Array.from(b.target.files??[])),b.target.value=""}}),(0,d.jsx)("button",{type:"button","aria-label":b,onClick:()=>f.current?.click(),className:c,children:(0,d.jsx)(X,{className:"h-4 w-4","aria-hidden":!0})})]})}function bt({phase:a,elapsed:b,canvasRef:c,start:e,stop:f,discard:g,onText:h,busy:i=!1}){let j=()=>{i||("idle"===a?e():"rec"===a&&f().then(a=>{a&&h(a)}))};if("rec"===a)return(0,d.jsxs)("span",{className:"flex shrink-0 items-center gap-1",children:[(0,d.jsxs)("button",{type:"button","aria-label":"Зупинити запис і розпізнати",onClick:j,className:"flex items-center gap-1.5 rounded-[8px] border border-err/50 bg-[#fff2f2] px-2 py-2 text-[11px] font-bold text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-err/40",children:[(0,d.jsx)("canvas",{ref:c,width:56,height:16,className:"h-4 w-14","aria-hidden":!0}),`${Math.floor(b/60)}:${String(b%60).padStart(2,"0")}`]}),(0,d.jsx)("button",{type:"button","aria-label":"Скасувати запис",onClick:g,className:"inline-flex items-center justify-center rounded-[8px] border border-line bg-panel p-2 text-dim hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",children:(0,d.jsx)(ad,{className:"h-3.5 w-3.5","aria-hidden":!0})})]});return(0,d.jsx)("button",{type:"button","aria-label":"busy"===a?"Розпізнаю…":"Надиктувати",title:"busy"===a?"розпізнаю…":"надиктувати (до 2 хв)",disabled:"busy"===a||i,onClick:j,className:"inline-flex shrink-0 items-center justify-center rounded-[8px] border border-line bg-panel p-2 text-dim hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-60",children:"busy"===a?(0,d.jsx)(al,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):(0,d.jsx)($,{className:"h-4 w-4","aria-hidden":!0})})}function bu({onText:a,onError:b}){let c=bn({onError:b,onUnclaimedText:a});return(0,d.jsx)(bt,{...c,onText:a})}function bv(a){return"claude-projects"===a.root?"сесія"===a.kind||"субагент"===a.kind:"codex-sessions"===a.root}function bw({file:a}){let b=function(a,b){let[c,d]=(0,e.useState)(null);return null!==a||b?c:null}(a.pid,bv(a)?a.path:void 0),[c,f]=(0,e.useState)(()=>""),g=(0,e.useRef)(c),h=b=>{let c="function"==typeof b?b(g.current):b;(g.current=c,f(c),c)?sessionStorage.setItem("llvDraft:"+a.path,c):sessionStorage.removeItem("llvDraft:"+a.path)},[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)([]),s=(0,e.useRef)(null),t=bq({onError:a=>p({kind:"err",text:a}),onAdded:()=>p(null)}),u=a=>{h(b=>b?b.trimEnd()+" "+a:a),p(null),s.current?.focus()},v=bn({onError:a=>p({kind:"err",text:a}),onUnclaimedText:u}),w=bv(a);if(null===b&&!w)return null;let x=null===b,y=x&&"claude-projects"===a.root&&"субагент"===a.kind,z=b=>{r(b),sessionStorage.setItem("llvSent:"+a.path,JSON.stringify(b))},A=async b=>{let d=b??c;if(!i&&!k&&(d.trim()||t.images.length)){j(!0),p(null);try{let b=await fetch("/api/tmux",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({pid:a.pid??void 0,path:a.path,text:d,images:t.images.map(a=>({base64:a.base64,mime:a.mime}))})}),c=await b.json();if(!b.ok||!c.ok)return void p({kind:"err",text:c.error??"не вдалося надіслати"});let e=t.images.length,f={id:Date.now(),text:d.trim()||(e?`${e} ${1===e?"картинка":"картинки"}`:""),at:Date.now(),via:c.spawned?"spawn":"pane"};z([...q,f].slice(-8)),h(""),t.clear(),p({kind:"ok",text:c.spawned?`запущено агента в tmux ${c.target??""}`:c.imagePaths?.length?`надіслано ${c.imagePaths.length} шлях(и)`:"надіслано"}),s.current?.focus()}catch{p({kind:"err",text:"сервер недоступний"})}finally{j(!1)}}},B=async()=>{if(!i&&!k){l(!0);try{let a=await v.stop();if(null===a)return;let b=g.current?g.current.trimEnd()+" "+a:a;h(b),await A(b)}finally{l(!1)}}},C=async()=>{if(!m){n(!0),p(null);try{let b=await fetch("/api/tmux",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"interrupt",path:a.path})}),c=await b.json();if(!b.ok||!c.ok)return void p({kind:"err",text:c.error??"не вдалося перервати"});p({kind:"ok",text:"надіслано Escape — агент перервано"})}catch{p({kind:"err",text:"сервер недоступний"})}finally{n(!1)}}},D="rec"===v.phase,E="busy"===v.phase,F=!i&&!k&&!E&&(D||!!c.trim()||t.images.length>0),G=i||k;return(0,d.jsxs)("form",{onSubmit:a=>{a.preventDefault(),A()},className:"flex shrink-0 flex-col gap-1.5 border-t border-line bg-[#fbfbfd] px-2.5 py-2","aria-label":x?"Запустити агента з промптом у tmux":`Надіслати повідомлення агенту в tmux ${b}`,children:[q.length?(0,d.jsx)("div",{className:"flex flex-col gap-0.5","aria-label":"Черга надісланих повідомлень",children:q.map(a=>(0,d.jsxs)("div",{className:"flex items-center justify-end gap-1.5",children:[(0,d.jsx)("span",{className:"min-w-0 max-w-[85%] truncate rounded-[10px] rounded-br-[3px] bg-[#ecebfb] px-2 py-0.5 text-[11px] text-[#333]",title:a.text,children:a.text}),(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-0.5 text-[9.5px] text-dim",children:["spawn"===a.via?(0,d.jsx)(_,{className:"h-2.5 w-2.5","aria-hidden":!0}):(0,d.jsx)(O,{className:"h-2.5 w-2.5","aria-hidden":!0}),new Date(a.at).toLocaleTimeString("uk",{hour12:!1,hour:"2-digit",minute:"2-digit"})]}),(0,d.jsx)("button",{type:"button","aria-label":"Прибрати з черги",className:"inline-flex shrink-0 items-center rounded px-0.5 text-dim hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>z(q.filter(b=>b.id!==a.id)),children:(0,d.jsx)(ad,{className:"h-3 w-3","aria-hidden":!0})})]},a.id))}):null,(0,d.jsx)("textarea",{ref:s,value:c,rows:1,onChange:a=>h(a.target.value),onPaste:t.handlePaste,onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),"rec"===v.phase?B():A())},placeholder:y?"написати — передам через кореневу сесію…":x?"промпт — агент запуститься в tmux…":"написати агенту…","aria-label":"Текст для агента",disabled:G,className:"w-full resize-none overflow-y-auto rounded-[10px] border border-line bg-panel px-2.5 py-1.5 text-[12.5px] leading-[18px] text-[#222] placeholder:text-dim focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-60"}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-1.5",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:"inline-flex min-w-0 items-center gap-1 rounded-full bg-chip px-1.5 py-1 font-mono text-[9.5px] font-semibold text-[#555]",title:y?"передасться через кореневу сесію гілки":x?"нове tmux-вікно з відновленим агентом":`tmux ${b}`,children:y?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(P,{className:"h-3 w-3 shrink-0","aria-hidden":!0})," корінь"]}):x?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(_,{className:"h-3 w-3 shrink-0","aria-hidden":!0})," resume"]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ac,{className:"h-3 w-3 shrink-0","aria-hidden":!0})," ",(0,d.jsx)("span",{className:"truncate",children:b})]})}),x?null:(0,d.jsx)("button",{type:"button","aria-label":"Перервати агента (Escape)",title:"надіслати Escape у пейн агента",disabled:m,onClick:()=>void C(),className:"inline-flex shrink-0 items-center justify-center rounded-[8px] border border-line bg-panel p-2 text-dim hover:border-err/40 hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-50",children:m?(0,d.jsx)(al,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):(0,d.jsx)(ab,{className:"h-4 w-4",fill:"currentColor","aria-hidden":!0})})]}),(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,d.jsx)(bt,{...v,busy:k,onText:u}),(0,d.jsx)(bs,{ariaLabel:"Додати картинки",className:"inline-flex shrink-0 items-center justify-center rounded-[8px] border border-line bg-panel p-2 text-dim hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onFiles:t.addFiles}),(0,d.jsx)("button",{type:D?"button":"submit",onClick:D?()=>void B():void 0,disabled:!F,"aria-label":D?"Зупинити запис і надіслати":x?"Запустити агента":"Надіслати агенту",title:D?"зупинити запис і надіслати":void 0,className:`inline-flex shrink-0 items-center justify-center rounded-[8px] border p-2 text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 ${D?"border-err bg-err hover:opacity-90":"border-accent bg-accent hover:opacity-90"}`,children:i||k?(0,d.jsx)(al,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):(0,d.jsx)(_,{className:"h-4 w-4","aria-hidden":!0})})]})]}),(0,d.jsx)(br,{images:t.images,onRemove:t.removeAt}),o?(0,d.jsx)("span",{className:`truncate text-[10.5px] font-semibold ${"ok"===o.kind?"text-ok":"text-err"}`,children:o.text}):null]})}let bx=()=>void 0;function by({file:a,files:b,tasks:c,onSelect:f,isRoot:g,onClose:h,dragHandle:i}){let j=(0,e.useRef)(null),k=D(a),l="live"===a.activity;return(0,d.jsxs)("section",{ref:j,"data-pan-ignore":!0,className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-[10px] border bg-panel shadow-card ${g?"border-t-4":"border-t-2"} ${l?"border-ok/60 shadow-[0_0_0_3px_rgba(47,158,68,0.16)]":"border-line"}`,style:{borderTopColor:B(a).color},children:[(0,d.jsxs)("header",{className:`flex h-10 shrink-0 items-center gap-1.5 border-b border-line px-2.5 ${l?"bg-[#eef8f0]":""} ${i?"cursor-grab active:cursor-grabbing":""}`,...i,children:[(0,d.jsx)("span",{className:`h-2 w-2 shrink-0 rounded-full ${w(a.activity)}`,title:"live"===a.activity?"працює":"recent"===a.activity?"закінчив":"stalled"===a.activity?"перервано":"тихо"}),(0,d.jsx)("span",{className:"inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-[10px] font-bold",style:k.style,children:k.label}),a.model?(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 py-0.5 font-mono text-[9.5px] font-semibold",style:{backgroundColor:B(a).soft,color:B(a).color},children:a.model}):null,g?null:(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-0.5 text-[10px] text-dim",title:"гілка цієї розмови",children:[(0,d.jsx)(L,{className:"h-3 w-3","aria-hidden":!0})," ",a.kind]}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold",title:s(a.title),children:s(a.title,90)}),(0,d.jsx)(as,{file:a,compact:!0}),h?(0,d.jsx)("button",{className:"inline-flex shrink-0 items-center rounded-[8px] border border-line bg-bg px-1.5 py-0.5 text-dim hover:border-err/40 hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":`Прибрати колонку ${s(a.title,60)}`,onClick:h,children:(0,d.jsx)(ad,{className:"h-3 w-3","aria-hidden":!0})}):null]}),c.length?(0,d.jsx)(ao,{className:"shrink-0 border-b border-line bg-[#fbfbfd]",enter:"fade",children:c.map(a=>(0,d.jsx)("div",{"data-flip-key":a.path,children:(0,d.jsx)(bz,{file:a,files:b,onSelect:f})},a.path))}):null,(0,d.jsx)(bm,{file:a,files:b,onSelect:f,showSvc:!1,lineFilter:"",onStatus:bx,paused:!1,follow:!0,setFollow:bx,compact:!0}),(0,d.jsx)(bw,{file:a}),("claude-projects"===a.root||"codex-sessions"===a.root)&&a.path.endsWith(".jsonl")?(0,d.jsx)(av,{file:a,paneRef:j}):null]})}function bz({file:a,files:b,onSelect:c}){let[f,g]=(0,e.useState)(!1),h=s(a.cmdDesc||a.title,80);return(0,d.jsxs)("div",{className:"border-t border-line first:border-t-0",children:[(0,d.jsxs)("div",{className:"flex h-7 items-center gap-1.5 pl-2 pr-2.5",children:[(0,d.jsxs)("button",{className:"flex h-full min-w-0 flex-1 items-center gap-1.5 rounded-[6px] text-left hover:bg-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-expanded":f,"aria-label":`${f?"Згорнути":"Розгорнути"} фонову задачу ${h}`,onClick:()=>g(a=>!a),children:[(0,d.jsx)(T,{className:`h-3.5 w-3.5 shrink-0 text-dim transition-transform ${f?"rotate-90":""}`,"aria-hidden":!0}),(0,d.jsx)("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${w(a.activity)}`}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold",title:s(a.title),children:h})]}),(0,d.jsx)(as,{file:a,compact:!0})]}),f?(0,d.jsx)("div",{className:"flex h-[220px] flex-col border-t border-dashed border-line bg-bg/60",children:(0,d.jsx)(bm,{file:a,files:b,onSelect:c,showSvc:!1,lineFilter:"",onStatus:bx,paused:!1,follow:!0,setFollow:bx,compact:!0})}):null]})}function bA(a){try{window.localStorage.setItem("llvArchived",JSON.stringify([...a]))}catch{}}function bB({data:a,onOpen:b}){let c=a.waiting.length;(0,e.useRef)(c);let[f,g]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:"group absolute bottom-3 right-3 z-20",children:[a.livePreview.length?(0,d.jsx)("div",{className:"pointer-events-none mb-1.5 hidden w-[300px] rounded-[8px] border border-line bg-panel/95 px-3 py-2 shadow-card backdrop-blur group-focus-within:block group-hover:block",children:a.livePreview.map(a=>(0,d.jsxs)("div",{className:"flex min-w-0 gap-1.5 py-0.5 text-[10.5px]",children:[(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate font-semibold",children:a.title}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-dim",children:a.statusLine||"працює…"})]},a.file.path))}):null,(0,d.jsxs)("button",{className:`ml-auto flex items-center gap-1.5 rounded-full border border-line bg-panel/95 px-2.5 py-1 text-[11.5px] font-bold shadow-card backdrop-blur transition-transform hover:border-accent/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 ${f?"scale-110 border-[#e0ae45]/70":""} motion-reduce:transition-none`,"aria-label":"Відкрити пульт агентів",onClick:b,children:[(0,d.jsx)("span",{className:`h-2 w-2 rounded-full ${a.working.length?"animate-pulse bg-ok":"bg-dim"}`}),(0,d.jsx)("span",{children:a.working.length}),(0,d.jsxs)("span",{className:c?"text-[#b8860b]":"text-dim",children:["\xb7 ",c," чекають"]})]})]})}function bC({file:a,title:b,project:c,currentProject:e,descendants:f,statusLine:g,size:h,tone:i,onOpen:j,onArchive:k}){let l=D(a),m="large"===h;return(0,d.jsxs)("article",{className:`group relative flex ${m?"h-[150px] w-[300px]":"h-[108px] w-[220px]"} shrink-0 flex-col rounded-[8px] border p-3 shadow-card transition-colors hover:border-accent/45 ${"working"===i?"border-ok/40 bg-[#f3fbf5] shadow-[0_0_0_3px_rgba(26,138,62,0.12)]":"stalled"===i?"border-err/35 bg-[#fff5f5]":"waiting"===i?"border-[#e0ae45]/45 bg-[#fff9ed]":"border-line bg-panel"}`,role:"button",tabIndex:0,"aria-label":`Відкрити колонкою ${s(b,80)}`,onClick:()=>j(a),onKeyDown:b=>{"Enter"===b.key&&j(a)},children:["live"===a.activity?null:(0,d.jsx)("button",{type:"button",className:"absolute right-1.5 top-1.5 z-10 hidden h-5 w-5 items-center justify-center rounded-full border border-line bg-bg text-dim hover:border-err/50 hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 group-hover:flex group-focus-within:flex","aria-label":"Прибрати з пульта",onClick:b=>{b.stopPropagation(),k(a)},onKeyDown:a=>a.stopPropagation(),children:(0,d.jsx)(ad,{className:"h-3 w-3","aria-hidden":!0})}),(0,d.jsxs)("div",{className:"relative flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:`h-2 w-2 shrink-0 rounded-full ${w(a.activity)}`}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 py-0.5 text-[9.5px] font-bold",style:l.style,children:l.label}),a.model?(0,d.jsx)("span",{className:"min-w-0 truncate rounded-full px-1.5 py-0.5 font-mono text-[9px] font-semibold",style:{backgroundColor:B(a).soft,color:B(a).color},children:a.model}):null,(0,d.jsx)("span",{className:`ml-auto min-w-0 truncate rounded-full border border-line bg-bg px-1.5 py-0.5 text-[9.5px] font-semibold ${c===e?"text-dim":"text-ink"}`,title:c,children:c})]}),(0,d.jsx)("div",{className:`relative mt-2 min-w-0 ${m?"text-[14px]":"text-[12.5px]"} font-bold leading-snug`,title:b,children:(0,d.jsx)("span",{className:"line-clamp-2",children:b})}),(0,d.jsxs)("div",{className:"relative mt-auto flex min-w-0 items-center gap-2 text-[10.5px] font-semibold text-dim",children:[(0,d.jsx)("span",{className:"shrink-0",children:t(a.mtime)}),f?(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-0.5",children:[(0,d.jsx)(L,{className:"h-3 w-3","aria-hidden":!0})," ",f]}):null]}),g?(0,d.jsx)("div",{className:`relative mt-1 min-w-0 truncate ${m?"text-[11.5px]":"text-[10.5px]"} font-semibold text-ink/75`,children:g}):null,a.pid&&"running"===a.proc?(0,d.jsx)("div",{className:"relative mt-2",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:(0,d.jsx)(as,{file:a,compact:!0})}):null]})}function bD({title:a,items:b,size:c,currentProject:e,onOpenFile:f,onArchive:g}){return b.length?(0,d.jsxs)("section",{className:"shrink-0",children:[(0,d.jsxs)("div",{className:"mb-2 flex items-baseline gap-2",children:[(0,d.jsx)("h2",{className:"text-[13px] font-bold",children:a}),(0,d.jsx)("span",{className:"text-[11px] font-semibold text-dim",children:b.length})]}),(0,d.jsx)(ao,{className:"flex flex-wrap gap-2.5",enter:"fade",children:b.map(a=>(0,d.jsx)("div",{"data-flip-key":a.file.path,children:(0,d.jsx)(bC,{file:a.file,title:a.title,project:a.project,currentProject:e,descendants:a.descendants,statusLine:a.statusLine,size:c,tone:"working"===a.kind?"working":"waiting"===a.kind&&"stalled"===a.file.activity?"stalled":"waiting"===a.kind?"waiting":"quiet",onOpen:f,onArchive:g})},a.file.path))})]}):null}function bE({files:a,project:b,onOpenFile:c}){let[f,g]=(0,e.useState)(!1),[h,i]=(0,e.useState)(""),[j,k]=(0,e.useState)(!1),[l,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(0),q=(0,e.useRef)(null),r=function(){let[a,b]=(0,e.useState)([]),[c,d]=(0,e.useState)(!1);return{events:a,loading:c}}(),{archivedPaths:t,archive:u,unarchive:v}=function(){let[a,b]=(0,e.useState)(()=>new Set),c=(0,e.useRef)(a);return{archivedPaths:a,archive:(0,e.useCallback)(a=>{b(b=>{if(b.has(a))return b;let d=new Set(b);return d.add(a),c.current=d,bA(d),d})},[]),unarchive:(0,e.useCallback)(a=>{b(b=>{if(!b.has(a))return b;let d=new Set(b);return d.delete(a),c.current=d,bA(d),d})},[])}}(),w=aA(a,r.events,h,o,t),x=aA(a,[],"",o,t),y=(0,e.useMemo)(()=>a.filter(a=>t.has(a.path)).map(a=>({file:a,title:s(a.title),project:m(a)})).sort((a,b)=>b.file.mtime-a.file.mtime),[a,t]),z=a=>{c(a),g(!1)},A=a=>u(a.path);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bB,{data:x,onOpen:()=>g(!0)}),f?(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/28 p-[2.5vh]",onMouseDown:()=>g(!1),children:(0,d.jsxs)("div",{className:"flex h-[95vh] w-[95vw] flex-col overflow-hidden rounded-[8px] border border-line bg-bg shadow-[0_18px_70px_rgb(20_20_30/0.28)]",role:"dialog","aria-modal":"true","aria-label":"Пульт агентів",onMouseDown:a=>a.stopPropagation(),children:[(0,d.jsxs)("header",{className:"flex h-14 shrink-0 items-center gap-3 border-b border-line bg-panel px-4",children:[(0,d.jsx)("div",{className:"text-[15px] font-bold",children:"Пульт"}),(0,d.jsx)("input",{ref:q,value:h,onChange:a=>i(a.target.value),placeholder:"Пошук за назвою або проєктом",className:"h-9 min-w-0 flex-1 rounded-[8px] border border-line bg-bg px-3 text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-accent/40"}),r.loading?(0,d.jsx)("span",{className:"text-[11px] font-semibold text-dim",children:"оновлення…"}):null,(0,d.jsx)("button",{className:"inline-flex h-8 w-8 items-center justify-center rounded-[8px] border border-line bg-bg text-dim hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":"Закрити пульт",onClick:()=>g(!1),children:(0,d.jsx)(ad,{className:"h-4 w-4","aria-hidden":!0})})]}),(0,d.jsxs)("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-4 py-4",children:[(0,d.jsx)(bD,{title:"Чекає тебе",items:w.waiting,size:"large",currentProject:b,onOpenFile:z,onArchive:A}),(0,d.jsx)(bD,{title:"Працюють",items:w.working,size:"large",currentProject:b,onOpenFile:z,onArchive:A}),(0,d.jsx)(bD,{title:"Нещодавні",items:w.recent,size:"small",currentProject:b,onOpenFile:z,onArchive:A}),(0,d.jsxs)("section",{className:"shrink-0",children:[(0,d.jsxs)("button",{className:"flex h-10 w-full items-center justify-between rounded-[8px] border border-line bg-panel px-3 text-left text-[12.5px] font-bold hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-expanded":j,onClick:()=>k(a=>!a),children:[(0,d.jsx)("span",{children:"Старіше"}),(0,d.jsx)("span",{className:"text-dim",children:w.older.length})]}),j?(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(bD,{title:"",items:w.older,size:"small",currentProject:b,onOpenFile:z,onArchive:A})}):null]}),w.waiting.length||w.working.length||w.recent.length||w.older.length?null:(0,d.jsx)("div",{className:"pt-[18vh] text-center text-[13px] font-semibold text-dim",children:"Нічого не знайдено"}),y.length?(0,d.jsxs)("section",{className:"shrink-0",children:[(0,d.jsxs)("button",{className:"flex h-9 w-full items-center justify-between rounded-[8px] border border-line bg-panel px-3 text-left text-[12px] font-bold text-dim hover:border-accent/40 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-expanded":l,onClick:()=>n(a=>!a),children:[(0,d.jsxs)("span",{children:["Приховані (",y.length,")"]}),(0,d.jsx)("span",{children:l?"сховати":"показати"})]}),l?(0,d.jsx)("div",{className:"mt-2 space-y-1",children:y.map(a=>(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2 rounded-[8px] border border-line bg-panel/60 px-3 py-1.5 text-[11.5px] text-dim",children:[(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate",children:a.title}),(0,d.jsx)("span",{className:"shrink-0 truncate text-[10.5px]",children:a.project}),(0,d.jsx)("button",{className:"shrink-0 rounded-full border border-line bg-bg px-2 py-0.5 text-[10.5px] font-semibold text-ink hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>v(a.file.path),children:"повернути"})]},a.file.path))}):null]}):null]})]})}):null]})}function bF({items:a,onSelect:b}){let[c,f]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:"shrink-0 border-t border-line bg-panel",children:[(0,d.jsxs)("button",{className:"flex h-8 items-center gap-2 px-4 text-[10px] font-bold uppercase tracking-[.6px] text-dim hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-expanded":c,onClick:()=>f(a=>!a),children:[(0,d.jsx)(T,{className:`h-3.5 w-3.5 transition-transform ${c?"rotate-90":""}`,"aria-hidden":!0}),"Тихі розмови й задачі",(0,d.jsx)("span",{className:"font-semibold normal-case tracking-normal",children:a.length})]}),c?(0,d.jsx)(ao,{className:"flex max-h-44 flex-wrap items-start gap-1.5 overflow-y-auto px-3 pb-2.5",children:a.map(a=>{let c=D(a),e=s(a.cmdDesc||a.title,70);return(0,d.jsxs)("button",{"data-flip-key":a.path,className:"inline-flex h-7 max-w-[360px] items-center gap-1.5 rounded-full border border-line bg-bg px-2 text-[11px] font-semibold text-ink hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",title:s(a.title),onClick:()=>b(a),children:[(0,d.jsx)("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${w(a.activity)}`}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 text-[9px]",style:c.style,children:c.label}),(0,d.jsx)("span",{className:"truncate",children:e}),(0,d.jsx)("span",{className:"shrink-0 font-normal text-dim",children:t(a.mtime)})]},a.path)})}):null]})}let bG=[{key:"claude",label:"Claude"},{key:"codex",label:"Codex"}];function bH({project:a}){let[b,c]=(0,e.useState)(!1),[f,g]=(0,e.useState)("claude"),[h,i]=(0,e.useState)(""),[j,k]=(0,e.useState)([]),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(null),r=(0,e.useRef)(null),s=(0,e.useRef)(null),t=bq({onError:a=>q({kind:"err",text:a}),onAdded:()=>q(null)}),u=async()=>{if(!n&&h.trim()){o(!0),q(null);try{let a=await fetch("/api/spawn",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:f,cwd:h.trim(),prompt:l,images:t.images.map(a=>({base64:a.base64,mime:a.mime}))})}),b=await a.json();if(!a.ok||!b.ok)return void q({kind:"err",text:b.error??"не вдалося запустити"});q({kind:"ok",text:`запущено в tmux ${b.target??""} — скоро з'явиться в списку`}),m(""),t.clear()}catch{q({kind:"err",text:"сервер недоступний"})}finally{o(!1)}}};return(0,d.jsxs)("div",{ref:r,className:"relative ml-auto shrink-0",children:[(0,d.jsxs)("button",{type:"button","aria-expanded":b,"aria-label":"Запустити нового агента",onClick:()=>c(a=>!a),className:"flex items-center gap-1 rounded-[8px] border border-line bg-panel px-2.5 py-1 text-[11.5px] font-bold text-ink shadow-card hover:border-accent/45 hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",children:[(0,d.jsx)("span",{className:"text-[13px] leading-none text-accent",children:"+"})," Агент"]}),b?(0,d.jsxs)("div",{className:"absolute right-0 top-full z-50 mt-1.5 flex w-[360px] flex-col gap-2.5 rounded-[12px] border border-line bg-panel p-3 shadow-[0_8px_28px_rgba(20,20,30,0.14)]",children:[(0,d.jsx)("div",{className:"flex items-center gap-1.5",role:"radiogroup","aria-label":"Двигун агента",children:bG.map(({key:a,label:b})=>{let c;return(0,d.jsx)("button",{type:"button",role:"radio","aria-checked":f===a,onClick:()=>g(a),style:f===a?{backgroundColor:(c=x[a]??y).soft,color:c.color,borderColor:c.color}:void 0,className:`flex-1 rounded-[8px] border px-2 py-1.5 text-[12px] font-bold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 ${f===a?"":"border-line bg-bg text-dim hover:text-ink"}`,children:b},a)})}),(0,d.jsxs)("label",{className:"flex flex-col gap-1 text-[10.5px] font-semibold text-dim",children:["директорія",(0,d.jsx)("input",{value:h,onChange:a=>i(a.target.value),list:"spawn-dirs",placeholder:"/home/…/Projects/…","aria-label":"Робоча директорія агента",className:"rounded-[8px] border border-line bg-bg px-2 py-1.5 font-mono text-[11.5px] font-normal text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40"}),(0,d.jsx)("datalist",{id:"spawn-dirs",children:j.map(a=>(0,d.jsx)("option",{value:a},a))})]}),(0,d.jsxs)("label",{className:"flex flex-col gap-1 text-[10.5px] font-semibold text-dim",children:["перший промпт (опційно)",(0,d.jsx)("textarea",{ref:s,value:l,onChange:a=>m(a.target.value),onPaste:t.handlePaste,rows:3,placeholder:"що зробити…","aria-label":"Перший промпт для агента",className:"resize-y rounded-[8px] border border-line bg-bg px-2 py-1.5 text-[12px] font-normal text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40"})]}),(0,d.jsx)(br,{images:t.images,onRemove:t.removeAt}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)(bu,{onText:a=>{m(b=>b?b.trimEnd()+" "+a:a),q(null),s.current?.focus()},onError:a=>q({kind:"err",text:a})}),(0,d.jsx)(bs,{ariaLabel:"Додати картинки до промпта",className:"inline-flex shrink-0 items-center rounded-[8px] border border-line bg-panel px-2 py-1.5 text-dim hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onFiles:t.addFiles}),(0,d.jsx)("button",{type:"button",disabled:n||!h.trim(),onClick:()=>void u(),className:"ml-auto rounded-[8px] border border-accent bg-accent px-3 py-1.5 text-[12px] font-bold text-white hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40",children:n?"запускаю…":"▶ Запустити"})]}),n?(0,d.jsx)("span",{className:"text-[10.5px] text-dim",children:"чекаю, поки CLI підніметься (до хвилини)…"}):null,p?(0,d.jsx)("span",{className:`text-[11px] font-semibold ${"ok"===p.kind?"text-ok":"text-err"}`,children:p.text}):null]}):null]})}function bI({group:a,quietCount:b,onSelect:c,onResetOrder:e}){let f=a.columns[0].file,g=D(f),h=a.columns.length,i=520*h+(h-1)*12;return(0,d.jsxs)("div",{className:"shrink-0",style:{width:i},children:[(0,d.jsxs)("div",{className:"flex justify-center",style:{height:28,width:520},children:[(0,d.jsxs)("button",{className:"inline-flex h-[24px] max-w-full items-center gap-1.5 self-start rounded-full border border-line bg-panel px-2.5 shadow-card hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",title:s(f.title),"aria-label":`Відкрити розмову ${s(f.title,60)}`,onClick:()=>c(f),children:[(0,d.jsx)("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${w(f.activity)}`}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 text-[9px] font-bold",style:g.style,children:g.label}),(0,d.jsx)("span",{className:"min-w-0 truncate text-[11px] font-bold",children:s(f.title,60)}),h-1+b>0?(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-0.5 text-[10px] font-semibold text-dim",children:[(0,d.jsx)(L,{className:"h-3 w-3","aria-hidden":!0})," ",h-1+b," ",v(h-1+b,"гілка","гілки","гілок")]}):null]}),e?(0,d.jsx)("button",{className:"ml-1.5 inline-flex h-[22px] w-[22px] items-center justify-center self-start rounded-full border border-line bg-panel text-dim hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",title:"Скинути ручний порядок колонок","aria-label":"Скинути ручний порядок колонок",onClick:e,children:(0,d.jsx)(M,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null]}),(0,d.jsxs)("svg",{width:i,height:36,className:"block","aria-hidden":!0,children:[a.columns.slice(1).map((a,b)=>{let c=(b+1)*532+260,e=C(a.file),f=260+(c-260)*.45;return(0,d.jsxs)("g",{children:[(0,d.jsx)("path",{d:`M 260 8 C ${f} 8, ${c} 8, ${c} 36`,fill:"none",stroke:e,strokeWidth:2,strokeLinecap:"round",opacity:"live"===a.file.activity?.9:.45}),(0,d.jsx)("circle",{cx:c,cy:33,r:2.5,fill:e})]},a.file.path)}),(0,d.jsx)("line",{x1:260,y1:4,x2:260,y2:36,stroke:C(f),strokeWidth:3,strokeLinecap:"round"}),(0,d.jsx)("circle",{cx:260,cy:5,r:4.5,fill:C(f)})]})]})}let bJ=a=>`llvCols:${a}`;function bK(a,b){let c=function(a){try{let b=JSON.parse(localStorage.getItem(bJ(a))??"{}");return{manual:b.manual??[],hidden:b.hidden??[],order:b.order??{}}}catch{return{manual:[],hidden:[],order:{}}}}(a);c.manual.includes(b)||c.manual.push(b),c.hidden=c.hidden.filter(a=>a!==b),localStorage.setItem(bJ(a),JSON.stringify(c))}function bL({files:a,project:b,openNonce:c}){let f=(0,e.useRef)(null),g=(0,e.useRef)(null),j=(0,e.useRef)(new Map),k=(0,e.useRef)(new Map),l=(0,e.useRef)(null),n=(0,e.useRef)(null),q=(0,e.useRef)(null),[s,t]=(0,e.useState)({manual:[],hidden:[],order:{}}),[u,w]=(0,e.useState)(null),x=(0,e.useRef)(null),y=(0,e.useRef)(s),z=a=>{y.current=a,t(a),localStorage.setItem(bJ(b),JSON.stringify(a))},A=(0,e.useMemo)(()=>r(a,b),[a,b]),B=(0,e.useMemo)(()=>new Set(A.map(a=>a.key)),[A]),C=(0,e.useMemo)(()=>(function(a,b,c){let d=o(a),e=[];for(let f of a){if(m(f)!==b||!i(f)||c.has(f.path))continue;let a=p(f,d);if(!a.length)continue;let g=f.mtime,j=h(f);for(let b of a)g=Math.max(g,b.mtime),j=Math.min(j,h(b));e.push({root:f,branchCount:a.length,smt:g,band:j})}return e.sort((a,b)=>a.band-b.band||b.smt-a.smt)})(a,b,B),[a,b,B]),D=(0,e.useMemo)(()=>{let c;return c=o(a),a.filter(a=>!(m(a)!==b||a.parent||B.has(a.path)||c.get(a.path)?.length)&&"live"!==a.activity).sort((a,b)=>h(a)-h(b)||b.mtime-a.mtime)},[a,b,B]),E=(0,e.useMemo)(()=>new Set(A.flatMap(a=>a.columns.map(a=>a.file.path))),[A]),F=(0,e.useMemo)(()=>new Set(s.hidden),[s.hidden]),G=(0,e.useMemo)(()=>{let c=new Map(a.map(a=>[a.path,a]));return s.manual.map(a=>c.get(a)).filter(a=>void 0!==a&&m(a)===b&&!E.has(a.path)&&!F.has(a.path))},[s.manual,a,b,E,F]),H=(0,e.useMemo)(()=>A.reduce((a,b)=>a+b.columns.reduce((a,b)=>a+ +("live"===b.file.activity)+b.tasks.filter(a=>"live"===a.activity).length,0),0),[A]),I=A.filter(a=>!a.orphanTask).length,J=a=>{let b=s.manual.filter(b=>b!==a),c=E.has(a)?[...new Set([...s.hidden,a])]:s.hidden;z({...s,manual:b,hidden:c})},K=a=>{var c;let d=m(a);if(d!==b){bK(d,a.path),location.hash="#p="+encodeURIComponent(d);return}if(E.has(a.path)&&!F.has(a.path)||G.some(b=>b.path===a.path))return void(c=a.path,j.current.get(c)?.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"}),w(c),n.current&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>w(null),1800));let e=s.hidden.filter(b=>b!==a.path),f=E.has(a.path)?s.manual:[...new Set([...s.manual,a.path])];z({...s,manual:f,hidden:e}),q.current=a.path},L=a=>{let b=f.current;g.current?.active&&b&&(b.releasePointerCapture(a.pointerId),b.style.userSelect="",b.style.cursor=""),g.current=null},M=[];H?M.push(`${H} ${v(H,"гілка працює","гілки працюють","гілок працюють")} \xb7 ${I} ${v(I,"дерево","дерева","дерев")}`):I&&M.push(`${I} ${v(I,"нещодавня розмова","нещодавні розмови","нещодавніх розмов")}`),C.length&&M.push(`${C.length} ${v(C.length,"тихе дерево","тихі дерева","тихих дерев")}`);let N=a=>b=>{b?j.current.set(a,b):j.current.delete(a)},O=A.map(a=>{let b=a.columns.filter(a=>!F.has(a.file.path)),c=s.order[a.key];if(!c||b.length<3)return{...a,columns:b};let[d,...e]=b;return e.sort((a,b)=>(c[a.file.path]??1e9)-(c[b.file.path]??1e9)),{...a,columns:d?[d,...e]:e}}).filter(a=>a.columns.length),P=O.filter(a=>a.orphanTask).map(a=>a.columns[0].file),Q=O.filter(a=>!a.orphanTask),R=Q.length>0||G.length>0;return(0,d.jsxs)("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,d.jsxs)("div",{className:"flex h-10 shrink-0 items-center gap-2.5 border-b border-line bg-panel px-4",children:[(0,d.jsx)("h1",{className:"truncate text-[13.5px] font-bold",children:b}),(0,d.jsx)("span",{className:"truncate text-[11.5px] text-dim",children:M.length?M.join(" \xb7 "):"зараз нічого не працює"}),(0,d.jsx)(bH,{project:b})]}),P.length?(0,d.jsx)("div",{className:"shrink-0 border-b border-line bg-[#fbfbfd]",children:P.map(b=>(0,d.jsx)("div",{className:`border-l-4 ${"live"===b.activity?"border-l-ok bg-[#f2faf4]":"border-l-[#9a9aa4]"}`,children:(0,d.jsx)(bz,{file:b,files:a,onSelect:K})},b.path))}):null,R?(0,d.jsx)("div",{ref:f,className:"min-h-0 flex-1 overflow-x-auto overflow-y-hidden",onPointerDown:a=>{if(0!==a.button||a.target.closest('button, a, input, textarea, select, [draggable="true"], [data-pan-ignore]'))return;let b=f.current;b&&(g.current={x:a.clientX,y:a.clientY,left:b.scrollLeft,active:!1})},onPointerMove:a=>{let b=g.current,c=f.current;if(!b||!c)return;let d=a.clientX-b.x,e=a.clientY-b.y;if(!b.active){let f=window.getSelection();if(f&&!f.isCollapsed){g.current=null;return}if(8>Math.abs(d)||Math.abs(d)<1.2*Math.abs(e))return;b.active=!0,c.setPointerCapture(a.pointerId),c.style.userSelect="none",c.style.cursor="grabbing"}c.scrollLeft=b.left-d},onPointerUp:L,onPointerCancel:L,children:(0,d.jsxs)(ao,{className:"flex h-full items-stretch gap-10 px-3 py-2.5",children:[Q.map(b=>{let c,e;return(0,d.jsxs)("div",{"data-flip-key":b.key,ref:(c=b.key,a=>{a?k.current.set(c,a):k.current.delete(c)}),className:"flex h-full shrink-0 flex-col",...(e=b.key,{onPointerEnter:a=>{l.current=e,a.currentTarget.setAttribute("data-flip-skip","1")},onPointerLeave:a=>{l.current===e&&(l.current=null),a.currentTarget.removeAttribute("data-flip-skip")}}),children:[(0,d.jsx)(bI,{group:b,quietCount:b.returnable.length+b.finished.length,onSelect:K,onResetOrder:s.order[b.key]?()=>{var a;let c;return a=b.key,c={...s.order},void(delete c[a],z({...s,order:c}))}:void 0}),(0,d.jsx)(ao,{className:"flex min-h-0 flex-1",style:{gap:12},children:b.columns.map(c=>{let e,f,g=c.file.path===b.key;return(0,d.jsx)("div",{"data-flip-key":c.file.path,ref:N(c.file.path),className:`flex min-h-0 rounded-[10px] transition-shadow ${u===c.file.path?"ring-2 ring-accent/60":""}`,style:{width:520},onDragOver:a=>{g||x.current?.group!==b.key||a.preventDefault()},onDrop:()=>{g||((a,b)=>{let c=x.current;if(x.current=null,!c||c.group!==a||c.path===b)return;let d=Q.find(b=>b.key===a);if(!d)return;let e=d.columns.slice(1).map(a=>a.file.path),f=e.indexOf(c.path),g=e.indexOf(b);if(f<0||g<0)return;e.splice(f,1),e.splice(g,0,c.path);let h=Object.fromEntries(e.map((a,b)=>[a,b]));z({...s,order:{...s.order,[a]:h}})})(b.key,c.file.path)},children:(0,d.jsx)(by,{file:c.file,tasks:c.tasks,files:a,onSelect:K,isRoot:g,onClose:()=>J(c.file.path),dragHandle:g?void 0:(e=b.key,f=c.file.path,{draggable:!0,onDragStart:a=>{x.current={group:e,path:f},a.dataTransfer.effectAllowed="move"},onDragEnd:()=>{x.current=null}})})},c.file.path)})})]},b.key)}),G.map(b=>(0,d.jsxs)("div",{"data-flip-key":b.path,className:"flex h-full shrink-0 flex-col",style:{width:520},children:[(0,d.jsx)("div",{style:{height:64},className:"shrink-0"}),(0,d.jsx)("div",{ref:N(b.path),className:`flex min-h-0 flex-1 rounded-[10px] transition-shadow ${u===b.path?"ring-2 ring-accent/60":""}`,children:(0,d.jsx)(by,{file:b,tasks:[],files:a,onSelect:K,isRoot:!b.parent,onClose:()=>J(b.path)})})]},b.path))]})}):(0,d.jsx)("div",{className:"flex flex-1 items-center justify-center px-4 py-5 text-center",children:(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[13.5px] font-semibold text-dim",children:"Жодної відкритої колонки"}),(0,d.jsx)("div",{className:"mt-0.5 text-[12px] text-dim",children:"Відкрий пульт у правому нижньому куті і клікни розмову — вона додасться сюди"})]})}),(0,d.jsx)(bE,{files:a,project:b,onOpenFile:K}),D.length?(0,d.jsx)(bF,{items:D,onSelect:K}):null]})}let bM=K("qr-code",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);function bN(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)({status:"idle"}),[g,h]=(0,e.useState)(null),[i,j]=(0,e.useState)(!1),k=(0,e.useRef)(null),l="ready"===c.status&&g&&g.url===c.url?g.dataUrl:null,m=(0,e.useCallback)(()=>{"ready"===c.status&&navigator.clipboard.writeText(c.url).then(()=>{j(!0),window.setTimeout(()=>j(!1),2e3)}).catch(()=>{})},[c]);return(0,d.jsxs)("div",{ref:k,className:"relative ml-auto shrink-0",children:[(0,d.jsx)("button",{type:"button","aria-expanded":a,"aria-label":"Показати QR для входу з телефона",onClick:()=>{a||f({status:"idle"}),b(!a)},className:"flex items-center justify-center rounded-[8px] border border-line bg-panel p-1.5 text-dim hover:border-accent/45 hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",children:(0,d.jsx)(bM,{className:"h-4 w-4","aria-hidden":!0})}),a?(0,d.jsx)("div",{className:"fixed left-1/2 top-12 z-50 flex w-[260px] -translate-x-1/2 flex-col gap-2.5 rounded-[12px] border border-line bg-panel p-3 shadow-[0_8px_28px_rgba(20,20,30,0.14)] sm:absolute sm:left-auto sm:right-0 sm:top-full sm:mt-1.5 sm:translate-x-0",children:"idle"===c.status?(0,d.jsx)("span",{className:"text-[11.5px] text-dim",children:"завантаження…"}):"error"===c.status?(0,d.jsx)("span",{className:"text-[11.5px] font-semibold text-err",children:"не вдалося отримати посилання"}):"unavailable"===c.status?(0,d.jsxs)("span",{className:"text-[11.5px] text-dim",children:["Запустіть viewer з доступом через Tailscale:"," ",(0,d.jsx)("code",{className:"rounded bg-bg px-1 py-0.5 font-mono text-[11px]",children:"bunx agent-log-viewer --tailscale"})]}):(0,d.jsxs)(d.Fragment,{children:[l?(0,d.jsx)("img",{src:l,alt:"QR код для входу з телефона",className:"mx-auto h-[220px] w-[220px]"}):(0,d.jsx)("span",{className:"text-[11.5px] text-dim",children:"генерую QR…"}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("input",{readOnly:!0,value:c.url,"aria-label":"Посилання для входу з телефона",onFocus:a=>a.currentTarget.select(),className:"min-w-0 flex-1 truncate rounded-[8px] border border-line bg-bg px-2 py-1.5 font-mono text-[10.5px] text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40"}),(0,d.jsx)("button",{type:"button","aria-label":"Копіювати посилання",onClick:m,className:"flex shrink-0 items-center gap-1 rounded-[8px] border border-line bg-panel px-2 py-1.5 text-[11px] font-semibold text-dim hover:border-accent/45 hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",children:i?(0,d.jsx)(S,{className:"h-3.5 w-3.5","aria-hidden":!0}):(0,d.jsx)(aq,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),(0,d.jsx)("span",{className:"text-[10.5px] text-dim",children:"скануй з телефона в тому ж tailnet"})]})}):null]})}function bO({files:a,selected:b,onSelect:c}){let[g,h]=(0,e.useState)(""),i=(0,e.useMemo)(()=>n(a),[a]),j=(0,e.useMemo)(()=>{let a=g.trim().toLowerCase();return a?i.filter(b=>b.project.toLowerCase().includes(a)):i},[i,g]),k=(0,e.useMemo)(()=>i.reduce((a,b)=>a+b.liveCount,0),[i]);return(0,d.jsxs)("aside",{className:"flex w-[248px] shrink-0 flex-col border-r border-line bg-panel",children:[(0,d.jsxs)("header",{className:"flex h-10 shrink-0 items-center gap-2 border-b border-line px-4 text-[13.5px] font-bold",children:["Логи агентів",k?(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-[#e5f6ea] px-2 py-0.5 text-[10.5px] font-bold text-ok",children:[(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-ok"}),k]}):null,(0,d.jsx)(bN,{})]}),(0,d.jsx)("div",{className:"px-2.5 pb-1 pt-2.5",children:(0,d.jsx)("input",{className:"w-full rounded-[9px] border border-line bg-bg px-2.5 py-1.5 text-[12px] outline-none focus-visible:ring-2 focus-visible:ring-accent/40",placeholder:"Фільтр проєктів…",value:g,onChange:a=>h(a.target.value)})}),(0,d.jsxs)("nav",{className:"flex-1 overflow-y-auto px-2 pb-3 pt-1","aria-label":"Проєкти",children:[(0,d.jsx)(bP,{label:"Огляд",live:0,total:null,age:"",active:b===f,hasLive:!1,onClick:()=>c(f)}),(0,d.jsx)("div",{className:"mx-2.5 my-1.5 border-t border-line"}),(0,d.jsx)(ao,{children:j.map(a=>(0,d.jsx)("div",{"data-flip-key":a.project,children:(0,d.jsx)(bP,{label:a.project,live:a.liveCount,total:a.conversations,age:t(a.smt),active:b===a.project,hasLive:a.liveCount>0,onClick:()=>c(a.project)})},a.project))}),j.length?null:(0,d.jsx)("div",{className:"px-3 py-4 text-center text-[12px] text-dim",children:"Нічого не знайдено"})]})]})}function bP({label:a,live:b,total:c,age:e,active:f,hasLive:g,onClick:h}){return(0,d.jsxs)("button",{className:["mb-0.5 flex w-full items-center gap-2 rounded-[10px] border px-2.5 py-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",f?"border-line bg-bg shadow-card":"border-transparent hover:bg-bg"].join(" "),"aria-current":f?"page":void 0,onClick:h,children:[(0,d.jsx)("span",{className:["h-2 w-2 shrink-0 rounded-full",g?"animate-pulse bg-ok":"bg-[#d6d6dd]"].join(" ")}),(0,d.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,d.jsx)("span",{className:`block truncate text-[13px] ${f?"font-bold":"font-semibold"}`,children:a}),e?(0,d.jsx)("span",{className:"block text-[10.5px] text-dim",children:e}):null]}),b>0?(0,d.jsx)("span",{className:"shrink-0 rounded-full bg-[#e5f6ea] px-1.5 py-0.5 text-[10.5px] font-bold text-ok",children:b}):null,null!==c?(0,d.jsx)("span",{className:"shrink-0 text-[11px] font-semibold text-dim",children:c}):null]})}function bQ(){let a=function(){let[a,b]=(0,e.useState)([]);return a}(),[b,c]=(0,e.useState)(f),[g,h]=(0,e.useState)(null),[i,j]=(0,e.useState)(0),k=(0,e.useCallback)(a=>{c(a),localStorage.setItem("llvProject",a),a!==f?history.replaceState(null,"","#p="+encodeURIComponent(a)):history.replaceState(null,"",location.pathname)},[]),l=(0,e.useCallback)(a=>{let b=m(a);bK(b,a.path),k(b),j(a=>a+1)},[k]);return(0,d.jsxs)("div",{className:"flex h-full",children:[(0,d.jsx)(bO,{files:a,selected:b,onSelect:k}),(0,d.jsx)("main",{className:"flex min-w-0 flex-1 flex-col",children:b===f?(0,d.jsx)(E,{files:a,onSelectProject:k,onSelectFile:l}):(0,d.jsx)(bL,{files:a,project:b,openNonce:i})})]})}},33873:a=>{"use strict";a.exports=require("path")},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},48056:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,95547,23))},57784:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,81921,23))},60728:()=>{},61135:()=>{},61744:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,81921,23)),Promise.resolve().then(c.t.bind(c,60440,23)),Promise.resolve().then(c.t.bind(c,84342,23)),Promise.resolve().then(c.t.bind(c,82265,23)),Promise.resolve().then(c.t.bind(c,35421,23)),Promise.resolve().then(c.t.bind(c,61335,23)),Promise.resolve().then(c.t.bind(c,70664,23)),Promise.resolve().then(c.bind(c,74661))},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},68673:(a,b,c)=>{Promise.resolve().then(c.bind(c,27074))},70440:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(88868);let e=async a=>[{type:"image/x-icon",sizes:"16x16",url:(0,d.fillMetadataSegment)(".",await a.params,"favicon.ico",!0)+"?603d046c9a6fdfbb"}]},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},74075:a=>{"use strict";a.exports=require("zlib")},76537:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>f,metadata:()=>e});var d=c(5735);c(61135);let e={title:"Живі логи",description:"Live viewer for Codex/Claude agent logs"};function f({children:a}){return(0,d.jsx)("html",{lang:"uk",className:"h-full antialiased",children:(0,d.jsx)("body",{className:"h-dvh overflow-hidden font-sans text-[15px]",children:a})})}},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},78335:()=>{},79428:a=>{"use strict";a.exports=require("buffer")},81825:(a,b,c)=>{Promise.resolve().then(c.bind(c,30366))},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},96487:()=>{}};var b=require("../webpack-runtime.js");b.C(a);var c=b.X(0,[445,319,918],()=>b(b.s=23655));module.exports=c})();
1
+ (()=>{var a={};a.id=974,a.ids=[974],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4494:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>f});var d=c(5735),e=c(27074);function f(){return(0,d.jsx)(e.Viewer,{})}},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12412:a=>{"use strict";a.exports=require("assert")},17891:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/get-segment-param")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},25880:()=>{},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},26896:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,95547,23)),Promise.resolve().then(c.t.bind(c,15098,23)),Promise.resolve().then(c.t.bind(c,47644,23)),Promise.resolve().then(c.t.bind(c,33859,23)),Promise.resolve().then(c.t.bind(c,98099,23)),Promise.resolve().then(c.t.bind(c,16237,23)),Promise.resolve().then(c.t.bind(c,98562,23)),Promise.resolve().then(c.t.bind(c,36675,23))},27074:(a,b,c)=>{"use strict";c.d(b,{Viewer:()=>d});let d=(0,c(77943).registerClientReference)(function(){throw Error("Attempted to call Viewer() from the server but Viewer is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/latand/.agents/tools/live-log-viewer-next/src/components/Viewer.tsx","Viewer")},27910:a=>{"use strict";a.exports=require("stream")},28354:a=>{"use strict";a.exports=require("util")},29021:a=>{"use strict";a.exports=require("fs")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:a=>{"use strict";a.exports=require("path")},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},48056:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,95547,23))},57784:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,81921,23))},60728:()=>{},61135:()=>{},61744:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,81921,23)),Promise.resolve().then(c.t.bind(c,60440,23)),Promise.resolve().then(c.t.bind(c,84342,23)),Promise.resolve().then(c.t.bind(c,82265,23)),Promise.resolve().then(c.t.bind(c,35421,23)),Promise.resolve().then(c.t.bind(c,61335,23)),Promise.resolve().then(c.t.bind(c,70664,23)),Promise.resolve().then(c.bind(c,74661))},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},68673:(a,b,c)=>{Promise.resolve().then(c.bind(c,27074))},70440:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>e});var d=c(88868);let e=async a=>[{type:"image/x-icon",sizes:"16x16",url:(0,d.fillMetadataSegment)(".",await a.params,"favicon.ico",!0)+"?603d046c9a6fdfbb"}]},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},74075:a=>{"use strict";a.exports=require("zlib")},76537:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>f,metadata:()=>e});var d=c(5735);c(61135);let e={title:"Живі логи",description:"Live viewer for Codex/Claude agent logs"};function f({children:a}){return(0,d.jsx)("html",{lang:"uk",className:"h-full antialiased",children:(0,d.jsx)("body",{className:"h-dvh overflow-hidden font-sans text-[15px]",children:a})})}},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},78335:()=>{},79428:a=>{"use strict";a.exports=require("buffer")},81825:(a,b,c)=>{Promise.resolve().then(c.bind(c,95170))},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},89175:(a,b,c)=>{"use strict";c.r(b),c.d(b,{__next_app__:()=>O,handler:()=>Q,routeModule:()=>P});var d=c(7553),e=c(84006),f=c(67798),g=c(34775),h=c(99373),i=c(73461),j=c(1020),k=c(26349),l=c(54365),m=c(16023),n=c(14965),o=c(63747),p=c(24235),q=c(23938),r=c(261),s=c(66758),t=c(77243),u=c(26713),v=c(37527),w=c(22820),x=c(88216),y=c(47929),z=c(79551),A=c(71797),B=c(89125),C=c(86439),D=c(77068),E=c(27269),F=c(37525),G=c(61287),H=c(81494),I=c(70722),J=c(70753),K=c(43954),L=c(17891),M={};for(let a in G)0>["default","__next_app__","routeModule","handler"].indexOf(a)&&(M[a]=()=>G[a]);c.d(b,M);let N={children:["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,4494)),"/home/latand/.agents/tools/live-log-viewer-next/src/app/page.tsx"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(c.bind(c,76537)),"/home/latand/.agents/tools/live-log-viewer-next/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.t.bind(c,95547,23)),"next/dist/client/components/builtin/global-error.js"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,55091,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,45270,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,28193,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,70440))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}},[]]}.children,O={require:c,loadChunk:()=>Promise.resolve()},P=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:N},distDir:".next",relativeProjectDir:""});async function Q(a,b,d){var M,R,S,T,U;d.requestMeta&&(0,h.setRequestMeta)(a,d.requestMeta),P.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let V=!!(0,h.getRequestMeta)(a,"minimalMode"),W="/page";"/index"===W&&(W="/");let X=await P.prepare(a,b,{srcPage:W,multiZoneDraftMode:!1});if(!X)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:Y,query:Z,params:$,pageIsDynamic:_,buildManifest:aa,nextFontManifest:ab,reactLoadableManifest:ac,serverActionsManifest:ad,clientReferenceManifest:ae,subresourceIntegrityManifest:af,prerenderManifest:ag,isDraftMode:ah,resolvedPathname:ai,revalidateOnlyGenerated:aj,routerServerContext:ak,nextConfig:al,parsedUrl:am,interceptionRoutePatterns:an,deploymentId:ao,clientAssetToken:ap}=X,aq=(0,r.normalizeAppPath)(W),{isOnDemandRevalidate:ar}=X,as=al.experimental.ppr&&!al.cacheComponents&&(0,K.isInterceptionRouteAppPath)(ai)?null:P.match(ai,ag),at=(null==as?void 0:as.route)??null,au=!!ag.routes[ai],av=a.headers["user-agent"]||"",aw=(0,u.getBotType)(av),ax=(0,q.isHtmlBotRequest)(a),ay=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[t.NEXT_ROUTER_PREFETCH_HEADER],az=(0,h.getRequestMeta)(a,"isRSCRequest")??(0,n.f)(a.headers[t.RSC_HEADER]),aA=(0,s.getIsPossibleServerAction)(a),aB=(0,m.checkIsAppPPREnabled)(al.experimental.ppr),aC=a.headers[y.NEXT_RESUME_STATE_LENGTH_HEADER];if(!(0,h.getRequestMeta)(a,"postponed")&&V&&aB&&aA&&aC&&"string"==typeof aC){let e=parseInt(aC,10),{maxPostponedStateSize:f,maxPostponedStateSizeBytes:g}=(0,E.getMaxPostponedStateSize)(al.experimental.maxPostponedStateSize);if(!isNaN(e)&&e>0){if(e>g)return b.statusCode=413,b.end((0,E.getPostponedStateExceededErrorMessage)(f)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let i="1 MB",j=(null==(U=al.experimental.serverActions)?void 0:U.bodySizeLimit)??i,k=e+(j!==i?c(95726).parse(j):1048576),l=await (0,E.readBodyWithSizeLimit)(a,k);if(null===l)return b.statusCode=413,b.end("Request body exceeded limit. To configure the body size limit for Server Actions, see: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;if(l.length>=e){let b=l.subarray(0,e).toString("utf8");(0,h.addRequestMeta)(a,"postponed",b);let c=l.subarray(e);(0,h.addRequestMeta)(a,"actionBody",c)}else throw Object.defineProperty(Error(`invariant: expected ${e} bytes of postponed state but only received ${l.length} bytes`),"__NEXT_ERROR_CODE",{value:"E979",enumerable:!1,configurable:!0})}}if(!(0,h.getRequestMeta)(a,"postponed")&&aB&&"1"===a.headers[y.NEXT_RESUME_HEADER]&&"POST"===a.method){let{maxPostponedStateSize:c,maxPostponedStateSizeBytes:e}=(0,E.getMaxPostponedStateSize)(al.experimental.maxPostponedStateSize),f=await (0,E.readBodyWithSizeLimit)(a,e);if(null===f)return b.statusCode=413,b.end((0,E.getPostponedStateExceededErrorMessage)(c)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let g=f.toString("utf8");(0,h.addRequestMeta)(a,"postponed",g)}let aD=!0===P.isDev||!0===al.experimental.exposeTestingApiInProductionBuild,aE=aD&&("1"===a.headers[t.NEXT_INSTANT_PREFETCH_HEADER]||!(0,n.f)(a.headers[t.RSC_HEADER])&&"string"==typeof a.headers.cookie&&a.headers.cookie.includes(t.NEXT_INSTANT_TEST_COOKIE+"=")),aF=(aB||aE)&&((null==(M=ag.routes[aq]??ag.dynamicRoutes[aq])?void 0:M.renderingMode)==="PARTIALLY_STATIC"||aE&&(aD||(null==ak?void 0:ak.experimentalTestProxy)===!0)),aG=aE&&aF,aH=aG&&!0===P.isDev,aI=!1,aJ=aF?(0,h.getRequestMeta)(a,"postponed"):void 0,aK=null==(R=ag.routes[ai])?void 0:R.prefetchDataRoute,aL=aF&&az&&!ay&&!aK;V&&(aL=aL&&!!aJ);let aM=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),aN=(!aw||!aF)&&(!av||(0,q.shouldServeStreamingMetadata)(av,al.htmlLimitedBots)),aO=!!((at||au||ag.routes[aq])&&!(aw&&aF)),aP=aF&&!0===al.cacheComponents,aQ=!0===P.isDev||!aO||"string"==typeof aJ||(aP&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?aL&&!V:aL),aR=!!aw&&aF,aS=(null==at?void 0:at.remainingPrerenderableParams)??[],aT=(null==at?void 0:at.fallback)===null&&((null==(S=at.fallbackRootParams)?void 0:S.length)??0)>0,aU=null;if(!ah&&aO&&!aQ&&!aA&&!aJ&&!aL){let a=as?"string"==typeof(null==at?void 0:at.fallback)?at.fallback:as.source:null;if(!0===al.experimental.partialFallbacks&&a&&(null==at?void 0:at.fallbackRouteParams)&&!aT){if(aS.length>0){let b,c=(b=new Map(aS.map(a=>[a.paramName,a])),a.split("/").map(a=>{let c=(0,L.getSegmentParam)(a);if(!c)return a;let d=b.get(c.paramName);if(!d)return a;let e=null==$?void 0:$[d.paramName];if(!e)return a;let f=Array.isArray(e)?e.map(a=>encodeURIComponent(a)).join("/"):encodeURIComponent(e);return a.replace((0,o.buildDynamicSegmentPlaceholder)(d),f)}).join("/")||"/");aU=c!==a?c:null}}else aU=ai}let aV=aU;!aV&&(P.isDev||aO&&_&&(null==at?void 0:at.fallbackRouteParams)&&!aA)&&(aV=ai),P.isDev||ah||!aO||!az||aL||(0,k.d)(a.headers);let aW={...G,tree:N,handler:Q,routeModule:P,__next_app__:O};ad&&ae&&(0,p.setManifestsSingleton)({page:W,clientReferenceManifest:ae,serverActionsManifest:ad});let aX=a.method||"GET",aY=(0,g.getTracer)(),aZ=aY.getActiveScopeSpan(),a$=!!(null==ak?void 0:ak.isWrappedByNextServer),a_=!0===al.experimental.partialFallbacks&&aS.length>0?(null==at||null==(T=at.fallbackRouteParams)?void 0:T.filter(a=>!aS.some(b=>b.paramName===a.paramName)))??[]:[],a0=async()=>((null==ak?void 0:ak.render404)?await ak.render404(a,b,am,!1):b.end("This page could not be found"),null);try{let k,m=P.getVaryHeader(ai,an);b.setHeader("Vary",m);let n=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return P.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aY.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aX} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a),k&&k!==c&&(k.setAttribute("http.route",d),k.updateName(a))}else c.updateName(`${aX} ${W}`)})},p=(0,h.getRequestMeta)(a,"incrementalCache")||await P.getIncrementalCache(a,al,ag,V);null==p||p.resetRequestCache(),globalThis.__incrementalCache=p;let q=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let k={query:Z,params:$,page:aq,sharedContext:{buildId:Y,deploymentId:ao,clientAssetToken:ap},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aW,Component:(0,j.T)(aW),params:$,routeModule:P,page:W,postponed:f,shouldWaitOnAllReady:aR,serveStreamingMetadata:aN,supportsDynamicResponse:"string"==typeof f||aQ,buildManifest:aa,nextFontManifest:ab,reactLoadableManifest:ac,subresourceIntegrityManifest:af,setCacheStatus:null==ak?void 0:ak.setCacheStatus,setIsrStatus:null==ak?void 0:ak.setIsrStatus,setReactDebugChannel:null==ak?void 0:ak.setReactDebugChannel,sendErrorsToBrowser:null==ak?void 0:ak.sendErrorsToBrowser,dir:c(33873).join(process.cwd(),P.relativeProjectDir),isDraftMode:ah,botType:aw,isOnDemandRevalidate:ar,isPossibleServerAction:aA,assetPrefix:al.assetPrefix,nextConfigOutput:al.output,crossOrigin:al.crossOrigin,trailingSlash:al.trailingSlash,images:al.images,previewProps:ag.preview,enableTainting:al.experimental.taint,htmlLimitedBots:al.htmlLimitedBots,reactMaxHeadersLength:al.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:p,cacheLifeProfiles:al.cacheLife,basePath:al.basePath,serverActions:al.experimental.serverActions,logServerFunctions:"object"==typeof al.logging&&!!al.logging.serverFunctions,...aG||aH||aI?{isBuildTimePrerendering:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:aH}:{},cacheComponents:!!al.cacheComponents,experimental:{isRoutePPREnabled:aF,expireTime:al.expireTime,staleTimes:al.experimental.staleTimes,dynamicOnHover:!!al.experimental.dynamicOnHover,optimisticRouting:!!al.experimental.optimisticRouting,inlineCss:!!al.experimental.inlineCss,prefetchInlining:al.experimental.prefetchInlining??!1,authInterrupts:!!al.experimental.authInterrupts,cachedNavigations:!!al.experimental.cachedNavigations,clientTraceMetadata:al.experimental.clientTraceMetadata||[],clientParamParsingOrigins:al.experimental.clientParamParsingOrigins,maxPostponedStateSizeBytes:(0,D.parseMaxPostponedStateSize)(al.experimental.maxPostponedStateSize)},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>P.onRequestError(a,b,d,e,ak),err:(0,h.getRequestMeta)(a,"invokeError")}};i&&(k.renderOpts.supportsDynamicResponse=!1);let l=await n(e,k),{metadata:m}=l,{cacheControl:o,headers:q={},fetchTags:r,fetchMetrics:s}=m;if(r&&(q[y.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,aO&&(null==o?void 0:o.revalidate)===0&&!P.isDev&&!aF){let a=m.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${ai}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
2
+ see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:v.CachedRouteKind.APP_PAGE,html:l,headers:q,rscData:m.flightData,postponed:m.postponed,status:m.statusCode,segmentData:m.segmentData},cacheControl:o}},r=async({hasResolved:c,previousCacheEntry:g,isRevalidating:i,span:j,forceStaticRender:k=!1})=>{let l=!1===P.isDev,m=c||b.writableEnded;try{var n;let f;if(ar&&aj&&!g&&!V)return(null==ak?void 0:ak.render404)?await ak.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(at&&(f=(0,w.parseFallbackField)(at.fallback)),!0===al.experimental.partialFallbacks&&(null==at?void 0:at.fallback)===null&&!aT&&aS.length>0&&(f=w.FallbackMode.PRERENDER),f===w.FallbackMode.PRERENDER&&(0,u.isBot)(av)&&(!aF||ax)&&(f=w.FallbackMode.BLOCKING_STATIC_RENDER),(null==g?void 0:g.isStale)===-1&&(ar=!0),ar&&(f!==w.FallbackMode.NOT_FOUND||g)&&(f=w.FallbackMode.BLOCKING_STATIC_RENDER),!V&&f!==w.FallbackMode.BLOCKING_STATIC_RENDER&&aV&&!m&&!ah&&_&&(l||!au)){if((l||at)&&f===w.FallbackMode.NOT_FOUND){if(al.adapterPath)return await a0();throw new C.NoFallbackError}if(aF&&(al.cacheComponents?!aL:!az)){let b=l&&"string"==typeof(null==at?void 0:at.fallback)?at.fallback:aq,f=(l||aG)&&(null==at?void 0:at.fallbackRouteParams)?(0,o.createOpaqueFallbackRouteParams)(at.fallbackRouteParams):aI?(0,o.getFallbackRouteParams)(aq,P):null;aG&&f&&(0,h.addRequestMeta)(a,"fallbackParams",f);let g=await P.handleResponse({cacheKey:b,req:a,nextConfig:al,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:ag,isRoutePPREnabled:aF,responseGenerator:async()=>q({span:j,postponed:void 0,fallbackRouteParams:f,forceStaticRender:!0}),waitUntil:d.waitUntil,isMinimalMode:V});if(null===g)return null;if(g)return V||!aF||!(aS.length>0)||!0!==al.experimental.partialFallbacks||!aU||!p||ar||aI||aD||aE||ay||(0,J.scheduleOnNextTick)(async()=>{let b=P.getResponseCache(a);try{await b.revalidate(aU,p,aF,!1,a=>q({span:a.span,postponed:void 0,fallbackRouteParams:a_.length>0?(0,o.createOpaqueFallbackRouteParams)(a_):null,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}),delete g.cacheControl,g}}let s=ar||i||!aJ?void 0:aJ;if(aP&&!V&&p&&(aL||aA)&&!k){let b=await p.get(ai,{kind:v.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===v.CachedRouteKind.APP_PAGE&&(s=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,J.scheduleOnNextTick)(async()=>{let b=P.getResponseCache(a);try{await b.revalidate(ai,p,aF,!1,a=>r({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if((aG||aH)&&void 0!==s)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:v.CachedRouteKind.PAGES,html:x.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let t=!P.isDev&&_&&(null==at?void 0:at.fallbackRouteParams)?(0,o.getPlaceholderFallbackRouteParams)($,at.fallbackRouteParams):null,y=t&&t.length>0?t:null==at?void 0:at.fallbackRouteParams,z=null!=t&&t.length>0,A=null;if(al.cacheComponents&&(null==at?void 0:at.fallbackRouteParams)){let b=(0,h.getRequestMeta)(a,"resolvedRouteParamKeys");b&&b.size>0&&(A=at.fallbackRouteParams.filter(a=>!b.has(a.paramName)))}let B=(l&&(0,h.getRequestMeta)(a,"renderFallbackShell")||z||aG&&!au)&&y?(0,o.createOpaqueFallbackRouteParams)(y):A&&A.length>0&&A.length<((null==at||null==(n=at.fallbackRouteParams)?void 0:n.length)??0)?(0,o.createOpaqueFallbackRouteParams)(A):aI?(0,o.getFallbackRouteParams)(aq,P):null;if((l||aG)&&al.cacheComponents&&!au&&(null==at?void 0:at.fallbackRouteParams)){let b=(0,o.createOpaqueFallbackRouteParams)(y??at.fallbackRouteParams);b&&(0,h.addRequestMeta)(a,"fallbackParams",b)}return q({span:j,postponed:s,fallbackRouteParams:B,forceStaticRender:k})}catch(b){throw(null==g?void 0:g.isStale)&&await P.onRequestError(a,b,{routerKind:"App Router",routePath:W,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aO,isOnDemandRevalidate:ar})},!1,ak),b}},s=async c=>{var f,g,i,j,k,l;let m,n=await P.handleResponse({cacheKey:aU,responseGenerator:a=>r({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ar,isRoutePPREnabled:aF,req:a,nextConfig:al,prerenderManifest:ag,waitUntil:d.waitUntil,isMinimalMode:V});if(ah&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),P.isDev&&b.setHeader("Cache-Control","no-cache, must-revalidate"),!n){if(aU)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=n.value)?void 0:f.kind)!==v.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=n.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let o="string"==typeof n.value.postponed;az&&!aA&&ao&&b.setHeader(y.NEXT_NAV_DEPLOYMENT_ID_HEADER,ao),aO&&!aL&&(!o||ay)&&(V||b.setHeader("x-nextjs-cache",ar?"REVALIDATED":n.isMiss?"MISS":n.isStale?"STALE":"HIT"),b.setHeader(t.NEXT_IS_PRERENDER_HEADER,"1"));let{value:p}=n;if(aJ)m={revalidate:0,expire:void 0};else if(aL)m={revalidate:0,expire:void 0};else if(!P.isDev)if(ah)m={revalidate:0,expire:void 0};else if(aO){if(n.cacheControl)if("number"==typeof n.cacheControl.revalidate){if(n.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${n.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});m={revalidate:n.cacheControl.revalidate,expire:(null==(j=n.cacheControl)?void 0:j.expire)??al.expireTime}}else m={revalidate:y.CACHE_ONE_YEAR_SECONDS,expire:void 0}}else b.getHeader("Cache-Control")||(m={revalidate:0,expire:void 0});if(n.cacheControl=m,"string"==typeof aM&&(null==p?void 0:p.kind)===v.CachedRouteKind.APP_PAGE&&p.segmentData){b.setHeader(t.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=p.headers)?void 0:k[y.NEXT_CACHE_TAGS_HEADER];V&&aO&&c&&"string"==typeof c&&b.setHeader(y.NEXT_CACHE_TAGS_HEADER,c);let d=p.segmentData.get(aM);return void 0!==d?(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:x.default.fromStatic(d,t.RSC_CONTENT_TYPE_HEADER),cacheControl:n.cacheControl}):(b.statusCode=204,(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:x.default.EMPTY,cacheControl:n.cacheControl}))}let s=aP?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(s){let b=(0,h.getRequestMeta)(a,"initURL")??a.url,c=b?(null==(l=(0,F.parseUrl)(b))?void 0:l.pathname)??b:void 0;if(await s(n,{url:c}))return null}if(p.headers){let a={...p.headers};for(let[c,d]of(V&&aO||delete a[y.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let u=null==(g=p.headers)?void 0:g[y.NEXT_CACHE_TAGS_HEADER];if(V&&aO&&u&&"string"==typeof u&&b.setHeader(y.NEXT_CACHE_TAGS_HEADER,u),!p.status||az&&aF||(b.statusCode=p.status),!V&&p.status&&H.RedirectStatusCode[p.status]&&az&&(b.statusCode=200),o&&!aL&&b.setHeader(t.NEXT_DID_POSTPONE_HEADER,"1"),az&&!ah){if(void 0===p.rscData){if(p.html.contentType!==t.RSC_CONTENT_TYPE_HEADER)if(al.cacheComponents)return b.statusCode=404,(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:x.default.EMPTY,cacheControl:n.cacheControl});else throw Object.defineProperty(new I.InvariantError(`Expected RSC response, got ${p.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:p.html,cacheControl:n.cacheControl})}return(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:x.default.fromStatic(p.rscData,t.RSC_CONTENT_TYPE_HEADER),cacheControl:n.cacheControl})}let w=p.html;if(aE&&aG){let c=!0===P.isDev?crypto.randomUUID():null;return w.pipeThrough(await (0,A.createInstantTestScriptInsertionTransformStream)(c)),(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:w,cacheControl:{revalidate:0,expire:void 0}})}if(!o||V||az)return(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:w,cacheControl:n.cacheControl});if(aG||aH)return w.push(new ReadableStream({start(a){a.enqueue(z.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:w,cacheControl:{revalidate:0,expire:void 0}});let C=new TransformStream;return w.push(C.readable),q({span:c,postponed:p.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==v.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(C.writable)}).catch(a=>{C.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,B.sendRenderResult)({req:a,res:b,generateEtags:al.generateEtags,poweredByHeader:al.poweredByHeader,result:w,cacheControl:{revalidate:0,expire:void 0}})};if(!a$||!aZ)return k=aY.getActiveScopeSpan(),await aY.withPropagatedContext(a.headers,()=>aY.trace(i.BaseServerSpan.handleRequest,{spanName:`${aX} ${W}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aX,"http.target":a.url}},s),void 0,!a$);await s(aZ)}catch(b){throw b instanceof C.NoFallbackError||await P.onRequestError(a,b,{routerKind:"App Router",routePath:W,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aO,isOnDemandRevalidate:ar})},!1,ak),b}}},95170:(a,b,c)=>{"use strict";c.d(b,{Viewer:()=>c6});var d=c(48249),e=c(67484);let f=(...a)=>a.filter((a,b,c)=>!!a&&""!==a.trim()&&c.indexOf(a)===b).join(" ").trim(),g=a=>{let b=a.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,b,c)=>c?c.toUpperCase():b.toLowerCase());return b.charAt(0).toUpperCase()+b.slice(1)};var h={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,e.createContext)({}),j=(0,e.forwardRef)(({color:a,size:b,strokeWidth:c,absoluteStrokeWidth:d,className:g="",children:j,iconNode:k,...l},m)=>{let{size:n=24,strokeWidth:o=2,absoluteStrokeWidth:p=!1,color:q="currentColor",className:r=""}=(0,e.useContext)(i)??{},s=d??p?24*Number(c??o)/Number(b??n):c??o;return(0,e.createElement)("svg",{ref:m,...h,width:b??n??h.width,height:b??n??h.height,stroke:a??q,strokeWidth:s,className:f("lucide",r,g),...!j&&!(a=>{for(let b in a)if(b.startsWith("aria-")||"role"===b||"title"===b)return!0;return!1})(l)&&{"aria-hidden":"true"},...l},[...k.map(([a,b])=>(0,e.createElement)(a,b)),...Array.isArray(j)?j:[j]])}),k=(a,b)=>{let c=(0,e.forwardRef)(({className:c,...d},h)=>(0,e.createElement)(j,{ref:h,iconNode:b,className:f(`lucide-${g(a).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${a}`,c),...d}));return c.displayName=g(a),c},l=k("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function m(a,b=160){let c=a.replace(/\[([^\]]+)\]\(([^)]+)\)/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/[*_~#>]+/g,"").replace(/\s+/g," ").trim().replace(/(?:\/[^\s)]+){3,}/g,a=>{if(a.length<=40)return a;let b=a.split("/").filter(Boolean);return b.length>=2?".../"+b.slice(-2).join("/"):a}).replace(/\s+/g," ").trim();return c.length>b?c.slice(0,b-1).trimEnd()+"…":c}let n="__overview__",o=a=>Math.floor(a/300);function p(a){return"live"===a.activity?0:"recent"===a.activity?1:"stalled"===a.activity?2:3}function q(a){return"claude-projects"===a.root?"сесія"===a.kind&&!a.parent:"codex-sessions"===a.root&&!a.parent}function r(a){return"claude-projects"===a.root&&"субагент"===a.kind}function s(a){return!!r(a)||!!a.handoff&&!!a.parent||"codex-sessions"===a.root&&!!a.parent}function t(a){return"shell"===a.engine||"codex-jobs"===a.root}function u(a){return a.project||"інше"}function v(a){let b=new Map;for(let c of a){let a=u(c),d=b.get(a);d||(d={project:a,liveCount:0,attentionCount:0,conversations:0,smt:0},b.set(a,d)),"live"===c.activity&&(d.liveCount+=1),(c.pendingQuestion||c.waitingInput)&&(d.attentionCount+=1),q(c)&&(d.conversations+=1),d.smt=Math.max(d.smt,c.mtime)}return[...b.values()].sort((a,b)=>{let c=a.attentionCount>0;return c!==b.attentionCount>0?c?-1:1:a.liveCount!==b.liveCount?b.liveCount-a.liveCount:o(b.smt)-o(a.smt)||a.project.localeCompare(b.project)})}function w(a){let b=new Map;for(let c of a){if(!c.parent)continue;let a=b.get(c.parent);a?a.push(c):b.set(c.parent,[c])}return b}function x(a,b){let c=[],d=[...b.get(a.path)??[]],e=new Set([a.path]);for(;d.length;){let a=d.pop();e.has(a.path)||(e.add(a.path),c.push(a),d.push(...b.get(a.path)??[]))}return c}function y(a){return!t(a)&&("live"===a.activity||"recent"===a.activity&&s(a))}function z(a,b){let c=new Map(a.map(a=>[a.path,a])),d=w(a),e=new Map,f=new Map;for(let d of a)if(u(d)===b){if("live"===d.activity||"recent"===d.activity&&s(d)){let a=function(a,b){let c=new Set,d=a;for(;d.parent&&!c.has(d.path);){c.add(d.path);let a=b.get(d.parent);if(!a)break;d=a}return d}(d,c);t(a)?f.set(a.path,a):e.set(a.path,a);continue}"recent"===d.activity&&q(d)&&e.set(d.path,d)}let g=[...e.values()].map(a=>(function(a,b,c){let d=x(a,b),e=d.filter(y).sort((a,b)=>("live"!==a.activity)-("live"!==b.activity)||o(b.mtime)-o(a.mtime)||a.path.localeCompare(b.path)),f=d.filter(a=>t(a)&&"live"===a.activity).sort((a,b)=>o(b.mtime)-o(a.mtime)||a.path.localeCompare(b.path)),g=[a,...e].map(a=>({file:a,tasks:[]})),h=new Map(g.map(a=>[a.file.path,a]));for(let a of f)(a.parent&&h.get(a.parent)||g[0]).tasks.push(a);let i=new Set([...h.keys(),...f.map(a=>a.path)]),j=d.filter(a=>!i.has(a.path)).sort((a,b)=>b.mtime-a.mtime),k=j.filter(a=>s(a)&&function(a,b){let c=new Set([a.path]),d=a;for(;d.parent&&!c.has(d.parent);){let a=b.get(d.parent);if(!a)break;if(c.add(a.path),"сесія"===a.kind)return"live"===a.activity||"recent"===a.activity;d=a}return!1}(a,c)),l=new Set(k.map(a=>a.path)),m=j.filter(a=>!l.has(a.path)),n=Math.max(...g.map(a=>a.file.mtime),...f.map(a=>a.mtime));return{key:a.path,columns:g,returnable:k,finished:m,smt:n,orphanTask:!1}})(a,d,c));for(let a of f.values())g.push({key:a.path,columns:[{file:a,tasks:[]}],returnable:[],finished:[],smt:a.mtime,orphanTask:!0});return g.sort((a,b)=>a.orphanTask!==b.orphanTask?a.orphanTask?1:-1:o(b.smt)-o(a.smt)||a.key.localeCompare(b.key))}function A(a){let b=new Map;for(let c of a){if("closed"===c.state)continue;let a=b.get(c.implementerPath);(!a||c.createdAt>a.createdAt)&&b.set(c.implementerPath,c)}return b}function B(a){let b=new Set;for(let c of a)for(let a of c.rounds)a.reviewerPath&&b.add(a.reviewerPath);return b}let C={waiting_ready:"чекає READY",spawn_pending:"готовий спавнити ревʼюера",spawning:"запускаю ревʼюера",reviewing:"ревью",relay_pending:"вердикт є — передати?",relaying:"передаю зауваження",fixing:"фікси",approved:"затверджено",done_comment:"готово із зауваженнями",needs_decision:"потребує рішення",paused:"пауза",closed:"закрито"},D=new Set(["spawn_pending","relay_pending","needs_decision","paused","approved"]),E={APPROVE:"✓",REQUEST_CHANGES:"✖",COMMENT:"◆"};function F(a){return"APPROVE"===a?{color:"#1a8a3e",soft:"#e7f4ea"}:"REQUEST_CHANGES"===a?{color:"#c62828",soft:"#fbeaea"}:"COMMENT"===a?{color:"#b07d1f",soft:"#fdf3dd"}:{color:"#8b8b95",soft:"#efeff3"}}async function G(a,b){try{let c=await fetch(`/api/flows/${encodeURIComponent(a)}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(b)});if(c.ok)return null;let d=await c.json().catch(()=>null);return d?.error??`не вдалося (${c.status})`}catch{return"сервер недоступний"}}function H(a){let b=Date.now()/1e3-a;return b<90?Math.round(b)+" с тому":b<5400?Math.round(b/60)+" хв тому":b<129600?Math.round(b/3600)+" год тому":Math.round(b/86400)+" д тому"}function I(a){if("string"!=typeof a&&"number"!=typeof a)return"";let b=new Date(a);return Number.isNaN(b.getTime())?"":b.toLocaleTimeString("uk",{hour12:!1})}function J(a,b,c,d){let e=a%10,f=a%100;return 1===e&&11!==f?b:e>=2&&e<=4&&(f<12||f>14)?c:d}function K(a){return"live"===a?"animate-pulse bg-ok":"recent"===a?"bg-[#d29a2f]":"stalled"===a?"bg-err":"bg-[#c9c9d1]"}let L={codex:{color:"#2f6fd0",soft:"#e8f0fb"},claude:{color:"#d97757",soft:"#faeee9"}},M={color:"#9a9aa4",soft:"#ececf1"},N=[[/fable|mythos/,{color:"#c2410c",soft:"#fbeade"}],[/opus/,{color:"#8a5ad6",soft:"#f1ebfb"}],[/sonnet/,{color:"#e0913f",soft:"#fbf1e4"}],[/haiku/,{color:"#d9a58c",soft:"#f9f1ec"}]],O=[[/spark/,{color:"#5ea3e4",soft:"#ecf4fd"}],[/mini|nano/,{color:"#7fb1e8",soft:"#eff6fd"}],[/codex/,{color:"#1d55ab",soft:"#e4edfa"}]];function P(a){let b=L[a.engine];if(!b)return M;let c=(a.model??"").toLowerCase();for(let[b,d]of"codex"===a.engine?O:N)if(b.test(c))return d;return b}let Q={minimal:{dl:20,ds:-32},low:{dl:12,ds:-20},medium:{dl:0,ds:0},high:{dl:-8,ds:12},xhigh:{dl:-14,ds:22},max:{dl:-19,ds:30}};function R(a,b,c){let[d,e,f]=function(a){let b=parseInt(a.slice(1),16),c=(b>>16&255)/255,d=(b>>8&255)/255,e=(255&b)/255,f=Math.max(c,d,e),g=Math.min(c,d,e),h=(f+g)/2,i=f-g;if(0===i)return[0,0,100*h];let j=i/(1-Math.abs(2*h-1));return[60*(f===c?((d-e)/i+6)%6:f===d?(e-c)/i+2:(c-d)/i+4),100*j,100*h]}(a),g=a=>Math.min(100,Math.max(0,a));return`hsl(${Math.round(d)} ${Math.round(g(e+c))}% ${Math.round(g(f+b))}%)`}function S(a){let b=P(a),c=Q[a.effort??""];return c?{color:R(b.color,c.dl,c.ds),soft:R(b.soft,Math.round(c.dl/3),Math.round(c.ds/2))}:b}function T(a){return a.effort?`Зусилля міркування: ${a.effort}`:void 0}function U(a){let b={codex:"Codex",claude:"Claude",shell:"Bash"}[a.engine]??a.engine,c=L[a.engine]??M;return{label:b,style:{backgroundColor:c.soft,color:c.color}}}function V(a,b){return Math.floor(b.smt/300)-Math.floor(a.smt/300)||a.file.path.localeCompare(b.file.path)}function W(a){return r(a)&&"running"!==a.proc}function X(a,b=Date.now()/1e3){return!!a.pendingQuestion||!!a.waitingInput||("stalled"===a.activity?!W(a)&&b-a.mtime<=7200:"recent"===a.activity&&("claude"===a.engine||"codex"===a.engine)&&q(a)&&!r(a))}function Y(a,b,c,d,f=Z,g=$){return(0,e.useMemo)(()=>{let e=function(a){let b=w(a),c=new Map;for(let d of a){let a=[...b.get(d.path)??[]],e=new Set,f=0;for(;a.length;){let c=a.pop();e.has(c.path)||(e.add(c.path),f+=1,a.push(...b.get(c.path)??[]))}c.set(d.path,f)}return c}(a),h=new Map;for(let a of b){let b=h.get(a.file);(!b||a.ts>b.ts)&&h.set(a.file,a)}let i=A(g),j=B(g),k=c.trim().toLowerCase(),l=a.filter(a=>!f.has(a.path)&&!j.has(a.path)&&(q(a)||"live"===a.activity||"stalled"===a.activity||"recent"===a.activity&&!t(a))).map(a=>{let b=u(a),c=m(a.title),f=d-a.mtime,g=i.get(a.path),j=a.pendingQuestion||a.waitingInput?"waiting":"live"===a.activity?"working":X(a,d)?"waiting":f<=86400?"recent":"older",k=function(a,b){if(a.pendingQuestion)return"plan"===a.pendingQuestion.kind?"чекає затвердження плану":"чекає відповіді на питання";if(a.waitingInput)return"чекає на відповідь у терміналі";if("live"===a.activity&&a.plan?.current)return`${a.plan.done}/${a.plan.total} \xb7 ${a.plan.current}`;let c=b.get(a.path);return c?`${c.label} \xb7 ${H(c.ts)}`:"live"===a.activity?"працює…":W(a)?"повернувся з результатом":"stalled"===a.activity?"перервано або чекає дозволу":X(a)?"закінчив хід — чекає відповіді":""}(a,h);return g&&(D.has(g.state)?j="waiting":("reviewing"===g.state||"relaying"===g.state||"spawning"===g.state)&&(j="working"),k=`флоу: ${C[g.state]}${g.stateDetail?` — ${g.stateDetail}`:""}`),{file:a,project:b,title:c,descendants:e.get(a.path)??0,smt:a.mtime,kind:j,statusLine:k}}).filter(a=>!k||`${a.title} ${a.project}`.toLowerCase().includes(k)),n=(a,b)=>b.smt-a.smt||a.file.path.localeCompare(b.file.path),o=l.filter(a=>"waiting"===a.kind).sort(n),p=l.filter(a=>"working"===a.kind).sort(n);return{waiting:o,working:p,recent:l.filter(a=>"recent"===a.kind).sort(V),older:l.filter(a=>"older"===a.kind).sort(V),livePreview:p.slice(0,3)}},[a,b,c,d,f,g])}let Z=new Set,$=[],_="llvSound";function aa(a){try{window.localStorage.setItem("llvArchivedProjects",JSON.stringify([...a]))}catch{}}let ab={files:[],flows:[]};function ac({files:a,archivedProjects:b,onSelectProject:c,onSelectFile:f}){let g=function(){let[a,b]=(0,e.useState)(3);return a}(),h=(0,e.useMemo)(()=>v(a),[a]),i=(0,e.useMemo)(()=>h.filter(a=>!b.has(a.project)),[h,b]),j=h.length-i.length,k=(0,e.useMemo)(()=>i.reduce((a,b)=>a+b.liveCount,0),[i]),l=i.filter(a=>a.liveCount>0).length,n=(0,e.useMemo)(()=>i.map(b=>{let c=z(a,b.project).flatMap(a=>a.columns.flatMap(a=>[a.file,...a.tasks])).filter(a=>"live"===a.activity),d=c.slice(0,4),e=a.filter(a=>u(a)===b.project).sort((a,b)=>b.mtime-a.mtime)[0];return{summary:b,liveBranches:d,moreLive:c.length-d.length,latest:e}}),[a,i]);return(0,d.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,d.jsxs)("div",{className:"flex h-10 shrink-0 items-center gap-2.5 border-b border-line bg-panel px-4",children:[(0,d.jsx)("h1",{className:"text-[13.5px] font-bold",children:"Огляд"}),(0,d.jsxs)("span",{className:"text-[11.5px] text-dim",children:[k?`${k} ${J(k,"гілка працює","гілки працюють","гілок працюють")} у ${l} ${J(l,"проєкті","проєктах","проєктах")}`:"зараз нічого не працює",j?` \xb7 ${j} в архіві`:""]})]}),(0,d.jsxs)("div",{className:"grid flex-1 auto-rows-min gap-2.5 overflow-y-auto p-3",style:{gridTemplateColumns:`repeat(${g}, minmax(0, 1fr))`},children:[n.map(({summary:a,liveBranches:b,moreLive:e,latest:g})=>(0,d.jsxs)("button",{className:"flex flex-col gap-1.5 rounded-[10px] border border-line bg-panel p-3 text-left shadow-card hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>c(a.project),children:[(0,d.jsxs)("span",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:`h-2 w-2 shrink-0 rounded-full ${a.liveCount?"animate-pulse bg-ok":"bg-[#d6d6dd]"}`}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[13px] font-bold",children:a.project}),a.liveCount?(0,d.jsx)("span",{className:"shrink-0 rounded-full bg-[#e5f6ea] px-1.5 py-0.5 text-[10.5px] font-bold text-ok",children:a.liveCount}):null,(0,d.jsx)("span",{className:"shrink-0 text-[11px] font-semibold text-dim",children:a.conversations})]}),b.length?(0,d.jsxs)("span",{className:"flex flex-col gap-1",children:[b.map(a=>{let b=U(a);return(0,d.jsxs)("span",{className:"flex cursor-pointer items-center gap-1.5 rounded-[8px] px-1 py-0.5 text-[11.5px] hover:bg-bg",role:"link",tabIndex:0,title:m(a.title),onClick:b=>{b.stopPropagation(),f(a)},onKeyDown:b=>{"Enter"===b.key&&(b.stopPropagation(),f(a))},children:[(0,d.jsx)("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${K(a.activity)}`}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 text-[9px] font-bold",style:b.style,children:b.label}),(0,d.jsx)("span",{className:"truncate font-semibold",children:m(a.title,70)})]},a.path)}),e>0?(0,d.jsxs)("span",{className:"px-1 text-[10.5px] font-semibold text-dim",children:["ще ",e," live"]}):null]}):(0,d.jsxs)("span",{className:"text-[11px] text-dim",children:["тихо \xb7 остання активність ",g?H(g.mtime):"—"]})]},a.project)),i.length?null:(0,d.jsx)("div",{className:"col-span-full mt-[20vh] text-center text-dim",children:"Логів поки нема"})]})]})}let ad=k("git-branch",[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]]),ae=k("corner-down-right",[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]),af=k("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),ag=k("archive-restore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]),ah=k("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),ai=k("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),aj=k("arrow-up-to-line",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]),ak=k("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]),al=k("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]),am=k("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),an=k("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),ao=k("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),ap=k("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),aq=k("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),ar=k("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),as=k("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]),at=k("message-circle",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]]),au=k("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]),av=k("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),aw=k("sparkle",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}]]),ax=k("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),ay=k("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),az=k("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),aA=k("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),aB=k("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),aC=k("binary",[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]]),aD=k("pencil-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),aE=k("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),aF=k("power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]),aG=k("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]),aH=k("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),aI={shell:an,tool:aA,"cmd-group":aB,codex:aq,claude:aw,image:ar,blob:aC,note:aD,citation:aE,message:as,shutdown:aF,plan:aG};function aJ({name:a,className:b}){let c=aI[a];return(0,d.jsx)(c,{className:b??"h-3.5 w-3.5","aria-hidden":!0})}let aK=k("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);var aL=c(74429);let aM="#0d9488",aN=new Map;function aO(){for(let a of document.querySelectorAll("[data-link-hover]"))a.removeAttribute("data-link-hover")}function aP(a,b,c,d){let e=Math.max(48,.45*Math.abs(c-a));return`M ${a} ${b} C ${a+e} ${b}, ${c-e} ${d}, ${c} ${d}`}function aQ({source:a,drop:b,onClose:c}){let f=(0,e.useRef)(null),[g,h]=(0,e.useState)(""),[i,j]=(0,e.useState)(!1),[k,n]=(0,e.useState)(null),o=b.file,p=U(o),q=Math.max(8,Math.min(b.to.x+14,window.innerWidth-340-8)),r=Math.max(8,Math.min(b.to.y+12,window.innerHeight-320)),s=async()=>{if(i||!g.trim())return;j(!0),n(null);let b=`Тобі передали контекст іншого агента — розмову \xab${m(a.title,80)}\xbb. Її транскрипт: ${a.path} — спочатку прочитай цей файл, щоб мати повний контекст, а тоді виконай прохання нижче.
3
+
4
+ ${g.trim()}`;try{let a=await fetch("/api/tmux",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...null!==o.pid?{pid:o.pid}:{},path:o.path,text:b})}),c=await a.json();if(!a.ok||!c.ok)return void n({kind:"err",text:c.error??"не вдалося надіслати"});n({kind:"ok",text:c.spawned?`агент прокинувся у tmux ${c.target??""}`:`надіслано у tmux ${c.target??""}`})}catch{n({kind:"err",text:"сервер недоступний"})}finally{j(!1)}};return(0,d.jsxs)("div",{ref:f,className:"pointer-events-auto fixed flex w-[340px] cursor-default flex-col gap-2.5 rounded-[12px] border border-line bg-panel p-3 shadow-[0_8px_28px_rgba(20,20,30,0.14)]",style:{left:q,top:r},children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)(aK,{className:"h-3.5 w-3.5 shrink-0",style:{color:aM},"aria-hidden":!0}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12px] font-bold",children:"звʼязати агентів"}),(0,d.jsx)("button",{type:"button","aria-label":"Закрити картку звʼязування",onClick:c,className:"inline-flex shrink-0 items-center rounded-[8px] border border-line bg-bg px-1.5 py-0.5 text-dim hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",children:(0,d.jsx)(l,{className:"h-3 w-3","aria-hidden":!0})})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 rounded-[8px] border border-line bg-bg px-2 py-2",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:"w-[64px] shrink-0 text-[10px] font-semibold text-dim",children:"кому"}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 py-0.5 text-[9.5px] font-bold",style:p.style,children:p.label}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[10.5px] font-semibold",title:m(o.title),children:m(o.title,60)})]}),(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:"w-[64px] shrink-0 text-[10px] font-semibold text-dim",children:"контекст"}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-ink",title:a.path,children:a.path})]})]}),(0,d.jsx)("p",{className:"text-[10.5px] text-dim",children:"Агент отримає шлях до цього транскрипта з пропозицією прочитати розмову. Додай, що саме в нього попросити:"}),(0,d.jsx)("textarea",{value:g,onChange:a=>h(a.target.value),rows:4,autoFocus:!0,placeholder:"що зробити з цим контекстом…","aria-label":"Прохання для звʼязаного агента",className:"resize-y rounded-[8px] border border-line bg-bg px-2 py-1.5 text-[12px] text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40"}),(0,d.jsx)("div",{className:"flex items-center",children:(0,d.jsx)("button",{type:"button",disabled:i||!g.trim(),onClick:()=>void s(),className:"ml-auto rounded-[8px] border px-3 py-1.5 text-[12px] font-bold text-white hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40",style:{backgroundColor:aM,borderColor:aM},children:i?"звʼязую…":"▶ Звʼязати"})}),i?(0,d.jsx)("span",{className:"text-[10.5px] text-dim",children:"якщо агент не запущений — резюмую його вікно (до хвилини)…"}):null,k?(0,d.jsx)("span",{className:`text-[11px] font-semibold ${"ok"===k.kind?"text-ok":"text-err"}`,children:k.text}):null]})}function aR({file:a,onDeleted:b}){let[c,f]=(0,e.useState)(!1),[g,h]=(0,e.useState)(!1),[i,j]=(0,e.useState)("");if("running"===a.proc)return null;let k=async()=>{h(!0),j("");try{let c=await fetch(`/api/log?path=${encodeURIComponent(a.path)}`,{method:"DELETE"}),d=await c.json();if(!c.ok||!d.ok)return void j(d.error??"не вдалося видалити");f(!1),b?.()}catch{j("сервер недоступний")}finally{h(!1)}};return c?(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-[10px] border border-err/30 bg-[#fff5f5] px-1.5 py-0.5 text-[11px]",children:[(0,d.jsx)("span",{className:"px-0.5 font-semibold text-err",children:"Видалити з диска?"}),(0,d.jsx)("button",{type:"button",className:"rounded-lg bg-err px-2 py-0.5 font-bold text-white disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-err/50",disabled:g,onClick:k,children:g?"…":"Так"}),(0,d.jsx)("button",{type:"button",className:"rounded-lg border border-line bg-panel px-2 py-0.5 font-semibold text-dim focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>f(!1),children:"Ні"})]}):(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1",children:[(0,d.jsx)("button",{type:"button",className:"inline-flex items-center rounded-[8px] border border-line bg-bg px-1.5 py-0.5 text-dim hover:border-err/40 hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":"Видалити розмову з диска",title:"Видалити розмову з диска",onClick:()=>f(!0),children:(0,d.jsx)(az,{className:"h-3 w-3","aria-hidden":!0})}),i?(0,d.jsx)("span",{className:"max-w-[160px] truncate text-[10.5px] font-semibold text-err",title:i,children:i}):null]})}function aS({className:a,style:b,enter:c="scale",children:f}){let g=(0,e.useRef)(null);return!function(a="scale"){(0,e.useRef)(new Map),(0,e.useRef)(new WeakMap),(0,e.useRef)(!0)}(c),(0,d.jsx)("div",{ref:g,className:a,style:b,children:f})}let aT=k("arrow-right-left",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]),aU=k("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);function aV({file:a}){return"running"===a.proc?(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-[#e5f6ea] px-2 py-0.5 text-[11px] font-bold text-ok",children:[(0,d.jsx)(av,{className:"h-3 w-3","aria-hidden":!0})," PID ",a.pid]}):"killed"===a.proc||"stalled"===a.activity?(0,d.jsx)("span",{className:"inline-flex items-center gap-1 rounded-full bg-[#f7e8e8] px-2 py-0.5 text-[11px] font-bold text-err",children:"перервано"}):"done"===a.proc?(0,d.jsx)("span",{className:"inline-flex items-center gap-1 rounded-full bg-chip px-2 py-0.5 text-[11px] font-bold text-dim",children:"завершено"}):null}function aW({file:a,compact:b=!1}){let[c,f]=(0,e.useState)(!1),[g,h]=(0,e.useState)(!1),[i,j]=(0,e.useState)(""),[k,l]=(0,e.useState)(!1),m=(0,d.jsx)(aV,{file:a}),n=async()=>{h(!0),j("");try{let b=await fetch("/api/proc",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:a.path,force:k})}),c=await b.json();if(!b.ok||!c.ok){j(c.error??"помилка зупинки"),l(!0);return}j(`надіслано ${k?"SIGKILL":"SIGTERM"} PID ${c.pid}`),f(!1)}catch{j("сервер недоступний"),l(!0)}finally{h(!1)}};return(0,d.jsxs)("span",{className:`inline-flex min-w-0 flex-wrap items-center gap-1.5 ${b?"text-[10.5px]":"text-xs"}`,children:[m,"running"===a.proc?c?(0,d.jsxs)("span",{className:"inline-flex max-w-full items-center gap-1 rounded-[10px] border border-err/30 bg-[#fff5f5] px-1.5 py-0.5",children:[b?null:(0,d.jsxs)("span",{className:"truncate px-1 text-[11px] font-semibold text-err",children:["Точно вбити PID ",a.pid,"?"]}),(0,d.jsx)("button",{className:"rounded-lg bg-err px-2 py-0.5 text-[11px] font-bold text-white disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-err/50",disabled:g,onClick:n,children:k?"SIGKILL":b?`Вбити ${a.pid}`:"Так, вбити"}),(0,d.jsx)("button",{className:"rounded-lg border border-line bg-panel px-2 py-0.5 text-[11px] font-semibold text-dim focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>f(!1),children:b?"Ні":"Скасувати"})]}):(0,d.jsx)("button",{className:"rounded-full border border-line bg-panel px-2 py-0.5 text-[11px] font-semibold text-dim hover:border-err/40 hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":`Зупинити процес PID ${a.pid}`,onClick:()=>f(!0),children:"Вбити"}):null,i?(0,d.jsx)("span",{className:"max-w-[220px] truncate text-[11px] font-semibold text-dim",children:i}):null]})}function aX({file:a,files:b,onSelect:c}){if("codex-jobs"===a.root){let e=b.find(b=>"codex-sessions"===b.root&&b.parent===a.path);return(0,d.jsxs)("div",{className:"mb-4 mt-1 rounded-[14px] border border-line bg-panel px-4 py-3 shadow-card",children:[(0,d.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:(0,d.jsx)(aV,{file:a})}),e?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"mb-2 whitespace-pre-line text-[13.5px] font-semibold",children:"Це короткий джоб-лог (лише службові події). Реальна робота Codex — у повній сесії:"}),(0,d.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-[10px] border border-line bg-bg px-3 py-1.5 text-[13px] font-semibold text-codex hover:bg-codex-soft",onClick:()=>c(e),children:[(0,d.jsx)(aq,{className:"h-3.5 w-3.5","aria-hidden":!0})," Відкрити сесію Codex (",(e.size/1024).toFixed(0)," kB","live"===e.activity?", працює":"stalled"===e.activity?", перервано":"recent"===e.activity?", закінчив":"",")"]})]}):(0,d.jsx)("div",{className:"text-[13.5px] text-dim",children:"Це короткий джоб-лог. Повна rollout-сесія Codex ще не з'явилась у списку"})]})}return"claude-tasks"!==a.root?null:(0,d.jsxs)("div",{className:"mb-4 mt-1 rounded-[14px] border border-line bg-panel px-4 py-3 shadow-card",children:[(0,d.jsx)("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:(0,d.jsx)(aV,{file:a})}),a.cmd?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"mb-1 text-[13.5px] font-semibold",children:a.cmdDesc||"Фонова команда"}),(0,d.jsxs)("code",{className:"block whitespace-pre-wrap break-words rounded-lg border border-line bg-[#fafafc] px-2.5 py-2 font-mono text-[12.5px]",children:["$ ",a.cmd]})]}):(0,d.jsx)("div",{className:"text-[13.5px] text-dim",children:"Команду, що запустила цю фонову задачу, не знайдено у транскриптах сесії"})]})}let aY=[{key:"claude",label:"Claude"},{key:"codex",label:"Codex"}];function aZ({file:a,paneRef:b}){let c=(0,e.useRef)(null),f=(0,e.useRef)({target:88,current:88,raf:0}),g=(0,e.useRef)(!1),h=(0,e.useRef)(null),i=(0,e.useRef)(null),[j,k]=(0,e.useState)(!1),[n,o]=(0,e.useState)({top:-18,maxH:480}),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)("codex"===a.engine?"codex":"claude"),[t,u]=(0,e.useState)(""),[v,w]=(0,e.useState)([]),[x,y]=(0,e.useState)(()=>`Прочитай розмову агента у файлі ${a.path} і продовж роботу звідти: `),[z,A]=(0,e.useState)(!1),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(!1),F=(0,e.useId)(),G=function(a,b){let[c,f]=(0,e.useState)(!1),[g,h]=(0,e.useState)(null),[i,j]=(0,e.useState)(null),k=(0,e.useRef)(null),l=(0,e.useRef)(!1),m=(0,e.useRef)(!1),n=(0,e.useRef)(null),o="link-arrow-"+(0,e.useId)().replace(/[^a-zA-Z0-9-]/g,"");return{onPillPointerDown:c=>{if("mouse"===c.pointerType&&0!==c.button||k.current)return;let d=c.currentTarget.getBoundingClientRect(),e=c=>{let d=k.current;if(!d)return;if(d.lastX=c.clientX,d.lastY=c.clientY,!d.active){if(7>Math.hypot(c.clientX-d.startX,c.clientY-d.startY))return;d.active=!0,l.current=!0,m.current=!0,document.body.style.cursor="crosshair",aO(),j(null),h({x:d.anchorX,y:d.anchorY}),f(!0),b?.()}n.current?.setAttribute("d",aP(d.anchorX,d.anchorY,c.clientX,c.clientY));let e=function(a,b,c){let d=document.elementFromPoint(a,b)?.closest("[data-link-path]"),e=d?.getAttribute("data-link-path");if(!d||!e||e===c)return null;let f=aN.get(e);return f&&f.el===d?f:null}(c.clientX,c.clientY,a.path);e?.el!==d.hover?.el&&(d.hover?.el.removeAttribute("data-link-hover"),e?.el.setAttribute("data-link-hover","1"),d.hover=e)},g=a=>{let b=k.current;k.current=null,b?.detach(),l.current=!1,document.body.style.cursor="",b?.active&&(f(!1),b.hover?j({file:b.hover.file,from:{x:b.anchorX,y:b.anchorY},to:{x:a.clientX,y:a.clientY}}):aO())};k.current={startX:c.clientX,startY:c.clientY,anchorX:d.right,anchorY:d.top+d.height/2,lastX:c.clientX,lastY:c.clientY,active:!1,hover:null,detach:()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g)}},window.addEventListener("pointermove",e),window.addEventListener("pointerup",g),window.addEventListener("pointercancel",g)},consumeClick:()=>{let a=m.current;return m.current=!1,a},draggingRef:l,overlay:c||i?(0,aL.createPortal)((0,d.jsxs)("div",{className:"pointer-events-none fixed inset-0 z-[95]",children:[(0,d.jsxs)("svg",{className:"block h-full w-full",children:[(0,d.jsx)("defs",{children:(0,d.jsx)("marker",{id:o,markerWidth:"9",markerHeight:"9",refX:"7",refY:"4.5",orient:"auto",children:(0,d.jsx)("path",{d:"M0,0 L8,4.5 L0,9 Z",fill:aM})})}),(0,d.jsx)("path",{ref:a=>{n.current=a;let b=k.current;a&&b?.active&&a.setAttribute("d",aP(b.anchorX,b.anchorY,b.lastX,b.lastY))},d:i?aP(i.from.x,i.from.y,i.to.x,i.to.y):void 0,fill:"none",stroke:aM,strokeWidth:2.5,strokeLinecap:"round",markerEnd:`url(#${o})`}),(0,d.jsx)("circle",{cx:i?i.from.x:g?.x??0,cy:i?i.from.y:g?.y??0,r:4,fill:aM})]}),i?(0,d.jsx)(aQ,{source:a,drop:i,onClose:()=>{aO(),j(null)}},i.file.path):null]}),document.body):null}}(a,()=>{h.current&&window.clearTimeout(h.current),h.current=null,g.current=!1,k(!1)}),{draggingRef:H}=G,I=a=>{g.current=a,k(a)},J=()=>{if(g.current)return;let a=b.current;if(a){let b=a.getBoundingClientRect().height,c=f.current.current;if(c>.55*b){let a=Math.min(c+18,b-8);o({bottom:c-a,maxH:a-8})}else{let a=Math.max(8,c-18);o({top:a-c,maxH:b-a-8})}}I(!0)},K=async()=>{if(!z&&t.trim()){A(!0),C(null);try{let b=await fetch("/api/spawn",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:r,cwd:t.trim(),prompt:x,src:a.path})}),c=await b.json();if(!b.ok||!c.ok)return void C({kind:"err",text:c.error??"не вдалося запустити"});C({kind:"ok",text:`запущено в tmux ${c.target??""} — з'явиться гілкою поруч із цією колонкою`})}catch{C({kind:"err",text:"сервер недоступний"})}finally{A(!1)}}},N=U(a);return(0,d.jsxs)("div",{ref:c,className:"pointer-events-none absolute left-1.5 top-0 z-40 h-0 w-0",style:{transform:"translate3d(0, 88px, 0)",willChange:"transform"},children:[(0,d.jsx)("button",{type:"button","aria-expanded":j,"aria-label":"Перекинути розмову іншому агенту або потягнути стрілку на його панель",title:"клік — перекинути новому агенту \xb7 потягни стрілку — звʼязати з наявним",onPointerDown:G.onPillPointerDown,onPointerEnter:()=>{p&&!g.current&&(h.current&&window.clearTimeout(h.current),h.current=window.setTimeout(J,130))},onPointerLeave:()=>{h.current&&window.clearTimeout(h.current),h.current=null},onClick:()=>{G.consumeClick()||(h.current&&window.clearTimeout(h.current),g.current?I(!1):J())},className:`pointer-events-auto absolute left-0 top-0 flex h-9 w-6 -translate-y-1/2 touch-none items-center justify-center rounded-full border bg-panel shadow-card transition-[opacity,border-color,color] duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 ${j?"border-accent/50 text-accent opacity-100":"border-line text-dim opacity-60 hover:border-accent/45 hover:text-accent hover:opacity-100"}`,children:(0,d.jsx)(aT,{className:"h-3.5 w-3.5","aria-hidden":!0})}),j?(0,d.jsxs)("div",{className:"pointer-events-auto absolute left-8 z-50 flex w-[340px] cursor-default flex-col gap-2.5 overflow-y-auto rounded-[12px] border border-line bg-panel p-3 shadow-[0_8px_28px_rgba(20,20,30,0.14)] [&>*]:shrink-0",style:{top:n.top,bottom:n.bottom,maxHeight:n.maxH},children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)(aT,{className:"h-3.5 w-3.5 shrink-0 text-accent","aria-hidden":!0}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12px] font-bold",children:"перекинути розмову іншому агенту"}),(0,d.jsx)("button",{type:"button","aria-label":"Закрити картку передачі",onClick:()=>I(!1),className:"inline-flex shrink-0 items-center rounded-[8px] border border-line bg-bg px-1.5 py-0.5 text-dim hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",children:(0,d.jsx)(l,{className:"h-3 w-3","aria-hidden":!0})})]}),(0,d.jsx)("div",{className:"truncate text-[10.5px] font-semibold text-dim",title:m(a.title),children:m(a.title,70)}),(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 rounded-[8px] border border-line bg-bg px-2 py-2",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:"w-[64px] shrink-0 text-[10px] font-semibold text-dim",children:"агент"}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 py-0.5 text-[9.5px] font-bold",style:N.style,children:N.label}),a.model?(0,d.jsx)("span",{className:"min-w-0 truncate rounded-full px-1.5 py-0.5 font-mono text-[9px] font-semibold",style:{backgroundColor:P(a).soft,color:P(a).color},children:a.model}):null,(0,d.jsx)(aV,{file:a})]}),(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:"w-[64px] shrink-0 text-[10px] font-semibold text-dim",children:"транскрипт"}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-ink",title:a.path,children:a.path}),(0,d.jsx)("button",{type:"button","aria-label":"Скопіювати шлях транскрипта",onClick:()=>{navigator.clipboard?.writeText(a.path).then(()=>{E(!0),i.current&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>E(!1),1500)}).catch(()=>{})},className:`inline-flex shrink-0 items-center rounded-[8px] border border-line bg-panel px-1.5 py-0.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 ${D?"text-ok":"text-dim hover:text-accent"}`,children:D?(0,d.jsx)(am,{className:"h-3 w-3","aria-hidden":!0}):(0,d.jsx)(aU,{className:"h-3 w-3","aria-hidden":!0})})]}),a.kind?(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:"w-[64px] shrink-0 text-[10px] font-semibold text-dim",children:"тип"}),(0,d.jsx)("span",{className:"min-w-0 truncate text-[10.5px] font-semibold text-ink",children:a.kind})]}):null]}),(0,d.jsx)("div",{className:"flex items-center gap-1.5",role:"radiogroup","aria-label":"Кому передати розмову",children:aY.map(({key:a,label:b})=>{let c;return(0,d.jsx)("button",{type:"button",role:"radio","aria-checked":r===a,onClick:()=>s(a),style:r===a?{backgroundColor:(c=L[a]??M).soft,color:c.color,borderColor:c.color}:void 0,className:`flex-1 rounded-[8px] border px-2 py-1.5 text-[12px] font-bold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 ${r===a?"":"border-line bg-bg text-dim hover:text-ink"}`,children:b},a)})}),(0,d.jsxs)("label",{className:"flex flex-col gap-1 text-[10.5px] font-semibold text-dim",children:["директорія (успадкована)",(0,d.jsx)("input",{value:t,onChange:a=>u(a.target.value),list:F,placeholder:"/home/…/Projects/…","aria-label":"Робоча директорія нового агента",className:"rounded-[8px] border border-line bg-bg px-2 py-1.5 font-mono text-[11.5px] font-normal text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40"}),(0,d.jsx)("datalist",{id:F,children:v.map(a=>(0,d.jsx)("option",{value:a},a))})]}),(0,d.jsxs)("label",{className:"flex flex-col gap-1 text-[10.5px] font-semibold text-dim",children:["промпт для нового агента",(0,d.jsx)("textarea",{value:x,onChange:a=>y(a.target.value),rows:4,placeholder:"що зробити далі…","aria-label":"Промпт для нового агента",className:"resize-y rounded-[8px] border border-line bg-bg px-2 py-1.5 text-[12px] font-normal text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40"})]}),(0,d.jsx)("div",{className:"flex items-center",children:(0,d.jsx)("button",{type:"button",disabled:z||!t.trim(),onClick:()=>void K(),className:"ml-auto rounded-[8px] border border-accent bg-accent px-3 py-1.5 text-[12px] font-bold text-white hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40",children:z?"перекидаю…":"▶ Перекинути"})}),z?(0,d.jsx)("span",{className:"text-[10.5px] text-dim",children:"чекаю, поки CLI підніметься (до хвилини)…"}):null,B?(0,d.jsx)("span",{className:`text-[11px] font-semibold ${"ok"===B.kind?"text-ok":"text-err"}`,children:B.text}):null]}):null,G.overlay]})}let a$=k("arrow-down-to-line",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]),a_=/^\s*(?:VERDICT:\s*)?(REQUEST_CHANGES|APPROVE|COMMENT)\b/m,a0=/^\s*(\d+)[.)]\s+(.*)$/,a1=/(?:\[(P[0-3])\]|\b(Critical|High|Medium|Low|Info|P[0-3])\b)/i,a2=/((?:\.{1,2}\/|\/|~\/)?[\w@.+-][\w@.+\-/]*\.(?:tsx?|jsx?|mjs|cjs|mts|cts|py|go|rs|md|json|ya?ml|toml|css|scss|html|sql|sh|env|ftl|txt))(?::(\d+))?/i,a3=/\[([^\]]+)\]\(([^)\s]+)\)/,a4=/([\w.-]*(?:api[_-]?key|access[_-]?token|refresh[_-]?token|authorization|bearer|secret|password|passwd|pwd|token))\b(\s*[:=]\s*)(["']?)[^\s"',}]+/gi;function a5(a){return a.replace(a4,(a,b,c,d)=>`${b}${c}${d}[redacted]`)}function a6(a){let b=a5(a);return{raw:b.slice(0,24e3),truncated:b.length>24e3}}function a7(a){let b=a.match(/^(.*?):(\d+(?:-\d+)?)$/);return b?{target:b[1]??a,line:b[2]}:{target:a}}function a8(a,b){let c=a.match(a_)?.[1];if(!c)return null;let d=[],e=[],f=null,g=()=>{let a,b,c,e=f?.trim();e&&d.push((a=function(a){let b=a.toUpperCase();if("P0"===b||"P1"===b||"P2"===b||"P3"===b)return b;let c=a.toLowerCase();return"critical"===c?"Critical":"high"===c?"High":"medium"===c?"Medium":"low"===c?"Low":"Info"}(e.match(a1)?.[1]??e.match(a1)?.[2]??"Info"),b=function(a){let b=a.match(a3);if(b){let a=a7((b[2]??"").replace(/^file:\/\//,"")),c=a.line?Number(a.line.split("-",1)[0]):void 0;return{file:a.target||b[1],line:Number.isFinite(c)?c:void 0}}let c=a.match(a2);if(!c)return{};let d=c[2]?Number(c[2]):void 0;return{file:c[1],line:Number.isFinite(d)?d:void 0}}(e),c=function(a){let b=a,c=b.match(a1);if(c&&void 0!==c.index){let a=b.slice(c.index+c[0].length).replace(/^[\s.:–—-]+/,"");a&&(b=a)}return b.replace(a3,"$1").replace(/`([^`]*)`/g,"$1").replace(/\s+/g," ").trim().slice(0,200)}(e)||e.slice(0,200)||"Finding",{severity:a,file:b.file,line:b.line,title:c,body:a6(e).raw})),f=null};for(let b of a.split("\n")){let a=b.trimEnd(),c=a.match(a0);if(c){g(),f=c[2]??"";continue}let h=a.trim();if(null!==f){h?f=`${f}
5
+ ${h}`:g();continue}!(!h||a_.test(a)||/^(findings?|summary|open questions?|tests?|residual risk)\s*:?\s*$/i.test(h))&&0===d.length&&e.length<3&&h.length<=240&&e.push(h)}g();let h=d.filter(a=>a1.test(a.body)).length;return c||/^findings?\s*:?$/im.test(a)||h>=2||h>=1&&/\b(review|request_changes|approve|comment)\b/i.test(a)?{kind:"review",ts:b,verdict:c,findings:d,summary:e,raw:a6(a).raw}:null}let a9=k("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),ba=k("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);function bb({src:a,alt:b,caption:c,onClose:f}){let[g,h]=(0,e.useState)(1),[i,j]=(0,e.useState)(0),[k,m]=(0,e.useState)(0),[n,o]=(0,e.useState)(!1),p=(0,e.useRef)(null),q=(a,b=0,c=0)=>{let d=Math.min(8,Math.max(.25,g*a)),e=d/g;h(d),j(b-(b-i)*e),m(c-(c-k)*e)},r=()=>{h(1),j(0),m(0)};return(0,aL.createPortal)((0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/85 backdrop-blur-sm",role:"dialog","aria-modal":"true","aria-label":b,onClick:f,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2.5",onClick:a=>a.stopPropagation(),children:[(0,d.jsx)("span",{className:"min-w-0 truncate text-[12.5px] font-semibold text-white/85",children:c??b}),(0,d.jsxs)("span",{className:"ml-auto flex items-center gap-1.5",children:[(0,d.jsx)("button",{className:"inline-flex items-center rounded-lg border border-white/25 bg-white/10 px-2.5 py-1 text-white hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60","aria-label":"Зменшити",onClick:()=>q(1/1.4),children:(0,d.jsx)(a9,{className:"h-4 w-4","aria-hidden":!0})}),(0,d.jsxs)("button",{className:"rounded-lg border border-white/25 bg-white/10 px-2 py-1 text-[11.5px] font-semibold text-white hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60","aria-label":"Скинути масштаб",onClick:r,children:[Math.round(100*g),"%"]}),(0,d.jsx)("button",{className:"inline-flex items-center rounded-lg border border-white/25 bg-white/10 px-2.5 py-1 text-white hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60","aria-label":"Збільшити",onClick:()=>q(1.4),children:(0,d.jsx)(ba,{className:"h-4 w-4","aria-hidden":!0})}),(0,d.jsx)("button",{className:"ml-1 inline-flex items-center rounded-lg border border-white/25 bg-white/10 px-2.5 py-1 text-white hover:bg-white/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/60","aria-label":"Закрити",onClick:f,children:(0,d.jsx)(l,{className:"h-4 w-4","aria-hidden":!0})})]})]}),(0,d.jsx)("div",{className:"min-h-0 flex-1 touch-none overflow-hidden",onClick:a=>a.stopPropagation(),onWheel:a=>{let b=a.currentTarget.getBoundingClientRect(),c=a.clientX-b.left-b.width/2,d=a.clientY-b.top-b.height/2;q(a.deltaY<0?1.18:1/1.18,c,d)},onPointerDown:a=>{a.currentTarget.setPointerCapture(a.pointerId),p.current={x:a.clientX,y:a.clientY,tx:i,ty:k},o(!0)},onPointerMove:a=>{p.current&&(j(p.current.tx+(a.clientX-p.current.x)),m(p.current.ty+(a.clientY-p.current.y)))},onPointerUp:()=>{p.current=null,o(!1)},onPointerCancel:()=>{p.current=null,o(!1)},onDoubleClick:()=>1===g?q(2):r(),children:(0,d.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,d.jsx)("img",{src:a,alt:b,draggable:!1,className:`max-h-full max-w-full select-none ${n?"":"transition-transform duration-75"} ${g>1?"cursor-grab active:cursor-grabbing":"cursor-zoom-in"}`,style:{transform:`translate(${i}px, ${k}px) scale(${g})`}})})})]}),document.body)}function bc({name:a,path:b}){let[c,f]=(0,e.useState)("thumb"),[g,h]=(0,e.useState)(null),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),o=`/api/inbox?name=${encodeURIComponent(a)}`,p=async()=>{l(!0),n("");try{let a=await fetch(o,{method:"DELETE"}),b=await a.json();if(!a.ok||!b.ok)return void n(b.error??"не вдалося видалити");h("deleted")}catch{n("сервер недоступний")}finally{l(!1),j(!1)}};return g?(0,d.jsx)("div",{className:"my-2 flex justify-end",children:(0,d.jsxs)("span",{className:"inline-flex max-w-[75%] items-center gap-1.5 rounded-full border border-line bg-chip px-2.5 py-1 text-[11.5px] font-semibold text-dim",title:b,children:[(0,d.jsx)(aJ,{name:"image",className:"h-3.5 w-3.5"}),(0,d.jsx)("span",{className:"truncate",children:a}),(0,d.jsxs)("span",{className:"shrink-0",children:["\xb7 ","deleted"===g?"видалено з диска":"файла вже немає на диску"]})]})}):"chip"===c?(0,d.jsx)("div",{className:"my-2 flex justify-end",children:(0,d.jsxs)("button",{type:"button",onClick:()=>f("thumb"),className:"inline-flex max-w-[75%] items-center gap-2 rounded-[14px] border border-line bg-panel px-3.5 py-2 text-[13px] shadow-card",title:b,children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(aJ,{name:"image",className:"h-4 w-4"})}),(0,d.jsx)("span",{className:"truncate font-mono text-[12px]",children:a}),(0,d.jsx)("span",{className:"shrink-0 text-[12px] font-semibold text-accent",children:"показати"})]})}):(0,d.jsxs)("div",{className:"my-2 flex justify-end",children:[(0,d.jsxs)("div",{className:"max-w-[75%]",children:[(0,d.jsx)("img",{src:o,alt:`вкладена картинка ${a}`,onClick:()=>f("full"),onError:()=>h("missing"),className:"ml-auto block max-h-[240px] cursor-zoom-in rounded-[14px] border border-line"}),(0,d.jsxs)("div",{className:"mt-1 flex flex-wrap items-center justify-end gap-1.5 text-[11px]",children:[(0,d.jsx)("span",{className:"min-w-0 truncate font-mono text-dim",title:b,children:a}),(0,d.jsx)("button",{type:"button",onClick:()=>f("chip"),className:"shrink-0 text-dim hover:text-ink",children:"згорнути"}),i?(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-[10px] border border-err/30 bg-[#fff5f5] px-1.5 py-0.5",children:[(0,d.jsx)("span",{className:"px-1 font-semibold text-err",children:"Видалити файл з диска?"}),(0,d.jsx)("button",{type:"button",className:"rounded-lg bg-err px-2 py-0.5 font-bold text-white disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-err/50",disabled:k,onClick:p,children:k?"видаляю…":"Так, видалити"}),(0,d.jsx)("button",{type:"button",className:"rounded-lg border border-line bg-panel px-2 py-0.5 font-semibold text-dim focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>j(!1),children:"Скасувати"})]}):(0,d.jsxs)("button",{type:"button",onClick:()=>j(!0),"aria-label":`Видалити ${a} з диска`,className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-line bg-panel px-2 py-0.5 font-semibold text-dim hover:border-err/40 hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",children:[(0,d.jsx)(az,{className:"h-3 w-3","aria-hidden":!0})," видалити з диска"]}),m?(0,d.jsx)("span",{className:"shrink-0 font-semibold text-err",children:m}):null]})]}),"full"===c?(0,d.jsx)(bb,{src:o,alt:`вкладена картинка ${a}`,caption:b,onClose:()=>f("thumb")}):null]})}let bd=/<oai-mem-citation>\s*<citation_entries>([\s\S]*?)<\/citation_entries>\s*<rollout_ids>([\s\S]*?)<\/rollout_ids>\s*<\/oai-mem-citation>/g,be=/(?:\/\.codex\/sessions\/|\/\.claude\/projects\/|\/\.claude\/plugins\/data\/codex-openai-codex\/state\/|^\/tmp\/claude-\d+\/)/;function bf(a){return"number"==typeof a&&Number.isFinite(a)?a:void 0}let bg=/<(teammate-message|agent-message)\b([^>]*)>([\s\S]*?)<\/\1>/g,bh=/\S*\/\.claude\/viewer-inbox\/([A-Za-z0-9._-]+\.(?:png|jpe?g|gif|webp))/gi;function bi(a){if(!a.includes("/.claude/viewer-inbox/"))return{cleaned:a,images:[]};let b=[],c=new Set,d=[];for(let e of a.split("\n"))e.replace(bh,(a,d)=>(c.has(a)||(c.add(a),b.push({name:d,path:a})),"")).trim()&&d.push(e);return{cleaned:d.join("\n").trim(),images:b}}let bj=/^\s*(?:<[a-zA-Z][\w:-]*|Caveat: The messages below|\[Request interrupted|This came from another Claude session)/;function bk(a){let b=a.match(/^\s*<([a-zA-Z][\w:-]*)/)?.[1];return b||(/^\s*Caveat:/.test(a)?"caveat":"системне")}function bl(a,b){return a.match(RegExp(`${b}="([^"]*)"`))?.[1]??""}function bm(a){return"string"==typeof a?a:""}function bn(a){return a&&"object"==typeof a&&!Array.isArray(a)?a:{}}function bo(a){return Array.isArray(a)?a.filter(a=>a&&"object"==typeof a&&!Array.isArray(a)):[]}let bp=/(`[^`]+`|\*\*[^*]+\*\*|\[[^\]]+\]\([^)\s]+\)|https?:\/\/[^\s<>"')\]]+)/g;function bq({href:a,label:b}){return(0,d.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",title:a,className:"break-all text-accent underline decoration-accent/40 underline-offset-2 hover:decoration-accent",children:b})}function br(a){return a.split(bp).map((a,b)=>{if(!a)return null;if(a.startsWith("`")&&a.endsWith("`"))return(0,d.jsx)("span",{className:"rounded-md bg-chip px-1.5 py-0.5 font-mono",children:a.slice(1,-1)},b);if(a.startsWith("**")&&a.endsWith("**"))return(0,d.jsx)("b",{children:a.slice(2,-2)},b);let c=a.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);if(c){let a=c[2].replace(/\\([()])/g,"$1");return/^https?:\/\//.test(a)?(0,d.jsx)(bq,{href:a,label:c[1]},b):(0,d.jsx)("span",{className:"rounded-md bg-chip px-1.5 py-0.5 font-mono",children:c[1]},b)}if(/^https?:\/\//.test(a)){let c=a.replace(/[.,;:!?…»)]+$/,""),e=a.slice(c.length),f=c.length>72?c.slice(0,69)+"…":c;return(0,d.jsxs)("span",{children:[(0,d.jsx)(bq,{href:c,label:f}),e]},b)}return a})}let bs=/^\s*\|.*\|\s*$/,bt=/^:?-{1,}:?$/;function bu({rows:a}){let b=a.map(a=>a.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(a=>a.trim())),c=b.length>1&&b[1].every(a=>bt.test(a)),e=c?b[0]:null,f=c?b.slice(2):b;return(0,d.jsx)("div",{className:"my-1.5 max-w-full overflow-x-auto",children:(0,d.jsxs)("table",{className:"border-collapse text-[12.5px]",children:[e?(0,d.jsx)("thead",{children:(0,d.jsx)("tr",{children:e.map((a,b)=>(0,d.jsx)("th",{className:"border border-line bg-chip px-2.5 py-1 text-left font-semibold",children:br(a)},b))})}):null,(0,d.jsx)("tbody",{children:f.map((a,b)=>(0,d.jsx)("tr",{children:a.map((a,b)=>(0,d.jsx)("td",{className:"border border-line px-2.5 py-1 align-top",children:br(a)},b))},b))})]})})}function bv(a){let b=a.split("\n"),c=[],f=0;for(;f<b.length;){if(/^\s*```/.test(b[f])){let a=f;for(f++;f<b.length&&!/^\s*```\s*$/.test(b[f]);)f++;let e=b.slice(a+1,f).join("\n");f<b.length&&f++,"\n"===c[c.length-1]&&c.pop(),c.push((0,d.jsx)("pre",{className:"my-1.5 max-w-full overflow-x-auto rounded-[10px] border border-line bg-bg px-3 py-2 font-mono text-[11.5px]",children:e},`c${a}`));continue}if(bs.test(b[f])){let a=f;for(;f<b.length&&bs.test(b[f]);)f++;"\n"===c[c.length-1]&&c.pop(),c.push((0,d.jsx)(bu,{rows:b.slice(a,f)},`t${a}`));continue}let a=b[f],g=a.match(/^#{1,6}\s+(.*)$/),h=a.match(/^>\s?(.*)$/);g?c.push((0,d.jsx)("span",{className:"text-[14px] font-bold",children:br(g[1])},f)):h?c.push((0,d.jsx)("span",{className:"border-l-2 border-line pl-2 text-dim",children:br(h[1])},f)):c.push((0,d.jsx)(e.Fragment,{children:br(a)},f)),++f<b.length&&c.push("\n")}return c}function bw(a,b,c){let d=b.split("\n").map(a=>a.trim()).filter(Boolean).map(a=>{let b=a.match(/\|note=\[(.*)\]$/)?.[1],c=a7(a.replace(/\|note=\[.*\]$/,""));return{target:c.target,line:c.line,note:b,raw:a}}),e=c.split(/\s+/).map(a=>a.trim()).filter(a=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(a)),f=a6(a);return{kind:"mem-citation",entries:d,rolloutIds:e,raw:f.raw,truncated:f.truncated}}function bx(a,b,c){if(!a)return null;let d=b.match(/exited with code (\d+)/)?.[1],e=b.replace(/^Chunk ID:[^\n]*\n/,"").replace(/Wall time:[^\n]*\n/,"").replace(/Original token count:[^\n]*\n?/,"").trim(),f=!0===c||void 0!==d&&"0"!==d;return a.status=f?"err":"ok",a.label=f?d&&"0"!==d?"exit "+d:"помилка":"ok",a.open||=f,e&&(a.output=(a.output+"\n"+a5(e)).trim().slice(-(f?6e4:12e3))),a}function by({media:a,data:b,w:c,h:f,bytes:g}){let[h,i]=(0,e.useState)("thumb"),j=Math.round((g??3*b.length/4)/1024),k=c&&f?`${c}\xd7${f}`:"зображення";if("chip"===h)return(0,d.jsxs)("button",{type:"button",onClick:()=>i("thumb"),className:"my-2 ml-9 flex items-center gap-2 rounded-[14px] border border-line bg-panel px-3.5 py-2 text-[13px] shadow-card",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(aJ,{name:"image",className:"h-4 w-4"})}),(0,d.jsx)("span",{className:"font-semibold",children:k}),(0,d.jsxs)("span",{className:"text-dim",children:["\xb7 ",j," КБ"]}),(0,d.jsx)("span",{className:"ml-1 text-[12px] font-semibold text-accent",children:"показати"})]});let l=`data:${a};base64,${b}`;return(0,d.jsxs)("div",{className:"my-2 ml-9",children:[(0,d.jsx)("img",{src:l,alt:`зображення ${k}`,onClick:()=>i("full"),className:"max-h-[240px] cursor-zoom-in rounded-[14px] border border-line"}),(0,d.jsx)("button",{type:"button",onClick:()=>i("chip"),className:"mt-1 block text-[12px] text-dim",children:"згорнути"}),"full"===h?(0,d.jsx)(bb,{src:l,alt:`зображення ${k}`,caption:`${k} \xb7 ${j} КБ`,onClose:()=>i("thumb")}):null]})}function bz({label:a,text:b}){let c=b.length>=2048?`${(b.length/1024).toFixed(1)} кБ`:`${b.length} симв.`;return(0,d.jsxs)("details",{className:"group my-1.5 ml-9",children:[(0,d.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-[11px] font-semibold text-dim hover:text-ink [&::-webkit-details-marker]:hidden",children:[(0,d.jsx)("span",{className:"flex h-4.5 w-4.5 items-center justify-center rounded-md bg-chip",children:(0,d.jsx)(aJ,{name:"cmd-group",className:"h-3 w-3"})}),(0,d.jsx)("span",{className:"rounded-full bg-chip px-1.5 py-0.5 font-mono text-[9.5px]",children:a}),(0,d.jsxs)("span",{children:["системне \xb7 ",c]}),(0,d.jsx)("span",{className:"text-accent group-open:hidden",children:"показати"}),(0,d.jsx)("span",{className:"hidden text-dim group-open:inline",children:"згорнути"})]}),(0,d.jsx)("pre",{className:"mt-1 max-h-[320px] overflow-auto whitespace-pre-wrap break-words rounded-[10px] border border-line bg-bg px-3 py-2 font-mono text-[11px] text-[#555]",children:b})]})}function bA({bytes:a,text:b}){let[c,f]=(0,e.useState)(!1),g=Math.round(a/1024);return c?(0,d.jsxs)("div",{className:"my-2 ml-9 overflow-hidden rounded-[14px] border border-line bg-panel shadow-card",children:[(0,d.jsx)("pre",{className:"max-h-[340px] overflow-auto whitespace-pre-wrap break-all bg-[#fafafc] px-3.5 py-2.5 font-mono text-[11.5px]",children:b}),(0,d.jsx)("button",{type:"button",onClick:()=>f(!1),className:"block w-full border-t border-line px-3.5 py-1.5 text-[12px] text-dim",children:"згорнути"})]}):(0,d.jsxs)("button",{type:"button",onClick:()=>f(!0),className:"my-2 ml-9 flex items-center gap-2 rounded-[14px] border border-line bg-panel px-3.5 py-2 text-[13px] shadow-card",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(aJ,{name:"blob",className:"h-4 w-4"})}),(0,d.jsxs)("span",{className:"font-semibold",children:["даних ",g," КБ"]}),(0,d.jsx)("span",{className:"ml-1 text-[12px] font-semibold text-accent",children:"показати"})]})}function bB({verdict:a}){return(0,d.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,d.jsx)("REQUEST_CHANGES"===a?ak:"APPROVE"===a?ap:at,{className:"h-3.5 w-3.5","aria-hidden":!0}),"REQUEST_CHANGES"===a?"REQUEST_CHANGES":"APPROVE"===a?"APPROVE":"COMMENT"]})}function bC({status:a,className:b}){let c=b??"h-3.5 w-3.5";return"ok"===a?(0,d.jsx)(am,{className:c,"aria-hidden":!0}):"err"===a?(0,d.jsx)(l,{className:c,"aria-hidden":!0}):(0,d.jsx)(aH,{className:`${c} animate-spin`,"aria-hidden":!0})}function bD({file:a,line:b}){let c=b?`${a}:${b}`:a,e="inline-block min-w-0 max-w-full truncate rounded-md bg-chip px-1.5 py-0.5 align-bottom font-mono text-[11.5px]";return be.test(a)?(0,d.jsx)("a",{href:`#f=${encodeURIComponent(a)}`,className:`${e} text-accent underline decoration-dotted`,title:c,children:c}):(0,d.jsx)("code",{className:e,title:c,children:c})}function bE({item:a}){let b=Object.entries(a.byTool).map(([a,b])=>`${a} \xd7${b}`).join(" \xb7 "),c=I(a.t0),e=I(a.t1),f=c&&e&&c!==e?`${c}–${e}`:c||e;return(0,d.jsxs)("details",{className:`my-2.5 ml-9 overflow-hidden rounded-[14px] border shadow-card ${a.hasErr?"border-err/35 bg-[#fff4f4]":"border-line bg-panel"}`,open:a.hasErr,children:[(0,d.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-2.5 px-3.5 py-2",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(aJ,{name:"cmd-group",className:"h-4 w-4"})}),(0,d.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate text-[12.5px]",children:[a.calls.length," ",J(a.calls.length,"команда","команди","команд"),b?" \xb7 "+b:""," \xb7",(0,d.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-ok",children:[(0,d.jsx)(am,{className:"h-3.5 w-3.5","aria-hidden":!0}),a.okCount]}),a.errCount?(0,d.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-err",children:[(0,d.jsx)(l,{className:"h-3.5 w-3.5","aria-hidden":!0}),a.errCount]}):null]}),f?(0,d.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-dim",children:f}):null]}),(0,d.jsx)("div",{className:"space-y-1 border-t border-line bg-[#fafafc] px-2 py-1.5",children:a.calls.map((b,c)=>{let e="ok"===b.status?"text-ok":"err"===b.status?"text-err":"text-dim";return(0,d.jsxs)("details",{className:"overflow-hidden rounded-[10px] border border-line bg-panel",open:b.open,children:[(0,d.jsxs)("summary",{className:"flex h-6 cursor-pointer list-none items-center gap-2 px-2.5 text-[11.5px]",children:[(0,d.jsx)("span",{className:"flex h-4.5 w-4.5 shrink-0 items-center justify-center rounded-md bg-chip",children:(0,d.jsx)(aJ,{name:b.icon,className:"h-3 w-3"})}),(0,d.jsx)("code",{className:"min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap rounded-md bg-chip px-1.5 py-0.5 font-mono text-[11px]",children:b.display}),(0,d.jsxs)("span",{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-[10.5px] font-semibold ${e}`,children:[(0,d.jsx)(bC,{status:b.status,className:"h-3 w-3"}),b.label]})]}),(0,d.jsx)("pre",{className:"max-h-[280px] overflow-auto whitespace-pre-wrap border-t border-line bg-[#fafafc] px-3 py-2 font-mono text-[11.5px]",children:"$ "+b.cmd+(b.output?"\n"+b.output:"")})]},a.ids[c])})})]})}function bF({item:a}){var b;let c=a.findings.length,e=a.findings.slice(0,12);return(0,d.jsxs)("div",{className:"my-3.5 ml-9 overflow-hidden rounded-[14px] border border-codex/20 bg-panel shadow-card",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-line px-3.5 py-2.5",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-lg bg-codex-soft text-codex",children:(0,d.jsx)(aq,{className:"h-4 w-4","aria-hidden":!0})}),(0,d.jsx)("span",{className:"text-[13.5px] font-bold",children:"Codex review"}),a.verdict?(0,d.jsx)("span",{className:`rounded-full border px-2.5 py-0.5 text-[11.5px] font-extrabold ${"REQUEST_CHANGES"===(b=a.verdict)?"bg-[#fff0f0] text-err border-err/25":"APPROVE"===b?"bg-[#eefaf1] text-ok border-ok/25":"bg-chip text-[#555] border-line"}`,children:(0,d.jsx)(bB,{verdict:a.verdict})}):null,(0,d.jsx)("span",{className:"text-[11px] text-dim",children:c?`${c} finding${1===c?"":"s"}`:"без findings"}),I(a.ts)?(0,d.jsx)("span",{className:"ml-auto text-[11px] text-dim",children:I(a.ts)}):null]}),(0,d.jsxs)("div",{className:"px-3.5 py-2.5",children:[a.summary.length?(0,d.jsx)("div",{className:"mb-2 whitespace-pre-wrap break-words text-[13px] text-[#444]",children:bv(a.summary.join("\n"))}):null,e.length?(0,d.jsx)("div",{className:"space-y-2",children:e.map((a,b)=>{var c;return(0,d.jsxs)("div",{className:"rounded-[10px] border border-line bg-[#fbfbfd] px-3 py-2",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("span",{className:`rounded-full border px-2 py-0.5 text-[10.5px] font-extrabold ${"Critical"===(c=a.severity)||"High"===c||"P0"===c||"P1"===c?"border-err/30 bg-[#fff4f4] text-err":"Medium"===c||"P2"===c?"border-[#d89b21]/35 bg-[#fff9ea] text-[#9a6500]":"Low"===c||"P3"===c?"border-line bg-chip text-[#555]":"border-line bg-panel text-dim"}`,children:a.severity}),a.file?(0,d.jsx)(bD,{file:a.file,line:a.line}):null]}),(0,d.jsx)("div",{className:"mt-1.5 whitespace-pre-wrap break-words text-[13px]",children:br(a.title)}),a.body&&a.body!==a.title?(0,d.jsxs)("details",{className:"mt-1 text-[12px] text-dim",children:[(0,d.jsx)("summary",{className:"cursor-pointer list-none font-semibold text-accent",children:"details"}),(0,d.jsx)("div",{className:"mt-1 whitespace-pre-wrap break-words",children:bv(a.body)})]}):null]},b)})}):null,a.findings.length>e.length?(0,d.jsxs)("div",{className:"mt-2 text-[12px] text-dim",children:["ще ",a.findings.length-e.length," findings у raw"]}):null,(0,d.jsxs)("details",{className:"mt-2 rounded-[10px] border border-line bg-[#fafafc] text-[12px]",children:[(0,d.jsx)("summary",{className:"cursor-pointer list-none px-3 py-1.5 font-semibold text-dim",children:"raw review text"}),(0,d.jsx)("pre",{className:"max-h-[320px] overflow-auto whitespace-pre-wrap border-t border-line px-3 py-2 font-mono text-[11.5px] text-[#555]",children:a.raw})]})]})]})}function bG({item:a}){let b=a.entries.slice(0,8),c=a.rolloutIds.slice(0,6);return(0,d.jsxs)("details",{className:"group my-2 ml-9 overflow-hidden rounded-[14px] border border-line bg-panel text-[12px] shadow-card",children:[(0,d.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-2 px-3.5 py-2",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(aJ,{name:"citation",className:"h-4 w-4"})}),(0,d.jsxs)("span",{className:"text-[13px] font-semibold",children:["цитати пам'яті (",a.entries.length,")"]}),(0,d.jsx)("span",{className:"ml-auto text-[11px] font-semibold text-accent group-open:hidden",children:"показати"}),(0,d.jsx)("span",{className:"ml-auto hidden text-[11px] font-semibold text-accent group-open:inline",children:"згорнути"})]}),(0,d.jsxs)("div",{className:"border-t border-line px-3.5 py-2.5",children:[b.length?(0,d.jsx)("div",{className:"space-y-1.5",children:b.map((a,b)=>(0,d.jsxs)("div",{className:"min-w-0 rounded-[9px] bg-[#fbfbfd] px-2.5 py-1.5",children:[(0,d.jsx)(bD,{file:a.target,line:a.line?Number(a.line.split("-",1)[0]):void 0}),a.note?(0,d.jsx)("div",{className:"mt-1 whitespace-pre-wrap break-words text-[12px] text-[#555]",children:a.note}):null]},b))}):(0,d.jsx)("div",{className:"text-[12px] text-dim",children:"без citation entries"}),a.entries.length>b.length?(0,d.jsxs)("div",{className:"mt-1.5 text-[12px] text-dim",children:["ще ",a.entries.length-b.length," entries у raw"]}):null,c.length?(0,d.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] text-dim",children:"rollout:"}),c.map(a=>(0,d.jsx)("code",{className:"rounded-full bg-chip px-2 py-0.5 font-mono text-[10.5px] text-dim",title:a,children:a.slice(0,8)},a)),a.rolloutIds.length>c.length?(0,d.jsxs)("span",{className:"text-[11px] text-dim",children:["+",a.rolloutIds.length-c.length]}):null]}):null,(0,d.jsxs)("details",{className:"mt-2 rounded-[10px] border border-line bg-[#fafafc] text-[12px]",children:[(0,d.jsxs)("summary",{className:"cursor-pointer list-none px-3 py-1.5 font-semibold text-dim",children:["raw citation block",a.truncated?" \xb7 обрізано":""]}),(0,d.jsx)("pre",{className:"max-h-[260px] overflow-auto whitespace-pre-wrap border-t border-line px-3 py-2 font-mono text-[11.5px] text-[#555]",children:a.raw})]})]})]})}let bH={shutdown_request:{icon:"shutdown",label:"запит на завершення",tone:"amber"},shutdown_response:{icon:"shutdown",label:"відповідь на завершення",tone:"amber"},plan_approval_request:{icon:"plan",label:"запит на затвердження плану",tone:"accent"},plan_approval_response:{icon:"plan",label:"вердикт по плану",tone:"accent"}};function bI(a){return"string"==typeof a&&a.length?a:void 0}function bJ({approve:a}){return(0,d.jsx)("span",{className:`rounded-full border px-2 py-0.5 text-[10.5px] font-extrabold ${a?"border-ok/25 bg-[#eefaf1] text-ok":"border-err/25 bg-[#fff0f0] text-err"}`,children:a?"схвалено":"відхилено"})}function bK({payload:a}){let b=bI(a.from),c=bI(a.requestId),e=I(a.timestamp);return b||c||e?(0,d.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-[11px] text-dim",children:[b?(0,d.jsxs)("span",{children:["від ",b]}):null,c?(0,d.jsx)("span",{className:"truncate font-mono",title:c,children:c.length>40?c.slice(0,40)+"…":c}):null,e?(0,d.jsx)("span",{children:e}):null]}):null}function bL({payload:a}){let b=bI(a.type),c=b?bH[b]:void 0;if(!c)return(0,d.jsxs)("div",{className:"text-[13px]",children:[(0,d.jsx)("div",{className:"text-dim",children:"структуроване повідомлення"}),(0,d.jsxs)("details",{className:"mt-1 text-[12px]",children:[(0,d.jsx)("summary",{className:"cursor-pointer list-none font-semibold text-accent",children:"показати JSON"}),(0,d.jsx)("pre",{className:"mt-1 max-h-[280px] overflow-auto whitespace-pre-wrap rounded-md bg-chip px-2.5 py-2 font-mono text-[11.5px]",children:JSON.stringify(a,null,2)})]})]});let e="boolean"==typeof a.approve?a.approve:void 0,f=bI(a.reason)??bI(a.feedback);return(0,d.jsxs)("div",{className:"text-[13px]",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsxs)("span",{className:`inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-[11.5px] font-bold ${"amber"===c.tone?"border-[#d89b21]/35 bg-[#fff9ea] text-[#9a6500]":"border-accent/25 bg-accent/10 text-accent"}`,children:[(0,d.jsx)(aJ,{name:c.icon,className:"h-3.5 w-3.5"}),c.label]}),void 0!==e?(0,d.jsx)(bJ,{approve:e}):null]}),f?(0,d.jsx)("div",{className:"mt-1.5 whitespace-pre-wrap break-words",children:bv(f)}):null,(0,d.jsx)(bK,{payload:a})]})}let bM=(0,e.memo)(function({item:a}){if("image"===a.kind)return(0,d.jsx)(by,{media:a.media,data:a.data,w:a.w,h:a.h,bytes:a.bytes});if("inbox-image"===a.kind)return(0,d.jsx)(bc,{name:a.name,path:a.path});if("blob"===a.kind)return(0,d.jsx)(bA,{bytes:a.bytes,text:a.text});if("sysmsg"===a.kind)return(0,d.jsx)(bz,{label:a.label,text:a.text});if("review"===a.kind)return(0,d.jsx)(bF,{item:a});if("mem-citation"===a.kind)return(0,d.jsx)(bG,{item:a});if("prose"===a.kind){let b="codex"===a.engine?"bg-codex":"bg-claude",c="codex"===a.engine?aq:aw;return(0,d.jsxs)("div",{className:"my-3.5 flex gap-2.5",children:[(0,d.jsx)("div",{className:`mt-1 flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-full text-white ${b}`,children:(0,d.jsx)(c,{className:"h-3.5 w-3.5","aria-hidden":!0})}),(0,d.jsxs)("div",{className:"min-w-0 flex-1 whitespace-pre-wrap break-words",children:[I(a.ts)?(0,d.jsx)("div",{className:"mb-0.5 text-[11px] text-dim",children:I(a.ts)}):null,bv(a.text)]})]})}if("user"===a.kind){let b=a.text.length>500;return(0,d.jsx)("div",{className:"my-3.5 flex justify-end",children:(0,d.jsx)("div",{className:"max-w-[75%] whitespace-pre-wrap break-words rounded-2xl bg-user px-4 py-2.5",children:b?(0,d.jsxs)("details",{className:"group/usr",children:[(0,d.jsxs)("summary",{className:"cursor-pointer list-none [&::-webkit-details-marker]:hidden",children:[(0,d.jsxs)("span",{className:"group-open/usr:hidden",children:[a.text.slice(0,180),"… ",(0,d.jsxs)("span",{className:"font-semibold text-accent",children:["(",a.text.length," симв.)"]})]}),(0,d.jsxs)("span",{className:"hidden items-center gap-1 text-[11px] font-semibold text-dim group-open/usr:inline-flex",children:["згорнути ",(0,d.jsx)(ao,{className:"h-3 w-3","aria-hidden":!0})]})]}),bv(a.text)]}):bv(a.text)})})}if("cmd"===a.kind){let b="ok"===a.call.status?"text-ok":"err"===a.call.status?"text-err":"text-dim";return(0,d.jsxs)("details",{className:"my-2.5 ml-9 overflow-hidden rounded-[14px] border border-line bg-panel shadow-card",open:a.call.open,children:[(0,d.jsxs)("summary",{className:"flex cursor-pointer list-none items-center gap-2.5 px-3.5 py-2",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(aJ,{name:a.call.icon,className:"h-4 w-4"})}),(0,d.jsx)("code",{className:"max-w-[70%] overflow-hidden text-ellipsis whitespace-nowrap rounded-md bg-chip px-2 py-0.5 font-mono text-[12.5px]",children:a.call.display}),(0,d.jsxs)("span",{className:`ml-auto inline-flex shrink-0 items-center gap-1 text-xs font-semibold ${b}`,children:[(0,d.jsx)(bC,{status:a.call.status}),a.call.label]})]}),(0,d.jsx)("pre",{className:"max-h-[340px] overflow-auto whitespace-pre-wrap border-t border-line bg-[#fafafc] px-3.5 py-2.5 font-mono text-[12.5px]",children:"$ "+a.call.cmd+(a.call.output?"\n"+a.call.output:"\n(вивід у цьому лог-файлі відсутній — повний є в rollout-сесії Codex)")})]})}if("cmd-group"===a.kind)return(0,d.jsx)(bE,{item:a});if("edit"===a.kind)return(0,d.jsxs)("div",{className:"my-2.5 ml-9 flex items-center gap-3 rounded-[14px] border border-line bg-panel px-3.5 py-2.5 shadow-card",children:[(0,d.jsx)("span",{className:"flex h-7.5 w-7.5 items-center justify-center rounded-lg bg-chip",children:(0,d.jsx)(aJ,{name:"note",className:"h-4 w-4"})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[13.5px] font-semibold",children:a.files}),(0,d.jsx)("div",{className:"text-xs text-dim",children:"файли змінені"})]})]});if("tmsg"===a.kind){let b=function(a){let b=a.trim();if((b.startsWith('"')&&b.endsWith('"')||b.startsWith("'")&&b.endsWith("'"))&&(b=b.slice(1,-1).trim()),!b.startsWith("{"))return null;try{let a=JSON.parse(b);if(null!==a&&"object"==typeof a&&!Array.isArray(a))return a}catch{}return null}(a.text),c=a.text.length>420||a.text.split("\n").length>6;return(0,d.jsxs)("div",{className:"my-2.5 ml-9 overflow-hidden rounded-[14px] border border-accent/25 bg-[#f8f8fd] shadow-card",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3.5 pt-2",children:[(0,d.jsx)("span",{className:"flex h-6.5 w-6.5 shrink-0 items-center justify-center rounded-lg bg-[#ecebfb] text-accent",children:(0,d.jsx)(as,{className:"h-3.5 w-3.5","aria-hidden":!0})}),(0,d.jsx)("span",{className:"text-[11px] font-semibold text-dim",children:"out"===a.dir?"до":"від"}),(0,d.jsx)("span",{className:"rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-bold text-accent",children:a.peer}),a.delivery?(0,d.jsxs)("span",{className:`inline-flex shrink-0 items-center gap-1 text-[10.5px] font-semibold ${"ok"===a.delivery?"text-ok":"text-err"}`,title:a.msgId?`msg_id: ${a.msgId}`:void 0,children:["ok"===a.delivery?(0,d.jsx)(am,{className:"h-3 w-3","aria-hidden":!0}):(0,d.jsx)(l,{className:"h-3 w-3","aria-hidden":!0}),"ok"===a.delivery?"доставлено":"не доставлено"]}):null,I(a.ts)?(0,d.jsx)("span",{className:"ml-auto shrink-0 text-[11px] text-dim",children:I(a.ts)}):null]}),(0,d.jsx)("div",{className:"px-3.5 pb-2.5 pt-1",children:b?(0,d.jsx)(bL,{payload:b}):(0,d.jsxs)(d.Fragment,{children:[a.summary?(0,d.jsx)("div",{className:"text-[13px] font-bold",children:br(a.summary)}):null,c?(0,d.jsxs)("details",{className:"group/tmsg mt-0.5 whitespace-pre-wrap break-words text-[13px]",children:[(0,d.jsxs)("summary",{className:"cursor-pointer list-none text-[12.5px] text-[#555] [&::-webkit-details-marker]:hidden",children:[(0,d.jsxs)("span",{className:"group-open/tmsg:hidden",children:[a.text.slice(0,260).trimEnd(),"… ",(0,d.jsx)("span",{className:"font-semibold text-accent",children:"показати все"})]}),(0,d.jsxs)("span",{className:"hidden items-center gap-1 text-[11px] font-semibold text-dim group-open/tmsg:inline-flex",children:["згорнути ",(0,d.jsx)(ao,{className:"h-3 w-3","aria-hidden":!0})]})]}),bv(a.text)]}):(0,d.jsx)("div",{className:"mt-0.5 whitespace-pre-wrap break-words text-[13px]",children:bv(a.text)})]})})]})}if("tnote"===a.kind)return(0,d.jsxs)("div",{className:"my-1 ml-9 flex items-center gap-1.5 text-[11.5px] text-dim",children:[(0,d.jsx)(as,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),a.text]});if("think"===a.kind){let b=a.text.length>150;return(0,d.jsxs)("details",{className:"my-1 ml-9 text-[11.5px] italic text-dim",children:[(0,d.jsxs)("summary",{className:`flex list-none items-center gap-1.5 truncate ${b?"cursor-pointer":""}`,title:"міркування агента",children:[(0,d.jsx)(al,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),(0,d.jsxs)("span",{className:"truncate",children:[a.text.slice(0,150),b?"…":""]})]}),b?(0,d.jsx)("div",{className:"whitespace-pre-wrap break-words pt-1 not-italic",children:bv(a.text)}):null]})}return"svc"===a.kind?(0,d.jsx)("div",{className:"my-1 break-words text-[11.5px] text-dim",children:a.text}):"note"===a.kind?(0,d.jsx)("div",{className:"my-2 break-words text-[12.5px] text-dim",children:br(a.text)}):(0,d.jsx)("div",{className:`my-0.5 break-words text-[12.5px] ${a.err?"text-err":"text-[#555]"}`,children:a.text})}),bN=k("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]),bO=k("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);function bP({file:a}){let b=a.pendingQuestion,[c,f]=(0,e.useState)("pending"),[g,h]=(0,e.useState)(""),[i,j]=(0,e.useState)({}),[k,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(!1),r=b?null!==b.paneTarget:null!==a.pid&&"running"===a.proc,s=(0,e.useMemo)(()=>b?.questions?b.questions.map((a,b)=>(i[b]??[]).map(b=>a.options[b]?.label??String(b+1)).join(", ")).filter(Boolean).join(" \xb7 "):"",[i,b]);if(!b)return a.waitingInput?(0,d.jsxs)("div",{id:"question",className:"my-4 rounded-[8px] border border-[#e0ae45]/45 bg-[#fff9ed] p-4 shadow-card",children:[(0,d.jsxs)("div",{className:"mb-2 inline-flex items-center gap-1.5 rounded-full bg-[#f5dfae] px-2 py-0.5 text-[11px] font-bold text-[#8a5a00]",children:[(0,d.jsx)(bN,{className:"h-3.5 w-3.5","aria-hidden":!0})," чекає на відповідь"]}),(0,d.jsxs)("div",{className:"text-[13px] font-semibold text-ink",children:["Пейн ",a.waitingInput.target," \xb7 ",function(a){let b=Math.max(0,Math.floor(Date.now()/1e3-a));if(b<60)return`${b} с`;let c=Math.floor(b/60);return c<60?`${c} хв`:`${Math.floor(c/60)} год`}(a.waitingInput.since)]}),(0,d.jsx)("pre",{className:"mt-2 whitespace-pre-wrap break-words rounded-[8px] border border-line bg-bg px-3 py-2 text-[12px] text-dim",children:a.waitingInput.screenTail}),(0,d.jsx)("div",{className:"mt-3 text-[12px] text-dim",children:"Можна відповісти через композер нижче."})]}):null;let t=async(a,c)=>{f("delivering"),h("");try{let d=await fetch("/api/answer",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({transcriptPath:b.transcriptPath,toolUseId:b.toolUseId,kind:b.kind,...a})}),e=await d.json();if(!d.ok||!e.ok){if(409===d.status&&(e.superseded||e.answer)){f("superseded"),h(e.answer??e.error??"відповідь уже записана");return}f("failed"),h(e.error??"не вдалося надіслати");return}f("answered"),h(e.answer??c)}catch{f("failed"),h("сервер недоступний")}},u=(a=i)=>b.questions?.map((b,c)=>a[c]??[])??[],v=b.questions?.length??0,w=v>1||(b.questions?.some(a=>a.multiSelect)??!1),x=b.questions?.every((a,b)=>(i[b]??[]).length>0)??!1,y=async()=>{q(!0),h("");try{let b=await fetch("/api/tmux",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"resume",path:a.path})}),c=await b.json();if(!b.ok||!c.ok)return void h(c.error??"не вдалося відкрити сесію");h(`відкрито ${c.target??"tmux"}`)}catch{h("сервер недоступний")}finally{q(!1)}},z="delivering"===c||!r;return"answered"===c?(0,d.jsxs)("div",{id:"question",className:"my-4 rounded-[8px] border border-ok/25 bg-[#eefaf1] px-4 py-3 text-[13px] font-semibold text-ok",children:["Відповідено: ",g||s]}):"superseded"===c?(0,d.jsxs)("div",{id:"question",className:"my-4 rounded-[8px] border border-line bg-chip px-4 py-3 text-[13px] font-semibold text-dim",children:["Відповідено в іншому місці: ",g]}):b&&!r?(0,d.jsxs)("div",{id:"question",className:"my-4 rounded-[8px] border border-[#e0ae45]/45 bg-[#fff9ed] p-4 shadow-card",children:[(0,d.jsxs)("div",{className:"mb-2 inline-flex items-center gap-1.5 rounded-full bg-[#f5dfae] px-2 py-0.5 text-[11px] font-bold text-[#8a5a00]",children:[(0,d.jsx)(bN,{className:"h-3.5 w-3.5","aria-hidden":!0})," чекає на відповідь"]}),(0,d.jsx)("div",{className:"text-[13px] font-semibold text-err",children:"tmux-пейн недоступний"}),"plan"===b.kind?(0,d.jsx)("pre",{className:"mt-2 max-h-[320px] overflow-auto whitespace-pre-wrap break-words rounded-[8px] border border-line bg-bg px-3 py-2 text-[13px]",children:b.plan}):b.questions?.map((a,b)=>(0,d.jsxs)("div",{className:"mt-2",children:[(0,d.jsx)("div",{className:"text-[12px] font-bold text-dim",children:a.header}),(0,d.jsx)("div",{className:"text-[13px] font-semibold text-ink",children:a.question})]},b)),(0,d.jsx)("button",{className:"mt-3 rounded-[8px] bg-accent px-3 py-1.5 text-[13px] font-bold text-white disabled:opacity-60",disabled:p,onClick:y,children:"відкрити сесію"}),g?(0,d.jsx)("div",{className:"mt-2 text-[12px] font-semibold text-dim",children:g}):null]}):(0,d.jsxs)("div",{id:"question",className:"my-4 rounded-[8px] border border-[#e0ae45]/45 bg-[#fff9ed] p-4 shadow-card",children:[(0,d.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,d.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-[#f5dfae] px-2 py-0.5 text-[11px] font-bold text-[#8a5a00]",children:[(0,d.jsx)(bN,{className:"h-3.5 w-3.5","aria-hidden":!0})," чекає на відповідь"]}),r?null:(0,d.jsx)("span",{className:"text-[12px] font-semibold text-err",children:"tmux-пейн недоступний"})]}),"plan"===b.kind?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("pre",{className:"max-h-[420px] overflow-auto whitespace-pre-wrap break-words rounded-[8px] border border-line bg-bg px-3 py-2 text-[13px]",children:b.plan}),(0,d.jsx)("textarea",{className:"mt-3 min-h-20 w-full resize-y rounded-[8px] border border-line bg-bg px-3 py-2 text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-accent/35",placeholder:"Коментар до відхилення…",value:n,onChange:a=>o(a.target.value)}),(0,d.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,d.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-[8px] bg-ok px-3 py-1.5 text-[13px] font-bold text-white disabled:opacity-60",disabled:z,onClick:()=>t({approve:!0},"затверджено"),children:[(0,d.jsx)(am,{className:"h-4 w-4","aria-hidden":!0})," Затвердити"]}),(0,d.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-[8px] bg-err px-3 py-1.5 text-[13px] font-bold text-white disabled:opacity-60",disabled:z,onClick:()=>t({approve:!1,text:n},"відхилено"),children:[(0,d.jsx)(l,{className:"h-4 w-4","aria-hidden":!0})," Відхилити"]})]})]}):(0,d.jsxs)(d.Fragment,{children:[b.questions?.map((a,b)=>(0,d.jsxs)("section",{className:"mt-3 first:mt-0",children:[(0,d.jsx)("div",{className:"mb-1 inline-flex rounded-full bg-bg px-2 py-0.5 text-[11px] font-bold text-dim",children:a.header}),(0,d.jsx)("div",{className:"mb-2 text-[14px] font-bold text-ink",children:a.question}),(0,d.jsx)("div",{className:"space-y-1.5",children:a.options.map((c,e)=>{let f=(i[b]??[]).includes(e);return(0,d.jsxs)("button",{className:`flex w-full items-start gap-2 rounded-[8px] border px-3 py-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/35 ${f?"border-accent/45 bg-accent/10":c.recommended?"border-[#e0ae45]/45 bg-[#fff5dc]":"border-line bg-bg"}`,disabled:z,onClick:()=>{var d;let f={...i,[b]:[e]};d=a.multiSelect,j(a=>{let c=a[b]??[],f=d?c.includes(e)?c.filter(a=>a!==e):[...c,e]:[e];return{...a,[b]:f}}),a.multiSelect||1!==v||t({answers:u(f)},c.label)},children:[(0,d.jsx)("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border border-line bg-panel text-[10px] font-bold",children:f?"✓":e+1}),(0,d.jsxs)("span",{className:"min-w-0",children:[(0,d.jsx)("span",{className:"block text-[13px] font-bold",children:c.label}),c.description?(0,d.jsx)("span",{className:"block text-[12px] text-dim",children:c.description}):null]})]},e)})})]},b)),v<=1?(0,d.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,d.jsx)("input",{className:"min-w-0 flex-1 rounded-[8px] border border-line bg-bg px-3 py-1.5 text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-accent/35",placeholder:"Своя відповідь…",value:k,onChange:a=>m(a.target.value)}),(0,d.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-[8px] bg-accent px-3 py-1.5 text-[13px] font-bold text-white disabled:opacity-60",disabled:z||!k.trim(),onClick:()=>t({text:k},k),children:[(0,d.jsx)(bO,{className:"h-4 w-4","aria-hidden":!0})," Надіслати"]})]}):null,w?(0,d.jsxs)("button",{className:"mt-3 inline-flex items-center gap-1.5 rounded-[8px] bg-accent px-3 py-1.5 text-[13px] font-bold text-white disabled:opacity-60",disabled:z||!x,onClick:()=>t({answers:u()},s),children:[(0,d.jsx)(bO,{className:"h-4 w-4","aria-hidden":!0})," Надіслати"]}):null]}),"delivering"===c?(0,d.jsxs)("div",{className:"mt-3 inline-flex items-center gap-1.5 text-[12px] font-semibold text-dim",children:[(0,d.jsx)(aH,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0})," надсилаю…"]}):null,"failed"===c?(0,d.jsx)("div",{className:"mt-3 text-[12px] font-semibold text-err",children:g}):null]})}function bQ({icon:a,label:b}){return(0,d.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-[12px] font-semibold text-ok",children:[(0,d.jsxs)("span",{className:"flex items-center gap-0.5","aria-hidden":!0,children:[(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-ok"}),(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-ok [animation-delay:150ms]"}),(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-ok [animation-delay:300ms]"})]}),(0,d.jsx)(a,{className:"h-3.5 w-3.5","aria-hidden":!0}),b]})}function bR({file:a,files:b,onSelect:c,showSvc:f,lineFilter:g,onStatus:h,paused:i,follow:j,setFollow:k,compact:l=!1}){let[m,n]=(0,e.useState)(j),o=function(a,b=!1,c=2500){(0,e.useRef)(c);let[d,f]=(0,e.useState)([]),[g,h]=(0,e.useState)(0),[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(null),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(0),w=(0,e.useRef)(0),x=(0,e.useRef)(0),y=(0,e.useRef)(""),z=(0,e.useRef)(!0),A=(0,e.useRef)(0);(0,e.useRef)(!1);let B=(0,e.useRef)(!1);return{lines:d,size:g,loading:i,error:k,tickTime:m,paused:o,setPaused:p,clear:(0,e.useCallback)(()=>{f([]),w.current=0,x.current=0,y.current="",z.current=!0,r(!1)},[]),hasMore:q,loadingOlder:s,loadOlder:(0,e.useCallback)(async()=>{if(!a||B.current||x.current<=0)return 0;B.current=!0,t(!0);let b=A.current;try{let c="",d=x.current;for(let e=0;e<4;e+=1){let e=await fetch(`/api/log?path=${encodeURIComponent(a.path)}&before=${d}`),f=await e.json();if(b!==A.current||"error"in f&&f.error)return 0;if(c=f.data+c,d=f.start,0===d||c.slice(0,-1).includes("\n"))break}let e=d;if(d>0){let a,b=c.indexOf("\n");if(b<0||b===c.length-1)return 0;e=d+(a=c.slice(0,b+1),new TextEncoder().encode(a).length),c=c.slice(b+1)}let g=c.split("\n");""===g.at(-1)&&g.pop();let h=g.map(a=>a.trim()).filter(Boolean);return x.current=e,r(e>0),h.length&&(f(a=>h.concat(a)),v(a=>a+1)),h.length}catch{return 0}finally{B.current=!1,t(!1)}},[a?.path]),prependGen:u}}(a,i,m&&l?2500:0),p=(0,e.useRef)(null),q=(0,e.useRef)(null),s=(0,e.useRef)(null),t=l?500:1500,[u,v]=(0,e.useState)(l?300:1500),[w,x]=(0,e.useState)(0),[y,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(null);(0,e.useRef)(!1);let C=(0,e.useRef)(m);(0,e.useRef)(0),(0,e.useRef)(0);let D=(0,e.useRef)(null),E=(a,b=!1)=>{C.current=a,n(a),k(a),a&&x(0),b&&(z(!0),D.current&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>z(!1),450))},F=(0,e.useMemo)(()=>a?function(a,b,c,d){let e=new Map,f=new Map,g=[],h=0,i="",j=a=>!!(!(a.length<=2e4)&&(a.match(/\s/g)?.length??0)/a.length<.02)&&(g.push({kind:"blob",bytes:a.length,text:a5(a).slice(0,2e5)}),!0),k=(a,b)=>{let c=bn(a.source),d=bm(c.data)||bm(b.base64);if(!d)return;let e=bm(c.media_type)||bm(b.type),f=e.startsWith("image/")?e:"image/png",h=bn(b.dimensions);g.push({kind:"image",media:f,data:d,w:bf(h.originalWidth),h:bf(h.originalHeight),bytes:bf(b.originalSize)})},l=(a,b,c)=>{bd.lastIndex=0;let d=bd.test(b);if(bd.lastIndex=0,!d){let c=a8(b.trim(),a);return!!c&&(g.push(c),!0)}let e=!1,f=0,h=b=>{let d=b.trim();if(!d)return;let f=a8(d,a);f?(g.push(f),e=!0):c(d)};for(let a of b.matchAll(bd)){let c=a[0],d=a.index??0;h(b.slice(f,d)),g.push(bw(c,a[1]??"",a[2]??"")),e=!0,f=d+c.length}return h(b.slice(f)),e},m=a=>{let b=[];return bd.lastIndex=0,{cleaned:a.replace(bd,(a,c,d)=>(b.push(bw(a,c,d)),"")).trim(),cites:b}},n=(b,c)=>{if(!c.trim()||c===i||(i=c,j(c)))return;let d="codex"===a.engine?"codex":"claude";l(b,c,a=>g.push({kind:"prose",ts:b,text:a,engine:d}))||g.push({kind:"prose",ts:b,text:c,engine:d})},o=(a,b,c,d)=>{let f=c||"plain-"+g.length+"-"+String(a??""),h=function(a,b="shell"){let c=a5(a);return{cmd:c,display:function(a){let b,c=a.match(/^([A-Za-z][\w.]*): /),d=c?c[0]:"",e=d?a.slice(d.length):a;do b=e,e=(e=(e=(e=e.replace(/^export PATH=[^;]+;\s*/,"")).replace(/^cd\s+\S+\s*&&\s*/,"")).replace(/^\/usr\/bin\/zsh -lc\s+/,"")).replace(/^(["'])([\s\S]*)\1$/,(a,b,c)=>RegExp(`(?<!\\\\)${b}`).test(c)?a:c);while(e!==b);let f=e.match(/^([\w./-]+(?:\s+-)?)\s*<<\s*['"]?(\w+)['"]?/);return f&&(e=`${f[1].trim()} \xabheredoc\xbb`),(d+(e=e.replace(/\s+/g," ").trim())).slice(0,160)}(c),icon:b,output:"",status:"run",label:"виконується…",open:!1}}(b,d);return e.set(f,h),g.push({kind:"cmd",id:f,call:h,ts:a}),h},p=(a,b,d)=>{if(!a)return;let h=f.get(a);if(h){h.delivery=d||/"success"\s*:\s*false/.test(b)?"err":"ok",h.msgId=b.match(/"msg_id"\s*:\s*"([^"]+)"/)?.[1];return}!bx(e.get(a),b,d)&&b&&c&&g.push({kind:"svc",text:"output: "+a5(b).slice(0,200)})},q=a=>{c?g.push({kind:"svc",text:a.slice(0,300)}):h+=1},r=a=>{g.push({kind:"note",text:a})},s=(a,b)=>{let c=b.replace(bg,(b,c,d,e)=>{let f=bl(d,"teammate_id")||bl(d,"from")||"тімейт",h=bl(d,"summary"),i=e.trim();if(i.startsWith("{"))try{let a=JSON.parse(i);if("idle_notification"===a.type){let b=I(a.timestamp);return g.push({kind:"tnote",text:`${f}: звільнився${b?" \xb7 "+b:""}`}),""}}catch{}let{cleaned:j,cites:k}=m(i),l=a_.test(j)?a8(j,a):null;for(let b of(g.push({kind:"tmsg",ts:a,dir:"in",peer:f,summary:h,text:l?"":j}),l&&g.push(l),k))g.push(b);return""}).replace(/Another Claude session sent a message:\s*/g,"").trim();if(!c||j(c))return;if(bj.test(c))return void g.push({kind:"sysmsg",label:bk(c),text:c});let{cleaned:d,images:e}=bi(c);for(let b of(d&&!l(a,d,b=>g.push({kind:"user",ts:a,text:b}))&&g.push({kind:"user",ts:a,text:d}),e))g.push({kind:"inbox-image",name:b.name,path:b.path})},t=(a,b)=>{let{cleaned:c,images:d}=bi(b);for(let b of(c&&g.push({kind:"user",ts:a,text:c}),d))g.push({kind:"inbox-image",name:b.name,path:b.path})},u=a=>{let b=bn(a.payload),c=a.timestamp;if("session_meta"===a.type)return r(`Сесія Codex створена \xb7 ${bm(b.model)} \xb7 ${bm(b.cwd)}`);if("event_msg"===a.type){if("agent_message"===b.type&&b.message)return n(c,bm(b.message));if("user_message"===b.type&&b.message){let a=bm(b.message);return bj.test(a)?g.push({kind:"sysmsg",label:bk(a),text:a}):t(c,a)}return"task_started"===b.type?r("Задача стартувала"+(c?" \xb7 "+I(c):"")):"task_complete"===b.type?r("Задачу завершено"+(c?" \xb7 "+I(c):"")):q(bm(b.type)||"event")}if("response_item"===a.type){if("message"===b.type){let a=bo(b.content).map(a=>bm(a.text)||bm(a.input_text)).join(" ").trim();return a?"user"!==b.role?n(c,a):bj.test(a)?g.push({kind:"sysmsg",label:bk(a),text:a}):t(c,a):q("message "+bm(b.role))}if("function_call"===b.type){let a={};try{a=JSON.parse(bm(b.arguments)||"{}")}catch{a={}}let d=bm(b.name);if("exec_command"===d||"shell"===d)return o(c,String(a.cmd??a.command??"").replace(/^\/usr\/bin\/zsh -lc /,""),bm(b.call_id));if("apply_patch"===d){let b=String(a.input??"").match(/(Add|Update|Delete) File: [^\n]+/g);g.push({kind:"edit",files:b?b.join(", ").replace(/(Add|Update|Delete) File: /g,""):"патч"});return}return"write_stdin"===d?q("stdin → сесія "+String(a.session_id??"")):o(c,d+" "+JSON.stringify(a).slice(0,120),bm(b.call_id),"tool")}if("function_call_output"===b.type)return p(bm(b.call_id),"string"==typeof b.output?b.output:JSON.stringify(b.output??""));if("custom_tool_call"===b.type&&"apply_patch"===bm(b.name)){let a=bm(b.input).match(/(Add|Update|Delete) File: [^\n]+/g);g.push({kind:"edit",files:a?a.join(", ").replace(/(Add|Update|Delete) File: /g,""):"патч"});return}return"custom_tool_call_output"===b.type?p(bm(b.call_id),"string"==typeof b.output?b.output:JSON.stringify(b.output??"")):"reasoning"===b.type?q("reasoning"):q(bm(b.type)||"item")}q(bm(a.type)||"запис")},v=a=>{let b=a.timestamp;if("user"===a.type&&a.message){let c=bn(a.message).content,d=bn(bn(a.toolUseResult).file);if("string"==typeof c)s(b,c);else for(let a of bo(c))if("text"===a.type)s(b,bm(a.text));else if("image"===a.type)k(a,d);else if("tool_result"===a.type){let b=bo(a.content);for(let a of b)"image"===a.type&&k(a,d);let c="string"==typeof a.content?a.content:b.filter(a=>"image"!==a.type).map(a=>bm(a.text)).join(" ");p(bm(a.tool_use_id),c,!0===a.is_error)}return}if("assistant"===a.type&&a.message){for(let c of bo(bn(a.message).content))if("text"===c.type&&bm(c.text).trim())n(b,bm(c.text));else if("thinking"===c.type&&bm(c.thinking).trim())g.push({kind:"think",text:bm(c.thinking).replace(/\s+/g," ").trim()});else if("tool_use"===c.type&&"SendMessage"===bm(c.name)){let a=bn(c.input),d=a.message;if("string"==typeof d){let{cleaned:e,cites:h}=m(d),i=a_.test(e)?a8(e,b):null,j={kind:"tmsg",ts:b,dir:"out",peer:String(a.to??""),summary:String(a.summary??""),text:i?"":e};for(let a of(g.push(j),i&&g.push(i),h))g.push(a);bm(c.id)&&f.set(bm(c.id),j)}else q(`SendMessage → ${String(a.to??"")} \xb7 ${bm(bn(d).type)||"протокол"}`)}else if("tool_use"===c.type){let a=bn(c.input),d=String(a.command??a.file_path??a.prompt??JSON.stringify(a));o(b,bm(c.name)+": "+d.slice(0,160),bm(c.id),"tool")}return}q(bm(a.type)||"запис")},w=null,x=()=>{if(!w)return;let a=w.join("\n").trim();if(w=null,!a)return;let b=a=>{for(let b of a.split("\n"))b.trim()&&g.push({kind:"raw",text:a5(b),err:/error|failed|traceback|exception/i.test(b)})};l(null,a,b)||b(a)},y=a=>{let b=a.replace(/\x1b\][^\x07]*(\x07|\x1b\\)/g,"").replace(/\x1b\[[0-9;?]*[A-Za-z]/g,"");if(w)if(!/^\[codex\]/.test(b))return void w.push(b);else x();if(/Assistant message$/.test(b))return;let c=b.match(/^\[([^\]]+)\]\s*(.*)$/),d=c?.[1]??null,f=c?.[2]??b;if(!(!f||/^Assistant message captured/.test(f))){if(!c&&(a_.test(b)||b.startsWith("<oai-mem-citation>"))){w=[b];return}if(/^Running command: /.test(f))return o(d,f.replace(/^Running command: /,"").replace(/^\/usr\/bin\/zsh -lc /,""));if(/^Command (completed|failed)/.test(f)){let a=[...e.values()].at(-1);a&&bx(a,/^Command failed/.test(f)?f+"\n(це джоб-лог: він не містить stdout команд; повний вивід — у rollout-сесії Codex у списку зліва)":f,/^Command failed/.test(f));return}return/^Applying \d+ file/.test(f)?g.push({kind:"edit",files:f}):c&&!/^(Running|Command|Applying)/.test(f)?n(d,f):void(!j(b)&&g.push({kind:"raw",text:a5(b),err:/error|failed|traceback|exception/i.test(b)}))}};for(let c of b)if(!d||c.toLowerCase().includes(d))if("claude"===a.fmt||"codex"===a.fmt)try{let b=JSON.parse(c);b&&"object"==typeof b&&!Array.isArray(b)&&("claude"===a.fmt?v(b):u(b))}catch{y(c)}else y(c);return x(),{items:function(a,b){let c=[],d=0;for(;d<a.length;){if("cmd"!==a[d].kind){c.push(a[d]),d+=1;continue}let f=d,g=[];for(;f<a.length;){let b=a[f];if("cmd"===b.kind)g.push(b);else if("think"!==b.kind)break;f+=1}let h=f===a.length;if(g.length>=4&&!(b&&h)){let a={},b=0,h=0;for(let c of g){var e;let d=(e=c.call.cmd,e.match(/^([A-Za-z][\w.]*): /)?.[1]??"cmd");a[d]=(a[d]??0)+1,"ok"===c.call.status?b+=1:"err"===c.call.status&&(h+=1)}c.push({kind:"cmd-group",ids:g.map(a=>a.id),calls:g.map(a=>a.call),t0:g[0]?.ts,t1:g.at(-1)?.ts,byTool:a,okCount:b,errCount:h,hasErr:h>0}),d=f}else c.push(a[d]),d+=1}return c}(g,"live"===a.activity),hiddenServiceCount:h}}(a,o.lines,f,g.toLowerCase()):{items:[],hiddenServiceCount:0},[a?.path,a?.engine,a?.fmt,a?.activity,o.lines,f,g]),G=Math.max(0,F.items.length-u),H=G?F.items.slice(-u):F.items,J=()=>{let a=p.current;a&&(s.current={top:a.scrollTop,height:a.scrollHeight}),G?v(a=>a+t):o.hasMore&&o.loadOlder().then(()=>v(a=>a+t))},K=G>0||o.hasMore,L=F.items.at(-1),M=L?.kind==="cmd"&&"run"===L.call.status?{icon:aA,label:`виконує ${L.call.cmd.split(/[\s:]/,1)[0]||"інструмент"}…`}:L?.kind==="think"?{icon:aw,label:"думає…"}:{icon:aw,label:"працює…"};return(0,d.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[a&&F.items.length?m?"live"===a.activity?(0,d.jsxs)("div",{className:`pointer-events-none absolute bottom-2 right-3 z-10 inline-flex items-center gap-1 rounded-full bg-ok px-2 py-0.5 text-[10px] font-bold text-white shadow-card transition-transform duration-200 ${y?"scale-125":"scale-100"}`,children:[(0,d.jsx)(a$,{className:"h-3 w-3","aria-hidden":!0})," живий хвіст"]}):null:(0,d.jsxs)("button",{className:"absolute bottom-2 right-3 z-10 inline-flex items-center gap-1 rounded-full border border-line bg-panel px-2.5 py-1 text-[11px] font-semibold text-ink shadow-card hover:border-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":"Повернутись до живого хвоста",onClick:()=>{let a=p.current;a&&(a.scrollTop=a.scrollHeight),E(!0,!0)},children:[(0,d.jsx)(ah,{className:"h-3.5 w-3.5","aria-hidden":!0})," ",w?`${w} нових`:"вниз"]}):null,(0,d.jsx)("div",{ref:p,className:l?"min-h-0 flex-1 overflow-y-auto py-3":"min-h-0 flex-1 overflow-y-auto py-6",onScroll:a=>{let b=a.currentTarget,c=b.scrollTop+b.clientHeight>=b.scrollHeight-50;c&&!C.current?E(!0,!0):!c&&C.current&&E(!1),b.scrollTop<120&&K&&!o.loadingOlder&&!o.loading&&J()},children:(0,d.jsx)("div",{ref:q,className:l?"px-3 pb-4 text-[13px]":"mx-auto w-full max-w-[1060px] px-6 pb-16",children:a?(0,d.jsxs)(d.Fragment,{children:[l&&K?(0,d.jsx)("button",{className:"mb-2 flex w-full items-center justify-center gap-1.5 rounded-[8px] border border-dashed border-line bg-bg px-2 py-1 text-[11px] font-semibold text-dim hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",disabled:o.loadingOlder,onClick:J,children:o.loadingOlder?"завантаження…":(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ao,{className:"h-3.5 w-3.5","aria-hidden":!0})," показати раніше"]})}):null,!l&&K&&F.items.length?(0,d.jsx)("button",{className:"mb-3 flex w-full items-center justify-center gap-1.5 rounded-[10px] border border-dashed border-line bg-panel px-3 py-1.5 text-[12px] font-semibold text-dim hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",disabled:o.loadingOlder,onClick:J,children:o.loadingOlder?"завантаження…":G?`показати раніше (сховано ${G})`:"завантажити раніше з файлу"}):null,l||K||!F.items.length?null:(0,d.jsx)("div",{className:"mb-3 text-center text-[11px] text-dim",children:"початок розмови"}),l?null:(0,d.jsx)(aX,{file:a,files:b,onSelect:c}),F.items.length?(0,d.jsxs)(d.Fragment,{children:[H.map((a,b)=>{let c=b+F.items.length-H.length;return l?(0,d.jsx)("div",{className:"feed-cv",children:(0,d.jsx)(bM,{item:a})},c):(0,d.jsx)(bM,{item:a},c)}),a.pendingQuestion||a.waitingInput?(0,d.jsx)(bP,{file:a},a.pendingQuestion?.toolUseId??"waiting"):null,a.pendingQuestion||a.waitingInput||!A?null:(0,d.jsx)("div",{className:"my-4 rounded-[8px] border border-line bg-chip px-4 py-3 text-[13px] font-semibold text-dim",children:A}),"live"===a.activity?(0,d.jsx)(bQ,{icon:M.icon,label:M.label}):null,"recent"===a.activity&&X(a)?(0,d.jsxs)("div",{className:"mt-2 flex items-center gap-1.5 text-[11.5px] font-semibold text-[#b8860b]",children:[(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-[#d29a2f]","aria-hidden":!0})," закінчив хід — чекає відповіді"]}):"recent"===a.activity&&r(a)&&"running"!==a.proc?(0,d.jsxs)("div",{className:"mt-2 flex items-center gap-1 text-[11.5px] font-semibold text-accent",children:[(0,d.jsx)(ae,{className:"h-3.5 w-3.5","aria-hidden":!0})," повернувся з результатом"]}):null]}):(0,d.jsxs)("div",{className:"mt-[14vh] text-center text-dim",children:[o.loading?"Завантаження…":0===o.size?"Ще без виводу — файл поки порожній":F.hiddenServiceCount?`Видимих повідомлень нема — лише службові записи (${F.hiddenServiceCount}). Натисни \xabСлужбові\xbb`:"Порожньо (немає рядків для показу)",!o.loading&&(a.cmdDesc||a.cmd)?(0,d.jsxs)("div",{className:"mx-auto mt-3 max-w-[560px]",children:[a.cmdDesc?(0,d.jsx)("div",{className:"text-[12.5px] font-semibold text-ink",children:a.cmdDesc}):null,a.cmd?(0,d.jsx)("pre",{className:"mt-1.5 overflow-x-auto whitespace-pre-wrap break-words rounded-[10px] border border-line bg-bg px-3 py-2 text-left font-mono text-[11.5px] text-ink",children:a.cmd}):null]}):null]}),F.items.length?null:a.pendingQuestion||a.waitingInput?(0,d.jsx)(bP,{file:a},a.pendingQuestion?.toolUseId??"waiting"):null]}):(0,d.jsx)("div",{className:"mt-[20vh] text-center text-dim",children:"Вибери лог зліва — стрічка оновлюється сама"})})})]})}let bS={completed:"✓",in_progress:"▸",pending:"○"};function bT({plan:a}){let b=a.total?Math.round(a.done/a.total*100):0;return(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-[#f1f0fc] px-1.5 py-0.5 font-mono text-[9.5px] font-semibold text-accent",title:["План агента:",...a.steps.map(a=>`${bS[a.status]} ${a.text}`)].join("\n"),"aria-label":`План: ${a.done} з ${a.total} кроків${a.current?`, зараз: ${a.current}`:""}`,children:[a.done,"/",a.total,(0,d.jsx)("span",{className:"h-1 w-6 overflow-hidden rounded-full bg-accent/20","aria-hidden":!0,children:(0,d.jsx)("span",{className:"block h-full rounded-full bg-accent",style:{width:`${b}%`}})})]})}let bU={active:{label:"ціль",className:"bg-[#f1f0fc] text-accent"},complete:{label:"ціль ✓",className:"bg-[#e7f4ea] text-ok"},blocked:{label:"ціль ✖",className:"bg-[#fbeaea] text-err"}};function bV({ctx:a}){var b;return(0,d.jsxs)("span",{className:`inline-flex shrink-0 items-center rounded-full px-1.5 py-0.5 font-mono text-[9.5px] font-semibold ${(b=a.pct)>=90?"bg-[#fbeaea] text-err":b>=70?"bg-[#fff7e6] text-[#b07d18]":"bg-chip text-dim"}`,title:`Контекстне вікно: використано ${a.pct}%
6
+ ${a.usedTokens.toLocaleString("uk-UA")} з ${a.windowTokens.toLocaleString("uk-UA")} токенів`,"aria-label":`Контекст: використано ${a.pct} відсотків вікна`,children:["ctx ",a.pct,"%"]})}function bW({goal:a}){let b,c=bU[a.status];return(0,d.jsx)("span",{className:`inline-flex shrink-0 items-center rounded-full px-1.5 py-0.5 text-[9.5px] font-semibold ${c.className}`,title:(b=[a.objective??"(objective не записаний у хвості транскрипта)"],null!==a.tokensUsed&&b.push(`токенів: ${a.tokensUsed.toLocaleString("uk-UA")}`),null!==a.timeUsedSeconds&&b.push(`часу: ${Math.round(a.timeUsedSeconds/60)} хв`),b.join("\n")),"aria-label":`Ціль сесії: ${a.status}${a.objective?` — ${a.objective.slice(0,120)}`:""}`,children:c.label})}function bX({onError:a,onUnclaimedText:b}){let[c,d]=(0,e.useState)("idle"),[f,g]=(0,e.useState)(0),h=(0,e.useRef)(null),i=(0,e.useRef)([]),j=(0,e.useRef)(!1),k=(0,e.useRef)(null),l=(0,e.useRef)(null),m=(0,e.useRef)(null),n=(0,e.useRef)(null),o=(0,e.useRef)(!1),p=async()=>{let c;null!==k.current&&(clearInterval(k.current),k.current=null),c=m.current,m.current=null,c&&(cancelAnimationFrame(c.raf),c.ctx.close().catch(()=>void 0));let e=h.current;h.current=null,e?.stream.getTracks().forEach(a=>a.stop());let f=new Blob(i.current,{type:"audio/webm"});i.current=[];let g=n.current;if(n.current=null,j.current||f.size<2e3){d("idle"),g?.(null);return}d("busy");try{let c=new FormData;c.append("file",f,"dictation.webm");let d=await fetch("/api/transcribe",{method:"POST",body:c}),e=await d.json();if(!d.ok||"string"!=typeof e.text){a(e.error??"не вдалося розпізнати"),g?.(null);return}let h=e.text.trim();h?g?g(h):b(h):(a("тиша — нічого не розпізналось"),g?.(null))}catch{a("сервер недоступний"),g?.(null)}finally{d("idle")}},q=async()=>{let b;if(o.current||h.current)return;o.current=!0;try{b=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1}})}catch{a("немає доступу до мікрофона");return}finally{o.current=!1}let c=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm",e=new MediaRecorder(b,{mimeType:c});i.current=[],j.current=!1,e.ondataavailable=a=>{a.data.size&&i.current.push(a.data)},e.onstop=()=>{p()},e.start(250),h.current=e,(a=>{let b;try{b=new AudioContext}catch{return}let c=b.createAnalyser();c.fftSize=128,c.smoothingTimeConstant=.7,b.createMediaStreamSource(a).connect(c);let d=new Uint8Array(c.frequencyBinCount),e=()=>{if(!m.current)return;m.current.raf=requestAnimationFrame(e),c.getByteFrequencyData(d);let a=l.current;a&&function(a,b){let c=window.devicePixelRatio||1;(a.width!==56*c||a.height!==16*c)&&(a.width=56*c,a.height=16*c);let d=a.getContext("2d");if(!d)return;d.setTransform(c,0,0,c,0,0),d.clearRect(0,0,56,16);let e=Math.max(13,Math.floor(.65*b.length))/13;for(let a=0;a<13;a+=1){let c=Math.floor(a*e),f=Math.max(c+1,Math.floor((a+1)*e)),g=0;for(let a=c;a<f;a+=1)g+=b[a]??0;let h=g/(f-c)/255,i=Math.max(1.5,16*h);d.fillStyle=`rgba(198, 40, 40, ${(.35+.65*h).toFixed(3)})`,d.fillRect(4.3076923076923075*a+1,(16-i)/2,2.3076923076923075,i)}}(a,d)};m.current={ctx:b,raf:requestAnimationFrame(e)}})(b),g(0),d("rec"),k.current=window.setInterval(()=>{g(a=>{let b=a+1;return b>=120&&h.current?.state==="recording"&&h.current.stop(),b})},1e3)};return{phase:c,elapsed:f,canvasRef:l,start:q,stop:()=>new Promise(a=>{let b=h.current;b&&"recording"===b.state?(n.current=a,b.stop()):a(null)}),discard:()=>{j.current=!0,h.current?.state==="recording"&&h.current.stop()}}}let bY={"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/webp":"webp"};function bZ(a){return new Promise((b,c)=>{let d=new FileReader;d.onload=()=>{let e=String(d.result),f=e.indexOf(",");f<0?c(Error("не вдалося прочитати картинку")):b({base64:e.slice(f+1),mime:a.type||"image/png",preview:e})},d.onerror=()=>c(d.error??Error("не вдалося прочитати картинку")),d.onabort=()=>c(Error("читання картинки перервано")),d.readAsDataURL(a)})}function b$(a){let[b,c]=(0,e.useState)([]),d=b=>{if(!b.length)return;let d=[];for(let c of b){if(null===(bY[c.type]??null)){a.onError(`непідтримуваний формат картинки: ${c.name||c.type||"невідомий файл"}`);continue}if(c.size>0xa00000){a.onError(`${c.name||"картинка"}: завелика (ліміт 10 МБ)`);continue}d.push(c)}if(!d.length)return;let e=d.length<b.length;Promise.all(d.map(bZ)).then(b=>{c(a=>[...a,...b]),e||a.onAdded?.()}).catch(b=>{a.onError(b instanceof Error?b.message:"помилка картинки")})};return{images:b,addFiles:d,handlePaste:a=>{let b=Array.from(a.clipboardData.items).filter(a=>a.type.startsWith("image/")).map(a=>a.getAsFile()).filter(a=>null!==a);b.length&&(a.preventDefault(),d(b))},removeAt:a=>c(b=>b.filter((b,c)=>c!==a)),clear:()=>c([])}}function b_({images:a,onRemove:b}){return a.length?(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.map((a,c)=>(0,d.jsxs)("div",{className:"group/img relative",children:[(0,d.jsx)("img",{src:a.preview,alt:`прев'ю картинки ${c+1}`,className:"h-10 w-10 rounded border border-line object-cover"}),(0,d.jsx)("button",{type:"button",onClick:()=>b(c),"aria-label":`Прибрати картинку ${c+1}`,className:"absolute -right-1 -top-1 hidden h-4 w-4 items-center justify-center rounded-full border border-line bg-panel text-dim shadow-card hover:text-err group-hover/img:flex focus-visible:flex focus-visible:outline-none",children:(0,d.jsx)(l,{className:"h-2.5 w-2.5","aria-hidden":!0})})]},c)),(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10.5px] font-semibold text-dim",children:[a.length," ",1===a.length?"картинка":"картинки"," ",(0,d.jsx)(ai,{className:"h-3 w-3","aria-hidden":!0})," шляхами до файлів"]})]}):null}function b0({onFiles:a,ariaLabel:b,className:c}){let f=(0,e.useRef)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("input",{ref:f,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:b=>{a(Array.from(b.target.files??[])),b.target.value=""}}),(0,d.jsx)("button",{type:"button","aria-label":b,onClick:()=>f.current?.click(),className:c,children:(0,d.jsx)(ar,{className:"h-4 w-4","aria-hidden":!0})})]})}function b1({phase:a,elapsed:b,canvasRef:c,start:e,stop:f,discard:g,onText:h,busy:i=!1}){let j=()=>{i||("idle"===a?e():"rec"===a&&f().then(a=>{a&&h(a)}))};if("rec"===a)return(0,d.jsxs)("span",{className:"flex shrink-0 items-center gap-1",children:[(0,d.jsxs)("button",{type:"button","aria-label":"Зупинити запис і розпізнати",onClick:j,className:"flex items-center gap-1.5 rounded-[8px] border border-err/50 bg-[#fff2f2] px-2 py-2 text-[11px] font-bold text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-err/40",children:[(0,d.jsx)("canvas",{ref:c,width:56,height:16,className:"h-4 w-14","aria-hidden":!0}),`${Math.floor(b/60)}:${String(b%60).padStart(2,"0")}`]}),(0,d.jsx)("button",{type:"button","aria-label":"Скасувати запис",onClick:g,className:"inline-flex items-center justify-center rounded-[8px] border border-line bg-panel p-2 text-dim hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",children:(0,d.jsx)(l,{className:"h-3.5 w-3.5","aria-hidden":!0})})]});return(0,d.jsx)("button",{type:"button","aria-label":"busy"===a?"Розпізнаю…":"Надиктувати",title:"busy"===a?"розпізнаю…":"надиктувати (до 2 хв)",disabled:"busy"===a||i,onClick:j,className:"inline-flex shrink-0 items-center justify-center rounded-[8px] border border-line bg-panel p-2 text-dim hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-60",children:"busy"===a?(0,d.jsx)(aH,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):(0,d.jsx)(au,{className:"h-4 w-4","aria-hidden":!0})})}function b2(a){return"claude-projects"===a.root?"сесія"===a.kind||"субагент"===a.kind:"codex-sessions"===a.root}function b3({file:a}){let b=function(a,b){let[c,d]=(0,e.useState)(null);return null!==a||b?c:null}(a.pid,b2(a)?a.path:void 0),[c,f]=(0,e.useState)(()=>""),g=(0,e.useRef)(c),h=b=>{let c="function"==typeof b?b(g.current):b;(g.current=c,f(c),c)?sessionStorage.setItem("llvDraft:"+a.path,c):sessionStorage.removeItem("llvDraft:"+a.path)},[i,j]=(0,e.useState)(!1),[k,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(null),[r,s]=(0,e.useState)([]),t=(0,e.useRef)(null),u=b$({onError:a=>q({kind:"err",text:a}),onAdded:()=>q(null)}),v=a=>{h(b=>b?b.trimEnd()+" "+a:a),q(null),t.current?.focus()},w=bX({onError:a=>q({kind:"err",text:a}),onUnclaimedText:v}),x=b2(a);if(null===b&&!x)return null;let y=null===b,z=y&&"claude-projects"===a.root&&"субагент"===a.kind,A=b=>{s(b),sessionStorage.setItem("llvSent:"+a.path,JSON.stringify(b))},B=async b=>{let d=b??c;if(!i&&!k&&(d.trim()||u.images.length)){j(!0),q(null);try{let b=await fetch("/api/tmux",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({pid:a.pid??void 0,path:a.path,text:d,images:u.images.map(a=>({base64:a.base64,mime:a.mime}))})}),c=await b.json();if(!b.ok||!c.ok)return void q({kind:"err",text:c.error??"не вдалося надіслати"});let e=u.images.length,f={id:Date.now(),text:d.trim()||(e?`${e} ${1===e?"картинка":"картинки"}`:""),at:Date.now(),via:c.spawned?"spawn":"pane"};A([...r,f].slice(-8)),h(""),u.clear(),q({kind:"ok",text:c.spawned?`запущено агента в tmux ${c.target??""}`:c.imagePaths?.length?`надіслано ${c.imagePaths.length} шлях(и)`:"надіслано"}),t.current?.focus()}catch{q({kind:"err",text:"сервер недоступний"})}finally{j(!1)}}},C=async()=>{if(!i&&!k){m(!0);try{let a=await w.stop();if(null===a)return;let b=g.current?g.current.trimEnd()+" "+a:a;h(b),await B(b)}finally{m(!1)}}},D=async()=>{if(!n){o(!0),q(null);try{let b=await fetch("/api/tmux",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"interrupt",path:a.path})}),c=await b.json();if(!b.ok||!c.ok)return void q({kind:"err",text:c.error??"не вдалося перервати"});q({kind:"ok",text:"надіслано Escape — агент перервано"})}catch{q({kind:"err",text:"сервер недоступний"})}finally{o(!1)}}},E="rec"===w.phase,F="busy"===w.phase,G=!i&&!k&&!F&&(E||!!c.trim()||u.images.length>0),H=i||k;return(0,d.jsxs)("form",{onSubmit:a=>{a.preventDefault(),B()},className:"flex shrink-0 flex-col gap-1.5 border-t border-line bg-[#fbfbfd] px-2.5 py-2","aria-label":y?"Запустити агента з промптом у tmux":`Надіслати повідомлення агенту в tmux ${b}`,children:[r.length?(0,d.jsx)("div",{className:"flex flex-col gap-0.5","aria-label":"Черга надісланих повідомлень",children:r.map(a=>(0,d.jsxs)("div",{className:"flex items-center justify-end gap-1.5",children:[(0,d.jsx)("span",{className:"min-w-0 max-w-[85%] truncate rounded-[10px] rounded-br-[3px] bg-[#ecebfb] px-2 py-0.5 text-[11px] text-[#333]",title:a.text,children:a.text}),(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-0.5 text-[9.5px] text-dim",children:["spawn"===a.via?(0,d.jsx)(av,{className:"h-2.5 w-2.5","aria-hidden":!0}):(0,d.jsx)(ai,{className:"h-2.5 w-2.5","aria-hidden":!0}),new Date(a.at).toLocaleTimeString("uk",{hour12:!1,hour:"2-digit",minute:"2-digit"})]}),(0,d.jsx)("button",{type:"button","aria-label":"Прибрати з черги",className:"inline-flex shrink-0 items-center rounded px-0.5 text-dim hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>A(r.filter(b=>b.id!==a.id)),children:(0,d.jsx)(l,{className:"h-3 w-3","aria-hidden":!0})})]},a.id))}):null,(0,d.jsx)("textarea",{ref:t,value:c,rows:1,onChange:a=>h(a.target.value),onPaste:u.handlePaste,onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),"rec"===w.phase?C():B())},placeholder:z?"написати — передам через кореневу сесію…":y?"промпт — агент запуститься в tmux…":"написати агенту…","aria-label":"Текст для агента",disabled:H,className:"w-full resize-none overflow-y-auto rounded-[10px] border border-line bg-panel px-2.5 py-1.5 text-[12.5px] leading-[18px] text-[#222] placeholder:text-dim focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-60"}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-1.5",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:"inline-flex min-w-0 items-center gap-1 rounded-full bg-chip px-1.5 py-1 font-mono text-[9.5px] font-semibold text-[#555]",title:z?"передасться через кореневу сесію гілки":y?"нове tmux-вікно з відновленим агентом":`tmux ${b}`,children:z?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(aj,{className:"h-3 w-3 shrink-0","aria-hidden":!0})," корінь"]}):y?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(av,{className:"h-3 w-3 shrink-0","aria-hidden":!0})," resume"]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ay,{className:"h-3 w-3 shrink-0","aria-hidden":!0})," ",(0,d.jsx)("span",{className:"truncate",children:b})]})}),y?null:(0,d.jsx)("button",{type:"button","aria-label":"Перервати агента (Escape)",title:"надіслати Escape у пейн агента",disabled:n,onClick:()=>void D(),className:"inline-flex shrink-0 items-center justify-center rounded-[8px] border border-line bg-panel p-2 text-dim hover:border-err/40 hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-50",children:n?(0,d.jsx)(aH,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):(0,d.jsx)(ax,{className:"h-4 w-4",fill:"currentColor","aria-hidden":!0})})]}),(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,d.jsx)(b1,{...w,busy:k,onText:v}),(0,d.jsx)(b0,{ariaLabel:"Додати картинки",className:"inline-flex shrink-0 items-center justify-center rounded-[8px] border border-line bg-panel p-2 text-dim hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onFiles:u.addFiles}),(0,d.jsx)("button",{type:E?"button":"submit",onClick:E?()=>void C():void 0,disabled:!G,"aria-label":E?"Зупинити запис і надіслати":y?"Запустити агента":"Надіслати агенту",title:E?"зупинити запис і надіслати":void 0,className:`inline-flex shrink-0 items-center justify-center rounded-[8px] border p-2 text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 ${E?"border-err bg-err hover:opacity-90":"border-accent bg-accent hover:opacity-90"}`,children:i||k?(0,d.jsx)(aH,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):(0,d.jsx)(av,{className:"h-4 w-4","aria-hidden":!0})})]})]}),(0,d.jsx)(b_,{images:u.images,onRemove:u.removeAt}),p?(0,d.jsx)("span",{className:`truncate text-[10.5px] font-semibold ${"ok"===p.kind?"text-ok":"text-err"}`,children:p.text}):null]})}let b4=()=>void 0,b5={live:{section:"border-ok/60 shadow-[0_0_0_3px_rgba(47,158,68,0.16)]",header:"bg-[#eef8f0]"},waiting:{section:"border-[#e0ae45]/60 shadow-[0_0_0_3px_rgba(224,174,69,0.2)]",header:"bg-[#fff7e6]",glow:"#e0ae45"},returned:{section:"border-accent/50 shadow-[0_0_0_3px_rgba(90,81,224,0.15)]",header:"bg-[#f1f0fc]",glow:"#7a6ff0"},stalled:{section:"border-err/50 shadow-[0_0_0_3px_rgba(198,40,40,0.13)]",header:"bg-[#fdf0f0]",glow:"#d76a6a"},done:{section:"border-line",header:"bg-[#f4f4f6] text-dim opacity-80 saturate-50"}},b6={live:"працює",waiting:"закінчив хід — чекає відповіді",returned:"повернувся з результатом",stalled:"перервано або чекає дозволу",done:"завершено — можна прибрати"};function b7({file:a,files:b,tasks:c,onSelect:f,isRoot:g,onClose:h,dragHandle:i,noComposer:j,banner:k}){let n=(0,e.useRef)(null),o=U(a),p=function(a,b=Date.now()/1e3){return a.pendingQuestion||a.waitingInput?"waiting":"live"===a.activity?"live":"recent"===a.activity&&s(a)&&"running"!==a.proc?"returned":X(a,b)?"stalled"===a.activity?"stalled":"waiting":"done"}(a),q=b5[p];return(0,d.jsxs)("section",{ref:n,"data-pan-ignore":!0,"data-link-path":a.path,className:`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-[10px] border bg-panel shadow-card ${g?"border-t-4":"border-t-2"} ${q.section} ${q.glow?"pane-attention":""}`,style:{..."done"===p?{borderTopColor:"#c9c9d1"}:{borderTopColor:P(a).color},...q.glow?{"--pane-glow":q.glow}:null},children:[(0,d.jsxs)("header",{className:`flex h-10 shrink-0 items-center gap-1.5 border-b border-line px-2.5 ${q.header} ${i?"cursor-grab active:cursor-grabbing":""}`,...i,children:[(0,d.jsx)("span",{className:`h-2 w-2 shrink-0 rounded-full ${K(a.activity)}`,title:b6[p]}),a.model?(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 py-0.5 font-mono text-[9.5px] font-semibold",style:{backgroundColor:S(a).soft,color:S(a).color},title:[o.label,T(a)].filter(Boolean).join(" \xb7 "),children:a.model}):(0,d.jsx)("span",{className:"inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-[10px] font-bold",style:o.style,children:o.label}),a.ctx?(0,d.jsx)(bV,{ctx:a.ctx}):null,a.worktree?(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-0.5 rounded-full border border-line/80 px-1.5 py-0.5 font-mono text-[9.5px] text-dim",title:`Ворк-дерево ${a.worktree}`,children:[(0,d.jsx)(ad,{className:"h-2.5 w-2.5","aria-hidden":!0})," ",a.worktree]}):null,a.plan?(0,d.jsx)(bT,{plan:a.plan}):null,a.goal?(0,d.jsx)(bW,{goal:a.goal}):null,g?null:(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-0.5 text-[10px] text-dim",title:a.handoff?"агент, породжений хендоффом цієї розмови":"гілка цієї розмови",children:[(0,d.jsx)(ae,{className:"h-3 w-3","aria-hidden":!0})," ",a.handoff?"хендофф":a.kind]}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold",title:m(a.title),children:m(a.title,90)}),(0,d.jsx)(aW,{file:a,compact:!0}),(0,d.jsx)(aR,{file:a,onDeleted:h}),h?(0,d.jsx)("button",{className:"inline-flex shrink-0 items-center rounded-[8px] border border-line bg-bg px-1.5 py-0.5 text-dim hover:border-err/40 hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":`Прибрати колонку ${m(a.title,60)}`,onClick:h,children:(0,d.jsx)(l,{className:"h-3 w-3","aria-hidden":!0})}):null]}),k??null,c.length?(0,d.jsx)(aS,{className:"shrink-0 border-b border-line bg-[#fbfbfd]",enter:"fade",children:c.map(a=>(0,d.jsx)("div",{"data-flip-key":a.path,children:(0,d.jsx)(b8,{file:a,files:b,onSelect:f})},a.path))}):null,(0,d.jsx)(bR,{file:a,files:b,onSelect:f,showSvc:!1,lineFilter:"",onStatus:b4,paused:!1,follow:!0,setFollow:b4,compact:!0}),j?null:(0,d.jsx)(b3,{file:a}),("claude-projects"===a.root||"codex-sessions"===a.root)&&a.path.endsWith(".jsonl")?(0,d.jsx)(aZ,{file:a,paneRef:n}):null]})}function b8({file:a,files:b,onSelect:c}){let[f,g]=(0,e.useState)(!1),h=m(a.cmdDesc||a.title,80);return(0,d.jsxs)("div",{className:"border-t border-line first:border-t-0",children:[(0,d.jsxs)("div",{className:"flex h-7 items-center gap-1.5 pl-2 pr-2.5",children:[(0,d.jsxs)("button",{className:"flex h-full min-w-0 flex-1 items-center gap-1.5 rounded-[6px] text-left hover:bg-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-expanded":f,"aria-label":`${f?"Згорнути":"Розгорнути"} фонову задачу ${h}`,onClick:()=>g(a=>!a),children:[(0,d.jsx)(an,{className:`h-3.5 w-3.5 shrink-0 text-dim transition-transform ${f?"rotate-90":""}`,"aria-hidden":!0}),(0,d.jsx)("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${K(a.activity)}`}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold",title:m(a.title),children:h})]}),(0,d.jsx)(aW,{file:a,compact:!0})]}),f?(0,d.jsx)("div",{className:"flex h-[220px] flex-col border-t border-dashed border-line bg-bg/60",children:(0,d.jsx)(bR,{file:a,files:b,onSelect:c,showSvc:!1,lineFilter:"",onStatus:b4,paused:!1,follow:!0,setFollow:b4,compact:!0})}):null]})}let b9=[{key:"claude",label:"Claude"},{key:"codex",label:"Codex"}],ca=(a,b)=>`llvDraftPane:${a}:${b}`;function cb(a,b,c){c?sessionStorage.setItem(ca(a,b),c):sessionStorage.removeItem(ca(a,b))}function cc({draftId:a,project:b,files:c,onClose:f,onSpawned:g}){let[h,i]=(0,e.useState)(()=>"claude"),[j,k]=(0,e.useState)(()=>""),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(()=>""),[q,r]=(0,e.useState)(()=>(function(){try{let a=JSON.parse("null");return a&&"number"==typeof a.at&&"string"==typeof a.prompt?a:null}catch{return null}})()),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(null),A=(0,e.useRef)(null),B=(0,e.useRef)(null),C=(0,e.useRef)(o),D=b=>{let c="function"==typeof b?b(C.current):b;C.current=c,p(c),cb(a,"text",c)},E=b$({onError:a=>z({kind:"err",text:a}),onAdded:()=>z(null)}),F=a=>{D(b=>b?b.trimEnd()+" "+a:a),z(null),A.current?.focus()},G=bX({onError:a=>z({kind:"err",text:a}),onUnclaimedText:F}),H=async b=>{let d=b??o;if(!s&&!u&&!q){if(!j.trim())return void z({kind:"err",text:"вкажи робочу директорію"});if(d.trim()||E.images.length){t(!0),z(null);try{var e;let b=await fetch("/api/spawn",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({engine:h,cwd:j.trim(),prompt:d,images:E.images.map(a=>({base64:a.base64,mime:a.mime}))})}),f=await b.json();if(!b.ok||!f.ok)return void z({kind:"err",text:f.error??"не вдалося запустити"});B.current=new Set(c.map(a=>a.path)),e={at:Date.now(),target:f.target??"",path:f.path??null,prompt:d.trim()},r(e),cb(a,"boot",e?JSON.stringify(e):""),D(""),E.clear()}catch{z({kind:"err",text:"сервер недоступний"})}finally{t(!1)}}}},I=async()=>{if(!s&&!u){v(!0);try{let a=await G.stop();if(null===a)return;let b=C.current?C.current.trimEnd()+" "+a:a;D(b),await H(b)}finally{v(!1)}}},J=L[h]??M,K="rec"===G.phase,N="busy"===G.phase,O=s||u||!!q,P=!O&&!N&&(K||!!o.trim()||E.images.length>0),Q="draft-dirs-"+a;return(0,d.jsxs)("section",{"data-pan-ignore":!0,className:"relative flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-[10px] border border-t-4 border-line bg-panel shadow-card",style:{borderTopColor:J.color},"aria-label":"Чернетка нової розмови з агентом",children:[(0,d.jsxs)("header",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-line px-2.5",style:{backgroundColor:J.soft},children:[(0,d.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[#c9c9d1]",title:"агент ще не запущений"}),(0,d.jsx)("div",{className:"flex shrink-0 items-center gap-1",role:"radiogroup","aria-label":"Двигун агента",children:b9.map(({key:b,label:c})=>{let e=h===b,f=L[b]??M;return(0,d.jsx)("button",{type:"button",role:"radio","aria-checked":e,disabled:O,onClick:()=>{i(b),cb(a,"engine",b)},style:e?{backgroundColor:"#fff",color:f.color,borderColor:f.color}:void 0,className:`rounded-full border px-2 py-0.5 text-[10.5px] font-bold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-60 ${e?"":"border-transparent bg-transparent text-dim hover:text-ink"}`,children:c},b)})}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12px] font-semibold text-dim",children:"нова розмова"}),(0,d.jsx)("button",{className:"inline-flex shrink-0 items-center rounded-[8px] border border-line bg-bg px-1.5 py-0.5 text-dim hover:border-err/40 hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":"Прибрати чернетку розмови",onClick:f,children:(0,d.jsx)(l,{className:"h-3 w-3","aria-hidden":!0})})]}),(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5 border-b border-line bg-[#fbfbfd] px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"shrink-0 text-[10px] font-semibold text-dim",children:"директорія"}),(0,d.jsx)("input",{value:j,disabled:O,onChange:b=>{var c;k(c=b.target.value),cb(a,"cwd",c)},list:Q,placeholder:"/home/…/Projects/…","aria-label":"Робоча директорія агента",className:"min-w-0 flex-1 rounded-[6px] border border-line bg-panel px-2 py-1 font-mono text-[11px] text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-60"}),(0,d.jsx)("datalist",{id:Q,children:m.map(a=>(0,d.jsx)("option",{value:a},a))})]}),(0,d.jsx)("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-4 py-4",children:q?(0,d.jsxs)("div",{className:"flex flex-1 flex-col justify-end gap-3",children:[(0,d.jsx)("div",{className:"flex justify-end",children:(0,d.jsx)("span",{className:"min-w-0 max-w-[85%] whitespace-pre-wrap rounded-[10px] rounded-br-[3px] bg-[#ecebfb] px-2.5 py-1.5 text-[12px] text-[#333]",children:q.prompt||"(картинки)"})}),(0,d.jsxs)("div",{className:"flex items-center gap-2 text-[11.5px] font-semibold text-dim",children:[(0,d.jsx)(aH,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}),(0,d.jsxs)("span",{children:["агент запущений у tmux ",q.target,"— чекаю, поки розмова з'явиться тут…"]})]}),w?(0,d.jsxs)("div",{className:"text-[11px] text-dim",children:["Щось довго. Перевір вікно tmux ",q.target,"— щойно транскрипт з'явиться, панель підхопить його сама."]}):null]}):(0,d.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-center",children:[(0,d.jsx)("span",{className:"rounded-full px-3 py-1 text-[13px] font-bold",style:{backgroundColor:J.soft,color:J.color},children:"claude"===h?"Claude":"Codex"}),(0,d.jsx)("div",{className:"max-w-[360px] text-[12px] text-dim",children:"Обери двигун і директорію, напиши перший промпт — агент запуститься в tmux, і розмова продовжиться в цій самій панелі."})]})}),(0,d.jsxs)("form",{onSubmit:a=>{a.preventDefault(),H()},className:"flex shrink-0 flex-col gap-1.5 border-t border-line bg-[#fbfbfd] px-2.5 py-2","aria-label":"Перший промпт для нового агента",children:[(0,d.jsx)("textarea",{ref:A,value:o,rows:1,onChange:a=>D(a.target.value),onPaste:E.handlePaste,onKeyDown:a=>{"Enter"!==a.key||a.shiftKey||a.nativeEvent.isComposing||(a.preventDefault(),"rec"===G.phase?I():H())},placeholder:"перший промпт — агент запуститься в tmux…","aria-label":"Текст першого промпта",disabled:O,className:"w-full resize-none overflow-y-auto rounded-[10px] border border-line bg-panel px-2.5 py-1.5 text-[12.5px] leading-[18px] text-[#222] placeholder:text-dim focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-60"}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-1.5",children:[(0,d.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1 rounded-full bg-chip px-1.5 py-1 font-mono text-[9.5px] font-semibold text-[#555]",title:"нове tmux-вікно зі свіжим агентом",children:[(0,d.jsx)(av,{className:"h-3 w-3 shrink-0","aria-hidden":!0})," новий агент"]}),(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,d.jsx)(b1,{...G,busy:u,onText:F}),(0,d.jsx)(b0,{ariaLabel:"Додати картинки до промпта",className:"inline-flex shrink-0 items-center justify-center rounded-[8px] border border-line bg-panel p-2 text-dim hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onFiles:E.addFiles}),(0,d.jsx)("button",{type:K?"button":"submit",onClick:K?()=>void I():void 0,disabled:!P,"aria-label":K?"Зупинити запис і запустити агента":"Запустити агента",style:K?void 0:{backgroundColor:J.color,borderColor:J.color},className:`inline-flex shrink-0 items-center justify-center rounded-[8px] border p-2 text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 ${K?"border-err bg-err hover:opacity-90":"hover:opacity-90"}`,children:s||u?(0,d.jsx)(aH,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):(0,d.jsx)(av,{className:"h-4 w-4","aria-hidden":!0})})]})]}),(0,d.jsx)(b_,{images:E.images,onRemove:E.removeAt}),y?(0,d.jsx)("span",{className:`truncate text-[10.5px] font-semibold ${"ok"===y.kind?"text-ok":"text-err"}`,children:y.text}):null]})]})}let cd=k("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]),ce=k("hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]),cf=k("mouse-pointer-2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]),cg=k("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),ch=["low","medium","high","xhigh"],ci={implementer:{engine:"claude",model:null,effort:null},reviewer:{engine:"codex",model:null,effort:"xhigh"}};function cj({label:a,role:b,onChange:c}){return(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:"w-[86px] shrink-0 text-[10.5px] font-semibold text-dim",children:a}),(0,d.jsxs)("select",{value:b.engine,"aria-label":`Двигун: ${a}`,className:"h-7 rounded-[8px] border border-line bg-bg px-1.5 text-[11.5px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onChange:a=>c({...b,engine:a.target.value,effort:null}),children:[(0,d.jsx)("option",{value:"claude",children:"Claude"}),(0,d.jsx)("option",{value:"codex",children:"Codex"})]}),(0,d.jsx)("input",{value:b.model??"",placeholder:"модель (дефолт)","aria-label":`Модель: ${a}`,className:"h-7 w-0 min-w-0 flex-1 rounded-[8px] border border-line bg-bg px-1.5 font-mono text-[11px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onChange:a=>c({...b,model:a.target.value.trim()||null})}),"codex"===b.engine?(0,d.jsxs)("select",{value:b.effort??"","aria-label":`Reasoning effort: ${a}`,className:"h-7 rounded-[8px] border border-line bg-bg px-1.5 text-[11.5px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onChange:a=>c({...b,effort:a.target.value||null}),children:[(0,d.jsx)("option",{value:"",children:"effort: дефолт"}),ch.map(a=>(0,d.jsx)("option",{value:a,children:a},a))]}):null]})}function ck({file:a,onClose:b}){let[c,f]=(0,e.useState)([]),[g,h]=(0,e.useState)(null),[i,j]=(0,e.useState)(ci),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)("head"),[o,p]=(0,e.useState)("auto"),[q,r]=(0,e.useState)("headless"),[s,t]=(0,e.useState)(5),[u,v]=(0,e.useState)(!1),[w,x]=(0,e.useState)(null),y=async()=>{if(!u){v(!0),x(null);try{let c=await fetch("/api/flows",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({implementerPath:a.path,...k||!g?{roles:i}:{preset:g},baseMode:m,mode:o,reviewerMode:q,roundLimit:s})});if(!c.ok){let a=await c.json().catch(()=>null);x(a?.error??`не вдалося створити флоу (${c.status})`);return}b()}catch{x("сервер недоступний")}finally{v(!1)}}};return(0,d.jsxs)("div",{"data-scheme-ui":!0,className:"flex w-[420px] flex-col gap-2.5 rounded-[12px] border border-line bg-panel p-3 shadow-[0_10px_36px_rgb(20_20_30/0.18)]",onKeyDown:a=>{"Escape"===a.key&&b()},children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-[12.5px] font-bold",children:"Запустити флоу"}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[10.5px] text-dim",children:"implement → review \xb7 ця розмова стає виконавцем"})]}),c.length?(0,d.jsxs)("label",{className:"flex flex-col gap-1 text-[10.5px] font-semibold text-dim",children:["пресет",(0,d.jsx)("select",{value:g??"",className:"h-8 rounded-[8px] border border-line bg-bg px-2 text-[12px] font-normal text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onChange:a=>{var b;let d;return h(b=a.target.value),void((d=c.find(a=>a.name===b))&&j({implementer:d.implementer,reviewer:d.reviewer}))},children:c.map(a=>(0,d.jsx)("option",{value:a.name,children:a.name},a.name))})]}):null,(0,d.jsx)("button",{className:"self-start text-[10.5px] font-semibold text-dim hover:text-accent focus-visible:outline-none","aria-expanded":k,onClick:()=>l(a=>!a),children:k?"▾ ролі вручну":"▸ ролі вручну (модель / effort)"}),k?(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 rounded-[10px] border border-dashed border-line bg-bg/50 p-2",children:[(0,d.jsx)(cj,{label:"виконавець",role:i.implementer,onChange:a=>j(b=>({...b,implementer:a}))}),(0,d.jsx)(cj,{label:"ревʼюер",role:i.reviewer,onChange:a=>j(b=>({...b,reviewer:a}))})]}):null,(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,d.jsxs)("label",{className:"flex flex-col gap-1 text-[10.5px] font-semibold text-dim",children:["база діфу",(0,d.jsxs)("select",{value:m,className:"h-8 rounded-[8px] border border-line bg-bg px-2 text-[11.5px] font-normal text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onChange:a=>n(a.target.value),children:[(0,d.jsx)("option",{value:"head",children:"від поточного HEAD"}),(0,d.jsx)("option",{value:"merge-base",children:"від merge-base з main"})]})]}),(0,d.jsxs)("label",{className:"flex flex-col gap-1 text-[10.5px] font-semibold text-dim",children:["ревʼюер",(0,d.jsxs)("select",{value:q,className:"h-8 rounded-[8px] border border-line bg-bg px-2 text-[11.5px] font-normal text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onChange:a=>r(a.target.value),children:[(0,d.jsx)("option",{value:"headless",children:"headless (без панелі)"}),(0,d.jsx)("option",{value:"pane",children:"tmux-панель"})]})]}),(0,d.jsxs)("label",{className:"flex flex-col gap-1 text-[10.5px] font-semibold text-dim",children:["переходи",(0,d.jsxs)("select",{value:o,className:"h-8 rounded-[8px] border border-line bg-bg px-2 text-[11.5px] font-normal text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onChange:a=>p(a.target.value),children:[(0,d.jsx)("option",{value:"auto",children:"авто"}),(0,d.jsx)("option",{value:"manual",children:"вручну (гейт на кожен крок)"})]})]}),(0,d.jsxs)("label",{className:"flex flex-col gap-1 text-[10.5px] font-semibold text-dim",children:["ліміт раундів",(0,d.jsx)("input",{type:"number",min:1,max:20,value:s,className:"h-8 rounded-[8px] border border-line bg-bg px-2 text-[11.5px] font-normal text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onChange:a=>t(Math.max(1,Math.min(20,Number(a.target.value)||5)))})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[w?(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[10.5px] font-semibold text-err",children:w}):(0,d.jsx)("span",{className:"flex-1"}),(0,d.jsx)("button",{className:"rounded-[8px] border border-line bg-bg px-2.5 py-1.5 text-[11.5px] font-semibold text-dim hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:b,children:"Скасувати"}),(0,d.jsx)("button",{className:"rounded-[8px] border border-accent bg-accent px-3 py-1.5 text-[12px] font-bold text-white hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40",disabled:u,onClick:()=>void y(),children:u?"створюю…":"▶ Запустити"})]})]})}let cl=k("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),cm={waiting_ready:{label:"Почати ревью",action:"advance"},spawn_pending:{label:"Заспавнити ревʼюера",action:"advance"},relay_pending:{label:"Передати зауваження",action:"advance"},needs_decision:{label:"Повторити раунд",action:"retry-round"},done_comment:{label:"Ще коло",action:"another-round"}},cn=new Set(["spawning","reviewing","relaying","fixing"]);function co({flow:a,onFocusRound:b}){let[c,f]=(0,e.useState)(!1),[g,h]=(0,e.useState)(null),i=async(b,d)=>{if(c)return;f(!0),h(null);let e=await G(a.id,{action:b,...d});e&&h(e),f(!1)},j=cm[a.state],k=D.has(a.state),m="closed"===a.state||"approved"===a.state;return(0,d.jsxs)("div",{"data-scheme-ui":!0,className:`pointer-events-auto flex h-8 max-w-full items-center gap-1.5 overflow-x-auto rounded-full border bg-panel px-2 shadow-card ${k?"border-[#e0ae45]/70":"border-line"}`,children:[(0,d.jsx)("span",{className:`h-2 w-2 shrink-0 rounded-full ${"approved"===a.state?"bg-ok":"needs_decision"===a.state?"bg-err":"paused"===a.state?"bg-[#e0ae45]":cn.has(a.state)?"bg-ok animate-pulse":"bg-[#9a9aa4]"}`,"aria-hidden":!0}),(0,d.jsx)("span",{className:"shrink-0 text-[10.5px] font-bold tracking-wide text-dim",children:"ФЛОУ"}),(0,d.jsxs)("span",{className:"shrink-0 text-[11px] font-semibold",title:a.stateDetail??void 0,children:[C[a.state],a.stateDetail?(0,d.jsxs)("span",{className:"text-dim",children:[" \xb7 ",a.stateDetail]}):null]}),a.rounds.length?(0,d.jsx)("span",{className:"flex shrink-0 items-center gap-1","aria-label":"Раунди ревью",children:a.rounds.map(a=>{let c=F(a.verdict),e=null===a.verdict&&!a.error;return(0,d.jsxs)("button",{className:`inline-flex h-5 items-center gap-0.5 rounded-full px-1.5 text-[10px] font-bold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 ${e?"animate-pulse":""}`,style:{backgroundColor:c.soft,color:c.color},title:a.error?`Раунд ${a.n}: ${a.error}`:a.verdict?`Раунд ${a.n}: ${a.verdict}${null!=a.findingsCount?` \xb7 ${a.findingsCount} знахідок`:""}`:`Раунд ${a.n}: триває`,onClick:()=>b?.(a.n),children:["R",a.n,a.verdict?(0,d.jsx)("span",{children:E[a.verdict]}):e?(0,d.jsx)("span",{children:"⏳"}):(0,d.jsx)("span",{children:"!"}),null!=a.findingsCount&&a.findingsCount>0?(0,d.jsx)("span",{children:a.findingsCount}):null]},a.n)})}):null,j?(0,d.jsx)("button",{className:"shrink-0 rounded-full border border-accent bg-accent px-2.5 py-0.5 text-[11px] font-bold text-white hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40",disabled:c,onClick:()=>void i(j.action),children:j.label}):null,"needs_decision"===a.state?(0,d.jsx)("button",{className:"shrink-0 rounded-full border border-line bg-bg px-2 py-0.5 text-[10.5px] font-semibold text-ink hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-40",disabled:c,title:"Додати ще раунди до ліміту",onClick:()=>void i("extend",{rounds:2}),children:"+2 раунди"}):null,m?null:(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("button",{className:`shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-bold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-40 ${"auto"===a.mode?"border-ok/40 bg-[#eef8f0] text-ok":"border-line bg-bg text-dim hover:text-ink"}`,disabled:c,title:"auto"===a.mode?"Авто: переходи самі. Клік — вручну.":"Вручну: кожен перехід чекає кліку. Клік — авто.",onClick:()=>void i("set-mode",{mode:"auto"===a.mode?"manual":"auto"}),children:"auto"===a.mode?"авто":"вручну"}),"paused"===a.state?(0,d.jsx)("button",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-ok hover:bg-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-40",disabled:c,title:"Продовжити флоу","aria-label":"Продовжити флоу",onClick:()=>void i("resume"),children:(0,d.jsx)(av,{className:"h-3.5 w-3.5","aria-hidden":!0})}):(0,d.jsx)("button",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-dim hover:bg-bg hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-40",disabled:c,title:"Пауза","aria-label":"Пауза",onClick:()=>void i("pause"),children:(0,d.jsx)(bN,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),c?(0,d.jsx)(cl,{className:"h-3 w-3 shrink-0 animate-spin text-dim","aria-hidden":!0}):null,g?(0,d.jsx)("span",{className:"shrink-0 text-[10.5px] font-semibold text-err",children:g}):null,(0,d.jsx)("button",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-dim hover:bg-bg hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-40",disabled:c,title:"Закрити флоу","aria-label":"Закрити флоу",onClick:()=>void i("close"),children:(0,d.jsx)(l,{className:"h-3 w-3","aria-hidden":!0})})]})}function cp(a){return a.error?`Раунд ${a.n} \xb7 перервано`:a.verdict?`Раунд ${a.n} \xb7 ${E[a.verdict]} ${a.verdict}`:`Раунд ${a.n} \xb7 триває`}function cq({round:a,depth:b,pulse:c,onPull:e}){let f=F(a.verdict);return(0,d.jsxs)("button",{className:`deck-tab absolute inset-x-0 flex items-center gap-1.5 rounded-[9px] border bg-panel px-2.5 text-left shadow-card focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 ${c?"deck-tab-live border-ok/50":"border-line hover:border-accent/45"}`,style:{height:36,bottom:-(30*b)-10,zIndex:10-b,transform:`scale(${1-.035*b}) translateZ(${-(34*b)}px)`},title:a.error?`${cp(a)}: ${a.error}`:cp(a),onClick:e,children:[(0,d.jsxs)("span",{className:"inline-flex h-4 shrink-0 items-center gap-1 rounded-full px-1.5 text-[9.5px] font-bold",style:{backgroundColor:f.soft,color:f.color},children:["R",a.n," ",a.verdict?E[a.verdict]:a.error?"!":"⏳"]}),(0,d.jsxs)("span",{className:"min-w-0 flex-1 truncate text-[10.5px] font-semibold text-dim",children:[a.error?"перервано":a.verdict?a.verdict:"ревью триває",null!=a.findingsCount&&a.findingsCount>0?` \xb7 ${a.findingsCount} знахідок`:""]}),c?(0,d.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-ok","aria-hidden":!0}):null]})}function cr({flow:a,rounds:b,files:c,onSelect:f,focusRound:g}){let h=b.length?b[b.length-1]:null,[i,j]=(0,e.useState)(null),[k,l]=(0,e.useState)(null);null!=g&&g!==k&&(l(g),j(Math.round(g)));let[m,n]=(0,e.useState)(null);h&&h.round.n!==m&&(n(h.round.n),null!=i&&h.round.n>i&&null===h.round.verdict&&j(null));let o=(0,e.useMemo)(()=>b.find(a=>a.round.n===i)??h,[b,i,h]);if(!o)return(0,d.jsx)("div",{className:"flex h-full items-center justify-center rounded-[10px] border border-dashed border-[#c9c9d1] bg-panel/60",children:(0,d.jsx)("span",{className:"text-[12px] font-semibold text-dim",children:"чекаю на перший раунд ревью…"})});let p=b.filter(a=>a.round.n!==o.round.n).reverse(),q=p.slice(0,5),r=p.length-q.length,s=F(o.round.verdict),t=null!==o.round.verdict||!!o.round.error,u=h&&o.round.n!==h.round.n&&null===h.round.verdict&&!h.round.error?h:null;return(0,d.jsxs)("div",{className:"deck-3d relative h-full",style:{paddingBottom:30*Math.min(p.length,5+ +!!r)},children:[(0,d.jsx)("div",{className:"scheme-enter relative z-[11] flex h-full flex-col",children:o.file?(0,d.jsx)(b7,{file:o.file,files:c,tasks:[],onSelect:f,isRoot:!1,noComposer:"headless"===a.reviewerMode||t,banner:(0,d.jsxs)("div",{className:"flex h-6 shrink-0 items-center gap-1.5 border-b border-line px-2.5 text-[10.5px] font-bold",style:{backgroundColor:s.soft,color:s.color},children:[cp(o.round),null!=o.round.findingsCount&&o.round.findingsCount>0?(0,d.jsxs)("span",{className:"font-semibold opacity-80",children:["\xb7 ",o.round.findingsCount," знахідок"]}):null,o.round.readyNote?(0,d.jsxs)("span",{className:"min-w-0 flex-1 truncate font-semibold opacity-70",title:o.round.readyNote,children:["\xb7 ",o.round.readyNote]}):null]})}):(0,d.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-1 rounded-[10px] border border-line bg-panel shadow-card",children:[(0,d.jsx)("span",{className:"text-[12px] font-semibold text-dim",children:cp(o.round)}),(0,d.jsx)("span",{className:"text-[11px] text-dim",children:o.round.error?o.round.error:"запускаю ревʼюера — транскрипт зʼявиться за мить…"})]})},o.round.n),q.map((a,b)=>(0,d.jsx)(cq,{round:a.round,depth:b,pulse:u?.round.n===a.round.n,onPull:()=>j(a.round.n)},a.round.n)),r>0?(0,d.jsxs)("div",{className:"pointer-events-none absolute inset-x-6 flex items-center justify-center rounded-[9px] border border-line bg-panel/70 text-[10px] font-semibold text-dim shadow-card",style:{height:26,bottom:-(30*q.length)-8,zIndex:10-q.length},"aria-hidden":!0,children:["ще ",r," раунд(и) — клікни чипи на стрічці флоу"]}):null]})}let cs=new Set(["spawning","reviewing","relaying"]);function ct({layout:a,cam:b,vp:c,onJump:f}){let g=(0,e.useRef)(null),h=(0,e.useRef)(!1),i=Math.min(216/a.width,148/a.height),j=(216-a.width*i)/2,k=(148-a.height*i)/2,l=a=>{let b=g.current?.getBoundingClientRect();b&&f((a.clientX-b.left-j)/i,(a.clientY-b.top-k)/i)};return(0,d.jsx)("div",{ref:g,"data-scheme-ui":!0,className:"absolute bottom-3 right-3 z-40 cursor-pointer overflow-hidden rounded-[10px] border border-line bg-panel/95 shadow-card",style:{width:216,height:148},title:"Мінімапа — клікни або тягни, щоб перейти",onPointerDown:a=>{a.stopPropagation(),h.current=!0,l(a);try{a.currentTarget.setPointerCapture(a.pointerId)}catch{}},onPointerMove:a=>{h.current&&l(a)},onPointerUp:a=>{h.current=!1;try{a.currentTarget.releasePointerCapture(a.pointerId)}catch{}},onPointerCancel:()=>{h.current=!1},children:(0,d.jsx)("svg",{width:216,height:148,"aria-hidden":!0,children:(0,d.jsxs)("g",{transform:`translate(${j} ${k}) scale(${i})`,children:[a.stacks.map(a=>(0,d.jsx)("rect",{x:a.x,y:a.y,width:a.w,height:a.h,rx:18,fill:"#c9c9d1",opacity:.45},a.key)),a.drafts.map(a=>(0,d.jsx)("rect",{x:a.x,y:a.y,width:a.w,height:a.h,rx:18,fill:"#9a9aa4",opacity:.3},a.key)),a.nodes.map(a=>(0,d.jsx)("rect",{x:a.x,y:a.y,width:a.w,height:a.h,rx:18,fill:P(a.file).color,opacity:"live"===a.file.activity?.85:.35},a.file.path)),(0,d.jsx)("rect",{x:-b.x/b.z,y:-b.y/b.z,width:c.w/b.z,height:c.h/b.z,fill:"rgba(90,81,224,0.08)",stroke:"#5a51e0",strokeWidth:2.5/i})]})})})}let cu="cubic-bezier(.22,.8,.36,1)",cv=`transform 380ms ${cu}`,cw=(0,e.memo)(function({edges:a,width:b,height:c}){return(0,d.jsx)("svg",{width:b,height:c,className:"absolute left-0 top-0","aria-hidden":!0,children:a.map(a=>{let b=Math.max(36,(a.y2-a.y1)*.5),c=`M ${a.x1} ${a.y1} C ${a.x1} ${a.y1+b}, ${a.x2} ${a.y2-b}, ${a.x2} ${a.y2-7}`,e=`M ${a.x2-5} ${a.y2-9} L ${a.x2+5} ${a.y2-9} L ${a.x2} ${a.y2-1} Z`;return(0,d.jsxs)("g",{opacity:a.live?.9:.5,children:[(0,d.jsx)("path",{d:c,style:{d:`path("${c}")`,transition:`d 380ms ${cu}`},fill:"none",stroke:a.color,strokeWidth:2.5,strokeLinecap:"round",strokeDasharray:a.dashed?"5 7":void 0}),(0,d.jsx)("circle",{cx:a.x1,cy:a.y1,r:3.5,fill:a.color,style:{cx:`${a.x1}px`,cy:`${a.y1}px`,transition:`cx 380ms ${cu}, cy 380ms ${cu}`}}),(0,d.jsx)("path",{d:e,style:{d:`path("${e}")`,transition:`d 380ms ${cu}`},fill:a.color})]},a.to)})})});function cx({file:a,onSelect:b}){let c=U(a);return(0,d.jsxs)("button",{className:"flex h-8 w-full min-w-0 items-center gap-1.5 rounded-[8px] px-2 text-left hover:bg-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",title:m(a.title),onClick:()=>b(a),children:[(0,d.jsx)("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${K(a.activity)}`}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 text-[9px] font-bold",style:c.style,children:c.label}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold",children:m(a.cmdDesc||a.title,80)}),(0,d.jsx)("span",{className:"shrink-0 text-[10.5px] text-dim",children:H(a.mtime)})]})}function cy({file:a}){let b=U(a);return(0,d.jsx)("div",{className:"pointer-events-none absolute inset-0 z-[3] flex items-center justify-center",style:{opacity:"var(--label-o, 0)",transition:"opacity .25s"},"aria-hidden":!0,children:(0,d.jsxs)("div",{className:"flex max-w-[94%] items-center gap-[0.5em] rounded-[0.55em] border border-line bg-panel/95 px-[0.75em] py-[0.45em] shadow-[0_2px_14px_rgb(20_20_30/0.14)]",style:{fontSize:"calc(13px * min(var(--inv-z, 1), 2.6))"},children:[(0,d.jsx)("span",{className:`h-[0.6em] w-[0.6em] shrink-0 rounded-full ${K(a.activity)}`}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-[0.45em] font-bold",style:{...b.style,fontSize:"0.72em"},children:b.label}),(0,d.jsx)("span",{className:"line-clamp-2 min-w-0 font-bold",children:m(a.title,70)})]})})}function cz({stack:a,onSelect:b}){return(0,d.jsx)("div",{"data-scheme-node":a.key,className:"scheme-enter absolute",style:{transform:`translate(${a.x}px, ${a.y}px)`,width:a.w,height:a.h,transition:cv},children:(0,d.jsx)("div",{className:"flex h-full flex-col gap-1.5 overflow-y-auto rounded-[10px] border border-dashed border-[#c9c9d1] bg-panel/60 p-2",children:a.items.map(({file:a,branches:c})=>{let e=U(a);return(0,d.jsxs)("button",{className:"flex min-h-[52px] w-full min-w-0 flex-col justify-center gap-0.5 rounded-[8px] border border-line bg-panel px-2 py-1 text-left shadow-card hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",title:m(a.title),onClick:()=>b(a),children:[(0,d.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${K(a.activity)}`}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 text-[9px] font-bold",style:e.style,children:e.label}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold",children:m(a.title,70)})]}),(0,d.jsxs)("span",{className:"flex items-center gap-2 pl-3 text-[10.5px] text-dim",children:[(0,d.jsx)("span",{children:a.kind}),(0,d.jsx)("span",{children:H(a.mtime)}),c?(0,d.jsxs)("span",{children:["⤷ ",c]}):null]})]},a.path)})})})}function cA({node:a,files:b,ringed:c,flow:f,canFlow:g,onSelect:h,onClose:i,onFocusRound:j}){let[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(!1);return(0,d.jsxs)("div",{"data-scheme-node":a.file.path,className:`scheme-enter absolute ${k||m?"z-20":""}`,style:{transform:`translate(${a.x}px, ${a.y}px)`,width:a.w,height:a.h,transition:cv},children:[f?(0,d.jsx)("div",{className:"absolute inset-x-0 -top-10 z-[4] flex justify-center",children:(0,d.jsx)(co,{flow:f,onFocusRound:a=>j(f.id,a)})}):g?(0,d.jsx)("div",{className:"absolute -top-10 left-0 z-[4]",children:(0,d.jsxs)("button",{"data-scheme-ui":!0,className:"inline-flex h-7 items-center gap-1 rounded-full border border-line bg-panel px-2.5 text-[11px] font-semibold text-dim shadow-card hover:border-accent/45 hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-expanded":m,title:"Запустити цикл implement → review для цієї розмови",onClick:()=>n(a=>!a),children:[(0,d.jsx)("span",{className:"text-[13px] leading-none text-accent",children:"⟳"})," Флоу"]})}):null,m?(0,d.jsx)("div",{className:"absolute left-0 top-[-8px] z-40 -translate-y-full",children:(0,d.jsx)(ck,{file:a.file,onClose:()=>n(!1)})}):null,a.under.length?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"absolute inset-x-4 -bottom-4 h-5 rounded-[10px] border border-line bg-panel/70 shadow-card","aria-hidden":!0}),(0,d.jsx)("div",{className:"absolute inset-x-2 -bottom-2 h-5 rounded-[10px] border border-line bg-panel/90 shadow-card","aria-hidden":!0})]}):null,(0,d.jsx)("div",{className:`relative z-[1] flex h-full ${c?"rounded-[10px] ring-2 ring-accent/60":""}`,children:(0,d.jsx)(b7,{file:a.file,tasks:a.tasks,files:b,onSelect:h,isRoot:a.isRoot,onClose:()=>i(a.file.path)})}),(0,d.jsx)(cy,{file:a.file}),a.under.length?(0,d.jsxs)("button",{className:"absolute -bottom-11 left-1/2 z-[2] inline-flex h-7 -translate-x-1/2 items-center gap-1.5 whitespace-nowrap rounded-full border border-line bg-panel px-2.5 text-[11px] font-semibold text-dim shadow-card hover:border-accent/40 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-expanded":k,title:"Згорнуті гілки й задачі цієї розмови",onClick:()=>l(a=>!a),children:[(0,d.jsx)(cd,{className:"h-3.5 w-3.5","aria-hidden":!0}),a.under.length," під сподом",(0,d.jsx)(an,{className:`h-3 w-3 transition-transform ${k?"rotate-90":""}`,"aria-hidden":!0})]}):null,k?(0,d.jsx)("div",{className:"absolute left-0 top-[calc(100%+52px)] z-30 max-h-[280px] w-full overflow-y-auto rounded-[10px] border border-line bg-panel p-1.5 shadow-[0_10px_36px_rgb(20_20_30/0.18)]",children:a.under.map(a=>(0,d.jsx)(cx,{file:a,onSelect:h},a.path))}):null]})}function cB({draft:a,project:b,files:c,ringed:e,onDraftClose:f,onDraftSpawned:g}){return(0,d.jsx)("div",{"data-scheme-node":a.key,className:"scheme-enter absolute",style:{transform:`translate(${a.x}px, ${a.y}px)`,width:a.w,height:a.h,transition:cv},children:(0,d.jsx)("div",{className:`flex h-full ${e?"rounded-[10px] ring-2 ring-accent/60":""}`,children:(0,d.jsx)(cc,{draftId:a.id,project:b,files:c,onClose:()=>f(a.id),onSpawned:b=>g(a.id,b)})})})}function cC({deck:a,files:b,focus:c,onSelect:e}){let f=c&&c.flowId===a.flow.id?c.round+c.nonce/1e3:null;return(0,d.jsx)("div",{"data-scheme-node":a.key,className:"scheme-enter absolute",style:{transform:`translate(${a.x}px, ${a.y}px)`,width:a.w,height:a.h,transition:cv},children:(0,d.jsx)(cr,{flow:a.flow,rounds:a.rounds,files:b,onSelect:e,focusRound:f})})}let cD=(0,e.memo)(function({layout:a,project:b,files:c,interactive:e,selected:f,focus:g,flowsByImpl:h,deckFocus:i,onSelect:j,onClose:k,onFocusRound:l,onDraftClose:m,onDraftSpawned:n}){return(0,d.jsxs)("div",{className:e?void 0:"pointer-events-none select-none",children:[a.stacks.map(a=>(0,d.jsx)(cz,{stack:a,onSelect:j},a.key)),a.decks.map(a=>(0,d.jsx)(cC,{deck:a,files:c,focus:i,onSelect:j},a.key)),a.drafts.map(a=>(0,d.jsx)(cB,{draft:a,project:b,files:c,ringed:f===a.key||g===a.key,onDraftClose:m,onDraftSpawned:n},a.key)),a.nodes.map(a=>{var b;return(0,d.jsx)(cA,{node:a,files:c,ringed:f===a.file.path||g===a.file.path,flow:h.get(a.file.path)??null,canFlow:(b=a.file,!h.has(b.path)&&("claude"===b.engine||"codex"===b.engine)&&q(b)),onSelect:j,onClose:k,onFocusRound:l},a.file.path)})]})});function cE({active:a,title:b,onClick:c,children:e}){return(0,d.jsx)("button",{className:`inline-flex h-7 w-7 items-center justify-center rounded-[8px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 ${a?"bg-accent/10 text-accent":"text-dim hover:bg-bg hover:text-ink"}`,title:b,"aria-label":b,"aria-pressed":a,onClick:c,children:e})}let cF=(a,b)=>Math.hypot(a.x-b.x,a.y-b.y);function cG({project:a,groups:b,manual:c,files:f,flows:g,drafts:h,focus:i,onSelect:j,onClose:k,onDraftClose:l,onDraftSpawned:m}){let n=(0,e.useRef)(null),[o,q]=(0,e.useState)({x:0,y:0,z:.5}),[r,t]=(0,e.useState)("select"),[u,v]=(0,e.useState)(!1),[x,y]=(0,e.useState)(!1),[z,C]=(0,e.useState)(!1),[D,E]=(0,e.useState)(null),[F,G]=(0,e.useState)({w:1,h:1}),H=(0,e.useRef)(null),I=(0,e.useRef)(new Map),J=(0,e.useRef)(null);(0,e.useRef)(r),(0,e.useRef)(u);let K=(0,e.useRef)(null);(0,e.useRef)(null),(0,e.useRef)(null);let L=(0,e.useCallback)(a=>{t(a),localStorage.setItem("llvSchemeMode",a)},[]),M=(0,e.useMemo)(()=>(function(a,b,c,d=[],e=[]){let f=new Map(c.map(a=>[a.path,a])),g=w(c),h=[],i=[],j=[],k=[],l=A(d),m=B(d),n=100,o=a=>({file:a,branches:g.get(a.path)?.length??0}),q=(a,b,c,d,e)=>{let g=(a,n,p,q)=>{let r=0===q?780:680;h.push({file:a.file,tasks:a.tasks,under:d.get(a.file.path)??[],x:n,y:p,w:600,h:r,isRoot:a.file.path===e});let s=b.get(a.file.path)??[],t=n+64;for(let a of s)i.push({to:a.file.path,x1:n+40,y1:p+r,x2:t+300,y2:p+r+130,color:P(a.file).color,live:"live"===a.file.activity}),t+=g(a,t,p+r+130,q+1)+48;let u=l.get(a.file.path);if(u){var v,w,x;let a,b,c=(v=u,w=t,x=p+r+130,a=v.rounds.map(a=>({round:a,file:a.reviewerPath?f.get(a.reviewerPath)??null:null})),b={key:"deck::"+v.id,flow:v,rounds:a,x:w,y:x,w:600,h:680+30*Math.min(Math.max(v.rounds.length-1,0),6)},k.push(b),b);i.push({to:c.key,x1:n+40,y1:p+r,x2:t+300,y2:p+r+130,color:"#5a51e0",live:cs.has(u.state)}),t+=648}let y=c.get(a.file.path)?.filter(a=>!m.has(a.path));if(y?.length){let b=p+r+130;j.push({key:a.file.path+"::stack",parent:a.file.path,items:y.map(o),x:t,y:b,w:360,h:16+58*Math.min(y.length,8)-6}),i.push({to:a.file.path+"::stack",x1:n+40,y1:p+r,x2:t+180,y2:b,color:"#9a9aa4",live:!1,dashed:!0}),t+=408}let z=t-48-(n+64);return z>0?Math.max(600,64+z):600};return g(a,n,100,0)};for(let b of a){let a=b.columns;if(!a.length)continue;let c=a[0].file.path,d=new Set(a.map(a=>a.file.path)),e=a=>{let b=a.parent,e=new Set([a.path]);for(;b&&!e.has(b)&&!d.has(b);)e.add(b),b=f.get(b)?.parent??null;return b&&d.has(b)&&b!==a.path?b:c},g=new Map;for(let b of a){if(b.file.path===c)continue;let a=e(b.file),d=g.get(a);d?d.push(b):g.set(a,[b])}let h=new Map,i=[];for(let a of[...b.returnable,...b.finished])if(!m.has(a.path))if(s(a)){let b=e(a),c=h.get(b);c?c.push(a):h.set(b,[a])}else i.push(a);let j=new Map([[c,i]]);n+=q(a[0],g,h,j,b.key)+150}for(let a of b){let b=(function(a,b){if(!a)return[];let c=w(b),d=[],e=new Set([a.path]),f=(a,b)=>{for(let g of(c.get(a.path)??[]).filter(a=>!e.has(a.path)).sort((a,b)=>p(a)-p(b)||b.mtime-a.mtime))e.add(g.path),d.push({file:g,depth:b}),f(g,b+1)};return f(a,1),d})(a,c).map(a=>a.file).filter(a=>!m.has(a.path)),d=b.filter(a=>s(a)),e=b.filter(a=>!s(a));n+=q({file:a,tasks:[]},new Map,new Map(d.length?[[a.path,d]]:[]),new Map([[a.path,e]]),a.parent?"":a.path)+150}let r=[];for(let a of e)r.push({key:"draft::"+a,id:a,x:n,y:100,w:600,h:780}),n+=750;let t=0;for(let a of h)t=Math.max(t,a.y+a.h);for(let a of j)t=Math.max(t,a.y+a.h);for(let a of k)t=Math.max(t,a.y+a.h);for(let a of r)t=Math.max(t,a.y+a.h);return{nodes:h,edges:i,stacks:j,decks:k,drafts:r,byPath:new Map([...h.map(a=>[a.file.path,a]),...r.map(a=>[a.key,a])]),width:Math.max(n-150+100,800),height:t+100+140}})(b,c,f,g,h),[b,c,f,g,h]),N=(0,e.useMemo)(()=>A(g),[g]),[O,Q]=(0,e.useState)(null),R=(0,e.useCallback)((a,b)=>{Q(c=>({flowId:a,round:b,nonce:(c?.nonce??0)+1}))},[]),S=(0,e.useRef)(j),T=(0,e.useRef)(k),U=(0,e.useRef)(l),V=(0,e.useRef)(m),W=(0,e.useCallback)(a=>S.current(a),[]),X=(0,e.useCallback)(a=>T.current(a),[]),Y=(0,e.useCallback)(a=>U.current(a),[]),Z=(0,e.useCallback)((a,b)=>V.current(a,b),[]),$=(0,e.useCallback)(a=>{let b=Math.min(Math.max(a.x,120-M.width*a.z),F.w-120),c=Math.min(Math.max(a.y,120-M.height*a.z),F.h-120);return b===a.x&&c===a.y?a:{...a,x:b,y:c}},[M.width,M.height,F]),_=(0,e.useRef)([]),aa=(0,e.useRef)(null),ab=(0,e.useCallback)(a=>{_.current.push(a),null==aa.current&&(aa.current=requestAnimationFrame(()=>{aa.current=null;let a=_.current;_.current=[],q(b=>a.reduce((a,b)=>b(a),b))}))},[]),ac=(0,e.useCallback)((a,b,c)=>{ab(d=>{let e=Math.min(1.6,Math.max(.12,d.z*c));if(e===d.z)return d;let f=e/d.z;return $({z:e,x:a-(a-d.x)*f,y:b-(b-d.y)*f})})},[$,ab]),ad=(0,e.useCallback)(a=>{let b=n.current?.getBoundingClientRect();b&&ac(b.width/2,b.height/2,a)},[ac]),ae=(0,e.useCallback)(a=>{let b=n.current?.getBoundingClientRect();b&&q(c=>{let d=Math.min(1.6,Math.max(.12,a));if(d===c.z)return c;let e=d/c.z,f=b.width/2,g=b.height/2;return $({z:d,x:f-(f-c.x)*e,y:g-(g-c.y)*e})})},[$]),af=(0,e.useCallback)(()=>{let a=n.current?.getBoundingClientRect();if(!a||!M.nodes.length&&!M.drafts.length)return null;let b=Math.min(1.6,Math.max(.12,Math.min((a.width-48)/M.width,(a.height-48)/M.height,1)));return{z:b,x:(a.width-M.width*b)/2,y:(a.height-M.height*b)/2}},[M]),ag=(0,e.useCallback)(a=>{C(!0),q(a),K.current&&window.clearTimeout(K.current),K.current=window.setTimeout(()=>C(!1),500)},[]),ah=(0,e.useCallback)(()=>{let a=af();a&&ag(a)},[af,ag]),ai=(0,e.useCallback)((a,b)=>{let c=n.current?.getBoundingClientRect();c&&ag(d=>{let e=Math.min(1.6,Math.max(d.z,b));return{z:e,x:c.width/2-(a.x+a.w/2)*e,y:Math.min(c.height/2-a.y*e,.08*c.height-(a.y-40)*e)}})},[ag]),aj=a=>{let b=n.current?.getBoundingClientRect();return b?{x:a.clientX-b.left,y:a.clientY-b.top}:{x:a.clientX,y:a.clientY}},ak=a=>{H.current={sx:a.clientX,sy:a.clientY,cx:o.x,cy:o.y},y(!0);try{n.current?.setPointerCapture(a.pointerId)}catch{}},al="hand"===r||u,am=(0,e.useCallback)((a,b)=>q(c=>$({...c,x:F.w/2-a*c.z,y:F.h/2-b*c.z})),[F,$]),an=24*o.z;return(0,d.jsxs)("div",{ref:n,className:`relative min-h-0 flex-1 overflow-hidden ${x?"cursor-grabbing select-none":al?"cursor-grab":""} ${al?"touch-none":""}`,onPointerDown:a=>{let b=a.target;if(!b.closest("[data-scheme-ui]")){if("touch"===a.pointerType&&(I.current.set(a.pointerId,aj(a)),2===I.current.size)){let[a,b]=[...I.current.values()];J.current={d:cF(a,b),cx:(a.x+b.x)/2,cy:(a.y+b.y)/2},H.current=null,y(!1);return}if(1===a.button){a.preventDefault(),ak(a);return}if(0===a.button){if(!("hand"===r||u)){let a=b.closest("[data-scheme-node]");if(a)return void E(a.getAttribute("data-scheme-node"));if(E(null),b.closest("button, a, input, textarea, select"))return}ak(a)}}},onPointerMove:a=>{if("touch"===a.pointerType&&I.current.has(a.pointerId)){I.current.set(a.pointerId,aj(a));let b=J.current;if(b&&I.current.size>=2){let[a,c]=[...I.current.values()],d=cF(a,c),e=(a.x+c.x)/2,f=(a.y+c.y)/2,g=b.d>0?d/b.d:1;ab(a=>{let c=Math.min(1.6,Math.max(.12,a.z*g)),d=c/a.z;return $({z:c,x:e-(b.cx-a.x)*d,y:f-(b.cy-a.y)*d})}),J.current={d,cx:e,cy:f};return}}let b=H.current;if(!b)return;let c=a.clientX-b.sx,d=a.clientY-b.sy;ab(a=>$({...a,x:b.cx+c,y:b.cy+d}))},onDoubleClick:a=>{let b=a.target;if(b.closest("[data-scheme-ui]"))return;let c=b.closest("[data-scheme-node]");if(!c)return void ah();if("hand"!==r&&!u)return;let d=M.byPath.get(c.getAttribute("data-scheme-node")??"");d&&ai(d,.9)},children:[(0,d.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute",style:{inset:-an,backgroundImage:"radial-gradient(rgba(28,28,34,0.09) 1px, transparent 1px)",backgroundSize:`${an}px ${an}px`,transform:`translate(${(o.x%an+an)%an}px, ${(o.y%an+an)%an}px)`,willChange:"transform"}}),(0,d.jsxs)("div",{className:`absolute left-0 top-0 ${x?"scheme-panning":""}`,style:{width:M.width,height:M.height,transform:`translate(${o.x}px, ${o.y}px) scale(${o.z})`,transformOrigin:"0 0",transition:z?`transform .45s ${cu}`:void 0,willChange:"transform","--inv-z":String(1/o.z),"--label-o":o.z<.45?"1":"0"},children:[(0,d.jsx)(cw,{edges:M.edges,width:M.width,height:M.height}),(0,d.jsx)(cD,{layout:M,project:a,files:f,interactive:!al,selected:D,focus:i,flowsByImpl:N,deckFocus:O,onSelect:W,onClose:X,onFocusRound:R,onDraftClose:Y,onDraftSpawned:Z})]},a),(0,d.jsxs)("div",{"data-scheme-ui":!0,className:"absolute left-3 top-3 z-40 flex items-center gap-1 rounded-[10px] border border-line bg-panel/95 p-1 shadow-card",children:[(0,d.jsx)(cE,{active:al,title:"Рука — тягнути полотно (H, або тримай Space)",onClick:()=>L("hand"),children:(0,d.jsx)(ce,{className:"h-4 w-4","aria-hidden":!0})}),(0,d.jsx)(cE,{active:!al,title:"Виділення — клік і робота з розмовами (V)",onClick:()=>L("select"),children:(0,d.jsx)(cf,{className:"h-4 w-4","aria-hidden":!0})}),(0,d.jsx)("div",{className:"mx-0.5 h-5 w-px bg-line","aria-hidden":!0}),(0,d.jsx)(cE,{title:"Віддалити (−)",onClick:()=>ad(.8),children:(0,d.jsx)(a9,{className:"h-4 w-4","aria-hidden":!0})}),(0,d.jsxs)("button",{className:"min-w-[46px] rounded-[8px] px-1 text-center text-[11px] font-semibold text-dim hover:bg-bg hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",title:"Масштаб 100% (1)",onClick:()=>ae(1),children:[Math.round(100*o.z),"%"]}),(0,d.jsx)(cE,{title:"Наблизити (+)",onClick:()=>ad(1.25),children:(0,d.jsx)(ba,{className:"h-4 w-4","aria-hidden":!0})}),(0,d.jsx)(cE,{title:"Вписати все (0, або подвійний клік по фону)",onClick:ah,children:(0,d.jsx)(cg,{className:"h-4 w-4","aria-hidden":!0})})]}),(0,d.jsx)(ct,{layout:M,cam:o,vp:F,onJump:am})]})}function cH(a){try{window.localStorage.setItem("llvArchived",JSON.stringify([...a]))}catch{}}function cI({data:a,onOpen:b}){let c=a.waiting.length;(0,e.useRef)(c);let[f,g]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:"group absolute bottom-3 right-3 z-20",children:[a.livePreview.length?(0,d.jsx)("div",{className:"pointer-events-none mb-1.5 hidden w-[300px] rounded-[8px] border border-line bg-panel/95 px-3 py-2 shadow-card backdrop-blur group-focus-within:block group-hover:block",children:a.livePreview.map(a=>(0,d.jsxs)("div",{className:"flex min-w-0 gap-1.5 py-0.5 text-[10.5px]",children:[(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate font-semibold",children:a.title}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-dim",children:a.statusLine||"працює…"})]},a.file.path))}):null,(0,d.jsxs)("button",{className:`ml-auto flex items-center gap-1.5 rounded-full border border-line bg-panel/95 px-2.5 py-1 text-[11.5px] font-bold shadow-card backdrop-blur transition-transform hover:border-accent/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 ${f?"scale-110 border-[#e0ae45]/70":""} motion-reduce:transition-none`,"aria-label":"Відкрити пульт агентів",onClick:b,children:[(0,d.jsx)("span",{className:`h-2 w-2 rounded-full ${a.working.length?"animate-pulse bg-ok":"bg-dim"}`}),(0,d.jsx)("span",{children:a.working.length}),(0,d.jsxs)("span",{className:c?"text-[#b8860b]":"text-dim",children:["\xb7 ",c," чекають"]})]})]})}function cJ({file:a,title:b,project:c,currentProject:e,descendants:f,statusLine:g,size:h,tone:i,onOpen:j,onArchive:k}){let n=U(a),o="large"===h;return(0,d.jsxs)("article",{className:`group relative flex ${o?"h-[150px] w-[300px]":"h-[108px] w-[220px]"} shrink-0 flex-col rounded-[8px] border p-3 shadow-card transition-colors hover:border-accent/45 ${"working"===i?"border-ok/40 bg-[#f3fbf5] shadow-[0_0_0_3px_rgba(26,138,62,0.12)]":"stalled"===i?"border-err/35 bg-[#fff5f5]":"waiting"===i?"border-[#e0ae45]/45 bg-[#fff9ed]":"border-line bg-panel"}`,role:"button",tabIndex:0,"aria-label":`Відкрити колонкою ${m(b,80)}`,onClick:()=>j(a),onKeyDown:b=>{"Enter"===b.key&&j(a)},children:["live"===a.activity?null:(0,d.jsx)("button",{type:"button",className:"absolute right-1.5 top-1.5 z-10 hidden h-5 w-5 items-center justify-center rounded-full border border-line bg-bg text-dim hover:border-err/50 hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 group-hover:flex group-focus-within:flex","aria-label":"Прибрати з пульта",onClick:b=>{b.stopPropagation(),k(a)},onKeyDown:a=>a.stopPropagation(),children:(0,d.jsx)(l,{className:"h-3 w-3","aria-hidden":!0})}),(0,d.jsxs)("div",{className:"relative flex min-w-0 items-center gap-1.5",children:[(0,d.jsx)("span",{className:`h-2 w-2 shrink-0 rounded-full ${K(a.activity)}`}),a.model?(0,d.jsx)("span",{className:"min-w-0 truncate rounded-full px-1.5 py-0.5 font-mono text-[9px] font-semibold",style:{backgroundColor:S(a).soft,color:S(a).color},title:[n.label,T(a)].filter(Boolean).join(" \xb7 "),children:a.model}):(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 py-0.5 text-[9.5px] font-bold",style:n.style,children:n.label}),(0,d.jsx)("span",{className:`ml-auto min-w-0 truncate rounded-full border border-line bg-bg px-1.5 py-0.5 text-[9.5px] font-semibold ${c===e?"text-dim":"text-ink"}`,title:c,children:c})]}),(0,d.jsx)("div",{className:`relative mt-2 min-w-0 ${o?"text-[14px]":"text-[12.5px]"} font-bold leading-snug`,title:b,children:(0,d.jsx)("span",{className:"line-clamp-2",children:b})}),(0,d.jsxs)("div",{className:"relative mt-auto flex min-w-0 items-center gap-2 text-[10.5px] font-semibold text-dim",children:[(0,d.jsx)("span",{className:"shrink-0",children:H(a.mtime)}),a.ctx?(0,d.jsx)(bV,{ctx:a.ctx}):null,f?(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-0.5",children:[(0,d.jsx)(ae,{className:"h-3 w-3","aria-hidden":!0})," ",f]}):null]}),g?(0,d.jsx)("div",{className:`relative mt-1 min-w-0 truncate ${o?"text-[11.5px]":"text-[10.5px]"} font-semibold text-ink/75`,children:g}):null,a.pid&&"running"===a.proc?(0,d.jsx)("div",{className:"relative mt-2",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:(0,d.jsx)(aW,{file:a,compact:!0})}):null]})}function cK({title:a,items:b,size:c,currentProject:e,onOpenFile:f,onArchive:g}){return b.length?(0,d.jsxs)("section",{className:"shrink-0",children:[(0,d.jsxs)("div",{className:"mb-2 flex items-baseline gap-2",children:[(0,d.jsx)("h2",{className:"text-[13px] font-bold",children:a}),(0,d.jsx)("span",{className:"text-[11px] font-semibold text-dim",children:b.length})]}),(0,d.jsx)(aS,{className:"flex flex-wrap gap-2.5",enter:"fade",children:b.map(a=>(0,d.jsx)("div",{"data-flip-key":a.file.path,children:(0,d.jsx)(cJ,{file:a.file,title:a.title,project:a.project,currentProject:e,descendants:a.descendants,statusLine:a.statusLine,size:c,tone:"working"===a.kind?"working":"waiting"===a.kind&&"stalled"===a.file.activity?"stalled":"waiting"===a.kind?"waiting":"quiet",onOpen:f,onArchive:g})},a.file.path))})]}):null}function cL({files:a,flows:b,project:c,onOpenFile:f}){let[g,h]=(0,e.useState)(!1),[i,j]=(0,e.useState)(""),[k,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(0),s=(0,e.useRef)(null),t=function(){let[a,b]=(0,e.useState)([]),[c,d]=(0,e.useState)(!1);return{events:a,loading:c}}(),{archivedPaths:v,archive:w,unarchive:x}=function(){let[a,b]=(0,e.useState)(()=>new Set),c=(0,e.useRef)(a);return{archivedPaths:a,archive:(0,e.useCallback)(a=>{b(b=>{if(b.has(a))return b;let d=new Set(b);return d.add(a),c.current=d,cH(d),d})},[]),unarchive:(0,e.useCallback)(a=>{b(b=>{if(!b.has(a))return b;let d=new Set(b);return d.delete(a),c.current=d,cH(d),d})},[])}}(),y=Y(a,t.events,i,q,v,b),z=Y(a,[],"",q,v,b),A=(0,e.useMemo)(()=>a.filter(a=>v.has(a.path)).map(a=>({file:a,title:m(a.title),project:u(a)})).sort((a,b)=>b.file.mtime-a.file.mtime),[a,v]),B=a=>{f(a),h(!1)},C=a=>w(a.path);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(cI,{data:z,onOpen:()=>h(!0)}),g?(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/28 p-[2.5vh]",onMouseDown:()=>h(!1),children:(0,d.jsxs)("div",{className:"flex h-[95vh] w-[95vw] flex-col overflow-hidden rounded-[8px] border border-line bg-bg shadow-[0_18px_70px_rgb(20_20_30/0.28)]",role:"dialog","aria-modal":"true","aria-label":"Пульт агентів",onMouseDown:a=>a.stopPropagation(),children:[(0,d.jsxs)("header",{className:"flex h-14 shrink-0 items-center gap-3 border-b border-line bg-panel px-4",children:[(0,d.jsx)("div",{className:"text-[15px] font-bold",children:"Пульт"}),(0,d.jsx)("input",{ref:s,value:i,onChange:a=>j(a.target.value),placeholder:"Пошук за назвою або проєктом",className:"h-9 min-w-0 flex-1 rounded-[8px] border border-line bg-bg px-3 text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-accent/40"}),t.loading?(0,d.jsx)("span",{className:"text-[11px] font-semibold text-dim",children:"оновлення…"}):null,(0,d.jsx)("button",{className:"inline-flex h-8 w-8 items-center justify-center rounded-[8px] border border-line bg-bg text-dim hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":"Закрити пульт",onClick:()=>h(!1),children:(0,d.jsx)(l,{className:"h-4 w-4","aria-hidden":!0})})]}),(0,d.jsxs)("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-4 py-4",children:[(0,d.jsx)(cK,{title:"Чекає тебе",items:y.waiting,size:"large",currentProject:c,onOpenFile:B,onArchive:C}),(0,d.jsx)(cK,{title:"Працюють",items:y.working,size:"large",currentProject:c,onOpenFile:B,onArchive:C}),(0,d.jsx)(cK,{title:"Нещодавні",items:y.recent,size:"small",currentProject:c,onOpenFile:B,onArchive:C}),(0,d.jsxs)("section",{className:"shrink-0",children:[(0,d.jsxs)("button",{className:"flex h-10 w-full items-center justify-between rounded-[8px] border border-line bg-panel px-3 text-left text-[12.5px] font-bold hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-expanded":k,onClick:()=>n(a=>!a),children:[(0,d.jsx)("span",{children:"Старіше"}),(0,d.jsx)("span",{className:"text-dim",children:y.older.length})]}),k?(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(cK,{title:"",items:y.older,size:"small",currentProject:c,onOpenFile:B,onArchive:C})}):null]}),y.waiting.length||y.working.length||y.recent.length||y.older.length?null:(0,d.jsx)("div",{className:"pt-[18vh] text-center text-[13px] font-semibold text-dim",children:"Нічого не знайдено"}),A.length?(0,d.jsxs)("section",{className:"shrink-0",children:[(0,d.jsxs)("button",{className:"flex h-9 w-full items-center justify-between rounded-[8px] border border-line bg-panel px-3 text-left text-[12px] font-bold text-dim hover:border-accent/40 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-expanded":o,onClick:()=>p(a=>!a),children:[(0,d.jsxs)("span",{children:["Приховані (",A.length,")"]}),(0,d.jsx)("span",{children:o?"сховати":"показати"})]}),o?(0,d.jsx)("div",{className:"mt-2 space-y-1",children:A.map(a=>(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2 rounded-[8px] border border-line bg-panel/60 px-3 py-1.5 text-[11.5px] text-dim",children:[(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate",children:a.title}),(0,d.jsx)("span",{className:"shrink-0 truncate text-[10.5px]",children:a.project}),(0,d.jsx)("button",{className:"shrink-0 rounded-full border border-line bg-bg px-2 py-0.5 text-[10.5px] font-semibold text-ink hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>x(a.file.path),children:"повернути"})]},a.file.path))}):null]}):null]})]})}):null]})}function cM(){location.hash="#p="+encodeURIComponent(n)}function cN({files:a,onOpen:b}){return(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-5",children:(0,d.jsxs)("div",{className:"mx-auto w-full max-w-[760px]",children:[(0,d.jsx)("div",{className:"text-[13.5px] font-semibold text-dim",children:"На схемі порожньо, але в проєкті є записи"}),(0,d.jsx)("div",{className:"mb-3 mt-0.5 text-[12px] text-dim",children:"Клік по рядку відкриває розмову нодою; смітник видаляє її файл з диска назавжди."}),(0,d.jsx)("div",{className:"space-y-1.5",children:a.map(a=>(0,d.jsx)(cO,{file:a,onOpen:b},a.path))})]})})}function cO({file:a,onOpen:b}){let[c,f]=(0,e.useState)(!1),g=U(a);return c?(0,d.jsxs)("div",{className:"flex items-center gap-2 rounded-[8px] border border-line bg-chip/60 px-3 py-1.5 text-[11.5px] font-semibold text-dim",children:[(0,d.jsx)(az,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),(0,d.jsx)("span",{className:"min-w-0 truncate",children:m(a.title,80)}),(0,d.jsx)("span",{className:"shrink-0",children:"\xb7 видалено з диска"})]}):(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2 rounded-[8px] border border-line bg-panel px-3 py-1.5 shadow-card",children:[(0,d.jsxs)("button",{type:"button",className:"flex h-full min-w-0 flex-1 items-center gap-2 rounded-[6px] text-left hover:bg-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":`Відкрити ${m(a.title,60)}`,onClick:()=>b(a),children:[(0,d.jsx)("span",{className:`h-2 w-2 shrink-0 rounded-full ${K(a.activity)}`}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 py-0.5 text-[9.5px] font-bold",style:g.style,children:g.label}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate text-[12.5px] font-semibold",title:a.path,children:m(a.title,90)}),(0,d.jsx)("span",{className:"shrink-0 text-[10.5px] font-semibold text-dim",children:H(a.mtime)}),(0,d.jsxs)("span",{className:"shrink-0 text-[10.5px] text-dim",children:[(a.size/1024).toFixed(0)," кБ"]})]}),(0,d.jsx)(aR,{file:a,onDeleted:()=>f(!0)})]})}function cP({files:a,onArchive:b}){return!a.length||a.some(a=>"running"===a.proc||"live"===a.activity)?null:(0,d.jsxs)("button",{type:"button",className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-line bg-bg px-2 py-0.5 text-[11px] font-semibold text-dim hover:border-accent/40 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>{b(),cM()},children:[(0,d.jsx)(af,{className:"h-3 w-3","aria-hidden":!0})," В архів"]})}function cQ({files:a}){let[b,c]=(0,e.useState)(!1),[f,g]=(0,e.useState)(!1),[h,i]=(0,e.useState)("");if(!a.length||a.some(a=>"running"===a.proc||"live"===a.activity))return null;let j=async()=>{g(!0),i("");let b=0;for(let c of a)try{let a=await fetch(`/api/log?path=${encodeURIComponent(c.path)}`,{method:"DELETE"}),d=await a.json();a.ok&&d.ok||(b+=1)}catch{b+=1}(g(!1),c(!1),b)?i(`не видалено ${b} з ${a.length}`):cM()};return b?(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-[10px] border border-err/30 bg-[#fff5f5] px-1.5 py-0.5 text-[11px]",children:[(0,d.jsxs)("span",{className:"px-0.5 font-semibold text-err",children:["Видалити з диска ",a.length," ",J(a.length,"файл","файли","файлів")," проєкту?"]}),(0,d.jsx)("button",{type:"button",className:"rounded-lg bg-err px-2 py-0.5 font-bold text-white disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-err/50",disabled:f,onClick:j,children:f?"видаляю…":"Так, видалити"}),(0,d.jsx)("button",{type:"button",className:"rounded-lg border border-line bg-panel px-2 py-0.5 font-semibold text-dim focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>c(!1),children:"Скасувати"})]}):(0,d.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(0,d.jsx)("button",{type:"button",className:"inline-flex items-center rounded-full border border-line bg-bg p-1 text-dim hover:border-err/40 hover:text-err focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":"Видалити проєкт з диска",title:"Видалити проєкт з диска",onClick:()=>c(!0),children:(0,d.jsx)(az,{className:"h-3 w-3","aria-hidden":!0})}),h?(0,d.jsx)("span",{className:"max-w-[180px] truncate text-[10.5px] font-semibold text-err",children:h}):null]})}let cR=k("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]),cS=k("volume-x",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);function cT(){let[a,b]=(0,e.useState)(!0);return(0,d.jsx)("button",{className:"ml-auto inline-flex h-[26px] w-[26px] shrink-0 items-center justify-center rounded-full border border-line bg-panel text-dim hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",title:a?"Звукові сповіщення увімкнено":"Звукові сповіщення вимкнено","aria-label":a?"Вимкнути звукові сповіщення":"Увімкнути звукові сповіщення","aria-pressed":a,onClick:()=>{let c=!a;b(c);try{localStorage.setItem(_,c?"on":"off")}catch{}c&&function(a=0){(function(){try{localStorage.getItem(_)}catch{return!0}})()}()},children:a?(0,d.jsx)(cR,{className:"h-3.5 w-3.5","aria-hidden":!0}):(0,d.jsx)(cS,{className:"h-3.5 w-3.5","aria-hidden":!0})})}function cU({items:a,onSelect:b}){let[c,f]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:"shrink-0 border-t border-line bg-panel",children:[(0,d.jsxs)("button",{className:"flex h-8 items-center gap-2 px-4 text-[10px] font-bold uppercase tracking-[.6px] text-dim hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-expanded":c,onClick:()=>f(a=>!a),children:[(0,d.jsx)(an,{className:`h-3.5 w-3.5 transition-transform ${c?"rotate-90":""}`,"aria-hidden":!0}),"Тихі розмови й задачі",(0,d.jsx)("span",{className:"font-semibold normal-case tracking-normal",children:a.length})]}),c?(0,d.jsx)(aS,{className:"flex max-h-44 flex-wrap items-start gap-1.5 overflow-y-auto px-3 pb-2.5",children:a.map(a=>{let c=U(a),e=m(a.cmdDesc||a.title,70);return(0,d.jsxs)("button",{"data-flip-key":a.path,className:"inline-flex h-7 max-w-[360px] items-center gap-1.5 rounded-full border border-line bg-bg px-2 text-[11px] font-semibold text-ink hover:border-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",title:m(a.title),onClick:()=>b(a),children:[(0,d.jsx)("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${K(a.activity)}`}),(0,d.jsx)("span",{className:"shrink-0 rounded-full px-1.5 text-[9px]",style:c.style,children:c.label}),(0,d.jsx)("span",{className:"truncate",children:e}),(0,d.jsx)("span",{className:"shrink-0 font-normal text-dim",children:H(a.mtime)})]},a.path)})}):null]})}let cV=a=>`llvCols:${a}`;function cW(a,b){let c=function(a){try{let b=JSON.parse(localStorage.getItem(cV(a))??"{}");return{manual:b.manual??[],hidden:b.hidden??[]}}catch{return{manual:[],hidden:[]}}}(a);c.manual.includes(b)||c.manual.push(b),c.hidden=c.hidden.filter(a=>a!==b),localStorage.setItem(cV(a),JSON.stringify(c))}function cX({files:a,flows:b,project:c,openNonce:f,archived:g,onArchive:h,onUnarchive:i}){let j=(0,e.useRef)(null),k=(0,e.useRef)(null),[l,m]=(0,e.useState)({manual:[],hidden:[]}),[n,o]=(0,e.useState)([]),[r,s]=(0,e.useState)(null),t=(0,e.useRef)(l),v=a=>{t.current=a,m(a),localStorage.setItem(cV(c),JSON.stringify(a))},y=(0,e.useMemo)(()=>{let c=B(b);return c.size?a.filter(a=>!c.has(a.path)):a},[a,b]),A=(0,e.useMemo)(()=>z(y,c),[y,c]),C=(0,e.useMemo)(()=>new Set(A.map(a=>a.key)),[A]),D=(0,e.useMemo)(()=>(function(a,b,c){let d=w(a),e=[];for(let f of a){if(u(f)!==b||!q(f)||c.has(f.path))continue;let a=x(f,d);if(!a.length)continue;let g=f.mtime,h=p(f);for(let b of a)g=Math.max(g,b.mtime),h=Math.min(h,p(b));e.push({root:f,branchCount:a.length,smt:g,band:h})}return e.sort((a,b)=>a.band-b.band||b.smt-a.smt)})(y,c,C),[y,c,C]),E=(0,e.useMemo)(()=>{let a;return a=w(y),y.filter(b=>!(u(b)!==c||b.parent||C.has(b.path)||a.get(b.path)?.length)&&"live"!==b.activity).sort((a,b)=>p(a)-p(b)||b.mtime-a.mtime)},[y,c,C]),F=(0,e.useMemo)(()=>new Set(A.flatMap(a=>a.columns.map(a=>a.file.path))),[A]),G=(0,e.useMemo)(()=>new Set(l.hidden),[l.hidden]),H=(0,e.useMemo)(()=>{let a=new Map(y.map(a=>[a.path,a]));return l.manual.map(b=>a.get(b)).filter(a=>void 0!==a&&u(a)===c&&!F.has(a.path)&&!G.has(a.path))},[l.manual,y,c,F,G]),I=(0,e.useMemo)(()=>A.reduce((a,b)=>a+b.columns.reduce((a,b)=>a+ +("live"===b.file.activity)+b.tasks.filter(a=>"live"===a.activity).length,0),0),[A]),K=A.filter(a=>!a.orphanTask).length,L=a=>{o(a),sessionStorage.setItem(`llvDrafts:${c}`,JSON.stringify(a))},M=a=>{for(let b of["engine","cwd","text","boot"])sessionStorage.removeItem(ca(a,b));L(n.filter(b=>b!==a))},N=a=>{let b=u(a);if(b!==c){cW(b,a.path),location.hash="#p="+encodeURIComponent(b);return}if(F.has(a.path)&&!G.has(a.path)||H.some(b=>b.path===a.path))return void(s(a.path),j.current&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>s(null),1800));let d=l.hidden.filter(b=>b!==a.path);v({manual:F.has(a.path)?l.manual:[...new Set([...l.manual,a.path])],hidden:d}),k.current=a.path},O=[];I?O.push(`${I} ${J(I,"гілка працює","гілки працюють","гілок працюють")} \xb7 ${K} ${J(K,"дерево","дерева","дерев")}`):K&&O.push(`${K} ${J(K,"нещодавня розмова","нещодавні розмови","нещодавніх розмов")}`),D.length&&O.push(`${D.length} ${J(D.length,"тихе дерево","тихі дерева","тихих дерев")}`);let P=A.map(a=>({...a,columns:a.columns.filter(a=>!G.has(a.file.path))})).filter(a=>a.columns.length),Q=P.filter(a=>a.orphanTask).map(a=>a.columns[0].file),R=P.filter(a=>!a.orphanTask),S=R.length>0||H.length>0||n.length>0,T=(0,e.useMemo)(()=>a.filter(a=>u(a)===c).sort((a,b)=>b.mtime-a.mtime),[a,c]);return(0,d.jsxs)("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:[(0,d.jsxs)("div",{className:"flex h-10 shrink-0 items-center gap-2.5 border-b border-line bg-panel px-4",children:[(0,d.jsx)("h1",{className:"truncate text-[13.5px] font-bold",children:c}),(0,d.jsx)("span",{className:"truncate text-[11.5px] text-dim",children:O.length?O.join(" \xb7 "):"зараз нічого не працює"}),(0,d.jsx)(cT,{}),g?(0,d.jsxs)("button",{type:"button",className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-line bg-bg px-2 py-0.5 text-[11px] font-semibold text-dim hover:border-accent/40 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>i(c),children:[(0,d.jsx)(ag,{className:"h-3 w-3","aria-hidden":!0})," Повернути з архіву"]}):(0,d.jsx)(cP,{files:T,onArchive:()=>h(c)}),(0,d.jsx)(cQ,{files:T}),(0,d.jsxs)("button",{type:"button",onClick:()=>{let a="function"==typeof crypto.randomUUID?crypto.randomUUID():Date.now().toString(36)+Math.random().toString(36).slice(2,10);L([...n,a]),k.current="draft::"+a},"aria-label":"Нова розмова з агентом",className:"ml-auto flex shrink-0 items-center gap-1 rounded-[8px] border border-line bg-panel px-2.5 py-1 text-[11.5px] font-bold text-ink shadow-card hover:border-accent/45 hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",children:[(0,d.jsx)("span",{className:"text-[13px] leading-none text-accent",children:"+"})," Агент"]})]}),Q.length?(0,d.jsx)("div",{className:"shrink-0 border-b border-line bg-[#fbfbfd]",children:Q.map(b=>(0,d.jsx)("div",{className:`border-l-4 ${"live"===b.activity?"border-l-ok bg-[#f2faf4]":"border-l-[#9a9aa4]"}`,children:(0,d.jsx)(b8,{file:b,files:a,onSelect:N})},b.path))}):null,S?(0,d.jsx)(cG,{project:c,groups:R,manual:H,files:a,flows:b,drafts:n,focus:r,onSelect:N,onClose:a=>{fetch("/api/tmux",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"kill",path:a})}).catch(()=>{}),v({manual:l.manual.filter(b=>b!==a),hidden:F.has(a)?[...new Set([...l.hidden,a])]:l.hidden})},onDraftClose:M,onDraftSpawned:(a,b)=>{M(a),N(b)}}):T.length?(0,d.jsx)(cN,{files:T,onOpen:N}):(0,d.jsx)("div",{className:"flex flex-1 items-center justify-center px-4 py-5 text-center",children:(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[13.5px] font-semibold text-dim",children:"На схемі поки порожньо"}),(0,d.jsx)("div",{className:"mt-0.5 text-[12px] text-dim",children:"Відкрий пульт у правому нижньому куті і клікни розмову — вона з'явиться тут"})]})}),(0,d.jsx)(cL,{files:a,flows:b,project:c,onOpenFile:N}),E.length?(0,d.jsx)(cU,{items:E,onSelect:N}):null]})}let cY=k("qr-code",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);function cZ(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)({status:"idle"}),[g,h]=(0,e.useState)(null),[i,j]=(0,e.useState)(!1),k=(0,e.useRef)(null),l="ready"===c.status&&g&&g.url===c.url?g.dataUrl:null,m=(0,e.useCallback)(()=>{"ready"===c.status&&navigator.clipboard.writeText(c.url).then(()=>{j(!0),window.setTimeout(()=>j(!1),2e3)}).catch(()=>{})},[c]);return(0,d.jsxs)("div",{ref:k,className:"relative ml-auto shrink-0",children:[(0,d.jsx)("button",{type:"button","aria-expanded":a,"aria-label":"Показати QR для входу з телефона",onClick:()=>{a||f({status:"idle"}),b(!a)},className:"flex items-center justify-center rounded-[8px] border border-line bg-panel p-1.5 text-dim hover:border-accent/45 hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",children:(0,d.jsx)(cY,{className:"h-4 w-4","aria-hidden":!0})}),a?(0,d.jsx)("div",{className:"fixed left-1/2 top-12 z-50 flex w-[260px] -translate-x-1/2 flex-col gap-2.5 rounded-[12px] border border-line bg-panel p-3 shadow-[0_8px_28px_rgba(20,20,30,0.14)] sm:absolute sm:left-0 sm:right-auto sm:top-full sm:mt-1.5 sm:translate-x-0",children:"idle"===c.status?(0,d.jsx)("span",{className:"text-[12px] text-ink",children:"завантаження…"}):"error"===c.status?(0,d.jsx)("span",{className:"text-[12px] font-semibold text-err",children:"не вдалося отримати посилання"}):"unavailable"===c.status?(0,d.jsxs)("span",{className:"text-[12px] leading-relaxed text-ink",children:["Запустіть viewer з доступом через Tailscale:"," ",(0,d.jsx)("code",{className:"break-all rounded bg-chip px-1 py-0.5 font-mono text-[11px]",children:"bunx agent-log-viewer --tailscale"})]}):(0,d.jsxs)(d.Fragment,{children:[l?(0,d.jsx)("img",{src:l,alt:"QR код для входу з телефона",className:"mx-auto h-[220px] w-[220px]"}):(0,d.jsx)("span",{className:"text-[12px] text-ink",children:"генерую QR…"}),(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("input",{readOnly:!0,value:c.url,"aria-label":"Посилання для входу з телефона",onFocus:a=>a.currentTarget.select(),className:"min-w-0 flex-1 truncate rounded-[8px] border border-line bg-bg px-2 py-1.5 font-mono text-[10.5px] text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40"}),(0,d.jsx)("button",{type:"button","aria-label":"Копіювати посилання",onClick:m,className:"flex shrink-0 items-center gap-1 rounded-[8px] border border-line bg-panel px-2 py-1.5 text-[11px] font-semibold text-dim hover:border-accent/45 hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",children:i?(0,d.jsx)(am,{className:"h-3.5 w-3.5","aria-hidden":!0}):(0,d.jsx)(aU,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),(0,d.jsx)("span",{className:"text-[10.5px] text-dim",children:"скануй з телефона в тому ж tailnet"})]})}):null]})}function c$({label:a,window:b,engineColor:c,now:e}){var f;let g,h,i;if(!b)return null;let j=Math.max(0,Math.min(100,100-b.usedPercent)),k=j<=10?"#c62828":j<=30?"#d29a2f":c;return(0,d.jsxs)("div",{className:"mt-1.5",children:[(0,d.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,d.jsx)("span",{className:"text-[11px] font-semibold text-ink",children:a}),(0,d.jsxs)("span",{className:"text-[11px] text-dim",children:["лишилось ",(0,d.jsxs)("span",{className:`font-bold tabular-nums ${j<=30?"":"text-ink"}`,style:j<=30?{color:k}:void 0,children:[Math.round(j),"%"]})]})]}),(0,d.jsx)("div",{className:"mt-1 h-[4px] overflow-hidden rounded-full bg-chip",children:(0,d.jsx)("div",{className:"h-full rounded-full transition-[width] duration-700 ease-out",style:{width:Math.max(j,1.5)+"%",backgroundColor:k}})}),b.resetsAt?(0,d.jsxs)("div",{className:"mt-[3px] text-[10px] leading-none text-dim",children:["скид ",(g=b.resetsAt-e)<=60?"зараз":g<5400?"через "+Math.round(g/60)+" хв":g<129600?"через "+Math.round(g/3600)+" год":"через "+Math.round(g/86400)+" д"," \xb7 ",(f=b.resetsAt,i=(h=new Date(1e3*f)).toLocaleTimeString("uk",{hour:"2-digit",minute:"2-digit",hour12:!1}),f-e<86400?i:h.toLocaleDateString("uk",{day:"numeric",month:"short"})+" "+i)]}):null]})}function c_({label:a,engine:b,limits:c,now:e,staleHint:f}){if(!c||!c.session&&!c.weekly)return null;let g=L[b]??M,h=c.capturedAt&&e-c.capturedAt>1200?H(c.capturedAt):null;return(0,d.jsxs)("div",{className:`mt-2.5 first:mt-0 ${f?"opacity-60":""}`,children:[(0,d.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,d.jsx)("span",{className:"text-[11.5px] font-bold",style:{color:g.color},children:a}),c.plan?(0,d.jsx)("span",{className:"truncate text-[10px] text-dim",children:c.plan}):null,f?(0,d.jsx)("span",{className:"truncate text-[10px] text-dim",children:f}):null,h?(0,d.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 self-center rounded-full bg-[#d29a2f]",title:`дані застарілі: ${h}`}):null]}),(0,d.jsx)(c$,{label:"5 год",window:c.session,engineColor:g.color,now:e}),(0,d.jsx)(c$,{label:"Тиждень",window:c.weekly,engineColor:g.color,now:e})]})}function c0(){let[a,b]=(0,e.useState)(null);if(!a||!a.data.claude&&!a.data.codex)return null;let c=function(a){if(!a)return null;let b=new Date(a);return Number.isNaN(b.getTime())?null:"станом на "+b.toLocaleTimeString("uk",{hour:"2-digit",minute:"2-digit",hour12:!1})}(a.data.staleSince);return(0,d.jsxs)("div",{className:"shrink-0 border-t border-line px-3.5 pb-3 pt-2.5",children:[(0,d.jsx)(c_,{label:"Claude",engine:"claude",limits:a.data.claude,now:a.at,staleHint:c}),(0,d.jsx)(c_,{label:"Codex",engine:"codex",limits:a.data.codex,now:a.at,staleHint:c})]})}let c1=k("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]),c2=k("bell-off",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]);function c3(){let[a,b]=(0,e.useState)(!1),[c,f]=(0,e.useState)(!1),g=async()=>{if(!c||"default"===Notification.permission&&"granted"!==await Notification.requestPermission()||"granted"!==Notification.permission)return;let a=await navigator.serviceWorker.register("/question-push-sw.js"),d=await a.pushManager.getSubscription();if(d){await d.unsubscribe(),b(!1);return}let e=await (await fetch("/api/push")).json(),f=await a.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:function(a){let b=atob((a+"=".repeat((4-a.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/")),c=new Uint8Array(b.length);for(let a=0;a<b.length;a+=1)c[a]=b.charCodeAt(a);return c.buffer.slice(0)}(e.publicKey)});await fetch("/api/push",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(f)}),b(!0)};return(0,d.jsx)("button",{className:"inline-flex h-[26px] w-[26px] shrink-0 items-center justify-center rounded-full border border-line bg-panel text-dim hover:text-ink disabled:opacity-45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",title:c?a?"Push-сповіщення увімкнено":"Увімкнути push-сповіщення":"Push потребує HTTPS","aria-label":c?a?"Вимкнути push-сповіщення":"Увімкнути push-сповіщення":"Push потребує HTTPS","aria-pressed":a,disabled:!c,onClick:g,children:a?(0,d.jsx)(c1,{className:"h-3.5 w-3.5","aria-hidden":!0}):(0,d.jsx)(c2,{className:"h-3.5 w-3.5","aria-hidden":!0})})}function c4({files:a,archivedProjects:b,selected:c,onSelect:f}){let[g,h]=(0,e.useState)(""),[i,j]=(0,e.useState)(!1),k=(0,e.useMemo)(()=>v(a),[a]),l=(0,e.useMemo)(()=>{let a=g.trim().toLowerCase();return a?k.filter(b=>b.project.toLowerCase().includes(a)):k},[k,g]),m=(0,e.useMemo)(()=>l.filter(a=>!b.has(a.project)),[l,b]),o=(0,e.useMemo)(()=>l.filter(a=>b.has(a.project)),[l,b]),p=(0,e.useMemo)(()=>k.reduce((a,b)=>a+b.liveCount,0),[k]),q=(0,e.useMemo)(()=>k.reduce((a,b)=>a+b.attentionCount,0),[k]);return(0,d.jsxs)("aside",{className:"flex w-[248px] shrink-0 flex-col border-r border-line bg-panel",children:[(0,d.jsxs)("header",{className:"flex h-10 shrink-0 items-center gap-2 border-b border-line px-4 text-[13.5px] font-bold",children:["Логи агентів",p?(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-[#e5f6ea] px-2 py-0.5 text-[10.5px] font-bold text-ok",children:[(0,d.jsx)("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-ok"}),p]}):null,q?(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-[#fff1ca] px-2 py-0.5 text-[10.5px] font-bold text-[#8a5a00]",children:["⏸ ",q]}):null,(0,d.jsx)(cZ,{}),(0,d.jsx)(c3,{})]}),(0,d.jsx)("div",{className:"px-2.5 pb-1 pt-2.5",children:(0,d.jsx)("input",{className:"w-full rounded-[9px] border border-line bg-bg px-2.5 py-1.5 text-[12px] outline-none focus-visible:ring-2 focus-visible:ring-accent/40",placeholder:"Фільтр проєктів…",value:g,onChange:a=>h(a.target.value)})}),(0,d.jsxs)("nav",{className:"flex-1 overflow-y-auto px-2 pb-3 pt-1","aria-label":"Проєкти",children:[(0,d.jsx)(c5,{label:"Огляд",live:0,attention:0,total:null,age:"",active:c===n,hasLive:!1,onClick:()=>f(n)}),(0,d.jsx)("div",{className:"mx-2.5 my-1.5 border-t border-line"}),(0,d.jsx)(aS,{children:m.map(a=>(0,d.jsx)("div",{"data-flip-key":a.project,children:(0,d.jsx)(c5,{label:a.project,live:a.liveCount,attention:a.attentionCount,total:a.conversations,age:H(a.smt),active:c===a.project,hasLive:a.liveCount>0,onClick:()=>f(a.project)})},a.project))}),o.length?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"mx-2.5 my-1.5 border-t border-line"}),(0,d.jsxs)("button",{type:"button",className:"mb-0.5 flex w-full items-center gap-1.5 rounded-[10px] px-2.5 py-1.5 text-left text-[11.5px] font-bold text-dim hover:bg-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-expanded":i,onClick:()=>j(a=>!a),children:[(0,d.jsx)(an,{className:`h-3 w-3 shrink-0 transition-transform ${i?"rotate-90":""}`,"aria-hidden":!0}),(0,d.jsx)(af,{className:"h-3 w-3 shrink-0","aria-hidden":!0}),"Архів",(0,d.jsx)("span",{className:"font-semibold",children:o.length})]}),i?o.map(a=>(0,d.jsx)(c5,{label:a.project,live:a.liveCount,attention:a.attentionCount,total:a.conversations,age:H(a.smt),active:c===a.project,hasLive:a.liveCount>0,onClick:()=>f(a.project)},a.project)):null]}):null,m.length||o.length?null:(0,d.jsx)("div",{className:"px-3 py-4 text-center text-[12px] text-dim",children:"Нічого не знайдено"})]}),(0,d.jsx)(c0,{})]})}function c5({label:a,live:b,attention:c,total:e,age:f,active:g,hasLive:h,onClick:i}){return(0,d.jsxs)("button",{className:["mb-0.5 flex w-full items-center gap-2 rounded-[10px] border px-2.5 py-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",g?"border-line bg-bg shadow-card":"border-transparent hover:bg-bg"].join(" "),"aria-current":g?"page":void 0,onClick:i,children:[(0,d.jsx)("span",{className:["h-2 w-2 shrink-0 rounded-full",h?"animate-pulse bg-ok":"bg-[#d6d6dd]"].join(" ")}),(0,d.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,d.jsx)("span",{className:`block truncate text-[13px] ${g?"font-bold":"font-semibold"}`,children:a}),f?(0,d.jsx)("span",{className:"block text-[10.5px] text-dim",children:f}):null]}),b>0?(0,d.jsx)("span",{className:"shrink-0 rounded-full bg-[#e5f6ea] px-1.5 py-0.5 text-[10.5px] font-bold text-ok",children:b}):null,c>0?(0,d.jsxs)("span",{className:"shrink-0 rounded-full bg-[#fff1ca] px-1.5 py-0.5 text-[10.5px] font-bold text-[#8a5a00]",children:["⏸ ",c]}):null,null!==e?(0,d.jsx)("span",{className:"shrink-0 text-[11px] font-semibold text-dim",children:e}):null]})}function c6(){let{files:a,flows:b}=function(){let[a,b]=(0,e.useState)(ab);return a}();(0,e.useRef)(null);let{archivedProjects:c,archiveProject:f,unarchiveProject:g}=function(){let[a,b]=(0,e.useState)(()=>new Set),c=(0,e.useRef)(a);return{archivedProjects:a,archiveProject:(0,e.useCallback)(a=>{b(b=>{if(b.has(a))return b;let d=new Set(b);return d.add(a),c.current=d,aa(d),d})},[]),unarchiveProject:(0,e.useCallback)(a=>{b(b=>{if(!b.has(a))return b;let d=new Set(b);return d.delete(a),c.current=d,aa(d),d})},[])}}(),[h,i]=(0,e.useState)(n),[j,k]=(0,e.useState)(null),[m,o]=(0,e.useState)(null);(0,e.useRef)(null);let[p,q]=(0,e.useState)(0),r=(0,e.useCallback)(a=>{i(a),localStorage.setItem("llvProject",a),a!==n?history.replaceState(null,"","#p="+encodeURIComponent(a)):history.replaceState(null,"",location.pathname)},[]),s=(0,e.useCallback)(a=>{let b=u(a);cW(b,a.path),r(b),q(a=>a+1)},[r]),t=m?a.find(a=>a.path===m):null;return(0,d.jsxs)("div",{className:"flex h-full",children:[(0,d.jsx)(c4,{files:a,archivedProjects:c,selected:h,onSelect:r}),(0,d.jsxs)("main",{className:"flex min-w-0 flex-1 flex-col",children:[t?(0,d.jsxs)("div",{className:"fixed right-4 top-4 z-50 flex max-w-[360px] gap-2 rounded-[8px] border border-[#e0ae45]/45 bg-[#fff9ed] px-4 py-3 text-[13px] font-semibold text-ink shadow-card",children:[(0,d.jsxs)("button",{className:"min-w-0 flex-1 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40",onClick:()=>{s(t),o(null)},children:[(0,d.jsx)("span",{className:"block text-[11px] font-bold text-[#8a5a00]",children:"Агент чекає відповіді"}),(0,d.jsx)("span",{className:"line-clamp-2",children:t.title})]}),(0,d.jsx)("button",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-line bg-bg text-dim hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40","aria-label":"Закрити сповіщення",onClick:()=>o(null),children:(0,d.jsx)(l,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}):null,h===n?(0,d.jsx)(ac,{files:a,archivedProjects:c,onSelectProject:r,onSelectFile:s}):(0,d.jsx)(cX,{files:a,flows:b,project:h,openNonce:p,archived:c.has(h),onArchive:f,onUnarchive:g})]})]})}},96487:()=>{}};var b=require("../webpack-runtime.js");b.C(a);var c=b.X(0,[445,319,918],()=>b(b.s=89175));module.exports=c})();