@wjarka/cezarion 0.18.0-dev.6478 → 0.18.0-dev.6548

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 (44) hide show
  1. package/package.json +2 -2
  2. package/web/dist/assets/{activity-motion-Cd6HKRn5.js → activity-motion-CEnf2rDh.js} +2 -2
  3. package/web/dist/assets/{activity-route-Dgjznc_j.js → activity-route--Qj4NT9h.js} +1 -1
  4. package/web/dist/assets/{agent-accounts-WZgtbThS.js → agent-accounts-BxpWcFS3.js} +1 -1
  5. package/web/dist/assets/attention-BDa7opY9.js +1 -0
  6. package/web/dist/assets/{commit-diff-panel-Bsf9f2Cd.js → commit-diff-panel-DOgakNKv.js} +1 -1
  7. package/web/dist/assets/{diff-BB8od2CB.js → diff-MoyKcT8Q.js} +2 -2
  8. package/web/dist/assets/{diff-view-Bbf1guXZ.js → diff-view-BFQcOCEf.js} +1 -1
  9. package/web/dist/assets/{file-preview-DYaWK5Hi.js → file-preview-BancpZHA.js} +1 -1
  10. package/web/dist/assets/{git-toolbar-CPxEOnk6.js → git-toolbar-ClMasBRM.js} +1 -1
  11. package/web/dist/assets/{github-4ILuqTHS.js → github-BVZ01nJq.js} +1 -1
  12. package/web/dist/assets/{global-activity-route-BaL40ikO.js → global-activity-route-DTgywy--.js} +1 -1
  13. package/web/dist/assets/index-CsOa03VW.js +17 -0
  14. package/web/dist/assets/{index-Bv_JpzCB.css → index-DTIPJ2b8.css} +1 -1
  15. package/web/dist/assets/{preview-pane-connected-CVIYmAKK.js → preview-pane-connected-B5PCWA9a.js} +2 -2
  16. package/web/dist/assets/{project-router-_4jaKCY-.js → project-router-CiB1O_5A.js} +1 -1
  17. package/web/dist/assets/{project-scope-context-BwaC58sQ.js → project-scope-context-CSPQyWoO.js} +1 -1
  18. package/web/dist/assets/{prompt-template-menu-Q6yvBBX2.js → prompt-template-menu-VwBcsbqE.js} +1 -1
  19. package/web/dist/assets/{queries-jqgF_s0L.js → queries-pj368bmB.js} +1 -1
  20. package/web/dist/assets/{reference-chip-BFXq2y0V.js → reference-chip-DT-_ninM.js} +1 -1
  21. package/web/dist/assets/{repo-git-BXcJkKGQ.js → repo-git-7KuJaDRk.js} +1 -1
  22. package/web/dist/assets/{report-reader-B2xFHTUH.js → report-reader-CgY75QM2.js} +1 -1
  23. package/web/dist/assets/reports-CxTUchWh.js +1 -0
  24. package/web/dist/assets/run-header-BcX23gw7.js +2 -0
  25. package/web/dist/assets/{skills-C1zxbSly.js → skills-Dnrta_-m.js} +1 -1
  26. package/web/dist/assets/{tab-link-BmBr8sDS.js → tab-link-BPBiho7-.js} +1 -1
  27. package/web/dist/assets/{task-changes-DDHU2MYs.js → task-changes-C6sDd3Le.js} +1 -1
  28. package/web/dist/assets/{task-commits-ntmx-1wH.js → task-commits-CQHxnFJ5.js} +1 -1
  29. package/web/dist/assets/{task-files-DlUIW3P5.js → task-files-DK8Demuc.js} +1 -1
  30. package/web/dist/assets/{task-github-item-Qg7SGfny.js → task-github-item-DgmmFFtN.js} +1 -1
  31. package/web/dist/assets/{task-thread-BKdI_JXT.js → task-thread-Dg9VWJq6.js} +6 -6
  32. package/web/dist/assets/{thread-state-D8yAejJN.js → thread-state-DIMUAyFk.js} +1 -1
  33. package/web/dist/assets/{use-desktop-DpH_9i2n.js → use-desktop-Bq_Qh5ur.js} +1 -1
  34. package/web/dist/assets/{use-hand-to-agent-state-DSRe0E7u.js → use-hand-to-agent-state-D-yaVRRx.js} +1 -1
  35. package/web/dist/assets/{useInfiniteQuery-BK0ElV__.js → useInfiniteQuery-Q8eFXz-L.js} +1 -1
  36. package/web/dist/assets/useQuery-BoLjCS2U.js +1 -0
  37. package/web/dist/assets/{workflows-CK12d25D.js → workflows-W_uriBcj.js} +2 -2
  38. package/web/dist/assets/{ws-CayNmoGi.js → ws-B-tB133E.js} +1 -1
  39. package/web/dist/index.html +13 -13
  40. package/web/dist/assets/attention-C_kiJ1bk.js +0 -1
  41. package/web/dist/assets/index-BXr2mRSZ.js +0 -17
  42. package/web/dist/assets/reports-JoaY6sCT.js +0 -1
  43. package/web/dist/assets/run-header-4CYT6aL6.js +0 -2
  44. package/web/dist/assets/useQuery-Qq5WoH8B.js +0 -1
