specrails-desktop 2.30.2 → 2.30.3
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.
- package/client/dist/assets/{ActivityFeedPage-9DZOvIcY.js → ActivityFeedPage-CcBOllqm.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-DqyHbzk7.js → AgentBrowserCapture-BOJkZUj_.js} +1 -1
- package/client/dist/assets/{AgentModeCodePane-BAYyFRmY.js → AgentModeCodePane-BIh67rGi.js} +2 -2
- package/client/dist/assets/{AgentModeJobsPane-CTIHMUKN.js → AgentModeJobsPane-C5tkU2Ed.js} +1 -1
- package/client/dist/assets/{AgentsPage-DuyJuaFs.js → AgentsPage-CNlE_Uh4.js} +1 -1
- package/client/dist/assets/{AnalyticsPage-BY7gtCx6.js → AnalyticsPage-cYcJxWPn.js} +1 -1
- package/client/dist/assets/{CodePage-vyQr40Vl.js → CodePage-D4QYa4t1.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-CkXUFj3F.js → DesktopAnalyticsPage-DCmgYV86.js} +1 -1
- package/client/dist/assets/{DocsDialog-PhdCJNVj.js → DocsDialog-BXnOgm7V.js} +1 -1
- package/client/dist/assets/{DocsPage-BY-wDthx.js → DocsPage-nFkHh-Dc.js} +1 -1
- package/client/dist/assets/{InteractiveJobComposer-C9I0A4KR.js → InteractiveJobComposer-qoeZjwVY.js} +1 -1
- package/client/dist/assets/{JobDetailModal-I_RoQJV4.js → JobDetailModal-ChRBB9bc.js} +1 -1
- package/client/dist/assets/{JobDetailPage-CU4FEnUC.js → JobDetailPage-BuOnlndB.js} +1 -1
- package/client/dist/assets/{JobsPage-DcllM4Ip.js → JobsPage-C_UEIXWA.js} +1 -1
- package/client/dist/assets/{LoopBuilderPage-DGm_iuff.js → LoopBuilderPage-BV_wge0g.js} +1 -1
- package/client/dist/assets/{LoopPreviewModal-BC-TeFdD.js → LoopPreviewModal-Qk_Jaxo8.js} +1 -1
- package/client/dist/assets/{LoopsPage-SqglnXlp.js → LoopsPage-lLi6ax0p.js} +1 -1
- package/client/dist/assets/{PluginsPage-B89S8o1a.js → PluginsPage-DZIFv9kw.js} +1 -1
- package/client/dist/assets/{ProjectSettingsDialog-nEs-ENrE.js → ProjectSettingsDialog-DEHcyt_I.js} +1 -1
- package/client/dist/assets/{TemplatePreviewModal-D4qW-J9B.js → TemplatePreviewModal-Bxbtnzob.js} +1 -1
- package/client/dist/assets/{TicketDetailModal-CI47Dq9E.js → TicketDetailModal-CqQ5gx7O.js} +2 -2
- package/client/dist/assets/{dist-js-jwoXo0YD.js → dist-js-CBhuoTO6.js} +1 -1
- package/client/dist/assets/{dist-js-Dj72W6qo.js → dist-js-eSxaoEw0.js} +1 -1
- package/client/dist/assets/{index-F9r8mWP_.js → index-CewRMo0W.js} +10 -10
- package/client/dist/index.html +2 -2
- package/package.json +1 -1
- package/server/dist/core-update-manager.js +17 -1
- package/server/dist/framework-manager.js +19 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-js-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-js-eSxaoEw0.js","assets/index-CewRMo0W.js","assets/rolldown-runtime-CNC7AqOf.js","assets/jsx-runtime-zu2_FqZY.js","assets/react-dom-DiWzBDP9.js","assets/preload-helper-Czpn1I53.js","assets/chunk-KS7C4IRE-Cx5sqopX.js","assets/i18n-Bf9Ckd10.js","assets/createLucideIcon-Bjbbp_KS.js","assets/activity-DiyjsgQV.js","assets/addspec-Rw8uVBC1.js","assets/agent-BuUpgqVx.js","assets/agents-DhG7mg6-.js","assets/agentstudio-BIUe1Im2.js","assets/aiedit-iIjz2_Qk.js","assets/analytics-DZ8Aoq3I.js","assets/attachments-B53PG733.js","assets/browser-CXUcnTMI.js","assets/builder-Cc_Lf79C.js","assets/chat-BGD7MXAy.js","assets/code-BDXEM4ml.js","assets/commands-DyUZQ1FI.js","assets/common-DHsv9N5d.js","assets/dashboard-Cslu_GCH.js","assets/explore-DgBACn39.js","assets/integrations-mB-7zoyT.js","assets/jira-CmKWERE0.js","assets/jobs-DoSaFzAa.js","assets/loops-BzfXWEwO.js","assets/mcp-uDkXYu4L.js","assets/nav-myFaXRHD.js","assets/settings-B0ypw9uw.js","assets/setup-ajB4rYm-.js","assets/specs-DII0C8gw.js","assets/terminal-BFRZnMPP.js","assets/tickets-D_yDquEw.js","assets/Trans-CPISVji8.js","assets/dist-bVqfYmby.js","assets/arrow-left-CpIR4j7G.js","assets/useBrowserCaptureSession-CkBJShUw.js","assets/auth-D_5bQv5W.js","assets/api-B2M7CtDw.js","assets/arrow-up-right-9DoMn7fD.js","assets/MinimizedChatsContext-Cs34FPTz.js","assets/sparkles-DrY8hb0X.js","assets/x-CBMI9ejn.js","assets/useSharedWebSocket-DaPh7QBL.js","assets/useDesktop-B4pSBIDd.js","assets/external-link-BcU5EWZp.js","assets/chevron-right-CViMxucY.js","assets/circle-x-CMYsN4ZH.js","assets/download-CFHyyHcw.js","assets/file-text-CFT-xXKN.js","assets/git-branch-BRM0F5GN.js","assets/loader-circle-DcygOQpC.js","assets/pencil-C9RkrIPZ.js","assets/play-DNlrawbS.js","assets/plus-CsnjfkmX.js","assets/save-28sIlCdr.js","assets/search-Cq_gE3Ik.js","assets/trash-2-BOU3WdZZ.js","assets/triangle-alert-H9T4jAmh.js","assets/zap-CHo3aCD1.js","assets/dist-Cez5CRkX.js","assets/button-BUIIBQPT.js","assets/clsx-CjueKrWZ.js","assets/utils-BC4DHlz2.js","assets/dialog-CzIekCw0.js","assets/jira-api-BgFIr8eD.js","assets/lib-CGdyxIWg.js","assets/getTimezoneOffsetInMilliseconds-qrcBaLW1.js","assets/index-Dh9i4CnN.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{l as a}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{_ as o,a as s,f as c,h as l,o as u,v as d}from"./i18n-Bf9Ckd10.js";import{t as f}from"./Trans-CPISVji8.js";import{n as p,t as m}from"./createLucideIcon-Bjbbp_KS.js";import{n as h}from"./dist-bVqfYmby.js";import{t as g}from"./arrow-left-CpIR4j7G.js";import{c as _,g as v,h as y,i as b,m as x,o as S,t as C,u as w}from"./useBrowserCaptureSession-CkBJShUw.js";import{n as T,u as E}from"./MinimizedChatsContext-Cs34FPTz.js";import{n as D,t as ee}from"./external-link-BcU5EWZp.js";import{t as te}from"./circle-x-CMYsN4ZH.js";import{t as O}from"./download-CFHyyHcw.js";import{t as ne}from"./file-text-CFT-xXKN.js";import{t as k}from"./git-branch-BRM0F5GN.js";import{t as re}from"./loader-circle-DcygOQpC.js";import{t as ie}from"./pencil-C9RkrIPZ.js";import{t as ae}from"./play-DNlrawbS.js";import{t as oe}from"./plus-CsnjfkmX.js";import{t as se}from"./save-28sIlCdr.js";import{t as A}from"./search-Cq_gE3Ik.js";import{t as ce}from"./trash-2-BOU3WdZZ.js";import{t as le}from"./triangle-alert-H9T4jAmh.js";import{t as ue}from"./x-CBMI9ejn.js";import{t as de}from"./zap-CHo3aCD1.js";import{a as j}from"./auth-D_5bQv5W.js";import{n as M}from"./useSharedWebSocket-DaPh7QBL.js";import{t as N}from"./api-B2M7CtDw.js";import{r as P}from"./useDesktop-B4pSBIDd.js";import{t as F}from"./button-BUIIBQPT.js";import{t as I}from"./utils-BC4DHlz2.js";import{a as fe,c as pe,i as me,n as he,o as ge,r as _e,s as ve,t as ye}from"./dialog-CzIekCw0.js";import{t as L}from"./jira-api-BgFIr8eD.js";import{n as be,t as xe}from"./lib-CGdyxIWg.js";import{t as R}from"./formatDistanceToNow-ByKli7Q_.js";import{n as Se}from"./spending-DMnCXy84.js";var Ce=m(`circle-arrow-right`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m12 16 4-4-4-4`,key:`1i9zcv`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]]),we=m(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Te=m(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),Ee=m(`file-minus-corner`,[[`path`,{d:`M20 14V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12`,key:`l9p8hp`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),z=m(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),B=m(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),De=m(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),V=m(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),H=m(`split`,[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M8 3H3v5`,key:`15dfkv`}],[`path`,{d:`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,key:`1qrqzj`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}]]),U=m(`ticket`,[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]),W=new Map,Oe=2e3;function ke(e){W.set(e,(W.get(e)??0)+1)}function Ae(e){(W.get(e)??0)<=0||setTimeout(()=>{let t=(W.get(e)??0)-1;t<=0?W.delete(e):W.set(e,t)},Oe)}function je(e){return e?(W.get(e)??0)>0:!1}var G=e(t(),1),Me=3e3,Ne=`
|
|
3
3
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## Contract Layer
|
|
7
7
|
|
|
8
|
-
`;function K(e){return`${j}/api/projects/${encodeURIComponent(e)}`}function Pe(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Fe(e,t){let n=new Map(e.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.id);return t&&Pe(t,e)?t:e});return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r}function Ie(){let{t:e}=p(`tickets`),{activeProjectId:t}=P(),[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(new Set),[u,d]=(0,G.useState)(new Set),f=(0,G.useRef)(t);f.current=t;let m=(0,G.useRef)(0),g=(0,G.useRef)(null),_=(0,G.useRef)(new Set),{registerHandler:v,unregisterHandler:y,connectionStatus:b}=M(),x=(0,G.useId)(),S=(0,G.useCallback)(async(e,t)=>{let n=K(e),r=await fetch(`${n}/tickets`,{signal:t,cache:`no-store`});if(!r.ok)throw Error(`Failed to fetch tickets: ${r.status}`);let i=await r.json();return Array.isArray(i)?i:i.tickets??[]},[]),C=(0,G.useCallback)(async(t,n)=>{let i=++m.current;g.current?.abort();let o=new AbortController;g.current=o,f.current===t&&(a(!0),s(null));try{let a=await S(t,o.signal);if(o.signal.aborted||i!==m.current||f.current!==t)return;let s=_.current,c=new Set;if(n===`merge`)for(let e of a)s.size>0&&!s.has(e.id)&&c.add(e.id);_.current=new Set(a.map(e=>e.id)),r(n===`replace`?a:e=>Fe(e,a)),c.size>0&&s.size>0&&(l(c),h.success(e(`toasts.newTicketsAdded`,{count:c.size}),{id:`tickets-added-${t}`}),setTimeout(()=>{f.current===t&&l(e=>{let t=new Set(e);for(let e of c)t.delete(e);return t})},Me))}catch(e){if(o.signal.aborted||i!==m.current||f.current!==t)return;s(e instanceof Error?e.message:String(e))}finally{i===m.current&&(g.current===o&&(g.current=null),f.current===t&&a(!1))}},[S,e]),w=(0,G.useCallback)(async()=>{t&&await C(t,`merge`)},[t,C]);(0,G.useEffect)(()=>{if(m.current+=1,g.current?.abort(),g.current=null,r([]),a(!1),s(null),_.current=new Set,l(new Set),d(new Set),t)return C(t,`replace`),()=>{m.current+=1,g.current?.abort(),g.current=null}},[t,C]);let T=(0,G.useCallback)(t=>{let n=t;if(!n||typeof n.type!=`string`)return;let i=f.current;if(!(n.projectId&&n.projectId!==i))switch(n.type){case`mcp.activity`:n.affectedProjectId&&n.affectedProjectId===i&&w();break;case`ticket_created`:{if(!n.ticket)break;let t=n.ticket;r(e=>e.some(e=>e.id===t.id)?e:[...e,t]),_.current.add(t.id),l(e=>new Set([...e,t.id])),je(i)||h.success(e(`toasts.newTicket`,{title:t.title}),{id:`new-ticket-${t.id}`}),setTimeout(()=>{l(e=>{let n=new Set(e);return n.delete(t.id),n})},Me);break}case`ticket_updated`:{if(!n.ticket)break;if(n.ticket.id===0){w();break}let e=n.ticket;r(t=>t.map(t=>t.id===e.id?e:t)),typeof e.description==`string`&&e.description.includes(Ne)&&d(t=>{if(!t.has(e.id))return t;let n=new Set(t);return n.delete(e.id),n});break}case`ticket_deleted`:{if(n.ticketId==null)break;let e=n.ticketId;r(t=>t.filter(t=>t.id!==e)),_.current.delete(e);break}case`explore.contract_refine_started`:if(n.ticketId==null)break;d(e=>new Set([...e,n.ticketId]));break;case`explore.contract_refine_failed`:{if(n.ticketId==null)break;let e=n.ticketId;d(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n});break}}},[w,e]);(0,G.useLayoutEffect)(()=>(v(`tickets-${x}`,T),()=>y(`tickets-${x}`)),[T,v,y,x]);let E=(0,G.useRef)(b);return(0,G.useEffect)(()=>{E.current!==`connected`&&b===`connected`&&f.current&&w(),E.current=b},[b,w]),{tickets:n,loading:i,isLoading:i,error:o,newTicketIds:c,contractRefiningIds:u,refetch:w,refresh:w,deleteTicket:(0,G.useCallback)(async e=>{let n=t;if(!n)return!1;try{let t=await fetch(`${K(n)}/tickets/${e}`,{method:`DELETE`});return t.ok&&f.current===n&&await C(n,`merge`),t.ok}catch{return!1}},[t,C]),updateTicketStatus:(0,G.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${K(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({status:n})});return t.ok&&f.current===r&&await C(r,`merge`),t.ok}catch{return!1}},[t,C]),updateTicketPriority:(0,G.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${K(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({priority:n})});return t.ok&&f.current===r&&await C(r,`merge`),t.ok}catch{return!1}},[t,C]),createTicket:(0,G.useCallback)(async e=>{let n=t;if(!n)return!1;try{let t=await fetch(`${K(n)}/tickets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return t.ok&&f.current===n&&await C(n,`merge`),t.ok}catch{return!1}},[t,C]),updateTicket:(0,G.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${K(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});return t.ok&&f.current===r&&await C(r,`merge`),t.ok}catch{return!1}},[t,C])}}var q=n(),Le=224,Re=8,ze=8;function Be({rails:e,onMoveToRail:t,onClose:n,anchorRect:r}){let{t:i}=p(`tickets`),a=(0,G.useRef)(null),[o,s]=(0,G.useState)(!1);(0,G.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>s(!0));return()=>cancelAnimationFrame(e)},[]),(0,G.useEffect)(()=>{function e(e){a.current&&(a.current.contains(e.target)||n())}function t(e){e.key===`Escape`&&n()}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[n]);let{top:c,left:l,caretLeft:u}=(0,G.useMemo)(()=>{let e=r.left+r.width/2,t=e-Le/2,n=window.innerWidth-Le-Re,i=Math.max(Re,Math.min(n,t)),a=e-i,o=Math.max(12,Math.min(Le-12,a));return{top:r.bottom+ze,left:i,caretLeft:o}},[r]);return(0,q.jsxs)(`div`,{ref:a,role:`dialog`,"aria-label":i(`rail.popoverTitle`),"data-testid":`move-to-rail-popover`,style:{top:c,left:l,width:Le,opacity:+!!o,transform:o?`translateY(0) scale(1)`:`translateY(-4px) scale(0.97)`,transformOrigin:`${u}px top`,transition:`opacity 140ms ease-out, transform 160ms cubic-bezier(0.2, 0.9, 0.3, 1)`},className:`fixed z-50 rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/40 p-1`,children:[(0,q.jsx)(`div`,{"aria-hidden":!0,className:`absolute w-2 h-2 rotate-45 bg-card/95 border-l border-t border-border/60`,style:{top:-5,left:u-4}}),(0,q.jsx)(`div`,{className:`px-2 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground/70 font-medium`,children:i(`rail.popoverTitle`)}),e.length===0?(0,q.jsx)(`div`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:i(`rail.noRails`)}):(0,q.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{t(e.id),n()},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-sm hover:bg-accent-info/10 hover:text-accent-info transition-colors`,children:[e.status===`running`?(0,q.jsx)(ae,{className:`w-3 h-3 text-accent-success animate-pulse shrink-0`,"aria-hidden":!0}):(0,q.jsx)(we,{className:`w-3 h-3 text-muted-foreground/60 shrink-0`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),(0,q.jsx)(Ce,{className:`w-3.5 h-3.5 text-muted-foreground/40 shrink-0`,"aria-hidden":!0})]})},e.id))})]})}var J=/\n*##\s*Acceptance Criteria\s*\n([\s\S]*?)(?=\n##\s|\n*$)/i;function Ve(e){if(!e)return{body:``,criteria:[]};let t=J.exec(e);if(!t)return{body:e.replace(/\s+$/,``),criteria:[]};let n=t[1],r=e.slice(0,t.index),i=e.slice(t.index+t[0].length),a=`${r.replace(/\s+$/,``)}${i?`\n\n${i.replace(/^\s+/,``)}`:``}`,o=n.split(/\r?\n/).map(e=>e.replace(/^\s*[-*+]\s+/,``).trim()).filter(e=>e.length>0);return{body:a.replace(/\s+$/,``),criteria:o}}var He=new Set([`draft`,`todo`]);function Y(e){return!!(He.has(e.status)||e.source===`jira`&&e.jira_key&&e.status!==`cancelled`)}function X(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}var Z=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_TERMINAL_PANEL;return typeof e!=`string`||e!==`false`})(),Ue=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENTS_SECTION;return typeof e!=`string`||e!==`false`})(),We=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_CODE_EXPLORER;return typeof e!=`string`||e!==`false`})(),Ge=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_JIRA;return typeof e!=`string`||e!==`false`})(),Ke=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_MCP;return typeof e!=`string`||e!==`false`})(),qe=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENT_CHAT;return typeof e!=`string`||e!==`false`})(),Je=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENT_MODE;return qe&&(typeof e!=`string`||e!==`false`)})();(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_INTERACTIVE_JOBS;return typeof e!=`string`||e!==`false`})();var Ye=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_LOOPS_SECTION;return typeof e!=`string`||e!==`false`})(),Xe=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_PROJECT_BUILDER;return typeof e!=`string`||e!==`false`})();function Ze(){let{activeProjectId:e}=P(),[t,n]=(0,G.useState)({connected:!1,key:null,discardStatus:null}),[r,i]=(0,G.useState)(!0);return(0,G.useEffect)(()=>{if(!Ge||!e){n({connected:!1,key:null,discardStatus:null}),i(!1);return}let t=!1;return i(!0),L.getConnection().then(e=>{if(t)return;let r=!!(e.connected&&e.connection?.enabled);n({connected:r,key:e.connection?.jiraProjectKey??null,discardStatus:r?e.connection?.discardStatus??null:null})}).catch(()=>{t||n({connected:!1,key:null,discardStatus:null})}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),{connected:t.connected,jiraProjectKey:t.key,discardStatus:t.discardStatus,loading:r}}function Qe({open:e,onOpenChange:t,ticket:n,discardStatus:r,onDiscarded:i}){let{t:a}=p(`jira`),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(!1);async function u(){l(!0);try{await L.discardSpec(n.id,o.trim()||null),h.success(a(`discard.movedToast`,{status:r,key:n.jira_key??`#${n.id}`})),t(!1),s(``),i?.()}catch(e){h.error(e instanceof Error?e.message:a(`errors.generic`))}finally{l(!1)}}return(0,q.jsx)(ye,{open:e,onOpenChange:e=>{c||t(e)},children:(0,q.jsxs)(he,{movableResizable:!0,className:`max-w-md`,"data-testid":`jira-discard-dialog`,children:[(0,q.jsxs)(fe,{children:[(0,q.jsx)(ge,{children:a(`discard.title`,{status:r})}),(0,q.jsx)(_e,{children:a(`discard.body`,{status:r,key:n.jira_key??`#${n.id}`})})]}),(0,q.jsxs)(`label`,{className:`block space-y-1`,children:[(0,q.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:a(`discard.commentLabel`)}),(0,q.jsx)(`textarea`,{value:o,onChange:e=>s(e.target.value),placeholder:a(`discard.commentPlaceholder`),rows:3,className:`w-full rounded-md border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-none`,"data-testid":`jira-discard-comment`})]}),(0,q.jsxs)(me,{children:[(0,q.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:c,children:a(`wizard.cancel`)}),(0,q.jsxs)(F,{size:`sm`,onClick:u,disabled:c,"data-testid":`jira-discard-confirm`,children:[(0,q.jsx)(v,{className:`w-3.5 h-3.5 mr-1.5`}),c?a(`discard.moving`):a(`discard.confirm`,{status:r})]})]})]})})}var $e={draft:{dotClass:`bg-accent-secondary/60`,textClass:`text-accent-secondary`,borderClass:`border-l-[3px] border-dashed border-accent-secondary/50 pl-3`,labelKey:`common:status.draft`,pulsing:!1},todo:{dotClass:`bg-slate-500/70`,textClass:`text-muted-foreground`,borderClass:`border-l-[3px] border-dashed border-slate-500/40 pl-3`,labelKey:`status.todo`,pulsing:!1},in_progress:{dotClass:`bg-blue-400 aurora-light:bg-accent-info`,textClass:`text-foreground font-semibold`,borderClass:`border-l-[3px] border-solid border-blue-500 pl-3`,labelKey:`status.inProgress`,pulsing:!0},on_review:{dotClass:`bg-accent-warning/80`,textClass:`text-accent-warning`,borderClass:`border-l-[3px] border-solid border-accent-warning/60 pl-3`,labelKey:`status.onReview`,pulsing:!1},done:{dotClass:`text-emerald-400 aurora-light:text-accent-success`,textClass:`text-emerald-400/80 aurora-light:text-accent-success`,borderClass:`border-l-[3px] border-solid border-emerald-500 pl-3`,labelKey:`status.done`,pulsing:!1},cancelled:{dotClass:`text-red-400/60 aurora-light:text-destructive/70`,textClass:`text-muted-foreground/50`,borderClass:`pl-3`,labelKey:`status.cancelled`,pulsing:!1}};function et({status:e,className:t}){let{t:n}=p(`specs`),r=$e[e];return e===`done`?(0,q.jsx)(D,{className:I(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.done`)}):e===`cancelled`?(0,q.jsx)(ue,{className:I(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.cancelled`)}):r.pulsing?(0,q.jsxs)(`span`,{className:I(`relative flex shrink-0 h-2.5 w-2.5`,t),"aria-label":n(`status.inProgress`),children:[(0,q.jsx)(`span`,{className:I(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,r.dotClass)}),(0,q.jsx)(`span`,{className:I(`relative inline-flex rounded-full h-2.5 w-2.5`,r.dotClass)})]}):(0,q.jsx)(`span`,{className:I(`inline-flex rounded-full h-2.5 w-2.5 shrink-0`,r.dotClass,t),"aria-label":n(r.labelKey)})}function tt({status:e,className:t}){let{t:n}=p(`specs`),r=$e[e];return(0,q.jsxs)(`span`,{className:I(`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[11px] font-medium border`,e===`todo`&&`bg-slate-500/10 border-slate-500/30 text-slate-400 aurora-light:bg-muted aurora-light:border-border aurora-light:text-muted-foreground`,e===`in_progress`&&`bg-blue-500/10 border-blue-500/30 text-blue-400 aurora-light:bg-accent-info/10 aurora-light:border-accent-info/30 aurora-light:text-accent-info`,e===`on_review`&&`bg-accent-warning/10 border-accent-warning/30 text-accent-warning`,e===`done`&&`bg-emerald-500/10 border-emerald-500/30 text-emerald-400 aurora-light:bg-accent-success/10 aurora-light:border-accent-success/30 aurora-light:text-accent-success`,e===`cancelled`&&`bg-red-500/10 border-red-500/30 text-red-400/60 aurora-light:bg-destructive/10 aurora-light:border-destructive/30 aurora-light:text-destructive/70`,t),children:[(0,q.jsx)(et,{status:e}),n(r.labelKey)]})}async function nt(e,t,n){let r=new FormData;r.append(`file`,t);let i=await fetch(`${N()}/tickets/${e}/attachments`,{method:`POST`,body:r,signal:n});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??u.t(`attachments:errors.uploadFailed`,{status:i.status}))}return(await i.json()).attachment}async function rt(e,t){let n=await fetch(`${N()}/tickets/${e}/attachments/${t}`,{method:`DELETE`});if(!n.ok&&n.status!==404)throw Error(u.t(`attachments:errors.deleteFailed`,{status:n.status}))}async function it(e){let t=await fetch(`${N()}/tickets/${e}/attachments`,{method:`DELETE`});if(!t.ok&&t.status!==404)throw Error(u.t(`attachments:errors.bulkDeleteFailed`,{status:t.status}))}async function at(e){let t=await fetch(`${N()}/tickets/${e}/attachments`);if(!t.ok)throw Error(u.t(`attachments:errors.listFailed`,{status:t.status}));return(await t.json()).attachments}function ot(e,t){return`${N()}/tickets/${e}/attachments/${t}`}async function st(e,t){let n=await fetch(ot(e,t));if(!n.ok)throw Error(u.t(`attachments:errors.fetchFailed`,{status:n.status}));return n.blob()}var ct=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/csv,text/plain,application/json,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/sql,application/x-sql,text/sql,text/x-sql,.sql`,lt=new Set(ct.split(`,`).filter(e=>!e.startsWith(`.`))),ut=/\.sql$/i,dt=/\.(png|jpe?g|gif|webp)$/i;function ft(e){return lt.has(e.type)||ut.test(e.name)||dt.test(e.name)}function pt(){return typeof window<`u`&&window.__TAURI_INTERNALS__!==void 0}function mt(e){return Function(`s`,`return import(s)`)(e).catch(()=>null)}async function ht(e){if(pt()){try{let t=await mt(`@tauri-apps/plugin-opener`);if(t?.revealItemInDir){await t.revealItemInDir(e);return}}catch{}try{await(await mt(`@tauri-apps/api/shell`))?.open?.(e)}catch{}}}async function Q(e){if(pt())try{let t=await i(()=>import(`./dist-js-Dj72W6qo.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71]));if(typeof t.open==`function`){await t.open(e);return}}catch(e){console.warn(`[openExternalUrl] tauri shell open failed:`,e)}try{window.open(e,`_blank`,`noopener,noreferrer`)}catch{}}function gt(e,t){let n=()=>l(t?.in,NaN),r=t?.additionalDigits??2,i=xt(e),a;if(i.date){let e=St(i.date,r);a=Ct(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,u;if(i.time&&(s=Tt(i.time),isNaN(s)))return n();if(i.timezone){if(u=Dt(i.timezone),isNaN(u))return n()}else{let e=new Date(o+s),n=c(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return c(o+s+u,t?.in)}var _t={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},vt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,yt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,bt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function xt(e){let t={},n=e.split(_t.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],_t.timeZoneDelimiter.test(t.date)&&(t.date=e.split(_t.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=_t.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function St(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function Ct(e,t){if(t===null)return new Date(NaN);let n=e.match(vt);if(!n)return new Date(NaN);let r=!!n[4],i=wt(n[1]),a=wt(n[2])-1,o=wt(n[3]),s=wt(n[4]),c=wt(n[5])-1;if(r)return Nt(t,s,c)?Ot(t,s,c):new Date(NaN);{let e=new Date(0);return!jt(t,a,o)||!Mt(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function wt(e){return e?parseInt(e):1}function Tt(e){let t=e.match(yt);if(!t)return NaN;let n=Et(t[1]),r=Et(t[2]),i=Et(t[3]);return Pt(n,r,i)?n*o+r*d+i*1e3:NaN}function Et(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function Dt(e){if(e===`Z`)return 0;let t=e.match(bt);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return Ft(r,i)?n*(r*o+i*d):NaN}function Ot(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}var kt=[31,null,31,30,31,30,31,31,30,31,30,31];function At(e){return e%400==0||e%4==0&&e%100!=0}function jt(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(kt[t]||(At(e)?29:28))}function Mt(e,t){return t>=1&&t<=(At(e)?366:365)}function Nt(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function Pt(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function Ft(e,t){return t>=0&&t<=59}function It({ticketKey:e,attachment:t,onClose:n}){let{t:r}=p(`attachments`),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(null);if((0,G.useEffect)(()=>{if(!t)return;function e(e){e.key===`Escape`&&n()}document.addEventListener(`keydown`,e);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=r}},[t,n]),(0,G.useEffect)(()=>{if(!t){a(null),s(null);return}let n=!1;return a(null),s(null),st(e,t.id).then(e=>{n||a(URL.createObjectURL(e))}).catch(e=>{n||s(e instanceof Error?e.message:r(`errors.loadFailed`))}),()=>{n=!0}},[t,e]),(0,G.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),!t)return null;let c=t.mimeType.startsWith(`image/`),l=t.mimeType===`application/pdf`;return(0,q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":r(`lightbox.preview`,{name:t.filename}),className:`fixed inset-0 z-[100] flex flex-col bg-black/85 backdrop-blur-sm animate-in fade-in-0 duration-200`,onClick:n,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-white/10 bg-black/40`,onClick:e=>e.stopPropagation(),children:[(0,q.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":r(`lightbox.backToDesktop`),className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-white/85 hover:bg-white/10 hover:text-white transition-colors`,children:[(0,q.jsx)(g,{className:`w-4 h-4`}),r(`common:actions.back`)]}),(0,q.jsxs)(`div`,{className:`flex-1 text-center min-w-0 px-4`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-white/95 truncate`,children:t.filename}),(0,q.jsx)(`div`,{className:`text-[11px] text-white/50`,children:t.mimeType})]}),(0,q.jsxs)(`a`,{href:i??`#`,download:t.filename,onClick:e=>{e.stopPropagation(),i||e.preventDefault()},className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-white/85 hover:bg-white/10 hover:text-white transition-colors`,"aria-label":r(`lightbox.download`),children:[(0,q.jsx)(O,{className:`w-4 h-4`}),r(`lightbox.download`)]})]}),(0,q.jsx)(`div`,{className:I(`flex-1 flex items-center justify-center overflow-auto p-6`),onClick:n,children:o?(0,q.jsx)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/80 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:(0,q.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loadError`,{error:o})})}):i?c?(0,q.jsx)(`img`,{src:i,alt:t.filename,onClick:e=>e.stopPropagation(),className:`max-h-full max-w-full rounded-lg shadow-2xl animate-in zoom-in-95 duration-200`}):l?(0,q.jsx)(`iframe`,{src:i,title:t.filename,onClick:e=>e.stopPropagation(),className:`w-full h-full max-w-5xl bg-white rounded-lg shadow-2xl`}):(0,q.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/80 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:[(0,q.jsx)(`p`,{className:`text-sm mb-3`,children:r(`lightbox.previewUnavailable`)}),(0,q.jsxs)(`a`,{href:i,download:t.filename,className:`inline-flex items-center gap-2 px-4 py-2 rounded-md bg-white/10 hover:bg-white/20 text-white transition-colors`,children:[(0,q.jsx)(O,{className:`w-4 h-4`}),r(`lightbox.downloadFile`,{name:t.filename})]})]}):(0,q.jsx)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/70 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:(0,q.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loading`)})})})]})}function Lt(e,t){let n=new Set,r=[];for(let i of[...e,...t])n.has(i.id)||(n.add(i.id),r.push(i));return r}function Rt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function zt(e){return e.startsWith(`image/`)?`🖼`:e===`application/pdf`?`📄`:e===`text/csv`||e.includes(`spreadsheetml`)||e===`application/vnd.ms-excel`?`📊`:e===`application/json`?`{ }`:e===`text/plain`||e.includes(`sql`)?`📝`:`📎`}function Bt(e){try{return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}catch{return e}}function Vt({ticketKey:e,attachments:t,onChange:n,className:r}){let{t:i}=p(`attachments`),[a,o]=(0,G.useState)(new Set),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null);if((0,G.useEffect)(()=>{let r=!1;return at(e).then(e=>{if(r)return;let i=Lt(t,e);i.length!==t.length&&n?.(i)}).catch(()=>{}),()=>{r=!0}},[e]),!t||t.length===0)return null;let d=[...t].sort((e,t)=>e.addedAt<t.addedAt?1:-1);async function f(r){c(null),o(e=>{let t=new Set(e);return t.add(r.id),t});try{await rt(e,r.id),await new Promise(e=>setTimeout(e,160)),n?.(t.filter(e=>e.id!==r.id))}catch(e){c(e instanceof Error?e.message:i(`errors.removeFailed`)),o(e=>{let t=new Set(e);return t.delete(r.id),t})}}return(0,q.jsxs)(`section`,{className:I(`mt-4`,r),"aria-label":i(`section.ariaLabel`),children:[(0,q.jsxs)(`header`,{className:`flex items-center justify-between mb-2`,children:[(0,q.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:i(`section.title`)}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`section.fileCount`,{count:d.length})})]}),(0,q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:d.map(e=>{let t=a.has(e.id);return(0,q.jsxs)(`li`,{className:I(`flex items-center gap-3 px-2.5 py-2 rounded-md border border-border bg-card/60 hover:bg-card transition-all duration-200`,t&&`opacity-0 scale-95 max-h-0 py-0 border-transparent overflow-hidden`),children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`w-6 text-center text-sm shrink-0`,children:zt(e.mimeType)}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:`flex-1 min-w-0 flex flex-col text-sm text-left hover:text-primary transition-colors`,children:[(0,q.jsx)(`span`,{className:`font-medium truncate text-foreground`,children:e.filename}),(0,q.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[Rt(e.size),` · `,Bt(e.addedAt)]})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`text-[11px] text-primary hover:underline shrink-0`,children:i(`common:actions.open`)}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>f(e),"aria-label":i(`removeFile`,{name:e.filename}),disabled:t,className:`w-6 h-6 inline-flex items-center justify-center rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors disabled:opacity-50`,children:`×`})]},e.id)})}),s&&(0,q.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:s}),(0,q.jsx)(It,{ticketKey:e,attachment:l,onClose:()=>u(null)})]})}function Ht({ticketId:e,onClose:t}){let{t:n}=p(`code`),r=a(),{activeProjectId:i}=P(),[o,s]=(0,G.useState)(null);return(0,G.useEffect)(()=>{if(!We)return;let t=new AbortController;return s(null),fetch(`${N()}/code/provenance?ticketId=${e}`,{signal:t.signal}).then(e=>e.ok?e.json():[]).then(e=>{s(Array.isArray(e)?e:[])}).catch(e=>{e?.name!==`AbortError`&&s([])}),()=>t.abort()},[e,i]),!We||!o||o.length===0?null:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:n(`ticketFiles.title`)}),(0,q.jsx)(`ul`,{className:`space-y-1`,children:o.map((e,i)=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{t(),r(`/code?path=${encodeURIComponent(e.path)}`)},className:`w-full text-left flex items-center gap-2 rounded px-2 py-1 text-xs hover:bg-muted/40`,children:[(0,q.jsx)(e.kind===`created`?z:e.kind===`deleted`?Ee:ne,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,q.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.path}),e.jobId&&(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground font-mono shrink-0`,title:n(`ticketFiles.jobTitle`,{jobId:e.jobId}),children:[(0,q.jsx)(B,{className:`h-3 w-3`}),e.jobId.length>10?e.jobId.slice(0,10):e.jobId]}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider shrink-0`,children:n(`kind.${e.kind}`)})]})},`${e.path}-${i}`))})]})}var Ut={critical:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,high:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,medium:``,low:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`};function Wt(e){try{return R(new Date(e),{addSuffix:!0,locale:s()})}catch{return e}}function Gt({tickets:e,excludeIds:t,onSelect:n}){let{t:r}=p(`tickets`),[i,a]=(0,G.useState)(``),o=(0,G.useMemo)(()=>{let n=new Set(t),r=e.filter(e=>e.status!==`cancelled`&&!n.has(e.id));if(!i.trim())return r;let a=i.toLowerCase();return r.filter(e=>e.title.toLowerCase().includes(a)||e.description.toLowerCase().includes(a))},[e,t,i]);return(0,q.jsxs)(`div`,{"data-testid":`spec-compare-picker`,className:`h-full flex flex-col rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`px-4 py-3 border-b border-border/30 flex items-center gap-2`,children:[(0,q.jsx)(U,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:r(`comparePicker.title`)}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`comparePicker.count`,{n:o.length})})]}),(0,q.jsx)(`div`,{className:`px-4 py-2 border-b border-border/20`,children:(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(A,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,q.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:r(`comparePicker.searchPlaceholder`),className:`w-full h-7 rounded border border-border bg-input pl-7 pr-2 text-[11px] text-foreground placeholder:text-muted-foreground outline-none focus:border-accent-primary/60`})]})}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`spec-compare-picker-list`,children:o.length===0?(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center px-4 py-8 gap-2`,children:[(0,q.jsx)(U,{className:`w-6 h-6 text-muted-foreground/40`}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.trim()?r(`comparePicker.noMatches`):r(`comparePicker.empty`)})]}):(0,q.jsx)(`ul`,{className:`divide-y divide-border/10`,children:o.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,"data-testid":`spec-compare-card-${e.id}`,onClick:()=>n(e.id),className:`w-full text-left px-4 py-2.5 hover:bg-accent/30 transition-colors flex items-start gap-2 group`,children:[(0,q.jsx)(et,{status:e.status}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:[`#`,e.id]}),e.priority&&Ut[e.priority]&&(0,q.jsx)(`span`,{className:`inline-flex items-center rounded px-1 py-0.5 text-[9px] font-medium border ${Ut[e.priority]}`,children:r(`priority.${e.priority}`)})]}),(0,q.jsx)(`p`,{className:`mt-0.5 text-xs text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title||r(`untitled`)}),e.description&&(0,q.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground line-clamp-1`,children:e.description.slice(0,120)}),e.labels&&e.labels.length>0&&(0,q.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[e.labels.slice(0,3).map(e=>(0,q.jsx)(`span`,{className:`inline-flex items-center rounded px-1 py-0.5 text-[9px] bg-accent/40 text-foreground/60`,children:e},e)),e.labels.length>3&&(0,q.jsxs)(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.labels.length-3]})]}),(0,q.jsx)(`p`,{className:`mt-1 text-[9px] text-muted-foreground`,children:r(`meta.updatedAgo`,{time:Wt(e.updated_at)})})]})]})},e.id))})})]})}var Kt=.25,qt=.75;function Jt({state:e,leftTicket:t,rightTicket:n,allTickets:r,allLabels:i,onSave:a,onDelete:o,onOpenTicket:s,onCloseAll:c,onSetCompared:l,onSetRatio:u,onExitSplit:d}){let f=(0,G.useRef)(null),p=(0,G.useRef)(null),[m,h]=(0,G.useState)(!0);(0,G.useEffect)(()=>{let e=setTimeout(()=>h(!1),320);return()=>clearTimeout(e)},[]);let g=(0,G.useCallback)(e=>{if(!p.current)return;let t=window.innerWidth,n=e.clientX/t;u(Math.min(qt,Math.max(Kt,n)))},[u]),_=(0,G.useCallback)(e=>{if(!p.current)return;let{pointerId:t,element:n}=p.current;try{n.releasePointerCapture(t)}catch{}p.current=null,window.removeEventListener(`pointermove`,g),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,_)},[g]),v=(0,G.useCallback)(e=>{let t=e.currentTarget;try{t.setPointerCapture(e.pointerId)}catch{}p.current={pointerId:e.pointerId,element:t},window.addEventListener(`pointermove`,g),window.addEventListener(`pointerup`,_),window.addEventListener(`pointercancel`,_)},[g,_]);(0,G.useEffect)(()=>()=>{window.removeEventListener(`pointermove`,g),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,_);let e=p.current;if(e){try{e.element.releasePointerCapture(e.pointerId)}catch{}p.current=null}},[g,_]);let y=(0,G.useCallback)(t=>{let n=.04;t.key===`ArrowLeft`?(t.preventDefault(),u(Math.max(Kt,e.splitRatio-n))):t.key===`ArrowRight`?(t.preventDefault(),u(Math.min(qt,e.splitRatio+n))):t.key===`Home`?(t.preventDefault(),u(Kt)):t.key===`End`?(t.preventDefault(),u(qt)):t.key===`0`&&(t.preventDefault(),u(.5))},[u,e.splitRatio]),b=e=>{e.target===e.currentTarget&&c()},x=u=>{let d=u===e.originSide,f=u===`left`?t:n;return f?(0,q.jsx)(Un,{ticket:f,allLabels:i,allTickets:r,onClose:d?c:()=>l(null,u),onOpenTicket:s,onSave:a,onDelete:o,embedded:!0},`${u}-${f.id}`):(0,q.jsx)(Gt,{tickets:r,excludeIds:[t?.id,n?.id].filter(e=>e!=null),onSelect:e=>l(e,u)})},S=(e.splitRatio*100).toFixed(2),C=((1-e.splitRatio)*100).toFixed(2);return(0,q.jsxs)(`div`,{ref:f,"data-testid":`split-view-shell`,className:`fixed inset-0 z-[68] flex`,onClick:b,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/70 pointer-events-none`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`relative flex w-full h-full`,style:{transition:m?`opacity 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:[(0,q.jsx)(`div`,{"data-testid":`split-panel-left`,className:`relative h-full overflow-hidden`,style:{width:`${S}%`,transition:m?`width 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:(0,q.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,q.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`left`)})})}),(0,q.jsx)(`div`,{"data-testid":`split-divider`,role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":Math.round(e.splitRatio*100),"aria-valuemin":Math.round(Kt*100),"aria-valuemax":Math.round(qt*100),tabIndex:0,onPointerDown:v,onKeyDown:y,className:`relative z-10 w-2 cursor-col-resize bg-border/40 hover:bg-accent-primary/40 transition-colors focus:outline-none focus:bg-accent-primary/60`}),(0,q.jsx)(`div`,{"data-testid":`split-panel-right`,className:`relative h-full overflow-hidden`,style:{width:`${C}%`,transition:m?`width 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:(0,q.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,q.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`right`)})})})]})]})}var Yt=.5,Xt=.25,Zt=.75,Qt={leftId:null,rightId:null,originSide:null,splitRatio:Yt};function $t(e){return Number.isFinite(e)?Math.min(Zt,Math.max(Xt,e)):Yt}function en(e,t){switch(t.type){case`openCentered`:return e.originSide!==null&&e.leftId!==t.id&&e.rightId!==t.id?{leftId:t.id,rightId:null,originSide:null,splitRatio:Yt}:e.originSide!==null&&(e.leftId===t.id||e.rightId===t.id)?e:{...Qt,leftId:t.id};case`closeAll`:return Qt;case`enterSplit`:{let n=t.ticketId??e.leftId;return n===null||e.originSide!==null?e:t.side===`left`?{leftId:n,rightId:null,originSide:`left`,splitRatio:Yt}:{leftId:null,rightId:n,originSide:`right`,splitRatio:Yt}}case`setComparedTicket`:{if(e.originSide===null)return e;let n=e.originSide===`left`?`right`:`left`;return t.side===n?t.side===`left`?{...e,leftId:t.id}:{...e,rightId:t.id}:e}case`exitSplit`:{if(e.originSide===null)return e;let t=e.originSide===`left`?e.leftId:e.rightId;return{...Qt,leftId:t}}case`setSplitRatio`:return{...e,splitRatio:$t(t.ratio)};default:return e}}var tn=(0,G.createContext)(null),nn=900;function rn({children:e}){let[t,n]=(0,G.useReducer)(en,Qt),{tickets:r,updateTicket:i,deleteTicket:a}=Ie(),{activeProjectId:o,setActiveProjectId:s}=P(),c=(0,G.useRef)(null);(0,G.useEffect)(()=>{n({type:`closeAll`});let e=c.current;e&&(c.current=null,e.projectId===o&&n({type:`openCentered`,id:e.ticketId}))},[o]);let l=(0,G.useCallback)(e=>n({type:`openCentered`,id:e}),[]),u=(0,G.useCallback)((e,t)=>{if(e===o){n({type:`openCentered`,id:t});return}c.current={projectId:e,ticketId:t},s(e)},[o,s]),d=(0,G.useCallback)(()=>n({type:`closeAll`}),[]),f=(0,G.useCallback)((e,t)=>{typeof window<`u`&&window.innerWidth<nn||n({type:`enterSplit`,side:e,ticketId:t})},[]),p=(0,G.useCallback)((e,t)=>n({type:`setComparedTicket`,id:e,side:t}),[]),m=(0,G.useCallback)(()=>n({type:`exitSplit`}),[]),h=(0,G.useCallback)(e=>n({type:`setSplitRatio`,ratio:e}),[]);(0,G.useEffect)(()=>{if(typeof window>`u`)return;function e(){window.innerWidth<nn&&n({type:`exitSplit`})}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let g=(0,G.useMemo)(()=>{let e=new Set;for(let t of r)for(let n of t.labels??[])e.add(n);return Array.from(e).sort()},[r]),_=t.leftId==null?null:r.find(e=>e.id===t.leftId)??null,v=t.rightId==null?null:r.find(e=>e.id===t.rightId)??null,y=(0,G.useMemo)(()=>({openTicketDetail:l,openTicketDetailInProject:u,closeTicketDetail:d,enterSplit:f,setComparedTicket:p,exitSplit:m,setSplitRatio:h,state:t}),[l,u,d,f,p,m,h,t]),b=t.originSide!==null;return(0,q.jsxs)(tn.Provider,{value:y,children:[e,!b&&_&&(0,q.jsx)(Un,{ticket:_,allLabels:g,allTickets:r,onClose:d,onOpenTicket:l,onSave:i,onDelete:a},_.id),b&&(0,q.jsx)(Jt,{state:t,leftTicket:_,rightTicket:v,allTickets:r,allLabels:g,onSave:i,onDelete:a,onOpenTicket:l,onCloseAll:d,onSetCompared:p,onSetRatio:h,onExitSplit:m})]})}function an(){return(0,G.useContext)(tn)||{openTicketDetail:()=>{typeof console<`u`&&console.warn(`[TicketDetailModalContext] openTicketDetail called without provider`)},openTicketDetailInProject:()=>{typeof console<`u`&&console.warn(`[TicketDetailModalContext] openTicketDetailInProject called without provider`)},closeTicketDetail:()=>{},enterSplit:()=>{},setComparedTicket:()=>{},exitSplit:()=>{},setSplitRatio:()=>{},state:Qt}}function on(e){return e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function sn(e){return e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function cn({ticketId:e}){let{t}=p(`tickets`),[n,r]=(0,G.useState)(null),i=a(),{activeProjectId:o}=P(),{closeTicketDetail:s}=an();if((0,G.useEffect)(()=>{let t=new AbortController;return r(null),fetch(`${N()}/tickets/${e}/spending-summary`,{signal:t.signal}).then(e=>e.ok?e.json():null).then(e=>{e&&r(e)}).catch(()=>{}),()=>t.abort()},[e,o]),!n||!n.bySurface||!n.totalRuns||n.totalRuns===0)return null;let c=Object.entries(n.bySurface).filter(([,e])=>e.count>0).map(([e,n])=>t(`spendingLine.breakdownItem`,{n:n.count,label:Se[e].toLowerCase()})).join(` + `);return(0,q.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(),i(`/analytics?ticketId=${e}`)},className:`mt-1.5 group inline-flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,"aria-label":t(`spendingLine.ariaLabel`),children:[(0,q.jsxs)(`span`,{className:`tabular-nums font-medium text-foreground`,title:(n.estimatedCostUsd??0)>0?t(`spendingLine.estimatedTooltip`):void 0,children:[(n.estimatedCostUsd??0)>0?`~`:``,on(n.totalCostUsd)]}),(0,q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:t(`spendingLine.turns`,{count:n.totalTurns})}),(0,q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:t(`spendingLine.active`,{duration:sn(n.activeDurationMs)})}),c&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,q.jsx)(`span`,{children:c})]}),(0,q.jsx)(v,{className:`w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity`})]})}var ln=/^\d{4}-\d{2}-\d{2}T/;function un(e){if(ln.test(e))try{return{text:R(gt(e),{addSuffix:!0,locale:s()}),title:e}}catch{}return{text:e}}function dn({localId:e}){let{t}=p(`jira`),{activeProjectId:n}=P(),r=Ze(),[i,a]=(0,G.useState)(null);if((0,G.useEffect)(()=>{if(!Ge||!r.connected)return;let t=!1;return a(null),L.getSpecDetails(e).then(e=>{t||a(e)}).catch(()=>{t||a(null)}),()=>{t=!0}},[e,n,r.connected]),!Ge||!r.connected||!i)return null;let o=i.development,s=i.fields.length>0,c=o.pullRequests.length>0,l=o.branches.length>0,u=(o.commits?.length??0)>0;return!s&&!c&&!l&&!u?null:(0,q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-details-panel`,children:[s&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.detailsTitle`)}),(0,q.jsx)(`div`,{className:`space-y-1.5`,children:i.fields.map((e,t)=>{let n=un(e.value);return(0,q.jsxs)(`div`,{className:`text-xs`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block`,children:e.label}),e.href?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.href)},className:`inline-flex items-center gap-1 text-accent-info hover:underline text-left`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:e.value}),(0,q.jsx)(ee,{className:`w-3 h-3 shrink-0`})]}):(0,q.jsx)(`span`,{className:`text-foreground/80 whitespace-pre-line`,title:n.title,children:n.text})]},`${e.label}-${t}`)})})]}),(c||l||u)&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.developmentTitle`)}),c&&(0,q.jsxs)(`div`,{className:`mb-2`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.pullRequests`)}),(0,q.jsx)(`div`,{className:`space-y-1`,children:o.pullRequests.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.url)},className:`w-full flex items-start gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-pr`,children:[(0,q.jsx)(De,{className:`w-3 h-3 mt-0.5 shrink-0 text-accent-info`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`truncate text-foreground/80 block`,children:e.title}),(0,q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[e.status,e.sourceBranch?` · ${e.sourceBranch} → ${e.destBranch??``}`:``]})]})]},e.url))})]}),l&&(0,q.jsxs)(`div`,{className:`mb-2`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.branches`)}),(0,q.jsx)(`div`,{className:`space-y-1`,children:o.branches.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.url)},className:`w-full flex items-center gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-branch`,children:[(0,q.jsx)(k,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,q.jsx)(`span`,{className:`truncate font-mono text-foreground/80`,children:e.name}),e.repo&&(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate`,children:e.repo})]},e.url))})]}),u&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.commits`)}),(0,q.jsx)(`div`,{className:`space-y-1`,children:o.commits.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.url)},className:`w-full flex items-center gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-commit`,children:[(0,q.jsx)(B,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:e.displayId}),(0,q.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.message})]},e.url))})]})]})]})}var fn=e(r(),1);function pn({open:e,url:t,projectId:n,onClose:r}){let{t:i}=p(`browser`),a=C({projectId:n,open:e,initialUrl:t}),{canvasRef:o,viewport:s,status:c,errorMsg:l,url:u,title:d,popup:f}=a,[m,h]=(0,G.useState)(t),S=(0,G.useRef)(a.forwardInput);S.current=a.forwardInput;let T=(0,G.useRef)(null),E=(0,G.useCallback)(()=>(T.current??=b(e=>S.current(e)),T.current),[]);(0,G.useEffect)(()=>()=>{T.current?.dispose(),T.current=null},[]),(0,G.useEffect)(()=>{u&&h(u)},[u]),(0,G.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,r]);let D=(0,G.useCallback)((e,t)=>{let n=o.current?.getBoundingClientRect();return n?_({x:e,y:t},{left:n.left,top:n.top,width:n.width,height:n.height},s):{x:0,y:0}},[o,s]),te=e=>e===2?`right`:e===1?`middle`:`left`,O=(0,G.useCallback)(e=>{let t=D(e.clientX,e.clientY);E().move(t.x,t.y)},[D,E]),ne=(0,G.useCallback)(e=>{let t=D(e.clientX,e.clientY),n=E();n.move(t.x,t.y),n.flush(),a.forwardInput({type:`mouse`,action:`down`,x:t.x,y:t.y,button:te(e.button),clickCount:e.detail||1})},[D,a,E]),k=(0,G.useCallback)(e=>{let t=D(e.clientX,e.clientY),n=E();n.move(t.x,t.y),n.flush(),a.forwardInput({type:`mouse`,action:`up`,x:t.x,y:t.y,button:te(e.button),clickCount:e.detail||1})},[D,a,E]),re=(0,G.useCallback)(e=>{let t=D(e.clientX,e.clientY);E().wheel(t.x,t.y,e.deltaX,e.deltaY)},[D,E]),ie=(0,G.useCallback)(e=>{if(e.key===`Escape`)return;let t=e.metaKey||e.ctrlKey;if(t&&(e.key===`c`||e.key===`v`||e.key===`x`)){e.preventDefault();let t=e.key;(async()=>{try{if(t===`v`){let e=await navigator.clipboard.readText();e&&await a.clipboard(`paste`,e)}else{let{text:e}=await a.clipboard(t===`x`?`cut`:`copy`);e&&await navigator.clipboard.writeText(e)}}catch{}})();return}let n={type:`key`,action:`down`,key:e.key,code:e.code,text:!t&&e.key.length===1?e.key:void 0};a.forwardInput(n),(e.key===`Tab`||e.key===` `||e.key.startsWith(`Arrow`))&&e.preventDefault()},[a]),ae=(0,G.useCallback)(e=>{e.key!==`Escape`&&a.forwardInput({type:`key`,action:`up`,key:e.key,code:e.code})},[a]),oe=(0,G.useCallback)(()=>{a.navigate(`goto`,m)},[a,m]);return!e||typeof document>`u`?null:(0,fn.createPortal)((0,q.jsx)(`div`,{className:`fixed inset-0 z-[80] bg-background-deep/50 backdrop-blur-sm pointer-events-auto`,onClick:e=>{e.target===e.currentTarget&&r()},"data-testid":`webview-modal`,children:(0,q.jsxs)(`div`,{className:`absolute inset-2 flex flex-col border border-border rounded-lg bg-background-deep overflow-hidden`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`modal.dialogLabel`),onClick:e=>e.stopPropagation(),children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border/50 bg-surface/80 shrink-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`common:actions.back`),onClick:()=>a.navigate(`back`),children:(0,q.jsx)(g,{className:`w-4 h-4`})}),(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.forward`),onClick:()=>a.navigate(`forward`),children:(0,q.jsx)(v,{className:`w-4 h-4`})}),(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.reload`),onClick:()=>a.navigate(`reload`),children:(0,q.jsx)(x,{className:`w-4 h-4`})})]}),(0,q.jsxs)(`form`,{className:`flex-1 flex items-center gap-2 min-w-0`,onSubmit:e=>{e.preventDefault(),oe()},children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0 rounded-md border border-border bg-background px-2.5 py-1`,children:[(0,q.jsx)(y,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,q.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),oe())},placeholder:i(`modal.address.placeholder`),"aria-label":i(`modal.address.label`),className:`flex-1 min-w-0 bg-transparent outline-none text-sm`})]}),(0,q.jsx)(F,{type:`submit`,size:`sm`,variant:`secondary`,className:`shrink-0`,disabled:c===`error`,children:i(`modal.address.go`)})]}),(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.closeBrowser`),onClick:r,children:(0,q.jsx)(ue,{className:`w-4 h-4`})})]}),(0,q.jsxs)(`div`,{className:`px-3 py-1 text-[11px] text-muted-foreground truncate shrink-0 flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full shrink-0 ${c===`ready`?`bg-accent-success`:c===`error`?`bg-destructive`:`bg-accent-warning animate-pulse`}`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`truncate`,children:c===`connecting`?i(`modal.status.connecting`):c===`error`?l??i(`modal.status.unavailable`):d||``})]}),f&&(0,q.jsxs)(`div`,{"data-testid":`webview-popup-bar`,className:`flex items-center gap-2 px-3 py-1.5 text-xs border-b shrink-0 ${f.active?`bg-accent-info/10 border-accent-info/30 text-accent-info`:`bg-surface/70 border-border/40 text-muted-foreground`}`,children:[(0,q.jsx)(ee,{className:`w-3.5 h-3.5 shrink-0`}),f.active?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`truncate font-medium`,children:i(`popup.loginWindow`,{origin:w(f.url)})}),f.count>1&&(0,q.jsx)(`span`,{className:`shrink-0 opacity-70`,children:i(`popup.stacked`,{count:f.count-1})}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>a.setPopupView(`root`),className:`ml-auto shrink-0 inline-flex items-center gap-1 h-6 px-2 rounded-md border border-current/30 hover:bg-card/60 transition-colors`,children:[(0,q.jsx)(g,{className:`w-3 h-3`}),i(`popup.backToPage`)]})]}):(0,q.jsxs)(`button`,{type:`button`,onClick:()=>a.setPopupView(`popup`),className:`inline-flex items-center gap-1 h-6 px-2 rounded-md border border-border/50 hover:bg-card/60 hover:text-foreground transition-colors`,children:[i(`popup.show`),f.count>1&&(0,q.jsx)(`span`,{className:`opacity-70`,children:i(`popup.stacked`,{count:f.count-1})})]})]}),(0,q.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden flex items-center justify-center outline-none`,tabIndex:0,onKeyDown:ie,onKeyUp:ae,children:c===`error`?(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center max-w-md px-6`,children:[(0,q.jsx)(le,{className:`w-8 h-8 text-accent-warning`}),(0,q.jsx)(`p`,{className:`text-sm text-foreground/90`,children:l??i(`modal.error.unavailable`)})]}):(0,q.jsx)(`canvas`,{ref:o,className:`max-w-full max-h-full block shadow-2xl cursor-default`,onPointerMove:O,onPointerDown:ne,onPointerUp:k,onContextMenu:e=>e.preventDefault(),onWheel:re})})]})}),document.body)}var mn=(0,G.createContext)(null);function hn({children:e}){let{activeProjectId:t}=P(),[n,r]=(0,G.useState)(null),i=(0,G.useCallback)(e=>r(e),[]),a=S();return(0,q.jsxs)(mn.Provider,{value:{openWebView:i,canOpenWebView:a&&!!t},children:[e,a&&n&&t&&(0,q.jsx)(pn,{open:!0,url:n,projectId:t,onClose:()=>r(null)})]})}function gn(){return(0,G.useContext)(mn)??{openWebView:()=>{},canOpenWebView:!1}}var _n={analyzing:`activity:smash.stage.analyzing`,identifying:`activity:smash.stage.identifying`,ordering:`activity:smash.stage.ordering`},vn=(0,G.createContext)(null);function $(e){return`smash:${e}`}async function yn(e,t){try{let n=await fetch(`${j}/api/projects/${e}/tickets/${t}/smash`,{method:`POST`});if(n.ok)h.loading(u.t(`activity:smash.retrying`),{id:$(t)});else{let e=await n.json().catch(()=>({}));h.error(e.reason?u.t(`activity:smash.couldNotRetryWithReason`,{reason:e.reason}):u.t(`activity:smash.couldNotRetry`),{id:$(t)})}}catch(e){h.error(u.t(`activity:smash.retryFailed`,{message:e.message}),{id:$(t)})}}async function bn(e,t,n){try{let r=await fetch(`${j}/api/projects/${e}/tickets/${t}/smash/undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({smashedAt:n})});if(r.ok)h.success(u.t(`activity:smash.undone`),{id:$(t),duration:3e3});else{let e=await r.json().catch(()=>({}));h.error(e.reason?u.t(`activity:smash.undoFailedWithReason`,{reason:e.reason}):u.t(`activity:smash.undoFailed`),{id:$(t)})}}catch(e){h.error(u.t(`activity:smash.undoFailedWithReason`,{reason:e.message}),{id:$(t)})}}function xn({children:e}){let{registerHandler:t,unregisterHandler:n}=M(),[r,i]=(0,G.useState)({}),a=(0,G.useRef)(new Map),o=(0,G.useRef)(new Map),s=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.started`)return;let n=t.ticketId,r=t.runId,o=t.projectId,s=t.timestamp,c=t.ticketTitle;typeof n!=`number`||!r||!o||(a.current.set(n,o),i(e=>({...e,[n]:{ticketId:n,runId:r,stage:`analyzing`,startedAt:s??new Date().toISOString(),ticketTitle:c}})),h.loading(u.t(_n.analyzing),{id:$(n),description:c?u.t(`activity:smash.onTitled`,{title:c}):u.t(`activity:smash.onThisSpec`)}))},[]),c=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.progress`)return;let n=t.ticketId,r=t.stage;if(typeof n!=`number`||!r)return;let a;i(e=>{let t=e[n];return t?(a=t.ticketTitle,{...e,[n]:{...t,stage:r}}):e}),h.loading(u.t(_n[r]),{id:$(n),description:a?u.t(`activity:smash.onTitled`,{title:a}):u.t(`activity:smash.onThisSpec`)})},[]),l=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.completed`)return;let n=t.ticketId,r=t.runId,a=t.projectId,s=t.smashedAt,c=t.childrenIds;typeof n!=`number`||!r||!a||!s||!c||(o.current.set(r,s),i(e=>{let t={...e};return delete t[n],t}),h.success(u.t(`activity:smash.split`,{count:c.length}),{id:$(n),duration:1e4,action:{label:u.t(`activity:smash.undoAction`),onClick:()=>void bn(a,n,s)}}))},[]),d=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.failed`)return;let n=t.ticketId,r=t.projectId,o=t.reason??`unknown`;if(typeof n!=`number`||!r)return;a.current.set(n,r),i(e=>{let t={...e};return delete t[n],t});let s=o===`invalid-output`?u.t(`activity:smash.failReason.invalidOutput`):o===`timeout`?u.t(`activity:smash.failReason.timeout`):o===`model_error`?u.t(`activity:smash.failReason.modelError`):o===`crashed`?u.t(`activity:smash.failReason.crashed`):u.t(`activity:smash.failReason.generic`,{reason:o});h.error(u.t(`activity:smash.couldNotComplete`),{id:$(n),description:s,action:{label:u.t(`common:actions.retry`),onClick:()=>void yn(r,n)},duration:15e3})},[]),f=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.undone`)return;let n=t.ticketId;typeof n==`number`&&(h.dismiss($(n)),h.success(u.t(`activity:smash.undone`),{id:$(n),duration:3e3}))},[]);(0,G.useLayoutEffect)(()=>(t(`_smash_started`,s),t(`_smash_progress`,c),t(`_smash_completed`,l),t(`_smash_failed`,d),t(`_smash_undone`,f),()=>{n(`_smash_started`),n(`_smash_progress`),n(`_smash_completed`),n(`_smash_failed`),n(`_smash_undone`)}),[t,n,s,c,l,d,f]),(0,G.useEffect)(()=>()=>{a.current.clear(),o.current.clear()},[]);let p=(0,G.useMemo)(()=>({inflight:r}),[r]);return(0,q.jsx)(vn.Provider,{value:p,children:e})}function Sn(e){let t=(0,G.useContext)(vn);return!t||e==null?null:t.inflight[e]??null}var Cn=150,wn={analyzing:0,identifying:1,ordering:2},Tn={analyzing:`smash.stage.analyzing`,identifying:`smash.stage.identifying`,ordering:`smash.stage.ordering`};function En({stage:e,minDisplayMs:t=Cn}){let{t:n}=p(`activity`),[r,i]=(0,G.useState)(e),a=(0,G.useRef)(Date.now()),o=(0,G.useRef)(null);if((0,G.useEffect)(()=>{if(e===r)return;let n=Date.now()-a.current,s=Math.max(0,t-n);return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i(e),a.current=Date.now(),o.current=null},s),()=>{o.current&&clearTimeout(o.current)}},[e,r,t]),!r)return null;let s=wn[r];return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-md border border-accent-highlight/40 bg-accent-highlight/10 text-sm text-foreground`,role:`status`,"aria-live":`polite`,"data-testid":`smash-status-pills`,children:[(0,q.jsx)(re,{className:`h-4 w-4 animate-spin text-accent-highlight`,"aria-hidden":!0}),(0,q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:[`analyzing`,`identifying`,`ordering`].map(e=>(0,q.jsx)(`span`,{className:[`inline-block w-1.5 h-1.5 rounded-full transition-all`,wn[e]<=s?`bg-accent-highlight`:`bg-muted`,e===r?`scale-125`:`scale-100`].join(` `),"aria-hidden":!0},e))}),(0,q.jsx)(`span`,{className:`font-medium`,children:n(Tn[r])})]})}var Dn={simple:{titleKey:`smashModal.modes.simple.title`,bulletKeys:[`smashModal.modes.simple.bullet1`,`smashModal.modes.simple.bullet2`,`smashModal.modes.simple.bullet3`],etaKey:`smashModal.modes.simple.eta`},full:{titleKey:`smashModal.modes.full.title`,bulletKeys:[`smashModal.modes.full.bullet1`,`smashModal.modes.full.bullet2`,`smashModal.modes.full.bullet3`,`smashModal.modes.full.bullet4`],etaKey:`smashModal.modes.full.eta`}};function On({open:e,ticketTitle:t,isReSmash:n,childrenCount:r,submitting:i=!1,onCancel:a,onConfirm:o}){let{t:s}=p(`activity`),[c,l]=(0,G.useState)(`simple`),{panelRef:u,panelStyle:d,headerHandleProps:m,resizeHandles:h,isFloating:g,guardBackdrop:_}=pe();return e?(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"data-testid":`smash-confirm-modal`,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:_(a)}),(0,q.jsxs)(`div`,{ref:u,className:`relative w-full max-w-lg m-4 rounded-xl glass-card border border-border/30 animate-in fade-in zoom-in-95 duration-150`,style:d,children:[(0,q.jsxs)(`div`,{...m,className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${g?`cursor-grab active:cursor-grabbing`:``}`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,q.jsx)(H,{className:`w-5 h-5 text-accent-highlight shrink-0 mt-0.5`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:s(`smashModal.title`)}),(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate`,title:t,children:t})]})]}),(0,q.jsx)(`button`,{type:`button`,onClick:a,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors shrink-0`,"aria-label":s(`common:actions.close`),children:(0,q.jsx)(ue,{className:`w-4 h-4`})})]}),n&&r>0&&(0,q.jsx)(`div`,{className:`mx-5 mt-4 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:(0,q.jsx)(f,{t:s,i18nKey:`smashModal.reSmashWarning`,count:r})}),(0,q.jsxs)(`div`,{className:`px-5 py-4 space-y-3`,children:[(0,q.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-medium`,children:s(`smashModal.modePickerLabel`)}),[`simple`,`full`].map(e=>{let t=Dn[e],n=c===e;return(0,q.jsx)(`button`,{type:`button`,onClick:()=>l(e),disabled:i,className:`w-full text-left rounded-lg border px-3 py-3 transition-colors ${n?`border-accent-highlight/60 bg-accent-highlight/10`:`border-border/40 bg-card/40 hover:bg-card/60 hover:border-border/60`}`,"data-testid":`smash-mode-${e}`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(`div`,{className:`mt-0.5 h-3.5 w-3.5 rounded-full border-2 shrink-0 ${n?`border-accent-highlight bg-accent-highlight`:`border-muted-foreground/60`}`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[e===`full`&&(0,q.jsx)(de,{className:`w-3.5 h-3.5 text-accent-highlight`,"aria-hidden":!0}),s(t.titleKey)]}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:s(t.etaKey)})]}),(0,q.jsx)(`ul`,{className:`space-y-0.5`,children:t.bulletKeys.map(e=>(0,q.jsxs)(`li`,{className:`text-[11px] text-foreground/70 leading-snug`,children:[`• `,s(e)]},e))})]})]})},e)})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-border/30 bg-surface/20`,children:[(0,q.jsx)(F,{variant:`ghost`,size:`sm`,onClick:a,disabled:i,children:s(`common:actions.cancel`)}),(0,q.jsxs)(F,{size:`sm`,onClick:()=>o(c),disabled:i,"data-testid":`smash-confirm-modal-continue`,children:[(0,q.jsx)(H,{className:`w-3.5 h-3.5 mr-1.5`}),s(i?`smashModal.starting`:n?`smashModal.confirmReSmash`:`smashModal.smash`)]})]})]}),(0,q.jsx)(ve,{handles:h})]}):null}var kn=`## Contract Layer`;function An(e,t){return!(!t||e.status===`draft`||e.parent_epic_id!=null||!e.description?.includes(kn))}function jn({ticket:e,projectId:t,featureFlagOn:n,childrenCount:r}){let{t:i}=p(`activity`),a=Sn(e.id),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),u=e.is_epic===!0,d=!u&&An(e,n),f=u&&n,m=u&&r>0,g=(0,G.useCallback)(async n=>{l(!0);try{let r=await fetch(`${j}/api/projects/${t}/tickets/${e.id}/smash`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:n})});if(!r.ok){let e=await r.json().catch(()=>({}));h.error(e.reason?i(`smash.couldNotStartWithReason`,{reason:e.reason}):i(`smash.couldNotStart`));return}s(!1)}catch(e){h.error(i(`smash.smashFailed`,{message:e.message}))}finally{l(!1)}},[t,e.id,i]),_=(0,G.useCallback)(async n=>{if(m){l(!0);try{if(!(await fetch(`${j}/api/projects/${t}/tickets/${e.id}/children`,{method:`DELETE`})).ok){h.error(i(`smash.couldNotDeleteChildren`)),l(!1);return}}catch(e){h.error(i(`smash.deleteFailed`,{message:e.message})),l(!1);return}}await g(n)},[m,g,t,e.id,i]);return!d&&!f?null:a?(0,q.jsx)(`div`,{className:`flex flex-col gap-2`,"data-testid":`smash-actions-streaming`,children:(0,q.jsx)(En,{stage:a.stage})}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(F,{size:`sm`,variant:`outline`,onClick:()=>s(!0),className:`border-accent-highlight/40 text-accent-highlight hover:bg-accent-highlight/10`,"data-testid":f?`resmash-button`:`smash-button`,children:[(0,q.jsx)(H,{className:`w-3.5 h-3.5 mr-1.5`}),i(f?`smash.reSmashButton`:`smash.smashButton`)]}),(0,q.jsx)(On,{open:o,ticketTitle:e.title,isReSmash:m,childrenCount:r,submitting:c,onCancel:()=>s(!1),onConfirm:_})]})}function Mn({epic:e,childExecutionOrder:t,totalChildren:n,onOpenEpic:r}){let{t:i}=p(`activity`);return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-accent-secondary/30 bg-accent-secondary/10 px-3 py-1.5 text-xs`,"data-testid":`epic-breadcrumb`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:r,className:`text-accent-secondary hover:underline font-medium`,children:[`← `,e.title]}),t!=null&&n>0&&(0,q.jsx)(`span`,{className:`text-foreground/60`,children:i(`epicChildren.step`,{order:t,total:n})})]})}var Nn={critical:`bg-red-400`,high:`bg-orange-400`,medium:`bg-yellow-400`,low:`bg-slate-400`};function Pn(e){return e?Nn[e]:`bg-muted`}function Fn(e){return[...e].sort((e,t)=>{let n=e.execution_order??1/0,r=t.execution_order??1/0;return n===r?e.id-t.id:n-r})}function In({ticket:e,allTickets:t,onOpenTicket:n}){let{t:r}=p(`activity`),i=e.is_epic===!0,a=e.parent_epic_id!=null;if(!i&&!a)return null;if(i){let i=Fn(t.filter(t=>t.parent_epic_id===e.id));return(0,q.jsx)(Ln,{header:r(`family.subSpecsHeader`,{count:i.length}),rows:i,currentId:e.id,onOpenTicket:n,emptyMessage:r(`family.emptySubSpecs`)})}let o=t.find(t=>t.id===e.parent_epic_id)??null,s=Fn(t.filter(t=>t.parent_epic_id===e.parent_epic_id)),c=o?[o,...s]:s;return(0,q.jsx)(Ln,{header:r(`family.familyHeader`,{count:s.length}),rows:c,currentId:e.id,onOpenTicket:n,emptyMessage:r(`family.noSiblings`)})}function Ln({header:e,rows:t,currentId:n,onOpenTicket:r,emptyMessage:i}){let{t:a}=p(`activity`);return(0,q.jsxs)(`div`,{"data-testid":`epic-family-sidebar`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,q.jsx)(H,{className:`w-3 h-3 text-accent-highlight`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:e})]}),t.length===0?(0,q.jsx)(`p`,{className:`text-[10px] text-foreground/50 italic`,children:i}):(0,q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:t.map(e=>{let t=e.id===n,i=e.is_epic===!0;return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{t||r(e.id)},disabled:t,"aria-label":a(i?`family.openParentEpic`:`family.openSubSpec`,{title:e.title}),"aria-current":t?`page`:void 0,className:[`w-full flex items-center gap-1.5 rounded px-1.5 py-1 text-left transition-colors`,t?`bg-accent-highlight/15 cursor-default`:`hover:bg-muted/30 cursor-pointer`].join(` `),"data-testid":`epic-family-row-${e.id}`,children:[i?(0,q.jsx)(E,{className:`w-3 h-3 text-accent-highlight flex-shrink-0`,"aria-hidden":!0}):(0,q.jsx)(`span`,{className:`text-[9px] tabular-nums text-foreground/40 w-3 text-center flex-shrink-0`,children:e.execution_order??`–`}),(0,q.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${Pn(e.priority)}`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-[11px] truncate ${t?`text-foreground font-medium`:`text-foreground/80`}`,title:e.title,children:e.title})]})},e.id)})})]})}var Rn=900,zn=.2,Bn=[{value:`critical`,labelKey:`priority.critical`,className:`text-red-400`},{value:`high`,labelKey:`priority.high`,className:`text-orange-400`},{value:`medium`,labelKey:`priority.medium`,className:`text-yellow-400`},{value:`low`,labelKey:`priority.low`,className:`text-slate-400`}];function Vn(e){return e.jira_epic_key&&e.jira_url?e.jira_url.replace(/\/browse\/[^/]+$/,`/browse/${e.jira_epic_key}`):null}var Hn={manual:`source.manual`,"product-backlog":`source.productBacklog`,"propose-spec":`source.proposeSpec`,"get-backlog-specs":`source.getBacklogSpecs`,"free-prompt":`source.freePrompt`};function Un({ticket:e,allLabels:t,allTickets:n,onClose:r,onOpenTicket:i,onSave:a,onDelete:o,rails:s,onMoveToRail:c,onRemoveFromRail:l,embedded:u=!1}){let{t:d}=p(`tickets`),{t:m}=p(`jira`),{activeProjectId:g,projects:_}=P(),{enterSplit:y,state:b}=an(),x=b.originSide!==null,S=_.find(e=>e.id===g)?.provider!==`codex`,C=(0,G.useMemo)(()=>(n??[]).filter(t=>t.parent_epic_id===e.id),[n,e.id]),w=(0,G.useMemo)(()=>e.parent_epic_id==null?null:(n??[]).find(t=>t.id===e.parent_epic_id)??null,[n,e.parent_epic_id]),T=(0,G.useMemo)(()=>w?(n??[]).filter(e=>e.parent_epic_id===w.id).length:0,[n,w]),[E,D]=(0,G.useState)(e.title),[O,ne]=(0,G.useState)(e.description),[k,ae]=(0,G.useState)(e.priority??`medium`),[A,le]=(0,G.useState)([...e.labels??[]]),[de,j]=(0,G.useState)(!1),[M,N]=(0,G.useState)(!1),[I,L]=(0,G.useState)(``),[be,xe]=(0,G.useState)(!1),[R,Se]=(0,G.useState)(!1),[Ce,we]=(0,G.useState)(!1),[Ee,z]=(0,G.useState)(!1),[B,De]=(0,G.useState)(!1),[V,H]=(0,G.useState)(!1),U=Ze(),W=U.connected&&!!U.discardStatus&&e.source===`jira`&&!!e.jira_key,Oe=U.connected&&e.source===`jira`&&!!e.jira_key,[ke,Ae]=(0,G.useState)(e.attachments??[]);(0,G.useEffect)(()=>{Ae(e.attachments??[])},[e.attachments,e.id]);let je=(0,G.useRef)(null),Me=(0,G.useRef)(null),Ne=(0,G.useRef)(null),K=(0,G.useMemo)(()=>E!==e.title||O!==e.description||k!==e.priority||JSON.stringify(A)!==JSON.stringify(e.labels),[E,O,k,A,e]);(0,G.useEffect)(()=>{de&&je.current?.focus()},[de]),(0,G.useEffect)(()=>{if(M){let e=Me.current;e&&(e.focus(),e.selectionStart=e.value.length)}},[M]),(0,G.useEffect)(()=>{be&&Ne.current?.focus()},[be]),(0,G.useEffect)(()=>{function e(e){e.key===`Escape`&&!de&&!M&&!R&&r()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,de,M,R]);let Pe=(0,G.useMemo)(()=>{if(!I.trim())return[];let e=I.toLowerCase();return t.filter(t=>t.toLowerCase().includes(e)&&!A.includes(t)).slice(0,5)},[I,t,A]),Fe=(0,G.useCallback)(e=>{let t=e.trim();t&&!A.includes(t)&&le(e=>[...e,t]),L(``)},[A]),Ie=(0,G.useCallback)(e=>{le(t=>t.filter(t=>t!==e))},[]),Le=(0,G.useCallback)(async()=>{let t={};if(E!==e.title&&(t.title=E),O!==e.description&&(t.description=O),k!==e.priority&&(t.priority=k),JSON.stringify(A)!==JSON.stringify(e.labels)&&(t.labels=A),Object.keys(t).length===0){r();return}De(!0);let n=await a(e.id,t);De(!1),n?(h.success(d(`detailModal.toast.updated`)),r()):h.error(d(`detailModal.toast.updateFailed`))},[E,O,k,A,e,a,r,d]),Re=(0,G.useCallback)(async()=>{if(V)return;H(!0);let t=!1;try{t=await o(e.id)}catch{t=!1}if(H(!1),!t){h.error(d(`detailModal.toast.deleteFailed`));return}Se(!1),r()},[V,e.id,o,r,d]),[ze,Be]=(0,G.useState)(0),J=(0,G.useRef)(null),[Ve,He]=(0,G.useState)(()=>typeof window<`u`&&window.innerWidth>=Rn);(0,G.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>He(window.innerWidth>=Rn);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let Y=!u&&!x&&Ve,X=(0,G.useCallback)(e=>{J.current&&Be(e.clientX-J.current.startX)},[]),Z=(0,G.useCallback)(t=>{if(!J.current)return;let n=t.clientX-J.current.startX,i=window.innerWidth*zn;if(window.removeEventListener(`pointermove`,X),window.removeEventListener(`pointerup`,Z),window.removeEventListener(`pointercancel`,Z),J.current=null,Be(0),Math.abs(n)>=i&&window.innerWidth>=Rn){let t=b.leftId===e.id;y(n<0?`left`:`right`,e.id),t||r()}},[y,X,b.leftId,e.id,r]),Ue=(0,G.useCallback)(e=>{Y&&e.button===0&&(e.target.closest(`button, input, textarea, select, [contenteditable="true"]`)||(J.current={startX:e.clientX,pointerId:e.pointerId},window.addEventListener(`pointermove`,X),window.addEventListener(`pointerup`,Z),window.addEventListener(`pointercancel`,Z)))},[Y,X,Z]);(0,G.useEffect)(()=>()=>{J.current&&(window.removeEventListener(`pointermove`,X),window.removeEventListener(`pointerup`,Z),window.removeEventListener(`pointercancel`,Z))},[X,Z]);let We=(0,G.useCallback)(()=>{if(!Y||window.innerWidth<Rn)return;let t=b.leftId===e.id;y(`right`,e.id),t||r()},[Y,y,b.leftId,e.id,r]),{panelRef:Ge,panelStyle:Ke,resizeHandles:qe,guardBackdrop:Je}=pe({enabled:!u,allowMove:!1}),Ye=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{ref:Ge,className:u?`relative w-full h-full rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 flex flex-col overflow-hidden`:`relative w-full max-w-[67rem] m-4 rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 flex flex-col animate-in fade-in zoom-in-95 duration-200 h-[90vh]`,style:{...ze===0?{transition:`transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1)`}:{transform:`translateX(${ze}px)`,transition:`none`},...Ke},children:[w&&(0,q.jsx)(`div`,{className:`px-5 pt-3`,children:(0,q.jsx)(Mn,{epic:w,childExecutionOrder:e.execution_order??null,totalChildren:T,onOpenEpic:()=>i?.(w.id)})}),(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${Y?`cursor-grab active:cursor-grabbing`:``}`,onPointerDown:Ue,"data-testid":`ticket-modal-header`,children:[(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[de?(0,q.jsx)(`input`,{ref:je,value:E,onChange:e=>D(e.target.value),onBlur:()=>j(!1),onKeyDown:t=>{t.key===`Enter`&&j(!1),t.key===`Escape`&&(D(e.title),j(!1))},className:`w-full bg-transparent border-b border-accent-primary/50 text-sm font-semibold text-foreground outline-none pb-0.5`}):(0,q.jsxs)(`button`,{type:`button`,onClick:()=>j(!0),className:`group flex items-center gap-1.5 text-left w-full`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:E||d(`untitled`)}),(0,q.jsx)(ie,{className:`w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,q.jsxs)(`span`,{className:`text-[10px] text-foreground font-mono`,children:[`#`,e.id]}),e.status===`on_review`&&(0,q.jsx)(`span`,{title:d(`specs:status.onReviewHint`),"data-testid":`ticket-modal-on-review-badge`,children:(0,q.jsx)(tt,{status:`on_review`})})]}),(0,q.jsx)(cn,{ticketId:e.id})]}),g&&(0,q.jsx)(`div`,{className:`shrink-0`,children:(0,q.jsx)(jn,{ticket:e,projectId:g,featureFlagOn:S,childrenCount:C.length})}),(0,q.jsx)(Gn,{ticket:e,title:E,description:O,priority:k,labels:A,onClose:r}),s&&(c||l)&&(0,q.jsx)(Kn,{ticket:e,rails:s,onMoveToRail:c,onRemoveFromRail:l}),Y&&(0,q.jsxs)(F,{variant:`outline`,size:`sm`,className:`shrink-0 mr-1 gap-1.5`,"data-testid":`ticket-modal-compare`,onClick:We,title:d(`detailModal.compareTooltip`),children:[(0,q.jsx)(Te,{className:`w-3.5 h-3.5`}),d(`detailModal.compare`)]}),(0,q.jsx)(`button`,{onClick:r,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors cursor-pointer shrink-0`,"data-testid":`ticket-modal-close`,children:(0,q.jsx)(ue,{className:`w-4 h-4`})})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:(0,q.jsxs)(`div`,{className:`flex flex-col sm:flex-row h-full`,children:[(0,q.jsxs)(`div`,{className:`flex-1 min-w-0 px-5 py-4 space-y-4 flex flex-col`,children:[(0,q.jsxs)(`div`,{className:`flex-1 flex flex-col`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5`,children:d(`fields.description`)}),!M&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>N(!0),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,q.jsx)(ie,{className:`w-2.5 h-2.5`}),d(`common:actions.edit`)]})]}),M?(0,q.jsxs)(`div`,{className:`space-y-1.5 flex-1 flex flex-col`,children:[(0,q.jsx)(`textarea`,{ref:Me,value:O,onChange:e=>ne(e.target.value),className:`w-full flex-1 rounded-lg border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-none min-h-[300px]`,placeholder:d(`fields.markdownPlaceholder`)}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(F,{variant:`ghost`,size:`sm`,className:`h-6 text-[10px]`,onClick:()=>N(!1),children:d(`detailModal.doneEditing`)}),(0,q.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:d(`fields.supportsMarkdown`)})]})]}):O?(0,q.jsx)(Xn,{description:O,onEdit:()=>N(!0)}):(0,q.jsx)(`button`,{type:`button`,onClick:()=>N(!0),className:`w-full rounded-lg border border-dashed border-border/40 bg-muted/10 px-3 py-4 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/20 transition-colors text-center`,children:d(`detailModal.addDescription`)})]}),(0,q.jsx)(Vt,{ticketKey:e.id,attachments:ke,onChange:Ae}),(0,q.jsx)(Ht,{ticketId:e.id,onClose:r}),e.prerequisites&&e.prerequisites.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`detailModal.prerequisites`)}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.prerequisites.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-mono bg-accent/60 text-foreground/70`,children:[`#`,e]},e))})]})]}),(0,q.jsxs)(`div`,{className:`sm:w-56 sm:border-l border-t sm:border-t-0 border-border/30 px-4 py-4 space-y-4 bg-muted/5`,children:[e.jira_url&&e.jira_key&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.jira_url)},"data-testid":`jira-go-to-ticket`,className:`w-full inline-flex items-center justify-center gap-1.5 h-7 rounded border border-accent-info/50 bg-accent-info/10 px-2 text-xs font-medium text-accent-info hover:bg-accent-info/20 transition-colors`,children:[(0,q.jsx)(ee,{className:`w-3.5 h-3.5 shrink-0`}),m(`detail.goToTicket`,{key:e.jira_key})]}),e.jira_epic_key&&(0,q.jsxs)(`div`,{"data-testid":`jira-epic`,children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:m(`detail.epic`)}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{let t=Vn(e);t&&Q(t)},title:e.jira_epic_name??e.jira_epic_key,className:`w-full inline-flex items-center gap-1.5 rounded border border-accent-highlight/40 bg-accent-highlight/5 px-2 py-1.5 text-left text-xs hover:bg-accent-highlight/10 transition-colors`,children:[(0,q.jsx)(`span`,{className:`font-mono text-accent-highlight shrink-0`,children:e.jira_epic_key}),e.jira_epic_name&&(0,q.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.jira_epic_name})]})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.priority`)}),(0,q.jsx)(`select`,{value:k,onChange:e=>ae(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:Bn.map(e=>(0,q.jsx)(`option`,{value:e.value,children:d(e.labelKey)},e.value))})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.labels`)}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:A.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] font-medium bg-accent/60 text-foreground/70 group`,children:[e,(0,q.jsx)(`button`,{type:`button`,onClick:()=>Ie(e),className:`text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,q.jsx)(te,{className:`w-2.5 h-2.5`})})]},e))}),be?(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(`input`,{ref:Ne,value:I,onChange:e=>L(e.target.value),onKeyDown:e=>{e.key===`Enter`&&I.trim()&&(e.preventDefault(),Fe(I)),e.key===`Escape`&&(xe(!1),L(``))},onBlur:()=>{I.trim()&&Fe(I),xe(!1),L(``)},placeholder:d(`detailModal.addLabelPlaceholder`),className:`w-full h-6 rounded border border-border bg-input px-2 text-[10px] text-foreground placeholder:text-muted-foreground`}),Pe.length>0&&(0,q.jsx)(`div`,{className:`absolute left-0 right-0 top-full mt-0.5 rounded border border-border/50 bg-popover shadow-lg z-10 py-0.5`,children:Pe.map(e=>(0,q.jsx)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),Fe(e)},className:`w-full text-left px-2 py-1 text-[10px] hover:bg-accent/50 text-foreground/80`,children:e},e))})]}):(0,q.jsxs)(`button`,{type:`button`,onClick:()=>xe(!0),className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,q.jsx)(oe,{className:`w-2.5 h-2.5`}),d(`detailModal.addLabel`)]})]}),(0,q.jsx)(In,{ticket:e,allTickets:n??[],onOpenTicket:e=>i?.(e)}),e.source===`jira`&&e.jira_key&&(0,q.jsx)(dn,{localId:e.id}),e.metadata?.effort_level&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:d(`detailModal.effort`)}),(0,q.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.metadata.effort_level})]}),e.assignee&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:d(`detailModal.assignee`)}),(0,q.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.assignee})]})]})]})}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-t border-border/30`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:d(`meta.createdAgo`,{time:Wn(e.created_at)})}),(0,q.jsx)(`span`,{children:d(`meta.updatedAgo`,{time:Wn(e.updated_at)})}),e.source&&(0,q.jsx)(`span`,{className:`bg-muted/30 rounded px-1.5 py-0.5`,children:Hn[e.source]?d(Hn[e.source]):e.source})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[W?(0,q.jsxs)(F,{variant:`ghost`,size:`sm`,className:`h-7 text-xs text-accent-info hover:bg-accent-info/10`,onClick:()=>we(!0),"data-testid":`jira-move-to-button`,children:[(0,q.jsx)(v,{className:`w-3 h-3 mr-1`}),m(`discard.moveButton`,{status:U.discardStatus})]}):(0,q.jsxs)(F,{variant:`ghost`,size:`sm`,className:`h-7 text-xs text-red-400 aurora-light:text-destructive hover:text-red-300 aurora-light:hover:text-destructive hover:bg-red-500/10 aurora-light:hover:bg-destructive/10`,onClick:()=>Se(!0),children:[(0,q.jsx)(ce,{className:`w-3 h-3 mr-1`}),d(`common:actions.delete`)]}),K&&(0,q.jsxs)(F,{size:`sm`,className:`h-7 text-xs`,onClick:()=>{Oe?z(!0):Le()},disabled:B||!E.trim(),children:[(0,q.jsx)(se,{className:`w-3 h-3 mr-1`}),d(B?`common:states.saving`:`common:actions.save`)]})]})]})]}),(0,q.jsx)(ye,{open:R,onOpenChange:e=>{V||Se(e)},children:(0,q.jsxs)(he,{className:`max-w-sm`,children:[(0,q.jsxs)(fe,{children:[(0,q.jsx)(ge,{children:d(`deleteDialog.title`)}),(0,q.jsx)(_e,{children:(0,q.jsx)(f,{t:d,i18nKey:`deleteDialog.body`,values:{id:e.id,title:e.title},components:{strong:(0,q.jsx)(`span`,{className:`font-semibold text-foreground`})}})})]}),(0,q.jsxs)(me,{children:[(0,q.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>Se(!1),disabled:V,children:d(`common:actions.cancel`)}),(0,q.jsxs)(F,{variant:`destructive`,size:`sm`,onClick:()=>{Re()},disabled:V,"aria-busy":V,children:[V?(0,q.jsx)(re,{className:`w-3.5 h-3.5 mr-1.5 animate-spin`}):(0,q.jsx)(ce,{className:`w-3.5 h-3.5 mr-1.5`}),d(`common:actions.delete`)]})]})]})}),W&&U.discardStatus&&(0,q.jsx)(Qe,{open:Ce,onOpenChange:we,ticket:{id:e.id,title:e.title,jira_key:e.jira_key},discardStatus:U.discardStatus,onDiscarded:r}),(0,q.jsx)(ye,{open:Ee,onOpenChange:z,children:(0,q.jsxs)(he,{className:`max-w-md`,"data-testid":`jira-save-confirm`,children:[(0,q.jsxs)(fe,{children:[(0,q.jsx)(ge,{children:m(`detail.saveTitle`)}),(0,q.jsx)(_e,{children:m(`detail.saveBody`,{key:e.jira_key??`#${e.id}`})})]}),(0,q.jsxs)(me,{children:[(0,q.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>z(!1),children:d(`common:actions.cancel`)}),(0,q.jsxs)(F,{size:`sm`,onClick:()=>{z(!1),Le()},disabled:B,"data-testid":`jira-save-confirm-btn`,children:[(0,q.jsx)(se,{className:`w-3.5 h-3.5 mr-1.5`}),m(`detail.saveConfirm`)]})]})]})})]});return u?Ye:(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[68] flex items-center justify-center`,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/70`,onClick:Je(r)}),Ye,(0,q.jsx)(ve,{handles:qe})]})}function Wn(e){try{return R(new Date(e),{addSuffix:!0,locale:s()})}catch{return e}}function Gn({ticket:e,title:t,description:n,priority:r,labels:i,onClose:a}){let{t:o}=p(`tickets`),{triggerResume:s}=T(),{activeProjectId:c}=P(),{closeTicketDetail:l}=an();return Y(e)?(0,q.jsxs)(F,{variant:`default`,size:`sm`,onClick:()=>{if(!c)return;let{body:u,criteria:d}=Ve(n);s({kind:`explore-spec`,projectId:c,label:t||e.title||o(`detailModal.ticketFallbackLabel`,{id:e.id}),restoreRoute:`/`,params:{initialIdea:``,pendingSpecId:X(),initialAttachmentIds:[],resumeConversationId:e.origin_conversation_id??void 0,editTicket:{id:e.id,title:t,description:u,labels:i,priority:r,acceptanceCriteria:d,status:e.status}}}),l(),a()},className:`shrink-0 mr-2`,"data-testid":`continue-editing`,children:[(0,q.jsx)(V,{className:`w-3.5 h-3.5 mr-1.5`}),o(`detailModal.continueEditing`)]}):null}function Kn({ticket:e,rails:t,onMoveToRail:n,onRemoveFromRail:r}){let{t:i}=p(`tickets`),[a,o]=(0,G.useState)(null),s=(0,G.useRef)(null),c=t.find(t=>t.ticketIds.includes(e.id));return c?r?(0,q.jsxs)(F,{variant:`outline`,size:`sm`,className:`shrink-0 mr-2 gap-1.5 border-accent-warning/30 text-accent-warning hover:bg-accent-warning/10 hover:text-accent-warning`,"data-testid":`modal-remove-from-rail`,onClick:()=>r(e.id),title:i(`rail.currentlyOn`,{rail:c.label}),children:[(0,q.jsx)(g,{className:`w-3.5 h-3.5`,"aria-hidden":!0}),i(`rail.removeFromRail`)]}):null:n?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(F,{ref:s,variant:`outline`,size:`sm`,className:`shrink-0 mr-2 gap-1.5 border-accent-info/30 text-accent-info hover:bg-accent-info/10 hover:text-accent-info`,"data-testid":`modal-move-to-rail`,onClick:()=>{s.current&&o(s.current.getBoundingClientRect())},children:[i(`rail.moveToRail`),(0,q.jsx)(v,{className:`w-3.5 h-3.5`,"aria-hidden":!0})]}),a&&(0,q.jsx)(Be,{rails:t,anchorRect:a,onMoveToRail:t=>n(e.id,t),onClose:()=>o(null)})]}):null}var qn=`
|
|
8
|
+
`;function K(e){return`${j}/api/projects/${encodeURIComponent(e)}`}function Pe(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Fe(e,t){let n=new Map(e.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.id);return t&&Pe(t,e)?t:e});return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r}function Ie(){let{t:e}=p(`tickets`),{activeProjectId:t}=P(),[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(new Set),[u,d]=(0,G.useState)(new Set),f=(0,G.useRef)(t);f.current=t;let m=(0,G.useRef)(0),g=(0,G.useRef)(null),_=(0,G.useRef)(new Set),{registerHandler:v,unregisterHandler:y,connectionStatus:b}=M(),x=(0,G.useId)(),S=(0,G.useCallback)(async(e,t)=>{let n=K(e),r=await fetch(`${n}/tickets`,{signal:t,cache:`no-store`});if(!r.ok)throw Error(`Failed to fetch tickets: ${r.status}`);let i=await r.json();return Array.isArray(i)?i:i.tickets??[]},[]),C=(0,G.useCallback)(async(t,n)=>{let i=++m.current;g.current?.abort();let o=new AbortController;g.current=o,f.current===t&&(a(!0),s(null));try{let a=await S(t,o.signal);if(o.signal.aborted||i!==m.current||f.current!==t)return;let s=_.current,c=new Set;if(n===`merge`)for(let e of a)s.size>0&&!s.has(e.id)&&c.add(e.id);_.current=new Set(a.map(e=>e.id)),r(n===`replace`?a:e=>Fe(e,a)),c.size>0&&s.size>0&&(l(c),h.success(e(`toasts.newTicketsAdded`,{count:c.size}),{id:`tickets-added-${t}`}),setTimeout(()=>{f.current===t&&l(e=>{let t=new Set(e);for(let e of c)t.delete(e);return t})},Me))}catch(e){if(o.signal.aborted||i!==m.current||f.current!==t)return;s(e instanceof Error?e.message:String(e))}finally{i===m.current&&(g.current===o&&(g.current=null),f.current===t&&a(!1))}},[S,e]),w=(0,G.useCallback)(async()=>{t&&await C(t,`merge`)},[t,C]);(0,G.useEffect)(()=>{if(m.current+=1,g.current?.abort(),g.current=null,r([]),a(!1),s(null),_.current=new Set,l(new Set),d(new Set),t)return C(t,`replace`),()=>{m.current+=1,g.current?.abort(),g.current=null}},[t,C]);let T=(0,G.useCallback)(t=>{let n=t;if(!n||typeof n.type!=`string`)return;let i=f.current;if(!(n.projectId&&n.projectId!==i))switch(n.type){case`mcp.activity`:n.affectedProjectId&&n.affectedProjectId===i&&w();break;case`ticket_created`:{if(!n.ticket)break;let t=n.ticket;r(e=>e.some(e=>e.id===t.id)?e:[...e,t]),_.current.add(t.id),l(e=>new Set([...e,t.id])),je(i)||h.success(e(`toasts.newTicket`,{title:t.title}),{id:`new-ticket-${t.id}`}),setTimeout(()=>{l(e=>{let n=new Set(e);return n.delete(t.id),n})},Me);break}case`ticket_updated`:{if(!n.ticket)break;if(n.ticket.id===0){w();break}let e=n.ticket;r(t=>t.map(t=>t.id===e.id?e:t)),typeof e.description==`string`&&e.description.includes(Ne)&&d(t=>{if(!t.has(e.id))return t;let n=new Set(t);return n.delete(e.id),n});break}case`ticket_deleted`:{if(n.ticketId==null)break;let e=n.ticketId;r(t=>t.filter(t=>t.id!==e)),_.current.delete(e);break}case`explore.contract_refine_started`:if(n.ticketId==null)break;d(e=>new Set([...e,n.ticketId]));break;case`explore.contract_refine_failed`:{if(n.ticketId==null)break;let e=n.ticketId;d(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n});break}}},[w,e]);(0,G.useLayoutEffect)(()=>(v(`tickets-${x}`,T),()=>y(`tickets-${x}`)),[T,v,y,x]);let E=(0,G.useRef)(b);return(0,G.useEffect)(()=>{E.current!==`connected`&&b===`connected`&&f.current&&w(),E.current=b},[b,w]),{tickets:n,loading:i,isLoading:i,error:o,newTicketIds:c,contractRefiningIds:u,refetch:w,refresh:w,deleteTicket:(0,G.useCallback)(async e=>{let n=t;if(!n)return!1;try{let t=await fetch(`${K(n)}/tickets/${e}`,{method:`DELETE`});return t.ok&&f.current===n&&await C(n,`merge`),t.ok}catch{return!1}},[t,C]),updateTicketStatus:(0,G.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${K(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({status:n})});return t.ok&&f.current===r&&await C(r,`merge`),t.ok}catch{return!1}},[t,C]),updateTicketPriority:(0,G.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${K(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({priority:n})});return t.ok&&f.current===r&&await C(r,`merge`),t.ok}catch{return!1}},[t,C]),createTicket:(0,G.useCallback)(async e=>{let n=t;if(!n)return!1;try{let t=await fetch(`${K(n)}/tickets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return t.ok&&f.current===n&&await C(n,`merge`),t.ok}catch{return!1}},[t,C]),updateTicket:(0,G.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${K(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});return t.ok&&f.current===r&&await C(r,`merge`),t.ok}catch{return!1}},[t,C])}}var q=n(),Le=224,Re=8,ze=8;function Be({rails:e,onMoveToRail:t,onClose:n,anchorRect:r}){let{t:i}=p(`tickets`),a=(0,G.useRef)(null),[o,s]=(0,G.useState)(!1);(0,G.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>s(!0));return()=>cancelAnimationFrame(e)},[]),(0,G.useEffect)(()=>{function e(e){a.current&&(a.current.contains(e.target)||n())}function t(e){e.key===`Escape`&&n()}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[n]);let{top:c,left:l,caretLeft:u}=(0,G.useMemo)(()=>{let e=r.left+r.width/2,t=e-Le/2,n=window.innerWidth-Le-Re,i=Math.max(Re,Math.min(n,t)),a=e-i,o=Math.max(12,Math.min(Le-12,a));return{top:r.bottom+ze,left:i,caretLeft:o}},[r]);return(0,q.jsxs)(`div`,{ref:a,role:`dialog`,"aria-label":i(`rail.popoverTitle`),"data-testid":`move-to-rail-popover`,style:{top:c,left:l,width:Le,opacity:+!!o,transform:o?`translateY(0) scale(1)`:`translateY(-4px) scale(0.97)`,transformOrigin:`${u}px top`,transition:`opacity 140ms ease-out, transform 160ms cubic-bezier(0.2, 0.9, 0.3, 1)`},className:`fixed z-50 rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/40 p-1`,children:[(0,q.jsx)(`div`,{"aria-hidden":!0,className:`absolute w-2 h-2 rotate-45 bg-card/95 border-l border-t border-border/60`,style:{top:-5,left:u-4}}),(0,q.jsx)(`div`,{className:`px-2 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground/70 font-medium`,children:i(`rail.popoverTitle`)}),e.length===0?(0,q.jsx)(`div`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:i(`rail.noRails`)}):(0,q.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{t(e.id),n()},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-sm hover:bg-accent-info/10 hover:text-accent-info transition-colors`,children:[e.status===`running`?(0,q.jsx)(ae,{className:`w-3 h-3 text-accent-success animate-pulse shrink-0`,"aria-hidden":!0}):(0,q.jsx)(we,{className:`w-3 h-3 text-muted-foreground/60 shrink-0`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),(0,q.jsx)(Ce,{className:`w-3.5 h-3.5 text-muted-foreground/40 shrink-0`,"aria-hidden":!0})]})},e.id))})]})}var J=/\n*##\s*Acceptance Criteria\s*\n([\s\S]*?)(?=\n##\s|\n*$)/i;function Ve(e){if(!e)return{body:``,criteria:[]};let t=J.exec(e);if(!t)return{body:e.replace(/\s+$/,``),criteria:[]};let n=t[1],r=e.slice(0,t.index),i=e.slice(t.index+t[0].length),a=`${r.replace(/\s+$/,``)}${i?`\n\n${i.replace(/^\s+/,``)}`:``}`,o=n.split(/\r?\n/).map(e=>e.replace(/^\s*[-*+]\s+/,``).trim()).filter(e=>e.length>0);return{body:a.replace(/\s+$/,``),criteria:o}}var He=new Set([`draft`,`todo`]);function Y(e){return!!(He.has(e.status)||e.source===`jira`&&e.jira_key&&e.status!==`cancelled`)}function X(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}var Z=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_TERMINAL_PANEL;return typeof e!=`string`||e!==`false`})(),Ue=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENTS_SECTION;return typeof e!=`string`||e!==`false`})(),We=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_CODE_EXPLORER;return typeof e!=`string`||e!==`false`})(),Ge=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_JIRA;return typeof e!=`string`||e!==`false`})(),Ke=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_MCP;return typeof e!=`string`||e!==`false`})(),qe=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENT_CHAT;return typeof e!=`string`||e!==`false`})(),Je=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENT_MODE;return qe&&(typeof e!=`string`||e!==`false`)})();(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_INTERACTIVE_JOBS;return typeof e!=`string`||e!==`false`})();var Ye=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_LOOPS_SECTION;return typeof e!=`string`||e!==`false`})(),Xe=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_PROJECT_BUILDER;return typeof e!=`string`||e!==`false`})();function Ze(){let{activeProjectId:e}=P(),[t,n]=(0,G.useState)({connected:!1,key:null,discardStatus:null}),[r,i]=(0,G.useState)(!0);return(0,G.useEffect)(()=>{if(!Ge||!e){n({connected:!1,key:null,discardStatus:null}),i(!1);return}let t=!1;return i(!0),L.getConnection().then(e=>{if(t)return;let r=!!(e.connected&&e.connection?.enabled);n({connected:r,key:e.connection?.jiraProjectKey??null,discardStatus:r?e.connection?.discardStatus??null:null})}).catch(()=>{t||n({connected:!1,key:null,discardStatus:null})}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),{connected:t.connected,jiraProjectKey:t.key,discardStatus:t.discardStatus,loading:r}}function Qe({open:e,onOpenChange:t,ticket:n,discardStatus:r,onDiscarded:i}){let{t:a}=p(`jira`),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(!1);async function u(){l(!0);try{await L.discardSpec(n.id,o.trim()||null),h.success(a(`discard.movedToast`,{status:r,key:n.jira_key??`#${n.id}`})),t(!1),s(``),i?.()}catch(e){h.error(e instanceof Error?e.message:a(`errors.generic`))}finally{l(!1)}}return(0,q.jsx)(ye,{open:e,onOpenChange:e=>{c||t(e)},children:(0,q.jsxs)(he,{movableResizable:!0,className:`max-w-md`,"data-testid":`jira-discard-dialog`,children:[(0,q.jsxs)(fe,{children:[(0,q.jsx)(ge,{children:a(`discard.title`,{status:r})}),(0,q.jsx)(_e,{children:a(`discard.body`,{status:r,key:n.jira_key??`#${n.id}`})})]}),(0,q.jsxs)(`label`,{className:`block space-y-1`,children:[(0,q.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:a(`discard.commentLabel`)}),(0,q.jsx)(`textarea`,{value:o,onChange:e=>s(e.target.value),placeholder:a(`discard.commentPlaceholder`),rows:3,className:`w-full rounded-md border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-none`,"data-testid":`jira-discard-comment`})]}),(0,q.jsxs)(me,{children:[(0,q.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:c,children:a(`wizard.cancel`)}),(0,q.jsxs)(F,{size:`sm`,onClick:u,disabled:c,"data-testid":`jira-discard-confirm`,children:[(0,q.jsx)(v,{className:`w-3.5 h-3.5 mr-1.5`}),c?a(`discard.moving`):a(`discard.confirm`,{status:r})]})]})]})})}var $e={draft:{dotClass:`bg-accent-secondary/60`,textClass:`text-accent-secondary`,borderClass:`border-l-[3px] border-dashed border-accent-secondary/50 pl-3`,labelKey:`common:status.draft`,pulsing:!1},todo:{dotClass:`bg-slate-500/70`,textClass:`text-muted-foreground`,borderClass:`border-l-[3px] border-dashed border-slate-500/40 pl-3`,labelKey:`status.todo`,pulsing:!1},in_progress:{dotClass:`bg-blue-400 aurora-light:bg-accent-info`,textClass:`text-foreground font-semibold`,borderClass:`border-l-[3px] border-solid border-blue-500 pl-3`,labelKey:`status.inProgress`,pulsing:!0},on_review:{dotClass:`bg-accent-warning/80`,textClass:`text-accent-warning`,borderClass:`border-l-[3px] border-solid border-accent-warning/60 pl-3`,labelKey:`status.onReview`,pulsing:!1},done:{dotClass:`text-emerald-400 aurora-light:text-accent-success`,textClass:`text-emerald-400/80 aurora-light:text-accent-success`,borderClass:`border-l-[3px] border-solid border-emerald-500 pl-3`,labelKey:`status.done`,pulsing:!1},cancelled:{dotClass:`text-red-400/60 aurora-light:text-destructive/70`,textClass:`text-muted-foreground/50`,borderClass:`pl-3`,labelKey:`status.cancelled`,pulsing:!1}};function et({status:e,className:t}){let{t:n}=p(`specs`),r=$e[e];return e===`done`?(0,q.jsx)(D,{className:I(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.done`)}):e===`cancelled`?(0,q.jsx)(ue,{className:I(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.cancelled`)}):r.pulsing?(0,q.jsxs)(`span`,{className:I(`relative flex shrink-0 h-2.5 w-2.5`,t),"aria-label":n(`status.inProgress`),children:[(0,q.jsx)(`span`,{className:I(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,r.dotClass)}),(0,q.jsx)(`span`,{className:I(`relative inline-flex rounded-full h-2.5 w-2.5`,r.dotClass)})]}):(0,q.jsx)(`span`,{className:I(`inline-flex rounded-full h-2.5 w-2.5 shrink-0`,r.dotClass,t),"aria-label":n(r.labelKey)})}function tt({status:e,className:t}){let{t:n}=p(`specs`),r=$e[e];return(0,q.jsxs)(`span`,{className:I(`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[11px] font-medium border`,e===`todo`&&`bg-slate-500/10 border-slate-500/30 text-slate-400 aurora-light:bg-muted aurora-light:border-border aurora-light:text-muted-foreground`,e===`in_progress`&&`bg-blue-500/10 border-blue-500/30 text-blue-400 aurora-light:bg-accent-info/10 aurora-light:border-accent-info/30 aurora-light:text-accent-info`,e===`on_review`&&`bg-accent-warning/10 border-accent-warning/30 text-accent-warning`,e===`done`&&`bg-emerald-500/10 border-emerald-500/30 text-emerald-400 aurora-light:bg-accent-success/10 aurora-light:border-accent-success/30 aurora-light:text-accent-success`,e===`cancelled`&&`bg-red-500/10 border-red-500/30 text-red-400/60 aurora-light:bg-destructive/10 aurora-light:border-destructive/30 aurora-light:text-destructive/70`,t),children:[(0,q.jsx)(et,{status:e}),n(r.labelKey)]})}async function nt(e,t,n){let r=new FormData;r.append(`file`,t);let i=await fetch(`${N()}/tickets/${e}/attachments`,{method:`POST`,body:r,signal:n});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??u.t(`attachments:errors.uploadFailed`,{status:i.status}))}return(await i.json()).attachment}async function rt(e,t){let n=await fetch(`${N()}/tickets/${e}/attachments/${t}`,{method:`DELETE`});if(!n.ok&&n.status!==404)throw Error(u.t(`attachments:errors.deleteFailed`,{status:n.status}))}async function it(e){let t=await fetch(`${N()}/tickets/${e}/attachments`,{method:`DELETE`});if(!t.ok&&t.status!==404)throw Error(u.t(`attachments:errors.bulkDeleteFailed`,{status:t.status}))}async function at(e){let t=await fetch(`${N()}/tickets/${e}/attachments`);if(!t.ok)throw Error(u.t(`attachments:errors.listFailed`,{status:t.status}));return(await t.json()).attachments}function ot(e,t){return`${N()}/tickets/${e}/attachments/${t}`}async function st(e,t){let n=await fetch(ot(e,t));if(!n.ok)throw Error(u.t(`attachments:errors.fetchFailed`,{status:n.status}));return n.blob()}var ct=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/csv,text/plain,application/json,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/sql,application/x-sql,text/sql,text/x-sql,.sql`,lt=new Set(ct.split(`,`).filter(e=>!e.startsWith(`.`))),ut=/\.sql$/i,dt=/\.(png|jpe?g|gif|webp)$/i;function ft(e){return lt.has(e.type)||ut.test(e.name)||dt.test(e.name)}function pt(){return typeof window<`u`&&window.__TAURI_INTERNALS__!==void 0}function mt(e){return Function(`s`,`return import(s)`)(e).catch(()=>null)}async function ht(e){if(pt()){try{let t=await mt(`@tauri-apps/plugin-opener`);if(t?.revealItemInDir){await t.revealItemInDir(e);return}}catch{}try{await(await mt(`@tauri-apps/api/shell`))?.open?.(e)}catch{}}}async function Q(e){if(pt())try{let t=await i(()=>import(`./dist-js-eSxaoEw0.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71]));if(typeof t.open==`function`){await t.open(e);return}}catch(e){console.warn(`[openExternalUrl] tauri shell open failed:`,e)}try{window.open(e,`_blank`,`noopener,noreferrer`)}catch{}}function gt(e,t){let n=()=>l(t?.in,NaN),r=t?.additionalDigits??2,i=xt(e),a;if(i.date){let e=St(i.date,r);a=Ct(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,u;if(i.time&&(s=Tt(i.time),isNaN(s)))return n();if(i.timezone){if(u=Dt(i.timezone),isNaN(u))return n()}else{let e=new Date(o+s),n=c(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return c(o+s+u,t?.in)}var _t={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},vt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,yt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,bt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function xt(e){let t={},n=e.split(_t.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],_t.timeZoneDelimiter.test(t.date)&&(t.date=e.split(_t.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=_t.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function St(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function Ct(e,t){if(t===null)return new Date(NaN);let n=e.match(vt);if(!n)return new Date(NaN);let r=!!n[4],i=wt(n[1]),a=wt(n[2])-1,o=wt(n[3]),s=wt(n[4]),c=wt(n[5])-1;if(r)return Nt(t,s,c)?Ot(t,s,c):new Date(NaN);{let e=new Date(0);return!jt(t,a,o)||!Mt(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function wt(e){return e?parseInt(e):1}function Tt(e){let t=e.match(yt);if(!t)return NaN;let n=Et(t[1]),r=Et(t[2]),i=Et(t[3]);return Pt(n,r,i)?n*o+r*d+i*1e3:NaN}function Et(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function Dt(e){if(e===`Z`)return 0;let t=e.match(bt);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return Ft(r,i)?n*(r*o+i*d):NaN}function Ot(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}var kt=[31,null,31,30,31,30,31,31,30,31,30,31];function At(e){return e%400==0||e%4==0&&e%100!=0}function jt(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(kt[t]||(At(e)?29:28))}function Mt(e,t){return t>=1&&t<=(At(e)?366:365)}function Nt(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function Pt(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function Ft(e,t){return t>=0&&t<=59}function It({ticketKey:e,attachment:t,onClose:n}){let{t:r}=p(`attachments`),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(null);if((0,G.useEffect)(()=>{if(!t)return;function e(e){e.key===`Escape`&&n()}document.addEventListener(`keydown`,e);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=r}},[t,n]),(0,G.useEffect)(()=>{if(!t){a(null),s(null);return}let n=!1;return a(null),s(null),st(e,t.id).then(e=>{n||a(URL.createObjectURL(e))}).catch(e=>{n||s(e instanceof Error?e.message:r(`errors.loadFailed`))}),()=>{n=!0}},[t,e]),(0,G.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),!t)return null;let c=t.mimeType.startsWith(`image/`),l=t.mimeType===`application/pdf`;return(0,q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":r(`lightbox.preview`,{name:t.filename}),className:`fixed inset-0 z-[100] flex flex-col bg-black/85 backdrop-blur-sm animate-in fade-in-0 duration-200`,onClick:n,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-white/10 bg-black/40`,onClick:e=>e.stopPropagation(),children:[(0,q.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":r(`lightbox.backToDesktop`),className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-white/85 hover:bg-white/10 hover:text-white transition-colors`,children:[(0,q.jsx)(g,{className:`w-4 h-4`}),r(`common:actions.back`)]}),(0,q.jsxs)(`div`,{className:`flex-1 text-center min-w-0 px-4`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-white/95 truncate`,children:t.filename}),(0,q.jsx)(`div`,{className:`text-[11px] text-white/50`,children:t.mimeType})]}),(0,q.jsxs)(`a`,{href:i??`#`,download:t.filename,onClick:e=>{e.stopPropagation(),i||e.preventDefault()},className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-white/85 hover:bg-white/10 hover:text-white transition-colors`,"aria-label":r(`lightbox.download`),children:[(0,q.jsx)(O,{className:`w-4 h-4`}),r(`lightbox.download`)]})]}),(0,q.jsx)(`div`,{className:I(`flex-1 flex items-center justify-center overflow-auto p-6`),onClick:n,children:o?(0,q.jsx)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/80 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:(0,q.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loadError`,{error:o})})}):i?c?(0,q.jsx)(`img`,{src:i,alt:t.filename,onClick:e=>e.stopPropagation(),className:`max-h-full max-w-full rounded-lg shadow-2xl animate-in zoom-in-95 duration-200`}):l?(0,q.jsx)(`iframe`,{src:i,title:t.filename,onClick:e=>e.stopPropagation(),className:`w-full h-full max-w-5xl bg-white rounded-lg shadow-2xl`}):(0,q.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/80 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:[(0,q.jsx)(`p`,{className:`text-sm mb-3`,children:r(`lightbox.previewUnavailable`)}),(0,q.jsxs)(`a`,{href:i,download:t.filename,className:`inline-flex items-center gap-2 px-4 py-2 rounded-md bg-white/10 hover:bg-white/20 text-white transition-colors`,children:[(0,q.jsx)(O,{className:`w-4 h-4`}),r(`lightbox.downloadFile`,{name:t.filename})]})]}):(0,q.jsx)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/70 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:(0,q.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loading`)})})})]})}function Lt(e,t){let n=new Set,r=[];for(let i of[...e,...t])n.has(i.id)||(n.add(i.id),r.push(i));return r}function Rt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function zt(e){return e.startsWith(`image/`)?`🖼`:e===`application/pdf`?`📄`:e===`text/csv`||e.includes(`spreadsheetml`)||e===`application/vnd.ms-excel`?`📊`:e===`application/json`?`{ }`:e===`text/plain`||e.includes(`sql`)?`📝`:`📎`}function Bt(e){try{return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}catch{return e}}function Vt({ticketKey:e,attachments:t,onChange:n,className:r}){let{t:i}=p(`attachments`),[a,o]=(0,G.useState)(new Set),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null);if((0,G.useEffect)(()=>{let r=!1;return at(e).then(e=>{if(r)return;let i=Lt(t,e);i.length!==t.length&&n?.(i)}).catch(()=>{}),()=>{r=!0}},[e]),!t||t.length===0)return null;let d=[...t].sort((e,t)=>e.addedAt<t.addedAt?1:-1);async function f(r){c(null),o(e=>{let t=new Set(e);return t.add(r.id),t});try{await rt(e,r.id),await new Promise(e=>setTimeout(e,160)),n?.(t.filter(e=>e.id!==r.id))}catch(e){c(e instanceof Error?e.message:i(`errors.removeFailed`)),o(e=>{let t=new Set(e);return t.delete(r.id),t})}}return(0,q.jsxs)(`section`,{className:I(`mt-4`,r),"aria-label":i(`section.ariaLabel`),children:[(0,q.jsxs)(`header`,{className:`flex items-center justify-between mb-2`,children:[(0,q.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:i(`section.title`)}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`section.fileCount`,{count:d.length})})]}),(0,q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:d.map(e=>{let t=a.has(e.id);return(0,q.jsxs)(`li`,{className:I(`flex items-center gap-3 px-2.5 py-2 rounded-md border border-border bg-card/60 hover:bg-card transition-all duration-200`,t&&`opacity-0 scale-95 max-h-0 py-0 border-transparent overflow-hidden`),children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`w-6 text-center text-sm shrink-0`,children:zt(e.mimeType)}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:`flex-1 min-w-0 flex flex-col text-sm text-left hover:text-primary transition-colors`,children:[(0,q.jsx)(`span`,{className:`font-medium truncate text-foreground`,children:e.filename}),(0,q.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[Rt(e.size),` · `,Bt(e.addedAt)]})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`text-[11px] text-primary hover:underline shrink-0`,children:i(`common:actions.open`)}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>f(e),"aria-label":i(`removeFile`,{name:e.filename}),disabled:t,className:`w-6 h-6 inline-flex items-center justify-center rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors disabled:opacity-50`,children:`×`})]},e.id)})}),s&&(0,q.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:s}),(0,q.jsx)(It,{ticketKey:e,attachment:l,onClose:()=>u(null)})]})}function Ht({ticketId:e,onClose:t}){let{t:n}=p(`code`),r=a(),{activeProjectId:i}=P(),[o,s]=(0,G.useState)(null);return(0,G.useEffect)(()=>{if(!We)return;let t=new AbortController;return s(null),fetch(`${N()}/code/provenance?ticketId=${e}`,{signal:t.signal}).then(e=>e.ok?e.json():[]).then(e=>{s(Array.isArray(e)?e:[])}).catch(e=>{e?.name!==`AbortError`&&s([])}),()=>t.abort()},[e,i]),!We||!o||o.length===0?null:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:n(`ticketFiles.title`)}),(0,q.jsx)(`ul`,{className:`space-y-1`,children:o.map((e,i)=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{t(),r(`/code?path=${encodeURIComponent(e.path)}`)},className:`w-full text-left flex items-center gap-2 rounded px-2 py-1 text-xs hover:bg-muted/40`,children:[(0,q.jsx)(e.kind===`created`?z:e.kind===`deleted`?Ee:ne,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,q.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.path}),e.jobId&&(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground font-mono shrink-0`,title:n(`ticketFiles.jobTitle`,{jobId:e.jobId}),children:[(0,q.jsx)(B,{className:`h-3 w-3`}),e.jobId.length>10?e.jobId.slice(0,10):e.jobId]}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider shrink-0`,children:n(`kind.${e.kind}`)})]})},`${e.path}-${i}`))})]})}var Ut={critical:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,high:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,medium:``,low:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`};function Wt(e){try{return R(new Date(e),{addSuffix:!0,locale:s()})}catch{return e}}function Gt({tickets:e,excludeIds:t,onSelect:n}){let{t:r}=p(`tickets`),[i,a]=(0,G.useState)(``),o=(0,G.useMemo)(()=>{let n=new Set(t),r=e.filter(e=>e.status!==`cancelled`&&!n.has(e.id));if(!i.trim())return r;let a=i.toLowerCase();return r.filter(e=>e.title.toLowerCase().includes(a)||e.description.toLowerCase().includes(a))},[e,t,i]);return(0,q.jsxs)(`div`,{"data-testid":`spec-compare-picker`,className:`h-full flex flex-col rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`px-4 py-3 border-b border-border/30 flex items-center gap-2`,children:[(0,q.jsx)(U,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:r(`comparePicker.title`)}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`comparePicker.count`,{n:o.length})})]}),(0,q.jsx)(`div`,{className:`px-4 py-2 border-b border-border/20`,children:(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(A,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,q.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:r(`comparePicker.searchPlaceholder`),className:`w-full h-7 rounded border border-border bg-input pl-7 pr-2 text-[11px] text-foreground placeholder:text-muted-foreground outline-none focus:border-accent-primary/60`})]})}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`spec-compare-picker-list`,children:o.length===0?(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center px-4 py-8 gap-2`,children:[(0,q.jsx)(U,{className:`w-6 h-6 text-muted-foreground/40`}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.trim()?r(`comparePicker.noMatches`):r(`comparePicker.empty`)})]}):(0,q.jsx)(`ul`,{className:`divide-y divide-border/10`,children:o.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,"data-testid":`spec-compare-card-${e.id}`,onClick:()=>n(e.id),className:`w-full text-left px-4 py-2.5 hover:bg-accent/30 transition-colors flex items-start gap-2 group`,children:[(0,q.jsx)(et,{status:e.status}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:[`#`,e.id]}),e.priority&&Ut[e.priority]&&(0,q.jsx)(`span`,{className:`inline-flex items-center rounded px-1 py-0.5 text-[9px] font-medium border ${Ut[e.priority]}`,children:r(`priority.${e.priority}`)})]}),(0,q.jsx)(`p`,{className:`mt-0.5 text-xs text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title||r(`untitled`)}),e.description&&(0,q.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground line-clamp-1`,children:e.description.slice(0,120)}),e.labels&&e.labels.length>0&&(0,q.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[e.labels.slice(0,3).map(e=>(0,q.jsx)(`span`,{className:`inline-flex items-center rounded px-1 py-0.5 text-[9px] bg-accent/40 text-foreground/60`,children:e},e)),e.labels.length>3&&(0,q.jsxs)(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.labels.length-3]})]}),(0,q.jsx)(`p`,{className:`mt-1 text-[9px] text-muted-foreground`,children:r(`meta.updatedAgo`,{time:Wt(e.updated_at)})})]})]})},e.id))})})]})}var Kt=.25,qt=.75;function Jt({state:e,leftTicket:t,rightTicket:n,allTickets:r,allLabels:i,onSave:a,onDelete:o,onOpenTicket:s,onCloseAll:c,onSetCompared:l,onSetRatio:u,onExitSplit:d}){let f=(0,G.useRef)(null),p=(0,G.useRef)(null),[m,h]=(0,G.useState)(!0);(0,G.useEffect)(()=>{let e=setTimeout(()=>h(!1),320);return()=>clearTimeout(e)},[]);let g=(0,G.useCallback)(e=>{if(!p.current)return;let t=window.innerWidth,n=e.clientX/t;u(Math.min(qt,Math.max(Kt,n)))},[u]),_=(0,G.useCallback)(e=>{if(!p.current)return;let{pointerId:t,element:n}=p.current;try{n.releasePointerCapture(t)}catch{}p.current=null,window.removeEventListener(`pointermove`,g),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,_)},[g]),v=(0,G.useCallback)(e=>{let t=e.currentTarget;try{t.setPointerCapture(e.pointerId)}catch{}p.current={pointerId:e.pointerId,element:t},window.addEventListener(`pointermove`,g),window.addEventListener(`pointerup`,_),window.addEventListener(`pointercancel`,_)},[g,_]);(0,G.useEffect)(()=>()=>{window.removeEventListener(`pointermove`,g),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,_);let e=p.current;if(e){try{e.element.releasePointerCapture(e.pointerId)}catch{}p.current=null}},[g,_]);let y=(0,G.useCallback)(t=>{let n=.04;t.key===`ArrowLeft`?(t.preventDefault(),u(Math.max(Kt,e.splitRatio-n))):t.key===`ArrowRight`?(t.preventDefault(),u(Math.min(qt,e.splitRatio+n))):t.key===`Home`?(t.preventDefault(),u(Kt)):t.key===`End`?(t.preventDefault(),u(qt)):t.key===`0`&&(t.preventDefault(),u(.5))},[u,e.splitRatio]),b=e=>{e.target===e.currentTarget&&c()},x=u=>{let d=u===e.originSide,f=u===`left`?t:n;return f?(0,q.jsx)(Un,{ticket:f,allLabels:i,allTickets:r,onClose:d?c:()=>l(null,u),onOpenTicket:s,onSave:a,onDelete:o,embedded:!0},`${u}-${f.id}`):(0,q.jsx)(Gt,{tickets:r,excludeIds:[t?.id,n?.id].filter(e=>e!=null),onSelect:e=>l(e,u)})},S=(e.splitRatio*100).toFixed(2),C=((1-e.splitRatio)*100).toFixed(2);return(0,q.jsxs)(`div`,{ref:f,"data-testid":`split-view-shell`,className:`fixed inset-0 z-[68] flex`,onClick:b,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/70 pointer-events-none`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`relative flex w-full h-full`,style:{transition:m?`opacity 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:[(0,q.jsx)(`div`,{"data-testid":`split-panel-left`,className:`relative h-full overflow-hidden`,style:{width:`${S}%`,transition:m?`width 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:(0,q.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,q.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`left`)})})}),(0,q.jsx)(`div`,{"data-testid":`split-divider`,role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":Math.round(e.splitRatio*100),"aria-valuemin":Math.round(Kt*100),"aria-valuemax":Math.round(qt*100),tabIndex:0,onPointerDown:v,onKeyDown:y,className:`relative z-10 w-2 cursor-col-resize bg-border/40 hover:bg-accent-primary/40 transition-colors focus:outline-none focus:bg-accent-primary/60`}),(0,q.jsx)(`div`,{"data-testid":`split-panel-right`,className:`relative h-full overflow-hidden`,style:{width:`${C}%`,transition:m?`width 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:(0,q.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,q.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`right`)})})})]})]})}var Yt=.5,Xt=.25,Zt=.75,Qt={leftId:null,rightId:null,originSide:null,splitRatio:Yt};function $t(e){return Number.isFinite(e)?Math.min(Zt,Math.max(Xt,e)):Yt}function en(e,t){switch(t.type){case`openCentered`:return e.originSide!==null&&e.leftId!==t.id&&e.rightId!==t.id?{leftId:t.id,rightId:null,originSide:null,splitRatio:Yt}:e.originSide!==null&&(e.leftId===t.id||e.rightId===t.id)?e:{...Qt,leftId:t.id};case`closeAll`:return Qt;case`enterSplit`:{let n=t.ticketId??e.leftId;return n===null||e.originSide!==null?e:t.side===`left`?{leftId:n,rightId:null,originSide:`left`,splitRatio:Yt}:{leftId:null,rightId:n,originSide:`right`,splitRatio:Yt}}case`setComparedTicket`:{if(e.originSide===null)return e;let n=e.originSide===`left`?`right`:`left`;return t.side===n?t.side===`left`?{...e,leftId:t.id}:{...e,rightId:t.id}:e}case`exitSplit`:{if(e.originSide===null)return e;let t=e.originSide===`left`?e.leftId:e.rightId;return{...Qt,leftId:t}}case`setSplitRatio`:return{...e,splitRatio:$t(t.ratio)};default:return e}}var tn=(0,G.createContext)(null),nn=900;function rn({children:e}){let[t,n]=(0,G.useReducer)(en,Qt),{tickets:r,updateTicket:i,deleteTicket:a}=Ie(),{activeProjectId:o,setActiveProjectId:s}=P(),c=(0,G.useRef)(null);(0,G.useEffect)(()=>{n({type:`closeAll`});let e=c.current;e&&(c.current=null,e.projectId===o&&n({type:`openCentered`,id:e.ticketId}))},[o]);let l=(0,G.useCallback)(e=>n({type:`openCentered`,id:e}),[]),u=(0,G.useCallback)((e,t)=>{if(e===o){n({type:`openCentered`,id:t});return}c.current={projectId:e,ticketId:t},s(e)},[o,s]),d=(0,G.useCallback)(()=>n({type:`closeAll`}),[]),f=(0,G.useCallback)((e,t)=>{typeof window<`u`&&window.innerWidth<nn||n({type:`enterSplit`,side:e,ticketId:t})},[]),p=(0,G.useCallback)((e,t)=>n({type:`setComparedTicket`,id:e,side:t}),[]),m=(0,G.useCallback)(()=>n({type:`exitSplit`}),[]),h=(0,G.useCallback)(e=>n({type:`setSplitRatio`,ratio:e}),[]);(0,G.useEffect)(()=>{if(typeof window>`u`)return;function e(){window.innerWidth<nn&&n({type:`exitSplit`})}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let g=(0,G.useMemo)(()=>{let e=new Set;for(let t of r)for(let n of t.labels??[])e.add(n);return Array.from(e).sort()},[r]),_=t.leftId==null?null:r.find(e=>e.id===t.leftId)??null,v=t.rightId==null?null:r.find(e=>e.id===t.rightId)??null,y=(0,G.useMemo)(()=>({openTicketDetail:l,openTicketDetailInProject:u,closeTicketDetail:d,enterSplit:f,setComparedTicket:p,exitSplit:m,setSplitRatio:h,state:t}),[l,u,d,f,p,m,h,t]),b=t.originSide!==null;return(0,q.jsxs)(tn.Provider,{value:y,children:[e,!b&&_&&(0,q.jsx)(Un,{ticket:_,allLabels:g,allTickets:r,onClose:d,onOpenTicket:l,onSave:i,onDelete:a},_.id),b&&(0,q.jsx)(Jt,{state:t,leftTicket:_,rightTicket:v,allTickets:r,allLabels:g,onSave:i,onDelete:a,onOpenTicket:l,onCloseAll:d,onSetCompared:p,onSetRatio:h,onExitSplit:m})]})}function an(){return(0,G.useContext)(tn)||{openTicketDetail:()=>{typeof console<`u`&&console.warn(`[TicketDetailModalContext] openTicketDetail called without provider`)},openTicketDetailInProject:()=>{typeof console<`u`&&console.warn(`[TicketDetailModalContext] openTicketDetailInProject called without provider`)},closeTicketDetail:()=>{},enterSplit:()=>{},setComparedTicket:()=>{},exitSplit:()=>{},setSplitRatio:()=>{},state:Qt}}function on(e){return e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function sn(e){return e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function cn({ticketId:e}){let{t}=p(`tickets`),[n,r]=(0,G.useState)(null),i=a(),{activeProjectId:o}=P(),{closeTicketDetail:s}=an();if((0,G.useEffect)(()=>{let t=new AbortController;return r(null),fetch(`${N()}/tickets/${e}/spending-summary`,{signal:t.signal}).then(e=>e.ok?e.json():null).then(e=>{e&&r(e)}).catch(()=>{}),()=>t.abort()},[e,o]),!n||!n.bySurface||!n.totalRuns||n.totalRuns===0)return null;let c=Object.entries(n.bySurface).filter(([,e])=>e.count>0).map(([e,n])=>t(`spendingLine.breakdownItem`,{n:n.count,label:Se[e].toLowerCase()})).join(` + `);return(0,q.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(),i(`/analytics?ticketId=${e}`)},className:`mt-1.5 group inline-flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,"aria-label":t(`spendingLine.ariaLabel`),children:[(0,q.jsxs)(`span`,{className:`tabular-nums font-medium text-foreground`,title:(n.estimatedCostUsd??0)>0?t(`spendingLine.estimatedTooltip`):void 0,children:[(n.estimatedCostUsd??0)>0?`~`:``,on(n.totalCostUsd)]}),(0,q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:t(`spendingLine.turns`,{count:n.totalTurns})}),(0,q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:t(`spendingLine.active`,{duration:sn(n.activeDurationMs)})}),c&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,q.jsx)(`span`,{children:c})]}),(0,q.jsx)(v,{className:`w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity`})]})}var ln=/^\d{4}-\d{2}-\d{2}T/;function un(e){if(ln.test(e))try{return{text:R(gt(e),{addSuffix:!0,locale:s()}),title:e}}catch{}return{text:e}}function dn({localId:e}){let{t}=p(`jira`),{activeProjectId:n}=P(),r=Ze(),[i,a]=(0,G.useState)(null);if((0,G.useEffect)(()=>{if(!Ge||!r.connected)return;let t=!1;return a(null),L.getSpecDetails(e).then(e=>{t||a(e)}).catch(()=>{t||a(null)}),()=>{t=!0}},[e,n,r.connected]),!Ge||!r.connected||!i)return null;let o=i.development,s=i.fields.length>0,c=o.pullRequests.length>0,l=o.branches.length>0,u=(o.commits?.length??0)>0;return!s&&!c&&!l&&!u?null:(0,q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-details-panel`,children:[s&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.detailsTitle`)}),(0,q.jsx)(`div`,{className:`space-y-1.5`,children:i.fields.map((e,t)=>{let n=un(e.value);return(0,q.jsxs)(`div`,{className:`text-xs`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block`,children:e.label}),e.href?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.href)},className:`inline-flex items-center gap-1 text-accent-info hover:underline text-left`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:e.value}),(0,q.jsx)(ee,{className:`w-3 h-3 shrink-0`})]}):(0,q.jsx)(`span`,{className:`text-foreground/80 whitespace-pre-line`,title:n.title,children:n.text})]},`${e.label}-${t}`)})})]}),(c||l||u)&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.developmentTitle`)}),c&&(0,q.jsxs)(`div`,{className:`mb-2`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.pullRequests`)}),(0,q.jsx)(`div`,{className:`space-y-1`,children:o.pullRequests.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.url)},className:`w-full flex items-start gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-pr`,children:[(0,q.jsx)(De,{className:`w-3 h-3 mt-0.5 shrink-0 text-accent-info`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`truncate text-foreground/80 block`,children:e.title}),(0,q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[e.status,e.sourceBranch?` · ${e.sourceBranch} → ${e.destBranch??``}`:``]})]})]},e.url))})]}),l&&(0,q.jsxs)(`div`,{className:`mb-2`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.branches`)}),(0,q.jsx)(`div`,{className:`space-y-1`,children:o.branches.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.url)},className:`w-full flex items-center gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-branch`,children:[(0,q.jsx)(k,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,q.jsx)(`span`,{className:`truncate font-mono text-foreground/80`,children:e.name}),e.repo&&(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate`,children:e.repo})]},e.url))})]}),u&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.commits`)}),(0,q.jsx)(`div`,{className:`space-y-1`,children:o.commits.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.url)},className:`w-full flex items-center gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-commit`,children:[(0,q.jsx)(B,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:e.displayId}),(0,q.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.message})]},e.url))})]})]})]})}var fn=e(r(),1);function pn({open:e,url:t,projectId:n,onClose:r}){let{t:i}=p(`browser`),a=C({projectId:n,open:e,initialUrl:t}),{canvasRef:o,viewport:s,status:c,errorMsg:l,url:u,title:d,popup:f}=a,[m,h]=(0,G.useState)(t),S=(0,G.useRef)(a.forwardInput);S.current=a.forwardInput;let T=(0,G.useRef)(null),E=(0,G.useCallback)(()=>(T.current??=b(e=>S.current(e)),T.current),[]);(0,G.useEffect)(()=>()=>{T.current?.dispose(),T.current=null},[]),(0,G.useEffect)(()=>{u&&h(u)},[u]),(0,G.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,r]);let D=(0,G.useCallback)((e,t)=>{let n=o.current?.getBoundingClientRect();return n?_({x:e,y:t},{left:n.left,top:n.top,width:n.width,height:n.height},s):{x:0,y:0}},[o,s]),te=e=>e===2?`right`:e===1?`middle`:`left`,O=(0,G.useCallback)(e=>{let t=D(e.clientX,e.clientY);E().move(t.x,t.y)},[D,E]),ne=(0,G.useCallback)(e=>{let t=D(e.clientX,e.clientY),n=E();n.move(t.x,t.y),n.flush(),a.forwardInput({type:`mouse`,action:`down`,x:t.x,y:t.y,button:te(e.button),clickCount:e.detail||1})},[D,a,E]),k=(0,G.useCallback)(e=>{let t=D(e.clientX,e.clientY),n=E();n.move(t.x,t.y),n.flush(),a.forwardInput({type:`mouse`,action:`up`,x:t.x,y:t.y,button:te(e.button),clickCount:e.detail||1})},[D,a,E]),re=(0,G.useCallback)(e=>{let t=D(e.clientX,e.clientY);E().wheel(t.x,t.y,e.deltaX,e.deltaY)},[D,E]),ie=(0,G.useCallback)(e=>{if(e.key===`Escape`)return;let t=e.metaKey||e.ctrlKey;if(t&&(e.key===`c`||e.key===`v`||e.key===`x`)){e.preventDefault();let t=e.key;(async()=>{try{if(t===`v`){let e=await navigator.clipboard.readText();e&&await a.clipboard(`paste`,e)}else{let{text:e}=await a.clipboard(t===`x`?`cut`:`copy`);e&&await navigator.clipboard.writeText(e)}}catch{}})();return}let n={type:`key`,action:`down`,key:e.key,code:e.code,text:!t&&e.key.length===1?e.key:void 0};a.forwardInput(n),(e.key===`Tab`||e.key===` `||e.key.startsWith(`Arrow`))&&e.preventDefault()},[a]),ae=(0,G.useCallback)(e=>{e.key!==`Escape`&&a.forwardInput({type:`key`,action:`up`,key:e.key,code:e.code})},[a]),oe=(0,G.useCallback)(()=>{a.navigate(`goto`,m)},[a,m]);return!e||typeof document>`u`?null:(0,fn.createPortal)((0,q.jsx)(`div`,{className:`fixed inset-0 z-[80] bg-background-deep/50 backdrop-blur-sm pointer-events-auto`,onClick:e=>{e.target===e.currentTarget&&r()},"data-testid":`webview-modal`,children:(0,q.jsxs)(`div`,{className:`absolute inset-2 flex flex-col border border-border rounded-lg bg-background-deep overflow-hidden`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`modal.dialogLabel`),onClick:e=>e.stopPropagation(),children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border/50 bg-surface/80 shrink-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`common:actions.back`),onClick:()=>a.navigate(`back`),children:(0,q.jsx)(g,{className:`w-4 h-4`})}),(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.forward`),onClick:()=>a.navigate(`forward`),children:(0,q.jsx)(v,{className:`w-4 h-4`})}),(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.reload`),onClick:()=>a.navigate(`reload`),children:(0,q.jsx)(x,{className:`w-4 h-4`})})]}),(0,q.jsxs)(`form`,{className:`flex-1 flex items-center gap-2 min-w-0`,onSubmit:e=>{e.preventDefault(),oe()},children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0 rounded-md border border-border bg-background px-2.5 py-1`,children:[(0,q.jsx)(y,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,q.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),oe())},placeholder:i(`modal.address.placeholder`),"aria-label":i(`modal.address.label`),className:`flex-1 min-w-0 bg-transparent outline-none text-sm`})]}),(0,q.jsx)(F,{type:`submit`,size:`sm`,variant:`secondary`,className:`shrink-0`,disabled:c===`error`,children:i(`modal.address.go`)})]}),(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.closeBrowser`),onClick:r,children:(0,q.jsx)(ue,{className:`w-4 h-4`})})]}),(0,q.jsxs)(`div`,{className:`px-3 py-1 text-[11px] text-muted-foreground truncate shrink-0 flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full shrink-0 ${c===`ready`?`bg-accent-success`:c===`error`?`bg-destructive`:`bg-accent-warning animate-pulse`}`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`truncate`,children:c===`connecting`?i(`modal.status.connecting`):c===`error`?l??i(`modal.status.unavailable`):d||``})]}),f&&(0,q.jsxs)(`div`,{"data-testid":`webview-popup-bar`,className:`flex items-center gap-2 px-3 py-1.5 text-xs border-b shrink-0 ${f.active?`bg-accent-info/10 border-accent-info/30 text-accent-info`:`bg-surface/70 border-border/40 text-muted-foreground`}`,children:[(0,q.jsx)(ee,{className:`w-3.5 h-3.5 shrink-0`}),f.active?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`truncate font-medium`,children:i(`popup.loginWindow`,{origin:w(f.url)})}),f.count>1&&(0,q.jsx)(`span`,{className:`shrink-0 opacity-70`,children:i(`popup.stacked`,{count:f.count-1})}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>a.setPopupView(`root`),className:`ml-auto shrink-0 inline-flex items-center gap-1 h-6 px-2 rounded-md border border-current/30 hover:bg-card/60 transition-colors`,children:[(0,q.jsx)(g,{className:`w-3 h-3`}),i(`popup.backToPage`)]})]}):(0,q.jsxs)(`button`,{type:`button`,onClick:()=>a.setPopupView(`popup`),className:`inline-flex items-center gap-1 h-6 px-2 rounded-md border border-border/50 hover:bg-card/60 hover:text-foreground transition-colors`,children:[i(`popup.show`),f.count>1&&(0,q.jsx)(`span`,{className:`opacity-70`,children:i(`popup.stacked`,{count:f.count-1})})]})]}),(0,q.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden flex items-center justify-center outline-none`,tabIndex:0,onKeyDown:ie,onKeyUp:ae,children:c===`error`?(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center max-w-md px-6`,children:[(0,q.jsx)(le,{className:`w-8 h-8 text-accent-warning`}),(0,q.jsx)(`p`,{className:`text-sm text-foreground/90`,children:l??i(`modal.error.unavailable`)})]}):(0,q.jsx)(`canvas`,{ref:o,className:`max-w-full max-h-full block shadow-2xl cursor-default`,onPointerMove:O,onPointerDown:ne,onPointerUp:k,onContextMenu:e=>e.preventDefault(),onWheel:re})})]})}),document.body)}var mn=(0,G.createContext)(null);function hn({children:e}){let{activeProjectId:t}=P(),[n,r]=(0,G.useState)(null),i=(0,G.useCallback)(e=>r(e),[]),a=S();return(0,q.jsxs)(mn.Provider,{value:{openWebView:i,canOpenWebView:a&&!!t},children:[e,a&&n&&t&&(0,q.jsx)(pn,{open:!0,url:n,projectId:t,onClose:()=>r(null)})]})}function gn(){return(0,G.useContext)(mn)??{openWebView:()=>{},canOpenWebView:!1}}var _n={analyzing:`activity:smash.stage.analyzing`,identifying:`activity:smash.stage.identifying`,ordering:`activity:smash.stage.ordering`},vn=(0,G.createContext)(null);function $(e){return`smash:${e}`}async function yn(e,t){try{let n=await fetch(`${j}/api/projects/${e}/tickets/${t}/smash`,{method:`POST`});if(n.ok)h.loading(u.t(`activity:smash.retrying`),{id:$(t)});else{let e=await n.json().catch(()=>({}));h.error(e.reason?u.t(`activity:smash.couldNotRetryWithReason`,{reason:e.reason}):u.t(`activity:smash.couldNotRetry`),{id:$(t)})}}catch(e){h.error(u.t(`activity:smash.retryFailed`,{message:e.message}),{id:$(t)})}}async function bn(e,t,n){try{let r=await fetch(`${j}/api/projects/${e}/tickets/${t}/smash/undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({smashedAt:n})});if(r.ok)h.success(u.t(`activity:smash.undone`),{id:$(t),duration:3e3});else{let e=await r.json().catch(()=>({}));h.error(e.reason?u.t(`activity:smash.undoFailedWithReason`,{reason:e.reason}):u.t(`activity:smash.undoFailed`),{id:$(t)})}}catch(e){h.error(u.t(`activity:smash.undoFailedWithReason`,{reason:e.message}),{id:$(t)})}}function xn({children:e}){let{registerHandler:t,unregisterHandler:n}=M(),[r,i]=(0,G.useState)({}),a=(0,G.useRef)(new Map),o=(0,G.useRef)(new Map),s=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.started`)return;let n=t.ticketId,r=t.runId,o=t.projectId,s=t.timestamp,c=t.ticketTitle;typeof n!=`number`||!r||!o||(a.current.set(n,o),i(e=>({...e,[n]:{ticketId:n,runId:r,stage:`analyzing`,startedAt:s??new Date().toISOString(),ticketTitle:c}})),h.loading(u.t(_n.analyzing),{id:$(n),description:c?u.t(`activity:smash.onTitled`,{title:c}):u.t(`activity:smash.onThisSpec`)}))},[]),c=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.progress`)return;let n=t.ticketId,r=t.stage;if(typeof n!=`number`||!r)return;let a;i(e=>{let t=e[n];return t?(a=t.ticketTitle,{...e,[n]:{...t,stage:r}}):e}),h.loading(u.t(_n[r]),{id:$(n),description:a?u.t(`activity:smash.onTitled`,{title:a}):u.t(`activity:smash.onThisSpec`)})},[]),l=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.completed`)return;let n=t.ticketId,r=t.runId,a=t.projectId,s=t.smashedAt,c=t.childrenIds;typeof n!=`number`||!r||!a||!s||!c||(o.current.set(r,s),i(e=>{let t={...e};return delete t[n],t}),h.success(u.t(`activity:smash.split`,{count:c.length}),{id:$(n),duration:1e4,action:{label:u.t(`activity:smash.undoAction`),onClick:()=>void bn(a,n,s)}}))},[]),d=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.failed`)return;let n=t.ticketId,r=t.projectId,o=t.reason??`unknown`;if(typeof n!=`number`||!r)return;a.current.set(n,r),i(e=>{let t={...e};return delete t[n],t});let s=o===`invalid-output`?u.t(`activity:smash.failReason.invalidOutput`):o===`timeout`?u.t(`activity:smash.failReason.timeout`):o===`model_error`?u.t(`activity:smash.failReason.modelError`):o===`crashed`?u.t(`activity:smash.failReason.crashed`):u.t(`activity:smash.failReason.generic`,{reason:o});h.error(u.t(`activity:smash.couldNotComplete`),{id:$(n),description:s,action:{label:u.t(`common:actions.retry`),onClick:()=>void yn(r,n)},duration:15e3})},[]),f=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.undone`)return;let n=t.ticketId;typeof n==`number`&&(h.dismiss($(n)),h.success(u.t(`activity:smash.undone`),{id:$(n),duration:3e3}))},[]);(0,G.useLayoutEffect)(()=>(t(`_smash_started`,s),t(`_smash_progress`,c),t(`_smash_completed`,l),t(`_smash_failed`,d),t(`_smash_undone`,f),()=>{n(`_smash_started`),n(`_smash_progress`),n(`_smash_completed`),n(`_smash_failed`),n(`_smash_undone`)}),[t,n,s,c,l,d,f]),(0,G.useEffect)(()=>()=>{a.current.clear(),o.current.clear()},[]);let p=(0,G.useMemo)(()=>({inflight:r}),[r]);return(0,q.jsx)(vn.Provider,{value:p,children:e})}function Sn(e){let t=(0,G.useContext)(vn);return!t||e==null?null:t.inflight[e]??null}var Cn=150,wn={analyzing:0,identifying:1,ordering:2},Tn={analyzing:`smash.stage.analyzing`,identifying:`smash.stage.identifying`,ordering:`smash.stage.ordering`};function En({stage:e,minDisplayMs:t=Cn}){let{t:n}=p(`activity`),[r,i]=(0,G.useState)(e),a=(0,G.useRef)(Date.now()),o=(0,G.useRef)(null);if((0,G.useEffect)(()=>{if(e===r)return;let n=Date.now()-a.current,s=Math.max(0,t-n);return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i(e),a.current=Date.now(),o.current=null},s),()=>{o.current&&clearTimeout(o.current)}},[e,r,t]),!r)return null;let s=wn[r];return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-md border border-accent-highlight/40 bg-accent-highlight/10 text-sm text-foreground`,role:`status`,"aria-live":`polite`,"data-testid":`smash-status-pills`,children:[(0,q.jsx)(re,{className:`h-4 w-4 animate-spin text-accent-highlight`,"aria-hidden":!0}),(0,q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:[`analyzing`,`identifying`,`ordering`].map(e=>(0,q.jsx)(`span`,{className:[`inline-block w-1.5 h-1.5 rounded-full transition-all`,wn[e]<=s?`bg-accent-highlight`:`bg-muted`,e===r?`scale-125`:`scale-100`].join(` `),"aria-hidden":!0},e))}),(0,q.jsx)(`span`,{className:`font-medium`,children:n(Tn[r])})]})}var Dn={simple:{titleKey:`smashModal.modes.simple.title`,bulletKeys:[`smashModal.modes.simple.bullet1`,`smashModal.modes.simple.bullet2`,`smashModal.modes.simple.bullet3`],etaKey:`smashModal.modes.simple.eta`},full:{titleKey:`smashModal.modes.full.title`,bulletKeys:[`smashModal.modes.full.bullet1`,`smashModal.modes.full.bullet2`,`smashModal.modes.full.bullet3`,`smashModal.modes.full.bullet4`],etaKey:`smashModal.modes.full.eta`}};function On({open:e,ticketTitle:t,isReSmash:n,childrenCount:r,submitting:i=!1,onCancel:a,onConfirm:o}){let{t:s}=p(`activity`),[c,l]=(0,G.useState)(`simple`),{panelRef:u,panelStyle:d,headerHandleProps:m,resizeHandles:h,isFloating:g,guardBackdrop:_}=pe();return e?(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"data-testid":`smash-confirm-modal`,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:_(a)}),(0,q.jsxs)(`div`,{ref:u,className:`relative w-full max-w-lg m-4 rounded-xl glass-card border border-border/30 animate-in fade-in zoom-in-95 duration-150`,style:d,children:[(0,q.jsxs)(`div`,{...m,className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${g?`cursor-grab active:cursor-grabbing`:``}`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,q.jsx)(H,{className:`w-5 h-5 text-accent-highlight shrink-0 mt-0.5`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:s(`smashModal.title`)}),(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate`,title:t,children:t})]})]}),(0,q.jsx)(`button`,{type:`button`,onClick:a,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors shrink-0`,"aria-label":s(`common:actions.close`),children:(0,q.jsx)(ue,{className:`w-4 h-4`})})]}),n&&r>0&&(0,q.jsx)(`div`,{className:`mx-5 mt-4 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:(0,q.jsx)(f,{t:s,i18nKey:`smashModal.reSmashWarning`,count:r})}),(0,q.jsxs)(`div`,{className:`px-5 py-4 space-y-3`,children:[(0,q.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-medium`,children:s(`smashModal.modePickerLabel`)}),[`simple`,`full`].map(e=>{let t=Dn[e],n=c===e;return(0,q.jsx)(`button`,{type:`button`,onClick:()=>l(e),disabled:i,className:`w-full text-left rounded-lg border px-3 py-3 transition-colors ${n?`border-accent-highlight/60 bg-accent-highlight/10`:`border-border/40 bg-card/40 hover:bg-card/60 hover:border-border/60`}`,"data-testid":`smash-mode-${e}`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(`div`,{className:`mt-0.5 h-3.5 w-3.5 rounded-full border-2 shrink-0 ${n?`border-accent-highlight bg-accent-highlight`:`border-muted-foreground/60`}`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[e===`full`&&(0,q.jsx)(de,{className:`w-3.5 h-3.5 text-accent-highlight`,"aria-hidden":!0}),s(t.titleKey)]}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:s(t.etaKey)})]}),(0,q.jsx)(`ul`,{className:`space-y-0.5`,children:t.bulletKeys.map(e=>(0,q.jsxs)(`li`,{className:`text-[11px] text-foreground/70 leading-snug`,children:[`• `,s(e)]},e))})]})]})},e)})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-border/30 bg-surface/20`,children:[(0,q.jsx)(F,{variant:`ghost`,size:`sm`,onClick:a,disabled:i,children:s(`common:actions.cancel`)}),(0,q.jsxs)(F,{size:`sm`,onClick:()=>o(c),disabled:i,"data-testid":`smash-confirm-modal-continue`,children:[(0,q.jsx)(H,{className:`w-3.5 h-3.5 mr-1.5`}),s(i?`smashModal.starting`:n?`smashModal.confirmReSmash`:`smashModal.smash`)]})]})]}),(0,q.jsx)(ve,{handles:h})]}):null}var kn=`## Contract Layer`;function An(e,t){return!(!t||e.status===`draft`||e.parent_epic_id!=null||!e.description?.includes(kn))}function jn({ticket:e,projectId:t,featureFlagOn:n,childrenCount:r}){let{t:i}=p(`activity`),a=Sn(e.id),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),u=e.is_epic===!0,d=!u&&An(e,n),f=u&&n,m=u&&r>0,g=(0,G.useCallback)(async n=>{l(!0);try{let r=await fetch(`${j}/api/projects/${t}/tickets/${e.id}/smash`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:n})});if(!r.ok){let e=await r.json().catch(()=>({}));h.error(e.reason?i(`smash.couldNotStartWithReason`,{reason:e.reason}):i(`smash.couldNotStart`));return}s(!1)}catch(e){h.error(i(`smash.smashFailed`,{message:e.message}))}finally{l(!1)}},[t,e.id,i]),_=(0,G.useCallback)(async n=>{if(m){l(!0);try{if(!(await fetch(`${j}/api/projects/${t}/tickets/${e.id}/children`,{method:`DELETE`})).ok){h.error(i(`smash.couldNotDeleteChildren`)),l(!1);return}}catch(e){h.error(i(`smash.deleteFailed`,{message:e.message})),l(!1);return}}await g(n)},[m,g,t,e.id,i]);return!d&&!f?null:a?(0,q.jsx)(`div`,{className:`flex flex-col gap-2`,"data-testid":`smash-actions-streaming`,children:(0,q.jsx)(En,{stage:a.stage})}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(F,{size:`sm`,variant:`outline`,onClick:()=>s(!0),className:`border-accent-highlight/40 text-accent-highlight hover:bg-accent-highlight/10`,"data-testid":f?`resmash-button`:`smash-button`,children:[(0,q.jsx)(H,{className:`w-3.5 h-3.5 mr-1.5`}),i(f?`smash.reSmashButton`:`smash.smashButton`)]}),(0,q.jsx)(On,{open:o,ticketTitle:e.title,isReSmash:m,childrenCount:r,submitting:c,onCancel:()=>s(!1),onConfirm:_})]})}function Mn({epic:e,childExecutionOrder:t,totalChildren:n,onOpenEpic:r}){let{t:i}=p(`activity`);return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-accent-secondary/30 bg-accent-secondary/10 px-3 py-1.5 text-xs`,"data-testid":`epic-breadcrumb`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:r,className:`text-accent-secondary hover:underline font-medium`,children:[`← `,e.title]}),t!=null&&n>0&&(0,q.jsx)(`span`,{className:`text-foreground/60`,children:i(`epicChildren.step`,{order:t,total:n})})]})}var Nn={critical:`bg-red-400`,high:`bg-orange-400`,medium:`bg-yellow-400`,low:`bg-slate-400`};function Pn(e){return e?Nn[e]:`bg-muted`}function Fn(e){return[...e].sort((e,t)=>{let n=e.execution_order??1/0,r=t.execution_order??1/0;return n===r?e.id-t.id:n-r})}function In({ticket:e,allTickets:t,onOpenTicket:n}){let{t:r}=p(`activity`),i=e.is_epic===!0,a=e.parent_epic_id!=null;if(!i&&!a)return null;if(i){let i=Fn(t.filter(t=>t.parent_epic_id===e.id));return(0,q.jsx)(Ln,{header:r(`family.subSpecsHeader`,{count:i.length}),rows:i,currentId:e.id,onOpenTicket:n,emptyMessage:r(`family.emptySubSpecs`)})}let o=t.find(t=>t.id===e.parent_epic_id)??null,s=Fn(t.filter(t=>t.parent_epic_id===e.parent_epic_id)),c=o?[o,...s]:s;return(0,q.jsx)(Ln,{header:r(`family.familyHeader`,{count:s.length}),rows:c,currentId:e.id,onOpenTicket:n,emptyMessage:r(`family.noSiblings`)})}function Ln({header:e,rows:t,currentId:n,onOpenTicket:r,emptyMessage:i}){let{t:a}=p(`activity`);return(0,q.jsxs)(`div`,{"data-testid":`epic-family-sidebar`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,q.jsx)(H,{className:`w-3 h-3 text-accent-highlight`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:e})]}),t.length===0?(0,q.jsx)(`p`,{className:`text-[10px] text-foreground/50 italic`,children:i}):(0,q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:t.map(e=>{let t=e.id===n,i=e.is_epic===!0;return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{t||r(e.id)},disabled:t,"aria-label":a(i?`family.openParentEpic`:`family.openSubSpec`,{title:e.title}),"aria-current":t?`page`:void 0,className:[`w-full flex items-center gap-1.5 rounded px-1.5 py-1 text-left transition-colors`,t?`bg-accent-highlight/15 cursor-default`:`hover:bg-muted/30 cursor-pointer`].join(` `),"data-testid":`epic-family-row-${e.id}`,children:[i?(0,q.jsx)(E,{className:`w-3 h-3 text-accent-highlight flex-shrink-0`,"aria-hidden":!0}):(0,q.jsx)(`span`,{className:`text-[9px] tabular-nums text-foreground/40 w-3 text-center flex-shrink-0`,children:e.execution_order??`–`}),(0,q.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${Pn(e.priority)}`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-[11px] truncate ${t?`text-foreground font-medium`:`text-foreground/80`}`,title:e.title,children:e.title})]})},e.id)})})]})}var Rn=900,zn=.2,Bn=[{value:`critical`,labelKey:`priority.critical`,className:`text-red-400`},{value:`high`,labelKey:`priority.high`,className:`text-orange-400`},{value:`medium`,labelKey:`priority.medium`,className:`text-yellow-400`},{value:`low`,labelKey:`priority.low`,className:`text-slate-400`}];function Vn(e){return e.jira_epic_key&&e.jira_url?e.jira_url.replace(/\/browse\/[^/]+$/,`/browse/${e.jira_epic_key}`):null}var Hn={manual:`source.manual`,"product-backlog":`source.productBacklog`,"propose-spec":`source.proposeSpec`,"get-backlog-specs":`source.getBacklogSpecs`,"free-prompt":`source.freePrompt`};function Un({ticket:e,allLabels:t,allTickets:n,onClose:r,onOpenTicket:i,onSave:a,onDelete:o,rails:s,onMoveToRail:c,onRemoveFromRail:l,embedded:u=!1}){let{t:d}=p(`tickets`),{t:m}=p(`jira`),{activeProjectId:g,projects:_}=P(),{enterSplit:y,state:b}=an(),x=b.originSide!==null,S=_.find(e=>e.id===g)?.provider!==`codex`,C=(0,G.useMemo)(()=>(n??[]).filter(t=>t.parent_epic_id===e.id),[n,e.id]),w=(0,G.useMemo)(()=>e.parent_epic_id==null?null:(n??[]).find(t=>t.id===e.parent_epic_id)??null,[n,e.parent_epic_id]),T=(0,G.useMemo)(()=>w?(n??[]).filter(e=>e.parent_epic_id===w.id).length:0,[n,w]),[E,D]=(0,G.useState)(e.title),[O,ne]=(0,G.useState)(e.description),[k,ae]=(0,G.useState)(e.priority??`medium`),[A,le]=(0,G.useState)([...e.labels??[]]),[de,j]=(0,G.useState)(!1),[M,N]=(0,G.useState)(!1),[I,L]=(0,G.useState)(``),[be,xe]=(0,G.useState)(!1),[R,Se]=(0,G.useState)(!1),[Ce,we]=(0,G.useState)(!1),[Ee,z]=(0,G.useState)(!1),[B,De]=(0,G.useState)(!1),[V,H]=(0,G.useState)(!1),U=Ze(),W=U.connected&&!!U.discardStatus&&e.source===`jira`&&!!e.jira_key,Oe=U.connected&&e.source===`jira`&&!!e.jira_key,[ke,Ae]=(0,G.useState)(e.attachments??[]);(0,G.useEffect)(()=>{Ae(e.attachments??[])},[e.attachments,e.id]);let je=(0,G.useRef)(null),Me=(0,G.useRef)(null),Ne=(0,G.useRef)(null),K=(0,G.useMemo)(()=>E!==e.title||O!==e.description||k!==e.priority||JSON.stringify(A)!==JSON.stringify(e.labels),[E,O,k,A,e]);(0,G.useEffect)(()=>{de&&je.current?.focus()},[de]),(0,G.useEffect)(()=>{if(M){let e=Me.current;e&&(e.focus(),e.selectionStart=e.value.length)}},[M]),(0,G.useEffect)(()=>{be&&Ne.current?.focus()},[be]),(0,G.useEffect)(()=>{function e(e){e.key===`Escape`&&!de&&!M&&!R&&r()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,de,M,R]);let Pe=(0,G.useMemo)(()=>{if(!I.trim())return[];let e=I.toLowerCase();return t.filter(t=>t.toLowerCase().includes(e)&&!A.includes(t)).slice(0,5)},[I,t,A]),Fe=(0,G.useCallback)(e=>{let t=e.trim();t&&!A.includes(t)&&le(e=>[...e,t]),L(``)},[A]),Ie=(0,G.useCallback)(e=>{le(t=>t.filter(t=>t!==e))},[]),Le=(0,G.useCallback)(async()=>{let t={};if(E!==e.title&&(t.title=E),O!==e.description&&(t.description=O),k!==e.priority&&(t.priority=k),JSON.stringify(A)!==JSON.stringify(e.labels)&&(t.labels=A),Object.keys(t).length===0){r();return}De(!0);let n=await a(e.id,t);De(!1),n?(h.success(d(`detailModal.toast.updated`)),r()):h.error(d(`detailModal.toast.updateFailed`))},[E,O,k,A,e,a,r,d]),Re=(0,G.useCallback)(async()=>{if(V)return;H(!0);let t=!1;try{t=await o(e.id)}catch{t=!1}if(H(!1),!t){h.error(d(`detailModal.toast.deleteFailed`));return}Se(!1),r()},[V,e.id,o,r,d]),[ze,Be]=(0,G.useState)(0),J=(0,G.useRef)(null),[Ve,He]=(0,G.useState)(()=>typeof window<`u`&&window.innerWidth>=Rn);(0,G.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>He(window.innerWidth>=Rn);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let Y=!u&&!x&&Ve,X=(0,G.useCallback)(e=>{J.current&&Be(e.clientX-J.current.startX)},[]),Z=(0,G.useCallback)(t=>{if(!J.current)return;let n=t.clientX-J.current.startX,i=window.innerWidth*zn;if(window.removeEventListener(`pointermove`,X),window.removeEventListener(`pointerup`,Z),window.removeEventListener(`pointercancel`,Z),J.current=null,Be(0),Math.abs(n)>=i&&window.innerWidth>=Rn){let t=b.leftId===e.id;y(n<0?`left`:`right`,e.id),t||r()}},[y,X,b.leftId,e.id,r]),Ue=(0,G.useCallback)(e=>{Y&&e.button===0&&(e.target.closest(`button, input, textarea, select, [contenteditable="true"]`)||(J.current={startX:e.clientX,pointerId:e.pointerId},window.addEventListener(`pointermove`,X),window.addEventListener(`pointerup`,Z),window.addEventListener(`pointercancel`,Z)))},[Y,X,Z]);(0,G.useEffect)(()=>()=>{J.current&&(window.removeEventListener(`pointermove`,X),window.removeEventListener(`pointerup`,Z),window.removeEventListener(`pointercancel`,Z))},[X,Z]);let We=(0,G.useCallback)(()=>{if(!Y||window.innerWidth<Rn)return;let t=b.leftId===e.id;y(`right`,e.id),t||r()},[Y,y,b.leftId,e.id,r]),{panelRef:Ge,panelStyle:Ke,resizeHandles:qe,guardBackdrop:Je}=pe({enabled:!u,allowMove:!1}),Ye=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{ref:Ge,className:u?`relative w-full h-full rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 flex flex-col overflow-hidden`:`relative w-full max-w-[67rem] m-4 rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 flex flex-col animate-in fade-in zoom-in-95 duration-200 h-[90vh]`,style:{...ze===0?{transition:`transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1)`}:{transform:`translateX(${ze}px)`,transition:`none`},...Ke},children:[w&&(0,q.jsx)(`div`,{className:`px-5 pt-3`,children:(0,q.jsx)(Mn,{epic:w,childExecutionOrder:e.execution_order??null,totalChildren:T,onOpenEpic:()=>i?.(w.id)})}),(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${Y?`cursor-grab active:cursor-grabbing`:``}`,onPointerDown:Ue,"data-testid":`ticket-modal-header`,children:[(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[de?(0,q.jsx)(`input`,{ref:je,value:E,onChange:e=>D(e.target.value),onBlur:()=>j(!1),onKeyDown:t=>{t.key===`Enter`&&j(!1),t.key===`Escape`&&(D(e.title),j(!1))},className:`w-full bg-transparent border-b border-accent-primary/50 text-sm font-semibold text-foreground outline-none pb-0.5`}):(0,q.jsxs)(`button`,{type:`button`,onClick:()=>j(!0),className:`group flex items-center gap-1.5 text-left w-full`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:E||d(`untitled`)}),(0,q.jsx)(ie,{className:`w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,q.jsxs)(`span`,{className:`text-[10px] text-foreground font-mono`,children:[`#`,e.id]}),e.status===`on_review`&&(0,q.jsx)(`span`,{title:d(`specs:status.onReviewHint`),"data-testid":`ticket-modal-on-review-badge`,children:(0,q.jsx)(tt,{status:`on_review`})})]}),(0,q.jsx)(cn,{ticketId:e.id})]}),g&&(0,q.jsx)(`div`,{className:`shrink-0`,children:(0,q.jsx)(jn,{ticket:e,projectId:g,featureFlagOn:S,childrenCount:C.length})}),(0,q.jsx)(Gn,{ticket:e,title:E,description:O,priority:k,labels:A,onClose:r}),s&&(c||l)&&(0,q.jsx)(Kn,{ticket:e,rails:s,onMoveToRail:c,onRemoveFromRail:l}),Y&&(0,q.jsxs)(F,{variant:`outline`,size:`sm`,className:`shrink-0 mr-1 gap-1.5`,"data-testid":`ticket-modal-compare`,onClick:We,title:d(`detailModal.compareTooltip`),children:[(0,q.jsx)(Te,{className:`w-3.5 h-3.5`}),d(`detailModal.compare`)]}),(0,q.jsx)(`button`,{onClick:r,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors cursor-pointer shrink-0`,"data-testid":`ticket-modal-close`,children:(0,q.jsx)(ue,{className:`w-4 h-4`})})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:(0,q.jsxs)(`div`,{className:`flex flex-col sm:flex-row h-full`,children:[(0,q.jsxs)(`div`,{className:`flex-1 min-w-0 px-5 py-4 space-y-4 flex flex-col`,children:[(0,q.jsxs)(`div`,{className:`flex-1 flex flex-col`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5`,children:d(`fields.description`)}),!M&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>N(!0),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,q.jsx)(ie,{className:`w-2.5 h-2.5`}),d(`common:actions.edit`)]})]}),M?(0,q.jsxs)(`div`,{className:`space-y-1.5 flex-1 flex flex-col`,children:[(0,q.jsx)(`textarea`,{ref:Me,value:O,onChange:e=>ne(e.target.value),className:`w-full flex-1 rounded-lg border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-none min-h-[300px]`,placeholder:d(`fields.markdownPlaceholder`)}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(F,{variant:`ghost`,size:`sm`,className:`h-6 text-[10px]`,onClick:()=>N(!1),children:d(`detailModal.doneEditing`)}),(0,q.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:d(`fields.supportsMarkdown`)})]})]}):O?(0,q.jsx)(Xn,{description:O,onEdit:()=>N(!0)}):(0,q.jsx)(`button`,{type:`button`,onClick:()=>N(!0),className:`w-full rounded-lg border border-dashed border-border/40 bg-muted/10 px-3 py-4 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/20 transition-colors text-center`,children:d(`detailModal.addDescription`)})]}),(0,q.jsx)(Vt,{ticketKey:e.id,attachments:ke,onChange:Ae}),(0,q.jsx)(Ht,{ticketId:e.id,onClose:r}),e.prerequisites&&e.prerequisites.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`detailModal.prerequisites`)}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.prerequisites.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-mono bg-accent/60 text-foreground/70`,children:[`#`,e]},e))})]})]}),(0,q.jsxs)(`div`,{className:`sm:w-56 sm:border-l border-t sm:border-t-0 border-border/30 px-4 py-4 space-y-4 bg-muted/5`,children:[e.jira_url&&e.jira_key&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.jira_url)},"data-testid":`jira-go-to-ticket`,className:`w-full inline-flex items-center justify-center gap-1.5 h-7 rounded border border-accent-info/50 bg-accent-info/10 px-2 text-xs font-medium text-accent-info hover:bg-accent-info/20 transition-colors`,children:[(0,q.jsx)(ee,{className:`w-3.5 h-3.5 shrink-0`}),m(`detail.goToTicket`,{key:e.jira_key})]}),e.jira_epic_key&&(0,q.jsxs)(`div`,{"data-testid":`jira-epic`,children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:m(`detail.epic`)}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{let t=Vn(e);t&&Q(t)},title:e.jira_epic_name??e.jira_epic_key,className:`w-full inline-flex items-center gap-1.5 rounded border border-accent-highlight/40 bg-accent-highlight/5 px-2 py-1.5 text-left text-xs hover:bg-accent-highlight/10 transition-colors`,children:[(0,q.jsx)(`span`,{className:`font-mono text-accent-highlight shrink-0`,children:e.jira_epic_key}),e.jira_epic_name&&(0,q.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.jira_epic_name})]})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.priority`)}),(0,q.jsx)(`select`,{value:k,onChange:e=>ae(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:Bn.map(e=>(0,q.jsx)(`option`,{value:e.value,children:d(e.labelKey)},e.value))})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.labels`)}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:A.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] font-medium bg-accent/60 text-foreground/70 group`,children:[e,(0,q.jsx)(`button`,{type:`button`,onClick:()=>Ie(e),className:`text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,q.jsx)(te,{className:`w-2.5 h-2.5`})})]},e))}),be?(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(`input`,{ref:Ne,value:I,onChange:e=>L(e.target.value),onKeyDown:e=>{e.key===`Enter`&&I.trim()&&(e.preventDefault(),Fe(I)),e.key===`Escape`&&(xe(!1),L(``))},onBlur:()=>{I.trim()&&Fe(I),xe(!1),L(``)},placeholder:d(`detailModal.addLabelPlaceholder`),className:`w-full h-6 rounded border border-border bg-input px-2 text-[10px] text-foreground placeholder:text-muted-foreground`}),Pe.length>0&&(0,q.jsx)(`div`,{className:`absolute left-0 right-0 top-full mt-0.5 rounded border border-border/50 bg-popover shadow-lg z-10 py-0.5`,children:Pe.map(e=>(0,q.jsx)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),Fe(e)},className:`w-full text-left px-2 py-1 text-[10px] hover:bg-accent/50 text-foreground/80`,children:e},e))})]}):(0,q.jsxs)(`button`,{type:`button`,onClick:()=>xe(!0),className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,q.jsx)(oe,{className:`w-2.5 h-2.5`}),d(`detailModal.addLabel`)]})]}),(0,q.jsx)(In,{ticket:e,allTickets:n??[],onOpenTicket:e=>i?.(e)}),e.source===`jira`&&e.jira_key&&(0,q.jsx)(dn,{localId:e.id}),e.metadata?.effort_level&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:d(`detailModal.effort`)}),(0,q.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.metadata.effort_level})]}),e.assignee&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:d(`detailModal.assignee`)}),(0,q.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.assignee})]})]})]})}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-t border-border/30`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:d(`meta.createdAgo`,{time:Wn(e.created_at)})}),(0,q.jsx)(`span`,{children:d(`meta.updatedAgo`,{time:Wn(e.updated_at)})}),e.source&&(0,q.jsx)(`span`,{className:`bg-muted/30 rounded px-1.5 py-0.5`,children:Hn[e.source]?d(Hn[e.source]):e.source})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[W?(0,q.jsxs)(F,{variant:`ghost`,size:`sm`,className:`h-7 text-xs text-accent-info hover:bg-accent-info/10`,onClick:()=>we(!0),"data-testid":`jira-move-to-button`,children:[(0,q.jsx)(v,{className:`w-3 h-3 mr-1`}),m(`discard.moveButton`,{status:U.discardStatus})]}):(0,q.jsxs)(F,{variant:`ghost`,size:`sm`,className:`h-7 text-xs text-red-400 aurora-light:text-destructive hover:text-red-300 aurora-light:hover:text-destructive hover:bg-red-500/10 aurora-light:hover:bg-destructive/10`,onClick:()=>Se(!0),children:[(0,q.jsx)(ce,{className:`w-3 h-3 mr-1`}),d(`common:actions.delete`)]}),K&&(0,q.jsxs)(F,{size:`sm`,className:`h-7 text-xs`,onClick:()=>{Oe?z(!0):Le()},disabled:B||!E.trim(),children:[(0,q.jsx)(se,{className:`w-3 h-3 mr-1`}),d(B?`common:states.saving`:`common:actions.save`)]})]})]})]}),(0,q.jsx)(ye,{open:R,onOpenChange:e=>{V||Se(e)},children:(0,q.jsxs)(he,{className:`max-w-sm`,children:[(0,q.jsxs)(fe,{children:[(0,q.jsx)(ge,{children:d(`deleteDialog.title`)}),(0,q.jsx)(_e,{children:(0,q.jsx)(f,{t:d,i18nKey:`deleteDialog.body`,values:{id:e.id,title:e.title},components:{strong:(0,q.jsx)(`span`,{className:`font-semibold text-foreground`})}})})]}),(0,q.jsxs)(me,{children:[(0,q.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>Se(!1),disabled:V,children:d(`common:actions.cancel`)}),(0,q.jsxs)(F,{variant:`destructive`,size:`sm`,onClick:()=>{Re()},disabled:V,"aria-busy":V,children:[V?(0,q.jsx)(re,{className:`w-3.5 h-3.5 mr-1.5 animate-spin`}):(0,q.jsx)(ce,{className:`w-3.5 h-3.5 mr-1.5`}),d(`common:actions.delete`)]})]})]})}),W&&U.discardStatus&&(0,q.jsx)(Qe,{open:Ce,onOpenChange:we,ticket:{id:e.id,title:e.title,jira_key:e.jira_key},discardStatus:U.discardStatus,onDiscarded:r}),(0,q.jsx)(ye,{open:Ee,onOpenChange:z,children:(0,q.jsxs)(he,{className:`max-w-md`,"data-testid":`jira-save-confirm`,children:[(0,q.jsxs)(fe,{children:[(0,q.jsx)(ge,{children:m(`detail.saveTitle`)}),(0,q.jsx)(_e,{children:m(`detail.saveBody`,{key:e.jira_key??`#${e.id}`})})]}),(0,q.jsxs)(me,{children:[(0,q.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>z(!1),children:d(`common:actions.cancel`)}),(0,q.jsxs)(F,{size:`sm`,onClick:()=>{z(!1),Le()},disabled:B,"data-testid":`jira-save-confirm-btn`,children:[(0,q.jsx)(se,{className:`w-3.5 h-3.5 mr-1.5`}),m(`detail.saveConfirm`)]})]})]})})]});return u?Ye:(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[68] flex items-center justify-center`,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/70`,onClick:Je(r)}),Ye,(0,q.jsx)(ve,{handles:qe})]})}function Wn(e){try{return R(new Date(e),{addSuffix:!0,locale:s()})}catch{return e}}function Gn({ticket:e,title:t,description:n,priority:r,labels:i,onClose:a}){let{t:o}=p(`tickets`),{triggerResume:s}=T(),{activeProjectId:c}=P(),{closeTicketDetail:l}=an();return Y(e)?(0,q.jsxs)(F,{variant:`default`,size:`sm`,onClick:()=>{if(!c)return;let{body:u,criteria:d}=Ve(n);s({kind:`explore-spec`,projectId:c,label:t||e.title||o(`detailModal.ticketFallbackLabel`,{id:e.id}),restoreRoute:`/`,params:{initialIdea:``,pendingSpecId:X(),initialAttachmentIds:[],resumeConversationId:e.origin_conversation_id??void 0,editTicket:{id:e.id,title:t,description:u,labels:i,priority:r,acceptanceCriteria:d,status:e.status}}}),l(),a()},className:`shrink-0 mr-2`,"data-testid":`continue-editing`,children:[(0,q.jsx)(V,{className:`w-3.5 h-3.5 mr-1.5`}),o(`detailModal.continueEditing`)]}):null}function Kn({ticket:e,rails:t,onMoveToRail:n,onRemoveFromRail:r}){let{t:i}=p(`tickets`),[a,o]=(0,G.useState)(null),s=(0,G.useRef)(null),c=t.find(t=>t.ticketIds.includes(e.id));return c?r?(0,q.jsxs)(F,{variant:`outline`,size:`sm`,className:`shrink-0 mr-2 gap-1.5 border-accent-warning/30 text-accent-warning hover:bg-accent-warning/10 hover:text-accent-warning`,"data-testid":`modal-remove-from-rail`,onClick:()=>r(e.id),title:i(`rail.currentlyOn`,{rail:c.label}),children:[(0,q.jsx)(g,{className:`w-3.5 h-3.5`,"aria-hidden":!0}),i(`rail.removeFromRail`)]}):null:n?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(F,{ref:s,variant:`outline`,size:`sm`,className:`shrink-0 mr-2 gap-1.5 border-accent-info/30 text-accent-info hover:bg-accent-info/10 hover:text-accent-info`,"data-testid":`modal-move-to-rail`,onClick:()=>{s.current&&o(s.current.getBoundingClientRect())},children:[i(`rail.moveToRail`),(0,q.jsx)(v,{className:`w-3.5 h-3.5`,"aria-hidden":!0})]}),a&&(0,q.jsx)(Be,{rails:t,anchorRect:a,onMoveToRail:t=>n(e.id,t),onClose:()=>o(null)})]}):null}var qn=`
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as e}from"./index-
|
|
1
|
+
import{f as e}from"./index-CewRMo0W.js";function t(e){if(e!==void 0){if(typeof e==`string`)return e;if(`ok`in e&&`cancel`in e)return{OkCancelCustom:[e.ok,e.cancel]};if(`yes`in e&&`no`in e&&`cancel`in e)return{YesNoCancelCustom:[e.yes,e.no,e.cancel]};if(`ok`in e)return{OkCustom:e.ok}}}async function n(t={}){return typeof t==`object`&&Object.freeze(t),await e(`plugin:dialog|open`,{options:t})}async function r(t={}){return typeof t==`object`&&Object.freeze(t),await e(`plugin:dialog|save`,{options:t})}async function i(n,r){return await e(`plugin:dialog|message`,{message:n,title:r?.title,kind:r?.kind,buttons:t(r?.buttons)})}async function a(e,t){let n=typeof t==`string`?{title:t}:t;return n&&!n.buttons&&n.okLabel&&(n.buttons={ok:n.okLabel}),i(e,n)}async function o(e,t){let n=typeof t==`string`?{title:t}:t,r=n?.okLabel||n?.cancelLabel,a=n?.okLabel??`Yes`;return await i(e,{title:n?.title,kind:n?.kind,buttons:r?{ok:a,cancel:n.cancelLabel??`No`}:`YesNo`})===a}async function s(e,t){let n=typeof t==`string`?{title:t}:t,r=n?.okLabel||n?.cancelLabel,a=n?.okLabel??`Ok`;return await i(e,{title:n?.title,kind:n?.kind,buttons:r?{ok:a,cancel:n.cancelLabel??`Cancel`}:`OkCancel`})===a}export{o as ask,s as confirm,a as message,n as open,r as save};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,f as t}from"./index-
|
|
1
|
+
import{d as e,f as t}from"./index-CewRMo0W.js";var n=class{constructor(){this.eventListeners=Object.create(null)}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}on(e,t){return e in this.eventListeners?this.eventListeners[e].push(t):this.eventListeners[e]=[t],this}once(e,t){let n=r=>{this.removeListener(e,n),t(r)};return this.addListener(e,n)}off(e,t){return e in this.eventListeners&&(this.eventListeners[e]=this.eventListeners[e].filter(e=>e!==t)),this}removeAllListeners(e){return e?delete this.eventListeners[e]:this.eventListeners=Object.create(null),this}emit(e,t){if(e in this.eventListeners){let n=this.eventListeners[e];for(let e of n)e(t);return!0}return!1}listenerCount(e){return e in this.eventListeners?this.eventListeners[e].length:0}prependListener(e,t){return e in this.eventListeners?this.eventListeners[e].unshift(t):this.eventListeners[e]=[t],this}prependOnceListener(e,t){let n=r=>{this.removeListener(e,n),t(r)};return this.prependListener(e,n)}},r=class{constructor(e){this.pid=e}async write(e){await t(`plugin:shell|stdin_write`,{pid:this.pid,buffer:e})}async kill(){await t(`plugin:shell|kill`,{cmd:`killChild`,pid:this.pid})}},i=class i extends n{constructor(e,t=[],r){super(),this.stdout=new n,this.stderr=new n,this.program=e,this.args=typeof t==`string`?[t]:t,this.options=r??{}}static create(e,t=[],n){return new i(e,t,n)}static sidecar(e,t=[],n){let r=new i(e,t,n);return r.options.sidecar=!0,r}async spawn(){let n=this.program,i=this.args,a=this.options;typeof i==`object`&&Object.freeze(i);let o=new e;return o.onmessage=e=>{switch(e.event){case`Error`:this.emit(`error`,e.payload);break;case`Terminated`:this.emit(`close`,e.payload);break;case`Stdout`:this.stdout.emit(`data`,e.payload);break;case`Stderr`:this.stderr.emit(`data`,e.payload);break}},await t(`plugin:shell|spawn`,{program:n,args:i,options:a,onEvent:o}).then(e=>new r(e))}async execute(){let e=this.program,n=this.args,r=this.options;return typeof n==`object`&&Object.freeze(n),await t(`plugin:shell|execute`,{program:e,args:n,options:r})}};async function a(e,n){await t(`plugin:shell|open`,{path:e,with:n})}export{r as Child,i as Command,n as EventEmitter,a as open};
|