@@ -1,4 +1,4 @@
1
- import{t as e,u as t}from"./button-DGwhwRuD.js";import{t as n}from"./react-runtime-CCIEwYL0.js";import{dr as r,fr as i}from"./project-scope-context-BwaC58sQ.js";import{G as a,K as o,_ as s,f as c,g as l,h as ee,m as u}from"./live-protocol-aMLJJ0MQ.js";import{t as d}from"./createLucideIcon-BHp8sXmF.js";import{t as f}from"./app-window-CSHwDX9N.js";import{i as p}from"./format-BNCkW110.js";import{t as te}from"./play-CmVAj_fu.js";import{$t as ne,Kt as re,cn as ie,g as ae,h as oe}from"./index-BXr2mRSZ.js";var m=d(`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`}]]),h=d(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),g=n(),_={registered:e=>e.server.answeredAtRegistration?{label:`Open`,run:!1}:{label:`Run and open`,run:!0},adopted:()=>({label:`Open`,run:!1}),starting:()=>({label:`Open`,run:!1}),up:()=>({label:`Open`,run:!1}),stalled:()=>({label:`View`,run:!1}),exited:()=>({label:`Start again`,run:!0}),stopped:()=>({label:`Start again`,run:!0}),unavailable:()=>void 0};function v(e){let{text:t,...n}=ae(e),r={...n,status:t},i=_[e.state](e);return i?{...r,action:i}:r}var se={"Run and open":te,Open:f,View:ie,"Start again":m};function ce({entry:e,inPreview:n,onOpen:r}){let{server:i}=e,a=v(e),o=e.state===`unavailable`,s=r?a.action:void 0,c=oe(i.command),l=p(i.registeredAt);return(0,g.jsxs)(`div`,{"data-slot":`preview-server-card`,"data-state":e.state,className:t(`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,o&&`text-muted-foreground`),children:[(0,g.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,g.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,g.jsx)(h,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,g.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),o?(0,g.jsx)(`span`,{children:`worktree removed`}):l?(0,g.jsxs)(`span`,{children:[l,` ago`]}):null]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,g.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,g.jsx)(re,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse===!0,"aria-hidden":`true`}),(0,g.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.label}),(0,g.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,i.port]}),(0,g.jsx)(`span`,{className:`text-muted-foreground`,children:a.status})]}),(0,g.jsx)(le,{entry:e,inPreview:n,action:s,onOpen:r})]}),(0,g.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,g.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:i.command}),i.cwd?(0,g.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,g.jsx)(`span`,{children:`cwd`}),(0,g.jsx)(`span`,{className:`break-all`,children:i.cwd})]}):null]}),s?.run?(0,g.jsx)(y,{icon:(0,g.jsx)(ne,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),children:`${s.label===`Start again`?`Starting again`:`Opening`} runs ${c} in this task's worktree, on the host.`}):null,o?(0,g.jsx)(y,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function le({entry:t,inPreview:n,action:r,onOpen:i}){let{server:a}=t,o=n&&r!==void 0&&!r.run,s=o?`In preview`:r?.label,c=o?f:r?se[r.label]:null;return r&&s&&c?(0,g.jsxs)(e,{variant:o||r.label===`View`||r.label===`Open`&&t.state===`starting`?`outline`:`contrast`,size:`sm`,className:`max-md:h-11 max-md:px-3.5`,onClick:()=>i?.({port:a.port,run:r.run}),children:[(0,g.jsx)(c,{"aria-hidden":`true`}),s]}):null}function y({icon:e,children:t}){return(0,g.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,g.jsx)(`span`,{children:t})]})}var b=120;function x(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function S(e){let t=e.replace(/\s+/g,` `).trim();return t.length>b?`${t.slice(0,b-1)}…`:t}function C(e,...t){if(x(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return S(t)}}function ue(e){if(!x(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return S(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return S(e.join(` `))}}function de(e){if(!x(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)x(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function w(e){return C(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function T(e,t){return t?`${e} ${t}`:e}var fe=new Map([[`bash`,`execute`],[`commandexecution`,`execute`],[`edit`,`edit`],[`multiedit`,`edit`],[`write`,`edit`],[`notebookedit`,`edit`],[`filechange`,`edit`],[`read`,`read`],[`imageview`,`read`],[`glob`,`search`],[`grep`,`search`],[`webfetch`,`fetch`],[`websearch`,`fetch`],[`task`,`task`],[`agent`,`task`],[`skill`,`task`],[`todowrite`,`plan`],[`todolist`,`plan`],[`plan`,`plan`],[`taskcreate`,`plan`],[`taskupdate`,`plan`],[`tasklist`,`plan`],[`contextcompaction`,`other`],[`mcptoolcall`,`other`]]);function pe(e,t){switch(e){case`write`:return{toolKind:`edit`,title:T(`Write`,C(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:T(`Edit`,C(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=de(t);return{toolKind:`edit`,title:T(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}default:return{toolKind:`edit`,title:T(`Edit`,C(t,`file_path`,`filePath`,`path`))}}}function me(e,t){return e===`imageview`?{toolKind:`read`,title:T(`View image`,C(t,`path`))}:{toolKind:`read`,title:T(`Read`,C(t,`file_path`,`filePath`,`path`))}}function he(e,t){return e===`webfetch`?{toolKind:`fetch`,title:T(`Fetch`,C(t,`url`))}:{toolKind:`fetch`,title:T(`Web search`,C(t,`query`))}}function ge(e,t){if(e===`skill`){let e=C(t,`skill`,`name`,`command`);return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:C(t,`args`,`description`)}}let n=e===`agent`?`Agent`:`Task`,r=C(t,`subagent_type`,`subagentType`),i=C(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${n}: ${i}`:n,subtitle:i===r?void 0:r}}function _e(e,t,n){if(t===`contextcompaction`)return{toolKind:`other`,title:`Compacted context`};if(t===`mcptoolcall`){let e=C(n,`server`),t=C(n,`tool`);return e&&t?{toolKind:`other`,title:`${e}.${t}`}:{toolKind:`other`,title:`MCP tool`,subtitle:w(n)}}if(t.startsWith(`mcp__`)){let t=e.split(`__`).filter(e=>e!==``);if(t.length>=3)return{toolKind:`other`,title:`${t[1]}.${t.slice(2).join(`__`)}`}}return{toolKind:`other`,title:typeof e==`string`&&e.trim()!==``?S(e):`Tool`,subtitle:w(n)}}function ve(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(fe.get(n)){case`execute`:return{toolKind:`execute`,title:T(`Ran`,ue(t)),subtitle:C(t,`description`)};case`edit`:return pe(n,t);case`read`:return me(n,t);case`search`:return{toolKind:`search`,title:T(`Search`,C(t,`pattern`,`query`)),subtitle:C(t,`path`)};case`fetch`:return he(n,t);case`task`:return ge(n,t);case`plan`:return{toolKind:`plan`,title:`Update plan`};default:return _e(e,n,t)}}function ye(e,t){if(t.type===`ask.requested`&&typeof t.requestId==`string`&&a.safeParse({questions:t.questions}).success)return t;if(t.type===`human-input-delivered`||t.type===`human-ask-closed`){let n=(t.type===`human-input-delivered`?l:ee).safeParse(t);if(n.success&&n.data.askSeq===e?.seq)return}return e}function E(e){if(!(e.type!==`ask.requested`||typeof e.requestId!=`string`))return{requestId:e.requestId,questions:e.questions,...e.context===void 0?{}:{context:e.context}}}function D(e){let t=E(e);return t&&{seq:e.seq,...t}}function O(e,t){let n=ye(e&&{type:`ask.requested`,seq:e.seq,ts:``},t);return n===t?D(t):n===void 0?void 0:e}function k(e){let t;for(let n of e)t=O(t,n);return t}function A(e){let t=Array.isArray(e.questions)?e.questions.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.header==`string`&&(e.options===void 0||Array.isArray(e.options))):[];if(t.length===0)return;let n=typeof e.context==`string`&&e.context!==``?e.context:void 0;return{id:e.requestId,questions:t,...n===void 0?{}:{context:n},askSeq:e.seq}}function j(){return{turns:[],itemsById:new Map,turnSeq:0,permissions:new Map,conversationEntries:new Map,outcomesByRequest:new Map,seenInputs:new Set,previewByPort:new Map,handedOff:!1}}function M(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function N(e){return typeof e==`string`?e:void 0}function P(e){let t=typeof e==`string`?new Date(e):void 0;return!t||Number.isNaN(t.getTime())?``:` · ${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}`}function F(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}var be=new Set(o.options);function xe(e){return typeof e==`string`&&be.has(e)?e:void 0}function I(e,t){e.turnSeq+=1;let n={id:t===void 0?`turn-fallback-${e.turnSeq}`:`turn-seq-${t}`,entries:[],v2Items:!1};return e.turns.push(n),n}function L(e){return e.turns.at(-1)??I(e)}function R(e,t){L(e).entries.push({origin:`meta`,entry:t})}function z(e){for(let t of e.permissions.values())t.status===`pending`&&(t.status=`expired`)}function B(e,t){let n=N(e.stepId);return n===void 0?t:`${n}:${t}`}function Se(e,t){t.v2Items=!0;for(let n of t.entries)n.origin===`v1`&&n.entry.kind===`tool`&&e.itemsById.delete(n.entry.id);t.entries=t.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}function Ce(e,t,n,r,i){let a=n.kind===`message`&&i!==void 0?{...n,ts:i}:{...n};!t.v2Items&&a.kind!==`hook`&&Se(e,t);let o=e.itemsById.get(r);if(o&&o.turn===t){o.entry.entry=a;return}let s={origin:`v2`,entry:a};t.entries.push(s),e.itemsById.set(r,{turn:t,entry:s})}var V={"not-delivered":0,queued:1,delivered:2,consumed:3},we=[`instruction`,`resumed`,`requestId`,`relationship`,`state`,`createdAt`,`requestHash`,`deadline`];function H(e){let t={};for(let n of we)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}function U(e,t){if(t.messageKind!==`request`)return;let n=e.outcomesByRequest.get(t.messageId);n&&(t.outcome={status:n.status,...n.replyId===void 0?{}:{replyId:n.replyId},observedAt:n.observedAt})}function Te(e,t){let n=e.conversationEntries.get(t);n&&U(e,n)}function Ee(e,t,n,r){(V[e.delivery]<V.delivered||V[n]>V[e.delivery])&&(e.delivery=n),t.text!==``&&(e.text=t.text),Object.assign(e,H(t)),r.deliveredAt!==void 0&&(e.deliveredAt=r.deliveredAt),r.consumedAt!==void 0&&(e.consumedAt=r.consumedAt),r.recordedAt!==void 0&&(n===`delivered`||e.delivery!==`delivered`)&&(e.recordedAt=r.recordedAt)}function W(e,t,n,r){let i=e.conversationEntries.get(t.id);if(i){Ee(i,t,n,r),U(e,i);return}let a={kind:`conversation`,id:`conversation-message:${t.id}`,messageId:t.id,text:t.text,senderRunId:t.senderRunId,recipientRunId:t.recipientRunId,messageKind:t.kind,delivery:n,...r,...H(t)};U(e,a),e.conversationEntries.set(t.id,a),R(e,a)}function De(e,t){let n=P(t.ts),r=N(t.message),i=t.notify===!1?`Stopped notifying the webhook${n}`:`${e.handedOff?`Note sent to webhook`:`Handed off to webhook`}${n}${r?` — ${r}`:``}`;e.handedOff=t.notify!==!1,R(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`dim`,icon:`handoff`})}function Oe(e,t){let n=typeof t.attempts==`number`?t.attempts:void 0,r=N(t.webhookName),i=`${r?`Delivery to ${r} failed`:`Webhook delivery failed`}${N(t.event)?` (${N(t.event)})`:``}${n?` after ${n} attempt${n===1?``:`s`}`:``}: ${N(t.error)??`unknown error`}`;R(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`danger`})}function ke(e,t){let n=N(t.webhookName)??`webhook`,r=N(t.title),i=`v1:${t.seq}`;if(t.ok===!1){R(e,{kind:`note`,id:i,text:`Report to ${n} failed: ${N(t.error)??`unknown error`}`,tone:`danger`});return}let a=`${t.dryRun===!0?`Report to ${n} (dry run, nothing sent)`:`Sent report to ${n}`}${P(t.ts)}${r?` — ${r}`:``}`;R(e,t.dryRun===!0?{kind:`note`,id:i,text:a,tone:`dim`}:{kind:`note`,id:i,text:a,tone:`dim`,icon:`handoff`})}function Ae(e,t){let n=t.payload??{},r=`Webhook (dry run, nothing sent): ${N(t.event)??`delivery`}${N(n.status)?` · ${N(n.status)}`:``}`;R(e,{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`})}function je(e,t){let n=r.safeParse(t.server);if(!n.success)return;let i=e.previewByPort.get(n.data.port);i&&(i.turn.entries=i.turn.entries.filter(e=>e!==i.draft));let a=L(e),o={origin:`meta`,entry:{kind:`preview-server`,id:`preview-server:${n.data.port}`,server:n.data,state:`registered`,stateAt:t.ts}};a.entries.push(o),e.previewByPort.set(n.data.port,{turn:a,draft:o})}function Me(e,t){let n=i.safeParse(t.state),r=typeof t.port==`number`?e.previewByPort.get(t.port):void 0;if(!n.success||!r||r.draft.entry.kind!==`preview-server`)return;let{server:a,id:o}=r.draft.entry;r.draft.entry={kind:`preview-server`,id:o,server:a,state:n.data,stateAt:t.ts,...typeof t.exitCode==`number`?{exitCode:t.exitCode}:{},...t.reason===`user`||t.reason===`idle`?{reason:t.reason}:{}}}function Ne(e,t){let n=u.safeParse(t);if(!n.success)return;let{message:r,delivery:i,deliveredAt:a,consumedAt:o,ts:s}=n.data;W(e,r,i,{deliveredAt:a,consumedAt:o,recordedAt:s})}function Pe(e,t){let n=s.safeParse(t);if(!n.success)return;let{outcome:r}=n.data,i=e.outcomesByRequest.get(r.requestId);i&&!(i.status===`timed-out`&&r.status===`replied-late`)||(e.outcomesByRequest.set(r.requestId,r),Te(e,r.requestId))}function Fe(e,t){let n=c.safeParse(t);if(!n.success)return;let{input:r}=n.data;if(!e.seenInputs.has(r.id)){if(e.seenInputs.add(r.id),r.conversation){W(e,{id:r.id,text:r.text,createdAt:r.createdAt,...r.conversation},`delivered`,{deliveredAt:r.deliveredAt,recordedAt:n.data.ts});return}R(e,{kind:`note`,id:`agent-input:${r.id}`,text:r.text,tone:`dim`,attribution:{source:r.source,parentRunId:r.parentRunId}})}}function Ie(e,t){let n=N(t.text)??``,r=e.pendingAsk;e.pendingAsk&&!e.pendingAsk.resolved&&(e.pendingAsk.resolved=!0,e.pendingAsk.answeredBy=`human`,n!==``&&(e.pendingAsk.answer=n),e.pendingAsk=void 0);let i=I(e,t.seq),a=F(t.ts);i.userMessage={text:n,ask:r,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[],...a===void 0?{}:{ts:a}},a!==void 0&&(i.startedAt=a)}function Le(e,t){let n=e.turns.at(-1),r=n&&n.turnId===void 0&&!n.v2Items?n:I(e,t.seq);r.turnId=N(t.turnId),r.startedAt??=F(t.ts)}function Re(e,t){for(let n=e.turns.length-1;n>=0;--n)if(e.turns[n].turnId===t)return e.turns[n];return e.turns.at(-1)}function ze(e,t){z(e);let n=Re(e,N(t.turnId));if(!n)return;let r=F(t.ts);n.completed={stopReason:N(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...r===void 0?{}:{ts:r}}}var G=new Set([`message`,`reasoning`,`tool`,`hook`]),Be=e=>G.has(e.kind);function Ve(e){if(!(!M(e)||!G.has(e.kind)))return typeof e.id==`string`&&e.id!==``?e:void 0}function K(e,t){let n=Ve(t.item);if(!n)return;let r=B(t,n.id);Ce(e,e.itemsById.get(r)?.turn??L(e),n,r,t.type===`item.completed`?F(t.ts):void 0)}function He(e,t){let n=e.itemsById.get(B(t,N(t.itemId)??``)),r=N(t.delta)??``;if(!n||r===``||!Be(n.entry.entry))return;let i=n.entry.entry;t.field===`output`&&i.kind===`tool`?i.output=(i.output??``)+r:t.field!==`output`&&(i.kind===`message`||i.kind===`reasoning`)&&(i.text+=r)}function Ue(e,t){let n=L(e),r=N(t.text)??``;if(r===``)return;let i=F(t.ts);n.entries.push({origin:`v1`,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:r,...i===void 0?{}:{ts:i}}})}var We=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Ge(e){if(!M(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!M(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:We.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}var Ke=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function qe(e,t){let n=L(e),r=N(t.tool)??`Tool`;if(n.v2Items||Ke.has(r))return;let i=ve(r,t.input),a=i.toolKind===`plan`?Ge(t.input):void 0;a!==void 0&&(n.planEntries=a);let o={kind:`tool`,id:N(t.id)??`v1:${t.seq}`,name:r,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},s={origin:`v1`,entry:o};n.entries.push(s),e.itemsById.set(o.id,{turn:n,entry:s})}function Je(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}function Ye(e,t){let n=e.itemsById.get(N(t.toolCallId)??``);if(!n||n.turn.v2Items||n.entry.origin!==`v1`)return;let r=n.entry.entry;r.kind===`tool`&&(r.status=`completed`,r.output=Je(t.result))}function q(e,t,n,r){let i=N(t.message)??``;i!==``&&R(e,{kind:`note`,id:n,text:i,tone:r})}function J(e,t){q(e,t,`v1:${t.seq}`,t.tone===`danger`?`danger`:`dim`)}function Xe(e,t){q(e,t,`v1:${t.seq}`,`danger`)}function Ze(e,t){q(e,t,`v2:${t.seq}`,`danger`)}function Qe(e,t){if(t.status!==`failed`)return;let n=N(t.error)?` — ${N(t.error)}`:``;R(e,{kind:`note`,id:`v1:${t.seq}`,text:`step ${N(t.stepId)??`?`} failed${n}`,tone:`danger`})}function $e(e,t){let n=N(t.command)??`check`,r=typeof t.exitCode==`number`?t.exitCode:-1;R(e,{kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${n}`,status:r===0?`completed`:`failed`,output:N(t.text)??``,exitCode:r})}function et(e,t){let n=xe(t.provider),r=N(t.authFailureId)??``;n===void 0||r.length<1||r.length>128||R(e,{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:n,authFailureId:r})}function tt(e,t){let n=N(t.url);if(n===void 0)return;let r={kind:`image`,id:`v1:${t.seq}`,url:n},i=N(t.name);i!==void 0&&(r.name=i),R(e,r)}function nt(e,t){Array.isArray(t.entries)&&(L(e).planEntries=t.entries)}function rt(e,t){z(e);let n=N(t.message);e.sessionEnded={reason:N(t.reason)??`end_turn`,...n===void 0?{}:{message:n}}}var it=new Set([`allow_once`,`allow_always`,`reject_once`,`reject_always`]);function at(e){return M(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.label==`string`&&e.label!==``&&it.has(e.kind)}function ot(e){if(!(!Array.isArray(e)||e.length===0||!e.every(at)))return new Set(e.map(e=>e.id)).size===e.length?e:void 0}function st(e,t){let n=N(t.requestId),r=N(t.title),i=ot(t.options);if(!n||!r||e.permissions.has(n)||!i)return;let a=N(t.itemId),o=N(t.details),s={kind:`permission`,id:`permission:${n}`,requestId:n,title:r,options:i.map(e=>({...e})),status:`pending`,...a===void 0?{}:{itemId:a},...o===void 0?{}:{details:o}};e.permissions.set(n,s),R(e,s)}function ct(e,t){let n=e.permissions.get(N(t.requestId)??``);if(!n||n.status!==`pending`)return;let r=N(t.optionId);r!==void 0&&n.options.some(e=>e.id===r)?(n.status=`resolved`,n.optionId=r):n.status=`expired`;let i=N(t.reason);i!==void 0&&(n.reason=i)}function lt(e,t){let n=D(t),r=n&&A(n);if(!r)return;let i={kind:`ask`,...r,questions:r.questions,resolved:!1};R(e,i),e.pendingAsk=i}function Y(e,t){let n=e.pendingAsk;return n&&!n.resolved&&n.askSeq===t.askSeq?n:void 0}function ut(e,t){let n=Y(e,t);if(!n)return;n.routedToParent=!0;let r=N(t.parentRunId);r!==void 0&&(n.parentRunId=r)}function dt(e,t){let n=Y(e,t);n&&(n.routedToParent=!1)}function ft(e,t){let n=Y(e,t);n&&X(e,n,`undeliverable`)}var pt=new Set([`finish`,`superseded`,`parent-stopped`,`worker-stopped`,`undeliverable`]);function mt(e,t){let n=Y(e,t);n&&pt.has(t.reason)&&X(e,n,t.reason)}function X(e,t,n){t.resolved=!0,t.closed=n,e.pendingAsk=void 0}function Z(e,t){let n=Y(e,t);if(n){if(t.source===`cezar`){X(e,n,`undeliverable`);return}t.source===`parent`&&(n.resolved=!0,n.answeredBy=`parent`,e.pendingAsk=void 0)}}var Q=()=>{},ht=new Map([[`handoff`,De],[`webhook.failed`,Oe],[`webhook.dry-run`,Ae],[`webhook.report`,ke],[`preview.server-registered`,je],[`preview.server-state`,Me],[`conversation-message`,Ne],[`request-outcome`,Pe],[`agent-input`,Fe],[`user-message`,Ie],[`turn.started`,Le],[`turn.completed`,ze],[`item.started`,K],[`item.updated`,K],[`item.completed`,K],[`item.delta`,He],[`text`,Ue],[`tool-call`,qe],[`tool-result`,Ye],[`note`,J],[`lifecycle`,J],[`error`,Xe],[`session.error`,Ze],[`step-end`,Qe],[`check-output`,$e],[`provider-auth-required`,et],[`image`,tt],[`plan.updated`,nt],[`session.started`,e=>z(e)],[`session.ended`,rt],[`permission.requested`,st],[`permission.resolved`,ct],[`ask.requested`,lt],[`worker-question-routed`,ut],[`worker-question-fallback`,dt],[`worker-question-undelivered`,ft],[`human-ask-closed`,mt],[`human-input-delivered`,Z],[`step-start`,Q],[`token-usage`,Q],[`cost`,Q],[`turn-end`,Q],[`done`,Q],[`session`,Q]]);function gt(e,t){ht.get(t.type)?.(e,t)}function _t(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function vt(e){let t=[];for(let n of e.turns)for(let e of n.items)if(e.kind===`tool`){for(let n of e.locations??[])t.push(n.path);for(let n of e.diffs??[])t.push(n.path)}let n=[];for(let e=t.length-1;e>=0;--e)n.includes(t[e])||n.push(t[e]);return n}function yt(e,t){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t?`Session failed — ${t}`:`Session failed`};case`review`:return{state:`closed`,tone:`dim`,label:`Session closed — waiting for your review`};case`done`:case`cancelled`:return{state:`closed`,tone:`dim`,label:`Session closed`};default:return null}}function $(e,t){let n=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``);if(t){let e=n.trimEnd(),t=e.lastIndexOf(`
1
+ import{t as e,u as t}from"./button-DGwhwRuD.js";import{t as n}from"./react-runtime-CCIEwYL0.js";import{dr as r,ur as i}from"./project-scope-context-CSPQyWoO.js";import{G as a,K as o,_ as s,f as c,g as l,h as ee,m as u}from"./live-protocol-aMLJJ0MQ.js";import{t as d}from"./createLucideIcon-BHp8sXmF.js";import{t as f}from"./app-window-CSHwDX9N.js";import{i as p}from"./format-BNCkW110.js";import{t as te}from"./play-CmVAj_fu.js";import{$t as ne,Kt as re,cn as ie,g as ae,h as oe}from"./index-CsOa03VW.js";var m=d(`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`}]]),h=d(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),g=n(),_={registered:e=>e.server.answeredAtRegistration?{label:`Open`,run:!1}:{label:`Run and open`,run:!0},adopted:()=>({label:`Open`,run:!1}),starting:()=>({label:`Open`,run:!1}),up:()=>({label:`Open`,run:!1}),stalled:()=>({label:`View`,run:!1}),exited:()=>({label:`Start again`,run:!0}),stopped:()=>({label:`Start again`,run:!0}),unavailable:()=>void 0};function v(e){let{text:t,...n}=ae(e),r={...n,status:t},i=_[e.state](e);return i?{...r,action:i}:r}var se={"Run and open":te,Open:f,View:ie,"Start again":m};function ce({entry:e,inPreview:n,onOpen:r}){let{server:i}=e,a=v(e),o=e.state===`unavailable`,s=r?a.action:void 0,c=oe(i.command),l=p(i.registeredAt);return(0,g.jsxs)(`div`,{"data-slot":`preview-server-card`,"data-state":e.state,className:t(`min-w-0 rounded-lg border border-border bg-card px-3.5 py-3 text-sm`,o&&`text-muted-foreground`),children:[(0,g.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-xs text-soft-foreground`,children:[(0,g.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono`,children:[(0,g.jsx)(h,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,g.jsx)(`span`,{className:`truncate`,children:`cezar_preview_serve`})]}),o?(0,g.jsx)(`span`,{children:`worktree removed`}):l?(0,g.jsxs)(`span`,{children:[l,` ago`]}):null]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-2`,children:[(0,g.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,g.jsx)(re,{tone:a.tone,shape:a.ring?`ring`:`filled`,pulse:a.pulse===!0,"aria-hidden":`true`}),(0,g.jsx)(`span`,{className:`font-semibold text-foreground`,children:i.label}),(0,g.jsxs)(`span`,{className:`font-mono text-muted-foreground`,children:[`:`,i.port]}),(0,g.jsx)(`span`,{className:`text-muted-foreground`,children:a.status})]}),(0,g.jsx)(le,{entry:e,inPreview:n,action:s,onOpen:r})]}),(0,g.jsxs)(`div`,{className:`mt-2.5 min-w-0 rounded-md bg-muted px-3 py-2 font-mono text-xs`,children:[(0,g.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:i.command}),i.cwd?(0,g.jsxs)(`p`,{className:`mt-1 flex gap-3 text-soft-foreground`,children:[(0,g.jsx)(`span`,{children:`cwd`}),(0,g.jsx)(`span`,{className:`break-all`,children:i.cwd})]}):null]}),s?.run?(0,g.jsx)(y,{icon:(0,g.jsx)(ne,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),children:`${s.label===`Start again`?`Starting again`:`Opening`} runs ${c} in this task's worktree, on the host.`}):null,o?(0,g.jsx)(y,{children:`The worktree this server ran in is gone. Register it again from a new task.`}):null]})}function le({entry:t,inPreview:n,action:r,onOpen:i}){let{server:a}=t,o=n&&r!==void 0&&!r.run,s=o?`In preview`:r?.label,c=o?f:r?se[r.label]:null;return r&&s&&c?(0,g.jsxs)(e,{variant:o||r.label===`View`||r.label===`Open`&&t.state===`starting`?`outline`:`contrast`,size:`sm`,className:`max-md:h-11 max-md:px-3.5`,onClick:()=>i?.({port:a.port,run:r.run}),children:[(0,g.jsx)(c,{"aria-hidden":`true`}),s]}):null}function y({icon:e,children:t}){return(0,g.jsxs)(`p`,{className:`mt-2.5 flex items-start gap-2 text-xs text-muted-foreground`,children:[e,(0,g.jsx)(`span`,{children:t})]})}var b=120;function x(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function S(e){let t=e.replace(/\s+/g,` `).trim();return t.length>b?`${t.slice(0,b-1)}…`:t}function C(e,...t){if(x(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return S(t)}}function ue(e){if(!x(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return S(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return S(e.join(` `))}}function de(e){if(!x(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)x(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function w(e){return C(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function T(e,t){return t?`${e} ${t}`:e}var fe=new Map([[`bash`,`execute`],[`commandexecution`,`execute`],[`edit`,`edit`],[`multiedit`,`edit`],[`write`,`edit`],[`notebookedit`,`edit`],[`filechange`,`edit`],[`read`,`read`],[`imageview`,`read`],[`glob`,`search`],[`grep`,`search`],[`webfetch`,`fetch`],[`websearch`,`fetch`],[`task`,`task`],[`agent`,`task`],[`skill`,`task`],[`todowrite`,`plan`],[`todolist`,`plan`],[`plan`,`plan`],[`taskcreate`,`plan`],[`taskupdate`,`plan`],[`tasklist`,`plan`],[`contextcompaction`,`other`],[`mcptoolcall`,`other`]]);function pe(e,t){switch(e){case`write`:return{toolKind:`edit`,title:T(`Write`,C(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:T(`Edit`,C(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=de(t);return{toolKind:`edit`,title:T(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}default:return{toolKind:`edit`,title:T(`Edit`,C(t,`file_path`,`filePath`,`path`))}}}function me(e,t){return e===`imageview`?{toolKind:`read`,title:T(`View image`,C(t,`path`))}:{toolKind:`read`,title:T(`Read`,C(t,`file_path`,`filePath`,`path`))}}function he(e,t){return e===`webfetch`?{toolKind:`fetch`,title:T(`Fetch`,C(t,`url`))}:{toolKind:`fetch`,title:T(`Web search`,C(t,`query`))}}function ge(e,t){if(e===`skill`){let e=C(t,`skill`,`name`,`command`);return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:C(t,`args`,`description`)}}let n=e===`agent`?`Agent`:`Task`,r=C(t,`subagent_type`,`subagentType`),i=C(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${n}: ${i}`:n,subtitle:i===r?void 0:r}}function _e(e,t,n){if(t===`contextcompaction`)return{toolKind:`other`,title:`Compacted context`};if(t===`mcptoolcall`){let e=C(n,`server`),t=C(n,`tool`);return e&&t?{toolKind:`other`,title:`${e}.${t}`}:{toolKind:`other`,title:`MCP tool`,subtitle:w(n)}}if(t.startsWith(`mcp__`)){let t=e.split(`__`).filter(e=>e!==``);if(t.length>=3)return{toolKind:`other`,title:`${t[1]}.${t.slice(2).join(`__`)}`}}return{toolKind:`other`,title:typeof e==`string`&&e.trim()!==``?S(e):`Tool`,subtitle:w(n)}}function ve(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(fe.get(n)){case`execute`:return{toolKind:`execute`,title:T(`Ran`,ue(t)),subtitle:C(t,`description`)};case`edit`:return pe(n,t);case`read`:return me(n,t);case`search`:return{toolKind:`search`,title:T(`Search`,C(t,`pattern`,`query`)),subtitle:C(t,`path`)};case`fetch`:return he(n,t);case`task`:return ge(n,t);case`plan`:return{toolKind:`plan`,title:`Update plan`};default:return _e(e,n,t)}}function ye(e,t){if(t.type===`ask.requested`&&typeof t.requestId==`string`&&a.safeParse({questions:t.questions}).success)return t;if(t.type===`human-input-delivered`||t.type===`human-ask-closed`){let n=(t.type===`human-input-delivered`?l:ee).safeParse(t);if(n.success&&n.data.askSeq===e?.seq)return}return e}function E(e){if(!(e.type!==`ask.requested`||typeof e.requestId!=`string`))return{requestId:e.requestId,questions:e.questions,...e.context===void 0?{}:{context:e.context}}}function D(e){let t=E(e);return t&&{seq:e.seq,...t}}function O(e,t){let n=ye(e&&{type:`ask.requested`,seq:e.seq,ts:``},t);return n===t?D(t):n===void 0?void 0:e}function k(e){let t;for(let n of e)t=O(t,n);return t}function A(e){let t=Array.isArray(e.questions)?e.questions.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e.header==`string`&&(e.options===void 0||Array.isArray(e.options))):[];if(t.length===0)return;let n=typeof e.context==`string`&&e.context!==``?e.context:void 0;return{id:e.requestId,questions:t,...n===void 0?{}:{context:n},askSeq:e.seq}}function j(){return{turns:[],itemsById:new Map,turnSeq:0,permissions:new Map,conversationEntries:new Map,outcomesByRequest:new Map,seenInputs:new Set,previewByPort:new Map,handedOff:!1}}function M(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function N(e){return typeof e==`string`?e:void 0}function P(e){let t=typeof e==`string`?new Date(e):void 0;return!t||Number.isNaN(t.getTime())?``:` · ${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}`}function F(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}var be=new Set(o.options);function xe(e){return typeof e==`string`&&be.has(e)?e:void 0}function I(e,t){e.turnSeq+=1;let n={id:t===void 0?`turn-fallback-${e.turnSeq}`:`turn-seq-${t}`,entries:[],v2Items:!1};return e.turns.push(n),n}function L(e){return e.turns.at(-1)??I(e)}function R(e,t){L(e).entries.push({origin:`meta`,entry:t})}function z(e){for(let t of e.permissions.values())t.status===`pending`&&(t.status=`expired`)}function B(e,t){let n=N(e.stepId);return n===void 0?t:`${n}:${t}`}function Se(e,t){t.v2Items=!0;for(let n of t.entries)n.origin===`v1`&&n.entry.kind===`tool`&&e.itemsById.delete(n.entry.id);t.entries=t.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}function Ce(e,t,n,r,i){let a=n.kind===`message`&&i!==void 0?{...n,ts:i}:{...n};!t.v2Items&&a.kind!==`hook`&&Se(e,t);let o=e.itemsById.get(r);if(o&&o.turn===t){o.entry.entry=a;return}let s={origin:`v2`,entry:a};t.entries.push(s),e.itemsById.set(r,{turn:t,entry:s})}var V={"not-delivered":0,queued:1,delivered:2,consumed:3},we=[`instruction`,`resumed`,`requestId`,`relationship`,`state`,`createdAt`,`requestHash`,`deadline`];function H(e){let t={};for(let n of we)e[n]!==void 0&&Object.assign(t,{[n]:e[n]});return t}function U(e,t){if(t.messageKind!==`request`)return;let n=e.outcomesByRequest.get(t.messageId);n&&(t.outcome={status:n.status,...n.replyId===void 0?{}:{replyId:n.replyId},observedAt:n.observedAt})}function Te(e,t){let n=e.conversationEntries.get(t);n&&U(e,n)}function Ee(e,t,n,r){(V[e.delivery]<V.delivered||V[n]>V[e.delivery])&&(e.delivery=n),t.text!==``&&(e.text=t.text),Object.assign(e,H(t)),r.deliveredAt!==void 0&&(e.deliveredAt=r.deliveredAt),r.consumedAt!==void 0&&(e.consumedAt=r.consumedAt),r.recordedAt!==void 0&&(n===`delivered`||e.delivery!==`delivered`)&&(e.recordedAt=r.recordedAt)}function W(e,t,n,r){let i=e.conversationEntries.get(t.id);if(i){Ee(i,t,n,r),U(e,i);return}let a={kind:`conversation`,id:`conversation-message:${t.id}`,messageId:t.id,text:t.text,senderRunId:t.senderRunId,recipientRunId:t.recipientRunId,messageKind:t.kind,delivery:n,...r,...H(t)};U(e,a),e.conversationEntries.set(t.id,a),R(e,a)}function De(e,t){let n=P(t.ts),r=N(t.message),i=t.notify===!1?`Stopped notifying the webhook${n}`:`${e.handedOff?`Note sent to webhook`:`Handed off to webhook`}${n}${r?` — ${r}`:``}`;e.handedOff=t.notify!==!1,R(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`dim`,icon:`handoff`})}function Oe(e,t){let n=typeof t.attempts==`number`?t.attempts:void 0,r=N(t.webhookName),i=`${r?`Delivery to ${r} failed`:`Webhook delivery failed`}${N(t.event)?` (${N(t.event)})`:``}${n?` after ${n} attempt${n===1?``:`s`}`:``}: ${N(t.error)??`unknown error`}`;R(e,{kind:`note`,id:`v1:${t.seq}`,text:i,tone:`danger`})}function ke(e,t){let n=N(t.webhookName)??`webhook`,r=N(t.title),i=`v1:${t.seq}`;if(t.ok===!1){R(e,{kind:`note`,id:i,text:`Report to ${n} failed: ${N(t.error)??`unknown error`}`,tone:`danger`});return}let a=`${t.dryRun===!0?`Report to ${n} (dry run, nothing sent)`:`Sent report to ${n}`}${P(t.ts)}${r?` — ${r}`:``}`;R(e,t.dryRun===!0?{kind:`note`,id:i,text:a,tone:`dim`}:{kind:`note`,id:i,text:a,tone:`dim`,icon:`handoff`})}function Ae(e,t){let n=t.payload??{},r=`Webhook (dry run, nothing sent): ${N(t.event)??`delivery`}${N(n.status)?` · ${N(n.status)}`:``}`;R(e,{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`})}function je(e,t){let n=i.safeParse(t.server);if(!n.success)return;let r=e.previewByPort.get(n.data.port);r&&(r.turn.entries=r.turn.entries.filter(e=>e!==r.draft));let a=L(e),o={origin:`meta`,entry:{kind:`preview-server`,id:`preview-server:${n.data.port}`,server:n.data,state:`registered`,stateAt:t.ts}};a.entries.push(o),e.previewByPort.set(n.data.port,{turn:a,draft:o})}function Me(e,t){let n=r.safeParse(t.state),i=typeof t.port==`number`?e.previewByPort.get(t.port):void 0;if(!n.success||!i||i.draft.entry.kind!==`preview-server`)return;let{server:a,id:o}=i.draft.entry;i.draft.entry={kind:`preview-server`,id:o,server:a,state:n.data,stateAt:t.ts,...typeof t.exitCode==`number`?{exitCode:t.exitCode}:{},...t.reason===`user`||t.reason===`idle`?{reason:t.reason}:{}}}function Ne(e,t){let n=u.safeParse(t);if(!n.success)return;let{message:r,delivery:i,deliveredAt:a,consumedAt:o,ts:s}=n.data;W(e,r,i,{deliveredAt:a,consumedAt:o,recordedAt:s})}function Pe(e,t){let n=s.safeParse(t);if(!n.success)return;let{outcome:r}=n.data,i=e.outcomesByRequest.get(r.requestId);i&&!(i.status===`timed-out`&&r.status===`replied-late`)||(e.outcomesByRequest.set(r.requestId,r),Te(e,r.requestId))}function Fe(e,t){let n=c.safeParse(t);if(!n.success)return;let{input:r}=n.data;if(!e.seenInputs.has(r.id)){if(e.seenInputs.add(r.id),r.conversation){W(e,{id:r.id,text:r.text,createdAt:r.createdAt,...r.conversation},`delivered`,{deliveredAt:r.deliveredAt,recordedAt:n.data.ts});return}R(e,{kind:`note`,id:`agent-input:${r.id}`,text:r.text,tone:`dim`,attribution:{source:r.source,parentRunId:r.parentRunId}})}}function Ie(e,t){let n=N(t.text)??``,r=e.pendingAsk;e.pendingAsk&&!e.pendingAsk.resolved&&(e.pendingAsk.resolved=!0,e.pendingAsk.answeredBy=`human`,n!==``&&(e.pendingAsk.answer=n),e.pendingAsk=void 0);let i=I(e,t.seq),a=F(t.ts);i.userMessage={text:n,ask:r,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[],...a===void 0?{}:{ts:a}},a!==void 0&&(i.startedAt=a)}function Le(e,t){let n=e.turns.at(-1),r=n&&n.turnId===void 0&&!n.v2Items?n:I(e,t.seq);r.turnId=N(t.turnId),r.startedAt??=F(t.ts)}function Re(e,t){for(let n=e.turns.length-1;n>=0;--n)if(e.turns[n].turnId===t)return e.turns[n];return e.turns.at(-1)}function ze(e,t){z(e);let n=Re(e,N(t.turnId));if(!n)return;let r=F(t.ts);n.completed={stopReason:N(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...r===void 0?{}:{ts:r}}}var G=new Set([`message`,`reasoning`,`tool`,`hook`]),Be=e=>G.has(e.kind);function Ve(e){if(!(!M(e)||!G.has(e.kind)))return typeof e.id==`string`&&e.id!==``?e:void 0}function K(e,t){let n=Ve(t.item);if(!n)return;let r=B(t,n.id);Ce(e,e.itemsById.get(r)?.turn??L(e),n,r,t.type===`item.completed`?F(t.ts):void 0)}function He(e,t){let n=e.itemsById.get(B(t,N(t.itemId)??``)),r=N(t.delta)??``;if(!n||r===``||!Be(n.entry.entry))return;let i=n.entry.entry;t.field===`output`&&i.kind===`tool`?i.output=(i.output??``)+r:t.field!==`output`&&(i.kind===`message`||i.kind===`reasoning`)&&(i.text+=r)}function Ue(e,t){let n=L(e),r=N(t.text)??``;if(r===``)return;let i=F(t.ts);n.entries.push({origin:`v1`,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:r,...i===void 0?{}:{ts:i}}})}var We=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Ge(e){if(!M(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!M(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:We.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}var Ke=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]);function qe(e,t){let n=L(e),r=N(t.tool)??`Tool`;if(n.v2Items||Ke.has(r))return;let i=ve(r,t.input),a=i.toolKind===`plan`?Ge(t.input):void 0;a!==void 0&&(n.planEntries=a);let o={kind:`tool`,id:N(t.id)??`v1:${t.seq}`,name:r,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},s={origin:`v1`,entry:o};n.entries.push(s),e.itemsById.set(o.id,{turn:n,entry:s})}function Je(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}function Ye(e,t){let n=e.itemsById.get(N(t.toolCallId)??``);if(!n||n.turn.v2Items||n.entry.origin!==`v1`)return;let r=n.entry.entry;r.kind===`tool`&&(r.status=`completed`,r.output=Je(t.result))}function q(e,t,n,r){let i=N(t.message)??``;i!==``&&R(e,{kind:`note`,id:n,text:i,tone:r})}function J(e,t){q(e,t,`v1:${t.seq}`,t.tone===`danger`?`danger`:`dim`)}function Xe(e,t){q(e,t,`v1:${t.seq}`,`danger`)}function Ze(e,t){q(e,t,`v2:${t.seq}`,`danger`)}function Qe(e,t){if(t.status!==`failed`)return;let n=N(t.error)?` — ${N(t.error)}`:``;R(e,{kind:`note`,id:`v1:${t.seq}`,text:`step ${N(t.stepId)??`?`} failed${n}`,tone:`danger`})}function $e(e,t){let n=N(t.command)??`check`,r=typeof t.exitCode==`number`?t.exitCode:-1;R(e,{kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${n}`,status:r===0?`completed`:`failed`,output:N(t.text)??``,exitCode:r})}function et(e,t){let n=xe(t.provider),r=N(t.authFailureId)??``;n===void 0||r.length<1||r.length>128||R(e,{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:n,authFailureId:r})}function tt(e,t){let n=N(t.url);if(n===void 0)return;let r={kind:`image`,id:`v1:${t.seq}`,url:n},i=N(t.name);i!==void 0&&(r.name=i),R(e,r)}function nt(e,t){Array.isArray(t.entries)&&(L(e).planEntries=t.entries)}function rt(e,t){z(e);let n=N(t.message);e.sessionEnded={reason:N(t.reason)??`end_turn`,...n===void 0?{}:{message:n}}}var it=new Set([`allow_once`,`allow_always`,`reject_once`,`reject_always`]);function at(e){return M(e)&&typeof e.id==`string`&&e.id!==``&&typeof e.label==`string`&&e.label!==``&&it.has(e.kind)}function ot(e){if(!(!Array.isArray(e)||e.length===0||!e.every(at)))return new Set(e.map(e=>e.id)).size===e.length?e:void 0}function st(e,t){let n=N(t.requestId),r=N(t.title),i=ot(t.options);if(!n||!r||e.permissions.has(n)||!i)return;let a=N(t.itemId),o=N(t.details),s={kind:`permission`,id:`permission:${n}`,requestId:n,title:r,options:i.map(e=>({...e})),status:`pending`,...a===void 0?{}:{itemId:a},...o===void 0?{}:{details:o}};e.permissions.set(n,s),R(e,s)}function ct(e,t){let n=e.permissions.get(N(t.requestId)??``);if(!n||n.status!==`pending`)return;let r=N(t.optionId);r!==void 0&&n.options.some(e=>e.id===r)?(n.status=`resolved`,n.optionId=r):n.status=`expired`;let i=N(t.reason);i!==void 0&&(n.reason=i)}function lt(e,t){let n=D(t),r=n&&A(n);if(!r)return;let i={kind:`ask`,...r,questions:r.questions,resolved:!1};R(e,i),e.pendingAsk=i}function Y(e,t){let n=e.pendingAsk;return n&&!n.resolved&&n.askSeq===t.askSeq?n:void 0}function ut(e,t){let n=Y(e,t);if(!n)return;n.routedToParent=!0;let r=N(t.parentRunId);r!==void 0&&(n.parentRunId=r)}function dt(e,t){let n=Y(e,t);n&&(n.routedToParent=!1)}function ft(e,t){let n=Y(e,t);n&&X(e,n,`undeliverable`)}var pt=new Set([`finish`,`superseded`,`parent-stopped`,`worker-stopped`,`undeliverable`]);function mt(e,t){let n=Y(e,t);n&&pt.has(t.reason)&&X(e,n,t.reason)}function X(e,t,n){t.resolved=!0,t.closed=n,e.pendingAsk=void 0}function Z(e,t){let n=Y(e,t);if(n){if(t.source===`cezar`){X(e,n,`undeliverable`);return}t.source===`parent`&&(n.resolved=!0,n.answeredBy=`parent`,e.pendingAsk=void 0)}}var Q=()=>{},ht=new Map([[`handoff`,De],[`webhook.failed`,Oe],[`webhook.dry-run`,Ae],[`webhook.report`,ke],[`preview.server-registered`,je],[`preview.server-state`,Me],[`conversation-message`,Ne],[`request-outcome`,Pe],[`agent-input`,Fe],[`user-message`,Ie],[`turn.started`,Le],[`turn.completed`,ze],[`item.started`,K],[`item.updated`,K],[`item.completed`,K],[`item.delta`,He],[`text`,Ue],[`tool-call`,qe],[`tool-result`,Ye],[`note`,J],[`lifecycle`,J],[`error`,Xe],[`session.error`,Ze],[`step-end`,Qe],[`check-output`,$e],[`provider-auth-required`,et],[`image`,tt],[`plan.updated`,nt],[`session.started`,e=>z(e)],[`session.ended`,rt],[`permission.requested`,st],[`permission.resolved`,ct],[`ask.requested`,lt],[`worker-question-routed`,ut],[`worker-question-fallback`,dt],[`worker-question-undelivered`,ft],[`human-ask-closed`,mt],[`human-input-delivered`,Z],[`step-start`,Q],[`token-usage`,Q],[`cost`,Q],[`turn-end`,Q],[`done`,Q],[`session`,Q]]);function gt(e,t){ht.get(t.type)?.(e,t)}function _t(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function vt(e){let t=[];for(let n of e.turns)for(let e of n.items)if(e.kind===`tool`){for(let n of e.locations??[])t.push(n.path);for(let n of e.diffs??[])t.push(n.path)}let n=[];for(let e=t.length-1;e>=0;--e)n.includes(t[e])||n.push(t[e]);return n}function yt(e,t){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t?`Session failed — ${t}`:`Session failed`};case`review`:return{state:`closed`,tone:`dim`,label:`Session closed — waiting for your review`};case`done`:case`cancelled`:return{state:`closed`,tone:`dim`,label:`Session closed`};default:return null}}function $(e,t){let n=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``);if(t){let e=n.trimEnd(),t=e.lastIndexOf(`
2
2
  `)+1;/^CEZ:ASK[ \t]+.+$/.test(e.slice(t))&&(n=e.slice(0,t).trimEnd())}return n.includes(`CEZ:`)?n.split(`
3
3
  `).filter(e=>!/^CEZ:(?:PR=\d+|ISSUE=\d+|TITLE=.+)\s*$/.test(e)).join(`
4
4
  `):n}function bt(e){let t=e=>$(e,!0).replace(/\s+/g,``),n=new Set,r=[];for(let{origin:i,entry:a}of e.entries)if(i===`v2`&&a.kind===`message`){let e=t(a.text);n.add(e),r.push(e)}if(r.length===0)return;n.add(r.join(``));let i=[],a={entries:[],texts:[]},o=()=>{if(a.entries.length>=2&&n.has(t(a.texts.join(``)))){a={entries:[],texts:[]};return}i.push(...a.entries),a={entries:[],texts:[]}};for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`message`?(a.entries.push(t),a.texts.push(t.entry.text)):(o(),i.push(t));o(),e.entries=i}function xt(e){let t=new Set;for(let{origin:n,entry:r}of e.entries)n===`v2`&&r.kind===`message`&&t.add($(r.text,!0).trim());t.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&t.has($(e.entry.text,!0).trim()))),bt(e))}function St(e){for(let t of e.conversationEntries.values())t.messageKind!==`request`||t.outcome!==void 0||t.delivery!==`not-delivered`&&(t.state!==void 0&&t.state!==`accepted`||(t.outcome={status:`pending`}))}function Ct(e,t){let n=t||e.entries.some(({entry:e})=>e.kind===`ask`);return{id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...e.startedAt===void 0?{}:{startedAt:e.startedAt},...e.planEntries===void 0?{}:{planEntries:e.planEntries},...e.completed===void 0?{}:{completed:e.completed},items:e.entries.map(({entry:e})=>e.kind===`message`&&e.role===`assistant`?{...e,text:$(e.text,n)}:e)}}function wt(e,t={}){let n=j();for(let t of e)gt(n,t);for(let e of n.turns)e.v2Items&&xt(e);St(n);let r=n.turns.length-1;return{turns:n.turns.map((e,n)=>Ct(e,t.activeTurn===!0&&n===r)),...n.sessionEnded===void 0?{}:{sessionEnded:n.sessionEnded}}}export{k as a,m as c,yt as i,wt as n,ce as o,vt as r,h as s,_t as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,s as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Ln as o,Mn as s,Vn as c,nr as l}from"./project-scope-context-BwaC58sQ.js";import{M as u}from"./live-protocol-aMLJJ0MQ.js";import"./queries-jqgF_s0L.js";import{t as d}from"./createLucideIcon-BHp8sXmF.js";import{a as f,d as p,h as m,i as ee,l as te,m as ne,n as re,o as ie,p as h,r as ae,t as oe,u as g}from"./es2015-DTn4s5Lh.js";import{_,b as se,v as ce,x as le,y as ue}from"./dropdown-menu-DPrTX-zi.js";import"./attention-C_kiJ1bk.js";function de(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}var fe=d(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),v=e(i(),1),y=a(),b=`Popover`,[pe,me]=ne(b,[le]),x=le(),[he,S]=pe(b),C=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=x(t),c=v.useRef(null),[l,u]=v.useState(!1),[d,f]=p({prop:r,defaultProp:i??!1,onChange:a,caller:b});return(0,y.jsx)(se,{...s,children:(0,y.jsx)(he,{scope:t,contentId:te(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:v.useCallback(()=>u(!0),[]),onCustomAnchorRemove:v.useCallback(()=>u(!1),[]),modal:o,children:n})})};C.displayName=b;var w=`PopoverAnchor`,T=v.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=S(w,n),a=x(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return v.useEffect(()=>(o(),()=>s()),[o,s]),(0,y.jsx)(_,{...a,...r,ref:t})});T.displayName=w;var ge=`PopoverTrigger`,_e=v.forwardRef((e,t)=>{let{__scopePopover:r,...i}=e,a=S(ge,r),o=x(r),s=n(t,a.triggerRef),c=(0,y.jsx)(m.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":A(a.open),...i,ref:s,onClick:h(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?c:(0,y.jsx)(_,{asChild:!0,...o,children:c})});_e.displayName=ge;var E=`PopoverPortal`,[ve,ye]=pe(E,{forceMount:void 0}),be=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=S(E,t);return(0,y.jsx)(ve,{scope:t,forceMount:n,children:(0,y.jsx)(g,{present:n||a.open,children:(0,y.jsx)(ee,{asChild:!0,container:i,children:r})})})};be.displayName=E;var D=`PopoverContent`,xe=v.forwardRef((e,t)=>{let n=ye(D,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=S(D,e.__scopePopover);return(0,y.jsx)(g,{present:r||a.open,children:a.modal?(0,y.jsx)(Ce,{...i,ref:t}):(0,y.jsx)(we,{...i,ref:t})})});xe.displayName=D;var Se=t(`PopoverContent.RemoveScroll`),Ce=v.forwardRef((e,t)=>{let r=S(D,e.__scopePopover),i=v.useRef(null),a=n(t,i),o=v.useRef(!1);return v.useEffect(()=>{let e=i.current;if(e)return oe(e)},[]),(0,y.jsx)(re,{as:Se,allowPinchZoom:!0,children:(0,y.jsx)(O,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:h(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||r.triggerRef.current?.focus()}),onPointerDownOutside:h(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;o.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:h(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),we=v.forwardRef((e,t)=>{let n=S(D,e.__scopePopover),r=v.useRef(!1),i=v.useRef(!1);return(0,y.jsx)(O,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),O=v.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,p=S(D,n),m=x(n);return ae(),(0,y.jsx)(f,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,y.jsx)(ie,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>p.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,y.jsx)(ue,{"data-state":A(p.open),role:`dialog`,id:p.contentId,...m,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),k=`PopoverClose`,Te=v.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=S(k,n);return(0,y.jsx)(m.button,{type:`button`,...r,ref:t,onClick:h(e.onClick,()=>i.onOpenChange(!1))})});Te.displayName=k;var Ee=`PopoverArrow`,De=v.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=x(n);return(0,y.jsx)(ce,{...i,...r,ref:t})});De.displayName=Ee;function A(e){return e?`open`:`closed`}var Oe=C,ke=T,Ae=_e,je=be,Me=xe,Ne=new Set([`queued`,`running`,`waiting`]);function Pe(e){return Ne.has(e)}function j(e){return l(e)?!1:e.status===`queued`||e.status===`running`||e.status===`waiting`}function Fe(e){return j(e)&&e.status!==`queued`}function M(e,t,n){return e.archived||!(e.status===`done`||e.status===`failed`||e.status===`cancelled`)||e.delegation?.role===`worker`||n!==void 0&&c(e)!==n?!1:t===`unpinned`?!e.pinned:t!==`pinned`||e.pinned===!0}var Ie=[`done`,`failed`];function N(e){return e.archived||l(e)||!Ie.includes(e.status)?!1:e.finishedAt!==void 0}function Le(e){let t=e.finishedAt;return t===void 0||!N(e)?!1:e.seenAt===void 0||e.seenAt<t}var P=[`Needs you`,`Finished`,`Working`,`Archived`],Re={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},ze=3,F=e=>l(e)?ze:Re[e.status]??9;function Be(e){let t=e=>s[o(e).bucket];return[...e].sort((e,n)=>t(e)-t(n)||F(e)-F(n))[0]}function Ve(e,t){return t===`archived`?`Archived`:o(e).bucket===`waiting`?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function I(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function L(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function He(e,t){return t!==void 0&&L(e).ref===t}function R(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function Ue(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>{if(t!==`archived`){let t=Number(!!n.pinned)-Number(!!e.pinned);if(t!==0)return t}let r=F(e)-F(n);if(r!==0)return r;if(l(e)&&l(n)){let t=e.autoResumeAt.localeCompare(n.autoResumeAt);if(t!==0)return t}return e.status===`queued`&&n.status===`queued`?e.createdAt.localeCompare(n.createdAt):n.createdAt.localeCompare(e.createdAt)})}function z(e){return e.delegation?.role===`worker`}function We(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!z(n)?e:n.delegation?.parentRunId??e}function Ge(e,t,n=R(e)){let r=Ue(e,t).filter(e=>!z(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(Ve(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return P.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function Ke(e,t={}){let n=typeof t==`number`?{overall:t}:u(t),r={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},i=[],a=n.overall===void 0?10:n.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:n[r[t.label]]??1/0,o=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:a<=0||e<=0?!1:(--a,--e,!0)});o.length&&i.push({label:t.label,rows:o})}return i}function qe(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function Je(e){let t=0,n=0,r=0;for(let i of e)if(!z(i)){if(i.archived){n+=1;continue}t+=1,o(i).bucket===`waiting`&&(r+=1)}return{active:t,archived:n,waiting:r}}function Ye(e,t){let n=t===`automations`;return e.filter(e=>!e.archived&&c(e)===n)}var B={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},V=Object.keys(B),H=`section`;function Xe(e,t){return`/?origin=${t===`automations`?`automations`:`direct`}&${H}=${B[e]}`}function Ze(e){return V.find(t=>B[t]===e)??null}function Qe(e){let t={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let n of e){if(z(n)||n.archived)continue;let e=+(o(n).bucket===`waiting`);c(n)?(t.automations+=1,t.automationsWaiting+=e):(t.active+=1,t.activeWaiting+=e)}return t}function U(e){let t=e.visualViewport;return t?Math.max(0,Math.round(e.innerHeight-t.height-t.offsetTop)):0}function $e(e,t,n,r=250){let i=e.visualViewport;if(!i)return t(0),()=>{};let a,o=()=>{let i=U(e);t(i),n&&(clearTimeout(a),a=setTimeout(()=>n(i),r))};return t(U(e)),i.addEventListener(`resize`,o),i.addEventListener(`scroll`,o),()=>{clearTimeout(a),i.removeEventListener(`resize`,o),i.removeEventListener(`scroll`,o),t(0)}}function et(e){let t=e.visualViewport;return t?{top:Math.max(0,Math.round(t.offsetTop)),bottom:U(e)}:{top:0,bottom:0}}function tt(e,t=0){let n=typeof t==`number`?{top:t,right:t,bottom:t,left:t}:t;return{top:(n.top??0)+e.top,right:n.right??0,bottom:(n.bottom??0)+e.bottom,left:n.left??0}}function nt(e,t){let n=e.visualViewport;if(!n)return t({top:0,bottom:0}),()=>{};let r=()=>t(et(e));return r(),n.addEventListener(`resize`,r),n.addEventListener(`scroll`,r),()=>{n.removeEventListener(`resize`,r),n.removeEventListener(`scroll`,r)}}function rt(){let[e,t]=(0,v.useState)({top:0,bottom:0});return(0,v.useEffect)(()=>nt(window,e=>t(t=>t.top===e.top&&t.bottom===e.bottom?t:e)),[]),e}function it(e){let t=(0,v.useRef)(e);t.current=e,(0,v.useEffect)(()=>{let e=document.documentElement;return $e(window,t=>e.style.setProperty(`--kb`,`${t}px`),e=>t.current?.(e))},[])}var at=new Set([``,`text`,`search`,`email`,`url`,`tel`,`password`,`number`]);function ot(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.tagName?.toUpperCase();return n===`TEXTAREA`?!0:n===`INPUT`?at.has((t.type??``).toLowerCase()):t.isContentEditable===!0}var W=new WeakMap;function st(e){let t=W.get(e),n=t&&t.width===e.innerWidth?Math.max(t.height,e.innerHeight):e.innerHeight;return W.set(e,{width:e.innerWidth,height:n}),n-e.innerHeight}function ct(e){let t=st(e),n=e.visualViewport?.scale??1;return Math.abs(n-1)<.05&&U(e)>80||t>80&&ot(e.document?.activeElement)}function lt(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=window,n=()=>t(ct(e));n();let r=e.visualViewport;return r?.addEventListener(`resize`,n),r?.addEventListener(`scroll`,n),window.addEventListener(`resize`,n),document.addEventListener(`focusin`,n),document.addEventListener(`focusout`,n),()=>{r?.removeEventListener(`resize`,n),r?.removeEventListener(`scroll`,n),window.removeEventListener(`resize`,n),document.removeEventListener(`focusin`,n),document.removeEventListener(`focusout`,n)}},[]),e}function ut(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function dt(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?ut(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var ft=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:dt},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function pt(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function mt(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function ht(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.extras:{automation:mt(e,t.automationNames)},i=[],a=[],o=[],s={text:i,identifier:a,link:o},c=[];for(let t of ft)if(t.scopes.includes(n)){if(t.kind===`reference`){c.push(()=>t.numbers(e,r));continue}for(let n of t.texts(e,r))typeof n==`string`&&s[t.kind].push(n.toLowerCase())}let l;return{prose:i,ids:a,links:o,references:()=>l??=new Set(c.flatMap(e=>e().map(String)))}}function G(e,t,n={}){let r=pt(t);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=ht(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var gt=new Set([`running`,`waiting`]);function K(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function _t(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function vt(e,t=new Date){if(!l(e))return;let n=new Date(e.autoResumeAt);if(!Number.isFinite(n.getTime()))return;let r=n.toDateString()===t.toDateString(),i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);return{label:r?i:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)} ${i}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n)}`}}function yt(e){return e.steps?de({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function bt(e,t,n=()=>``){let r=e.filter(e=>!z(e));return t.trim()?r.filter(e=>G(e,t,{scope:`shown`,extras:{displayTitle:I(e),automation:n(e),references:()=>q(e)}})):[...r]}function q(e){return Y(e).map(e=>e.number)}function J(e,t){return e.filter(e=>M(e,t)).length}function xt(e){return J(e)}function St(e){return Ct(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function Ct(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function wt(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function Tt(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}function Y(e,t,n=e.projectId){let r=Ct(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>Z(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:wt(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(Z(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??Et(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=Tt(a);o.has(c)||(o.add(c),s.push(a))}return s}function Et(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function Dt(e){return Y(e)[0]}function X(e,t){if(!e.url)return!0;if(!t)return!1;let n=Ot(t);return n!==void 0&&Ot(e.url)===n}function Ot(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function kt(e,t){let n=[];for(let r of Y(e,t)){if(!X(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function At(e,t,n,r){if(X(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function Z(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function jt(e,t){let n=gt.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:K(n.rssBytes),kind:`live`}};let r=K(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}var Q=v.createContext(null);function Mt({...e}){let t=v.useRef(!1);return(0,y.jsx)(Q,{value:t,children:(0,y.jsx)(Oe,{"data-slot":`popover`,...e})})}function Nt({onPointerDownCapture:e,onKeyDownCapture:t,...n}){let r=v.useContext(Q);return(0,y.jsx)(Ae,{"data-slot":`popover-trigger`,...n,onPointerDownCapture:t=>{r&&(r.current=t.pointerType===`touch`),e?.(t)},onKeyDownCapture:e=>{r&&(r.current=!1),t?.(e)}})}function Pt({className:e,align:t=`center`,sideOffset:n=4,collisionPadding:i,onOpenAutoFocus:a,...o}){let s=rt(),c=v.useContext(Q);return(0,y.jsx)(je,{children:(0,y.jsx)(Me,{"data-slot":`popover-content`,align:t,sideOffset:n,onOpenAutoFocus:e=>{let t=c?.current;if(c&&(c.current=!1),a?.(e),e.defaultPrevented||!t)return;let n=e.target;n instanceof HTMLElement&&n.querySelector(`[cmdk-input]`)&&(e.preventDefault(),n.focus({preventScroll:!0}))},collisionPadding:tt(s,i),className:r(`z-50 w-72 max-w-(--radix-popover-content-available-width) [overflow-wrap:anywhere] origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=left]:slide-in-from-right-2 motion-safe:data-[side=right]:slide-in-from-left-2 motion-safe:data-[side=top]:slide-in-from-bottom-2 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95`,e),...o})})}function Ft({...e}){return(0,y.jsx)(ke,{"data-slot":`popover-anchor`,...e})}var $=`(min-width: 48rem)`;function It(){let[e,t]=(0,v.useState)(()=>typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 48rem)`).matches);return(0,v.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia($),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}export{V as A,Xe as B,jt as C,lt as D,it as E,Be as F,qe as G,Qe as H,Ze as I,Pe as J,N as K,R as L,Ge as M,z as N,P as O,Je as P,fe as Q,He as R,Y as S,G as T,Ye as U,We as V,L as W,M as X,Fe as Y,Le as Z,wt as _,Pt as a,St as b,xt as c,X as d,Z as f,J as g,q as h,Ft as i,Ke as j,H as k,_t as l,vt as m,It as n,Nt as o,Tt as p,j as q,Mt as r,bt as s,$ as t,K as u,At as v,yt as w,Dt as x,kt as y,I as z};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,s as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{Ln as o,Mn as s,Vn as c,tr as l}from"./project-scope-context-CSPQyWoO.js";import{M as u}from"./live-protocol-aMLJJ0MQ.js";import"./queries-pj368bmB.js";import{t as d}from"./createLucideIcon-BHp8sXmF.js";import{a as f,d as p,h as m,i as ee,l as te,m as ne,n as re,o as ie,p as h,r as ae,t as oe,u as g}from"./es2015-DTn4s5Lh.js";import{_,b as se,v as ce,x as le,y as ue}from"./dropdown-menu-DPrTX-zi.js";import"./attention-BDa7opY9.js";function de(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}var fe=d(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),v=e(i(),1),y=a(),b=`Popover`,[pe,me]=ne(b,[le]),x=le(),[he,S]=pe(b),C=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=x(t),c=v.useRef(null),[l,u]=v.useState(!1),[d,f]=p({prop:r,defaultProp:i??!1,onChange:a,caller:b});return(0,y.jsx)(se,{...s,children:(0,y.jsx)(he,{scope:t,contentId:te(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:v.useCallback(()=>u(!0),[]),onCustomAnchorRemove:v.useCallback(()=>u(!1),[]),modal:o,children:n})})};C.displayName=b;var w=`PopoverAnchor`,T=v.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=S(w,n),a=x(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return v.useEffect(()=>(o(),()=>s()),[o,s]),(0,y.jsx)(_,{...a,...r,ref:t})});T.displayName=w;var ge=`PopoverTrigger`,_e=v.forwardRef((e,t)=>{let{__scopePopover:r,...i}=e,a=S(ge,r),o=x(r),s=n(t,a.triggerRef),c=(0,y.jsx)(m.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":A(a.open),...i,ref:s,onClick:h(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?c:(0,y.jsx)(_,{asChild:!0,...o,children:c})});_e.displayName=ge;var E=`PopoverPortal`,[ve,ye]=pe(E,{forceMount:void 0}),be=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=S(E,t);return(0,y.jsx)(ve,{scope:t,forceMount:n,children:(0,y.jsx)(g,{present:n||a.open,children:(0,y.jsx)(ee,{asChild:!0,container:i,children:r})})})};be.displayName=E;var D=`PopoverContent`,xe=v.forwardRef((e,t)=>{let n=ye(D,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=S(D,e.__scopePopover);return(0,y.jsx)(g,{present:r||a.open,children:a.modal?(0,y.jsx)(Ce,{...i,ref:t}):(0,y.jsx)(we,{...i,ref:t})})});xe.displayName=D;var Se=t(`PopoverContent.RemoveScroll`),Ce=v.forwardRef((e,t)=>{let r=S(D,e.__scopePopover),i=v.useRef(null),a=n(t,i),o=v.useRef(!1);return v.useEffect(()=>{let e=i.current;if(e)return oe(e)},[]),(0,y.jsx)(re,{as:Se,allowPinchZoom:!0,children:(0,y.jsx)(O,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:h(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||r.triggerRef.current?.focus()}),onPointerDownOutside:h(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;o.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:h(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),we=v.forwardRef((e,t)=>{let n=S(D,e.__scopePopover),r=v.useRef(!1),i=v.useRef(!1);return(0,y.jsx)(O,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),O=v.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,p=S(D,n),m=x(n);return ae(),(0,y.jsx)(f,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,y.jsx)(ie,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>p.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,y.jsx)(ue,{"data-state":A(p.open),role:`dialog`,id:p.contentId,...m,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),k=`PopoverClose`,Te=v.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=S(k,n);return(0,y.jsx)(m.button,{type:`button`,...r,ref:t,onClick:h(e.onClick,()=>i.onOpenChange(!1))})});Te.displayName=k;var Ee=`PopoverArrow`,De=v.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=x(n);return(0,y.jsx)(ce,{...i,...r,ref:t})});De.displayName=Ee;function A(e){return e?`open`:`closed`}var Oe=C,ke=T,Ae=_e,je=be,Me=xe,Ne=new Set([`queued`,`running`,`waiting`]);function Pe(e){return Ne.has(e)}function j(e){return l(e)?!1:e.status===`queued`||e.status===`running`||e.status===`waiting`}function Fe(e){return j(e)&&e.status!==`queued`}function M(e,t,n){return e.archived||!(e.status===`done`||e.status===`failed`||e.status===`cancelled`)||e.delegation?.role===`worker`||n!==void 0&&c(e)!==n?!1:t===`unpinned`?!e.pinned:t!==`pinned`||e.pinned===!0}var Ie=[`done`,`failed`];function N(e){return e.archived||l(e)||!Ie.includes(e.status)?!1:e.finishedAt!==void 0}function Le(e){let t=e.finishedAt;return t===void 0||!N(e)?!1:e.seenAt===void 0||e.seenAt<t}var P=[`Needs you`,`Finished`,`Working`,`Archived`],Re={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},ze=3,F=e=>l(e)?ze:Re[e.status]??9;function Be(e){let t=e=>s[o(e).bucket];return[...e].sort((e,n)=>t(e)-t(n)||F(e)-F(n))[0]}function Ve(e,t){return t===`archived`?`Archived`:o(e).bucket===`waiting`?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function I(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function L(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function He(e,t){return t!==void 0&&L(e).ref===t}function R(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function Ue(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>{if(t!==`archived`){let t=Number(!!n.pinned)-Number(!!e.pinned);if(t!==0)return t}let r=F(e)-F(n);if(r!==0)return r;if(l(e)&&l(n)){let t=e.autoResumeAt.localeCompare(n.autoResumeAt);if(t!==0)return t}return e.status===`queued`&&n.status===`queued`?e.createdAt.localeCompare(n.createdAt):n.createdAt.localeCompare(e.createdAt)})}function z(e){return e.delegation?.role===`worker`}function We(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!z(n)?e:n.delegation?.parentRunId??e}function Ge(e,t,n=R(e)){let r=Ue(e,t).filter(e=>!z(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(Ve(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return P.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function Ke(e,t={}){let n=typeof t==`number`?{overall:t}:u(t),r={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},i=[],a=n.overall===void 0?10:n.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:n[r[t.label]]??1/0,o=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:a<=0||e<=0?!1:(--a,--e,!0)});o.length&&i.push({label:t.label,rows:o})}return i}function qe(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function Je(e){let t=0,n=0,r=0;for(let i of e)if(!z(i)){if(i.archived){n+=1;continue}t+=1,o(i).bucket===`waiting`&&(r+=1)}return{active:t,archived:n,waiting:r}}function Ye(e,t){let n=t===`automations`;return e.filter(e=>!e.archived&&c(e)===n)}var B={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},V=Object.keys(B),H=`section`;function Xe(e,t){return`/?origin=${t===`automations`?`automations`:`direct`}&${H}=${B[e]}`}function Ze(e){return V.find(t=>B[t]===e)??null}function Qe(e){let t={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let n of e){if(z(n)||n.archived)continue;let e=+(o(n).bucket===`waiting`);c(n)?(t.automations+=1,t.automationsWaiting+=e):(t.active+=1,t.activeWaiting+=e)}return t}function U(e){let t=e.visualViewport;return t?Math.max(0,Math.round(e.innerHeight-t.height-t.offsetTop)):0}function $e(e,t,n,r=250){let i=e.visualViewport;if(!i)return t(0),()=>{};let a,o=()=>{let i=U(e);t(i),n&&(clearTimeout(a),a=setTimeout(()=>n(i),r))};return t(U(e)),i.addEventListener(`resize`,o),i.addEventListener(`scroll`,o),()=>{clearTimeout(a),i.removeEventListener(`resize`,o),i.removeEventListener(`scroll`,o),t(0)}}function et(e){let t=e.visualViewport;return t?{top:Math.max(0,Math.round(t.offsetTop)),bottom:U(e)}:{top:0,bottom:0}}function tt(e,t=0){let n=typeof t==`number`?{top:t,right:t,bottom:t,left:t}:t;return{top:(n.top??0)+e.top,right:n.right??0,bottom:(n.bottom??0)+e.bottom,left:n.left??0}}function nt(e,t){let n=e.visualViewport;if(!n)return t({top:0,bottom:0}),()=>{};let r=()=>t(et(e));return r(),n.addEventListener(`resize`,r),n.addEventListener(`scroll`,r),()=>{n.removeEventListener(`resize`,r),n.removeEventListener(`scroll`,r)}}function rt(){let[e,t]=(0,v.useState)({top:0,bottom:0});return(0,v.useEffect)(()=>nt(window,e=>t(t=>t.top===e.top&&t.bottom===e.bottom?t:e)),[]),e}function it(e){let t=(0,v.useRef)(e);t.current=e,(0,v.useEffect)(()=>{let e=document.documentElement;return $e(window,t=>e.style.setProperty(`--kb`,`${t}px`),e=>t.current?.(e))},[])}var at=new Set([``,`text`,`search`,`email`,`url`,`tel`,`password`,`number`]);function ot(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.tagName?.toUpperCase();return n===`TEXTAREA`?!0:n===`INPUT`?at.has((t.type??``).toLowerCase()):t.isContentEditable===!0}var W=new WeakMap;function st(e){let t=W.get(e),n=t&&t.width===e.innerWidth?Math.max(t.height,e.innerHeight):e.innerHeight;return W.set(e,{width:e.innerWidth,height:n}),n-e.innerHeight}function ct(e){let t=st(e),n=e.visualViewport?.scale??1;return Math.abs(n-1)<.05&&U(e)>80||t>80&&ot(e.document?.activeElement)}function lt(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=window,n=()=>t(ct(e));n();let r=e.visualViewport;return r?.addEventListener(`resize`,n),r?.addEventListener(`scroll`,n),window.addEventListener(`resize`,n),document.addEventListener(`focusin`,n),document.addEventListener(`focusout`,n),()=>{r?.removeEventListener(`resize`,n),r?.removeEventListener(`scroll`,n),window.removeEventListener(`resize`,n),document.removeEventListener(`focusin`,n),document.removeEventListener(`focusout`,n)}},[]),e}function ut(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function dt(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?ut(n):null;e!==null&&t.add(e)}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var ft=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:dt},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function pt(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function mt(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function ht(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.extras:{automation:mt(e,t.automationNames)},i=[],a=[],o=[],s={text:i,identifier:a,link:o},c=[];for(let t of ft)if(t.scopes.includes(n)){if(t.kind===`reference`){c.push(()=>t.numbers(e,r));continue}for(let n of t.texts(e,r))typeof n==`string`&&s[t.kind].push(n.toLowerCase())}let l;return{prose:i,ids:a,links:o,references:()=>l??=new Set(c.flatMap(e=>e().map(String)))}}function G(e,t,n={}){let r=pt(t);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=ht(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var gt=new Set([`running`,`waiting`]);function K(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function _t(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function vt(e,t=new Date){if(!l(e))return;let n=new Date(e.autoResumeAt);if(!Number.isFinite(n.getTime()))return;let r=n.toDateString()===t.toDateString(),i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);return{label:r?i:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)} ${i}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n)}`}}function yt(e){return e.steps?de({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function bt(e,t,n=()=>``){let r=e.filter(e=>!z(e));return t.trim()?r.filter(e=>G(e,t,{scope:`shown`,extras:{displayTitle:I(e),automation:n(e),references:()=>q(e)}})):[...r]}function q(e){return Y(e).map(e=>e.number)}function J(e,t){return e.filter(e=>M(e,t)).length}function xt(e){return J(e)}function St(e){return Ct(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function Ct(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function wt(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function Tt(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}function Y(e,t,n=e.projectId){let r=Ct(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>Z(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:wt(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(Z(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??Et(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=Tt(a);o.has(c)||(o.add(c),s.push(a))}return s}function Et(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function Dt(e){return Y(e)[0]}function X(e,t){if(!e.url)return!0;if(!t)return!1;let n=Ot(t);return n!==void 0&&Ot(e.url)===n}function Ot(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function kt(e,t){let n=[];for(let r of Y(e,t)){if(!X(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function At(e,t,n,r){if(X(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function Z(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function jt(e,t){let n=gt.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:K(n.rssBytes),kind:`live`}};let r=K(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}var Q=v.createContext(null);function Mt({...e}){let t=v.useRef(!1);return(0,y.jsx)(Q,{value:t,children:(0,y.jsx)(Oe,{"data-slot":`popover`,...e})})}function Nt({onPointerDownCapture:e,onKeyDownCapture:t,...n}){let r=v.useContext(Q);return(0,y.jsx)(Ae,{"data-slot":`popover-trigger`,...n,onPointerDownCapture:t=>{r&&(r.current=t.pointerType===`touch`),e?.(t)},onKeyDownCapture:e=>{r&&(r.current=!1),t?.(e)}})}function Pt({className:e,align:t=`center`,sideOffset:n=4,collisionPadding:i,onOpenAutoFocus:a,...o}){let s=rt(),c=v.useContext(Q);return(0,y.jsx)(je,{children:(0,y.jsx)(Me,{"data-slot":`popover-content`,align:t,sideOffset:n,onOpenAutoFocus:e=>{let t=c?.current;if(c&&(c.current=!1),a?.(e),e.defaultPrevented||!t)return;let n=e.target;n instanceof HTMLElement&&n.querySelector(`[cmdk-input]`)&&(e.preventDefault(),n.focus({preventScroll:!0}))},collisionPadding:tt(s,i),className:r(`z-50 w-72 max-w-(--radix-popover-content-available-width) [overflow-wrap:anywhere] origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=left]:slide-in-from-right-2 motion-safe:data-[side=right]:slide-in-from-left-2 motion-safe:data-[side=top]:slide-in-from-bottom-2 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95`,e),...o})})}function Ft({...e}){return(0,y.jsx)(ke,{"data-slot":`popover-anchor`,...e})}var $=`(min-width: 48rem)`;function It(){let[e,t]=(0,v.useState)(()=>typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 48rem)`).matches);return(0,v.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia($),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}export{V as A,Xe as B,jt as C,lt as D,it as E,Be as F,qe as G,Qe as H,Ze as I,Pe as J,N as K,R as L,Ge as M,z as N,P as O,Je as P,fe as Q,He as R,Y as S,G as T,Ye as U,We as V,L as W,M as X,Fe as Y,Le as Z,wt as _,Pt as a,St as b,xt as c,X as d,Z as f,J as g,q as h,Ft as i,Ke as j,H as k,_t as l,vt as m,It as n,Nt as o,Tt as p,j as q,Mt as r,bt as s,$ as t,K as u,At as v,yt as w,Dt as x,kt as y,I as z};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,t as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{C as o,Hr as s,en as c,nt as l,r as u,rt as d,vr as f,zt as p}from"./project-scope-context-BwaC58sQ.js";import{$ as m,At as h,Lt as g,M as _,Nt as v,O as y,P as b,Qt as x,h as S,n as C,nt as w,wt as T}from"./queries-jqgF_s0L.js";import{t as E}from"./useQuery-Qq5WoH8B.js";import{Q as D,a as O,o as k,r as A}from"./use-desktop-DpH_9i2n.js";import{n as j}from"./toaster-CoMJoQvk.js";import{A as M,Z as ee,_ as N,b as P,ct as F,d as I,ft as te,h as L,l as R,mt as ne,ot as re,r as ie,rt as ae,u as oe,ut as se}from"./design-icons-DmYTv2r1.js";import{t as ce}from"./eye-B8okNWXU.js";import{a as le,i as z}from"./format-BNCkW110.js";import{t as ue}from"./message-square-B-MD-8rD.js";import{t as de}from"./play-CmVAj_fu.js";import{a as fe,i as pe,o as me,r as he,s as ge,t as _e}from"./dialog-B7p5oc5r.js";import{d as B,t as ve,y as V}from"./prompt-template-menu-Q6yvBBX2.js";import{t as H}from"./project-router-_4jaKCY-.js";import{B as ye,E as be,I as xe,L as U,M as Se,O as Ce,P as we,R as Te,S as Ee,T as De,a as Oe,b as ke,f as Ae,h as je,i as Me,l as Ne,m as Pe,n as Fe,p as Ie,r as W,s as Le,t as Re,u as ze,w as Be,x as Ve,z as He}from"./agent-accounts-WZgtbThS.js";import{d as Ue,f as We,i as Ge,s as Ke,t as qe,u as Je}from"./skills-DFBiAuJG.js";import{$ as Ye,F as Xe,L as Ze,X as Qe,Y as $e,pn as et}from"./index-BXr2mRSZ.js";import{t as tt}from"./diff-BB8od2CB.js";import{t as nt}from"./tab-link-BmBr8sDS.js";var G=e(i(),1),K=a(),rt={squash:`Squash and merge`,merge:`Create a merge commit`,rebase:`Rebase and merge`};function q({state:e}){let t=`size-4 shrink-0`;return e===`passing`?(0,K.jsx)(R,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-passing`,className:r(t,`text-success`)}):e===`failing`?(0,K.jsx)(N,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-failing`,className:r(t,`text-danger`)}):e===`pending`?(0,K.jsx)(le,{"aria-hidden":`true`,"data-slot":`gh-merge-status-pending`,className:r(t,`animate-spin text-warning`)}):(0,K.jsx)(L,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-unknown`,className:r(t,`text-soft-foreground`)})}function it(e){return e?.available?e.mergeState:null}function at(e,t){return e&&t?.methods.includes(e)?e:t?.defaultMethod??t?.methods[0]??null}function ot(e){return e.state===`merged`?`Merged`:e.state===`closed`?`Closed`:e.isDraft?`Draft`:e.mergeable===`conflicting`?`Conflicts must be resolved`:e.canMerge?`Ready to merge`:e.eligibility===`unknown`?`Merge blocked · Requirements unknown`:`Merge blocked`}function st(e){return e===`approved`||e===`not-required`?`passing`:e===`unknown`?`unknown`:`failing`}function ct(e){return e===`mergeable`?`passing`:e===`conflicting`?`failing`:`unknown`}function lt(e){return e===`conflicting`?`present`:e===`mergeable`?`none`:`unknown`}function ut(e){return e===!0?` · required`:e===null?` · requiredness unknown`:``}function dt(e){return e?.available===!1?e.reason:`GitHub could not load merge requirements.`}function ft(e,t,n){return!!(e&&(t.canMerge||t.canOverride&&n))}function J(e){return e?rt[e]:`Merge`}function pt(e){return e===`conflicting`?`true`:void 0}function mt({check:e}){return(0,K.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(q,{state:e.state}),(0,K.jsxs)(`span`,{children:[e.name,` · `,e.state,ut(e.required)]})]}),e.url&&t(e.url)?(0,K.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground underline`,children:`details`}):null]})}function ht({reason:e}){return(0,K.jsxs)(`section`,{"data-slot":`gh-merge-unavailable`,className:`mt-6 rounded-lg border border-border bg-card p-4 text-sm`,children:[(0,K.jsx)(`p`,{className:`font-medium`,children:`Merge status unavailable`}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:e})]})}function gt({state:e,selectedMethod:t,overrideRules:i,mergeEnabled:a,refreshPending:o,onRefresh:s,onRunAgent:c,onConfirm:l,onMethodChange:u,onOverrideChange:d}){let f=ot(e),p=st(e.reviewDecision),m=ct(e.mergeable);return(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[e.canMerge?(0,K.jsx)(R,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-success`}):(0,K.jsx)(F,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-warning`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(`h3`,{className:`font-semibold`,children:f}),(0,K.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,disabled:o,onClick:s,children:[(0,K.jsx)(ee,{size:16,"aria-hidden":`true`,className:r(`size-3.5`,o&&`animate-spin`)}),`Refresh`]})]}),(0,K.jsxs)(`p`,{className:`mt-1 font-mono text-[11px] text-soft-foreground`,children:[e.headRef,` (`,e.headSha.slice(0,7),`) → `,e.baseRef]}),(0,K.jsxs)(`ul`,{className:`mt-3 space-y-2 text-xs`,children:[(0,K.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(q,{state:p}),(0,K.jsxs)(`span`,{children:[`Reviews: `,e.reviewDecision.replaceAll(`-`,` `)]})]}),(0,K.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(q,{state:m}),(0,K.jsxs)(`span`,{children:[`Conflicts: `,lt(e.mergeable)]})]}),e.checks.length===0?(0,K.jsx)(`li`,{children:`No checks configured`}):e.checks.map(e=>(0,K.jsx)(mt,{check:e},e.name)),e.blockers.map(e=>(0,K.jsx)(`li`,{className:`text-soft-foreground`,children:e.message},e.code))]}),e.mergeable===`conflicting`&&c?(0,K.jsx)(n,{className:`mt-4`,onClick:c,children:`Run agent on this PR`}):null,e.canOverride?(0,K.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 rounded-md border border-warning/40 bg-warning/5 p-3 text-xs`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>d(e.target.checked),className:`mt-0.5 size-4 accent-accent-strong`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`block font-medium`,children:`Merge without waiting for requirements`}),(0,K.jsx)(`span`,{className:`mt-0.5 block text-soft-foreground`,children:`GitHub will allow this only if your permissions can bypass the repository rules.`})]})]}):null,e.eligibility===`unknown`?(0,K.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`GitHub could not confirm review and branch-protection requirements. Passing checks do not establish merge readiness.`}):null,e.state===`open`&&e.methods.length>0?(0,K.jsxs)(`div`,{className:`mt-4 flex flex-col flex-wrap gap-2 sm:flex-row`,children:[(0,K.jsx)(`select`,{"aria-label":`Merge method`,value:t??``,onChange:e=>u(e.target.value),className:`h-9 min-w-0 flex-1 rounded-md border border-input bg-background px-3 text-sm`,children:e.methods.map(e=>(0,K.jsx)(`option`,{value:e,children:rt[e]},e))}),(0,K.jsx)(n,{disabled:!a,onClick:l,children:J(t)})]}):null]})]})}function _t({number:e,state:t,selectedMethod:r,confirming:i,overrideRules:a,mergePending:o,mergeError:s,onOpenChange:c,onMerge:l}){return(0,K.jsx)(_e,{open:i,onOpenChange:c,children:(0,K.jsxs)(he,{"data-slot":`gh-merge-confirm`,showCloseButton:!1,children:[(0,K.jsxs)(me,{children:[(0,K.jsxs)(ge,{children:[J(r),` pull request #`,e,`?`]}),(0,K.jsx)(pe,{asChild:!0,children:(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{children:[`This will merge “`,t.title,`” into `,t.baseRef,`. GitHub will re-check the exact reviewed head before changing the repository.`]}),a&&t.canOverride?(0,K.jsx)(`p`,{"data-slot":`gh-bypass-warning`,className:`mt-4 text-sm text-warning`,children:`You are asking GitHub to bypass unmet repository requirements; GitHub may refuse if your permissions do not allow it.`}):null]})})]}),s?(0,K.jsx)(`p`,{className:`text-sm text-danger`,children:s.message}):null,(0,K.jsxs)(fe,{children:[(0,K.jsx)(n,{variant:`outline`,disabled:o,onClick:()=>c(!1),children:`Cancel`}),(0,K.jsx)(n,{disabled:o,onClick:l,children:o?`Merging…`:J(r)})]})]})})}function vt({number:e,onRunAgent:t}){let n=s(),r=w(),i=E({queryKey:C.githubMergeState(e),queryFn:({signal:t})=>d(e,{},{signal:t}),retry:!1}),a=it(i.data),[o,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(!1),[f,m]=(0,G.useState)(!1),h=x({mutationFn:t=>d(e,{refresh:!0}),onSuccess:(e,t)=>n.setQueryData(t,e),onError:e=>j(e instanceof Error?e.message:String(e),{tone:`danger`})}),g=at(o,a),_=()=>({mergeState:C.githubMergeState(e),list:C.githubPages(50),comments:C.githubComments(`pr`,e),item:C.githubItem(`pr`,e),refStatus:r===void 0?void 0:C.githubRefStatusOf(r)}),v=x({mutationFn:t=>{if(!a||!g)throw Error(`No merge method is available.`);return p(e,{method:g,expectedHeadSha:a.headSha,...f&&a.canOverride?{overrideRules:!0}:{}})},onSuccess:(t,r)=>{u(!1),j(`Pull request #${e} merged`),n.invalidateQueries({queryKey:r.mergeState}),n.invalidateQueries({queryKey:r.list}),n.invalidateQueries({queryKey:r.comments}),n.invalidateQueries({queryKey:r.item}),r.refStatus&&n.invalidateQueries({queryKey:r.refStatus})},onError:(e,t)=>{j(e instanceof Error?e.message:String(e),{tone:`danger`}),n.invalidateQueries({queryKey:t.mergeState})}});return i.isPending?(0,K.jsx)(V,{"data-slot":`gh-merge-loading`,className:`mt-6 h-32 w-full`}):a?(0,K.jsxs)(`section`,{"data-slot":`gh-merge-box`,"data-eligibility":a.eligibility,"data-conflicting":pt(a.mergeable),"aria-live":`polite`,className:`mt-6 rounded-lg border border-border bg-card p-4`,children:[(0,K.jsx)(gt,{state:a,selectedMethod:g,overrideRules:f,mergeEnabled:ft(g,a,f),refreshPending:h.isPending,onRefresh:()=>h.mutate(C.githubMergeState(e)),onRunAgent:t,onConfirm:()=>u(!0),onMethodChange:c,onOverrideChange:m}),(0,K.jsx)(_t,{number:e,state:a,selectedMethod:g,confirming:l,overrideRules:f,mergePending:v.isPending,mergeError:v.error,onOpenChange:u,onMerge:()=>v.mutate(_())})]}):(0,K.jsx)(ht,{reason:dt(i.data)})}function yt(e){let t=new Set;for(let n of e)for(let e of n.labels)t.add(e);return[...t].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))}function bt(e,t={}){let n=(t.query??``).trim().toLowerCase(),r=t.labels??[],i=n.replace(/^#/,``),a=i!==``&&/^\d+$/.test(i);return e.filter(e=>r.length>0&&!r.every(t=>e.labels.includes(t))||t.assignees?.length&&!e.assignees?.some(e=>t.assignees.some(t=>t.toLowerCase()===e.toLowerCase()))||t.author!==void 0&&e.author.toLowerCase()!==t.author.toLowerCase()||t.includeNumbers&&!t.includeNumbers.has(e.number)||t.excludeNumbers?.has(e.number)||t.projectId&&e.projectIds!==void 0&&!e.projectIds.includes(t.projectId)?!1:n===``?!0:a?String(e.number).includes(i):`#${e.number} ${e.title} ${e.author} ${e.body??``}`.toLowerCase().includes(n))}function xt(e,t){let n=e.trim();if(n===``)return!1;let r=n.replace(/^#/,``);return/^\d+$/.test(r)?!t.some(e=>e.number===Number(r)):t.length===0}function Y(e){if(!e||!/^[0-9a-fA-F]{6}$/.test(e))return{borderColor:`var(--border)`,color:`var(--muted-foreground)`};let t=`#${e}`;return{backgroundColor:`${t}22`,borderColor:`${t}66`,color:`color-mix(in srgb, ${t} 50%, var(--foreground))`}}function St({label:e,color:t,plain:n=!1}){return(0,K.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,style:n?void 0:Y(t),className:n?`text-[11px] font-normal text-muted-foreground`:`rounded-full border px-1.5 py-px text-[12px] font-medium`,children:e})}function Ct(e){return e===`pr`?`pull request`:`issue`}function wt(e,t,n){return e===`pr`&&!!(t||n)}function Tt({backLink:e}){return e?(0,K.jsxs)(H,{to:e.to,"data-slot":`gh-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,K.jsx)(ie,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}):null}function Et({item:e,kindWord:n,commentCount:r,hasDiffStat:i,additions:a,deletions:o}){return(0,K.jsxs)(`p`,{"data-slot":`gh-meta`,className:`flex flex-wrap items-center gap-x-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,K.jsxs)(`span`,{children:[`#`,e.number]}),`·`,(0,K.jsx)(`span`,{children:n}),`·`,(0,K.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,K.jsxs)(`span`,{children:[z(e.createdAt),` ago`]}),r?(0,K.jsxs)(K.Fragment,{children:[`·`,(0,K.jsx)(qt,{count:r})]}):null,i?(0,K.jsxs)(K.Fragment,{children:[`·`,(0,K.jsxs)(`span`,{"data-slot":`gh-diffstat`,children:[(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,a??0]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,o??0]})]})]}):null,`·`,t(e.url)?(0,K.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-open-link`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,K.jsx)(D,{"aria-hidden":`true`,className:`size-2.5`})]}):(0,K.jsx)(`span`,{"data-slot":`gh-open-link`,className:`text-muted-foreground`,children:`open on GitHub`})]})}function Dt({item:e,subNav:t,changes:n}){return e.kind===`pr`?t?(0,K.jsxs)(`nav`,{"aria-label":`Pull request detail`,className:`mt-4 flex border-b border-border`,children:[(0,K.jsx)(nt,{to:B(`prs`,t.filter,e.number),active:!n,children:`Conversation`}),(0,K.jsx)(nt,{to:B(`prs`,t.filter,e.number,`/changes`),active:n,children:`Changes`})]}):(0,K.jsx)(H,{to:B(`prs`,null,e.number,`/changes`),"data-slot":`gh-files-changed`,className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:underline`,children:`Files changed`}):null}function Ot({item:e,colors:t,checks:n}){return e.labels.length>0||n?(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,K.jsx)(St,{label:e,color:t[e]},e)),n?(0,K.jsx)(Jt,{checks:n,url:e.url}):null]}):null}function kt({item:e,colors:t,body:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{"data-slot":`gh-body`,className:`mt-5 text-sm`,children:n?(0,K.jsx)(Ze,{children:n}):(0,K.jsx)(`p`,{className:`text-soft-foreground`,children:`(no description)`})}),(0,K.jsx)(Mt,{item:e,colors:t})]})}function At({item:e,colors:t,checks:n,comments:r,backLink:i,subNav:a,onRunAgent:o,afterHeading:s,children:c}){let l=a?.changes??!1,u=Ct(e.kind),d=y(e.kind,e.number,!l).data?.detail,f=d?.body??e.body,p=d?.additions??e.additions,m=d?.deletions??e.deletions,h=wt(e.kind,p,m),g=r??e.comments;return(0,K.jsxs)(`article`,{"data-slot":`gh-detail-inner`,className:`min-w-0 px-4 py-4 md:px-7 md:py-5`,children:[(0,K.jsx)(Tt,{backLink:i}),(0,K.jsxs)(`div`,{"data-slot":`gh-description-card`,className:e.kind===`pr`?`rounded-xl border border-border bg-card p-6`:void 0,children:[e.kind===`pr`?(0,K.jsxs)(`h2`,{className:`mb-4 text-[22px] leading-snug font-normal`,children:[`#`,e.number,` `,e.title]}):null,(0,K.jsx)(Et,{item:e,kindWord:u,commentCount:g,hasDiffStat:h,additions:p,deletions:m}),e.kind===`pr`?null:(0,K.jsx)(`h2`,{className:`mt-2 text-[22px] leading-snug font-normal`,children:e.title}),s,(0,K.jsx)(Dt,{item:e,subNav:a,changes:l}),(0,K.jsx)(Ot,{item:e,colors:t,checks:n}),l&&e.kind===`pr`?(0,K.jsx)(jt,{item:e}):(0,K.jsx)(kt,{item:e,colors:t,body:f})]}),e.kind===`pr`?(0,K.jsx)(vt,{number:e.number,onRunAgent:o}):null,c]})}function jt({item:e}){let i=s(),a=_(e.number),[o,c]=(0,G.useState)(``),[u,d]=(0,G.useState)(null),f=a.data,p=f?.available?f.files.filter(e=>e.path.toLowerCase().includes(o.toLowerCase())):[],m=p.findIndex(e=>e.path===u);(0,G.useEffect)(()=>{p.length>0&&!p.some(e=>e.path===u)&&d(p[0].path)},[f?.available?f.headSha:``,o]);let h=async()=>{let t=f?.available?f.headSha:null,n=C.githubPrChanges(e.number),r=await l(e.number,{refresh:!0});i.setQueryData(n,r),r.available&&t&&t!==r.headSha&&(d(r.files[0]?.path??null),j(`The reviewed revision changed.`))};if(a.isPending)return(0,K.jsx)(`p`,{"aria-live":`polite`,className:`mt-6 text-sm text-muted-foreground`,children:`Loading changed files…`});if(a.isError||!f)return(0,K.jsx)(`p`,{className:`mt-6 text-sm text-danger`,children:`Changed files could not be loaded.`});if(!f.available)return(0,K.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:f.reason});let g=p.map(e=>({path:e.path,...e.previousPath?{oldPath:e.previousPath}:{},status:e.status===`removed`?`deleted`:e.status===`changed`?`modified`:e.status,adds:e.additions,dels:e.deletions,binary:e.patchUnavailableReason===`binary`,patch:e.patch??``})),v=t(e.url)?`${e.url}/files`:null,y=p.find(e=>e.path===u);return(0,K.jsxs)(`section`,{"data-slot":`gh-pr-changes`,className:`mt-5 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,K.jsxs)(`strong`,{children:[f.files.length,` changed files`]}),(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,f.additions]}),(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,f.deletions]}),(0,K.jsxs)(`span`,{className:`font-mono text-muted-foreground`,title:f.headSha,children:[`head `,f.headSha.slice(0,8)]}),(0,K.jsx)(n,{type:`button`,variant:`outline`,size:`sm`,className:`ml-auto min-h-11`,onClick:()=>void h(),children:`Refresh`})]}),f.truncated?(0,K.jsxs)(`p`,{role:`status`,className:`mt-3 rounded-md border border-warning/40 bg-warning/10 p-3 text-xs`,children:[f.reason??`This response is incomplete.`,` `,v?(0,K.jsx)(`a`,{href:v,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`Open all files on GitHub`}):null]}):null,(0,K.jsxs)(`div`,{className:`mt-4 grid min-w-0 gap-4 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,K.jsxs)(`aside`,{className:`min-w-0`,children:[(0,K.jsx)(`input`,{"aria-label":`Filter changed files`,value:o,onChange:e=>c(e.target.value),placeholder:`Filter files…`,className:`min-h-11 w-full rounded-md border border-input bg-background px-3 text-sm`}),(0,K.jsx)(`select`,{"aria-label":`Select changed file`,value:u??``,onChange:e=>d(e.target.value),className:`mt-2 min-h-11 w-full rounded-md border border-input bg-background px-2 text-sm lg:hidden`,children:p.map(e=>(0,K.jsx)(`option`,{children:e.path},e.path))}),(0,K.jsx)(`ul`,{className:`mt-2 hidden max-h-[60vh] overflow-auto lg:block`,children:p.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>d(e.path),className:r(`min-h-11 w-full truncate rounded px-2 text-left text-xs`,u===e.path&&`bg-muted font-medium`),title:e.path,children:[e.status,` · `,e.path,` `,(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})},e.path))})]}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex justify-end gap-1`,children:[(0,K.jsx)(n,{"aria-label":`Previous file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:m<=0,onClick:()=>d(p[m-1]?.path??null),children:(0,K.jsx)(et,{})}),(0,K.jsx)(n,{"aria-label":`Next file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:m<0||m>=p.length-1,onClick:()=>d(p[m+1]?.path??null),children:(0,K.jsx)(I,{size:16})})]}),p.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No changed files match this filter.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(tt,{files:g.filter(e=>e.path===u),wrap:!0,className:`min-w-0`}),y&&!y.patch?(0,K.jsxs)(`p`,{className:`rounded-b border border-border p-3 text-xs text-muted-foreground`,children:[`Patch unavailable: `,y.patchUnavailableReason??`not-provided`,`.`]}):null]})]})]})]})}function Mt({item:e,colors:t}){let n=y(e.kind,e.number),r=n.data,i=(0,G.useMemo)(()=>{let e=[...(r?.comments??[]).map(e=>({row:`comment`,comment:e})),...(r?.events??[]).map(e=>({row:`event`,event:e}))],t=e=>{let t=Date.parse(Nt(e));return Number.isNaN(t)?-1/0:t};return e.sort((e,n)=>t(e)-t(n))},[r?.comments,r?.events]);return n.isPending?(0,K.jsxs)(`section`,{"data-slot":`gh-thread-loading`,className:`mt-6 border-t border-border pt-5`,children:[(0,K.jsx)(V,{className:`mb-3 h-3 w-24`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(V,{className:`h-14 w-full`}),(0,K.jsx)(V,{className:`h-14 w-full`})]})]}):!r||!r.available?(0,K.jsxs)(`section`,{"data-slot":`gh-thread-error`,className:`mt-6 border-t border-border pt-5 text-xs text-soft-foreground`,children:[(0,K.jsxs)(`span`,{children:[`Couldn’t load comments — `,r?.reason??(n.error instanceof Error?n.error.message:`could not load comments`),`. `]}),(0,K.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,K.jsx)(D,{"aria-hidden":`true`,className:`size-2.5`})]})]}):i.length===0?null:(0,K.jsxs)(`section`,{"data-slot":`gh-thread`,className:`mt-6 border-t border-border pt-5`,children:[(0,K.jsxs)(`h3`,{"data-slot":`gh-thread-header`,className:`mb-4 text-[11px] font-semibold tracking-wide text-soft-foreground uppercase`,children:[`Activity · `,r.comments.length,` comment`,r.comments.length===1?``:`s`]}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-5`,children:Pt(i).map(e=>e.group===`commits`?(0,K.jsx)(Ft,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,K.jsx)(Gt,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,K.jsx)(It,{event:e.entry.event,colors:t},e.entry.event.id))}),r.truncated?(0,K.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-thread-truncated`,className:`mt-4 inline-flex items-center gap-0.5 text-xs text-soft-foreground hover:text-foreground hover:underline`,children:[`thread truncated — open on GitHub`,(0,K.jsx)(D,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var Nt=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function Pt(e){let t=[],n=[],r=()=>{n.length!==0&&(n.length===1?t.push({group:`single`,entry:{row:`event`,event:n[0]}}):t.push({group:`commits`,commits:n}),n=[])};for(let i of e){if(i.row===`event`&&i.event.kind===`committed`&&i.row===`event`){let e=n[n.length-1];e&&e.actor!==i.event.actor&&r(),n.push(i.event);continue}r(),t.push({group:`single`,entry:i})}return r(),t}function Ft({commits:e,colors:t}){let[n,r]=(0,G.useState)(!1),i=e[0]?.actor??`?`;return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`true`,className:`min-w-0`,children:(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":!0,onClick:()=>r(!1),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:X.committed}),(0,K.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,K.jsxs)(`span`,{children:[`added `,e.length,` commits`]})]})}),e.map(e=>(0,K.jsx)(It,{event:e,colors:t},e.id))]}):(0,K.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`false`,className:`min-w-0`,children:(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":!1,onClick:()=>r(!0),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:X.committed}),(0,K.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,K.jsxs)(`span`,{children:[`added `,e.length,` commits`]}),(0,K.jsx)(`span`,{className:`shrink-0`,children:z(e[e.length-1].createdAt)})]})})}var X={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function It({event:e,colors:t}){return(0,K.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:r(`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,e.kind===`merged`&&`text-accent-foreground`),children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:X[e.kind]}),(0,K.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,K.jsx)(Ht,{event:e,colors:t}),(0,K.jsx)(`span`,{className:`shrink-0`,children:z(e.createdAt)}),e.url?(0,K.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open ${e.kind} on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(D,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function Lt({event:e}){return(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`shrink-0`,children:`committed`}),e.sha?(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}):null,e.message?(0,K.jsx)(`span`,{className:`truncate font-sans text-foreground`,children:e.message}):null,(0,K.jsx)(Ut,{checks:e.checks})]})}function Rt({event:e,colors:t}){return(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`shrink-0`,children:e.kind===`labeled`?`added the`:`removed the`}),e.label?(0,K.jsx)(`span`,{"data-slot":`gh-event-label`,style:Y(e.label.color??t[e.label.name]),className:`max-w-[12rem] truncate rounded-full border px-1.5 py-px font-sans text-[12px]`,children:e.label.name}):null,(0,K.jsx)(`span`,{className:`shrink-0`,children:`label`})]})}function zt({event:e}){return(0,K.jsxs)(`span`,{className:`truncate`,children:[e.kind===`assigned`?`assigned`:`unassigned`,` `,e.subject??`someone`]})}function Bt({event:e}){return(0,K.jsxs)(`span`,{className:`truncate`,children:[`referenced this in `,e.refNumber?`#${e.refNumber}`:`another thread`,e.refTitle?` ${e.refTitle}`:``]})}var Vt={committed:e=>(0,K.jsx)(Lt,{event:e}),labeled:(e,t)=>(0,K.jsx)(Rt,{event:e,colors:t}),unlabeled:(e,t)=>(0,K.jsx)(Rt,{event:e,colors:t}),assigned:e=>(0,K.jsx)(zt,{event:e}),unassigned:e=>(0,K.jsx)(zt,{event:e}),merged:()=>(0,K.jsx)(`span`,{children:`merged this`}),closed:()=>(0,K.jsx)(`span`,{children:`closed this`}),reopened:()=>(0,K.jsx)(`span`,{children:`reopened this`}),head_ref_force_pushed:()=>(0,K.jsx)(`span`,{children:`force-pushed`}),renamed:e=>(0,K.jsxs)(`span`,{className:`truncate`,children:[`renamed this to `,e.subject??`—`]}),"cross-referenced":e=>(0,K.jsx)(Bt,{event:e})};function Ht({event:e,colors:t}){return Vt[e.kind]?.(e,t)??null}function Ut({checks:e}){return e?(0,K.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:r(`shrink-0`,Q[e]),children:Z[e]}):null}var Wt={approved:{label:`approved`,tone:`border-success/40 text-success`},changes_requested:{label:`changes requested`,tone:`border-danger/40 text-danger`},commented:{label:`commented`,tone:`border-border text-muted-foreground`},dismissed:{label:`dismissed`,tone:`border-border text-muted-foreground`}};function Gt({comment:e}){let t=e.reviewState?Wt[e.reviewState]:null;return(0,K.jsxs)(`li`,{"data-slot":`gh-thread-entry`,"data-kind":e.kind,className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,K.jsx)(Kt,{url:e.avatarUrl,login:e.author}),(0,K.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.author}),(0,K.jsx)(`span`,{children:z(e.createdAt)}),t?(0,K.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:r(`rounded-full border px-1.5 py-px font-sans text-[12px] font-medium`,t.tone),children:t.label}):null,(0,K.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open comment on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(D,{"aria-hidden":`true`,className:`size-2.5`})})]}),(0,K.jsx)(`div`,{"data-slot":`gh-thread-body`,className:`text-sm`,children:e.body?(0,K.jsx)(Ze,{children:e.body}):(0,K.jsx)(`p`,{className:`text-soft-foreground`,children:`(no body)`})})]})}function Kt({url:e,login:t}){let[n,r]=(0,G.useState)(!1);return e&&!n?(0,K.jsx)(`img`,{src:e,alt:``,width:16,height:16,loading:`lazy`,onError:()=>r(!0),"data-slot":`gh-avatar`,className:`size-4 shrink-0 rounded-full`}):(0,K.jsx)(`span`,{"data-slot":`gh-avatar-fallback`,"aria-hidden":`true`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-semibold text-muted-foreground uppercase`,children:t.slice(0,1)||`?`})}var Z={passing:`✓`,failing:`✗`,pending:`○`},Q={passing:`text-success`,failing:`text-danger`,pending:`text-muted-foreground`};function qt({count:e}){return e?(0,K.jsxs)(`span`,{"data-slot":`gh-comment-count`,"data-count":e,"aria-label":`${e} comment${e===1?``:`s`}`,className:`inline-flex shrink-0 items-center gap-0.5`,children:[(0,K.jsx)(ue,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function Jt({checks:e,url:t}){let n=r(`text-[11px] font-medium`,Q[e],t&&`hover:underline`),i=`${Z[e]} checks ${e}`;return t?(0,K.jsx)(`a`,{href:`${t}/checks`,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-checks`,"data-checks":e,className:n,children:i}):(0,K.jsx)(`span`,{"data-slot":`gh-checks`,"data-checks":e,className:n,children:i})}function Yt({checks:e}){return(0,K.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:`checks ${e}`,"aria-label":`checks ${e}`,className:r(`shrink-0 font-sans text-[11px] font-semibold`,Q[e]),children:Z[e]})}function $(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function Xt(e,t=[]){let n=$(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=Zt(t)),n}function Zt(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function Qt(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function $t(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function en(e,t,n){let r=(n??``).trim();if(!r)return Xt(e,t);let i=$(e),a=r.startsWith(i)?i+Qt(r.slice(i.length),e):Qt(r,e),o=$t(a,e)?a:`${i}\n\n${a}`;return t.length?o+Zt(t):o}function tn(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function nn(e,t,n,r,i={}){return t?{...i,workflow:t,task:en(e,n,r)}:n.length?{...i,steps:tn(n),task:en(e,[],r)}:{...i,workflow:`quick-task`,task:en(e,[],r)}}function rn(e){let t=m(),n=S(),r=f(t.data),i=n.data?.defaultRunner,a=be(e.runner,r,i??r[0]??`claude`),o=T(a),s=n.data?.modelsLocked===!0,{accounts:c,repoAccount:l}=Fe(),u=c.some(t=>t.provider===a&&t.id===e.account)?e.account:null,d=De(s?null:e.model,a,n.data?.defaultModels,o.data),p=ke(a,d,o.data);return{runner:a,runnerExplicit:e.runner!==null,model:d,effort:s?``:Be(e.effort,p),effortOptions:p,runners:r,defaultRunner:i,canRun:t.isSuccess&&r.length>0,modelsLocked:s,providerPending:t.isPending,providerError:t.isError,accounts:c,account:u,repoAccount:l}}function an(e){return{runner:Ce(e.runner,e.defaultRunner,e.runnerExplicit),model:e.modelsLocked?void 0:e.model||void 0,effort:e.modelsLocked?void 0:e.effort||void 0}}function on(e){return{...an(e),...e.account?{agentProfile:e.account}:{}}}function sn({pick:e,onChange:t,disabled:n=!1,accounts:r=!1,layout:i}){let a=(0,G.useRef)(null),o=(0,G.useRef)(null),[s,c]=(0,G.useState)(()=>typeof window<`u`&&window.innerWidth<=767);(0,G.useLayoutEffect)(()=>{let e=a.current;if(i!==`row`||!e)return;let t=()=>{let t=window.innerWidth<=767||e.getBoundingClientRect().width<550,n=document.activeElement;o.current=n instanceof HTMLElement&&e.contains(n)?n:null,c(t)};t();let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[i]),(0,G.useLayoutEffect)(()=>{let e=o.current;o.current=null,e&&e.isConnected&&document.activeElement!==e&&e.focus()},[s]);let l=rn(e),{runner:u,model:d,effort:f,effortOptions:p,runners:m,canRun:h,modelsLocked:g}=l,_=S(),v=T(u),y=Ee(u,v.data,[e.model,_.data?.defaultModels?.[u]]),b=n||!h,x=r?l.accounts:[],C=m.length>1||m.some(e=>Re(x,e))?(0,K.jsx)(Oe,{icon:(0,K.jsx)(re,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:m,value:u,accounts:x,account:r?l.account:null,repoAccount:r?l.repoAccount:void 0,disabled:b,onPick:(n,i)=>t(r?{runner:n,account:i,model:n===u?e.model:null,effort:e.effort}:{runner:n,account:null,model:null,effort:e.effort})},`runner`):null,w=(0,K.jsx)(W,{icon:(0,K.jsx)(P,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:d===``?`Default`:y.find(e=>e.id===d).label,value:d,disabled:b,readOnly:g===!0,disabledHint:g?`Model selection is locked to native coding-agent settings.`:void 0,onPick:n=>{let r=ke(u,n,v.data);t({...e,model:n,effort:e.effort===null?null:Be(e.effort,r)})},options:y.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Ve(u,v.data,v.isError,v.isFetching)},`model`),E=(0,K.jsx)(W,{icon:(0,K.jsx)(M,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:p.find(e=>e.value===f)?.label??`auto`,value:f,disabled:b,readOnly:g===!0,disabledHint:g?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:n=>t({...e,effort:n}),options:p.map(e=>({value:e.value,label:e.label,desc:e.desc}))},`effort`);return i===`row`?(0,K.jsx)(`div`,{ref:a,"data-slot":`engine-row-box`,children:(0,K.jsx)(`div`,{"data-slot":`engine-row`,className:`engine-row`,role:`group`,"aria-label":`Agent settings`,children:(0,K.jsx)(Me,{children:s?[C,E,w]:[C,w,E]})})}):(0,K.jsxs)(Me,{children:[C,w,E]})}var cn={workflow:null,skills:[]},ln=`cez-followup-selection`;function un(e){let t=e&&typeof e==`object`?e:{};return{workflow:typeof t.workflow==`string`?t.workflow:null,skills:Array.isArray(t.skills)?t.skills.filter(e=>typeof e==`string`):[]}}function dn(){try{let e=localStorage.getItem(ln);return e?un(JSON.parse(e)):{...cn}}catch{return{...cn}}}function fn(e){try{localStorage.setItem(ln,JSON.stringify(e))}catch{}}var pn=`cez-followup-prompt:`;function mn(e){try{return localStorage.getItem(pn+e)??``}catch{return``}}function hn(e,t){try{t===``?localStorage.removeItem(pn+e):localStorage.setItem(pn+e,t)}catch{}}function gn({item:e,workflows:r,skills:i,workflow:a,onWorkflowChange:l,selectedSkills:u,onSkillsChange:d,engine:f,onEngineChange:p,queuedRunId:m,onQueued:h}){let g=s(),_=v(),y=b().data?.capabilities.automations===!0,S=e.kind===`pr`?`PR`:`issue`,w=u.filter(e=>i.some(t=>t.name===e)),[T]=(0,G.useState)(()=>$(e)),[E,D]=(0,G.useState)(()=>mn(e.url)||T),O=rn(f),k=(0,G.useRef)(null),A=(0,G.useRef)(null);(0,G.useEffect)(()=>{hn(e.url,E===T?``:E)},[e.url,E,T]);let M=(0,G.useMemo)(()=>je(Ae(_.data?.promptTemplates),{automations:y}),[_.data?.promptTemplates,y]),ee=e=>{let t=k.current,n=Pe({prompt:E,base:T,selectionStart:t?.selectionStart??null,focused:document.activeElement===t,remembered:A.current}),r=ze(E,n,e);D(r.text),A.current=r.caret,requestAnimationFrame(()=>{k.current?.focus(),k.current?.setSelectionRange(r.caret,r.caret)})},N=Ne(M,w),P=(0,G.useRef)(E);P.current=E;let F=(0,G.useRef)(``);(0,G.useEffect)(()=>{let e=Ie(P.current,F.current,N,T);F.current=e.applied,e.text!==P.current&&D(e.text)},[N,T]);let I=x({mutationFn:async()=>O.canRun?o(nn(e,a,w,E,on(O))):null,onSuccess:t=>{if(t===null)return;let n=t;n&&h(e.url,n.id),j(`Added to the queue — ${S} #${e.number}`),w.length>0&&_.data!==void 0&&c({skillUsage:w.reduce((e,t)=>qe(e,t),_.data.skillUsage)}).then(()=>g.invalidateQueries({queryKey:C.uiState})).catch(()=>{}),hn(e.url,``),D(T),F.current=``,g.invalidateQueries({queryKey:C.runs.all})},onError:e=>j(e.message,{tone:`danger`})}),te=e=>{$e({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),!I.isPending&&O.canRun&&I.mutate())},L=e=>d(u.includes(e)?u.filter(t=>t!==e):[...u,e]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`section`,{"data-slot":`gh-hand`,className:`mt-7 rounded-lg border border-border bg-card p-4`,children:[(0,K.jsx)(`h3`,{className:`text-xl font-normal text-foreground`,children:`Hand this to the agent`}),(0,K.jsxs)(`label`,{className:`gh-field gh-prompt-field`,children:[(0,K.jsx)(`span`,{children:`Instructions for the agent`}),(0,K.jsx)(Ye,{ref:k,"data-slot":`gh-custom-prompt`,"aria-label":`Custom prompt`,"aria-keyshortcuts":`Control+Enter Meta+Enter`,value:E,onChange:e=>D(e.target.value),onSelect:e=>{A.current=e.currentTarget.selectionStart},onKeyDown:te,placeholder:`Instructions for the agent… (#${e.number} and its link are always sent)`,className:`mt-3 min-h-20 text-[13px]`})]}),(0,K.jsx)(ve,{templates:M,onInsert:ee}),(0,K.jsxs)(`div`,{className:`gh-handoff-settings`,children:[(0,K.jsxs)(`div`,{className:`gh-field`,children:[(0,K.jsx)(`span`,{children:`Workflow`}),(0,K.jsx)(_n,{workflows:r,value:a,onChange:l})]}),(0,K.jsxs)(`div`,{className:`gh-field`,children:[(0,K.jsx)(`span`,{children:`Skills · select one or more`}),(0,K.jsx)(yn,{skills:i,skillUsage:_.data?.skillUsage,selected:w,onToggle:L})]}),w.length>0?(0,K.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:w.map(e=>(0,K.jsxs)(`button`,{type:`button`,"data-slot":`gh-skill-chip`,"data-skill":e,onClick:()=>L(e),title:`Remove this skill`,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[e,(0,K.jsx)(ne,{size:16,"aria-hidden":`true`,className:`size-3`})]},e))}):null,(0,K.jsx)(sn,{layout:`row`,pick:f,onChange:p,disabled:I.isPending||!O.canRun,accounts:!0}),(0,K.jsxs)(`div`,{className:`gh-field`,children:[(0,K.jsx)(`span`,{children:`Account`}),(0,K.jsx)(vn,{resolved:O,disabled:I.isPending||!O.canRun,onPick:e=>p({...f,account:e})})]}),!O.providerPending&&!O.canRun?(0,K.jsxs)(`span`,{"data-slot":`gh-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[O.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,K.jsx)(H,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null]}),(0,K.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:[e.kind===`pr`?`PR`:`Issue`,` number and link remain attached to the task. Edit the prompt before starting. Cmd/Ctrl+Enter submits; Enter adds a new line.`]})]}),(0,K.jsxs)(`div`,{"data-slot":`gh-handoff-actions`,className:`mt-[22px] flex flex-wrap items-center gap-2.5`,children:[t(e.url)?(0,K.jsx)(n,{asChild:!0,variant:`outline`,children:(0,K.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open in GitHub`})}):null,(0,K.jsxs)(n,{variant:`primary`,"data-action":`gh-run`,disabled:I.isPending||!O.canRun,onClick:()=>I.mutate(),children:[(0,K.jsx)(de,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,S]}),(0,K.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[11px] font-medium text-muted-foreground`,children:Qe()}),m?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{"data-slot":`gh-queued`,className:`flex items-center gap-1 text-xs font-medium text-success`,children:[(0,K.jsx)(R,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,K.jsx)(H,{to:`/tasks/${m}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-accent-text hover:underline`,children:`View task →`})]}):null]})]})}function _n({workflows:e,value:t,onChange:n}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(``),c=(0,G.useRef)(null),l=Ue(e,o);return(0,K.jsxs)(A,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,K.jsx)(k,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:r(Le,t&&`border-foreground/60 font-mono text-[11px] font-semibold text-foreground`),children:[(0,K.jsx)(te,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-44 truncate`,children:t??`workflow`}),(0,K.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,K.jsx)(O,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,K.jsxs)(we,{shouldFilter:!1,children:[(0,K.jsx)(Te,{placeholder:`search workflows…`,value:o,onValueChange:s,onInput:()=>c.current?.scrollTo(0,0)}),(0,K.jsxs)(ye,{ref:c,"data-slot":`gh-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[l.length===0?(0,K.jsx)(xe,{children:`Nothing matches.`}):null,(0,K.jsx)(U,{children:l.map(e=>{let r=t===e.name;return(0,K.jsxs)(He,{value:`workflow ${e.name}`,keywords:We(e.name,e.description),"data-slot":`gh-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),a(!1)},children:[(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,K.jsx)(R,{size:16,"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},e.name)})})]})]})})]})}function vn({resolved:e,disabled:t,onPick:n}){let r=e.accounts.filter(t=>t.provider===e.runner),i=[...r.some(e=>e.id==="default")?[]:[{value:Se,label:`Default`}],...r.map(e=>({value:e.id,label:e.label,desc:e.configDir}))],a=e.account??e.repoAccount?.[e.runner]??`default`;return(0,K.jsx)(W,{icon:(0,K.jsx)(se,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),slot:`account-pill`,ariaLabel:`Account`,label:i.find(e=>e.value===a)?.label??`Default`,value:a,options:i,disabled:t,onPick:n})}function yn({skills:e,skillUsage:t,selected:n,onToggle:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(null),d=(0,G.useRef)(null),{mostUsed:f,project:p,global:m,ranked:h}=Je(e,s,t),g=(e,t)=>{let a=n.includes(e.name);return(0,K.jsxs)(He,{value:`skill ${e.name} ${e.path}`,keywords:We(e.name,e.description),"data-slot":`gh-skill-option`,"data-skill":e.name,"data-selected":a?`true`:void 0,onSelect:()=>i(e.name),children:[(0,K.jsx)(`span`,{className:r(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,K.jsx)(`button`,{type:`button`,"data-slot":`gh-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),u(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,K.jsx)(ce,{"aria-hidden":`true`,className:`size-3.5`})}),a?(0,K.jsx)(R,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.path)};return e.length===0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Xe,{skill:l,onClose:()=>u(null)}),(0,K.jsxs)(A,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,K.jsx)(k,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:r(Le,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,K.jsx)(ae,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`skills`,n.length>0?` · ${n.length}`:``,(0,K.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,K.jsx)(O,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,K.jsxs)(we,{shouldFilter:!1,children:[(0,K.jsx)(Te,{placeholder:`search skills…`,value:s,onValueChange:c,onInput:()=>d.current?.scrollTo(0,0)}),(0,K.jsxs)(ye,{ref:d,"data-slot":`gh-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(h?h.length===0:f.length===0&&p.length===0&&m.length===0)?(0,K.jsx)(xe,{children:`Nothing matches.`}):null,h?h.length>0?(0,K.jsx)(U,{children:h.map(e=>g(e,Ge(e)))}):null:(0,K.jsxs)(K.Fragment,{children:[f.length>0?(0,K.jsx)(U,{heading:`Most used`,children:f.map(e=>g(e,Ge(e)))}):null,p.length>0?(0,K.jsx)(U,{heading:`Project skills`,children:p.map(e=>g(e,!0))}):null,m.length>0?(0,K.jsx)(U,{heading:`Global`,children:m.map(e=>g(e,!1))}):null]})]})]})})]})]})}var bn=new WeakMap;function xn(){let e=dn(),t={workflow:e.workflow,selectedSkills:e.skills,engine:{runner:null,model:null,effort:null,account:null},queued:new Map},n=new Set;return{snapshot:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),update:e=>{t={...t,...e},(e.workflow!==void 0||e.selectedSkills!==void 0)&&fn({workflow:t.workflow,skills:[...t.selectedSkills]}),n.forEach(e=>e())}}}function Sn(){let e=s(),{projectId:t}=u(),n=bn.get(e);n||bn.set(e,n=new Map);let r=n.get(t);r||n.set(t,r=xn());let{snapshot:i,subscribe:a,update:o}=r,c=(0,G.useSyncExternalStore)(a,i,i),l=g(),d=h(),f=v(),p=l.data?.workflows;(0,G.useEffect)(()=>{p&&c.workflow!==null&&!p.some(e=>e.name===c.workflow)&&o({workflow:null})},[o,p,c.workflow]);let m=(0,G.useMemo)(()=>Ke(d.data??[],f.data?.skillUsage),[d.data,f.data?.skillUsage]);return{...c,workflows:l,skillList:m,setWorkflow:e=>o({workflow:e}),setSelectedSkills:e=>o({selectedSkills:e}),setEngine:e=>o({engine:e}),onQueued:(e,t)=>o({queued:new Map(i().queued).set(e,t)})}}export{qt as a,Pt as c,Y as d,xt as f,Yt as i,yt as l,gn as n,At as o,Xt as r,St as s,Sn as t,bt as u};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,t as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{C as o,Vr as s,_r as c,en as l,nt as u,r as d,rt as f,zt as p}from"./project-scope-context-CSPQyWoO.js";import{$ as m,At as h,Lt as g,M as _,Nt as v,O as y,P as b,Qt as x,h as S,n as C,nt as w,wt as T}from"./queries-pj368bmB.js";import{t as E}from"./useQuery-BoLjCS2U.js";import{Q as D,a as O,o as k,r as A}from"./use-desktop-Bq_Qh5ur.js";import{n as j}from"./toaster-CoMJoQvk.js";import{A as M,Z as ee,_ as N,b as P,ct as F,d as I,ft as te,h as L,l as R,mt as ne,ot as re,r as ie,rt as ae,u as oe,ut as se}from"./design-icons-DmYTv2r1.js";import{t as ce}from"./eye-B8okNWXU.js";import{a as le,i as z}from"./format-BNCkW110.js";import{t as ue}from"./message-square-B-MD-8rD.js";import{t as de}from"./play-CmVAj_fu.js";import{a as fe,i as pe,o as me,r as he,s as ge,t as _e}from"./dialog-B7p5oc5r.js";import{d as B,t as ve,y as V}from"./prompt-template-menu-VwBcsbqE.js";import{t as H}from"./project-router-CiB1O_5A.js";import{B as ye,E as be,I as xe,L as U,M as Se,O as Ce,P as we,R as Te,S as Ee,T as De,a as Oe,b as ke,f as Ae,h as je,i as Me,l as Ne,m as Pe,n as Fe,p as Ie,r as W,s as Le,t as Re,u as ze,w as Be,x as Ve,z as He}from"./agent-accounts-BxpWcFS3.js";import{d as Ue,f as We,i as Ge,s as Ke,t as qe,u as Je}from"./skills-DFBiAuJG.js";import{$ as Ye,F as Xe,L as Ze,X as Qe,Y as $e,pn as et}from"./index-CsOa03VW.js";import{t as tt}from"./diff-MoyKcT8Q.js";import{t as nt}from"./tab-link-BPBiho7-.js";var G=e(i(),1),K=a(),rt={squash:`Squash and merge`,merge:`Create a merge commit`,rebase:`Rebase and merge`};function q({state:e}){let t=`size-4 shrink-0`;return e===`passing`?(0,K.jsx)(R,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-passing`,className:r(t,`text-success`)}):e===`failing`?(0,K.jsx)(N,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-failing`,className:r(t,`text-danger`)}):e===`pending`?(0,K.jsx)(le,{"aria-hidden":`true`,"data-slot":`gh-merge-status-pending`,className:r(t,`animate-spin text-warning`)}):(0,K.jsx)(L,{size:16,"aria-hidden":`true`,"data-slot":`gh-merge-status-unknown`,className:r(t,`text-soft-foreground`)})}function it(e){return e?.available?e.mergeState:null}function at(e,t){return e&&t?.methods.includes(e)?e:t?.defaultMethod??t?.methods[0]??null}function ot(e){return e.state===`merged`?`Merged`:e.state===`closed`?`Closed`:e.isDraft?`Draft`:e.mergeable===`conflicting`?`Conflicts must be resolved`:e.canMerge?`Ready to merge`:e.eligibility===`unknown`?`Merge blocked · Requirements unknown`:`Merge blocked`}function st(e){return e===`approved`||e===`not-required`?`passing`:e===`unknown`?`unknown`:`failing`}function ct(e){return e===`mergeable`?`passing`:e===`conflicting`?`failing`:`unknown`}function lt(e){return e===`conflicting`?`present`:e===`mergeable`?`none`:`unknown`}function ut(e){return e===!0?` · required`:e===null?` · requiredness unknown`:``}function dt(e){return e?.available===!1?e.reason:`GitHub could not load merge requirements.`}function ft(e,t,n){return!!(e&&(t.canMerge||t.canOverride&&n))}function J(e){return e?rt[e]:`Merge`}function pt(e){return e===`conflicting`?`true`:void 0}function mt({check:e}){return(0,K.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(q,{state:e.state}),(0,K.jsxs)(`span`,{children:[e.name,` · `,e.state,ut(e.required)]})]}),e.url&&t(e.url)?(0,K.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground underline`,children:`details`}):null]})}function ht({reason:e}){return(0,K.jsxs)(`section`,{"data-slot":`gh-merge-unavailable`,className:`mt-6 rounded-lg border border-border bg-card p-4 text-sm`,children:[(0,K.jsx)(`p`,{className:`font-medium`,children:`Merge status unavailable`}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:e})]})}function gt({state:e,selectedMethod:t,overrideRules:i,mergeEnabled:a,refreshPending:o,onRefresh:s,onRunAgent:c,onConfirm:l,onMethodChange:u,onOverrideChange:d}){let f=ot(e),p=st(e.reviewDecision),m=ct(e.mergeable);return(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[e.canMerge?(0,K.jsx)(R,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-success`}):(0,K.jsx)(F,{size:16,"aria-hidden":`true`,className:`mt-0.5 size-5 shrink-0 text-warning`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(`h3`,{className:`font-semibold`,children:f}),(0,K.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,disabled:o,onClick:s,children:[(0,K.jsx)(ee,{size:16,"aria-hidden":`true`,className:r(`size-3.5`,o&&`animate-spin`)}),`Refresh`]})]}),(0,K.jsxs)(`p`,{className:`mt-1 font-mono text-[11px] text-soft-foreground`,children:[e.headRef,` (`,e.headSha.slice(0,7),`) → `,e.baseRef]}),(0,K.jsxs)(`ul`,{className:`mt-3 space-y-2 text-xs`,children:[(0,K.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(q,{state:p}),(0,K.jsxs)(`span`,{children:[`Reviews: `,e.reviewDecision.replaceAll(`-`,` `)]})]}),(0,K.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(q,{state:m}),(0,K.jsxs)(`span`,{children:[`Conflicts: `,lt(e.mergeable)]})]}),e.checks.length===0?(0,K.jsx)(`li`,{children:`No checks configured`}):e.checks.map(e=>(0,K.jsx)(mt,{check:e},e.name)),e.blockers.map(e=>(0,K.jsx)(`li`,{className:`text-soft-foreground`,children:e.message},e.code))]}),e.mergeable===`conflicting`&&c?(0,K.jsx)(n,{className:`mt-4`,onClick:c,children:`Run agent on this PR`}):null,e.canOverride?(0,K.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-2 rounded-md border border-warning/40 bg-warning/5 p-3 text-xs`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>d(e.target.checked),className:`mt-0.5 size-4 accent-accent-strong`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`block font-medium`,children:`Merge without waiting for requirements`}),(0,K.jsx)(`span`,{className:`mt-0.5 block text-soft-foreground`,children:`GitHub will allow this only if your permissions can bypass the repository rules.`})]})]}):null,e.eligibility===`unknown`?(0,K.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`GitHub could not confirm review and branch-protection requirements. Passing checks do not establish merge readiness.`}):null,e.state===`open`&&e.methods.length>0?(0,K.jsxs)(`div`,{className:`mt-4 flex flex-col flex-wrap gap-2 sm:flex-row`,children:[(0,K.jsx)(`select`,{"aria-label":`Merge method`,value:t??``,onChange:e=>u(e.target.value),className:`h-9 min-w-0 flex-1 rounded-md border border-input bg-background px-3 text-sm`,children:e.methods.map(e=>(0,K.jsx)(`option`,{value:e,children:rt[e]},e))}),(0,K.jsx)(n,{disabled:!a,onClick:l,children:J(t)})]}):null]})]})}function _t({number:e,state:t,selectedMethod:r,confirming:i,overrideRules:a,mergePending:o,mergeError:s,onOpenChange:c,onMerge:l}){return(0,K.jsx)(_e,{open:i,onOpenChange:c,children:(0,K.jsxs)(he,{"data-slot":`gh-merge-confirm`,showCloseButton:!1,children:[(0,K.jsxs)(me,{children:[(0,K.jsxs)(ge,{children:[J(r),` pull request #`,e,`?`]}),(0,K.jsx)(pe,{asChild:!0,children:(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{children:[`This will merge “`,t.title,`” into `,t.baseRef,`. GitHub will re-check the exact reviewed head before changing the repository.`]}),a&&t.canOverride?(0,K.jsx)(`p`,{"data-slot":`gh-bypass-warning`,className:`mt-4 text-sm text-warning`,children:`You are asking GitHub to bypass unmet repository requirements; GitHub may refuse if your permissions do not allow it.`}):null]})})]}),s?(0,K.jsx)(`p`,{className:`text-sm text-danger`,children:s.message}):null,(0,K.jsxs)(fe,{children:[(0,K.jsx)(n,{variant:`outline`,disabled:o,onClick:()=>c(!1),children:`Cancel`}),(0,K.jsx)(n,{disabled:o,onClick:l,children:o?`Merging…`:J(r)})]})]})})}function vt({number:e,onRunAgent:t}){let n=s(),r=w(),i=E({queryKey:C.githubMergeState(e),queryFn:({signal:t})=>f(e,{},{signal:t}),retry:!1}),a=it(i.data),[o,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(!1),[d,m]=(0,G.useState)(!1),h=x({mutationFn:t=>f(e,{refresh:!0}),onSuccess:(e,t)=>n.setQueryData(t,e),onError:e=>j(e instanceof Error?e.message:String(e),{tone:`danger`})}),g=at(o,a),_=()=>({mergeState:C.githubMergeState(e),list:C.githubPages(50),comments:C.githubComments(`pr`,e),item:C.githubItem(`pr`,e),refStatus:r===void 0?void 0:C.githubRefStatusOf(r)}),v=x({mutationFn:t=>{if(!a||!g)throw Error(`No merge method is available.`);return p(e,{method:g,expectedHeadSha:a.headSha,...d&&a.canOverride?{overrideRules:!0}:{}})},onSuccess:(t,r)=>{u(!1),j(`Pull request #${e} merged`),n.invalidateQueries({queryKey:r.mergeState}),n.invalidateQueries({queryKey:r.list}),n.invalidateQueries({queryKey:r.comments}),n.invalidateQueries({queryKey:r.item}),r.refStatus&&n.invalidateQueries({queryKey:r.refStatus})},onError:(e,t)=>{j(e instanceof Error?e.message:String(e),{tone:`danger`}),n.invalidateQueries({queryKey:t.mergeState})}});return i.isPending?(0,K.jsx)(V,{"data-slot":`gh-merge-loading`,className:`mt-6 h-32 w-full`}):a?(0,K.jsxs)(`section`,{"data-slot":`gh-merge-box`,"data-eligibility":a.eligibility,"data-conflicting":pt(a.mergeable),"aria-live":`polite`,className:`mt-6 rounded-lg border border-border bg-card p-4`,children:[(0,K.jsx)(gt,{state:a,selectedMethod:g,overrideRules:d,mergeEnabled:ft(g,a,d),refreshPending:h.isPending,onRefresh:()=>h.mutate(C.githubMergeState(e)),onRunAgent:t,onConfirm:()=>u(!0),onMethodChange:c,onOverrideChange:m}),(0,K.jsx)(_t,{number:e,state:a,selectedMethod:g,confirming:l,overrideRules:d,mergePending:v.isPending,mergeError:v.error,onOpenChange:u,onMerge:()=>v.mutate(_())})]}):(0,K.jsx)(ht,{reason:dt(i.data)})}function yt(e){let t=new Set;for(let n of e)for(let e of n.labels)t.add(e);return[...t].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))}function bt(e,t={}){let n=(t.query??``).trim().toLowerCase(),r=t.labels??[],i=n.replace(/^#/,``),a=i!==``&&/^\d+$/.test(i);return e.filter(e=>r.length>0&&!r.every(t=>e.labels.includes(t))||t.assignees?.length&&!e.assignees?.some(e=>t.assignees.some(t=>t.toLowerCase()===e.toLowerCase()))||t.author!==void 0&&e.author.toLowerCase()!==t.author.toLowerCase()||t.includeNumbers&&!t.includeNumbers.has(e.number)||t.excludeNumbers?.has(e.number)||t.projectId&&e.projectIds!==void 0&&!e.projectIds.includes(t.projectId)?!1:n===``?!0:a?String(e.number).includes(i):`#${e.number} ${e.title} ${e.author} ${e.body??``}`.toLowerCase().includes(n))}function xt(e,t){let n=e.trim();if(n===``)return!1;let r=n.replace(/^#/,``);return/^\d+$/.test(r)?!t.some(e=>e.number===Number(r)):t.length===0}function Y(e){if(!e||!/^[0-9a-fA-F]{6}$/.test(e))return{borderColor:`var(--border)`,color:`var(--muted-foreground)`};let t=`#${e}`;return{backgroundColor:`${t}22`,borderColor:`${t}66`,color:`color-mix(in srgb, ${t} 50%, var(--foreground))`}}function St({label:e,color:t,plain:n=!1}){return(0,K.jsx)(`span`,{"data-slot":`gh-label`,"data-label":e,style:n?void 0:Y(t),className:n?`text-[11px] font-normal text-muted-foreground`:`rounded-full border px-1.5 py-px text-[12px] font-medium`,children:e})}function Ct(e){return e===`pr`?`pull request`:`issue`}function wt(e,t,n){return e===`pr`&&!!(t||n)}function Tt({backLink:e}){return e?(0,K.jsxs)(H,{to:e.to,"data-slot":`gh-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,K.jsx)(ie,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}):null}function Et({item:e,kindWord:n,commentCount:r,hasDiffStat:i,additions:a,deletions:o}){return(0,K.jsxs)(`p`,{"data-slot":`gh-meta`,className:`flex flex-wrap items-center gap-x-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,K.jsxs)(`span`,{children:[`#`,e.number]}),`·`,(0,K.jsx)(`span`,{children:n}),`·`,(0,K.jsxs)(`span`,{children:[`opened by `,e.author]}),`·`,(0,K.jsxs)(`span`,{children:[z(e.createdAt),` ago`]}),r?(0,K.jsxs)(K.Fragment,{children:[`·`,(0,K.jsx)(qt,{count:r})]}):null,i?(0,K.jsxs)(K.Fragment,{children:[`·`,(0,K.jsxs)(`span`,{"data-slot":`gh-diffstat`,children:[(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,a??0]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,o??0]})]})]}):null,`·`,t(e.url)?(0,K.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-open-link`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,K.jsx)(D,{"aria-hidden":`true`,className:`size-2.5`})]}):(0,K.jsx)(`span`,{"data-slot":`gh-open-link`,className:`text-muted-foreground`,children:`open on GitHub`})]})}function Dt({item:e,subNav:t,changes:n}){return e.kind===`pr`?t?(0,K.jsxs)(`nav`,{"aria-label":`Pull request detail`,className:`mt-4 flex border-b border-border`,children:[(0,K.jsx)(nt,{to:B(`prs`,t.filter,e.number),active:!n,children:`Conversation`}),(0,K.jsx)(nt,{to:B(`prs`,t.filter,e.number,`/changes`),active:n,children:`Changes`})]}):(0,K.jsx)(H,{to:B(`prs`,null,e.number,`/changes`),"data-slot":`gh-files-changed`,className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:underline`,children:`Files changed`}):null}function Ot({item:e,colors:t,checks:n}){return e.labels.length>0||n?(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[e.labels.map(e=>(0,K.jsx)(St,{label:e,color:t[e]},e)),n?(0,K.jsx)(Jt,{checks:n,url:e.url}):null]}):null}function kt({item:e,colors:t,body:n}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{"data-slot":`gh-body`,className:`mt-5 text-sm`,children:n?(0,K.jsx)(Ze,{children:n}):(0,K.jsx)(`p`,{className:`text-soft-foreground`,children:`(no description)`})}),(0,K.jsx)(Mt,{item:e,colors:t})]})}function At({item:e,colors:t,checks:n,comments:r,backLink:i,subNav:a,onRunAgent:o,afterHeading:s,children:c}){let l=a?.changes??!1,u=Ct(e.kind),d=y(e.kind,e.number,!l).data?.detail,f=d?.body??e.body,p=d?.additions??e.additions,m=d?.deletions??e.deletions,h=wt(e.kind,p,m),g=r??e.comments;return(0,K.jsxs)(`article`,{"data-slot":`gh-detail-inner`,className:`min-w-0 px-4 py-4 md:px-7 md:py-5`,children:[(0,K.jsx)(Tt,{backLink:i}),(0,K.jsxs)(`div`,{"data-slot":`gh-description-card`,className:e.kind===`pr`?`rounded-xl border border-border bg-card p-6`:void 0,children:[e.kind===`pr`?(0,K.jsxs)(`h2`,{className:`mb-4 text-[22px] leading-snug font-normal`,children:[`#`,e.number,` `,e.title]}):null,(0,K.jsx)(Et,{item:e,kindWord:u,commentCount:g,hasDiffStat:h,additions:p,deletions:m}),e.kind===`pr`?null:(0,K.jsx)(`h2`,{className:`mt-2 text-[22px] leading-snug font-normal`,children:e.title}),s,(0,K.jsx)(Dt,{item:e,subNav:a,changes:l}),(0,K.jsx)(Ot,{item:e,colors:t,checks:n}),l&&e.kind===`pr`?(0,K.jsx)(jt,{item:e}):(0,K.jsx)(kt,{item:e,colors:t,body:f})]}),e.kind===`pr`?(0,K.jsx)(vt,{number:e.number,onRunAgent:o}):null,c]})}function jt({item:e}){let i=s(),a=_(e.number),[o,c]=(0,G.useState)(``),[l,d]=(0,G.useState)(null),f=a.data,p=f?.available?f.files.filter(e=>e.path.toLowerCase().includes(o.toLowerCase())):[],m=p.findIndex(e=>e.path===l);(0,G.useEffect)(()=>{p.length>0&&!p.some(e=>e.path===l)&&d(p[0].path)},[f?.available?f.headSha:``,o]);let h=async()=>{let t=f?.available?f.headSha:null,n=C.githubPrChanges(e.number),r=await u(e.number,{refresh:!0});i.setQueryData(n,r),r.available&&t&&t!==r.headSha&&(d(r.files[0]?.path??null),j(`The reviewed revision changed.`))};if(a.isPending)return(0,K.jsx)(`p`,{"aria-live":`polite`,className:`mt-6 text-sm text-muted-foreground`,children:`Loading changed files…`});if(a.isError||!f)return(0,K.jsx)(`p`,{className:`mt-6 text-sm text-danger`,children:`Changed files could not be loaded.`});if(!f.available)return(0,K.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:f.reason});let g=p.map(e=>({path:e.path,...e.previousPath?{oldPath:e.previousPath}:{},status:e.status===`removed`?`deleted`:e.status===`changed`?`modified`:e.status,adds:e.additions,dels:e.deletions,binary:e.patchUnavailableReason===`binary`,patch:e.patch??``})),v=t(e.url)?`${e.url}/files`:null,y=p.find(e=>e.path===l);return(0,K.jsxs)(`section`,{"data-slot":`gh-pr-changes`,className:`mt-5 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,K.jsxs)(`strong`,{children:[f.files.length,` changed files`]}),(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,f.additions]}),(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,f.deletions]}),(0,K.jsxs)(`span`,{className:`font-mono text-muted-foreground`,title:f.headSha,children:[`head `,f.headSha.slice(0,8)]}),(0,K.jsx)(n,{type:`button`,variant:`outline`,size:`sm`,className:`ml-auto min-h-11`,onClick:()=>void h(),children:`Refresh`})]}),f.truncated?(0,K.jsxs)(`p`,{role:`status`,className:`mt-3 rounded-md border border-warning/40 bg-warning/10 p-3 text-xs`,children:[f.reason??`This response is incomplete.`,` `,v?(0,K.jsx)(`a`,{href:v,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:`Open all files on GitHub`}):null]}):null,(0,K.jsxs)(`div`,{className:`mt-4 grid min-w-0 gap-4 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,K.jsxs)(`aside`,{className:`min-w-0`,children:[(0,K.jsx)(`input`,{"aria-label":`Filter changed files`,value:o,onChange:e=>c(e.target.value),placeholder:`Filter files…`,className:`min-h-11 w-full rounded-md border border-input bg-background px-3 text-sm`}),(0,K.jsx)(`select`,{"aria-label":`Select changed file`,value:l??``,onChange:e=>d(e.target.value),className:`mt-2 min-h-11 w-full rounded-md border border-input bg-background px-2 text-sm lg:hidden`,children:p.map(e=>(0,K.jsx)(`option`,{children:e.path},e.path))}),(0,K.jsx)(`ul`,{className:`mt-2 hidden max-h-[60vh] overflow-auto lg:block`,children:p.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>d(e.path),className:r(`min-h-11 w-full truncate rounded px-2 text-left text-xs`,l===e.path&&`bg-muted font-medium`),title:e.path,children:[e.status,` · `,e.path,` `,(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})},e.path))})]}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`mb-2 flex justify-end gap-1`,children:[(0,K.jsx)(n,{"aria-label":`Previous file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:m<=0,onClick:()=>d(p[m-1]?.path??null),children:(0,K.jsx)(et,{})}),(0,K.jsx)(n,{"aria-label":`Next file`,variant:`outline`,size:`icon`,className:`min-h-11 min-w-11`,disabled:m<0||m>=p.length-1,onClick:()=>d(p[m+1]?.path??null),children:(0,K.jsx)(I,{size:16})})]}),p.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No changed files match this filter.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(tt,{files:g.filter(e=>e.path===l),wrap:!0,className:`min-w-0`}),y&&!y.patch?(0,K.jsxs)(`p`,{className:`rounded-b border border-border p-3 text-xs text-muted-foreground`,children:[`Patch unavailable: `,y.patchUnavailableReason??`not-provided`,`.`]}):null]})]})]})]})}function Mt({item:e,colors:t}){let n=y(e.kind,e.number),r=n.data,i=(0,G.useMemo)(()=>{let e=[...(r?.comments??[]).map(e=>({row:`comment`,comment:e})),...(r?.events??[]).map(e=>({row:`event`,event:e}))],t=e=>{let t=Date.parse(Nt(e));return Number.isNaN(t)?-1/0:t};return e.sort((e,n)=>t(e)-t(n))},[r?.comments,r?.events]);return n.isPending?(0,K.jsxs)(`section`,{"data-slot":`gh-thread-loading`,className:`mt-6 border-t border-border pt-5`,children:[(0,K.jsx)(V,{className:`mb-3 h-3 w-24`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(V,{className:`h-14 w-full`}),(0,K.jsx)(V,{className:`h-14 w-full`})]})]}):!r||!r.available?(0,K.jsxs)(`section`,{"data-slot":`gh-thread-error`,className:`mt-6 border-t border-border pt-5 text-xs text-soft-foreground`,children:[(0,K.jsxs)(`span`,{children:[`Couldn’t load comments — `,r?.reason??(n.error instanceof Error?n.error.message:`could not load comments`),`. `]}),(0,K.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-0.5 text-muted-foreground hover:text-foreground hover:underline`,children:[`open on GitHub`,(0,K.jsx)(D,{"aria-hidden":`true`,className:`size-2.5`})]})]}):i.length===0?null:(0,K.jsxs)(`section`,{"data-slot":`gh-thread`,className:`mt-6 border-t border-border pt-5`,children:[(0,K.jsxs)(`h3`,{"data-slot":`gh-thread-header`,className:`mb-4 text-[11px] font-semibold tracking-wide text-soft-foreground uppercase`,children:[`Activity · `,r.comments.length,` comment`,r.comments.length===1?``:`s`]}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-5`,children:Pt(i).map(e=>e.group===`commits`?(0,K.jsx)(Ft,{commits:e.commits,colors:t},e.commits[0].id):e.entry.row===`comment`?(0,K.jsx)(Gt,{comment:e.entry.comment},`${e.entry.comment.kind}-${e.entry.comment.id}`):(0,K.jsx)(It,{event:e.entry.event,colors:t},e.entry.event.id))}),r.truncated?(0,K.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-thread-truncated`,className:`mt-4 inline-flex items-center gap-0.5 text-xs text-soft-foreground hover:text-foreground hover:underline`,children:[`thread truncated — open on GitHub`,(0,K.jsx)(D,{"aria-hidden":`true`,className:`size-2.5`})]}):null]})}var Nt=e=>e.row===`comment`?e.comment.createdAt:e.event.createdAt;function Pt(e){let t=[],n=[],r=()=>{n.length!==0&&(n.length===1?t.push({group:`single`,entry:{row:`event`,event:n[0]}}):t.push({group:`commits`,commits:n}),n=[])};for(let i of e){if(i.row===`event`&&i.event.kind===`committed`&&i.row===`event`){let e=n[n.length-1];e&&e.actor!==i.event.actor&&r(),n.push(i.event);continue}r(),t.push({group:`single`,entry:i})}return r(),t}function Ft({commits:e,colors:t}){let[n,r]=(0,G.useState)(!1),i=e[0]?.actor??`?`;return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`true`,className:`min-w-0`,children:(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":!0,onClick:()=>r(!1),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:X.committed}),(0,K.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,K.jsxs)(`span`,{children:[`added `,e.length,` commits`]})]})}),e.map(e=>(0,K.jsx)(It,{event:e,colors:t},e.id))]}):(0,K.jsx)(`li`,{"data-slot":`gh-commit-group`,"data-open":`false`,className:`min-w-0`,children:(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":!1,onClick:()=>r(!0),className:`flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground hover:text-foreground`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:X.committed}),(0,K.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:i}),(0,K.jsxs)(`span`,{children:[`added `,e.length,` commits`]}),(0,K.jsx)(`span`,{className:`shrink-0`,children:z(e[e.length-1].createdAt)})]})})}var X={committed:`⚙`,labeled:`◆`,unlabeled:`◇`,assigned:`◍`,unassigned:`◌`,merged:`⑃`,closed:`⊘`,reopened:`⊙`,head_ref_force_pushed:`↻`,"cross-referenced":`↗`,renamed:`✎`};function It({event:e,colors:t}){return(0,K.jsxs)(`li`,{"data-slot":`gh-event-row`,"data-kind":e.kind,className:r(`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,e.kind===`merged`&&`text-accent-foreground`),children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:X[e.kind]}),(0,K.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.actor}),(0,K.jsx)(Ht,{event:e,colors:t}),(0,K.jsx)(`span`,{className:`shrink-0`,children:z(e.createdAt)}),e.url?(0,K.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open ${e.kind} on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(D,{"aria-hidden":`true`,className:`size-2.5`})}):null]})}function Lt({event:e}){return(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`shrink-0`,children:`committed`}),e.sha?(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.sha.slice(0,7)}):null,e.message?(0,K.jsx)(`span`,{className:`truncate font-sans text-foreground`,children:e.message}):null,(0,K.jsx)(Ut,{checks:e.checks})]})}function Rt({event:e,colors:t}){return(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`shrink-0`,children:e.kind===`labeled`?`added the`:`removed the`}),e.label?(0,K.jsx)(`span`,{"data-slot":`gh-event-label`,style:Y(e.label.color??t[e.label.name]),className:`max-w-[12rem] truncate rounded-full border px-1.5 py-px font-sans text-[12px]`,children:e.label.name}):null,(0,K.jsx)(`span`,{className:`shrink-0`,children:`label`})]})}function zt({event:e}){return(0,K.jsxs)(`span`,{className:`truncate`,children:[e.kind===`assigned`?`assigned`:`unassigned`,` `,e.subject??`someone`]})}function Bt({event:e}){return(0,K.jsxs)(`span`,{className:`truncate`,children:[`referenced this in `,e.refNumber?`#${e.refNumber}`:`another thread`,e.refTitle?` ${e.refTitle}`:``]})}var Vt={committed:e=>(0,K.jsx)(Lt,{event:e}),labeled:(e,t)=>(0,K.jsx)(Rt,{event:e,colors:t}),unlabeled:(e,t)=>(0,K.jsx)(Rt,{event:e,colors:t}),assigned:e=>(0,K.jsx)(zt,{event:e}),unassigned:e=>(0,K.jsx)(zt,{event:e}),merged:()=>(0,K.jsx)(`span`,{children:`merged this`}),closed:()=>(0,K.jsx)(`span`,{children:`closed this`}),reopened:()=>(0,K.jsx)(`span`,{children:`reopened this`}),head_ref_force_pushed:()=>(0,K.jsx)(`span`,{children:`force-pushed`}),renamed:e=>(0,K.jsxs)(`span`,{className:`truncate`,children:[`renamed this to `,e.subject??`—`]}),"cross-referenced":e=>(0,K.jsx)(Bt,{event:e})};function Ht({event:e,colors:t}){return Vt[e.kind]?.(e,t)??null}function Ut({checks:e}){return e?(0,K.jsx)(`span`,{"data-slot":`gh-commit-checks`,"data-checks":e,"aria-label":`checks ${e}`,className:r(`shrink-0`,Q[e]),children:Z[e]}):null}var Wt={approved:{label:`approved`,tone:`border-success/40 text-success`},changes_requested:{label:`changes requested`,tone:`border-danger/40 text-danger`},commented:{label:`commented`,tone:`border-border text-muted-foreground`},dismissed:{label:`dismissed`,tone:`border-border text-muted-foreground`}};function Gt({comment:e}){let t=e.reviewState?Wt[e.reviewState]:null;return(0,K.jsxs)(`li`,{"data-slot":`gh-thread-entry`,"data-kind":e.kind,className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 font-mono text-[11px] text-soft-foreground`,children:[(0,K.jsx)(Kt,{url:e.avatarUrl,login:e.author}),(0,K.jsx)(`span`,{className:`font-sans font-medium text-foreground`,children:e.author}),(0,K.jsx)(`span`,{children:z(e.createdAt)}),t?(0,K.jsx)(`span`,{"data-slot":`gh-review-chip`,"data-review-state":e.reviewState,className:r(`rounded-full border px-1.5 py-px font-sans text-[12px] font-medium`,t.tone),children:t.label}):null,(0,K.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`open comment on GitHub`,className:`ml-auto shrink-0 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(D,{"aria-hidden":`true`,className:`size-2.5`})})]}),(0,K.jsx)(`div`,{"data-slot":`gh-thread-body`,className:`text-sm`,children:e.body?(0,K.jsx)(Ze,{children:e.body}):(0,K.jsx)(`p`,{className:`text-soft-foreground`,children:`(no body)`})})]})}function Kt({url:e,login:t}){let[n,r]=(0,G.useState)(!1);return e&&!n?(0,K.jsx)(`img`,{src:e,alt:``,width:16,height:16,loading:`lazy`,onError:()=>r(!0),"data-slot":`gh-avatar`,className:`size-4 shrink-0 rounded-full`}):(0,K.jsx)(`span`,{"data-slot":`gh-avatar-fallback`,"aria-hidden":`true`,className:`flex size-4 shrink-0 items-center justify-center rounded-full bg-muted text-[8px] font-semibold text-muted-foreground uppercase`,children:t.slice(0,1)||`?`})}var Z={passing:`✓`,failing:`✗`,pending:`○`},Q={passing:`text-success`,failing:`text-danger`,pending:`text-muted-foreground`};function qt({count:e}){return e?(0,K.jsxs)(`span`,{"data-slot":`gh-comment-count`,"data-count":e,"aria-label":`${e} comment${e===1?``:`s`}`,className:`inline-flex shrink-0 items-center gap-0.5`,children:[(0,K.jsx)(ue,{"aria-hidden":`true`,className:`size-3`}),e]}):null}function Jt({checks:e,url:t}){let n=r(`text-[11px] font-medium`,Q[e],t&&`hover:underline`),i=`${Z[e]} checks ${e}`;return t?(0,K.jsx)(`a`,{href:`${t}/checks`,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`gh-checks`,"data-checks":e,className:n,children:i}):(0,K.jsx)(`span`,{"data-slot":`gh-checks`,"data-checks":e,className:n,children:i})}function Yt({checks:e}){return(0,K.jsx)(`span`,{"data-slot":`gh-row-checks`,"data-checks":e,title:`checks ${e}`,"aria-label":`checks ${e}`,className:r(`shrink-0 font-sans text-[11px] font-semibold`,Q[e]),children:Z[e]})}function $(e){return`${e.kind===`pr`?`Address GitHub pull request`:`Fix GitHub issue`} #${e.number}: ${e.title}\n\n${e.url}`}function Xt(e,t=[]){let n=$(e);return e.body?.trim()&&(n+=`\n\n---\n\n${e.body.trim()}`),t.length&&(n+=Zt(t)),n}function Zt(e){return`\n\nUse these skills where relevant: ${e.join(`, `)}.`}function Qt(e,t){return e.replace(/\{\{\s*number\s*\}\}/gi,()=>`#${t.number}`).replace(/\{\{\s*title\s*\}\}/gi,()=>t.title).replace(/\{\{\s*url\s*\}\}/gi,()=>t.url)}function $t(e,t){if(e.includes(t.url))return!0;let n=t.kind===`pr`?String.raw`(?:pull\s+request|pr)`:String.raw`issue`;return new RegExp(String.raw`\b${n}\s*#?\s*${t.number}\b`,`i`).test(e)}function en(e,t,n){let r=(n??``).trim();if(!r)return Xt(e,t);let i=$(e),a=r.startsWith(i)?i+Qt(r.slice(i.length),e):Qt(r,e),o=$t(a,e)?a:`${i}\n\n${a}`;return t.length?o+Zt(t):o}function tn(e){let t=[];for(let n of e.slice(0,8)){let e=new Set(t.map(e=>e.id)),r=n;for(let t=2;e.has(r);t++)r=`${n}-${t}`;t.push({id:r,name:n,skill:n,prompt:`{{task}}`})}return t}function nn(e,t,n,r,i={}){return t?{...i,workflow:t,task:en(e,n,r)}:n.length?{...i,steps:tn(n),task:en(e,[],r)}:{...i,workflow:`quick-task`,task:en(e,[],r)}}function rn(e){let t=m(),n=S(),r=c(t.data),i=n.data?.defaultRunner,a=be(e.runner,r,i??r[0]??`claude`),o=T(a),s=n.data?.modelsLocked===!0,{accounts:l,repoAccount:u}=Fe(),d=l.some(t=>t.provider===a&&t.id===e.account)?e.account:null,f=De(s?null:e.model,a,n.data?.defaultModels,o.data),p=ke(a,f,o.data);return{runner:a,runnerExplicit:e.runner!==null,model:f,effort:s?``:Be(e.effort,p),effortOptions:p,runners:r,defaultRunner:i,canRun:t.isSuccess&&r.length>0,modelsLocked:s,providerPending:t.isPending,providerError:t.isError,accounts:l,account:d,repoAccount:u}}function an(e){return{runner:Ce(e.runner,e.defaultRunner,e.runnerExplicit),model:e.modelsLocked?void 0:e.model||void 0,effort:e.modelsLocked?void 0:e.effort||void 0}}function on(e){return{...an(e),...e.account?{agentProfile:e.account}:{}}}function sn({pick:e,onChange:t,disabled:n=!1,accounts:r=!1,layout:i}){let a=(0,G.useRef)(null),o=(0,G.useRef)(null),[s,c]=(0,G.useState)(()=>typeof window<`u`&&window.innerWidth<=767);(0,G.useLayoutEffect)(()=>{let e=a.current;if(i!==`row`||!e)return;let t=()=>{let t=window.innerWidth<=767||e.getBoundingClientRect().width<550,n=document.activeElement;o.current=n instanceof HTMLElement&&e.contains(n)?n:null,c(t)};t();let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return n?.observe(e),window.addEventListener(`resize`,t),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[i]),(0,G.useLayoutEffect)(()=>{let e=o.current;o.current=null,e&&e.isConnected&&document.activeElement!==e&&e.focus()},[s]);let l=rn(e),{runner:u,model:d,effort:f,effortOptions:p,runners:m,canRun:h,modelsLocked:g}=l,_=S(),v=T(u),y=Ee(u,v.data,[e.model,_.data?.defaultModels?.[u]]),b=n||!h,x=r?l.accounts:[],C=m.length>1||m.some(e=>Re(x,e))?(0,K.jsx)(Oe,{icon:(0,K.jsx)(re,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:m,value:u,accounts:x,account:r?l.account:null,repoAccount:r?l.repoAccount:void 0,disabled:b,onPick:(n,i)=>t(r?{runner:n,account:i,model:n===u?e.model:null,effort:e.effort}:{runner:n,account:null,model:null,effort:e.effort})},`runner`):null,w=(0,K.jsx)(W,{icon:(0,K.jsx)(P,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:d===``?`Default`:y.find(e=>e.id===d).label,value:d,disabled:b,readOnly:g===!0,disabledHint:g?`Model selection is locked to native coding-agent settings.`:void 0,onPick:n=>{let r=ke(u,n,v.data);t({...e,model:n,effort:e.effort===null?null:Be(e.effort,r)})},options:y.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Ve(u,v.data,v.isError,v.isFetching)},`model`),E=(0,K.jsx)(W,{icon:(0,K.jsx)(M,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:p.find(e=>e.value===f)?.label??`auto`,value:f,disabled:b,readOnly:g===!0,disabledHint:g?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:n=>t({...e,effort:n}),options:p.map(e=>({value:e.value,label:e.label,desc:e.desc}))},`effort`);return i===`row`?(0,K.jsx)(`div`,{ref:a,"data-slot":`engine-row-box`,children:(0,K.jsx)(`div`,{"data-slot":`engine-row`,className:`engine-row`,role:`group`,"aria-label":`Agent settings`,children:(0,K.jsx)(Me,{children:s?[C,E,w]:[C,w,E]})})}):(0,K.jsxs)(Me,{children:[C,w,E]})}var cn={workflow:null,skills:[]},ln=`cez-followup-selection`;function un(e){let t=e&&typeof e==`object`?e:{};return{workflow:typeof t.workflow==`string`?t.workflow:null,skills:Array.isArray(t.skills)?t.skills.filter(e=>typeof e==`string`):[]}}function dn(){try{let e=localStorage.getItem(ln);return e?un(JSON.parse(e)):{...cn}}catch{return{...cn}}}function fn(e){try{localStorage.setItem(ln,JSON.stringify(e))}catch{}}var pn=`cez-followup-prompt:`;function mn(e){try{return localStorage.getItem(pn+e)??``}catch{return``}}function hn(e,t){try{t===``?localStorage.removeItem(pn+e):localStorage.setItem(pn+e,t)}catch{}}function gn({item:e,workflows:r,skills:i,workflow:a,onWorkflowChange:c,selectedSkills:u,onSkillsChange:d,engine:f,onEngineChange:p,queuedRunId:m,onQueued:h}){let g=s(),_=v(),y=b().data?.capabilities.automations===!0,S=e.kind===`pr`?`PR`:`issue`,w=u.filter(e=>i.some(t=>t.name===e)),[T]=(0,G.useState)(()=>$(e)),[E,D]=(0,G.useState)(()=>mn(e.url)||T),O=rn(f),k=(0,G.useRef)(null),A=(0,G.useRef)(null);(0,G.useEffect)(()=>{hn(e.url,E===T?``:E)},[e.url,E,T]);let M=(0,G.useMemo)(()=>je(Ae(_.data?.promptTemplates),{automations:y}),[_.data?.promptTemplates,y]),ee=e=>{let t=k.current,n=Pe({prompt:E,base:T,selectionStart:t?.selectionStart??null,focused:document.activeElement===t,remembered:A.current}),r=ze(E,n,e);D(r.text),A.current=r.caret,requestAnimationFrame(()=>{k.current?.focus(),k.current?.setSelectionRange(r.caret,r.caret)})},N=Ne(M,w),P=(0,G.useRef)(E);P.current=E;let F=(0,G.useRef)(``);(0,G.useEffect)(()=>{let e=Ie(P.current,F.current,N,T);F.current=e.applied,e.text!==P.current&&D(e.text)},[N,T]);let I=x({mutationFn:async()=>O.canRun?o(nn(e,a,w,E,on(O))):null,onSuccess:t=>{if(t===null)return;let n=t;n&&h(e.url,n.id),j(`Added to the queue — ${S} #${e.number}`),w.length>0&&_.data!==void 0&&l({skillUsage:w.reduce((e,t)=>qe(e,t),_.data.skillUsage)}).then(()=>g.invalidateQueries({queryKey:C.uiState})).catch(()=>{}),hn(e.url,``),D(T),F.current=``,g.invalidateQueries({queryKey:C.runs.all})},onError:e=>j(e.message,{tone:`danger`})}),te=e=>{$e({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),!I.isPending&&O.canRun&&I.mutate())},L=e=>d(u.includes(e)?u.filter(t=>t!==e):[...u,e]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`section`,{"data-slot":`gh-hand`,className:`mt-7 rounded-lg border border-border bg-card p-4`,children:[(0,K.jsx)(`h3`,{className:`text-xl font-normal text-foreground`,children:`Hand this to the agent`}),(0,K.jsxs)(`label`,{className:`gh-field gh-prompt-field`,children:[(0,K.jsx)(`span`,{children:`Instructions for the agent`}),(0,K.jsx)(Ye,{ref:k,"data-slot":`gh-custom-prompt`,"aria-label":`Custom prompt`,"aria-keyshortcuts":`Control+Enter Meta+Enter`,value:E,onChange:e=>D(e.target.value),onSelect:e=>{A.current=e.currentTarget.selectionStart},onKeyDown:te,placeholder:`Instructions for the agent… (#${e.number} and its link are always sent)`,className:`mt-3 min-h-20 text-[13px]`})]}),(0,K.jsx)(ve,{templates:M,onInsert:ee}),(0,K.jsxs)(`div`,{className:`gh-handoff-settings`,children:[(0,K.jsxs)(`div`,{className:`gh-field`,children:[(0,K.jsx)(`span`,{children:`Workflow`}),(0,K.jsx)(_n,{workflows:r,value:a,onChange:c})]}),(0,K.jsxs)(`div`,{className:`gh-field`,children:[(0,K.jsx)(`span`,{children:`Skills · select one or more`}),(0,K.jsx)(yn,{skills:i,skillUsage:_.data?.skillUsage,selected:w,onToggle:L})]}),w.length>0?(0,K.jsx)(`div`,{"data-slot":`gh-skill-chips`,className:`mt-2.5 flex flex-wrap gap-1.5`,children:w.map(e=>(0,K.jsxs)(`button`,{type:`button`,"data-slot":`gh-skill-chip`,"data-skill":e,onClick:()=>L(e),title:`Remove this skill`,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium text-foreground transition-colors hover:bg-danger/10 hover:text-danger`,children:[e,(0,K.jsx)(ne,{size:16,"aria-hidden":`true`,className:`size-3`})]},e))}):null,(0,K.jsx)(sn,{layout:`row`,pick:f,onChange:p,disabled:I.isPending||!O.canRun,accounts:!0}),(0,K.jsxs)(`div`,{className:`gh-field`,children:[(0,K.jsx)(`span`,{children:`Account`}),(0,K.jsx)(vn,{resolved:O,disabled:I.isPending||!O.canRun,onPick:e=>p({...f,account:e})})]}),!O.providerPending&&!O.canRun?(0,K.jsxs)(`span`,{"data-slot":`gh-provider-gate`,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[O.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,K.jsx)(H,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null]}),(0,K.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:[e.kind===`pr`?`PR`:`Issue`,` number and link remain attached to the task. Edit the prompt before starting. Cmd/Ctrl+Enter submits; Enter adds a new line.`]})]}),(0,K.jsxs)(`div`,{"data-slot":`gh-handoff-actions`,className:`mt-[22px] flex flex-wrap items-center gap-2.5`,children:[t(e.url)?(0,K.jsx)(n,{asChild:!0,variant:`outline`,children:(0,K.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open in GitHub`})}):null,(0,K.jsxs)(n,{variant:`primary`,"data-action":`gh-run`,disabled:I.isPending||!O.canRun,onClick:()=>I.mutate(),children:[(0,K.jsx)(de,{"aria-hidden":`true`,className:`size-3.5`}),`Run agent on this `,S]}),(0,K.jsx)(`kbd`,{"aria-hidden":`true`,className:`rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-[11px] font-medium text-muted-foreground`,children:Qe()}),m?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{"data-slot":`gh-queued`,className:`flex items-center gap-1 text-xs font-medium text-success`,children:[(0,K.jsx)(R,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`queued`]}),(0,K.jsx)(H,{to:`/tasks/${m}`,"data-slot":`gh-view-run`,className:`text-xs font-semibold text-accent-text hover:underline`,children:`View task →`})]}):null]})]})}function _n({workflows:e,value:t,onChange:n}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(``),c=(0,G.useRef)(null),l=Ue(e,o);return(0,K.jsxs)(A,{open:i,onOpenChange:e=>{a(e),e||s(``)},children:[(0,K.jsx)(k,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"data-slot":`gh-workflow-trigger`,"aria-label":`Choose a workflow`,className:r(Le,t&&`border-foreground/60 font-mono text-[11px] font-semibold text-foreground`),children:[(0,K.jsx)(te,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),(0,K.jsx)(`span`,{className:`min-w-0 max-w-44 truncate`,children:t??`workflow`}),(0,K.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,K.jsx)(O,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,K.jsxs)(we,{shouldFilter:!1,children:[(0,K.jsx)(Te,{placeholder:`search workflows…`,value:o,onValueChange:s,onInput:()=>c.current?.scrollTo(0,0)}),(0,K.jsxs)(ye,{ref:c,"data-slot":`gh-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[l.length===0?(0,K.jsx)(xe,{children:`Nothing matches.`}):null,(0,K.jsx)(U,{children:l.map(e=>{let r=t===e.name;return(0,K.jsxs)(He,{value:`workflow ${e.name}`,keywords:We(e.name,e.description),"data-slot":`gh-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),a(!1)},children:[(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,r?(0,K.jsx)(R,{size:16,"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},e.name)})})]})]})})]})}function vn({resolved:e,disabled:t,onPick:n}){let r=e.accounts.filter(t=>t.provider===e.runner),i=[...r.some(e=>e.id==="default")?[]:[{value:Se,label:`Default`}],...r.map(e=>({value:e.id,label:e.label,desc:e.configDir}))],a=e.account??e.repoAccount?.[e.runner]??`default`;return(0,K.jsx)(W,{icon:(0,K.jsx)(se,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),slot:`account-pill`,ariaLabel:`Account`,label:i.find(e=>e.value===a)?.label??`Default`,value:a,options:i,disabled:t,onPick:n})}function yn({skills:e,skillUsage:t,selected:n,onToggle:i}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(null),d=(0,G.useRef)(null),{mostUsed:f,project:p,global:m,ranked:h}=Je(e,s,t),g=(e,t)=>{let a=n.includes(e.name);return(0,K.jsxs)(He,{value:`skill ${e.name} ${e.path}`,keywords:We(e.name,e.description),"data-slot":`gh-skill-option`,"data-skill":e.name,"data-selected":a?`true`:void 0,onSelect:()=>i(e.name),children:[(0,K.jsx)(`span`,{className:r(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null,(0,K.jsx)(`button`,{type:`button`,"data-slot":`gh-skill-view`,"aria-label":`View skill ${e.name}`,title:`View skill`,onClick:t=>{t.preventDefault(),t.stopPropagation(),u(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,K.jsx)(ce,{"aria-hidden":`true`,className:`size-3.5`})}),a?(0,K.jsx)(R,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.path)};return e.length===0?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Xe,{skill:l,onClose:()=>u(null)}),(0,K.jsxs)(A,{open:a,onOpenChange:e=>{o(e),e||c(``)},children:[(0,K.jsx)(k,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"data-slot":`gh-skills-trigger`,"aria-label":`Choose skills`,className:r(Le,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,K.jsx)(ae,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0 text-accent-icon`}),`skills`,n.length>0?` · ${n.length}`:``,(0,K.jsx)(oe,{size:16,"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,K.jsx)(O,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,K.jsxs)(we,{shouldFilter:!1,children:[(0,K.jsx)(Te,{placeholder:`search skills…`,value:s,onValueChange:c,onInput:()=>d.current?.scrollTo(0,0)}),(0,K.jsxs)(ye,{ref:d,"data-slot":`gh-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(h?h.length===0:f.length===0&&p.length===0&&m.length===0)?(0,K.jsx)(xe,{children:`Nothing matches.`}):null,h?h.length>0?(0,K.jsx)(U,{children:h.map(e=>g(e,Ge(e)))}):null:(0,K.jsxs)(K.Fragment,{children:[f.length>0?(0,K.jsx)(U,{heading:`Most used`,children:f.map(e=>g(e,Ge(e)))}):null,p.length>0?(0,K.jsx)(U,{heading:`Project skills`,children:p.map(e=>g(e,!0))}):null,m.length>0?(0,K.jsx)(U,{heading:`Global`,children:m.map(e=>g(e,!1))}):null]})]})]})})]})]})}var bn=new WeakMap;function xn(){let e=dn(),t={workflow:e.workflow,selectedSkills:e.skills,engine:{runner:null,model:null,effort:null,account:null},queued:new Map},n=new Set;return{snapshot:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)}),update:e=>{t={...t,...e},(e.workflow!==void 0||e.selectedSkills!==void 0)&&fn({workflow:t.workflow,skills:[...t.selectedSkills]}),n.forEach(e=>e())}}}function Sn(){let e=s(),{projectId:t}=d(),n=bn.get(e);n||bn.set(e,n=new Map);let r=n.get(t);r||n.set(t,r=xn());let{snapshot:i,subscribe:a,update:o}=r,c=(0,G.useSyncExternalStore)(a,i,i),l=g(),u=h(),f=v(),p=l.data?.workflows;(0,G.useEffect)(()=>{p&&c.workflow!==null&&!p.some(e=>e.name===c.workflow)&&o({workflow:null})},[o,p,c.workflow]);let m=(0,G.useMemo)(()=>Ke(u.data??[],f.data?.skillUsage),[u.data,f.data?.skillUsage]);return{...c,workflows:l,skillList:m,setWorkflow:e=>o({workflow:e}),setSelectedSkills:e=>o({selectedSkills:e}),setEngine:e=>o({engine:e}),onQueued:(e,t)=>o({queued:new Map(i().queued).set(e,t)})}}export{qt as a,Pt as c,Y as d,xt as f,Yt as i,yt as l,gn as n,At as o,Xt as r,St as s,Sn as t,bt as u};
@@ -1 +1 @@
1
- import{Gr as e,Kr as t,Mr as n,Ur as r}from"./project-scope-context-BwaC58sQ.js";var i=class extends r{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(n,r){let{state:i}=n,a=super.createResult(n,r),{isFetching:o,isRefetching:s,isError:c,isRefetchError:l}=a,u=i.fetchMeta?.fetchMore?.direction,d=c&&u===`forward`,f=o&&u===`forward`,p=c&&u===`backward`,m=o&&u===`backward`;return{...a,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:e(r,i.data),hasPreviousPage:t(r,i.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:s&&!f&&!m}}};function a(e,t){return n(e,i,t)}export{a as t};
1
+ import{Gr as e,Hr as t,Wr as n,jr as r}from"./project-scope-context-CSPQyWoO.js";var i=class extends t{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(t,r){let{state:i}=t,a=super.createResult(t,r),{isFetching:o,isRefetching:s,isError:c,isRefetchError:l}=a,u=i.fetchMeta?.fetchMore?.direction,d=c&&u===`forward`,f=o&&u===`forward`,p=c&&u===`backward`,m=o&&u===`backward`;return{...a,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:n(r,i.data),hasPreviousPage:e(r,i.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:s&&!f&&!m}}};function a(e,t){return r(e,i,t)}export{a as t};
@@ -0,0 +1 @@
1
+ import{Hr as e,jr as t}from"./project-scope-context-CSPQyWoO.js";function n(n,r){return t(n,e,r)}export{n as t};
@@ -1,7 +1,7 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,t as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{A as o,Hr as s,Kt as c,T as l,Yt as u,i as d}from"./project-scope-context-BwaC58sQ.js";import{At as f,Lt as ee,Nt as te,Qt as p,n as ne}from"./queries-jqgF_s0L.js";import{n as m}from"./toaster-CoMJoQvk.js";import{C as h,Q as g,S as re,X as _,a as ie,ct as ae,dt as v,l as oe,lt as y,mt as b,n as x,rt as se,st as S,u as ce,x as C,y as w}from"./design-icons-DmYTv2r1.js";import{i as T,p as le,r as E,t as D}from"./dropdown-menu-DPrTX-zi.js";import{a as O,c as k,i as A,n as j,o as M,r as ue,s as N,t as P}from"./alert-dialog-CH4SXGfX.js";import{i as F,o as de,r as I,s as L,t as R}from"./dialog-B7p5oc5r.js";import{_ as fe,a as z,d as pe,g as me,h as B,i as V,l as he,m as ge,o as _e,p as ve,r as ye,s as be,t as H,v as U}from"./sortable.esm-zp_qkYGV.js";import{i as W,l as xe,s as Se}from"./skills-DFBiAuJG.js";import{t as Ce}from"./centered-state-B5QmAy2y.js";import{$ as G,O as we,Zt as K}from"./index-BXr2mRSZ.js";import{n as Te}from"./skill-empty-hint-YDmkqgo-.js";var q=e(i(),1);function J(e){let t=[];for(let n of e){if(n.command||!n.skill||n.prompt!==void 0&&n.prompt!==`{{task}}`||n.name!==void 0&&n.name!==n.skill||n.timeoutMs!==void 0||n.model||n.effort!==void 0||n.runner||n.agentProfile||n.allowedTools||n.bashAllowlist||n.onFail)return null;t.push(n.skill)}return t.length?t:null}function Ee(e,t){let n=new Set(t.map(e=>e.id)),r=e;for(let t=2;n.has(r);t++)r=`${e}-${t}`;return{id:r,name:e,skill:e,prompt:`{{task}}`}}function De(e,t,n){let r=[...e];return r.splice(Math.max(0,Math.min(n,r.length)),0,t),r}function Oe(e,t,n){if(t===n||t<0||t>=e.length||n<0||n>=e.length)return[...e];let r=[...e],[i]=r.splice(t,1);return i===void 0?[...e]:(r.splice(n,0,i),r)}function ke(e,t){return e.filter((e,n)=>n!==t)}function Y(e){let t=String(e),n=/^[A-Za-z0-9._][A-Za-z0-9 ._/-]*$/.test(t)&&!t.endsWith(` `),r=/^(true|false|yes|no|on|off|null|~)$/i.test(t)||/^[-+.]?\d/.test(t);return n&&!r?t:JSON.stringify(t)}function X(e,t,n){let r=` `.repeat(n);return t.includes(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{E as t,t as n,u as r}from"./button-DGwhwRuD.js";import{i,t as a}from"./react-runtime-CCIEwYL0.js";import{A as o,Kt as s,T as c,Vr as l,Yt as u,i as d}from"./project-scope-context-CSPQyWoO.js";import{At as f,Lt as ee,Nt as te,Qt as p,n as ne}from"./queries-pj368bmB.js";import{n as m}from"./toaster-CoMJoQvk.js";import{C as h,Q as g,S as re,X as _,a as ie,ct as ae,dt as v,l as oe,lt as y,mt as b,n as x,rt as se,st as S,u as ce,x as C,y as w}from"./design-icons-DmYTv2r1.js";import{i as T,p as le,r as E,t as D}from"./dropdown-menu-DPrTX-zi.js";import{a as O,c as k,i as A,n as j,o as M,r as ue,s as N,t as P}from"./alert-dialog-CH4SXGfX.js";import{i as F,o as de,r as I,s as L,t as R}from"./dialog-B7p5oc5r.js";import{_ as fe,a as z,d as pe,g as me,h as B,i as V,l as he,m as ge,o as _e,p as ve,r as ye,s as be,t as H,v as U}from"./sortable.esm-zp_qkYGV.js";import{i as W,l as xe,s as Se}from"./skills-DFBiAuJG.js";import{t as Ce}from"./centered-state-B5QmAy2y.js";import{$ as G,O as we,Zt as K}from"./index-CsOa03VW.js";import{n as Te}from"./skill-empty-hint-YDmkqgo-.js";var q=e(i(),1);function J(e){let t=[];for(let n of e){if(n.command||!n.skill||n.prompt!==void 0&&n.prompt!==`{{task}}`||n.name!==void 0&&n.name!==n.skill||n.timeoutMs!==void 0||n.model||n.effort!==void 0||n.runner||n.agentProfile||n.allowedTools||n.bashAllowlist||n.onFail)return null;t.push(n.skill)}return t.length?t:null}function Ee(e,t){let n=new Set(t.map(e=>e.id)),r=e;for(let t=2;n.has(r);t++)r=`${e}-${t}`;return{id:r,name:e,skill:e,prompt:`{{task}}`}}function De(e,t,n){let r=[...e];return r.splice(Math.max(0,Math.min(n,r.length)),0,t),r}function Oe(e,t,n){if(t===n||t<0||t>=e.length||n<0||n>=e.length)return[...e];let r=[...e],[i]=r.splice(t,1);return i===void 0?[...e]:(r.splice(n,0,i),r)}function ke(e,t){return e.filter((e,n)=>n!==t)}function Y(e){let t=String(e),n=/^[A-Za-z0-9._][A-Za-z0-9 ._/-]*$/.test(t)&&!t.endsWith(` `),r=/^(true|false|yes|no|on|off|null|~)$/i.test(t)||/^[-+.]?\d/.test(t);return n&&!r?t:JSON.stringify(t)}function X(e,t,n){let r=` `.repeat(n);return t.includes(`
2
2
  `)?[`${r}${e}: |`,...t.split(`
3
3
  `).map(e=>`${r} ${e}`)]:[`${r}${e}: ${Y(t)}`]}function Ae(e){let t=[];return e.name&&e.name!==e.id&&t.push(` name: ${Y(e.name)}`),e.skill&&t.push(` skill: ${Y(e.skill)}`),t}function Z(e){let t=[];return e.model&&t.push(` model: ${Y(e.model)}`),e.timeoutMs!==void 0&&t.push(` timeoutMs: ${e.timeoutMs}`),e.effort!==void 0&&t.push(` effort: ${Y(e.effort)}`),e.runner&&t.push(` runner: ${Y(e.runner)}`),e.agentProfile&&t.push(` agentProfile: ${Y(e.agentProfile)}`),t}function je(e){let t=[];return e.allowedTools&&t.push(` allowedTools: [${e.allowedTools.map(Y).join(`, `)}]`),e.bashAllowlist&&t.push(` bashAllowlist: [${e.bashAllowlist.map(Y).join(`, `)}]`),t}function Me(e){return e.onFail?[` onFail:`,` retry: ${Y(e.onFail.retry)}`,` max: ${e.onFail.max??2}`]:[]}function Ne(e){return[` - id: ${Y(e.id)}`,...Ae(e),...e.prompt?X(`prompt`,e.prompt,4):[],...Z(e),...je(e),...e.command?X(`command`,e.command,4):[],...Me(e)]}function Pe(e,t,n){let r=[`name: ${Y(e.trim()||`my-workflow`)}`];t.trim()&&r.push(...X(`description`,t.trim(),0));let i=J(n);if(i){r.push(`skills:`);for(let e of i)r.push(` - ${Y(e)}`)}else if(n.length){r.push(`steps:`);for(let e of n)r.push(...Ne(e))}else r.push(`skills: []`);return`${r.join(`
4
4
  `)}\n`}function Fe(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`workflow`}function Ie(e){let t=J(e)?`skill`:`step`;return`${e.length} ${t}${e.length===1?``:`s`}`}function Le(e,t){let n=new Set,r=[];for(let t of e.steps.slice(0,8)){let e=t.id||`step`,i=e;for(let t=2;n.has(i);t++)i=`${e}-${t}`;n.add(i),r.push({...t,id:i})}return{name:e.name?.trim()||t,steps:r}}function Re(e,t,n){let r=J(n);return{name:e.trim(),...t.trim()?{description:t.trim()}:{},...r?{skills:r}:{steps:[...n]}}}var Q=a();function ze({workflows:e,draft:t,trimmedName:n,nameRef:r,onDraft:i,onLoadWorkflow:a}){return(0,Q.jsxs)(`section`,{"data-slot":`wb-metadata`,className:`flex min-w-0 flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{"data-slot":`wb-load`,className:`flex flex-col items-start gap-2`,children:[(0,Q.jsx)(`label`,{htmlFor:`workflow-load`,className:`text-xs text-muted-foreground`,children:`Load an existing workflow`}),(0,Q.jsxs)(`div`,{className:`relative max-w-full`,children:[(0,Q.jsx)(ce,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,Q.jsxs)(`select`,{id:`workflow-load`,value:e.some(e=>e.name===n)?n:``,onChange:t=>{let n=e.find(e=>e.name===t.target.value);n&&a(n)},className:`h-11 max-w-full rounded-lg border border-border bg-card pl-9 pr-3 text-xs font-medium appearance-none focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(`option`,{value:``,disabled:!0,children:`Choose a workflow`}),e.map(e=>(0,Q.jsx)(`option`,{value:e.name,"data-slot":`wb-load-option`,"data-name":e.name,children:e.name},e.name))]})]})]}),(0,Q.jsx)(`label`,{htmlFor:`workflow-name`,className:`text-xs font-semibold`,children:`Workflow name`}),(0,Q.jsx)(K,{id:`workflow-name`,ref:r,"data-slot":`wb-name`,"aria-label":`Workflow name`,spellCheck:!1,value:t.name,onChange:e=>i({...t,name:e.target.value}),className:`h-12 bg-card text-sm`}),(0,Q.jsx)(`label`,{htmlFor:`workflow-description`,className:`text-xs font-semibold`,children:`Description`}),(0,Q.jsx)(G,{id:`workflow-description`,"data-slot":`wb-description`,"aria-label":`Description`,value:t.description,onChange:e=>i({...t,description:e.target.value}),className:`min-h-[72px] bg-card p-3.5 text-sm`})]})}function Be({savedFile:e,autoOpen:t,onImportToggle:r,onExport:i,onAutoToggle:a,onDeleteRequest:o}){return(0,Q.jsxs)(`div`,{"data-slot":`wb-actions`,className:`grid grid-cols-[max-content_max-content] items-center justify-start gap-2 sm:flex sm:flex-wrap [&_button]:min-h-11 [&_button]:border [&_button]:border-border [&_button]:bg-card`,children:[(0,Q.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-import`,className:`col-span-2 justify-self-start`,onClick:r,children:[(0,Q.jsx)(y,{"aria-hidden":`true`,className:`size-3`}),`Import`]}),(0,Q.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-export`,className:`col-span-2 justify-self-start`,title:`Download workflow.yaml`,onClick:i,children:[(0,Q.jsx)(C,{"aria-hidden":`true`,className:`size-3`}),`Export`]}),(0,Q.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-auto`,"aria-expanded":t,title:`Describe a chain — the agent builds it`,onClick:a,children:[(0,Q.jsx)(v,{"aria-hidden":`true`,className:`size-3`}),`Auto`]}),e?(0,Q.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-delete`,className:`text-danger hover:text-danger`,title:`Delete the saved workflow file`,onClick:o,children:[(0,Q.jsx)(S,{"aria-hidden":`true`,className:`size-3`}),`Delete`]}):null]})}function Ve({text:e,onTextChange:t,pending:r,onRun:i,onCancel:a}){return(0,Q.jsxs)(`div`,{"data-slot":`wb-auto-panel`,className:`rounded-xl border border-border bg-card p-5 [&_button]:min-h-11`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-normal`,children:`Build a chain from a prompt`}),(0,Q.jsx)(`p`,{className:`mt-4 text-[13px] leading-relaxed text-muted-foreground`,children:`Describe the outcome. An agent proposes a title and ordered skill/check steps. Review the result, edit it, then Save.`}),(0,Q.jsx)(G,{"data-slot":`wb-auto-text`,"aria-label":`Describe the chain to build`,rows:3,autoFocus:!0,placeholder:`e.g. Fix the bug, run the tests, then review the diff for regressions.`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),i())},className:`mt-4 min-h-[108px] bg-background p-4 text-sm`}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,Q.jsxs)(n,{type:`button`,variant:`primary`,size:`sm`,"data-slot":`wb-auto-run`,disabled:r||e.trim()===``,onClick:i,children:[(0,Q.jsx)(v,{"aria-hidden":`true`,className:`size-3`}),r?`Building…`:`Build chain`]}),(0,Q.jsxs)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-auto-cancel`,onClick:a,children:[(0,Q.jsx)(b,{"aria-hidden":`true`,className:`size-4`}),`Cancel`]})]}),(0,Q.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`Creates an editable draft. Review the generated name and steps before saving.`})]})}function He({open:e,onOpenChange:t,text:r,onTextChange:i,error:a,pending:o,onRun:s,onCancel:c}){return(0,Q.jsx)(R,{open:e,onOpenChange:t,children:(0,Q.jsxs)(I,{showCloseButton:!1,"data-slot":`wb-import-panel`,className:`max-md:translate-x-0 max-md:translate-y-0 sm:max-w-[660px] rounded-xl border border-border bg-card p-5 [&_button]:min-h-11`,children:[(0,Q.jsx)(L,{className:`text-xl font-normal`,children:`Import workflow YAML`}),(0,Q.jsx)(F,{className:`sr-only`,children:`Paste a portable workflow definition to import.`}),(0,Q.jsx)(G,{"data-slot":`wb-import-text`,"aria-label":`Workflow YAML to import`,rows:4,spellCheck:!1,placeholder:`name: my-flow
5
5
  skills:
6
6
  - test-conventions
7
- - commit-style`,value:r,onChange:e=>i(e.target.value),className:`mt-4 min-h-[124px] bg-background p-4 font-mono text-[13px] leading-relaxed`}),(0,Q.jsx)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:`Paste a portable workflow definition. Imported steps appear in execution order.`}),a===``?null:(0,Q.jsx)(`p`,{"data-slot":`wb-import-error`,role:`alert`,className:`mt-2 text-xs text-danger`,children:a}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,Q.jsx)(n,{type:`button`,variant:`primary`,size:`sm`,"data-slot":`wb-import-run`,disabled:o,onClick:s,children:`Import`}),(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-import-cancel`,onClick:c,children:`Cancel`})]})]})})}function Ue({paletteSkills:e,query:t,onQueryChange:n,error:r,inFlow:i,onAdd:a,yaml:o}){return(0,Q.jsxs)(`aside`,{"data-slot":`wb-aside`,className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:`Available skills`}),(0,Q.jsxs)(`div`,{className:`sw-search relative mt-4`,children:[(0,Q.jsx)(g,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,Q.jsx)(K,{"data-slot":`wb-filter`,placeholder:`Find a skill…`,"aria-label":`Filter skills`,value:t,onChange:e=>n(e.target.value),className:`h-11 pl-9 text-xs`})]}),(0,Q.jsx)(rt,{skills:e,query:t,error:r,inFlow:i,onAdd:a}),(0,Q.jsx)(`h3`,{className:`mt-5 text-sm font-semibold`,children:`workflow.yaml`}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-muted-foreground`,children:`Export the workflow to use this chain in another project.`}),(0,Q.jsxs)(`details`,{className:`mt-4 min-w-0`,children:[(0,Q.jsxs)(`summary`,{"data-slot":`wb-yaml-toggle`,className:`inline-flex min-h-[44px] cursor-pointer items-center rounded-lg border border-border px-3 text-xs font-medium focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(h,{"aria-hidden":`true`,className:`mr-2 size-4`}),`View YAML`]}),(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsx)(at,{yaml:o})}),(0,Q.jsx)(`pre`,{"data-slot":`wb-yaml`,className:`mt-2 max-h-96 overflow-auto rounded-lg border border-border bg-background p-3 font-mono text-[11px] leading-relaxed whitespace-pre text-muted-foreground`,children:o})]})]})}function We({dragging:e,steps:t,skills:n}){return e?.type===`palette`?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-1.5 font-mono text-[13px] font-medium shadow-md`,children:[(0,Q.jsx)(se,{"aria-hidden":`true`,className:`size-3.5 text-link-foreground`}),e.skill]}):e?.type===`step`?(0,Q.jsx)(nt,{step:e.step,index:t.findIndex(t=>t.id===e.step.id),skills:n,overlay:!0}):null}function Ge({open:e,onOpenChange:t,query:r,onQueryChange:i,matches:a,skillsCount:o,error:s,selectedSkill:c,onSelectSkill:l,stepsCount:u,onCloseAutoFocus:d,onCancel:f,onAdd:ee}){return(0,Q.jsx)(R,{open:e,onOpenChange:t,children:(0,Q.jsxs)(I,{"data-slot":`wb-add-dialog`,onCloseAutoFocus:d,className:`max-h-[85dvh] overflow-y-auto sm:max-w-[660px] [&_button]:min-h-11`,children:[(0,Q.jsxs)(de,{children:[(0,Q.jsx)(L,{className:`text-xl font-normal`,children:`Add step`}),(0,Q.jsx)(F,{className:`sr-only`,children:`Choose a skill to append to this workflow.`})]}),(0,Q.jsx)(K,{"aria-label":`Filter skills`,placeholder:`Filter skills…`,value:r,onChange:e=>i(e.target.value)}),s===null?(0,Q.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Available skills`,className:`grid max-h-80 gap-2 overflow-y-auto`,children:[a.map(e=>(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg py-2 has-[:checked]:bg-accent-strong/10 has-[:focus-visible]:outline-2`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`workflow-add-skill`,className:`sr-only`,value:e.name,checked:c===e.name,onChange:()=>l(e.name)}),(0,Q.jsxs)(`span`,{className:`min-w-0 break-words text-sm`,children:[(0,Q.jsx)(`span`,{className:`block`,children:e.name}),(0,Q.jsx)(`span`,{className:`mt-2 block text-xs text-muted-foreground`,children:e.description})]})]},e.name)),a.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o===0?`No skills available in this project.`:`No matching skills.`}):null]}):(0,Q.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not load skills: `,s]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsx)(n,{variant:`outline`,onClick:f,children:`Cancel`}),(0,Q.jsx)(n,{variant:`primary`,disabled:!c||u>=8,onClick:()=>{c&&ee(c)},children:`Add selected skill`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Append the selected skill, then reorder it in the existing canvas.`}),u>=8?(0,Q.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`A workflow can contain up to `,8,` steps. Remove a step before adding another.`]}):null]})})}function Ke({trimmedName:e,savedFile:t,overwriteOpen:n,onOverwriteDismiss:r,deleteOpen:i,onDeleteDismiss:a,onOverwrite:o,onDelete:s}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{open:n,onOpenChange:e=>!e&&r(),children:(0,Q.jsxs)(A,{"data-slot":`wb-overwrite-dialog`,className:`sw-workflow-confirm sm:max-w-[660px]`,children:[(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(k,{children:[`“`,e,`” already exists`]}),(0,Q.jsx)(O,{children:`Saving overwrites the existing workflow file. There is no undo.`})]}),(0,Q.jsxs)(M,{children:[(0,Q.jsx)(ue,{children:`Keep the file`}),(0,Q.jsx)(j,{"data-slot":`wb-overwrite-confirm`,className:`bg-danger text-danger-foreground`,onClick:o,children:`Overwrite`})]})]})}),(0,Q.jsx)(P,{open:i,onOpenChange:e=>!e&&a(),children:(0,Q.jsxs)(A,{"data-slot":`wb-delete-dialog`,className:`sw-workflow-confirm sm:max-w-[660px]`,children:[(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(k,{children:[`Delete workflow “`,e,`”?`]}),(0,Q.jsxs)(O,{children:[`Removes `,t?.path?.split(`/`).pop()??`the saved file`,` from`,` `,(0,Q.jsx)(`span`,{className:`font-mono`,children:`.ai/cezar/workflows/`}),`. There is no undo.`]})]}),(0,Q.jsxs)(M,{children:[(0,Q.jsx)(ue,{children:`Keep the file`}),(0,Q.jsx)(j,{"data-slot":`wb-delete-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:s,children:`Delete workflow`})]})]})})]})}function qe(e){return e.name??e.skill??e.id}function Je(e){return e.prompt?.trim()===`{{task}}`?void 0:e.prompt?.trim()}function Ye(e){let t=e.onFail?` — on fail retry from "${e.onFail.retry}" (×${e.onFail.max??2})`:``;return`$ ${e.command}${t}`}function Xe(e,t){return Je(e)||t?.description||`Not in this repo or the team skills — the step runs on its plain prompt.`}function Ze(e,t){return e.command?Ye(e):e.skill?Xe(e,t):e.prompt??``}function Qe(e,t){return e.skill&&!t?`unknown`:null}function $e(e){return e.command?`Command step${e.onFail?` · Retry ×${e.onFail.max??2}`:``}`:e.skill?`Skill step`:`Prompt step`}function et({index:e,title:t,badge:i,onRemove:a,gripProps:o}){return(0,Q.jsxs)(`div`,{"data-slot":`wb-step-heading`,className:`flex min-w-0 items-center gap-2.5`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-slot":`wb-step-grip`,"aria-label":`Reorder step ${e+1}: ${t}`,className:`inline-flex size-[26px] shrink-0 cursor-grab items-center justify-center rounded-md text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,...o,children:(0,Q.jsx)(`span`,{className:`rounded bg-accent-strong/10 px-2 py-1 font-mono text-[12px] text-link-foreground`,children:String(e+1).padStart(2,`0`)})}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1 break-words text-sm font-medium [overflow-wrap:anywhere]`,children:t}),i?(0,Q.jsx)(`span`,{"data-slot":`wb-step-badge`,className:r(`shrink-0 rounded-full border px-2 py-px font-mono text-[11px]`,i===`unknown`&&`border-danger/35 text-danger`),children:i}):null,a?(0,Q.jsxs)(D,{children:[(0,Q.jsx)(le,{asChild:!0,children:(0,Q.jsx)(n,{"data-slot":`wb-step-actions`,variant:`ghost`,size:`icon`,className:`size-[26px]`,"aria-label":`Step ${e+1} actions: ${t}`,children:(0,Q.jsx)(re,{"aria-hidden":`true`,className:`size-4`})})}),(0,Q.jsx)(E,{align:`end`,children:(0,Q.jsxs)(T,{"data-slot":`wb-step-remove`,"aria-label":`Remove step ${e+1}: ${t}`,onSelect:a,children:[(0,Q.jsx)(S,{"aria-hidden":`true`}),` Remove step`]})})]}):null]})}function tt({index:e,onMoveUp:t,onMoveDown:r}){return(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 @min-[900px]:hidden`,children:[(0,Q.jsxs)(n,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":`Move step ${e+1} up`,disabled:!t,onClick:t,children:[(0,Q.jsx)(ie,{"aria-hidden":`true`,className:`size-4`}),`Move up`]}),(0,Q.jsxs)(n,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":`Move step ${e+1} down`,disabled:!r,onClick:r,children:[(0,Q.jsx)(x,{"aria-hidden":`true`,className:`size-4`}),`Move down`]})]})}function nt({step:e,index:t,skills:n,onRemove:i,gripProps:a,onMoveUp:o,onMoveDown:s,overlay:c=!1}){let l=n.find(t=>t.name===e.skill),u=qe(e),d=Ze(e,l),f=Qe(e,l);return(0,Q.jsxs)(`div`,{"data-slot":`wb-step`,"data-id":e.id,"data-index":t,className:r(`rounded-lg border border-border bg-background p-4`,c&&`shadow-md`),children:[(0,Q.jsx)(et,{index:t,title:u,badge:f,onRemove:i,gripProps:a}),d?(0,Q.jsx)(`div`,{"data-slot":`wb-step-summary`,className:`mt-3 break-words text-xs leading-relaxed text-muted-foreground`,children:d}):null,(0,Q.jsx)(`p`,{"data-slot":`wb-step-kind`,className:`mt-3 text-[12px] text-link-foreground`,children:$e(e)}),c?null:(0,Q.jsx)(tt,{index:t,onMoveUp:o,onMoveDown:s})]})}function rt({skills:e,query:t,error:n,inFlow:r,onAdd:i}){if(n!==null)return(0,Q.jsxs)(`p`,{"data-slot":`wb-palette`,className:`mt-2.5 text-xs text-danger`,children:[`Could not load skills: `,n]});let a=xe(e,t);return(0,Q.jsx)(`div`,{"data-slot":`wb-palette`,className:`mt-2.5 flex flex-col gap-1`,children:a.length>0?a.map(e=>(0,Q.jsx)(it,{skill:e,inFlow:r.has(e.name),onAdd:i},e.path)):(0,Q.jsx)(`p`,{className:`py-1 text-xs leading-relaxed text-soft-foreground`,children:e.length>0?`No skills match.`:(0,Q.jsx)(Te,{})})})}function it({skill:e,inFlow:t,onAdd:n}){let{attributes:i,listeners:a,setNodeRef:o,isDragging:s}=ge({id:`palette:${e.name}`,data:{type:`palette`,skill:e.name}});return(0,Q.jsxs)(`div`,{ref:o,"data-slot":`wb-skill`,"data-skill":e.name,"data-in-flow":t||void 0,title:e.description??``,className:r(`flex min-h-11 cursor-grab items-center gap-2 rounded-md py-1 transition-colors hover:bg-muted`,s&&`opacity-40`),...i,...a,children:[(0,Q.jsx)(`span`,{className:r(`min-w-0 flex-1 break-words text-xs`,W(e)?`font-semibold text-foreground`:`font-medium text-muted-foreground`),children:e.name}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`wb-skill-add`,"aria-label":`Add ${e.name} to the flow`,title:`Add to the flow`,onClick:()=>n(e.name),className:`inline-flex size-11 shrink-0 items-center justify-center rounded-md text-link-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:(0,Q.jsx)(_,{"aria-hidden":`true`,className:`size-3.5`})})]})}function at({yaml:e}){let[t,n]=(0,q.useState)(!1),r=(0,q.useRef)(null);return(0,q.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`wb-copy`,title:`Copy the YAML`,onClick:()=>{navigator.clipboard?.writeText(e).catch(()=>{}),n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),1600)},className:`flex items-center gap-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground`,children:t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(oe,{"aria-hidden":`true`,className:`size-3 text-success`}),`Copied`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(w,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})})}var ot=`wb-canvas`;function $(){return{name:`my-workflow`,description:``,steps:[]}}function st(e){return{name:e.name,description:e.description??``,steps:structuredClone(e.steps??[])}}function ct(){let{name:e}=t();return(0,Q.jsx)(lt,{routeName:e},e??``)}function lt({routeName:e}){let t=ee(),r=f(),i=te(),a=s(),[h,g]=(0,q.useState)(null),[re,ie]=(0,q.useState)(``),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(``),[se,S]=(0,q.useState)(null),[ce,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(``),[le,E]=(0,q.useState)(``),[D,O]=(0,q.useState)(!1),[k,A]=(0,q.useState)(``),[j,M]=(0,q.useState)(!1),[ue,N]=(0,q.useState)(!1),[P,F]=(0,q.useState)(null),[de,I]=(0,q.useState)(null),L=(0,q.useRef)(null),R=(0,q.useRef)(null),z=t.data?.workflows??[],B=r.data??[],V=Se(B,i.data?.skillUsage),ge=xe(V,b,i.data?.skillUsage);(0,q.useEffect)(()=>{if(h!==null||t.data===void 0)return;let n=t.data.workflows,r=(e?n.find(t=>t.name===e):void 0)??n.find(e=>e.source===`file`);g(r?st(r):$())},[h,t.data,e]);let H=e=>g(t=>t===null?t:{...t,steps:e}),U=p({mutationFn:e=>c(e),onSuccess:e=>{g({name:e.name,description:e.description??``,steps:e.steps}),C(!1),T(``),E(``),m(`Imported "${e.name}" — review, then Save.`)},onError:e=>E(e.message)}),W=p({mutationFn:e=>u(e),onSuccess:e=>{g(t=>{let n=t??$(),{name:r,steps:i}=Le(e,n.name);return{...n,name:r,steps:i}}),O(!1),A(``),m(e.fallback?`Planner unavailable — added a single step. Edit, then Save.`:`Built "${e.name??h?.name??`workflow`}" — review, tweak, then Save.`,e.fallback?{tone:`danger`}:void 0)},onError:e=>m(e instanceof Error?e.message:String(e),{tone:`danger`})}),G=p({mutationFn:e=>l({...Re(h?.name??``,h?.description??``,h?.steps??[]),...e?{overwrite:!0}:{}}),onSuccess:e=>{M(!1),m(`Saved — ${e.path.split(`/`).pop()??e.path}`),a.invalidateQueries({queryKey:ne.workflows})},onError:e=>{e instanceof d&&e.exists===!0?M(!0):m(e instanceof Error?e.message:String(e),{tone:`danger`})}}),K=p({mutationFn:e=>o(e),onSuccess:(e,t)=>{N(!1),m(`Deleted "${t}".`),g($()),a.invalidateQueries({queryKey:ne.workflows})},onError:e=>{N(!1),m(e instanceof Error?e.message:String(e),{tone:`danger`})}}),Te=fe(me(pe,{activationConstraint:{distance:4}}),me(he,{coordinateGetter:ye}));if(t.isError)return(0,Q.jsx)(`div`,{"data-route":`workflows`,className:`@container mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:(0,Q.jsx)(Ce,{icon:(0,Q.jsx)(ae,{}),tone:`danger`,title:`Could not load workflows`,subtitle:t.error.message})});if(h===null)return(0,Q.jsx)(we,{});let J=h.steps,Y=h.name.trim(),X=z.find(e=>e.name===Y&&e.source===`file`),Ae=Pe(h.name,h.description,J),Z=(e,t=J.length)=>{if(J.length>=8){m(`A workflow holds at most 8 steps.`,{tone:`danger`});return}H(De(J,Ee(e,J),t))};return(0,Q.jsxs)(`div`,{"data-route":`workflows`,className:`@container mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:[(0,Q.jsxs)(`header`,{className:`mb-[22px] flex flex-wrap items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-[25px] font-semibold md:text-[30px]`,children:`Workflows`}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground md:text-[13px]`,children:`Portable skill chains. Steps run from top to bottom.`})]}),(0,Q.jsxs)(n,{variant:`primary`,"data-slot":`wb-new`,className:`min-h-11`,onClick:()=>g($()),children:[(0,Q.jsx)(_,{"aria-hidden":`true`,className:`size-4`}),`New workflow`]})]}),(0,Q.jsxs)(_e,{sensors:Te,collisionDetection:ve,onDragStart:e=>{let t=e.active.data.current;F(t??null)},onDragOver:e=>{I(e.over?String(e.over.id):null)},onDragEnd:e=>{F(null),I(null);let{active:t,over:n}=e;if(n===null)return;let r=t.data.current;if(r?.type===`palette`){let e=n.id===ot?J.length:J.findIndex(e=>e.id===n.id);Z(r.skill,e===-1?J.length:e);return}if(n.id===t.id)return;let i=J.findIndex(e=>e.id===t.id),a=J.findIndex(e=>e.id===n.id);i!==-1&&a!==-1&&H(Oe(J,i,a))},onDragCancel:()=>{F(null),I(null)},children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[22px] pb-[calc(32px+env(safe-area-inset-bottom))]`,children:[(0,Q.jsx)(ze,{workflows:z,draft:h,trimmedName:Y,nameRef:L,onDraft:g,onLoadWorkflow:e=>g(st(e))}),(0,Q.jsx)(Be,{savedFile:X,autoOpen:D,onImportToggle:()=>{E(``),O(!1),C(e=>!e)},onExport:()=>{let e=new Blob([Ae],{type:`text/yaml`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${Fe(h.name)}.yaml`,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(t),1e3)},onAutoToggle:()=>{C(!1),O(e=>!e)},onDeleteRequest:()=>N(!0)}),D?(0,Q.jsx)(Ve,{text:k,onTextChange:A,pending:W.isPending,onRun:()=>{let e=k.trim();e===``||W.isPending||W.mutate(e)},onCancel:()=>{O(!1),A(``)}}):null,(0,Q.jsx)(He,{open:ce,onOpenChange:C,text:w,onTextChange:T,error:le,pending:U.isPending,onRun:()=>{let e=w.trim();e!==``&&U.mutate(e)},onCancel:()=>{C(!1),T(``),E(``)}}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 items-start gap-[22px] @min-[700px]:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,Q.jsxs)(`section`,{"data-slot":`wb-main`,className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Steps · `,J.length,` of `,8,(0,Q.jsx)(`span`,{"data-slot":`wb-count`,className:`sr-only`,children:Ie(J)})]}),(0,Q.jsx)(ut,{steps:J,skills:B,dragging:P!==null,overId:de,activeStepId:P?.type===`step`?P.step.id:null,onRemove:e=>H(ke(J,e)),onMove:(e,t)=>H(Oe(J,e,t))}),(0,Q.jsxs)(n,{ref:R,variant:`outline`,className:`mt-4 min-h-11`,onClick:()=>{S(null),x(``),y(!0)},children:[(0,Q.jsx)(_,{"aria-hidden":`true`,className:`size-4`}),`Add step`]}),(0,Q.jsxs)(`p`,{className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`hidden @min-[900px]:inline`,children:`Drag to reorder. The agent follows this sequence from top to bottom.`}),(0,Q.jsx)(`span`,{className:`@min-[900px]:hidden`,children:`Use Move up / Move down to reorder without dragging.`})]}),(0,Q.jsxs)(`footer`,{className:`mt-4 flex flex-wrap items-center justify-between gap-4 border-t border-border pt-4`,children:[(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Review the name and steps, then save to a workflow file.`}),(0,Q.jsxs)(n,{type:`button`,variant:`primary`,size:`sm`,className:`min-h-11 max-sm:w-full`,"data-slot":`wb-save`,disabled:G.isPending,onClick:()=>{if(Y===``){L.current?.focus();return}if(J.length===0){m(`Add at least one step first.`,{tone:`danger`});return}G.mutate(!1)},children:[(0,Q.jsx)(oe,{"aria-hidden":`true`,className:`size-3`}),`Save`]})]})]}),(0,Q.jsx)(Ue,{paletteSkills:V,query:re,onQueryChange:ie,error:r.isError?r.error.message:null,inFlow:new Set(J.map(e=>e.skill).filter(e=>!!e)),onAdd:e=>Z(e),yaml:Ae})]})]}),(0,Q.jsx)(be,{children:(0,Q.jsx)(We,{dragging:P,steps:J,skills:B})})]}),(0,Q.jsx)(Ge,{open:v,onOpenChange:y,query:b,onQueryChange:x,matches:ge,skillsCount:B.length,error:r.isError?r.error.message:null,selectedSkill:se,onSelectSkill:S,stepsCount:J.length,onCloseAutoFocus:e=>{e.preventDefault(),R.current?.focus()},onCancel:()=>y(!1),onAdd:e=>{Z(e),y(!1)}}),(0,Q.jsx)(Ke,{trimmedName:Y,savedFile:X,overwriteOpen:j,onOverwriteDismiss:()=>M(!1),deleteOpen:ue,onDeleteDismiss:()=>N(!1),onOverwrite:()=>G.mutate(!0),onDelete:()=>K.mutate(Y)})]})}function ut({steps:e,skills:t,dragging:n,overId:i,activeStepId:a,onRemove:o,onMove:s}){let{setNodeRef:c,isOver:l}=B({id:ot}),u=n&&i===ot;return(0,Q.jsx)(`div`,{ref:c,"data-slot":`wb-steps`,"data-dragging":n||void 0,className:r(`relative mt-4 rounded-lg transition-colors`,l?`border-accent-strong/60 bg-accent-strong/5`:`border-muted-foreground/25`),children:e.length===0?(0,Q.jsx)(`p`,{className:r(`rounded-md px-3 py-10 text-center text-[13px] transition-colors`,l?`text-link-foreground`:`text-muted-foreground`),children:`Drop a skill here — or Import a workflow.yaml`}):(0,Q.jsxs)(H,{items:e.map(e=>e.id),strategy:z,children:[(0,Q.jsx)(`ol`,{className:`flex flex-col gap-4`,children:e.map((r,c)=>(0,Q.jsx)(dt,{step:r,index:c,skills:t,dragging:n,insertBefore:n&&i===r.id&&a!==r.id,onRemove:()=>o(c),onMoveUp:c>0?()=>s(c,c-1):void 0,onMoveDown:c<e.length-1?()=>s(c,c+1):void 0},r.id))}),(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:r(`absolute inset-x-0 mt-1 h-[3px] rounded-full transition-colors`,u?`bg-accent-strong`:`bg-transparent`)})]})})}function dt({step:e,index:t,skills:n,insertBefore:i,onRemove:a,onMoveUp:o,onMoveDown:s}){let{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:ee}=V({id:e.id,data:{type:`step`,step:e}});return(0,Q.jsxs)(`li`,{ref:u,style:{transform:U.Transform.toString(d),transition:f},className:r(`relative`,ee&&`opacity-40`),children:[i?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`wb-drop-line`,className:`pointer-events-none absolute -top-[7px] right-0 left-0 h-[3px] rounded-full bg-accent-strong`}):null,(0,Q.jsx)(nt,{step:e,index:t,skills:n,onRemove:a,onMoveUp:o,onMoveDown:s,gripProps:{...c,...l}})]})}export{ct as WorkflowsRoute};
7
+ - commit-style`,value:r,onChange:e=>i(e.target.value),className:`mt-4 min-h-[124px] bg-background p-4 font-mono text-[13px] leading-relaxed`}),(0,Q.jsx)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:`Paste a portable workflow definition. Imported steps appear in execution order.`}),a===``?null:(0,Q.jsx)(`p`,{"data-slot":`wb-import-error`,role:`alert`,className:`mt-2 text-xs text-danger`,children:a}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,Q.jsx)(n,{type:`button`,variant:`primary`,size:`sm`,"data-slot":`wb-import-run`,disabled:o,onClick:s,children:`Import`}),(0,Q.jsx)(n,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-import-cancel`,onClick:c,children:`Cancel`})]})]})})}function Ue({paletteSkills:e,query:t,onQueryChange:n,error:r,inFlow:i,onAdd:a,yaml:o}){return(0,Q.jsxs)(`aside`,{"data-slot":`wb-aside`,className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:`Available skills`}),(0,Q.jsxs)(`div`,{className:`sw-search relative mt-4`,children:[(0,Q.jsx)(g,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,Q.jsx)(K,{"data-slot":`wb-filter`,placeholder:`Find a skill…`,"aria-label":`Filter skills`,value:t,onChange:e=>n(e.target.value),className:`h-11 pl-9 text-xs`})]}),(0,Q.jsx)(rt,{skills:e,query:t,error:r,inFlow:i,onAdd:a}),(0,Q.jsx)(`h3`,{className:`mt-5 text-sm font-semibold`,children:`workflow.yaml`}),(0,Q.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-muted-foreground`,children:`Export the workflow to use this chain in another project.`}),(0,Q.jsxs)(`details`,{className:`mt-4 min-w-0`,children:[(0,Q.jsxs)(`summary`,{"data-slot":`wb-yaml-toggle`,className:`inline-flex min-h-[44px] cursor-pointer items-center rounded-lg border border-border px-3 text-xs font-medium focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(h,{"aria-hidden":`true`,className:`mr-2 size-4`}),`View YAML`]}),(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsx)(at,{yaml:o})}),(0,Q.jsx)(`pre`,{"data-slot":`wb-yaml`,className:`mt-2 max-h-96 overflow-auto rounded-lg border border-border bg-background p-3 font-mono text-[11px] leading-relaxed whitespace-pre text-muted-foreground`,children:o})]})]})}function We({dragging:e,steps:t,skills:n}){return e?.type===`palette`?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-1.5 font-mono text-[13px] font-medium shadow-md`,children:[(0,Q.jsx)(se,{"aria-hidden":`true`,className:`size-3.5 text-link-foreground`}),e.skill]}):e?.type===`step`?(0,Q.jsx)(nt,{step:e.step,index:t.findIndex(t=>t.id===e.step.id),skills:n,overlay:!0}):null}function Ge({open:e,onOpenChange:t,query:r,onQueryChange:i,matches:a,skillsCount:o,error:s,selectedSkill:c,onSelectSkill:l,stepsCount:u,onCloseAutoFocus:d,onCancel:f,onAdd:ee}){return(0,Q.jsx)(R,{open:e,onOpenChange:t,children:(0,Q.jsxs)(I,{"data-slot":`wb-add-dialog`,onCloseAutoFocus:d,className:`max-h-[85dvh] overflow-y-auto sm:max-w-[660px] [&_button]:min-h-11`,children:[(0,Q.jsxs)(de,{children:[(0,Q.jsx)(L,{className:`text-xl font-normal`,children:`Add step`}),(0,Q.jsx)(F,{className:`sr-only`,children:`Choose a skill to append to this workflow.`})]}),(0,Q.jsx)(K,{"aria-label":`Filter skills`,placeholder:`Filter skills…`,value:r,onChange:e=>i(e.target.value)}),s===null?(0,Q.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Available skills`,className:`grid max-h-80 gap-2 overflow-y-auto`,children:[a.map(e=>(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg py-2 has-[:checked]:bg-accent-strong/10 has-[:focus-visible]:outline-2`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`workflow-add-skill`,className:`sr-only`,value:e.name,checked:c===e.name,onChange:()=>l(e.name)}),(0,Q.jsxs)(`span`,{className:`min-w-0 break-words text-sm`,children:[(0,Q.jsx)(`span`,{className:`block`,children:e.name}),(0,Q.jsx)(`span`,{className:`mt-2 block text-xs text-muted-foreground`,children:e.description})]})]},e.name)),a.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o===0?`No skills available in this project.`:`No matching skills.`}):null]}):(0,Q.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not load skills: `,s]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsx)(n,{variant:`outline`,onClick:f,children:`Cancel`}),(0,Q.jsx)(n,{variant:`primary`,disabled:!c||u>=8,onClick:()=>{c&&ee(c)},children:`Add selected skill`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Append the selected skill, then reorder it in the existing canvas.`}),u>=8?(0,Q.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`A workflow can contain up to `,8,` steps. Remove a step before adding another.`]}):null]})})}function Ke({trimmedName:e,savedFile:t,overwriteOpen:n,onOverwriteDismiss:r,deleteOpen:i,onDeleteDismiss:a,onOverwrite:o,onDelete:s}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{open:n,onOpenChange:e=>!e&&r(),children:(0,Q.jsxs)(A,{"data-slot":`wb-overwrite-dialog`,className:`sw-workflow-confirm sm:max-w-[660px]`,children:[(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(k,{children:[`“`,e,`” already exists`]}),(0,Q.jsx)(O,{children:`Saving overwrites the existing workflow file. There is no undo.`})]}),(0,Q.jsxs)(M,{children:[(0,Q.jsx)(ue,{children:`Keep the file`}),(0,Q.jsx)(j,{"data-slot":`wb-overwrite-confirm`,className:`bg-danger text-danger-foreground`,onClick:o,children:`Overwrite`})]})]})}),(0,Q.jsx)(P,{open:i,onOpenChange:e=>!e&&a(),children:(0,Q.jsxs)(A,{"data-slot":`wb-delete-dialog`,className:`sw-workflow-confirm sm:max-w-[660px]`,children:[(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(k,{children:[`Delete workflow “`,e,`”?`]}),(0,Q.jsxs)(O,{children:[`Removes `,t?.path?.split(`/`).pop()??`the saved file`,` from`,` `,(0,Q.jsx)(`span`,{className:`font-mono`,children:`.ai/cezar/workflows/`}),`. There is no undo.`]})]}),(0,Q.jsxs)(M,{children:[(0,Q.jsx)(ue,{children:`Keep the file`}),(0,Q.jsx)(j,{"data-slot":`wb-delete-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:s,children:`Delete workflow`})]})]})})]})}function qe(e){return e.name??e.skill??e.id}function Je(e){return e.prompt?.trim()===`{{task}}`?void 0:e.prompt?.trim()}function Ye(e){let t=e.onFail?` — on fail retry from "${e.onFail.retry}" (×${e.onFail.max??2})`:``;return`$ ${e.command}${t}`}function Xe(e,t){return Je(e)||t?.description||`Not in this repo or the team skills — the step runs on its plain prompt.`}function Ze(e,t){return e.command?Ye(e):e.skill?Xe(e,t):e.prompt??``}function Qe(e,t){return e.skill&&!t?`unknown`:null}function $e(e){return e.command?`Command step${e.onFail?` · Retry ×${e.onFail.max??2}`:``}`:e.skill?`Skill step`:`Prompt step`}function et({index:e,title:t,badge:i,onRemove:a,gripProps:o}){return(0,Q.jsxs)(`div`,{"data-slot":`wb-step-heading`,className:`flex min-w-0 items-center gap-2.5`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-slot":`wb-step-grip`,"aria-label":`Reorder step ${e+1}: ${t}`,className:`inline-flex size-[26px] shrink-0 cursor-grab items-center justify-center rounded-md text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,...o,children:(0,Q.jsx)(`span`,{className:`rounded bg-accent-strong/10 px-2 py-1 font-mono text-[12px] text-link-foreground`,children:String(e+1).padStart(2,`0`)})}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1 break-words text-sm font-medium [overflow-wrap:anywhere]`,children:t}),i?(0,Q.jsx)(`span`,{"data-slot":`wb-step-badge`,className:r(`shrink-0 rounded-full border px-2 py-px font-mono text-[11px]`,i===`unknown`&&`border-danger/35 text-danger`),children:i}):null,a?(0,Q.jsxs)(D,{children:[(0,Q.jsx)(le,{asChild:!0,children:(0,Q.jsx)(n,{"data-slot":`wb-step-actions`,variant:`ghost`,size:`icon`,className:`size-[26px]`,"aria-label":`Step ${e+1} actions: ${t}`,children:(0,Q.jsx)(re,{"aria-hidden":`true`,className:`size-4`})})}),(0,Q.jsx)(E,{align:`end`,children:(0,Q.jsxs)(T,{"data-slot":`wb-step-remove`,"aria-label":`Remove step ${e+1}: ${t}`,onSelect:a,children:[(0,Q.jsx)(S,{"aria-hidden":`true`}),` Remove step`]})})]}):null]})}function tt({index:e,onMoveUp:t,onMoveDown:r}){return(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 @min-[900px]:hidden`,children:[(0,Q.jsxs)(n,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":`Move step ${e+1} up`,disabled:!t,onClick:t,children:[(0,Q.jsx)(ie,{"aria-hidden":`true`,className:`size-4`}),`Move up`]}),(0,Q.jsxs)(n,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":`Move step ${e+1} down`,disabled:!r,onClick:r,children:[(0,Q.jsx)(x,{"aria-hidden":`true`,className:`size-4`}),`Move down`]})]})}function nt({step:e,index:t,skills:n,onRemove:i,gripProps:a,onMoveUp:o,onMoveDown:s,overlay:c=!1}){let l=n.find(t=>t.name===e.skill),u=qe(e),d=Ze(e,l),f=Qe(e,l);return(0,Q.jsxs)(`div`,{"data-slot":`wb-step`,"data-id":e.id,"data-index":t,className:r(`rounded-lg border border-border bg-background p-4`,c&&`shadow-md`),children:[(0,Q.jsx)(et,{index:t,title:u,badge:f,onRemove:i,gripProps:a}),d?(0,Q.jsx)(`div`,{"data-slot":`wb-step-summary`,className:`mt-3 break-words text-xs leading-relaxed text-muted-foreground`,children:d}):null,(0,Q.jsx)(`p`,{"data-slot":`wb-step-kind`,className:`mt-3 text-[12px] text-link-foreground`,children:$e(e)}),c?null:(0,Q.jsx)(tt,{index:t,onMoveUp:o,onMoveDown:s})]})}function rt({skills:e,query:t,error:n,inFlow:r,onAdd:i}){if(n!==null)return(0,Q.jsxs)(`p`,{"data-slot":`wb-palette`,className:`mt-2.5 text-xs text-danger`,children:[`Could not load skills: `,n]});let a=xe(e,t);return(0,Q.jsx)(`div`,{"data-slot":`wb-palette`,className:`mt-2.5 flex flex-col gap-1`,children:a.length>0?a.map(e=>(0,Q.jsx)(it,{skill:e,inFlow:r.has(e.name),onAdd:i},e.path)):(0,Q.jsx)(`p`,{className:`py-1 text-xs leading-relaxed text-soft-foreground`,children:e.length>0?`No skills match.`:(0,Q.jsx)(Te,{})})})}function it({skill:e,inFlow:t,onAdd:n}){let{attributes:i,listeners:a,setNodeRef:o,isDragging:s}=ge({id:`palette:${e.name}`,data:{type:`palette`,skill:e.name}});return(0,Q.jsxs)(`div`,{ref:o,"data-slot":`wb-skill`,"data-skill":e.name,"data-in-flow":t||void 0,title:e.description??``,className:r(`flex min-h-11 cursor-grab items-center gap-2 rounded-md py-1 transition-colors hover:bg-muted`,s&&`opacity-40`),...i,...a,children:[(0,Q.jsx)(`span`,{className:r(`min-w-0 flex-1 break-words text-xs`,W(e)?`font-semibold text-foreground`:`font-medium text-muted-foreground`),children:e.name}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`wb-skill-add`,"aria-label":`Add ${e.name} to the flow`,title:`Add to the flow`,onClick:()=>n(e.name),className:`inline-flex size-11 shrink-0 items-center justify-center rounded-md text-link-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:(0,Q.jsx)(_,{"aria-hidden":`true`,className:`size-3.5`})})]})}function at({yaml:e}){let[t,n]=(0,q.useState)(!1),r=(0,q.useRef)(null);return(0,q.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`wb-copy`,title:`Copy the YAML`,onClick:()=>{navigator.clipboard?.writeText(e).catch(()=>{}),n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),1600)},className:`flex items-center gap-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground`,children:t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(oe,{"aria-hidden":`true`,className:`size-3 text-success`}),`Copied`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(w,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})})}var ot=`wb-canvas`;function $(){return{name:`my-workflow`,description:``,steps:[]}}function st(e){return{name:e.name,description:e.description??``,steps:structuredClone(e.steps??[])}}function ct(){let{name:e}=t();return(0,Q.jsx)(lt,{routeName:e},e??``)}function lt({routeName:e}){let t=ee(),r=f(),i=te(),a=l(),[h,g]=(0,q.useState)(null),[re,ie]=(0,q.useState)(``),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(``),[se,S]=(0,q.useState)(null),[ce,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(``),[le,E]=(0,q.useState)(``),[D,O]=(0,q.useState)(!1),[k,A]=(0,q.useState)(``),[j,M]=(0,q.useState)(!1),[ue,N]=(0,q.useState)(!1),[P,F]=(0,q.useState)(null),[de,I]=(0,q.useState)(null),L=(0,q.useRef)(null),R=(0,q.useRef)(null),z=t.data?.workflows??[],B=r.data??[],V=Se(B,i.data?.skillUsage),ge=xe(V,b,i.data?.skillUsage);(0,q.useEffect)(()=>{if(h!==null||t.data===void 0)return;let n=t.data.workflows,r=(e?n.find(t=>t.name===e):void 0)??n.find(e=>e.source===`file`);g(r?st(r):$())},[h,t.data,e]);let H=e=>g(t=>t===null?t:{...t,steps:e}),U=p({mutationFn:e=>s(e),onSuccess:e=>{g({name:e.name,description:e.description??``,steps:e.steps}),C(!1),T(``),E(``),m(`Imported "${e.name}" — review, then Save.`)},onError:e=>E(e.message)}),W=p({mutationFn:e=>u(e),onSuccess:e=>{g(t=>{let n=t??$(),{name:r,steps:i}=Le(e,n.name);return{...n,name:r,steps:i}}),O(!1),A(``),m(e.fallback?`Planner unavailable — added a single step. Edit, then Save.`:`Built "${e.name??h?.name??`workflow`}" — review, tweak, then Save.`,e.fallback?{tone:`danger`}:void 0)},onError:e=>m(e instanceof Error?e.message:String(e),{tone:`danger`})}),G=p({mutationFn:e=>c({...Re(h?.name??``,h?.description??``,h?.steps??[]),...e?{overwrite:!0}:{}}),onSuccess:e=>{M(!1),m(`Saved — ${e.path.split(`/`).pop()??e.path}`),a.invalidateQueries({queryKey:ne.workflows})},onError:e=>{e instanceof d&&e.exists===!0?M(!0):m(e instanceof Error?e.message:String(e),{tone:`danger`})}}),K=p({mutationFn:e=>o(e),onSuccess:(e,t)=>{N(!1),m(`Deleted "${t}".`),g($()),a.invalidateQueries({queryKey:ne.workflows})},onError:e=>{N(!1),m(e instanceof Error?e.message:String(e),{tone:`danger`})}}),Te=fe(me(pe,{activationConstraint:{distance:4}}),me(he,{coordinateGetter:ye}));if(t.isError)return(0,Q.jsx)(`div`,{"data-route":`workflows`,className:`@container mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:(0,Q.jsx)(Ce,{icon:(0,Q.jsx)(ae,{}),tone:`danger`,title:`Could not load workflows`,subtitle:t.error.message})});if(h===null)return(0,Q.jsx)(we,{});let J=h.steps,Y=h.name.trim(),X=z.find(e=>e.name===Y&&e.source===`file`),Ae=Pe(h.name,h.description,J),Z=(e,t=J.length)=>{if(J.length>=8){m(`A workflow holds at most 8 steps.`,{tone:`danger`});return}H(De(J,Ee(e,J),t))};return(0,Q.jsxs)(`div`,{"data-route":`workflows`,className:`@container mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:[(0,Q.jsxs)(`header`,{className:`mb-[22px] flex flex-wrap items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-[25px] font-semibold md:text-[30px]`,children:`Workflows`}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground md:text-[13px]`,children:`Portable skill chains. Steps run from top to bottom.`})]}),(0,Q.jsxs)(n,{variant:`primary`,"data-slot":`wb-new`,className:`min-h-11`,onClick:()=>g($()),children:[(0,Q.jsx)(_,{"aria-hidden":`true`,className:`size-4`}),`New workflow`]})]}),(0,Q.jsxs)(_e,{sensors:Te,collisionDetection:ve,onDragStart:e=>{let t=e.active.data.current;F(t??null)},onDragOver:e=>{I(e.over?String(e.over.id):null)},onDragEnd:e=>{F(null),I(null);let{active:t,over:n}=e;if(n===null)return;let r=t.data.current;if(r?.type===`palette`){let e=n.id===ot?J.length:J.findIndex(e=>e.id===n.id);Z(r.skill,e===-1?J.length:e);return}if(n.id===t.id)return;let i=J.findIndex(e=>e.id===t.id),a=J.findIndex(e=>e.id===n.id);i!==-1&&a!==-1&&H(Oe(J,i,a))},onDragCancel:()=>{F(null),I(null)},children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[22px] pb-[calc(32px+env(safe-area-inset-bottom))]`,children:[(0,Q.jsx)(ze,{workflows:z,draft:h,trimmedName:Y,nameRef:L,onDraft:g,onLoadWorkflow:e=>g(st(e))}),(0,Q.jsx)(Be,{savedFile:X,autoOpen:D,onImportToggle:()=>{E(``),O(!1),C(e=>!e)},onExport:()=>{let e=new Blob([Ae],{type:`text/yaml`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${Fe(h.name)}.yaml`,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(t),1e3)},onAutoToggle:()=>{C(!1),O(e=>!e)},onDeleteRequest:()=>N(!0)}),D?(0,Q.jsx)(Ve,{text:k,onTextChange:A,pending:W.isPending,onRun:()=>{let e=k.trim();e===``||W.isPending||W.mutate(e)},onCancel:()=>{O(!1),A(``)}}):null,(0,Q.jsx)(He,{open:ce,onOpenChange:C,text:w,onTextChange:T,error:le,pending:U.isPending,onRun:()=>{let e=w.trim();e!==``&&U.mutate(e)},onCancel:()=>{C(!1),T(``),E(``)}}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 items-start gap-[22px] @min-[700px]:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,Q.jsxs)(`section`,{"data-slot":`wb-main`,className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Steps · `,J.length,` of `,8,(0,Q.jsx)(`span`,{"data-slot":`wb-count`,className:`sr-only`,children:Ie(J)})]}),(0,Q.jsx)(ut,{steps:J,skills:B,dragging:P!==null,overId:de,activeStepId:P?.type===`step`?P.step.id:null,onRemove:e=>H(ke(J,e)),onMove:(e,t)=>H(Oe(J,e,t))}),(0,Q.jsxs)(n,{ref:R,variant:`outline`,className:`mt-4 min-h-11`,onClick:()=>{S(null),x(``),y(!0)},children:[(0,Q.jsx)(_,{"aria-hidden":`true`,className:`size-4`}),`Add step`]}),(0,Q.jsxs)(`p`,{className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`hidden @min-[900px]:inline`,children:`Drag to reorder. The agent follows this sequence from top to bottom.`}),(0,Q.jsx)(`span`,{className:`@min-[900px]:hidden`,children:`Use Move up / Move down to reorder without dragging.`})]}),(0,Q.jsxs)(`footer`,{className:`mt-4 flex flex-wrap items-center justify-between gap-4 border-t border-border pt-4`,children:[(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Review the name and steps, then save to a workflow file.`}),(0,Q.jsxs)(n,{type:`button`,variant:`primary`,size:`sm`,className:`min-h-11 max-sm:w-full`,"data-slot":`wb-save`,disabled:G.isPending,onClick:()=>{if(Y===``){L.current?.focus();return}if(J.length===0){m(`Add at least one step first.`,{tone:`danger`});return}G.mutate(!1)},children:[(0,Q.jsx)(oe,{"aria-hidden":`true`,className:`size-3`}),`Save`]})]})]}),(0,Q.jsx)(Ue,{paletteSkills:V,query:re,onQueryChange:ie,error:r.isError?r.error.message:null,inFlow:new Set(J.map(e=>e.skill).filter(e=>!!e)),onAdd:e=>Z(e),yaml:Ae})]})]}),(0,Q.jsx)(be,{children:(0,Q.jsx)(We,{dragging:P,steps:J,skills:B})})]}),(0,Q.jsx)(Ge,{open:v,onOpenChange:y,query:b,onQueryChange:x,matches:ge,skillsCount:B.length,error:r.isError?r.error.message:null,selectedSkill:se,onSelectSkill:S,stepsCount:J.length,onCloseAutoFocus:e=>{e.preventDefault(),R.current?.focus()},onCancel:()=>y(!1),onAdd:e=>{Z(e),y(!1)}}),(0,Q.jsx)(Ke,{trimmedName:Y,savedFile:X,overwriteOpen:j,onOverwriteDismiss:()=>M(!1),deleteOpen:ue,onDeleteDismiss:()=>N(!1),onOverwrite:()=>G.mutate(!0),onDelete:()=>K.mutate(Y)})]})}function ut({steps:e,skills:t,dragging:n,overId:i,activeStepId:a,onRemove:o,onMove:s}){let{setNodeRef:c,isOver:l}=B({id:ot}),u=n&&i===ot;return(0,Q.jsx)(`div`,{ref:c,"data-slot":`wb-steps`,"data-dragging":n||void 0,className:r(`relative mt-4 rounded-lg transition-colors`,l?`border-accent-strong/60 bg-accent-strong/5`:`border-muted-foreground/25`),children:e.length===0?(0,Q.jsx)(`p`,{className:r(`rounded-md px-3 py-10 text-center text-[13px] transition-colors`,l?`text-link-foreground`:`text-muted-foreground`),children:`Drop a skill here — or Import a workflow.yaml`}):(0,Q.jsxs)(H,{items:e.map(e=>e.id),strategy:z,children:[(0,Q.jsx)(`ol`,{className:`flex flex-col gap-4`,children:e.map((r,c)=>(0,Q.jsx)(dt,{step:r,index:c,skills:t,dragging:n,insertBefore:n&&i===r.id&&a!==r.id,onRemove:()=>o(c),onMoveUp:c>0?()=>s(c,c-1):void 0,onMoveDown:c<e.length-1?()=>s(c,c+1):void 0},r.id))}),(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:r(`absolute inset-x-0 mt-1 h-[3px] rounded-full transition-colors`,u?`bg-accent-strong`:`bg-transparent`)})]})})}function dt({step:e,index:t,skills:n,insertBefore:i,onRemove:a,onMoveUp:o,onMoveDown:s}){let{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:ee}=V({id:e.id,data:{type:`step`,step:e}});return(0,Q.jsxs)(`li`,{ref:u,style:{transform:U.Transform.toString(d),transition:f},className:r(`relative`,ee&&`opacity-40`),children:[i?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`wb-drop-line`,className:`pointer-events-none absolute -top-[7px] right-0 left-0 h-[3px] rounded-full bg-accent-strong`}):null,(0,Q.jsx)(nt,{step:e,index:t,skills:n,onRemove:a,onMoveUp:o,onMoveDown:s,gripProps:{...c,...l}})]})}export{ct as WorkflowsRoute};