1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=[window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "index.js.js" : "/index.js.js",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "vendor.js" : "/vendor.js",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "main.js" : "/main.js",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "mermaid.js" : "/mermaid.js",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "main.css" : "/main.css",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "pending-spec-message-store.js" : "/pending-spec-message-store.js",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "survey-sampling.js" : "/survey-sampling.js",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "RepoButton.js" : "/RepoButton.js",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "useInitiateProviderAuth.js" : "/useInitiateProviderAuth.js",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "oauth-state.js" : "/oauth-state.js",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "GitLabPatModal.js" : "/GitLabPatModal.js",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "useAvailableProviders.js" : "/useAvailableProviders.js",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "useCompleteProviderAuth.js" : "/useCompleteProviderAuth.js",window.__kiro_asset_base__ ? window.__kiro_asset_base__ + "tiptap.js" : "/tiptap.js"])))=>i.map(i=>d[i]); 2import{fg as nr,bl as r,bq as t,gp as rs,em as yt,bP as Y,bL as w,en as k,ex as ar,ew as bt,ga as Ns,g9 as Tt,ep as Nn,bN as Be,fS as Rs,bO as ze,gq as Rn,gr as $n,bM as rr,gs as or,gt as Us,eW as ir,bK as Vt,ei as $s,ev as Qt,dw as Tn,dM as In,eJ as lr,dV as cr,dJ as dr,bY as ur,bR as dt,gu as En,fZ as Pn,gv as fr,e_ as Ft,e$ as mr,dn as pr,gw as hr,f1 as gr,et as mt,eu as wr,eE as An,gx as Vs,f2 as xr,eY as yr,bW as Qs,f0 as br,gy as _r,gz as Ys,eX as vr,bn as Ln,fp as Sr,_ as kr}from"./vendor.js";import{H as Mn,V as jr,I as Cr,$ as Nr,X as Rr,J as $r,L as Tr,N as Dn,O as Ts,P as Ir,R as A,T as Er,U as Pr,W as Ar,Y as Lr,Z as Mr,_ as Fn,a0 as Is,a1 as On,a2 as Es,a3 as qt,a4 as Dr,a5 as Ps,a6 as Fr,a7 as Xs,a8 as Or,a9 as Wn,aa as Wr,ab as Br,ac as zr,ad as Kr,ae as Yt,af as Bn,ag as zn,ah as Kn,ai as Gn,aj as Gr,ak as Hr,al as qr,am as Ur,an as Vr,ao as Qr,ap as Yr,aq as Xr,ar as Xt,as as ys,at as Hn,au as Jr,d as Jt,av as qn,aw as Js,ax as Zr,ay as eo,az as to,aA as so,aB as Un,F as no,aC as ao,aD as ro,aE as oo,aF as io,aG as lo,aH as co,aI as uo,aJ as fo,aK as mo,aL as po,aM as ho,aN as go,aO as wo,aP as xo,aQ as yo,n as bs,h as Vn,aR as Qn,aS as Yn,aT as Xn,aU as bo,aV as _s,aW as _o,aX as vo,r as So,aY as Jn,aZ as ko,a_ as jo,a$ as Co,b0 as No,e as Ro,o as $o,b1 as To,b2 as Io,b3 as Eo,b4 as Po,b5 as Ao,Q as Lo,i as Mo,b6 as Do,b7 as Zs,b8 as Fo,b9 as Oo}from"./main.js";import"./mermaid.js";import{N as Zn,n as ea,y as ta,C as Wo,d as Bo,B as zo,Q as Ko,t as sa,p as Go,I as Ho,H as qo,l as Uo,e as Vo,i as Qo,g as Yo,b as na,J as aa,h as ra,Z as Xo,r as Jo,j as en}from"./pending-spec-message-store.js";import{g as Kt,c as Zo}from"./pending-autonomous-message-store.js";import{k as oa,g as Gt,c as ei,N as ti,S as si}from"./NetworkAccessSelector.js";import{R as ia,p as ni,r as ai,n as ri,O as oi}from"./useInitiateProviderAuth.js";import{g as ii}from"./MarkdownPreview.js";import{C as la,d as ca,c as li,a as ci,w as tn,F as da,f as di,Q as ua,p as ui}from"./survey-sampling.js";import{q as fa,K as ma,L as fi}from"./RepoButton.js";import{u as mi,F as pi}from"./constants.js";import{c as hi}from"./useAvailableProviders.js";import"./oauth-state.js";import"./GitLabPatModal.js";import"./useCompleteProviderAuth.js";const gi="_gaugeButton_rgt69_1",wi="_dropdown_rgt69_20",xi="_arrow_rgt69_25",yi="_card_rgt69_30",bi="_sparklineContainer_rgt69_38",_i="_kpiGrid_rgt69_46",vi="_kpiItem_rgt69_52",Si="_kpiLabel_rgt69_58",ki="_kpiValue_rgt69_68",ji="_ttftSection_rgt69_75",Ci="_ttftRow_rgt69_80",at={gaugeButton:gi,dropdown:wi,arrow:xi,card:yi,sparklineContainer:bi,kpiGrid:_i,kpiItem:vi,kpiLabel:Si,kpiValue:ki,ttftSection:ji,ttftRow:Ci};function Ni({values:s}){const e=Math.max(...s,1),a=260/(s.length-1),n=s.map((i,d)=>`${(d*a).toFixed(1)},${(60-i/e*60*.9-2).toFixed(1)}`).join(" "),o=`0,60 ${n} ${((s.length-1)*a).toFixed(1)},60`;return t.jsxs("svg",{width:"100%",height:60,viewBox:"0 0 260 60",preserveAspectRatio:"none","aria-hidden":!0,
2children:[t.jsx("polygon",{points:o,fill:"var(--kiro-purple-500)",fillOpacity:.12}),t.jsx("polyline",{points:n,fill:"none",stroke:"var(--kiro-purple-500)",strokeWidth:1.5})]})}function Ot({label:s,value:e}){return t.jsxs(w,{className:at.kpiItem,children:[t.jsx(k,{className:at.kpiLabel,children:s}),t.jsx(k,{className:at.kpiValue,children:e})]})}function Ri({throughput:s,ttft:e}){const a=r.useMemo(()=>jr({throughput:s,ttft:e}),[s,e]),n=r.useMemo(()=>s?Cr(s.buckets):null,[s]),o=e?Nr(e):null,i=s?.streamingMs?(s.streamingMs/1e3).toFixed(1):null;return t.jsxs(w,{className:at.card,children:[n!==null&&n.length>=2?t.jsx(w,{className:at.sparklineContainer,children:t.jsx(Ni,{values:n})}):null,t.jsxs(w,{className:at.kpiGrid,children:[t.jsx(Ot,{label:"Est. tok/s",value:a.tokPerS!==null?`${a.tokPerS}`:"â"}),t.jsx(Ot,{label:"Chunks/s",value:s?.chunksPerSecond!==void 0&&Number.isFinite(s.chunksPerSecond)?`${Math.round(s.chunksPerSecond)}`:"â"}),t.jsx(Ot,{label:"Est. tokens",value:s?.estimatedTokens!==void 0?`${s.estimatedTokens}`:"â"}),t.jsx(Ot,{label:"Streaming",value:i!==null?`${i}s`:"â"})]}),o!==null?t.jsx(w,{className:at.ttftSection,children:t.jsxs(w,{className:at.ttftRow,children:[t.jsx(k,{className:at.kpiLabel,children:"TTFT"}),t.jsxs(k,{className:at.kpiValue,children:[o,"ms"]})]})}):null]})}function $i({latestTurnUsage:s}){const e=Mn(),[a,{open:n,close:o}]=nr(!1),[i,d]=r.useState(!1),l=s?.throughput!==void 0||s?.ttft!==void 0;if(!e||!l)return null;const u=()=>{i||o()},c=()=>{const f=!i;d(f),f?n():o()};return t.jsxs(rs,{opened:a,position:"top-start",withArrow:!0,shadow:"md",radius:"md",offset:8,classNames:{dropdown:at.dropdown,arrow:at.arrow},children:[t.jsx(rs.Target,{children:t.jsx(yt,{className:at.gaugeButton,title:"Performance","aria-label":"Performance","aria-haspopup":"dialog","aria-expanded":a,"aria-pressed":i,onMouseEnter:n,onMouseLeave:u,onClick:c,children:t.jsx(Y,{id:"dashboard",size:"xs"})})}),t.jsx(rs.Dropdown,{onMouseEnter:n,onMouseLeave:u,children:t.jsx(Ri,{throughput:s?.throughput,ttft:s?.ttft})})]})}const Ti="_container_1n35m_1",Ii="_scrollArea_1n35m_8",Ei="_scrollContent_1n35m_32",Pi="_inputArea_1n35m_41",Ai="_kiroSection_1n35m_53",Li="_kiroHeader_1n35m_59",Mi="_fakeToolCall_1n35m_66",Di="_toolCallHeader_1n35m_72",Fi="_toolCallIcon_1n35m_83",Oi="_toolCallTitle_1n35m_94",Wi="_tipCard_1n35m_101",Bi="_tipHeader_1n35m_112",zi="_tipIcon_1n35m_118",Ki="_tipHeaderText_1n35m_122",Gi="_tipContent_1n35m_128",Ye={container:Ti,scrollArea:Ii,scrollContent:Ei,inputArea:Pi,kiroSection:Ai,kiroHeader:Li,fakeToolCall:Mi,toolCallHeader:Di,toolCallIcon:Fi,toolCallTitle:Oi,tipCard:Wi,tipHeader:Bi,tipIcon:zi,tipHeaderText:Ki,tipContent:Gi},os=["Kiro can read images â just drag and drop or paste screenshots directly into the chat","Click on tool calls to expand them and view outputs like file changes, command results, and more","You can stop Kiro at any time by clicking the Stop button in the snackbar","Kiro can help you understand unfamiliar codebases by exploring and explaining the structure","Use the refresh button to reload your session if something seems out of sync","Kiro can create pull requests and push changes to GitHub directly from the chat","You can ask Kiro to run tests, lint your code, or execute any terminal command","Messages you send while Kiro is working act as live steering â guide the agent mid-task","Kiro keeps working even when you navigate away â come back anytime to check progress",'Use "Auto" model selection to let Kiro suggest the most fitting model for your work',"Kiro can create memories to learn your preferences and patterns over time","Kiro remembers context from earlier in your conversation to stay on track"],Hi=8e3;function qi({tip:s}){return t.jsxs(w,{className:Ye.tipCard,children:[t.jsxs(w,{className:Ye.tipHeader,children:[t.jsx(Y,{id:"lightbulb-sparkle",size:"sm",className:Ye.tipIcon}),t.jsx(k,{className:Ye.tipHeaderText,children:"Did you know?"})]}),t.jsx(k,{className:Ye.tipContent,children:s})]})}function Ui({header:s,chatInputProps:e}){const[a,n]=r.useState(()=>Math.floor(Math.random()*os.length));return r.useEffect(()=>{const o=setInterval(()=>{n(i=>(i+1)%os.length)},Hi);return()=>clearInterval(o)},[]),t.jsxs(w,{className:Ye.container,children:[t.jsxs(w,{className:Ye.scrollArea,children:[s,t.jsx(w,{className:Ye.scrollC
2ontent,children:t.jsxs(w,{className:Ye.kiroSection,children:[t.jsxs(w,{className:Ye.kiroHeader,children:[t.jsx(ar,{size:"sm",status:"thinking"}),t.jsx(k,{c:"var(--color-text-secondary)",fw:600,size:"sm",children:"Kiro"})]}),t.jsx(w,{className:Ye.fakeToolCall,children:t.jsxs(w,{className:Ye.toolCallHeader,children:[t.jsx(w,{className:Ye.toolCallIcon,children:t.jsx(bt,{size:"xs"})}),t.jsx(k,{className:Ye.toolCallTitle,children:"Reloading sandbox"})]})}),t.jsx(Ns,{mode:"wait",initial:!1,children:t.jsx(Tt.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.3,ease:[.4,0,.2,1]},children:t.jsx(qi,{tip:os[a]??""})},a)})]})})]}),t.jsxs(w,{className:Ye.inputArea,"data-snackbar-visible":"true",children:[t.jsx(Zn,{statusText:"Reloading sandbox"}),t.jsx(ea,{...e,variant:"session",disabled:!0})]})]})}function It({active:s,onFocused:e}){const a=r.useRef(null);return r.useCallback(n=>{if(!s){a.current=null;return}n===null||a.current===n||(a.current=n,n.focus(),e?.())},[s,e])}function pa(s){return s.merged?"merged":s.isDraft?"draft":s.state??"open"}function Et(s){const e=s.url??"";return e.includes("gitlab.com")||e.includes("/-/merge_requests/")?"gitlab":e.includes("code.amazon.com/reviews")||(s.prId??"").startsWith("CR-")?"gitfarm":"github"}const ha={github:{viewLabel:"View in GitHub",resourceNoun:"Pull Request"},gitlab:{viewLabel:"View in GitLab",resourceNoun:"Merge Request"},gitfarm:{viewLabel:"View in Code Review",resourceNoun:"Code Review"}};function ga(s){if(s.url)return s.url;if(s.owner&&s.repo&&s.prId)return`https://github.com/${s.owner}/${s.repo}/pull/${s.prId}`}function Wt(s){return`${Et(s)}-${s.owner}-${s.repo}-${s.prId}`}function As(s){return s.prId?Et(s)==="gitfarm"?s.prId:`#${s.prId}`:""}const Vi="_providerLink_tiqcv_1",Qi="_sizeSm_tiqcv_19",Yi="_sizeMd_tiqcv_23",is={providerLink:Vi,sizeSm:Qi,sizeMd:Yi};function vs({pr:s,size:e="sm",interactive:a=!0,className:n,onClick:o,onKeyDown:i}){const d=ga(s);if(!d)return null;const l=Et(s),{viewLabel:u,resourceNoun:c}=ha[l],f=As(s),g=e==="md"?is.sizeMd:is.sizeSm,h=[is.providerLink,g,n].filter(Boolean).join(" "),y=t.jsxs(t.Fragment,{children:[t.jsx(Y,{id:"link-external",size:e==="md"?"sm":"xs"}),t.jsx(k,{component:"span",children:u})]});return a?t.jsx(Nn,{href:d,target:"_blank",rel:"noopener noreferrer",underline:"never",className:h,"aria-label":`${u} â ${c.toLowerCase()} ${f}`.trim(),onClick:o,onKeyDown:i,children:y}):t.jsx(w,{className:h,children:y})}const Xi="_prListGroup_1rdi6_1",Ji="_prListPanel_1rdi6_11",Zi="_prList_1rdi6_1",el="_prListItem_1rdi6_27",tl="_prCardLink_1rdi6_33",sl="_prCard_1rdi6_33",nl="_prCardMain_1rdi6_60",al="_prTitleRow_1rdi6_68",rl="_prStateIcon_1rdi6_75",ol="_prTitle_1rdi6_68",il="_prMeta_1rdi6_106",ll="_prMetaSeparator_1rdi6_116",cl="_prRepo_1rdi6_121",dl="_prBranch_1rdi6_122",ul="_prLinkButton_1rdi6_128",fl="_prCardChevron_1rdi6_132",ml="_prErrorText_1rdi6_145",De={prListGroup:Xi,prListPanel:Ji,prList:Zi,prListItem:el,prCardLink:tl,prCard:sl,prCardMain:nl,prTitleRow:al,prStateIcon:rl,prTitle:ol,prMeta:il,prMetaSeparator:ll,prRepo:cl,prBranch:dl,prLinkButton:ul,prCardChevron:fl,prErrorText:ml};function pl(s){switch(s){case"open":return"git-pull-request";case"closed":return"git-pull-request-closed";case"merged":return"git-merge";case"draft":return"git-pull-request-draft";default:return"git-pull-request"}}function hl(s){switch(s){case"open":return"Open";case"closed":return"Closed";case"merged":return"Merged";case"draft":return"Draft";default:return"Unknown"}}function gl({pr:s,onPrClick:e,autoFocus:a=!1,onFocused:n}){const o=Et(s),i=It({active:a,onFocused:n}),{resourceNoun:d}=ha[o],l=o!=="github",u=pa(s),c=pl(u),f=hl(u),g=As(s),h=ga(s),y=[g,s.title??`${d} ${g}`].filter(Boolean).join(" "),m=l||e?t.jsx(vs,{pr:s,className:De.prLinkButton,onClick:_=>_.stopPropagation(),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&_.stopPropagation()}}):t.jsx(vs,{pr:s,className:De.prLinkButton,interactive:!1}),v=t.jsxs(w,{className:De.prCard,children:[t.jsxs(w,{className:De.prCardMain,children:[t.jsxs(w,{className:De.prTitleRow,children:[t.jsx(w,{className:De.prStateIcon,"data-state":u,children:t.jsx(Y,{id:c,size:"sm"})}),t.jsx(k,{className:De.prTitle,title:y,children:y})]}),t.jsxs(w,{className:De.prMeta,children:[u&&u!=="unknown"?t.jsx(k,{component:"span",children:f}):null,s.repo?t.jsxs(t.Fragment,{children:[u&&u!=="unknown"?t.jsx(k,{component:"span",className:De.prMetaSeparator,children:"â¢"}):null,t.jsx(k,{component:"span",className:De.prRepo,children:s.repo})]}
2):null,s.sourceBranch?t.jsxs(t.Fragment,{children:[t.jsx(k,{component:"span",className:De.prMetaSeparator,children:"â¢"}),t.jsx(Be,{label:s.sourceBranch,withArrow:!0,children:t.jsx(k,{component:"span",className:De.prBranch,children:s.sourceBranch})})]}):null]})]}),m,e&&!l?t.jsx(w,{className:De.prCardChevron,"aria-hidden":!0,children:t.jsx(Y,{id:"chevron-right",size:"sm"})}):null]});return l?v:e?t.jsx(w,{role:"button",tabIndex:0,ref:i,className:De.prCardLink,onClick:()=>e(s),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),e(s))},"aria-label":`View details for ${d.toLowerCase()} ${g}${s.title?` ${s.title}`:""}`,children:v}):h?t.jsx(yt,{component:"a",href:h,target:"_blank",rel:"noopener noreferrer",className:De.prCardLink,"aria-label":`Open ${d.toLowerCase()} ${g}${s.title?` ${s.title}`:""}`,children:v}):v}function wa({pullRequests:s,error:e,isLoading:a,hasAnswered:n,onPrClick:o,autoFocus:i=!1,autoFocusReview:d,onAutoFocusHandled:l}){const u=s.toSorted((m,v)=>Number(v.prId??0)-Number(m.prId??0)),c=d?Wt(d):void 0,f=i&&c!==void 0&&o!==void 0&&u.some(m=>Wt(m)===c&&Et(m)==="github"),g=f?c:void 0,h=It({active:i&&!f,onFocused:l}),y=e!=null&&s.length===0?t.jsx(k,{className:De.prErrorText,role:"status",children:"Unable to load reviews. Try refreshing the session."}):a||!n?t.jsx(k,{className:De.prErrorText,role:"status",children:"Loading reviewsâ¦"}):s.length===0?t.jsx(k,{className:De.prErrorText,children:"No reviews are available for this session."}):t.jsx(w,{className:De.prList,children:u.map(m=>t.jsx(w,{className:De.prListItem,children:t.jsx(gl,{pr:m,onPrClick:o,autoFocus:Wt(m)===g,onFocused:l})},Wt(m)))});return t.jsx(w,{role:"group","aria-label":"Reviews",tabIndex:-1,ref:h,className:De.prListGroup,children:y})}function wl(s){return t.jsx(w,{className:De.prListPanel,children:t.jsx(wa,{...s})})}function Ht(s){switch(s){case"APPROVED":return"approved";case"CHANGES_REQUESTED":return"changesRequested";case"DISMISSED":return"dismissed";case"PENDING":return"pending";case"COMMENTED":return"commented";default:return"unknown"}}const xl=new Set(["changesRequested","approved","commented"]);function yl(s){if(s)return s.filter(e=>xl.has(Ht(e.state))).length}const bl="_tab_1iag3_1",_l="_decisionBanner_1iag3_8",vl="_decisionCaption_1iag3_24",Sl="_decisionRow_1iag3_32",kl="_decisionValue_1iag3_39",jl="_decisionSummary_1iag3_51",Cl="_section_1iag3_56",Nl="_sectionTitle_1iag3_61",Rl="_conversations_1iag3_68",$l="_blockingTitle_1iag3_72",Tl="_blockingDot_1iag3_84",Il="_row_1iag3_92",El="_avatar_1iag3_98",Pl="_rowBody_1iag3_107",Al="_rowHeader_1iag3_115",Ll="_author_1iag3_121",Ml="_timestamp_1iag3_136",Dl="_commentBody_1iag3_143",Fl="_showMore_1iag3_150",Ol="_groups_1iag3_160",Wl="_groupsDivided_1iag3_165",Bl="_group_1iag3_160",zl="_groupHeader_1iag3_173",Kl="_iconApproved_1iag3_189",Gl="_iconCommented_1iag3_195",Hl="_groupLabel_1iag3_201",ql="_avatarCluster_1iag3_208",Ul="_clusterAvatar_1iag3_218",Vl="_groupNames_1iag3_226",Ql="_groupChevron_1iag3_236",Yl="_groupRows_1iag3_243",Xl="_emptyContent_1iag3_249",Jl="_emptyText_1iag3_258",he={tab:bl,decisionBanner:_l,decisionCaption:vl,decisionRow:Sl,decisionValue:kl,decisionSummary:jl,section:Cl,sectionTitle:Nl,conversations:Rl,blockingTitle:$l,blockingDot:Tl,row:Il,avatar:El,rowBody:Pl,rowHeader:Al,author:Ll,timestamp:Ml,commentBody:Dl,showMore:Fl,groups:Ol,groupsDivided:Wl,group:Bl,groupHeader:zl,iconApproved:Kl,iconCommented:Gl,groupLabel:Hl,avatarCluster:ql,clusterAvatar:Ul,groupNames:Vl,groupChevron:Ql,groupRows:Yl,emptyContent:Xl,emptyText:Jl},Zl={APPROVED:"Approved",CHANGES_REQUESTED:"Changes requested",REVIEW_REQUIRED:"Review required"},Ls="Unknown author",sn=220;function ec(s){switch(s){case"APPROVED":return"approved";case"CHANGES_REQUESTED":return"changesRequested";default:return"neutral"}}function xa(s){return Rr(s?.toISOString())}function Ms(s){return s?.trim().charAt(0).toUpperCase()||"?"}function ya({review:s}){const e=xa(s.submittedAt),a=s.authorLogin?.trim();return t.jsxs(w,{className:he.row,children:[t.jsx(Rs,{src:s.authorAvatarUrl,size:20,radius:"xl",className:he.avatar,children:Ms(s.authorLogin)}),t.jsxs(w,{className:he.rowBody,children:[t.jsxs(w,{className:he.rowHeader,children:[t.jsx(k,{component:"span",className:he.author,"data-unknown":a?void 0:!0,children:a||Ls}),e?t.jsx(k,{component:"span",className:he.timestamp,children:e}):null]}),s.body?t.jsx(k,{className:he.commentBody,children:s.body}):null]})]})}function nn({icon:s,iconClassName:e,label:a,reviews:n}){const[o,i]=r.useState(!1);if(n.length===0)return null;const d=n.map(l=>l.authorLogin?.trim()||Ls).join(", ");return t.jsxs(w,{className:he.group,children:[t.jsxs(yt,{className:he.groupHeader,"aria-expanded":o,onClick:()=>{i(l=>!l)},children:[t.jsx(w,{component:"span",className:e,children:t.jsx(Y,{id:s,size:"sm"})}),t.jsxs(k,{component:"span",className:he.groupLabel,children:[a," (",n.length,")"]}),o?null:t.jsxs(t.Fragment,{children:[t.jsx(w,{className:he.avatarCluster,children:n.slice(0,3).map((l,u)=>
2t.jsx(Rs,{src:l.authorAvatarUrl,size:18,radius:"xl",className:he.clusterAvatar,children:Ms(l.authorLogin)},`${l.authorLogin??"r"}-${String(u)}`))}),t.jsx(k,{component:"span",className:he.groupNames,children:d})]}),t.jsx(w,{component:"span",className:he.groupChevron,children:t.jsx(Y,{id:o?"chevron-down":"chevron-right",size:"xs"})})]}),o?t.jsx(w,{className:he.groupRows,children:n.map((l,u)=>t.jsx(ya,{review:l},`${l.authorLogin??"r"}-${String(u)}`))}):null]})}function tc({comment:s}){const[e,a]=r.useState(!1),n=xa(s.createdAt),o=s.authorLogin?.trim(),i=s.body??"",d=i.length>sn,l=e||!d?i:`${i.slice(0,sn).trimEnd()}â¦`;return t.jsxs(w,{className:he.row,children:[t.jsx(Rs,{src:s.authorAvatarUrl,size:20,radius:"xl",className:he.avatar,children:Ms(s.authorLogin)}),t.jsxs(w,{className:he.rowBody,children:[t.jsxs(w,{className:he.rowHeader,children:[t.jsx(k,{component:"span",className:he.author,"data-unknown":o?void 0:!0,children:o||Ls}),n?t.jsx(k,{component:"span",className:he.timestamp,children:n}):null]}),i?t.jsx(k,{className:he.commentBody,children:l}):null,d?t.jsx(yt,{className:he.showMore,onClick:()=>{a(u=>!u)},children:e?"Show less":"Show more"}):null]})]})}function sc({reviews:s,issueComments:e,reviewDecision:a}){const n=(s??[]).filter(c=>c.state!=null&&c.state!=="PENDING"),o=n.filter(c=>Ht(c.state)==="changesRequested"),i=n.filter(c=>Ht(c.state)==="approved"),d=n.filter(c=>Ht(c.state)==="commented"),l=e??[];if(o.length+i.length+d.length===0&&l.length===0&&!a)return t.jsx(w,{className:he.emptyContent,children:t.jsx(k,{className:he.emptyText,children:"No reviews or comments yet"})});const u=[o.length>0?`${String(o.length)} ${o.length===1?"change":"changes"}`:null,i.length>0?`${String(i.length)} approved`:null,d.length>0?`${String(d.length)} commented`:null].filter(Boolean).join(" · ");return t.jsxs(w,{className:he.tab,children:[a?t.jsxs(w,{className:he.decisionBanner,"data-status":ec(a),children:[t.jsx(k,{component:"span",className:he.decisionCaption,children:"Review decision"}),t.jsxs(w,{className:he.decisionRow,children:[t.jsx(k,{component:"span",className:he.decisionValue,children:Zl[a]??a}),u?t.jsx(k,{component:"span",className:he.decisionSummary,children:u}):null]})]}):null,o.length>0?t.jsxs(w,{className:he.section,children:[t.jsxs(w,{className:he.blockingTitle,children:[t.jsx(w,{component:"span",className:he.blockingDot}),"Blocking (",o.length,")"]}),o.map((c,f)=>t.jsx(ya,{review:c},`${c.authorLogin??"r"}-${String(f)}`))]}):null,i.length>0||d.length>0?t.jsxs(w,{className:o.length>0?`${he.groups} ${he.groupsDivided}`:he.groups,children:[t.jsx(nn,{icon:"check",iconClassName:he.iconApproved,label:"Approved",reviews:i}),t.jsx(nn,{icon:"chat",iconClassName:he.iconCommented,label:"Commented",reviews:d})]}):null,l.length>0?t.jsxs(w,{className:`${he.section} ${he.conversations}`,children:[t.jsx(k,{className:he.sectionTitle,children:"Conversations"}),l.map((c,f)=>t.jsx(tc,{comment:c},c.commentId??`c-${String(f)}`))]}):null]})}function nc(s){const e=rc(s),a=[],n=[],o=[],i=[];for(const d of e)for(const l of d.lines)l.type==="context"?(a.push(l.content),n.push(l.content),o.push(l.oldLineNum??0),i.push(l.newLineNum??0)):l.type==="removed"?(a.push(l.content),o.push(l.oldLineNum??0)):(n.push(l.content),i.push(l.newLineNum??0));return{original:a.join(` 3`),modified:n.join(` 4`),originalLineNumbers:o,modifiedLineNumbers:i}}const ac=/^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@/;function rc(s){if(!s)return[];const e=s.split(` 5`);e.at(-1)===""&&e.pop();const a=[];let n=null,o=0,i=0;for(const d of e){const l=ac.exec(d);if(l){const f=parseInt(l[1]??"0",10),g=parseInt(l[2]??"1",10),h=parseInt(l[3]??"0",10),y=parseInt(l[4]??"1",10);n={oldStart:f,oldCount:g,newStart:h,newCount:y,header:d,lines:[]},a.push(n),o=f,i=h;continue}if(!n)continue;const u=d[0],c=d.slice(1);if(u==="+")n.lines.push({type:"added",content:c,oldLineNum:null,newLineNum:i}),i++;else if(u==="-")n.lines.push({type:"removed",content:c,oldLineNum:o,newLineNum:null}),o++;else{if(u==="\\")continue;n.lines.push({type:"context",content:u===" "?c:d,oldLineNum:o,newLineNum:i}),o++,i++}}return a}const oc=/^[0-9]+$/;function ic({spaceId:s,sessionId:e,pullRequest:a,enabled:n}){const o=a!=null&&!!s&&!!e&&!!a.owner&&!!a.repo&&a.prId!=null&&oc.test(a.prId),{data:i,isLoading:d,error:l}=$r({input:{spaceId:s,sessionId:e,owner:a?.owner??"",repo:a?.repo??"",pullRequestNumber:a?.prId??""},options:{enabled:o,staleTime:6e4,retry:2,retryDelay:1e3,throwOnError:!1}});return{data:i,isLoading:d,error:l??null}}const lc="_panel_1fvbk_1",cc="_header_1fvbk_10",dc="_headerTop_1fvbk_23",uc="_backButton_1fvbk_30",fc="_headerInfo_1fvbk_35",mc="_titleSection_1fvbk_44",pc="_titleRow_1fvbk_51",hc="_prIcon_1fvbk_58",gc="_prTitle_1fvbk_75",wc="_metaRow_1fvbk_85",xc="_statusText_1fvbk_95",yc="_headerActions_1fvbk_99",bc="_viewLink_1fvbk_107",_c="_tabs_1fvbk_111",vc="_viewModeToggle_1fvbk_118",Sc="_content_1fvbk_122",kc="_fileSummary_1fvbk_128",jc="_collapseToggle_1fvbk_137",Cc="_additions_1fvbk_145",Nc="_deleti
5ons_1fvbk_150",Rc="_emptyContent_1fvbk_155",$c="_emptyText_1fvbk_164",Tc="_fileList_1fvbk_169",Ic="_fileEntry_1fvbk_175",Ec="_fileHeader_1fvbk_180",Pc="_fileChevron_1fvbk_201",Ac="_fileStatusIcon_1fvbk_206",Lc="_fileName_1fvbk_226",Mc="_fileStats_1fvbk_236",Dc="_fileAdditions_1fvbk_244",Fc="_fileDeletions_1fvbk_248",Oc="_diffBody_1fvbk_252",Wc="_monacoDiff_1fvbk_259",Bc="_noPatch_1fvbk_334",zc="_commitEntry_1fvbk_342",Kc="_commitRow_1fvbk_350",Gc="_commitMessage_1fvbk_356",Hc="_commitAuthor_1fvbk_374",qc="_commitSha_1fvbk_379",Uc="_commitShaText_1fvbk_393",ie={panel:lc,header:cc,headerTop:dc,backButton:uc,headerInfo:fc,titleSection:mc,titleRow:pc,prIcon:hc,prTitle:gc,metaRow:wc,statusText:xc,headerActions:yc,viewLink:bc,tabs:_c,viewModeToggle:vc,content:Sc,fileSummary:kc,collapseToggle:jc,additions:Cc,deletions:Nc,emptyContent:Rc,emptyText:$c,fileList:Tc,fileEntry:Ic,fileHeader:Ec,fileChevron:Pc,fileStatusIcon:Ac,fileName:Lc,fileStats:Mc,fileAdditions:Dc,fileDeletions:Fc,diffBody:Oc,monacoDiff:Wc,noPatch:Bc,commitEntry:zc,commitRow:Kc,commitMessage:Gc,commitAuthor:Hc,commitSha:qc,commitShaText:Uc};function Vc(s){switch(s){case"open":return"git-pull-request";case"closed":return"git-pull-request-closed";case"merged":return"git-merge";case"draft":return"git-pull-request-draft";default:return"git-pull-request"}}function Qc(s){switch(s){case"open":return"Open";case"closed":return"Closed";case"merged":return"Merged";case"draft":return"Draft";default:return"Open"}}function Yc(s){switch(s){case"ADDED":return"A";case"REMOVED":return"D";case"RENAMED":return"R";case"COPIED":return"C";default:return"M"}}function Xc({file:s,viewMode:e,expanded:a,onToggle:n}){const o=r.useMemo(()=>a?nc(s.patch):{original:"",modified:"",originalLineNumbers:[],modifiedLineNumbers:[]},[a,s.patch]),i=o.original!==""||o.modified!=="";return t.jsxs(w,{className:ie.fileEntry,children:[t.jsxs(yt,{className:ie.fileHeader,onClick:n,"aria-expanded":a,"aria-label":`${a?"Collapse":"Expand"} diff for ${s.filename}`,children:[t.jsx(w,{className:ie.fileChevron,children:t.jsx(Y,{id:a?"chevron-down":"chevron-right",size:"xs"})}),t.jsx(k,{component:"span",className:ie.fileStatusIcon,"data-status":s.status,children:Yc(s.status)}),t.jsx(k,{className:ie.fileName,title:s.filename,children:s.filename}),t.jsxs(w,{className:ie.fileStats,children:[s.additions!=null&&s.additions>0?t.jsxs(k,{component:"span",className:ie.fileAdditions,children:["+",s.additions]}):null,s.deletions!=null&&s.deletions>0?t.jsxs(k,{component:"span",className:ie.fileDeletions,children:["-",s.deletions]}):null]})]}),a?t.jsx(w,{className:ie.diffBody,children:s.patch&&i?t.jsx(Tr,{original:o.original,modified:o.modified,originalLineNumbers:o.originalLineNumbers,modifiedLineNumbers:o.modifiedLineNumbers,path:s.filename,renderSideBySide:e==="split",options:{useInlineViewWhenSpaceIsLimited:!1},className:ie.monacoDiff}):t.jsx(w,{className:ie.noPatch,children:t.jsx(k,{component:"span",children:s.patch?"Unable to display this diff":"Binary file or patch too large to display"})})}):null]})}function Jc({pullRequest:s,spaceId:e,sessionId:a,onBack:n,autoFocusBack:o=!1,onBackFocused:i,onViewModeChange:d}){const l=It({active:o,onFocused:i}),[u,c]=r.useState("files"),[f,g]=r.useState("unified"),[h,y]=r.useState(new Set),m=b=>{g(b),d&&d(b)},v=pa(s),_=As(s),re=_?`${_} ${s.title??"Pull Request"}`:s.title??"Pull Request",{data:j,isLoading:U,error:$}=ic({spaceId:e,sessionId:a,pullRequest:s,enabled:!0}),P=r.useMemo(()=>j?.files?j.files.filter(b=>!!b.filename).map(b=>({...b,filename:b.filename??"(unknown file)"})):[],[j?.files]),Z=r.useMemo(()=>j?.commits?j.commits.filter(b=>!!b.sha).map(b=>({...b,message:b.message??"(no commit message)"})):[],[j?.commits]),X=j?.files!=null?P.length:s.changedFiles,ee=j?.commits!=null?Z.length:s.commitCount,D=s.additions,T=s.deletions,G=P.length>0&&h.size===P.length,H=()=>{y(G?new Set:new Set(P.map(b=>b.filename)))},F=b=>{y(O=>{const B=new Set(O);return B.has(b)?B.delete(b):B.add(b),B})};return t.jsxs(w,{className:ie.panel,children:[t.jsxs(w,{className:ie.header,children:[t.jsxs(w,{className:ie.headerTop,children:[t.jsx(ze,{variant:"subtle",size:"sm",onClick:n,"aria-label":"Back to pull requests list",className:ie.backButton,ref:l,children:t.jsx(Y,{id:"chevron-left",size:"sm"})}),t.jsxs(w,{className:ie.headerInfo,children:[t.jsxs(w,{className:ie.titleSection,children:[t.jsxs(w,{className:ie.titleRow,children:[t.jsx(w,{component:"span",className:ie.prIcon,"data-status":v,children:t.jsx(Y,{id:Vc(v),size:"sm"})}),t.jsx(Be,{label:re,multiline:!0,withArrow:!0,maw:400,position:"bottom-start",disabled:!re||re.length<40,children:t.jsx(k,{className:ie.prTitle,children:re})})]}),t.jsxs(w,{className:ie.metaRow,children:[t.jsx(k,{component:"span",className:ie.statusText,"data-status":v,children:Qc(v)}),s.sourceBranch?t.jsxs(t.Fragment,{children:[t.jsx(k,{component:"span",children:"â¢"}),t.jsx(k,{component:"span",children:s.sourceBranch})]}):null]})]}),t.jsx(w,{className:ie.headerActions,children:t.jsx(vs,{pr:s,size:"md",className:ie.viewLink})})]})]}),t.jsxs(w,{className:ie.tabs,children:[t.jsx(Rn,{ariaLabel:"Pull request sections",value:u,onChange:b=>{(b==="files"||b==="commits"||b==="review")&&c(b)},data:[{value:"files",label:"Files changed",count:X??void 0},{value:"commits",label:"Commits",count:ee??void 0},{value:"review",label:"Reviews",count:yl(j?.reviews)}]}
5),u==="files"?t.jsx($n,{className:ie.viewModeToggle,size:"xs",value:f,onChange:b=>m(b),data:[{label:"Unified",value:"unified"},{label:"Split",value:"split"}],"aria-label":"Diff view mode"}):null]})]}),t.jsx(w,{className:ie.content,children:!e||!a?t.jsx(w,{className:ie.emptyContent,children:t.jsx(k,{className:ie.emptyText,children:"Unable to load PR details â missing context"})}):U?t.jsx(w,{className:ie.emptyContent,children:t.jsx(bt,{size:"sm",color:"var(--color-text-secondary)"})}):$?t.jsx(w,{className:ie.emptyContent,children:t.jsx(k,{className:ie.emptyText,children:"Unable to load PR details. Try reopening the panel."})}):u==="files"?t.jsxs(t.Fragment,{children:[X!=null?t.jsxs(w,{className:ie.fileSummary,children:[t.jsxs(k,{component:"span",children:[X," file",X===1?"":"s"," changed"]}),D!=null&&D>0?t.jsxs(k,{component:"span",className:ie.additions,children:["+",D]}):null,T!=null&&T>0?t.jsxs(k,{component:"span",className:ie.deletions,children:["-",T]}):null,P.length>0?t.jsx(ze,{variant:"subtle",size:"xs",onClick:H,"aria-label":G?"Collapse all files":"Expand all files",className:ie.collapseToggle,children:t.jsx(Y,{id:G?"collapse-all":"expand-all",size:"xs"})}):null]}):null,P.length>0?t.jsx(w,{className:ie.fileList,children:P.map(b=>t.jsx(Xc,{file:b,viewMode:f,expanded:h.has(b.filename),onToggle:()=>F(b.filename)},b.filename))}):t.jsx(w,{className:ie.emptyContent,children:t.jsx(k,{className:ie.emptyText,children:"No file changes available"})})]}):u==="commits"?t.jsx(w,{className:ie.fileList,children:Z.length>0?Z.map(b=>t.jsxs(w,{className:ie.commitEntry,children:[t.jsxs(w,{className:ie.commitRow,children:[t.jsx(Be,{label:b.message,multiline:!0,withArrow:!0,maw:400,position:"top-start",children:t.jsx(k,{className:ie.commitMessage,children:b.message.split(` 6`)[0]})}),t.jsx(rr,{value:b.sha,children:({copied:O,copy:B})=>t.jsx(Be,{label:O?"Copied":"Copy commit SHA",withArrow:!0,children:t.jsxs(yt,{className:ie.commitSha,onClick:B,"aria-label":`Copy commit SHA ${b.sha.slice(0,7)}`,children:[t.jsx(k,{component:"span",className:ie.commitShaText,children:b.sha.slice(0,7)}),t.jsx(Y,{id:O?"check":"copy",size:"xs"})]})})})]}),b.author?t.jsx(k,{className:ie.commitAuthor,children:b.author}):null]},b.sha)):t.jsx(w,{className:ie.emptyContent,children:t.jsx(k,{className:ie.emptyText,children:"No commits available"})})}):t.jsx(sc,{reviews:j?.reviews,issueComments:j?.issueComments,reviewDecision:j?.reviewDecision})})]})}const Zc="_docked_pjh0u_1",ed="_drawer_pjh0u_9",td="_header_pjh0u_43",sd="_heading_pjh0u_56",nd="_control_pjh0u_70",ad="_toggle_pjh0u_71",xt={docked:Zc,drawer:ed,header:td,heading:sd,control:nd,toggle:ad};function ba({controller:s,id:e,label:a,controlSubject:n,dockedClassName:o,hideCollapseControl:i=!1,children:d,...l}){const{collapsed:u,drawerOpen:c,railRef:f,collapseControlRef:g,pointerProps:h,closeDrawer:y,expand:m,collapse:v}=s,_=u?xt.drawer:`${xt.docked}${o?` ${o}`:""}`;return t.jsxs("aside",{ref:f,tabIndex:-1,id:e,"aria-label":a,"data-mode":u?"drawer":"docked","data-open":u?c:void 0,className:_,...u?h:{},...l,children:[t.jsxs("div",{className:xt.header,children:[u?t.jsx(Be,{label:`Hide ${n}`,children:t.jsx(ze,{variant:"transparent",size:"sm",className:xt.control,"aria-label":`Hide ${n}`,onClick:y,children:t.jsx(Y,{id:"menu",size:"xs"})})}):null,t.jsx(k,{component:"span",className:xt.heading,children:a}),u?t.jsx(Be,{label:`Keep ${n} open`,children:t.jsx(ze,{variant:"transparent",size:"sm",className:xt.control,"aria-label":`Keep ${n} open`,onClick:m,children:t.jsx(Y,{id:"layout-sidebar-left",size:"xs"})})}):null,!u&&!i?t.jsx(Be,{label:`Collapse ${n}`,children:t.jsx(ze,{ref:g,variant:"transparent",size:"sm",className:xt.control,"aria-label":`Collapse ${n}`,"aria-expanded":!0,"aria-controls":e,onClick:v,children:t.jsx(Y,{id:"menu",size:"xs"})})}):null]}),d]})}function Ss({controller:s,controlSubject:e,controls:a,className:n}){const{toggleRef:o,drawerOpen:i,toggleDrawer:d,pointerProps:l}=s;return t.jsx(Be,{label:`Show ${e}`,position:"bottom",children:t.jsx(ze,{ref:o,variant:"transparent",size:"sm",className:`${xt.toggle}${n?` ${n}`:""}`,"aria-label":`Show ${e}`,"aria-expanded":i,"aria-controls":a,onClick:d,...l,children:t.jsx(Y,{id:"menu",size:"xs"})})})}
6const rd=200,od='button, [href], input, [tabindex]:not([tabindex="-1"])';function _a({collapsed:s,onCollapsedChange:e,drawerOpen:a,onDrawerOpenChange:n,closeDelayMs:o=rd}){const i=s&&a,d=r.useRef(null),l=r.useRef(null),u=r.useRef(null),c=r.useRef(null),f=r.useRef(!1),g=or(()=>{f.current=!1,n(!1)},o);function h(){g.cancel()}function y($){h(),!i&&(f.current=$?.focus??!1,n(!0))}function m(){h(),f.current=!1,n(!1)}function v(){if(i){m();return}y({focus:!0})}function _(){h(),f.current=!1,e(!0),n(!1)}function re(){h(),f.current=!1;const $=document.activeElement;c.current=s&&(l.current?.contains($)||d.current===$)?$:null,e(!1),n(!1)}function j($){$.pointerType==="mouse"&&h()}function U($){$.pointerType==="mouse"&&g()}return Us("keydown",$=>{i&&$.key==="Escape"&&m()}),Us("pointerdown",$=>{if(!i)return;const P=$.target;P instanceof Node&&(l.current?.contains(P)||d.current?.contains(P)||m())}),r.useEffect(()=>{const $=c.current;if(c.current=null,!s){$&&(document.activeElement===$||!$.isConnected&&document.activeElement===document.body)&&(u.current??l.current)?.focus();return}if(i){if(!f.current)return;f.current=!1,l.current?.querySelector(od)?.focus();return}f.current=!1,l.current?.contains(document.activeElement)&&d.current?.focus()},[s,i]),{collapsed:s,drawerOpen:i,collapse:_,expand:re,openDrawer:y,closeDrawer:m,toggleDrawer:v,pointerProps:{onPointerEnter:j,onPointerLeave:U},toggleRef:d,railRef:l,collapseControlRef:u}}const id=[".md",".markdown",".mdx"];function va(s){if(!s)return!1;const e=s.toLowerCase();return id.some(a=>e.endsWith(a))}function ld(){let s=new Map;const e=new Set;return{getSnapshot:()=>s,subscribe:a=>(e.add(a),()=>{e.delete(a)}),update:(a,n)=>{const o=new Map(s),i=new Set(a.map(l=>l.workflowId));let d=!1;for(const l of a)l.status==="paused"?o.has(l.workflowId)||(o.set(l.workflowId,n),d=!0):o.delete(l.workflowId)&&(d=!0);for(const l of o.keys())i.has(l)||(o.delete(l),d=!0);if(d){s=o;for(const l of e)l()}}}}function Sa(s,e){const a=r.useMemo(()=>ld(),[]),n=r.useSyncExternalStore(a.subscribe,a.getSnapshot,a.getSnapshot);return r.useLayoutEffect(()=>{a.update(s,e)},[e,a,s]),n}function cd({spaceId:s,path:e}){const{content:a,isBinary:n,encoding:o,mimeType:i,isTruncated:d,isLoading:l,isError:u,retry:c}=Dn({spaceId:s,path:e}),{viewMode:f}=Ts(),g=r.useMemo(()=>({img:({src:h,alt:y})=>t.jsx(Ir,{spaceId:s,markdownFilePath:e,src:typeof h=="string"?h:void 0,alt:typeof y=="string"?y:void 0})}),[s,e]);if(u)return t.jsxs(w,{className:A.emptyState,children:[t.jsx(Y,{id:"warning",size:"xl",c:"orange"}),t.jsx(k,{className:A.emptyStateText,children:"Unable to load file."}),t.jsxs(yt,{className:A.retryButton,onClick:c,"aria-label":"Retry loading file",children:[t.jsx(Y,{id:"refresh",size:"xs"}),t.jsx("span",{children:"Retry"})]})]});if(n){const h=Er(i);return h!=null&&o==="base64"&&a!=null&&!d?t.jsx(w,{className:A.imagePreviewCanvas,children:t.jsx(ir,{className:A.imagePreviewImg,src:Pr(h,a),alt:e,w:"auto",h:"auto",fit:"contain"})}):t.jsxs(w,{className:A.emptyState,children:[t.jsx(Y,{id:"file-binary",size:"lg"}),t.jsx(k,{className:A.emptyStateText,children:h!=null&&d?"Image is too large to preview. Download it to view.":"Binary file â preview not supported."})]})}return l||a==null?t.jsx(w,{className:A.emptyState,children:t.jsx(k,{className:A.emptyStateText,children:"Loading file content..."})}):va(e)&&f==="preview"?t.jsx(w,{className:A.markdownScroll,children:t.jsx(ii,{content:a,components:g})}):t.jsx(Ar,{value:a,path:e,minimap:!0,loading:t.jsx(w,{className:A.emptyState,children:t.jsx(k,{className:A.emptyStateText,children:"Loading editor..."})})})}function ka(s,e){const a=URL.createObjectURL(e),n=document.createElement("a");n.href=a,n.download=s,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(a)}function dd(s,e){ka(s,new Blob([e],{type:"text/plain;charset=utf-8"}))}function ud(s,e,a){ka(s,Lr(e,a))}const fd={status:"pending"},md={status:"error"};function ks({data:s,isError:e}){return s!==void 0?{status:"ready",label:s}:e?md:fd}const ls="file-explorer-tree-rail";function cs({state:s,label:e}){if(s?.status==="ready")return t.jsx("span",{className:A.summarySectionCount,children:s.label});const a=s?.status==="error";return t.jsx("span",{className:A.summarySectionCount,"data-count-state":a?"error":"pending",title:a?`${e} count is unavailable`:void 0,"aria-label":a?`${e} count is unavailable`:`Loading ${e} count`,children:a?"!":t.jsx(bt,{size:"xs","aria-hidden":"true"})})}function pd({onClose:s,spaceId:e,fileSidebar:a,workflowTab:n,reviews:o,reviewTab:i,onFileTabSelect:d,filesEnabled:l=!0,fileTabsDisabled:u=!1,filesCount:c,artifactsCount:f,summaryActive:g=!1,onSummarySelect:h}){const{activeTab:y,setActiveTab:m,selectedFile:v,isSidebarCollapsed:_,setSidebarCollapsed:re,isSidebarDrawerOpen:j,setSidebarDrawerOpen:U,viewMode:$,setViewMode:P,treeStatus:Z}=Ts(),X=Dr(Z),ee=_&&X,D=_a({collapsed:ee,onCollapsedChange:re,drawerOpen:j,onDrawerOpenChange:U}),{content:T,isBinary:G,encoding:H,mimeType:F,isTruncated:b}=Dn({spaceId:e,path:v?.path??"",enabled:!!v}),O=T!=null&&!(G&&b),B=!G&&T!=null&&v!=null&&va(v.name),q=r.useCallback(()=>
6{if(!(v==null||T==null||G&&b))if(G&&H==="base64")try{ud(v.name,T,F??void 0)}catch{Vt.show({title:"Download failed",message:`Could not download ${v.name}. The file may be corrupted.`,color:"red"})}else dd(v.name,T)},[v,T,G,H,F,b]),[K,J]=r.useState(null),N=r.useId(),xe=(o?.pullRequests.length??0)>0,je=o?.error!=null&&!xe,ye=ks({data:o?.hasAnswered===!0&&!je?o.pullRequests.length:void 0,isError:o?.error!=null}),we=K??xe,[I,ne]=r.useState(!0),z=g?"summary":i?.active?i.value:n?.active?n.value:y,W=n?.summaryItems??[],pe=W.some(S=>S.status==="running"),M=Is(g&&pe),le=Sa(W,M);return t.jsxs(w,{className:A.fileExplorerPanelInner,children:[t.jsxs(w,{className:A.panelHeader,children:[t.jsx(w,{className:A.panelHeaderCenter,children:t.jsx(Rn,{ariaLabel:"Side panel sections",value:z,onChange:S=>{if(S==="summary"){U(!1),h?.();return}if(S===i?.value){U(!1),i.onSelect();return}if(S===n?.value){U(!1),n.onSelect();return}if(S==="files"||S==="artifacts"){const ae=S;m(ae),d?.(ae)}},data:[{value:"summary",label:"Summary"},...n?[{value:n.value,label:n.label}]:[],...l?[{value:"files",label:"Files",disabled:u},{value:"artifacts",label:"Artifacts",disabled:u}]:[],...i?[{value:i.value,label:i.label}]:[]]})}),t.jsx(w,{className:A.panelHeaderRight,children:t.jsx(ze,{variant:"subtle",size:"sm",onClick:s,"aria-label":"Close session panel",children:t.jsx("span",{className:A.rotatedSidebarIcon,"aria-hidden":"true",children:t.jsx(Y,{id:"layout-sidebar-left",size:"md",c:"var(--kiro-purple-400)"})})})})]}),g?t.jsxs(w,{className:A.summaryContent,children:[n?t.jsxs("section",{className:`${A.summarySection}${I?` ${A.summarySectionFlexible}`:""}`,children:[t.jsxs("button",{type:"button",className:A.summarySectionButton,onClick:()=>{ne(S=>!S)},"aria-expanded":I,"aria-controls":"session-summary-workflows",children:[t.jsx("span",{className:A.summarySectionIcon,children:t.jsx(Y,{id:"list-tree",size:"sm"})}),t.jsx("span",{className:A.summarySectionCopy,children:t.jsx("span",{className:A.summarySectionTitle,children:"Workflows"})}),t.jsx("span",{className:A.summarySectionCount,children:n?.summaryItems.length??0}),t.jsx(Y,{id:I?"chevron-down":"chevron-right",size:"sm"})]}),I?t.jsx("div",{id:"session-summary-workflows",className:A.summaryWorkflowList,children:n&&n.summaryItems.length>0?n.summaryItems.map(S=>{const ae=S.status==="completed"||S.status==="running"||S.status==="paused",oe=S.status==="paused"?le.get(S.workflowId)??M:M,E=ae&&S.status?On({createdAt:S.createdAt,endedAt:S.endedAt,status:S.status,nowMs:oe}):null,te=E===null?null:Ps(E),ce=S.status==="completed"?Es({createdAt:S.createdAt,endedAt:S.endedAt}):te;return t.jsxs("button",{type:"button",className:A.summaryWorkflowButton,"aria-label":[S.title,ce].filter(Boolean).join(", "),onClick:()=>{U(!1),S.onSelect()},children:[S.status?t.jsx(qt,{status:S.status}):null,t.jsx("span",{className:A.summaryWorkflowTitle,children:S.title}),ce?t.jsxs("span",{className:A.summaryWorkflowStatus,"data-completed":S.status==="completed"||void 0,children:[t.jsx("span",{className:A.summaryWorkflowStatusFull,children:ce}),te?t.jsx("span",{className:A.summaryWorkflowStatusCompact,children:te}):null]}):null]},S.workflowId)}):t.jsx(k,{className:A.summaryEmpty,children:"No workflows are available for this session."})}):null]}):null,o?t.jsxs("section",{className:`${A.summarySection}${we?` ${A.summarySectionFlexible}`:""}`,children:[t.jsxs("button",{type:"button",className:A.summarySectionButton,onClick:()=>J(!we),"aria-expanded":we,"aria-controls":N,children:[t.jsx("span",{className:A.summarySectionIcon,children:t.jsx(Y,{id:"git-pull-request",size:"sm"})}),t.jsx("span",{className:A.summarySectionCopy,children:t.jsx("span",{className:A.summarySectionTitle,children:"Reviews"})}),t.jsx(cs,{state:ye,label:"Reviews"}),t.jsx(Y,{id:we?"chevron-down":"chevron-right",size:"sm"})]}),we?t.jsx("div",{id:N,className:A.summaryWorkflowList,children:t.jsx(wa,{...o})}):null]}):null,l?t.jsxs(t.Fragment,{children:[t.jsx("section",{className:A.summarySection,children:t.jsxs("button",{type:"button",className:A.summarySectionButton,disabled:u,onClick:()=>{m("files"),d?.("files")},children:[t.jsx("span",{className:A.summarySectionIcon,children:t.jsx(Y,{id:"file",size:"sm"})}),t.jsx("span",{className:A.summarySectionCopy,children:t.jsx("span",{className:A.summarySectionTitle,children:"Files"})}),t.jsx(cs,{state:c,label:"Files"}),t.jsx(Y,{id:"chevron-right",size:"sm"})]})}),t.jsx("section",{className:A.summarySection,children:t.jsxs("button",{type:"button",className:A.summarySectionButton,disabled:u,onClick:()=>{m("artifacts"),d?.("artifacts")},children:[t.jsx("span",{className:A.summarySectionIcon,children:t.jsx(Y,{id:"archive",size:"sm"})}),t.jsx("span",{className:A.summarySectionCopy,children:t.jsx("span",{className:A.summarySectionTitle,children:"Artifacts"})}),t.jsx(cs,{state:f,label:"Artifacts"}),t.jsx(Y,{id:"chevron-right",size:"sm"})]})})]}):null]}):i?.active?t.jsx(w,{className:A.workflowTabContent,children:i.content}):n?.active?t.jsx(w,{className:A.workflowTabContent,children:n.content}):t.jsxs(w,{className:A.panelContent,children:[t.jsx(ba,{controller:D,id:ls,label:y==="artifacts"?"Artifacts":"Files",controlSubject:"file tree",dockedClassName:A.fileSidebar,hideCollapseControl:!X,"data-full-width":!X||void 0,children:t.jsx(w,{className:A.fileSidebarBody,children:a})}),X?t.jsx(w,{className:A.fileViewer,children:v?t.jsxs(t.Fragment,{children:[t.jsx(w,{className:A.fileViewerHeader,children:t.jsxs(w,{className:A.fileViewerTitleRow,children:[ee?t.jsx(Ss,{controller:D,controlSubject:"file tree",controls:ls}):null,B?t.jsx($n,{className:A.viewModeToggle,size:"xs",value:$,onChange:S=>P(S),data:[{value:"code",label:t.jsx("span",{className:A.viewModeToggleIcon,children:t.jsx(Y,{id:"code",size:"xs","aria-label":"View source"})})},{value:"preview",label:t.jsx("span",{className:A.viewModeToggleIcon,children:t.jsx(Y,{id:"eye",size:"xs","aria-label":"Preview"})})}],"aria-label":"File view mode"}):null,t.jsx(k,{className:A.fileViewerFileName,children:v.name}),t.jsx(w,{className:A.fileViewerActions,children:t.jsx(Be,{label:"Download file",position:"bottom",children:t.jsx(ze,{variant:"subtle",size:"sm","aria-label":"Download file",onClick:q,disabled:!O,children:t.jsx(Y,{id:"download",size:"xs",c:"var(--color-text-secondary)"})})})})]})}),t.jsx(w,{className:A.codeBlock,children:t.jsx(cd,{spaceId:e,path:v.path})})]}):t.jsxs(t.Fragment,{children:[ee?t.jsx(w,{className:A.fileViewerHeader,children:t.jsx(w,{className:A.fileViewerTitleRow,children:t.jsx(Ss,{controller:D,controlSubject:"file tree",controls:ls})})}):null,t.jsxs(w,{className:A.emptyState,children:[t.jsx(Y,{id:"file",size:"lg"}),t.jsx(k,{className:A.emptyStateText,children:"Select a file to view its contents"})]})]})}):null]})]})}function hd(s){const e=Mr(),a=t.jsx(gd,{...s});return e!==void 0?a:t.jsx(Fn,{spaceId:s.spaceId,children:a})}function gd({enabled:s,isOpen:e,onClose:a,spaceId:n,fileSidebar:o,widthPercent:i=60,minWidthPx:d,workflowTab:l,reviews:u,reviewTab:c,onFileTabSelect:f,filesEnabled:g,fileTabsDisabled:h,filesCount:y,artifactsCount:m,summaryActive:v,onSummarySelect:_,isResizing:re=!1}){return t.jsx(Ns,{children:s&&e?t.jsx(Tt.div,{initial:{width:0,minWidth:"0px",opacity:0}
6,animate:{width:`${i}%`,minWidth:`${d??0}px`,opacity:1},exit:{width:0,minWidth:"0px",opacity:0},transition:re||v?{width:{duration:0},minWidth:{duration:0},opacity:{duration:.3,ease:[.25,.1,.25,1]}}:{duration:.3,ease:[.25,.1,.25,1]},className:A.fileExplorerPanelMotion,"data-summary-active":v||void 0,children:t.jsx(pd,{onClose:a,spaceId:n,fileSidebar:o,workflowTab:l,reviews:u,reviewTab:c,onFileTabSelect:f,filesEnabled:g,fileTabsDisabled:h,filesCount:y,artifactsCount:m,summaryActive:v,onSummarySelect:_})},"file-explorer-pane"):null})}const ja="kiro.web.portal",wd="session-summary";let ds;function xd(){return ds||(ds=$s(ja,"session-summary.count-load-error")),ds}function an(s){try{xd().add(1,{OTelLib:ja,Feature:wd,Entity:s})}catch{}}const yd="_container_m2g03_27",bd="_bar_m2g03_34",us={container:yd,bar:bd};function Ca({lines:s,gap:e="var(--spacing-kiro-sm)",padding:a="var(--spacing-kiro-md)",label:n="Loading",className:o}){return t.jsx(w,{className:o?`${us.container} ${o}`:us.container,style:{gap:e,padding:a},role:"status","aria-busy":"true","aria-label":n,children:s.map((i,d)=>t.jsx(w,{className:us.bar,w:i.width??"100%",h:i.height??16,ml:i.indent??0,style:{animationDelay:`${d*.08}s`}},d))})}const Na="kiro.web.portal",_d="kiro-sessions";let fs;function vd(){return fs||(fs=$s(Na,"session.events")),fs}function rn(s){try{vd().add(1,{OTelLib:Na,Feature:_d,Activity:"sandbox-status-mirror",Entity:s})}catch{}}const Ra="GetSpaceCommand";function $a(s){if(s[0]!==Ra)return;const e=s[1];if(!(typeof e!="object"||e===null||!("spaceId"in e)))return typeof e.spaceId=="string"?e.spaceId:void 0}function Sd(s,e){let a;for(const n of s.getQueryCache().findAll({queryKey:[Ra]})){if($a(n.queryKey)!==e)continue;const o=s.getQueryData(n.queryKey)?.space?.sandboxStatus;o&&(!a||n.state.dataUpdatedAt>a.updatedAt)&&(a={status:o,updatedAt:n.state.dataUpdatedAt})}return a?.status}function kd(s){const e=Qt();r.useEffect(()=>{if(!s)return;const a=()=>{const n=Sd(e,s);if(!n){rn("no-cached-status");return}rn(Fr(e,s,n)?"patched":"no-change")};return a(),e.getQueryCache().subscribe(n=>{n.type!=="updated"||n.action.type!=="success"||$a(n.query.queryKey)!==s||a()})},[s,e])}const on=!0;function ms(s){return!(s.type!=="step"||s.status==="pending"||s.status==="paused"&&!s.hasStartEvidence)}function ps(s,e,a){if(s.nodePathKey!==void 0&&e.has(s.nodePathKey))return s.nodePathKey;if(s.nodeId!==void 0){const n=a.get(s.nodeId);if(n&&n.length===1)return n[0]}}function ln(s){const{tree:e,sources:a}=s,n=new Map,o=new Map;for(const c of e.rows){n.set(c.nodePathKey,c);const f=o.get(c.nodeId)??[];f.push(c.nodePathKey),o.set(c.nodeId,f)}const i=(c,f,g)=>{if(f===void 0||c.has(f))return;const h=n.get(f);!h||!ms(h)||c.set(f,g)},d=new Map;for(const[c,f]of a.liveNodeSessions)i(d,ps({nodePathKey:c},n,o),f);for(const c of a.stepSessionRefs){const f=ps({nodePathKey:Xs(c.nodePath),nodeId:c.nodeId},n,o);i(d,f,c.sessionId)}for(const c of e.rows)c.sessionId!==void 0&&i(d,c.nodePathKey,c.sessionId);const l=e.rows.some(c=>ms(c)&&!d.has(c.nodePathKey));if(a.sessionListRows)for(const c of a.sessionListRows){const f=c._meta?.kiro?.workflow;if(!f||f.workflowId!==e.workflowId)continue;const g=ps({nodePathKey:Xs(f.nodePath),nodeId:f.nodeId},n,o);i(d,g,c.sessionId)}const u=e.rows.some(c=>ms(c)&&!d.has(c.nodePathKey));return{sessionsByNodePathKey:d,needsSessionListBackstop:l,unresolvedAfterBackstop:u}}const jd=new Map;function Cd({spaceId:s,workflowId:e,tree:a}){const n=Or({spaceId:s,workflowId:e}),{routingSessionId:o,routingSessionError:i,routingSessionSettled:d}=Wn({spaceId:s}),l=o===void 0&&d,u=r.useSyncExternalStore(Wr,()=>Br(e)),c=n.data?.stepSessions,f=r.useMemo(()=>a?ln({tree:a,sources:{liveNodeSessions:u,stepSessionRefs:c??[]}}):null,[a,u,c]),g=f?.needsSessionListBackstop??!1,h=zr({spaceId:s,enabled:g}),y=h.data?.rows,m=h.data?.rowsDropped??0,v=r.useMemo(()=>!a||!y?f:ln({tree:a,sources:{liveNodeSessions:u,stepSessionRefs:c??[],sessionListRows:y}}),[a,f,u,c,y]),_=m>0&&(v?.unresolvedAfterBackstop??!1);return{sessionsByNodePathKey:v?.sessionsByNodePathKey??jd,stepSessionsQuery:n,sessionListFailed:g&&(h.isError&&!Kr(h.error)||_||l),sessionListError:h.error??(l?i:null)}}const Ta="kiro.web.portal",Nd="kiro-workflows";let hs;function Rd(){return hs||(hs=$s(Ta,"embedded.send.outcomes")),hs}const $d="none";function cn({kind:s,outcome:e,cause:a}){try{Rd().add(1,{OTelLib:Ta,Feature:Nd,Activity:`embedded_send_${s}`,Entity:e,ErrorType:a??$d}
6)}catch{}}const Td=300*1e3,Id=3,dn=new Set(["end_turn","refusal","cancelled"]);function Ed(s){return s instanceof Error&&s.name==="SessionNotFoundException"}function Pd({isStreamOpen:s,issuedProfileArn:e}){let a=e,n=null,o=[];const i=l=>{const u=o;o=[];for(const c of u)c(l)};function d(l){n??=l,i(n)}return{wait:()=>s()?Promise.resolve("open"):n!==null?Promise.resolve(n):new Promise(l=>{o.push(l)}),open:l=>{a=l,i("open")},end:()=>d("ended"),cancel:()=>d("cancelled"),get profileArn(){return a}}}function Ad({spaceId:s,sessionId:e,routingSessionId:a}){const n=Wn({spaceId:s}),{enabled:o,isLoading:i,isError:d}=Yt(),l=r.useRef(null);l.current===null&&(l.current=new ta);const u=l.current,c=r.useRef(null),f=r.useRef(null),{state:g,dispatchEvent:h,setStreamSessionId:y,resetState:m,addOptimisticUserMessage:v,rollbackOptimisticSend:_,settleUnconfirmedSend:re,closeAssistantSegment:j,refs:U}=la({streamScope:{spaceId:s},workflowsEnabled:o,workflowsGateLoading:i,workflowsGateError:d,onEvent:S=>{const ae=f.current;ae!==null&&ae===c.current&&u.eventReceived(S)}}),[$,P]=r.useState(!0),[Z,X]=r.useState(!1),[ee,D]=r.useState(!1),T=r.useRef(0),G=r.useRef(null),H=r.useRef(null),F=r.useRef(null),b=r.useRef(null),O=r.useRef(!1),B=r.useRef(!0),q=r.useRef(!1),K=r.useRef(0),J=r.useRef(null),N=r.useRef(n);N.current=n;const xe=r.useCallback(async(S,ae,oe,E)=>{for(;;){if(T.current!==ae){await S.return?.();return}const{value:te,done:ce}=await S.next();if(ce)return;if(T.current!==ae||oe.aborted){await S.return?.();return}if(f.current=S,te.event){const{eventType:Te,payload:ge}=te.event;Te&&ge&&(E?.(),h(Te,ge))}else te.done?(J.current=te.done.stopReason??null,E?.(),h("done",JSON.stringify(te.done))):te.error&&h("error",JSON.stringify(te.error));B.current&&J.current!==null&&(B.current=!1,P(!1))}},[h]),je=r.useCallback(async({myToken:S,abortSignal:ae,onStreamOpen:oe,onFirstFrame:E,armTtft:te})=>{let ce=!1;const Te=()=>{ce||(ce=!0,E?.())},ge=Date.now()+Td;let Ce=!1;
6do{if(T.current!==S)return"owner-changed";te&&!Ce&&(Ce=!0,u.streamStarted("loadSession",e)),y(e),J.current=null,U.current.lastStopReason=null;const{client:Ne,getCsrfToken:Ee,profileArn:ve,routingSessionId:V}=N.current;let Ie;try{Ie=(await Ne.send(new Tn({spaceId:s,sessionId:e,keepStreamOpen:!0,csrfToken:Ee(),profileArn:ve,routingSessionId:on?V:void 0}),{abortSignal:ae})).events}catch(be){if(T.current!==S)return"owner-changed";if(Ed(be))return q.current=!0,X(!0),B.current=!1,P(!1),"unavailable";throw be}if(!Ie)break;if(T.current!==S)return await Ie[Symbol.asyncIterator]().return?.(),"owner-changed";const Me=Ie[Symbol.asyncIterator]();H.current=Me,te&&(c.current=Me),O.current=!0,ae.aborted||oe?.(ve);try{await xe(Me,S,ae,Te)}finally{H.current===Me&&(H.current=null,O.current=!1)}if(T.current!==S)return"owner-changed"}while(J.current==="session_loaded"&&Date.now()<ge);return"ended"},[s,e,y,xe,U,u]),ye=r.useCallback(async({myToken:S,abortSignal:ae,onStreamOpen:oe,armTtft:E})=>{let te=!1,ce;try{if(await je({myToken:S,abortSignal:ae,onStreamOpen:oe,armTtft:E})!=="ended")return}catch(Ne){if(T.current!==S)return;te=!0,ce=Ne}if(B.current&&(B.current=!1,P(!1)),T.current!==S)return;const Te=J.current;if(!te&&Te!==null&&dn.has(Te))return;u.disconnected(te?Bn(ce)?"network_error":"attach_failed":"stream_ended");let ge=!1,Ce;try{Ce=await zn(async()=>{let Ne=!1;return await je({myToken:S,abortSignal:ae,armTtft:E,onStreamOpen:Ee=>{oe?.(Ee),!Ne&&(Ne=!0,Kn.publish({kind:"reconnected",spaceId:s}))},onFirstFrame:()=>{ge||(ge=!0,u.recovered())}})})}catch{}finally{if(!ge){const Ne=Ce==="owner-changed"||T.current!==S;u.recoveryExhausted(Ne?"abandoned":"exhausted")}}},[je,s,u]),we=r.useCallback(S=>{T.current+=1;const ae=G.current;G.current=null,S==="end"?ae?.end():ae?.cancel(),F.current?.abort(),F.current=null,H.current?.return?.(),H.current=null,O.current=!1},[]),I=r.useCallback((S=!0)=>{const ae=T.current,oe=Pd({isStreamOpen:()=>O.current,issuedProfileArn:N.current.profileArn});G.current=oe;const E=new AbortController;F.current=E;const te=(async()=>{try{await ye({myToken:ae,abortSignal:E.signal,onStreamOpen:oe.open,armTtft:S})}finally{F.current===E&&(F.current=null),G.current===oe&&(G.current=null),oe.end()}})();return b.current=te,te.finally(()=>{b.current===te&&(b.current=null)}),oe},[ye]),ne=r.useCallback((S,ae=!0)=>{G.current===S&&(we("end"),I(ae))},[we,I]),z=r.useCallback(async(S=!0)=>{const ae=K.current;if(q.current)return"unavailable";const oe=E=>O.current?"open":E==="open"?"ended":E;for(let E=0;E<Id;E+=1){const te=G.current??I(S),ce=await te.wait();if(ce==="cancelled")return ce;if(K.current!==ae)return"cancelled";if(q.current)return"unavailable";if(te.profileArn===N.current.profileArn)return oe(ce);ne(te,S)}return"ended"},[I,ne]);r.useEffect(()=>(T.current+=1,K.current+=1,B.current=!0,q.current=!1,P(!0),X(!1),m(),y(e),z(),()=>{K.current+=1,we("cancel")}),[s,e]);const W=r.useCallback((S,ae)=>{Gn(ae)?re(S):_(S)},[_,re]),pe=r.useCallback(async S=>{const ae=K.current;let oe;D(!0);try{oe=v(S);const E=await z(!1);if(E==="cancelled")return;if(E==="unavailable")throw new Error(`Step session ${e} is unavailable, so the prompt was not sent. Reopen the step to retry.`);const{client:te,getCsrfToken:ce,profileArn:Te,routingSessionId:ge}=N.current,Ce=!O.current,Ne=te.send(new In({spaceId:s,sessionId:e,contentBlocks:[{text:{text:S}}],csrfToken:ce(),profileArn:Te,routingSessionId:on?ge??s:void 0}));Ce&&Wo(),await Ne;const Ee=G.current;Ee!==null&&Ee.profileArn!==N.current.profileArn&&ne(Ee,!1);const ve=()=>K.current===ae&&!O.current&&!q.current;if(ve()){const V=b.current;V?V.then(()=>{const Ie=J.current;(Ie===null||!dn.has(Ie))&&ve()&&!G.current&&I(!1)}):I(!1)}j(null)}catch(E){throw oe!==void 0&&W(oe,E),E}finally{D(!1)}},[s,e,v,W,z,I,ne,j,U]),M=r.useCallback(async S=>{const{client:ae,getCsrfToken:oe,profileArn:E}=N.current;let te;D(!0);try{te=v(S);const ce=await Gr({client:ae,spaceId:s,routingSessionId:a??s,targetSessionId:e,text:S,csrfToken:oe(),profileArn:E});if(ce.status==="dropped")throw new Hr(ce.reason);if(ce.status==="unrecognized")throw new qr}catch(ce){throw te!==void 0&&W(te,ce),ce}finally{D(!1)}},[s,e,a,v,W]),le=r.useCallback(()=>{const{client:S,getCsrfToken:ae,profileArn:oe,routingSessionId:E}=N.current;Ur({client:S,spaceId:s,routingSessionId:E??s,targetSessionId:e,csrfToken:ae(),profileArn:oe}).catch(()=>{Bo()})},[s,e]);return{state:g,isLoading:$,isUnavailable:Z,sendPrompt:pe,sendSteer:M,stopTurn:le,isSending:ee}}const Ld="_embeddedChat_mpz1s_1",Md="_header_mpz1s_10",Dd="_headerLabel_mpz1s_19",Fd="_scrollArea_mpz1s_30",Od="_scrollContent_mpz1s_55",Wd="_loadingSkeleton_mpz1s_64",Bd="_inputArea_mpz1s_68",zd="_unavailableNote_mpz1s_77",Kd="_unavailableText_mpz1s_89",pt={embeddedChat:Ld,header:Md,headerLabel:Dd,scrollArea:Fd,scrollContent:Od,loadingSkeleton:Wd,inputArea:Bd,unavailableNote:zd,unavailableText:Kd};function Gd(s,e){return s==="paused"?"answer-paused":s==="running"?"steer-running":"message"}const Hd={"answer-paused":"Answer this step","steer-running":"Steer the agent","disabled-running":"The agent is mid-turn â send a message when the step pauses or completes",message:"Message this step's agent"},qd="Your message could not be sent. It is still in the composer â try again.",Ud="Message not sent",Vd="Delivery not confirmed",Qd="The connection dropped before this step confirmed your message, so it may already have been received. Check this conversation for a reply before sending it again â your text is still in the composer.";function Yd(s){if(s instanceof Error){const e=s.message.trim();if(e.length>0)return e}return qd}function Xd({spaceId:s,sessionId:e,routingSessionId:a,headerLabel:n,stepStatus:o}){const{state:i,isLoading:d,isUnavailable:l,sendPrompt:u,sendSteer:c,stopTurn:f,isSending:g}=Ad({spaceId:s,sessionId:e,routingSessionId:a}),h=r.useRef(null),[y,m]=r.useState(null);zo({scrollRef:h,contentEl:y});const v=Gd(o),_=r.useCallback(async re=>{const j=v==="steer-running";try{j?await c(re):await u(re),cn({kind:j?"steer":"prompt",outcome:"succeeded"})}catch(U){console.error("[embedded-session-chat] send failed",U);const $=Gn(U);throw cn({kind:j?"steer":"prompt",outcome:$?"unconfirmed":"rejected",cause:Vr(U)}),Vt.show({title:$?Vd:Ud,message:$?Qd:Yd(U),color:$?"yellow":"red",autoClose:8e3}),U}},[v,u,c]);return t.jsx(Qr,{value:s,children:t.jsx(Yr,{enabled:!1,children:t.jsxs(w,{className:pt.embeddedChat,"data-testid":"embedded-session-chat",children:[t.jsx(w,{className:pt.header,children:t.jsx(k,{component:"span",className:pt.headerLabel,title:n,children:n})}),l?t.jsxs(w,{className:pt.unavailableNote,"data-testid":"embedded-chat-unavailable",children:[t.jsx(Y,{id:"info",size:"sm"}),t.jsx(k,{component:"span",className:pt.unavailableText,children:"This step's conversation isn't available."})]}):t.jsxs(t.Fragment,{children:[t.jsx(w,{className:pt.scrollArea,ref:h,children:d?t.jsx(Ca,{className:pt.loadingSkeleton,label:"Loading step conversation",lines:[{width:"45%"},{width:"90%"},{width:"75%"},{width:"60%"}]}
6):t.jsx("div",{className:pt.scrollContent,ref:m,children:t.jsx(Xr,{state:i,hidePermissionBlock:!0,showSessionTitle:!0})})}),t.jsxs(w,{className:pt.inputArea,children:[t.jsx(Ns,{children:o==="running"?t.jsx(Zn,{onAction:f},"step-snack-bar"):null}),t.jsx(ea,{variant:"session",enableAttachments:!1,onSubmit:_,placeholder:Hd[v],disabled:v==="disabled-running",loading:g,clearOnSubmit:"restore-on-failure"})]})]})]})})})}const Jd=600*1e3,Ia=1e3,Zd=3e4,eu=2e3,un=5,tu=6e4,su=3e3,nu=5e3;function au(s){return s!=="off"}function ru({phase:s,kind:e,boundarySeen:a,turnOpen:n,pendingSend:o,pendingPermissionCount:i,active:d,gate:l,listSettled:u,timedOut:c}){return s!=="attached"||e!=="load"||!a||n||o||i>0||d?!1:c?!0:l!=="undecided"&&u}function ou(s){for(const e of s)if(e.status===null||!Xt(e.status))return!0;return!1}function Ea(s,e){return s!==null&&e-s<tu}function iu({hasNonterminalWorkflows:s,turnOpen:e,wakeGraceUntil:a,pendingSendSince:n,now:o}){return s||e||Ea(n,o)?!0:a!==null&&o<a}function fn(s){const e=Math.max(0,Math.floor(s));return Math.min(Ia*2**e,Zd)}function lu({endedCleanly:s,error:e,aborted:a,boundarySeen:n,boundaryAt:o,liveFrameCount:i,endedAt:d,turnOpen:l}){return!s&&ys(e)?"auth_error":l?"abnormal_mid_turn":s?n&&o!==null&&i===0&&d-o<=eu?"immediate_close":"idle_close":"abnormal_idle"}function cu({classification:s,endedCleanly:e,keepOpenRequested:a}){if(e&&!a)return null;switch(s){case"aborted":return null;case"auth_error":return"attach_failed";case"immediate_close":case"idle_close":return"stream_ended";case"abnormal_mid_turn":return e?"stream_ended":"network_error";case"abnormal_idle":return"network_error";default:{const n=s;throw new Error(`Unclassified stream end: ${String(n)}`)}}}function du({classification:s,active:e,consecutiveImmediateCloses:a,attempt:n,replayLost:o,replayRetried:i}){const d={action:"stop",delayMs:0},l={action:"stop_with_error",delayMs:0};return s==="aborted"?d:s==="auth_error"?o?l:d:e?s==="immediate_close"&&a>=un?d:s==="abnormal_mid_turn"&&n>=un?{action:"stop_with_error",delayMs:0}:{action:"reattach",delayMs:fn(n)}:o?i?l:{action:"reattach",delayMs:fn(n)}:d}function Pa(s,e){if(s!=="session_info_update")return null;try{const a=JSON.parse(e);if(typeof a!="object"||a===null)return null;const n=a._meta?.kiro;return n?.turnStart===!0?"start":n?.turnEnd!==void 0&&n.turnEnd!==null?"end":null}catch{return null}}function Aa(s,e){if(s!=="user_message_chunk")return null;try{const a=JSON.parse(e);if(typeof a!="object"||a===null)return null;const{content:n,text:o}=a;return typeof n=="object"&&n!==null?n.type==="text"&&typeof n.text=="string"?n.text:null:typeof o=="string"?o:null}catch{return null}}function La(s,e){const a=Hn(s);if(a!=="run_start"&&a!=="run_complete")return null;try{const n=JSON.parse(e);if(typeof n!="object"||n===null)return null;const{workflowId:o,status:i}=n;return typeof o!="string"||o.length===0?null:a==="run_start"?{workflowId:o,nonterminal:!0}:{workflowId:o,nonterminal:typeof i=="string"?!Xt(i):!1}}catch{return null}}function uu(s,e){return{async*[Symbol.asyncIterator](){for await(const a of s){if(a.event){const{eventType:n,payload:o}=a.event;if(n&&o){const i=Pa(n,o);i==="start"?e.onTurnStart?.():i==="end"&&e.onTurnEnd?.();const d=La(n,o);d!==null&&e.onWorkflowLifecycle?.(d),e.onFrame?.(n)}}else if(a.done){const n=a.done.stopReason??null;e.onDone?.(n),n!=="session_loaded"&&e.onTurnEnd?.(),e.onFrame?.("done")}yield a}}}}const fu=5e3,mu=8e6;async function pu({iterator:s,mode:e,isOwner:a,signal:n,dispatch:o,resetForReplay:i,onReady:d,onLiveFrame:l,onReplayFlushed:u,onWorkflowLifecycle:c,onTurnStart:f,onTurnEnd:g,onWireDone:h,metrics:y,gateLoadingRef:m,deferReady:v}){let _=[],re=0,j=!1,U=!1,$=!1,P=!1,Z=!1,X=e==="initial",ee=!1,D=null,T=0,G=null,H;const F=()=>a()&&!n.aborted,b=()=>{if(!Z){if(Z=!0,j&&m.current&&F()){v(d);return}d()}},O=()=>{if(_===null)return;if(!F()){_=null;return}const q=_;if(_=null,q.length!==0){X||(X=!0,i());for(const K of q)o(K.eventType,K.payload);u(q)}},B=(q,K)=>{if(!F()){_=null;return}if(y.eventReceived(q),m.current&&(q===Jr||Hn(q)!==null)&&(j=!0),_===null){o(q,K),ee&&(T+=1,l(q,K));return}_.push({eventType:q,payload:K}),$=!0,re+=K.length,_.length>=fu?(y.historyBufferFallback("frames"),O()):re>=mu&&(y.historyBufferFallback("chars"),O())};try{for(;;){if(!F()){await s.return?.();break}const{value:q,done:K}=await s.next();if(K){P=!0;break}if(!F()){_=null,await s.return?.();break}if(q.event){const{eventType:J,payload:N}=q.event;if(J&&N){const xe=Pa(J,N);if(xe==="start"?f():xe==="end"&&g(),ee){const je=La(J,N);je!==null&&c(je)}B(J,N)}}else if(q.done){const J=q.done.stopReason??null;G=J,h(J);const N=J==="session_loaded";N||g(),B("done",JSON.stringify(q.done)),N&&(ee||(ee=!0,D=Date.now()),U=!0,O(),b())}else q.error&&(U=!0,B("error",JSON.stringify(q.error)),O(),b())}}catch(q){H=q}finally{P&&!U&&$&&F()&&y.historyBufferFallback("noBoundary"),O(),b()}return{mode:e,endedCleanly:P,error:H,boundarySeen:ee,boundaryAt:D,liveFrameCount:T,lastStopReason:G,endedAt:Date.now()}}function hu(s){if(s)return{fields:{metaArgs:{ttft:!0,perf:!0}},commit:Ho}}function mn(s,e){return s.some(a=>Aa(a.eventType,a.payload)===e)}function gu(){return{phase:"none",kind:null,generation:0,abort:null,iterator:null,backoffTimer:null,consecutiveCloses:0,consecutiveImmediateCloses:0,turnOpen:!1,wakeGraceUntil:null,missedReplay:!1,lastLiveFrameAt:null,boundarySeen:!1,keepOpenRequested:!0,initialReplayRetried:!1,wireRuns:new Map,recoveryPending:!1,startPromise:null,releaseReady:null,selfCloseTimer:null,selfClosedAt:null,transportSeen:!1,disposed:!1,pendingSend:null,
6sentDuringReplay:[]}}function $t({error:s,mode:e}){return{mode:e,endedCleanly:!1,error:s,boundarySeen:!1,boundaryAt:null,liveFrameCount:0,lastStopReason:null,endedAt:Date.now()}}function Ma({owner:s,missedReplay:e,metrics:a}){s.backoffTimer!==null&&(clearTimeout(s.backoffTimer),s.backoffTimer=null),s.selfCloseTimer!==null&&(clearTimeout(s.selfCloseTimer),s.selfCloseTimer=null),s.sentDuringReplay=[],s.phase!=="none"&&(e&&s.kind==="load"&&!s.boundarySeen&&(s.missedReplay=!0),s.phase,s.kind,s.generation,s.abort?.abort(),s.iterator?.return?.()?.catch(()=>{}),s.releaseReady?.()),s.recoveryPending&&(a.recoveryExhausted("abandoned"),s.recoveryPending=!1),s.generation+=1,s.phase="none",s.kind=null,s.abort=null,s.iterator=null,s.startPromise=null,s.releaseReady=null,s.boundarySeen=!1,s.initialReplayRetried=!1}function wu({owner:s,sendAbortRef:e,deferredReadyRef:a,metrics:n}){s.disposed=!0,Ma({owner:s,missedReplay:!1,metrics:n}),e.current?.abort(),a.current?.(),a.current=null,n.cleanup()}function xu({vibeSpaceId:s,agentMode:e,hasNonterminalWorkflows:a=!1,workflowListSettled:n=!1}){const[o,i]=r.useState(s),[d,l]=r.useState(!1),[u,c]=r.useState(!1),[f,g]=r.useState(!1),[h,y]=r.useState(0),m=r.useRef(o),v=r.useCallback(C=>{m.current=C,i(C)},[]),{getCsrfToken:_,getIdp:re,userInfo:j}=Jt(),{defaultModelId:U}=Ko(),{enabled:$,isLoading:P,isError:Z}=Yt(),X=r.useRef(P);X.current=P;const ee=r.useRef(null),D=$?"on":P||Z?"undecided":"off",T=r.useRef(D);r.useEffect(()=>{T.current=D},[D]);const G=r.useRef(n);r.useEffect(()=>{G.current=n},[n]),r.useEffect(()=>{if(!P&&ee.current){const C=ee.current;ee.current=null,C()}},[P]);const H=r.useMemo(()=>qn(),[]),F=r.useRef(new ta),b=Mn(),O=r.useRef(!1);O.current=b;const{state:B,consumeStream:q,resetState:K,addOptimisticUserMessage:J,setError:N,setProcessing:xe,abortStream:je,dispatchEvent:ye,setStreamSessionId:we,liveReauth:I,clearLiveReauth:ne,closeAssistantSegment:z,refs:W}=la({onEvent:C=>F.current.eventReceived(C),streamScope:{spaceId:s},workflowsEnabled:$,workflowsGateLoading:P,workflowsGateError:Z}),pe=r.useRef(null);pe.current=ca(B).option;const M=r.useRef(gu()),le=r.useRef(null),S=r.useRef(0),ae=r.useRef(null),oe=a||ou(B.workflows.values()),E=r.useRef(!1),te=r.useRef(0);r.useEffect(()=>{te.current=B.pendingPermissions.size},[B.pendingPermissions]);const ce=r.useCallback(()=>{const C=M.current;C.backoffTimer!==null&&(clearTimeout(C.backoffTimer),C.backoffTimer=null)},[]),Te=r.useCallback(()=>{const C=M.current;C.consecutiveCloses=0,C.consecutiveImmediateCloses=0},[]),ge=r.useCallback(({missedReplay:C})=>{Ma({owner:M.current,missedReplay:C,metrics:F.current}),ee.current?.(),ee.current=null,c(!1)},[]);r.useEffect(()=>{const C=M.current,x=F.current;return C.disposed=!1,()=>{wu({owner:C,sendAbortRef:le,deferredReadyRef:ee,metrics:x})}},[]);const Ce=r.useRef(null),Ne=r.useRef(null),Ee=r.useCallback(()=>m.current??W.current.streamSessionId??s,[W,s]),ve=r.useCallback(C=>{const x=M.current;return iu({hasNonterminalWorkflows:E.current||[...x.wireRuns.values()].some(Boolean),turnOpen:x.turnOpen,wakeGraceUntil:x.wakeGraceUntil,pendingSendSince:x.pendingSend?.since??null,now:C})},[]),V=r.useCallback(({workflowId:C,nonterminal:x})=>{M.current.wireRuns.set(C,x)},[]);r.useEffect(()=>{const C=E.current;E.current=oe;const x=M.current;if(C&&!oe){x.wakeGraceUntil=Date.now()+Jd,x.wakeGraceUntil;return}if(!C&&oe){const p=Ee(),fe=Ce.current;x.transportSeen&&x.phase==="none"&&x.backoffTimer===null&&!W.current.isSendingMessage&&p&&fe&&(x.generation,fe({mode:"reattach",sessionId:p}).then(ue=>{ue.status==="failed"&&Ne.current?.($t({error:ue.error,mode:"reattach"}))}))}},[oe,Ee,W]);const Ie=r.useCallback(C=>{const x=M.current,p=Date.now(),fe=T.current,ue=G.current,Re=ve(p);ru({phase:x.phase,kind:x.kind,boundarySeen:x.boundarySeen,turnOpen:x.turnOpen,pendingSend:Ea(x.pendingSend?.since??null,p),pendingPermissionCount:te.current,active:Re,gate:fe,listSettled:ue,timedOut:C==="timeout"})&&(x.generation,x.selfCloseTimer!==null&&(clearTimeout(x.selfCloseTimer),x.selfCloseTimer=null),x.recoveryPending&&(F.current.recovered(),x.recoveryPending=!1),x.selfClosedAt=p,ge({missedReplay:!1}))},[ve,ge]),Me=r.useCallback(C=>{const x=M.current;x.selfCloseTimer!==null&&clearTimeout(x.selfCloseTimer),x.selfCloseTimer=setTimeout(()=>{x.selfCloseTimer=null,x.generation===C&&Ie("timeout")},su)},[Ie]);r.useEffect(()=>
6{M.current.phase==="attached"&&Ie("evaluate")},[h,oe,D,n,Ie]);const be=r.useCallback(C=>{const x=M.current;ce(),x.backoffTimer=setTimeout(()=>{x.backoffTimer=null;const p=Ee(),fe=Ce.current;!p||!fe||fe({mode:"reattach",sessionId:p}).then(ue=>{ue.status==="failed"&&Ne.current?.($t({error:ue.error,mode:"reattach"}))})},C)},[ce,Ee]),Xe=r.useCallback(C=>{const x=M.current,p=Date.now(),fe=lu({endedCleanly:C.endedCleanly,error:C.error,aborted:!1,boundarySeen:C.boundarySeen,boundaryAt:C.boundaryAt,liveFrameCount:C.liveFrameCount,endedAt:C.endedAt,turnOpen:x.turnOpen});x.consecutiveCloses+=1,fe==="immediate_close"?x.consecutiveImmediateCloses+=1:x.consecutiveImmediateCloses=0;const ue=!C.endedCleanly&&!C.boundarySeen&&(C.mode==="initial"||x.initialReplayRetried);ue&&(x.missedReplay=!0);const Re=ve(p),_e=du({classification:fe,active:Re,consecutiveImmediateCloses:x.consecutiveImmediateCloses,attempt:x.consecutiveCloses-1,replayLost:ue,replayRetried:x.initialReplayRetried});x.consecutiveCloses,x.consecutiveImmediateCloses;const $e=cu({classification:fe,endedCleanly:C.endedCleanly,keepOpenRequested:x.keepOpenRequested});if($e!==null&&!x.recoveryPending&&(F.current.disconnected($e),x.recoveryPending=!0),_e.action==="reattach"){ue&&(x.initialReplayRetried=!0),be(_e.delayMs);return}x.initialReplayRetried=!1,x.recoveryPending&&(F.current.recoveryExhausted(_e.action==="stop_with_error"?"exhausted":"abandoned"),x.recoveryPending=!1),_e.action==="stop_with_error"&&(x.turnOpen=!1,xe(!1),N({code:"stream_error",message:C.error instanceof Error?C.error.message:"Stream consumption failed"}))},[ve,be,xe,N]),Fe=r.useCallback(async({mode:C,sessionId:x})=>{const p=M.current;if(p.disposed)return{status:"superseded"};
6if(p.phase!=="none")return p.startPromise??{status:"superseded"};if(!s)return{status:"failed",error:new Error("No space to attach to")};const fe=s,ue=++p.generation,Re=new AbortController,{signal:_e}=Re;p.transportSeen=!0,p.selfClosedAt=null,p.phase="attaching",p.kind="load",p.abort=Re,p.iterator=null,p.boundarySeen=!1,p.sentDuringReplay=[],p.missedReplay=!1,ce();const $e=()=>p.generation===ue&&!_e.aborted;let He=()=>{};const it=new Promise(Oe=>{He=Oe});let lt=!1;const Je=()=>{lt||(lt=!0,He())};p.releaseReady=Je,T.current;const Ge=()=>{p.generation===ue&&(p.phase="none",p.kind=null,p.abort=null,p.iterator=null,p.startPromise=null,p.releaseReady=null,p.selfCloseTimer!==null&&(clearTimeout(p.selfCloseTimer),p.selfCloseTimer=null))},Ve=(async()=>{let Oe;try{Oe=await zn(async()=>{if(_e.aborted)return;we(x),F.current.streamStarted("loadSession",x);const Q=T.current,me=au(Q);return p.keepOpenRequested=me,H.send(new Tn({spaceId:fe,sessionId:x,keepStreamOpen:me,csrfToken:_()}),{abortSignal:_e})})}catch(Q){const me=$e();return Ge(),Je(),me?{status:"failed",error:Q}:{status:"superseded"}}if(Oe===void 0||!$e())return await Oe?.events?.[Symbol.asyncIterator]?.().return?.(),Ge(),Je(),{status:"superseded"};
6if(v(Oe.sessionId??x),!Oe.events)return Ge(),Je(),{status:"attached",ready:it};const Ze=Oe.events[Symbol.asyncIterator]();p.iterator=Ze,p.phase="attached",C==="reattach"&&(p.turnOpen||te.current>0)&&c(!0);let tt=!1,L=[];return pu({iterator:Ze,mode:C,isOwner:$e,signal:_e,dispatch:ye,resetForReplay:()=>{K(),p.wireRuns.clear(),W.current.userMessageCounter=0,we(x),L=p.sentDuringReplay,p.sentDuringReplay=[]},onReplayFlushed:Q=>{if(p.pendingSend!==null&&mn(Q,p.pendingSend.content)&&(p.pendingSend=null),L.length===0)return;const me=L;L=[];for(const se of me)mn(Q,se.content)||J(se.content,se.attachments)},onReady:()=>{$e()&&c(!1),Je()},onLiveFrame:(Q,me)=>{if(p.lastLiveFrameAt=Date.now(),p.consecutiveCloses=0,p.consecutiveImmediateCloses=0,p.pendingSend!==null&&Q==="user_message_chunk"){const se=Aa(Q,me);(se===null||se===p.pendingSend.content)&&(p.pendingSend=null)}tt||(tt=!0,C==="reattach"&&(Kn.publish({kind:"reconnected",spaceId:fe}),p.recoveryPending&&(F.current.recovered(),p.recoveryPending=!1)))},onWorkflowLifecycle:V,onTurnStart:()=>{p.turnOpen=!0,p.boundarySeen&&(p.pendingSend=null)},onTurnEnd:()=>{p.turnOpen=!1},onWireDone:Q=>{if(Q!=="session_loaded"){p.boundarySeen&&(p.pendingSend=null);return}$e()&&(p.boundarySeen=!0,p.initialReplayRetried=!1,y(me=>me+1),Me(ue))},metrics:F.current,gateLoadingRef:X,deferReady:Q=>{ee.current=Q}}).then(Q=>{if(p.generation!==ue){p.selfClosedAt;return}Ge(),c(!1),!_e.aborted&&W.current.streamSessionId&&v(W.current.streamSessionId),Ne.current?.(Q)}),{status:"attached",ready:it}})();return p.startPromise=Ve,Ve},[s,H,_,ce,we,v,ye,K,J,V,Me,W]);r.useEffect(()=>{Ce.current=Fe,Ne.current=Xe},[Fe,Xe]),r.useEffect(()=>{const C=()=>{if(document.visibilityState!=="visible")return;const x=M.current,p=($e,He)=>{qo($e),{generation:x.generation,...He}};if(x.disposed){p("disposed");return}if(x.phase!=="none"){p("streamLive",{phase:x.phase,kind:x.kind});return}if(x.backoffTimer!==null){p("backoffPending");return}if(!x.transportSeen){p("transportNotSeen");return}if(W.current.isSendingMessage){p("sendUnwinding");return}const fe=Ce.current,ue=Ee();if(!ue||!fe){p("noSession",{hasSessionId:ue!==null,hasAttach:fe!==null});return}const Re=Date.now(),_e=ae.current;if(_e!==null&&_e.sessionId===ue&&Re-_e.at<nu){p("debounced",{sessionId:ue,sinceMs:Re-_e.at});return}fe({mode:"reattach",sessionId:ue}).then($e=>{if($e.status==="attached"){ae.current={sessionId:ue,at:Date.now()},p("reattached",{sessionId:ue});return}if($e.status==="failed"){p("attachFailed",{sessionId:ue}),Ne.current?.($t({error:$e.error,mode:"reattach"}));return}p("superseded",{sessionId:ue})})};return document.addEventListener("visibilitychange",C),()=>document.removeEventListener("visibilitychange",C)},[Ee,W]);const de=r.useCallback(async(C,x)=>{if(!s)return;const p=M.current;ne(),g(!0),J(C,x),Te();let fe=null,ue=null,Re=null;try{const _e=m.current,$e=e==="AUTONOMOUS"?"auto":sa()??U??"auto",He=_(),it=(re()??j.idp)===lr.ExternalOIDC;if(!He&&!it){N({code:"auth_failed",message:"Session expired. Please refresh the page or sign in again."});return}const lt=Go({effortOption:pe.current,spaceId:s}),Je=lt?.configOptions,Ge=hu(O.current),Ve=x?.filter(Js),Oe=x?.filter(se=>!Js(se)),Ze=Ve&&Ve.length>0,tt=Oe&&Oe.length>0,L=C||(Ze||tt?"[Examine the attached files]":C),Q=p.phase==="attached"||p.phase==="attaching"&&p.kind==="send";Q||(W.current.isSendingMessage=!0,Zr(W.current),W.current.streamSessionId=null);const me=[...Ze?Ve.map(se=>({image:{data:se.data,mimeType:se.mimeType}})):[],...tt?Oe.map(se=>({resource:{uri:`attachment://${se.fileName}`,mimeType:se.mimeType,body:{blob:se.data}}})):[],{text:{text:L}}];if(Q){if(p.pendingSend={since:Date.now(),content:L},p.kind==="load"&&!p.boundarySeen&&p.sentDuringReplay.push({content:L,attachments:x}),Re=p.generation,await H.send(new In({spaceId:s,sessionId:_e??void 0,contentBlocks:me,csrfToken:He,modelId:$e,agentMode:e,configOptions:Je,...Ge?.fields})),lt?.commit(),Ge?.commit(),W.current.hasActiveSubAgent||z(null),g(!1),p.generation!==Re)return;if(p.phase==="none"){const se=Ee();if(se){const Le=await Fe({mode:"reattach",sessionId:se});Le.status==="failed"&&Ne.current?.($t({error:Le.error,mode:"reattach"}))}}}else{ge({missedReplay:!0}),fe=new AbortController,le.current=fe,ue=++p.generation,p.transportSeen=!0,p.phase="attaching",p.kind="send",p.abort=fe,p.turnOpen=!0,we(_e??s);let se;try{F.current.streamStarted("streamSendMessage",_e??void 0),se=await H.send(new cr({spaceId:s,sessionId:_e??void 0,contentBlocks:me,csrfToken:He,modelId:$e,agentMode:e,configOptions:Je,...Ge?.fields}
6),{abortSignal:fe.signal})}catch(qe){throw F.current.cleanup(),p.generation===ue&&(p.phase="none",p.kind=null,p.abort=null,p.turnOpen=!1),qe}if(Ge?.commit(),p.generation!==ue){await se.events?.[Symbol.asyncIterator]?.().return?.();return}lt?.commit(),g(!1),se.sessionId&&se.sessionId!=="pending"&&v(se.sessionId);let Le=null;if(se.events){const qe=se.events[Symbol.asyncIterator](),Zt={[Symbol.asyncIterator]:()=>qe};p.iterator=qe,p.phase="attached";try{await q(uu(Zt,{onDone:Pt=>{Le=Pt,Pt!=="session_loaded"&&(p.pendingSend=null)},onTurnStart:()=>{p.turnOpen=!0,p.pendingSend=null},onTurnEnd:()=>{p.turnOpen=!1},onWorkflowLifecycle:V,onFrame:()=>{p.lastLiveFrameAt=Date.now(),p.consecutiveCloses=0,p.consecutiveImmediateCloses=0}}))}finally{p.generation===ue&&(p.phase="none",p.kind=null,p.abort=null,p.iterator=null)}}else p.generation===ue&&(p.phase="none",p.kind=null,p.abort=null);if(fe.signal.aborted||p.generation!==ue)return;const We=Ee(),Se=Le==="session_loaded"||p.missedReplay||ve(Date.now());if(p.missedReplay,Se&&We){const qe=await Fe({mode:"reattach",sessionId:We});qe.status==="failed"&&Ne.current?.($t({error:qe.error,mode:"reattach"}))}}}catch(_e){if(fe?.signal.aborted||p.disposed)return;if(p.pendingSend=null,eo(_e)){Vt.show({title:"Attachment too large",message:"Your attachments exceed the current size limit. Try smaller files or fewer attachments.",color:"red",autoClose:8e3}),N({code:"send_failed",message:"Attachments are too large to send. Try smaller files or fewer attachments."});return}if(!ys(_e)&&Bn(_e)){if(Re!==null&&p.generation!==Re)return;F.current.disconnected("network_error"),p.recoveryPending=!0;const $e=m.current??W.current.streamSessionId;if($e){if((await Fe({mode:"reattach",sessionId:$e})).status!=="failed")return;p.turnOpen=!1,F.current.recoveryExhausted("exhausted"),p.recoveryPending=!1}N({code:"send_failed",message:"Connection lost. Please reload the page to continue."});return}N({code:ys(_e)?"auth_failed":"send_failed",message:_e instanceof Error?_e.message:"Failed to send message"})}finally{g(!1),W.current.isSendingMessage=!1}W.current.streamSessionId&&v(W.current.streamSessionId)},[s,H,_,re,j,e,U,q,Fe,ge,Te,V,Ee,ve,J,ne,z,N,v,W,we]),Ke=r.useCallback(async C=>{if(!s)return;const x=M.current,p=++S.current;ge({missedReplay:!1}),le.current?.abort(),Te(),x.pendingSend=null,l(!0),K(),x.wireRuns.clear(),W.current.userMessageCounter=0,we(C);try{const fe=await Fe({mode:"initial",sessionId:C});fe.status==="attached"?await fe.ready:fe.status==="failed"&&S.current===p&&N({code:"load_failed",message:fe.error instanceof Error?fe.error.message:"Failed to load session"})}finally{S.current===p&&l(!1)}},[s,ge,Te,K,W,we,Fe,N]),et=r.useCallback(async C=>{const x=B.pendingPermissions.size>0?B.pendingPermissions.values().next().value:null;if(!s||!x)return;const p=m.current??x.sessionId;if(!p)return;const fe=M.current,ue=fe.generation;try{await H.send(new dr({spaceId:s,sessionId:p,permissionRequestId:x.toolCall.toolCallId,permissionOptionId:C,csrfToken:_()})),li(x.interactionType)}catch(Re){N({code:"permission_response_failed",message:Re instanceof Error?Re.message:"Failed to respond to permission"});return}if(fe.generation===ue&&(Te(),fe.turnOpen=!0,fe.phase==="none")){const Re=await Fe({mode:"reattach",sessionId:p});Re.status==="failed"&&N({code:"load_failed",message:Re.error instanceof Error?Re.error.message:"Failed to reconnect session"})}},[s,B.pendingPermissions,H,_,N,Te,Fe]),rt=r.useCallback(async C=>{await et(C)},[et]),ot=r.useCallback(()=>{const C=M.current;je(),le.current?.abort(),ge({missedReplay:!1}),F.current.cleanup(),g(!1),l(!1),ye("done",JSON.stringify({stopReason:"cancelled"})),xe(!1),C.turnOpen=!1,C.pendingSend=null;const x=m.current??W.current.streamSessionId;s&&x&&H.send(new ur({spaceId:s,sessionId:x,csrfToken:_()})).catch(()=>{}),ve(Date.now())&&be(Ia)},[je,ge,xe,s,H,_,W,ye,ve,be]);return{state:B,sendMessage:de,loadSession:Ke,respondToPermission:et,respondToUserInput:rt,currentSessionId:o,isLoading:d,isReconnecting:u,isSending:f,liveReauth:I,abortStream:ot}}const yu={category:"KiroWeb",version:"1.0.0",name:"AutonomousAgent",locale:"en_US"},js="task-execution",bu={surveyId:js,samplingRate:100,cooldownDays:30};function _u(s){const e=dt.c(21),{isAutonomous:a}=s,{userInfo:n}=Jt(),[o,i]=r.useState(!1),[d,l]=r.useState(null),u=a?"taskExecutedAutonomous":"taskExecutedVibe";let c;e[0]!==u?(c={...yu,reference:u},e[0]=u,e[1]=c):c=e[1];const f=c,g=n.userId??"";let h;e[2]!==f||e[3]!==g?(h={...f,userid:g,serviceid:"kiro-autonomous-agent"},e[2]=f,e[3]=g,e[4]=h):h=e[4];const y=h;let m;e[5]!==y?(m={config:y},e[5]=y,e[6]=m):m=e[6];const{feedbackModalOpened:v,feedbackTemplate:_,handleFeedbackClick:re,closeFeedbackModal:j}=En(m);let U;e[7]===Symbol.for("react.memo_cache_sentinel")?(U=()=>{const T=ci(bu);return l(T),T&&i(!0),T},e[7]=U):U=e[7];const $=U;let P;e[8]!==re?(P=()=>{tn(js),i(!1),re()},e[8]=re,e[9]=P):P=e[9];const Z=P;let X;e[10]!==j?(X=()=>{tn(js),i(!1),j()},e[10]=j,e[11]=X):X=e[11];const ee=X;let D;return e[12]!==j||e[13]!==ee||e[14]!==f||e[15]!==v||e[16]!==_||e[17]!==d||e[18]!==Z||e[19]!==o?(D={isEligible:d,checkEligibility:$,showBanner:o,modalOpened:v,openModal:Z,dism
6iss:ee,closeModal:j,template:_,config:f},e[12]=j,e[13]=ee,e[14]=f,e[15]=v,e[16]=_,e[17]=d,e[18]=Z,e[19]=o,e[20]=D):D=e[20],D}function vu(s){return Pn()[s]??""}function Su({spaceId:s,sessionId:e,enabled:a}){const{data:n,error:o,isLoading:i}=to({input:{spaceId:s,sessionId:e??""},options:{enabled:a&&!!s&&!!e,refetchInterval:3e4,staleTime:15e3,retry:2,retryDelay:1e3,throwOnError:!1}}),d=n?.pullRequests??[],l=d.length>0||!!o;return{pullRequests:d,error:o,hasPullRequests:l,isLoading:i,hasAnswered:n!==void 0}}function ku(s){const e=dt.c(10),{spaceId:a}=s,n=Qt(),{getCsrfToken:o}=Jt();let i;e[0]!==n?(i={options:{onMutate:async g=>{if(g.spaceType==null||!g.spaceId)return{};const h=sa();Qo(g.spaceType==="AUTONOMOUS");const y=["GetSpaceCommand",{spaceId:g.spaceId}];await n.cancelQueries({queryKey:y});const m=n.getQueryData(y);return m?.space&&n.setQueryData(y,{...m,space:{...m.space,spaceType:g.spaceType}}),{previousSpace:m,queryKey:y,previousPendingModel:h}},onError:(g,h,y)=>{const m=y;m?.queryKey&&m.previousSpace!==void 0&&n.setQueryData(m.queryKey,m.previousSpace),m&&"previousPendingModel"in m&&(m.previousPendingModel==null?Uo():Vo(m.previousPendingModel))},onSuccess:(g,h)=>{h.displayName!=null&&h.spaceId&&Un(n,h.spaceId,h.displayName),h.spaceType!=null&&no(n),n.invalidateQueries({queryKey:["GetSpaceCommand"]})}}},e[0]=n,e[1]=i):i=e[1];const d=so(i);let l;e[2]!==o||e[3]!==d||e[4]!==a?(l=async g=>(await d.mutateAsync({spaceId:a,displayName:g.displayName,spaceType:g.spaceType,csrfToken:o()})).space,e[2]=o,e[3]=d,e[4]=a,e[5]=l):l=e[5];const u=l,c=d.error??null;let f;return e[6]!==d.isPending||e[7]!==c||e[8]!==u?(f={updateVibeSpace:u,isPending:d.isPending,error:c},e[6]=d.isPending,e[7]=c,e[8]=u,e[9]=f):f=e[9],f}const ju="_tree_1xn74_19",Cu="_header_1xn74_45",Nu="_headerAction_1xn74_53",Ru="_search_1xn74_60",$u="_rows_1xn74_68",Tu="_row_1xn74_68",Iu="_selected_1xn74_89",Eu="_indentGuides_1xn74_99",Pu="_indentGuide_1xn74_99",Au="_indentGuideActive_1xn74_114",Lu="_rowContent_1xn74_118",Mu="_glyph_1xn74_126",Du="_label_1xn74_142",Fu="_match_1xn74_149",Ou="_message_1xn74_154",Wu="_errorMessage_1xn74_160",Bu="_errorState_1xn74_164",zu="_errorStateText_1xn74_175",Ku="_retryButton_1xn74_180",Ae={tree:ju,header:Cu,headerAction:Nu,search:Ru,rows:$u,row:Tu,selected:Iu,indentGuides:Eu,indentGuide:Pu,indentGuideActive:Au,rowContent:Lu,glyph:Mu,label:Du,match:Fu,message:Ou,errorMessage:Wu,errorState:Bu,errorStateText:zu,retryButton:Ku};function Gu(s,e){if(!e)return s;const a=s.toLowerCase().indexOf(e.toLowerCase());return a===-1?s:t.jsxs(t.Fragment,{children:[s.slice(0,a),t.jsx("span",{className:Ae.match,children:s.slice(a,a+e.length)}),s.slice(a+e.length)]})}function Hu(s){const e=dt.c(54),{row:a,selected:n,tabbable:o,query:i,activeGuideLevel:d,activeGuidePrefix:l,onSelect:u,onToggleTwistie:c,onContextMenu:f}=s,{entry:g,depth:h,isDirectory:y,isExpanded:m,isLoading:v,hasError:_}=a,re=n?Ae.selected:"";let j;
6e[0]!==re?(j=[Ae.row,re].filter(Boolean),e[0]=re,e[1]=j):j=e[1];const U=j.join(" ");let $;e[2]!==l||e[3]!==g.path?($=l!==""&&g.path.startsWith(l),e[2]=l,e[3]=g.path,e[4]=$):$=e[4];const P=$,Z=h+1,X=y?m:void 0,ee=o?0:-1,D=g.path,T=g.path;let G;e[5]!==u||e[6]!==a?(G=()=>u(a),e[5]=u,e[6]=a,e[7]=G):G=e[7];let H;e[8]!==f||e[9]!==a?(H=ye=>f(ye,a),e[8]=f,e[9]=a,e[10]=H):H=e[10];let F;e[11]!==u||e[12]!==a?(F=ye=>{(ye.key==="Enter"||ye.key===" ")&&(ye.preventDefault(),u(a))},e[11]=u,e[12]=a,e[13]=F):F=e[13];let b;if(e[14]!==d||e[15]!==h||e[16]!==P){let ye;e[18]!==d||e[19]!==P?(ye=(we,I)=>{const ne=I===d&&P;return t.jsx("span",{className:ne?`${Ae.indentGuide} ${Ae.indentGuideActive}`:Ae.indentGuide},I)},e[18]=d,e[19]=P,e[20]=ye):ye=e[20],b=t.jsx("div",{className:Ae.indentGuides,"aria-hidden":"true",children:Array.from({length:h},ye)}),e[14]=d,e[15]=h,e[16]=P,e[17]=b}else b=e[17];let O;e[21]!==h?(O={"--ft-depth":h},e[21]=h,e[22]=O):O=e[22];const B=O;let q;e[23]!==g.type||e[24]!==y||e[25]!==m||e[26]!==v||e[27]!==c||e[28]!==a?(q=y?t.jsx("button",{type:"button",className:Ae.glyph,tabIndex:-1,"aria-label":m?"Collapse folder":"Expand folder",onClick:ye=>{ye.stopPropagation(),c(a)},children:v?t.jsx(bt,{size:12,color:"var(--ft-icon)"}):t.jsx(Y,{id:"chevron-down",size:"md",style:{transform:m?"none":"rotate(-90deg)",transition:"transform 0.1s linear"}})}):t.jsx("span",{className:Ae.glyph,children:g.type==="SYMLINK"?t.jsx(Y,{id:"file-symlink-file",size:"md"}):t.jsx(Y,{id:"file",size:"md"})}),e[23]=g.type,e[24]=y,e[25]=m,e[26]=v,e[27]=c,e[28]=a,e[29]=q):q=e[29];let K;e[30]!==g.name||e[31]!==i?(K=Gu(g.name,i),e[30]=g.name,e[31]=i,e[32]=K):K=e[32];let J;e[33]!==K?(J=t.jsx("span",{className:Ae.label,children:K}),e[33]=K,e[34]=J):J=e[34];let N;e[35]!==_?(N=_?t.jsx(Y,{id:"warning",size:"xs",c:"var(--color-feedback-error)",iconAriaLabel:"Failed to load folder contents"}):null,e[35]=_,e[36]=N):N=e[36];let xe;e[37]!==B||e[38]!==q||e[39]!==J||e[40]!==N?(xe=t.jsxs("div",{className:Ae.rowContent,style:B,children:[q,J,N]}),e[37]=B,e[38]=q,e[39]=J,e[40]=N,e[41]=xe):xe=e[41];let je;return e[42]!==g.path||e[43]!==U||e[44]!==n||e[45]!==H||e[46]!==F||e[47]!==b||e[48]!==xe||e[49]!==Z||e[50]!==X||e[51]!==ee||e[52]!==G?(je=t.jsxs("div",{className:U,role:"treeitem","aria-level":Z,"aria-selected":n,"aria-expanded":X,tabIndex:ee,title:D,"data-path":T,onClick:G,onContextMenu:H,onKeyDown:F,children:[b,xe]}),e[42]=g.path,e[43]=U,e[44]=n,e[45]=H,e[46]=F,e[47]=b,e[48]=xe,e[49]=Z,e[50]=X,e[51]=ee,e[52]=G,e[53]=je):je=e[53],je}const qu=r.memo(Hu),Ut="",pn=8,Uu=2e4,Cs=500,hn=new WeakMap;let gn=0;function Vu(s){let e=hn.get(s);return e===void 0&&(gn+=1,e=`api-${gn}`,hn.set(s,e)),e}function ct(s){return s==="."?Ut:s}function Qu(s){const e=s.lastIndexOf("/");return e===-1?Ut:s.slice(0,e)}function Da(s){const e=s.split("/"),a=[];for(let n=1;n<e.length;n++)a.push(e.slice(0,n).join("/"));return a}const Yu=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function Fa(s){return[...s].sort((e,a)=>{const n=e.type==="DIRECTORY",o=a.type==="DIRECTORY";return n!==o?n?-1:1:Yu.compare(e.name,a.name)})}function Xu(s,e,a){const n=e.trim().toLowerCase();if(!n)return{rows:[],truncated:!1};const o=new Map;for(const c of s){const f=Qu(c.path),g=o.get(f);g?g.push(c):o.set(f,[c])}const i=new Set;for(const c of s)if(c.name.toLowerCase().includes(n)){i.add(c.path);for(const f of Da(c.path))i.add(f)}const d=[],l=ct(a),u=(c,f)=>{const g=o.get(c);if(g)for(const h of Fa(g)){if(!i.has(h.path))continue;const y=h.type==="DIRECTORY";d.push({entry:h,depth:f,isDirectory:y,isExpanded:y,isLoading:!1,hasError:!1}),y&&u(h.path,f+1)}};return u(l,0),d.length>Cs?{rows:d.slice(0,Cs),truncated:!0}:{rows:d,truncated:!1}}function Ju(s,e={}){const{rootPath:a=Ut,includeHidden:n=!1,selectedPath:o,onSelect:i,initialExpandedPaths:d,onExpandedPathsChange:l,autoExpandRoot:u=!1}=e,c=Qt(),f=Vu(s),[g,h]=r.useState({}),[y,m]=r.useState(()=>new Set),v=r.useRef(new Set),_=r.useRef(new Set),[re,j]=r.useState(),U=o??re,[$,P]=r.useState([]),[Z,X]=r.useState(!1),[ee,D]=r.useState(),[T,G]=r.useState(!1),[H,F]=r.useState(!1),b=r.useRef(!1),O=r.useRef(0),B=r.useRef(0),q=r.useRef(!0);r.useEffect(()=>(q.current=!0,()=>{q.current=!1}),[]);const K=r.useCallback(async ne=>{const z=ct(ne),W=B.current;h(pe=>({...pe,[z]:{entries:pe[z]?.entries??[],loading:!0,error:void 0}}));try{const pe=await c.fetchQuery({queryKey:["listFiles",f,{path:z,includeHidden:n}],queryFn:()=>s.listFiles({path:z,includeHidden:n}),staleTime:3e4});if(!q.current||B.current!==W)return;const M=Fa(pe.entries);return h(le=>({...le,[z]:{entries:M,loading:!1,error:void 0}})),M}catch(pe){if(!q.current||B.current!==W)return;const M=pe instanceof Error?pe.message:"Failed to list directory";h(le=>({...le,[z]:{entries:le[z]?.entries??[],loading:!1,error:M}}));return}},[s,f,n,c]),J=r.useCallback(ne=>{const z=ne.filter(le=>le.type==="DIRECTORY"),W=z.length===1?z[0]:void 0;if(!W)return;const pe=ct(W.path),M=new Set(v.current);M.add(pe),v.current=M,m(M),l?.(M),_.current.has(pe)||(_.current.add(pe),K(W.path).finally(()=>_.current.delete(pe)))},[K,l]);r.useEffect(()=>{h({});const ne=d??new Set;
6m(new Set(ne)),v.current=new Set(ne),_.current=new Set,b.current=!1,O.current+=1,B.current+=1,P([]),X(!1),D(void 0),G(!1),F(!1),K(a).then(z=>{u&&ne.size===0&&z&&J(z)});for(const z of ne)z===ct(a)||_.current.has(z)||(_.current.add(z),K(z).finally(()=>_.current.delete(z)))},[a,n,s]),r.useEffect(()=>{if(U===void 0)return;const ne=ct(a),z=Da(U).map(ct).filter(M=>M!==ne&&(ne===Ut||M.startsWith(`${ne}/`)));if(z.length===0)return;const W=new Set(v.current);let pe=!1;for(const M of z)W.has(M)||(W.add(M),pe=!0);pe&&(v.current=W,m(W),l?.(W));for(const M of z){const le=g[M];(le===void 0||le.error)&&!_.current.has(M)&&(_.current.add(M),K(M).finally(()=>_.current.delete(M)))}},[U]);const N=r.useCallback(()=>{if(b.current)return;b.current=!0;const ne=O.current;X(!0),D(void 0);const z=()=>!q.current||O.current!==ne;(async()=>{try{const W=[];let pe=0;const M=new Set([ct(a)]);let le=[ct(a)],S=!1;for(;le.length>0;){const ae=le.slice(0,pn);le=le.slice(pn);const oe=await Promise.allSettled(ae.map(te=>c.fetchQuery({queryKey:["listFiles",f,{path:te,includeHidden:n}],queryFn:()=>s.listFiles({path:te,includeHidden:n}),staleTime:3e4})));if(z())return;const E=[];for(const te of oe){if(te.status==="rejected"){pe+=1;continue}for(const ce of te.value.entries){if(W.length>=Uu){S=!0;break}W.push(ce),E.push(ce),ce.type==="DIRECTORY"&&!M.has(ce.path)&&(M.add(ce.path),le.push(ce.path))}if(S)break}if(E.length>0&&P(te=>[...te,...E]),pe>0&&F(!0),S){G(!0);break}}}catch(W){if(z())return;D(W instanceof Error?W.message:"Indexing failed")}finally{z()||X(!1)}})()},[s,f,n,c,a]),xe=r.useCallback(ne=>{if(ne.type!=="DIRECTORY")return;const z=ct(ne.path),W=!v.current.has(z),pe=g[z],M=W&&(!pe||!!pe.error)&&!_.current.has(z),le=new Set(v.current);W?le.add(z):le.delete(z),v.current=le,m(le),l?.(le),M&&(_.current.add(z),K(ne.path).finally(()=>_.current.delete(z)))},[g,K,l]),je=r.useCallback(ne=>{if(ne.type==="DIRECTORY"){xe(ne);return}o===void 0&&j(ne.path),i?.(ne)},[o,i,xe]),ye=r.useCallback(()=>{c.removeQueries({queryKey:["listFiles",f]}),h({}),m(new Set),v.current=new Set,l?.(new Set),_.current=new Set,j(void 0),b.current=!1,O.current+=1,B.current+=1,P([]),X(!1),D(void 0),G(!1),F(!1),K(a).then(ne=>{u&&ne&&J(ne)})},[f,u,K,l,J,c,a]),we=g[ct(a)];return{rows:r.useMemo(()=>{const ne=[],z=(W,pe)=>{const M=g[ct(W)];if(M)for(const le of M.entries){const S=le.type==="DIRECTORY",ae=ct(le.path),oe=S&&y.has(ae),E=g[ae];ne.push({entry:le,depth:pe,isDirectory:S,isExpanded:oe,isLoading:oe&&(E?.loading??!1),hasError:!!E?.error}),oe&&z(le.path,pe+1)}};return z(a,0),ne},[g,y,a]),isRootLoading:we?.loading??!0,rootError:we?.error,selectedPath:U,toggle:xe,select:je,refresh:ye,index:$,isIndexing:Z,indexError:ee,indexTruncated:T,indexPartial:H,ensureIndex:N}}const Zu=[{width:"58%",height:14},{width:"44%",height:14,indent:"var(--spacing-kiro-md)"},{width:"66%",height:14,indent:"var(--spacing-kiro-md)"},{width:"50%",height:14,indent:"var(--spacing-kiro-xl)"},{width:"38%",height:14,indent:"var(--spacing-kiro-md)"},{width:"70%",height:14},{width:"48%",height:14,indent:"var(--spacing-kiro-md)"},{width:"56%",height:14,indent:"var(--spacing-kiro-md)"}];function ef(s){const e=dt.c(133),{api:a,rootPath:n,includeHidden:o,selectedPath:i,onSelect:d,showSearch:l,headerAction:u,initialExpandedPaths:c,onExpandedPathsChange:f,autoExpandRoot:g,onStatusChange:h,emptyMessage:y}=s,m=n===void 0?"":n,v=o===void 0?!1:o,_=l===void 0?!0:l,re=g===void 0?!1:g,[j,U]=r.useState(""),[$,P]=r.useState(),[Z,X]=r.useState(null),ee=fr(),D=r.useRef(null);let T;e[0]!==re||e[1]!==v||e[2]!==c||e[3]!==f||e[4]!==d||e[5]!==m||e[6]!==i?(T={rootPath:m,includeHidden:v,selectedPath:i,onSelect:d,initialExpandedPaths:c,onExpandedPathsChange:f,autoExpandRoot:re},e[0]=re,e[1]=v,e[2]=c,e[3]=f,e[4]=d,e[5]=m,e[6]=i,e[7]=T):T=e[7];const{rows:G,isRootLoading:H,rootError:F,selectedPath:b,toggle:O,select:B,refresh:q,index:K,isIndexing:J,indexError:N,indexTruncated:xe,indexPartial:je,ensureIndex:ye}=Ju(a,T);let we;e[8]!==j?(we=j.trim(),e[8]=j,e[9]=we):we=e[9];const I=we.length>0,ne=H?"loading":F?"error":G.length===0?"empty":"ready";let z,W;
6e[10]!==h||e[11]!==ne?(z=()=>{h?.(ne)},W=[ne,h],e[10]=h,e[11]=ne,e[12]=z,e[13]=W):(z=e[12],W=e[13]),r.useEffect(z,W);const pe=_&&(I||G.length>0);let M,le;e[14]!==ye||e[15]!==I?(le=()=>{I&&ye()},M=[I,ye],e[14]=ye,e[15]=I,e[16]=M,e[17]=le):(M=e[16],le=e[17]),r.useEffect(le,M);let S,ae;e[18]!==$?(S=()=>{if(!$)return;D.current?.querySelector(`[data-path="${CSS.escape($)}"]`)?.focus()},ae=[$],e[18]=$,e[19]=S,e[20]=ae):(S=e[19],ae=e[20]),r.useEffect(S,ae);let oe;e[21]!==K||e[22]!==j||e[23]!==m||e[24]!==G||e[25]!==I?(oe=I?Xu(K,j,m):{rows:G,truncated:!1},e[21]=K,e[22]=j,e[23]=m,e[24]=G,e[25]=I,e[26]=oe):oe=e[26];const{rows:E,truncated:te}=oe;let ce;e[27]!==B?(ce=L=>{P(L.entry.path),B(L.entry)},e[27]=B,e[28]=ce):ce=e[28];const Te=ce;let ge;e[29]!==O?(ge=L=>{P(L.entry.path),O(L.entry)},e[29]=O,e[30]=ge):ge=e[30];const Ce=ge;let Ne;e[31]===Symbol.for("react.memo_cache_sentinel")?(Ne=(L,Q)=>{L.preventDefault(),X({x:L.clientX,y:L.clientY,entry:Q.entry})},e[31]=Ne):Ne=e[31];const Ee=Ne;let ve;e[32]!==ee?(ve=L=>{ee.copy(L.path),Vt.show({message:"Copied file path",autoClose:1500,withBorder:!0}),X(null)},e[32]=ee,e[33]=ve):ve=e[33];const V=ve;let Ie;e[34]!==$||e[35]!==O||e[36]!==E?(Ie=L=>{if(!(L.target instanceof HTMLElement)||L.target.getAttribute("role")!=="treeitem"||E.length===0)return;const Q=Math.max(0,E.findIndex(se=>se.entry.path===$)),me=E[Q];e:switch(L.key){case"ArrowDown":{L.preventDefault();const se=E[Math.min(E.length-1,Q+1)];se&&P(se.entry.path);break e}case"ArrowUp":{L.preventDefault();const se=E[Math.max(0,Q-1)];se&&P(se.entry.path);break e}case"ArrowRight":{L.preventDefault(),me?.isDirectory&&!me.isExpanded&&O(me.entry);break e}case"ArrowLeft":{L.preventDefault(),me?.isDirectory&&me.isExpanded&&O(me.entry);break e}case"ContextMenu":case"F10":{if(L.key==="F10"&&!L.shiftKey||(L.preventDefault(),!me))break e;const se=L.target.getBoundingClientRect();X({x:se.left,y:se.bottom,entry:me.entry});break e}}},e[34]=$,e[35]=O,e[36]=E,e[37]=Ie):Ie=e[37];const Me=Ie,be=i??b;let Xe;e[38]!==$||e[39]!==E?(Xe=$&&E.some(L=>L.entry.path===$)?$:E[0]?.entry.path,e[38]=$,e[39]=E,e[40]=Xe):Xe=e[40];const Fe=Xe;let de;e:{if(!be){let Se;e[41]===Symbol.for("react.memo_cache_sentinel")?(Se={level:-1,prefix:""},e[41]=Se):Se=e[41],de=Se;break e}let L;if(e[42]!==be||e[43]!==E){let Se;e[45]!==be?(Se=qe=>qe.entry.path===be,e[45]=be,e[46]=Se):Se=e[46],L=E.find(Se),e[42]=be,e[43]=E,e[44]=L}else L=e[44];const Q=L;if(!Q){let Se;e[47]===Symbol.for("react.memo_cache_sentinel")?(Se={level:-1,prefix:""},e[47]=Se):Se=e[47],de=Se;break e}if(Q.isDirectory){const Se=`${be}/`;let qe;e[48]!==Q.depth||e[49]!==Se?(qe={level:Q.depth,prefix:Se},e[48]=Q.depth,e[49]=Se,e[50]=qe):qe=e[50],de=qe;break e}if(Q.depth===0){let Se;e[51]===Symbol.for("react.memo_cache_sentinel")?(Se={level:-1,prefix:""},e[51]=Se):Se=e[51],de=Se;break e}let me;if(e[52]!==be){const Se=be.lastIndexOf("/");me=Se===-1?"":`${be.slice(0,Se)}/`,e[52]=be,e[53]=me}else me=e[53];const se=me,Le=Q.depth-1;let We;
6e[54]!==se||e[55]!==Le?(We={level:Le,prefix:se},e[54]=se,e[55]=Le,e[56]=We):We=e[56],de=We}const Ke=de,et=r.useRef(void 0);let rt;e[57]!==be?(rt=()=>{if(!be){et.current=void 0;return}if(et.current===be)return;const L=D.current?.querySelector(`[data-path="${CSS.escape(be)}"]`);L&&(et.current=be,L.scrollIntoView?.({block:"nearest"}))},e[57]=be,e[58]=rt):rt=e[58];let ot;e[59]!==be||e[60]!==E?(ot=[be,E],e[59]=be,e[60]=E,e[61]=ot):ot=e[61],r.useEffect(rt,ot);let C;if(!I&&H){let L;e[62]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(Ca,{lines:Zu,label:"Loading files"}),e[62]=L):L=e[62],C=L}else if(!I&&F){let L,Q;e[63]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(Y,{id:"warning",size:"xl",c:"var(--color-feedback-warning)"}),Q=t.jsx("div",{className:Ae.errorStateText,children:"Unable to load files."}),e[63]=L,e[64]=Q):(L=e[63],Q=e[64]);let me,se;e[65]===Symbol.for("react.memo_cache_sentinel")?(me=t.jsx(Y,{id:"refresh",size:"xs"}),se=t.jsx("span",{children:"Retry"}),e[65]=me,e[66]=se):(me=e[65],se=e[66]);let Le;e[67]!==q?(Le=t.jsxs("div",{className:Ae.errorState,children:[L,Q,t.jsxs(yt,{className:Ae.retryButton,onClick:q,"aria-label":"Retry loading files",children:[me,se]})]}),e[67]=q,e[68]=Le):Le=e[68],C=Le}else if(E.length===0){let L;e[69]!==y||e[70]!==J||e[71]!==I?(L=I&&J?null:t.jsx("div",{className:Ae.message,children:I?"No matching files":y??"No files in this workspace yet"}),e[69]=y,e[70]=J,e[71]=I,e[72]=L):L=e[72],C=L}else{let L;if(e[73]!==Ke||e[74]!==be||e[75]!==Fe||e[76]!==Te||e[77]!==Ce||e[78]!==j||e[79]!==E){let Q;e[81]!==Ke||e[82]!==be||e[83]!==Fe||e[84]!==Te||e[85]!==Ce||e[86]!==j?(Q=me=>t.jsx(qu,{row:me,selected:be===me.entry.path,tabbable:Fe===me.entry.path,query:j.trim()||void 0,activeGuideLevel:Ke.level,activeGuidePrefix:Ke.prefix,onSelect:Te,onToggleTwistie:Ce,onContextMenu:Ee},me.entry.path),e[81]=Ke,e[82]=be,e[83]=Fe,e[84]=Te,e[85]=Ce,e[86]=j,e[87]=Q):Q=e[87],L=E.map(Q),e[73]=Ke,e[74]=be,e[75]=Fe,e[76]=Te,e[77]=Ce,e[78]=j,e[79]=E,e[80]=L}else L=e[80];C=L}let x;e[88]!==pe||e[89]!==u||e[90]!==j?(x=pe||u?t.jsxs("div",{className:Ae.header,children:[pe?t.jsx("div",{className:Ae.search,children:t.jsx(mr,{variant:"search","data-variant":"search",placeholder:"Search",value:j,onChange:L=>U(L.currentTarget.value),"aria-label":"Search files",leftSection:t.jsx(Y,{id:"search",size:"xs"}),rightSectionPointerEvents:"all",rightSection:j?t.jsx(ze,{variant:"subtle",size:"xs","aria-label":"Clear search",onClick:()=>U(""),children:t.jsx(Y,{id:"close",size:"xs"})}):null})}):null,u?t.jsx("div",{className:Ae.headerAction,children:u}):null]}):null,e[88]=pe,e[89]=u,e[90]=j,e[91]=x):x=e[91];let p;e[92]!==K||e[93]!==J||e[94]!==I?(p=I&&J?t.jsxs("div",{className:Ae.message,children:["Indexing sandbox⦠(",K.length," files)"]}):null,e[92]=K,e[93]=J,e[94]=I,e[95]=p):p=e[95];let fe;e[96]!==N||e[97]!==I?(fe=I&&N?t.jsx("div",{className:`${Ae.message} ${Ae.errorMessage}`,children:N}):null,e[96]=N,e[97]=I,e[98]=fe):fe=e[98];let ue;e[99]!==xe||e[100]!==I?(ue=I&&xe?t.jsx("div",{className:Ae.message,children:"Index limited; some matches may be hidden."}):null,e[99]=xe,e[100]=I,e[101]=ue):ue=e[101];let Re;e[102]!==je||e[103]!==I?(Re=I&&je?t.jsx("div",{className:Ae.message,children:"Some folders could not be read; results may be incomplete."}):null,e[102]=je,e[103]=I,e[104]=Re):Re=e[104];let _e;e[105]!==te||e[106]!==I?(_e=I&&te?t.jsxs("div",{className:Ae.message,children:["Showing the first ",Cs," matches; refine your search to narrow results."]}):null,e[105]=te,e[106]=I,e[107]=_e):_e=e[107];let $e;e[108]!==C||e[109]!==p||e[110]!==fe||e[111]!==ue||e[112]!==Re||e[113]!==_e?($e=t.jsxs("div",{className:Ae.rows,role:"presentation",children:[p,fe,ue,Re,_e,C]}),e[108]=C,e[109]=p,e[110]=fe,e[111]=ue,e[112]=Re,e[113]=_e,e[114]=$e):$e=e[114];const He=Z!==null;let it;e[115]===Symbol.for("react.memo_cache_sentinel")?(it=()=>X(null),e[115]=it):it=e[115];const lt=Z?.x??0,Je=Z?.y??0;let Ge;e[116]!==lt||e[117]!==Je?(Ge=t.jsx(Ft.Target,{children:t.jsx("div",{"aria-hidden":"true",style:{position:"fixed",left:lt,top:Je,width:0,height:0}})}),e[116]=lt,e[117]=Je,e[118]=Ge):Ge=e[118];let Ve;e[119]!==Z||e[120]!==V?(Ve=Z?t.jsx(Ft.Item,{leftSection:t.jsx(Y,{id:"copy",size:"xs"}),onClick:()=>V(Z.entry),children:"Copy file path"}):null,e[119]=Z,e[120]=V,e[121]=Ve):Ve=e[121];let Oe;e[122]!==Ve?(Oe=t.jsx(Ft.Dropdown,{children:Ve}),e[122]=Ve,e[123]=Oe):Oe=e[123];let Ze;e[124]!==He||e[125]!==Ge||e[126]!==Oe?(Ze=t.jsxs(Ft,{opened:He,onClose:it,position:"bottom-start",withinPortal:!0,shadow:"md",width:200,children:[Ge,Oe]}),e[124]=He,e[125]=Ge,e[126]=Oe,e[127]=Ze):Ze=e[127];let tt;
6return e[128]!==Me||e[129]!==x||e[130]!==$e||e[131]!==Ze?(tt=t.jsxs("div",{className:Ae.tree,role:"tree","aria-label":"File explorer",tabIndex:-1,ref:D,onKeyDown:Me,children:[x,$e,Ze]}),e[128]=Me,e[129]=x,e[130]=$e,e[131]=Ze,e[132]=tt):tt=e[132],tt}const Oa=".kiro/artifacts";function tf(s){const e=dt.c(12),{api:a}=s,{activeTab:n,selectedFile:o,setSelectedFile:i,expandedPaths:d,setExpandedPaths:l,setTreeStatus:u}=Ts(),c=n==="artifacts"?Oa:void 0,f=o?.path;let g;e[0]!==i?(g=m=>i(m),e[0]=i,e[1]=g):g=e[1];const h=n==="artifacts"?"No artifacts in this workspace yet":void 0;let y;return e[2]!==n||e[3]!==a||e[4]!==d||e[5]!==c||e[6]!==l||e[7]!==u||e[8]!==f||e[9]!==g||e[10]!==h?(y=t.jsx(ef,{api:a,rootPath:c,selectedPath:f,onSelect:g,showSearch:!1,initialExpandedPaths:d,onExpandedPathsChange:l,onStatusChange:u,autoExpandRoot:!0,emptyMessage:h},n),e[2]=n,e[3]=a,e[4]=d,e[5]=c,e[6]=l,e[7]=u,e[8]=f,e[9]=g,e[10]=h,e[11]=y):y=e[11],y}const sf="File or directory not found";function nf(s){return!s.path||!s.name||!s.type?null:{path:s.path,name:s.name,type:s.type,sizeBytes:s.sizeBytes,lastModified:s.lastModified}}function af({spaceId:s}){return{async listFiles(e){const a=e.path&&e.path!=="."?e.path:void 0,n={spaceId:s,path:a};let o;try{o=await qn().send(new pr(n))}catch(i){if(i instanceof hr&&ao(i,sf))return{entries:[],path:a??"",truncated:!1};throw i}return{entries:(o.items??[]).map(nf).filter(i=>i!==null),path:a??"",truncated:o.truncated??!1,totalCount:o.totalCount}}}}const rf="_panelMotion_6d6w8_2",of="_panelMotionEmbedded_6d6w8_9",lf="_panel_6d6w8_2",cf="_header_6d6w8_28",df="_titleRow_6d6w8_40",uf="_titleBlock_6d6w8_47",ff="_name_6d6w8_56",mf="_controls_6d6w8_78",pf="_pendingLabel_6d6w8_89",hf="_stopControl_6d6w8_95",gf="_closeButton_6d6w8_99",wf="_sessionLink_6d6w8_103",xf="_stepCount_6d6w8_117",yf="_elapsed_6d6w8_126",bf="_resizeSurface_6d6w8_143",_f="_treeContainer_6d6w8_150",vf="_noteCard_6d6w8_226",Sf="_noteText_6d6w8_237",kf="_hint_6d6w8_250",jf="_metadataDetails_6d6w8_256",Cf="_metadataTitle_6d6w8_263",Nf="_metadataGrid_6d6w8_270",Rf="_metadataNote_6d6w8_296",Pe={panelMotion:rf,panelMotionEmbedded:of,panel:lf,header:cf,titleRow:df,titleBlock:uf,name:ff,controls:mf,pendingLabel:pf,stopControl:hf,closeButton:gf,sessionLink:wf,stepCount:xf,elapsed:yf,resizeSurface:bf,treeContainer:_f,noteCard:vf,noteText:Sf,hint:kf,metadataDetails:jf,metadataTitle:Cf,metadataGrid:Nf,metadataNote:Rf},wn=45,gs=96,xn=220;function $f(s){const{tree:e,sessions:a,initialSelectedNodePathKey:n,initialSelectedNodeId:o,selectInitialActiveStep:i,allowSelectionWithoutSession:d}=s;if(n!==void 0&&e.rows.some(c=>c.nodePathKey===n))return n;if(o!==void 0)return wo(e,o);if(!i)return null;if(d){const c=e.rows.filter(h=>h.type==="step"),f=c.find(h=>h.status==="running");if(f)return f.nodePathKey;const g=c.find(h=>h.status==="paused");return g?g.nodePathKey:[...c].reverse().find(h=>h.status!=="pending")?.nodePathKey??null}const l=e.rows.find(c=>c.status==="running"&&a.has(c.nodePathKey));if(l)return l.nodePathKey;const u=e.rows.find(c=>c.status==="paused"&&a.has(c.nodePathKey));return u?u.nodePathKey:e.firstActiveRowKey}function Tf({spaceId:s,workflowId:e,initialSelectedNodePathKey:a,initialSelectedNodeId:n,routingSessionId:o,sessionLabel:i,fallbackName:d,onClose:l,widthPercent:u,isResizing:c,embedded:f=!1,detailOnly:g=!1,selectInitialActiveStep:h=!0,headerLeading:y}){const{data:m,error:v}=ro({spaceId:s,workflowId:e}),{sessionsByNodePathKey:_,sessionListFailed:re}=Cd({spaceId:s,workflowId:e,tree:m}),j=oo(e),U=r.useRef(m);U.current=m;const $=r.useRef(_);$.current=_;const[P,Z]=r.useState(null),[X,ee]=r.useState(!1),[D,T]=r.useState(null),[G,H]=r.useState(wn),F=D??G,b=r.useRef(null),O=r.useRef(null);r.useLayoutEffect(()=>{const de=b.current;if(de){if(de.style.setProperty("--workflow-tree-max-height",`${String(wn)}%`),de.style.setProperty("--workflow-tree-min-height",`${String(gs)}px`),de.style.setProperty("--workflow-step-chat-min-height",`${String(xn)}px`),D===null){de.style.removeProperty("--workflow-tree-height");return}de.style.setProperty("--workflow-tree-height",`${String(D)}%`)}},[D]);const B=m!==void 0;if(r.useLayoutEffect(()=>{const de=b.current,Ke=O.current;if(D!==null||!de||!Ke)return;const et=()=>{const ot=de.getBoundingClientRect().height;if(ot<=0)return;
6const C=Ke.getBoundingClientRect().height/ot*100,x=gs/ot*100;H(Math.max(C,x))};et();const rt=new ResizeObserver(et);return rt.observe(Ke),rt.observe(de),()=>{rt.disconnect()}},[D,B]),!X&&m){const de=$f({tree:m,sessions:_,initialSelectedNodePathKey:a,initialSelectedNodeId:n,selectInitialActiveStep:h,allowSelectionWithoutSession:g});de!==null&&(ee(!0),Z(de))}const q=r.useCallback(()=>{const de=U.current?io({rows:U.current.rows,sessions:$.current}):void 0;de&&(ee(!0),Z(de.nodePathKey))},[]),K=lo({spaceId:s}),J=co({spaceId:s,onStillPaused:q}),N=uo({spaceId:s}),xe=fo({spaceId:s}),[je,ye]=r.useState(!1),we=v!==null&&mo(v),I=m?.status,ne=m?.workflowName??d??e,z=I!==void 0&&Xt(I),W=Is(I==="running"),pe=m&&(I==="running"||I==="paused")?po({createdAt:m.createdAt,status:I,rows:m.rows,nowMs:W}):null,M=pe===null?null:Ps(pe),le=I==="completed"&&m?Es({createdAt:m.createdAt,endedAt:m.endedAt,rows:m.rows}):null,S=z&&(m?.rows.some(de=>de.status==="failed"||de.status==="aborted")??!1),ae=m!==void 0&&I==="running",oe=m!==void 0&&I==="paused",E=m!==void 0&&(I==="running"||I==="paused"),te=j?.control==="pause",ce=r.useCallback(de=>{ee(!0),Z(de.nodePathKey)},[]),Te=r.useCallback(()=>{ye(!1),N.mutate({workflowId:e})},[N,e]),ge=P!==null?m?.rows.find(de=>de.nodePathKey===P):void 0,Ce=we?d??e:ne,Ne=ge?.iterationSessions,Ee=(de,Ke)=>_.get(de)??Ke,ve=(Ne??[]).filter(de=>Ee(de.nodePathKey,de.sessionId)!==void 0),V=ve.findIndex(de=>de.nodePathKey===P),Ie=Ne!==void 0&&Ne.length>0,Me=ge?Ee(ge.nodePathKey,ge.sessionId):void 0,be=ge?.status??"pending",Xe=ge!==void 0&&Me!==void 0,Fe=ge?[ge.nodeId,ge.agentName,Ie&&V>=0?`${String(V+1)}/${String(ve.length)}`:void 0].filter(Boolean).join(" · "):"";return t.jsx(Tt.div,{className:`${Pe.panelMotion}${f?` ${Pe.panelMotionEmbedded}`:""}`,initial:f?!1:{width:0,opacity:0},animate:{width:f?"100%":`${String(u)}%`,opacity:1},transition:c?{width:{duration:0},opacity:{duration:.3,ease:[.25,.1,.25,1]}}:{duration:.3,ease:[.25,.1,.25,1]},children:t.jsxs("div",{className:Pe.panel,role:"complementary","aria-label":"Workflow panel","data-embedded":f||void 0,children:[t.jsx("div",{className:Pe.header,children:t.jsxs("div",{className:Pe.titleRow,children:[y,we?t.jsx(qt,{status:"aborted"}):I?t.jsx(qt,{status:I}):t.jsx(bt,{size:"xs","aria-label":"Loading workflow status"}),t.jsx("div",{className:Pe.titleBlock,title:Ce,children:t.jsx(k,{component:"span",className:Pe.name,children:Ce})}),!we&&!g?t.jsx(Be,{label:"Open parent session",position:"bottom",children:t.jsxs(Nn,{component:gr,to:`/session/${s}`,className:Pe.sessionLink,children:["Created by session",i!==void 0?` ${i}`:""]})}):null,!we&&le?t.jsx(k,{component:"span",className:Pe.stepCount,children:le}):null,!we&&M?t.jsx(k,{component:"span",className:Pe.elapsed,children:M}):null,!we&&m?t.jsxs("div",{className:Pe.controls,children:[ae?te?t.jsx(Be,{label:"Pausing",position:"bottom",children:t.jsx(ze,{variant:"transparent",size:"sm",disabled:!0,"aria-label":"Pausing",children:t.jsx(Y,{id:"debug-pause",size:"xs"})})}):t.jsx(Be,{label:"Pause workflow",position:"bottom",children:t.jsx(ze,{variant:"transparent",size:"sm",onClick:()=>{K.mutate({workflowId:e})},"aria-label":"Pause workflow",children:t.jsx(Y,{id:"debug-pause",size:"xs"})})}):null,te?t.jsx(k,{component:"span",className:Pe.pendingLabel,children:"Pausing"}):null,oe?t.jsx(Be,{label:"Resume workflow",position:"bottom",children:t.jsx(ze,{variant:"transparent",size:"sm",onClick:()=>{J.mutate({workflowId:e})},"aria-label":"Resume workflow",children:t.jsx(Y,{id:"play",size:"xs"})})}):null,E?t.jsx(Be,{label:"Stop workflow",position:"bottom",children:t.jsx(ze,{variant:"transparent",size:"sm",className:Pe.stopControl,onClick:()=>{ye(!0)},"aria-label":"Stop workflow",children:t.jsx(Y,{id:"primitive-square",size:"xs"})})}):null,S?t.jsx(Be,{label:"Retry workflow",position:"bottom",children:t.jsx(ze,{variant:"transparent",size:"sm",onClick:()=>{xe.mutate({workflowId:e})},"aria-label":"Retry workflow",children:t.jsx(Y,{id:"debug-rerun",size:"xs"})})}):null]}):null,f?null:t.jsx(ze,{variant:"transparent",size:"sm",className:Pe.closeButton,onClick:l,"aria-label":"Close workflow panel",children:t.jsx(Y,{id:"close",size:"xs"})})]})}),we?t.jsxs("div",{className:Pe.noteCard,"data-testid":"workflow-panel-deleted",children:[t.jsx(Y,{id:"info",size:"sm"}),t.jsx(k,{component:"span",className:Pe.noteText,children:"This workflow run was deleted."})]}):t.jsxs(t.Fragment,{children:[re?t.jsxs("div",{className:Pe.noteCard,"data-testid":"workflow-panel-session-list-error",children:[t.jsx(Y,{id:"info",size:"sm"}),t.jsx(k,{component:"span",className:Pe.noteText,children:"Some step conversations couldn't be loaded, so steps may be missing their session."})]}):null,null,t.jsxs("div",{className:Pe.resizeSurface,ref:b,"data-testid":"workflow-resize-surface",children:[m?t.jsx("div",{className:Pe.tree
6Container,ref:O,"data-resizable":Xe||void 0,"data-auto-height":D===null||void 0,"data-testid":g?"workflow-detail-tree":void 0,children:t.jsx(ho,{tree:m,workflowId:e,sessionsByNodePathKey:_,selectedNodePathKey:P,onRowClick:ce,allowSelectionWithoutSession:g})}):null,m&&Xe?t.jsx(da,{orientation:"vertical",position:F,onPositionChange:T,minLeftWidth:gs,minRightWidth:xn,containerRef:b,ariaLabel:"Resize workflow tree and step conversation",showGrip:!0}):null,Xe&&ge&&Me!==void 0?t.jsx(Xd,{spaceId:s,sessionId:Me,routingSessionId:o,headerLabel:Fe,stepStatus:be},Me):g&&!ge&&m?t.jsxs("div",{className:Pe.metadataDetails,"data-testid":"workflow-run-details",children:[t.jsx(k,{className:Pe.metadataTitle,children:"Workflow details"}),t.jsx("dl",{className:Pe.metadataGrid,children:t.jsxs("div",{children:[t.jsx("dt",{children:"Session"}),t.jsx("dd",{children:i??s})]})}),t.jsx(k,{className:Pe.metadataNote,children:"Select an agent step in the workflow tree to view its session."})]}):g&&ge?t.jsx(k,{className:Pe.hint,children:"This step has no conversation yet."}):g?null:t.jsx(k,{className:Pe.hint,children:"Select a step to open its session."})]})]}),t.jsx(go,{opened:je,workflowName:ne,onConfirm:Te,onCancel:()=>{ye(!1)}})]})})}const Wa="kiro.workflows.sessionListCollapsed";function If(){return xo(Wa)==="true"}function Ef(s){yo(Wa,String(s))}const Pf="_sessionWorkflowsLayout_1cpt9_1",Af="_sessionWorkflowsList_1cpt9_20",Lf="_sessionWorkflowsListBody_1cpt9_24",Mf="_sessionWorkflowItem_1cpt9_53",Df="_sessionWorkflowName_1cpt9_77",Ff="_sessionWorkflowStepCount_1cpt9_87",Of="_sessionWorkflowMetadataFull_1cpt9_99",Wf="_sessionWorkflowMetadataCompact_1cpt9_106",Bf="_sessionWorkflowDetail_1cpt9_132",zf="_sessionWorkflowPlaceholderColumn_1cpt9_140",Kf="_sessionWorkflowDetailToolbar_1cpt9_147",Gf="_sessionWorkflowPlaceholder_1cpt9_140",Hf="_sessionWorkflowsEmpty_1cpt9_172",nt={sessionWorkflowsLayout:Pf,sessionWorkflowsList:Af,sessionWorkflowsListBody:Lf,sessionWorkflowItem:Mf,sessionWorkflowName:Df,sessionWorkflowStepCount:Ff,sessionWorkflowMetadataFull:Of,sessionWorkflowMetadataCompact:Wf,sessionWorkflowDetail:Bf,sessionWorkflowPlaceholderColumn:zf,sessionWorkflowDetailToolbar:Kf,sessionWorkflowPlaceholder:Gf,sessionWorkflowsEmpty:Hf},yn="session-workflows-list";function qf(s){const e=dt.c(36),{spaceId:a,workflows:n,panelRequest:o,routingSessionId:i,sessionLabel:d,onSelectWorkflow:l,onClosePanel:u}=s;let c;e[0]!==o?(c=()=>o?.collapseRunList!==void 0?o.collapseRunList:If(),e[0]=o,e[1]=c):c=e[1];const[f,g]=r.useState(c),[h,y]=r.useState(!1);let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=b=>{g(b),Ef(b)},e[2]=m):m=e[2];let v;e[3]!==f||e[4]!==h?(v={collapsed:f,onCollapsedChange:m,drawerOpen:h,onDrawerOpenChange:y},e[3]=f,e[4]=h,e[5]=v):v=e[5];const _=_a(v),{closeDrawer:re}=_,[j,U]=r.useState(o);o!==j&&(U(o),o?.collapseRunList!==void 0&&g(o.collapseRunList));let $;e[6]!==n?($=n.some(Uf),e[6]=n,e[7]=$):$=e[7];const P=Is($),Z=Sa(n,P);let X;e[8]!==f||e[9]!==_?(X=f?t.jsx(Ss,{controller:_,controlSubject:"run list",controls:yn}):void 0,e[8]=f,e[9]=_,e[10]=X):X=e[10];const ee=X;let D;e[11]!==re||e[12]!==P||e[13]!==l||e[14]!==o?.workflowId||e[15]!==Z||e[16]!==a||e[17]!==n?(D=n.length>0?n.map(b=>{const O=o?.workflowId===b.workflowId,B=b.status,q=B==="paused"?Z.get(b.workflowId)??P:P,K=B==="completed"||B==="running"||B==="paused"?On({createdAt:b.createdAt,endedAt:b.endedAt,status:B,nowMs:q}):null,J=K===null?null:Ps(K),N=B==="completed"?Es({createdAt:b.createdAt,endedAt:b.endedAt}):J;return t.jsxs("button",{type:"button",className:nt.sessionWorkflowItem,"aria-current":O?"true":void 0,"aria-label":[b.name,N].filter(Boolean).join(", "),onClick:()=>{l({spaceId:a,workflowId:b.workflowId,...b.selectedNodePathKey?{selectNodePathKey:b.selectedNodePathKey}:{}}),re()},children:[B?t.jsx(qt,{status:B}):t.jsx(bt,{size:"xs","aria-label":"Loading workflow status"}),t.jsx(k,{component:"span",className:nt.sessionWorkflowName,children:b.name}),N?t.jsxs(k,{component:"span",className:nt.sessionWorkflowStepCount,children:[t.jsx("span",{className:nt.sessionWorkflowMetadataFull,children:N}),J?t.jsx("span",{className:nt.sessionWorkflowMetadataCompact,children:J}):null]}):null]},b.workflowId)}):t.jsx(k,{className:nt.sessionWorkflowsEmpty,children:"No workflows are available for this session."}),e[11]=re,e[12]=P,e[13]=l,e[14]=o?.workflowId,e[15]=Z,e[16]=a,e[17]=n,e[18]=D):D=e[18];let T;e[19]!==D?(T=t.jsx("div",{className:nt.sessionWorkflowsListBody,children:D}),e[19]=D,e[20]=T):T=e[20];let G;e[21]!==_||e[22]!==T?(G=t.jsx(ba,{controller:_,id:yn,label:"Runs",controlSubject:"run list",dockedClassName:nt.sessionWorkflowsList,"data-testid":"session-workflows-list",children:T}),e[21]=_,e[22]=T,e[23]=G):G=e[23];let H;e[24]!==u||e[25]!==o||e[26]!==i||e[27]!==d||e[28]!==a||e[29]!==ee||e[30]!==n?(H=t.jsx("div",{className:nt.sessionWorkflowDetail,children:o?t.jsx(Tf,{spaceId:a,workflowId:o.workflowId,initialSelectedNodePathKey:o.selectNodePathKey,initialSelectedNodeId:o.selectNodeId,routingSessionId:i,sessionLabel:d,fallbackName:n.find(b=>b.workflowId===o.workflowId)?.name,onClose:u,widthPercent:100,isResizing:!1,embedded:!0,detailOnly:!0,headerLeading:ee},JSON.stringify([o.workflowId,o.selectNodePathKey,o.selectNodeId])):t.jsxs("div",{className:nt.sessionWorkflowPlaceholderColumn,children:[ee?t.jsx("div",{className:nt.sessionWorkflowDetailToolbar,children:ee}):null,t.jsxs("div",{className:nt.sessionWorkflowPlaceholder,children:[t.jsx(Y,{id:"list-tree",size:"lg"}),t.jsx(k,{children:"Select a workflow to inspect its steps."})]})]})}),e[24]=u,e[25]=o,e[26]=i,e[27]=d,e[28]=a,e[29]=ee,e[30]=n,e[31]=H):H=e[31];let F;return e[32]!==f||e[33]!==G||e[34]!==H?(F=t.jsxs("div",{className:nt.sessionWorkflowsLayout,"data-collapsed":f,children:[G,H]}),e[32]=f,e[33]=G,e[34]=H,e[35]=F):F=e[35],F}function Uf(s){return s.status==="running"}const Vf="_banner_18g6g_1",Qf="_icon_18g6g_11",Yf="_text_18g6g_16",ws={banner:Vf,icon:Qf,text:Yf};function Xf(s){const e=dt.c(8),{visible:a,onGiveFeedback:n,onDismiss:o}=s;if(!a)return null;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsxs(mt,{gap:"xs",wrap:"nowrap",children:[t.jsx(Y,{id:"feedback",size:"sm",className:ws.icon}),t.jsx(k,{size:"sm",className:ws.text,children:"How was this execution?"})]}),e[0]=i):i=e[0];let d;e[1]!==n?(d=t.jsx(wr,{size:"xs",variant:"light",onClick:n,children:"Give feedback"}),e[1]=n,e[2]=d):d=e[2];let l;e[3]!==o?(l=t.jsx(An,{size:"sm",onClick:o,"aria-label":"Dismiss feedback banner"}),e[3]=o,e[4]=l):l=e[4];let u;return e[5]!==d||e[6]!==l?(u=t.jsx(w,{className:ws.banner,children:t.jsxs(mt,{gap:"sm",justify:"space-between",wrap:"nowrap",children:[i,t.jsxs(mt,{gap:"xs",wrap:"nowrap",children:[d,l]})]})}),e[5]=d,e[6]=l,e[7]=u):u=e[7],u}const Jf="_banner_1fhpl_1",Zf="_header_1fhpl_13",em="_body_1fhpl_19",tm="_icon_1fhpl_23",sm="_title_1fhpl_28",nm="_description_1fhpl_34",am="_error_1fhpl_39",rm="_reconnectButton_1fhpl_44",wt={banner:Jf,header:Zf,body:em,icon:tm,title:sm,description:nm,error:am,reconnectButton:rm};function om(s){const e=dt.c(33),{liveReauth:a}=s,n=bs(ia),{providers:o}=hi(),{initiateAuthAndRedirect:i,isPending:d}=ni("MIDWAY"),[l,u]=r.useState(!1),[c,f]=r.useState(!1),g=o.find(im),h=g?.status,y=h===Vs.EXPIRED,m=r.useRef(null);let v,_;if(e[0]!==a?(v=()=>{a&&!m.current&&(f(!1),u(!1)),m.current=a},_=[a],e[0]=a,e[1]=v,e[2]=_):(v=e[1],_=e[2]),r.useEffect(v,_),r.useEffect(()=>{h===Vs.CONNECTED&&!a&&(f(!1),u(!1))},[h,a]),!(n&&!c&&(a!==null||y)))return null;const j=oi,U=a?.reason??ai(g)??ri;let $;e[3]!==j||e[4]!==U?($=j(U),e[3]=j,e[4]=U,e[5]=$):$=e[5];const{title:P,sessionBody:Z}=$;let X;e[6]!==i?(X=async()=>{u(!1);try{await i()}catch{u(!0)}},e[6]=i,e[7]=X):X=e[7];const ee=X;let D;e[8]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(Y,{id:"warning",size:"sm",className:wt.icon,"aria-hidden":"true"}),e[8]=D):D=e[8];let T;e[9]!==P?(T=t.jsxs(mt,{gap:"xs",wrap:"nowrap",children:[D,t.jsx(k,{size:"sm",className:wt.title,children:P})]}),e[9]=P,e[10]=T):T=e[10];let G;e[11]===Symbol.for("react.memo_cache_sentinel")?(G=t.jsx(An,{size:"sm",onClick:()=>f(!0),"aria-label":"Dismiss reconnect banner"}),e[11]=G):G=e[11];let H;e[12]!==T?(H=t.jsxs(mt,{className:wt.header,gap:"xs",justify:"space-between",wrap:"nowrap",children:[T,G]}),e[12]=T,e[13]=H):H=e[13];let F;e[14]!==Z?(F=t.jsx(k,{size:"sm",className:wt.description,children:Z}),e[14]=Z,e[15]=F):F=e[15];let b;e[16]!==l?(b=l?t.jsx(k,{size:"sm",className:wt.error,role:"alert",children:"Reconnect failed. Please try again."}):null,e[16]=l,e[17]=b):b=e[17];let O;e[18]!==F||e[19]!==b?(O=t.jsxs(w,{children:[F,b]}),e[18]=F,e[19]=b,e[20]=O):O=e[20];let B;e[21]!==ee?(B=()=>{ee()},e[21]=ee,e[22]=B):B=e[22];const q=d?"Reconnectingâ¦":"Reconnect";let K;e[23]!==d||e[24]!==B||e[25]!==q?(K=t.jsx("button",{type:"button",className:wt.reconnectButton,disabled:d,onClick:B,children:q}),e[23]=d,e[24]=B,e[25]=q,e[26]=K):K=e[26];let J;e[27]!==O||e[28]!==K?(J=t.jsxs(mt,{className:wt.body,gap:"sm",justify:"space-between",align:"center",wrap:"nowrap",children:[O,K]}),e[27]=O,e[28]=K,e[29]=J):J=e[29];let N;return e[30]!==H||e[31]!==J?(N=t.jsxs(w,{className:wt.banner,role:"status",children:[H,J]}),e[30]=H,e[31]=J,e[32]=N):N=e[32],N}function im(s){return s.providerType==="MIDWAY"}const lm="_icon_1mtw3_1",cm={icon:lm};function bn(s){const e=dt.c(11),{summaryActive:a,onToggle:n,autoFocus:o,onAutoFocusHandled:i}=s,d=a===void 0?!1:a,l=o===void 0?!1:o,u=d?"Hide summary":"Show summary";let c;e[0]!==l||e[1]!==i?(c={active:l,onFocused:i},e[0]=l,e[1]=i,e[2]=c):c=e[2];const f=It(c);let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("span",{className:cm.icon,"aria-hidden":"true",children:t.jsx(Y,{id:"layout-sidebar-left-
6off",size:"md"})}),e[3]=g):g=e[3];let h;e[4]!==f||e[5]!==u||e[6]!==n?(h=t.jsx(ze,{variant:"transparent",size:"lg",onClick:n,"aria-label":u,ref:f,children:g}),e[4]=f,e[5]=u,e[6]=n,e[7]=h):h=e[7];let y;return e[8]!==u||e[9]!==h?(y=t.jsx(Be,{label:u,position:"bottom",children:h}),e[8]=u,e[9]=h,e[10]=y):y=e[10],y}const _n={category:"Kiro",version:"1.0.0",name:"KiroWebFeedback",locale:"en_US",reference:"generalFeedback"},dm="_vibeChatDetailLayout_11f1b_1",um="_floatingPanelDivider_11f1b_10",fm="_vibeChatDetailChatPane_11f1b_14",mm="_toolbar_11f1b_63",pm="_toolbarLeft_11f1b_81",hm="_toolbarActions_11f1b_90",gm="_vibeChatDetailError_11f1b_137",wm="_reconnectingOverlay_11f1b_217",Ue={vibeChatDetailLayout:dm,floatingPanelDivider:um,vibeChatDetailChatPane:fm,toolbar:mm,toolbarLeft:pm,toolbarActions:hm,vibeChatDetailError:gm,reconnectingOverlay:wm},kt="workflows",xm=360,ym=448,Bt=480,bm=668,vn=30,vt=52,Sn=vt;function kn(s){return s.totalCount!==void 0&&s.totalCount!==null?s.totalCount:s.truncated?`${s.entries.length}+`:s.entries.length}function jn(s){const e=s.updatedAt??s.lastEventAt??s.createdAt;if(e===void 0)return 0;const a=Date.parse(e);return Number.isNaN(a)?0:a}const zt=[];function _m(){const s=vu("spaceId"),e=r.useRef(!1),a=r.useRef(!1),n=r.useRef(s),o=r.useRef(null),i=r.useRef(null),d=r.useRef(!!(Gt()||Kt())),[l,u]=r.useState(()=>(Gt()??Kt())?.text),[c,f]=r.useState(!1),[g,h]=r.useState(!1),[y,m]=r.useState(null),v=r.useCallback(()=>{m(null)},[]),{hasFlag:_}=Vn(Qn),re=r.useRef(!1),{data:j,isLoading:U,refetch:$}=Yn({input:{spaceId:s},options:{...Xn,enabled:!!s,refetchInterval:V=>!V.state.data?.space?.displayName&&!c?500:!_||re.current||g?!1:bo(V.state.data?.space?.sandboxStatus),refetchOnWindowFocus:_}}),P=_&&_s(j?.space?.sandboxStatus);r.useEffect(()=>{if(!P){h(!1);return}if(g)return;const V=setTimeout(()=>h(!0),_o);return()=>clearTimeout(V)},[P,g]);const Z=j?.space?.displayName,X=j?.space?.spaceType==="AUTONOMOUS";r.useEffect(()=>{if(Z||c||U||!s)return;const V=setTimeout(()=>f(!0),1e4);return()=>clearTimeout(V)},[Z,c,s,U]);const{data:ee,isLoading:D}=vo({input:{spaceId:s},options:{enabled:!!s,refetchOnMount:"always"}}),T=ee?.sessionId;So(Z??"Chat");const{updateVibeSpace:G,isPending:H}=ku({spaceId:s}),F=r.useCallback(async V=>{await G({displayName:V})},[G]),b=r.useCallback(V=>{H||G({spaceType:V?"AUTONOMOUS":"VIBE"})},[G,H]),{enabled:O,isLoading:B}=Yt(),q=Jn({spaceId:O&&s||null}),K=O&&(q.data??[]).some(V=>V.parentSessionId===T&&!Xt(V.status)),J=O?q.data!==void 0||q.isError:!B,{state:N,sendMessage:xe,loadSession:je,respondToPermission:ye,respondToUserInput:we,isLoading:I,isReconnecting:ne,isSending:z,liveReauth:W,abortStream:pe}=xu({vibeSpaceId:s||null,agentMode:X?"AUTONOMOUS":"VIBE",hasNonterminalWorkflows:K,workflowListSettled:J}),M=r.useRef(je);M.current=je,r.useEffect(()=>{const V=re.current;re.current=I,V&&!I&&_&&_s(j?.space?.sandboxStatus)&&$()},[I]),r.useEffect(()=>{n.current!==s&&(n.current=s,e.current=!1,a.current=!1,f(!1),h(!1),m(null))},[s]);const le=xr();r.useEffect(()=>{const V=new URL(window.location.href),Ie=V.searchParams.get("workflow");if(Ie===null)return;const Me=V.searchParams.get("workflowNodePathKey")??void 0,be=V.searchParams.get("workflowNodeId")??void 0;V.searchParams.delete("workflow"),V.searchParams.delete("workflowNodePathKey"),V.searchParams.delete("workflowNodeId"),window.history.replaceState(window.history.state,"",V.pathname+V.search+V.hash),ko.test(Ie)&&m({spaceId:s,workflowId:Ie,selectNodePathKey:Me,selectNodeId:be})},[le.search,s]);const S=Qt(),ae=r.useRef(N.isProcessing);r.useEffect(()=>{ae.current&&!N.isProcessing&&S.invalidateQueries({queryKey:["GetSpaceCommand"]}),ae.current=N.isProcessing},[N.isProcessing,S]),r.useEffect(()=>{Z&&s&&Un(S,s,Z)},[Z,s,S]),kd(s),di({sessionTitle:N.sessionTitle,spaceId:s}),r.useEffect(()=>{if(T&&!e.current){if(Gt()||Kt()){e.current=!0;return}e.current=!0,M.current(T)}return()=>{e.current=!1}},[T,s]),r.useEffect(()=>{if(!U&&!D&&!a.current){const V=ei()??Zo();V&&Yo(V)&&(a.current=!0,u(""),xe(V.text??"",V.attachments))}},[U,D,xe]);const oe=r.useCallback((V,Ie)=>{zt[0]!==V&&zt.unshift(V),xe(V,Ie)},[xe]),E=r.useCallback(V=>{ye(V)},[ye]),te=r.useCallback(V=>{we(V)},[we]),ce=r.useCallback(()=>{T&&!N.isProcessing&&!z&&!I&&(d.current=!1,je(T))},[T,je,N.isProcessing,z,I]),Te=N.timeline.length>0||z||N.isProcessing||!!T&&I,{pullRequests:ge,error:Ce,hasPullRequests:Ne,hasAnswered:Ee,isLoading:ve}=Su({spaceId:s,sessionId:T,enabled:Te&&!N.isProcessing});return s?(U||D||I)&&!d.current?t.jsx("div",{style:{position:"relative",height:"100%"},children:t.jsx(Tt.div,{initial:{opacity:0,scale:.98,y:8,filter:"blur(4px)"}
6,animate:{opacity:1,scale:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:[.4,0,.2,1]},style:{display:"flex",flexDirection:"column",height:"100%"},children:t.jsx(w,{className:Ue.vibeChatDetailLayout,children:t.jsx(w,{className:Ue.vibeChatDetailChatPane,children:t.jsx(Ui,{header:t.jsx(w,{className:Ue.toolbar,children:t.jsx(w,{className:Ue.toolbarLeft,children:t.jsx(w,{style:{minWidth:120,minHeight:32},children:Z?t.jsx(ua,{title:Z,fallbackTitle:Z,onSave:F,isPending:H}):null})})}),chatInputProps:{storageKey:ra(s),messageHistory:zt,placeholder:"Ask a question or describe a task...",onSubmit:oe,enableAttachments:!0,hideInternalImageButton:!0,imageButtonRef:i,rightActions:t.jsxs(mt,{gap:"xs",align:"center",children:[t.jsx(aa,{disabled:!0,forceAuto:X}),t.jsx(oa,{enabled:X,onToggle:b,disabled:H||z||N.isProcessing})]}),belowActions:t.jsxs(t.Fragment,{children:[t.jsxs(w,{style:{display:"flex",alignItems:"center",gap:"var(--spacing-kiro-sm, 8px)"},children:[t.jsx(na,{disabled:!0,isFull:i.current?.isFull,onClick:()=>i.current?.open()}),t.jsx(fa,{disabled:!0,selectedRepo:j?.space?.githubRepo,providerResources:j?.space?.providerResources,onCloneRepo:()=>{}}),t.jsx(w,{style:{width:"1px",height:"16px",background:"var(--color-border-subtle)",flexShrink:0}})]}),t.jsx(w,{style:{display:"flex",alignItems:"center",gap:"var(--spacing-kiro-sm, 8px)",minWidth:0,flex:1,overflow:"hidden"},children:t.jsx(ma,{selectedRepo:j?.space?.githubRepo,providerResources:j?.space?.providerResources})})]})}})})})})}):N.error&&N.timeline.length===0?t.jsxs(w,{className:Ue.vibeChatDetailError,children:[t.jsx(Y,{c:"red",id:"warning",size:"xl"}),t.jsx(k,{fw:500,size:"lg",children:"Something went wrong"}),t.jsx(k,{c:"dimmed",size:"sm",children:N.error.message})]}):t.jsxs("div",{style:{position:"relative",height:"100%"},children:[ne?t.jsxs(w,{className:Ue.reconnectingOverlay,children:[t.jsx(bt,{size:"sm"}),t.jsx(k,{size:"sm",c:"dimmed",children:"Reconnecting..."})]}):null,t.jsx(Tt.div,{initial:!1,animate:{opacity:1,scale:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:[.4,0,.2,1]},style:{display:"flex",flexDirection:"column",height:"100%"},children:t.jsx(jo,{children:t.jsx(vm,{spaceId:s,hasChatStarted:Te,scrollAreaRef:o,state:N,liveReauth:W,handleRespondToPermission:E,handleRespondToUserInput:te,isSending:z,isLoading:I,abortStream:pe,spaceName:Z,handleSaveTitle:F,isUpdatingSpace:H,handleRefreshSession:ce,existingSessionId:T,hasPullRequests:Ne,isPrLoading:ve,reviewsAnswered:Ee,pullRequests:ge,sessionResourcesError:Ce,sentMessageHistory:zt,handleSendMessage:oe,isAutonomousSpace:X,handleAutonomousToggle:b,imageButtonRef:i,spaceData:j,sandboxStatus:g?void 0:j?.space?.sandboxStatus,sendMessage:xe,arrivalWorkflowRequest:y,onArrivalWorkflowConsumed:v,transitionComposerText:l})})})]}):t.jsxs(w,{className:Ue.vibeChatDetailError,children:[t.jsx(Y,{c:"orange",id:"warning",size:"xl"}),t.jsx(k,{fw:500,size:"lg",children:"Chat not found"})]})}function vm({spaceId:s,hasChatStarted:e,scrollAreaRef:a,state:n,liveReauth:o,handleRespondToPermission:i,handleRespondToUserInput:d,isSending:l,isLoading:u,abortStream:c,spaceName:f,handleSaveTitle:g,isUpdatingSpace:h,handleRefreshSession:y,existingSessionId:m,hasPullRequests:v,isPrLoading:_,reviewsAnswered:re,pullRequests:j,sessionResourcesError:U,sentMessageHistory:$,handleSendMessage:P,isAutonomousSpace:Z,handleAutonomousToggle:X,imageButtonRef:ee,spaceData:D,sandboxStatus:T,sendMessage:G,arrivalWorkflowRequest:H,onArrivalWorkflowConsumed:F,transitionComposerText:b}){const O=Co(),B=No(),{isDisabled:q}=mi(),K=D?.space?.networkMode,{groupNames:J=[],allSessions:N=[],moveToGroup:xe,pendingGroupIds:je=new Set,sessionsByGroup:ye=new Map}=Ro(),we=r.useMemo(()=>N.find(R=>R.spaceId===s),[N,s]),I=we!==void 0,ne=we?.folder??"",z=$o(ne)?"":ne,W=r.useMemo(()=>To(z,ye.get(Io(z))?.length),[z,ye]),pe=r.useCallback(R=>{xe(s,R)},[xe,s]),M=je.has(s),[le,S]=r.useState(null),[ae,oe]=r.useState(m);m!==ae&&(oe(m),S(null));const E=le??Eo(n)??Z,te=r.useMemo(()=>{for(let R=n.timeline.length-1;R>=0;R-=1){const ke=n.timeline[R];if(ke?.type==="turn_usage")return ke.data}},[n.timeline]),{option:ce,isLoading:Te}=ca(n),ge=r.useCallback(R=>{S(R),X(R)},[X]),{hasFlag:Ce}=Vn(Qn),Ne=bs(ia),Ee=bs(fi),{enabled:ve}=Yt(),V=_s(T)||T===vr.FAILED,{data:Ie}=Jn({spaceId:ve?s:null}),Me=r.useMemo(()=>
6{if(!ve)return[];const R=new Map;for(const ke of n.workflows.values())R.set(ke.workflowId,{workflowId:ke.workflowId,name:ke.name??ke.workflowId,status:ke.status,lastEventAt:ke.lastEventAt});for(const ke of Ie??[]){if(m===void 0||ke.parentSessionId!==m)continue;const Qe=R.get(ke.workflowId);R.set(ke.workflowId,{workflowId:ke.workflowId,name:Qe?.name??ke.name,status:Qe?.status??ke.status,createdAt:ke.createdAt,endedAt:ke.endedAt,updatedAt:ke.updatedAt,lastEventAt:Qe?.lastEventAt})}return[...R.values()]},[m,n.workflows,Ie,ve]),be=r.useMemo(()=>Me.map(R=>({spaceId:s,workflowId:R.workflowId})),[s,Me]),Xe=Po(be),Fe=r.useMemo(()=>Me.map(R=>{const ke=Xe.get(R.workflowId),Qe=ke?Ao({state:ke.state,nodePlan:ke.nodePlan,pendingSteps:ke.pendingSteps}):void 0,as=Qe?.rows.find(gt=>gt.type==="step"&>.status==="running"),tr=Qe?.rows.find(gt=>gt.type==="step"&>.status==="paused"),sr=[...Qe?.rows??[]].reverse().find(gt=>gt.type==="step"&>.status!=="pending");return{...R,status:Qe?.status??R.status,createdAt:Qe?.createdAt??R.createdAt,endedAt:Qe?.endedAt??R.endedAt,selectedNodePathKey:(as??tr??sr)?.nodePathKey}}).sort((R,ke)=>jn(ke)-jn(R)),[Me,Xe]),[de,Ke]=r.useState(null),{isLoggedIn:et}=yr(),{subscriptionInfo:rt,activeBonuses:ot,isLoading:C}=Lo({enabled:et}),x=et?Mo(rt,ot,C):!1,{userInfo:p}=Jt(),{feedbackModalOpened:fe,feedbackTemplate:ue,handleFeedbackClick:Re,closeFeedbackModal:_e}=En({config:_n}),$e=r.useMemo(()=>af({spaceId:s}),[s]),{checkEligibility:He,showBanner:it,modalOpened:lt,openModal:Je,dismiss:Ge,closeModal:Ve,template:Oe,config:Ze}=_u({isAutonomous:E}),tt=r.useRef(!1),L=(j??[]).length;r.useEffect(()=>{!n.isProcessing&&L>0&&!tt.current&&(tt.current=!0,He())},[n.isProcessing,L,He]);const[Q,me]=r.useState(!1),se=Ce||ve||v||_||Q,[Le,We]=r.useState("summary"),Se=Ce&&!V&&Q&&Le==="summary",qe=Qs({queryKey:["session-summary-entry-count",s,"files"],queryFn:async()=>{try{const R=await $e.listFiles({});return kn(R)}catch(R){throw an("files"),R}},enabled:Se,staleTime:3e4}),Zt=Qs({queryKey:["session-summary-entry-count",s,"artifacts"],queryFn:async()=>{try{const R=await $e.listFiles({path:Oa});return kn(R)}catch(R){throw an("artifacts"),R}},enabled:Se,staleTime:3e4}),Pt=ks(qe),za=ks(Zt),[Ka,ut]=r.useState(null),At=Le===kt?ym:xm,[Ga,Ha]=br(),Lt=Ga,St=Ha.width,[Fs,ft]=r.useState(vn),[qa,Ua]=r.useState(!1),[_t,jt]=r.useState(null),Ct=r.useCallback(()=>jt(null),[]),Va=se&&!Q,Qa=It({active:_t?.target==="summary-toggle"&&!Va,onFocused:Ct}),Mt=St>0&&St<Bt+At+8,Os=Mt?100:St>0?Math.min((St-Bt-8)/St*100,Math.max(Fs,At/St*100)):Fs,Nt=r.useCallback(()=>{ft(vt)},[]),es=r.useCallback(()=>{const R=Lt.current?.clientWidth??0;if(R<=0){ft(Sn);return}const ke=bm/R*100,Qe=Math.max(0,(R-Bt)/R*100);ft(Math.min(Qe,Math.max(Sn,ke)))},[Lt]),st=r.useCallback(()=>{H!==null&&F()},[H,F]),[Ws,Ya]=r.useState({spaceId:s,sessionId:m});(Ws.spaceId!==s||Ws.sessionId!==m)&&(Ya({spaceId:s,sessionId:m}),Ke(null),me(!1),We("summary"),ut(null),ft(vn),jt(null));const ts=m?{pullRequests:j,error:U,isLoading:_,hasAnswered:re,onPrClick:R=>{jt({target:"review-detail-back"}),O.close(),Ke(R),st(),ut(null),We("pull-request"),ft(vt)}}:void 0,ss=r.useCallback(R=>{ve&&(O.close(),ut(R),We(kt),es(),me(!0))},[ve,O,es]),Dt=r.useCallback(R=>{st(),ss(R)},[st,ss]),Bs=r.useMemo(()=>({openWorkflowPanel:Dt}),[Dt]),Rt=r.useRef(null),zs=r.useRef(s);r.useEffect(()=>{if(!ve)return;if(zs.current!==s){zs.current=s,Rt.current=new Set(n.workflows.keys());return}const R=new Set(n.workflows.keys());if(Rt.current===null){Rt.current=R;return}const ke=Rt.current;let Qe=!1;for(const as of R)ke.has(as)||(Qe=!0);Rt.current=R,Qe&&!Q&&(ut(null),O.close(),We("summary"),Nt(),me(!0))},[n.workflows,ve,s,Q]),r.useEffect(()=>{H!==null&&ss(H)},[H,ve]);const Ks=r.useCallback(()=>{if(ut(null),Q&&Le!=="summary"){st(),We("summary"),Nt();return}const R=!Q;R&&(O.close(),st(),We("summary"),Nt()),me(R)},[Le,Q,O,Nt,st]),Gs=r.useCallback(()=>{jt({target:"summary-toggle"}),ut(null),me(!1),We("summary"),st()},[st]),Xa=r.useCallback(()=>{!Ce||V||(O.close(),st(),ut(null),We("files"),ft(vt),me(!0))},[Ce,V,O,st]),Hs=n.isProcessing&&!Do(n),Ja=r.useCallback((R,ke)=>{x||P(R,ke)},[x,P]),Za=r.useCallback(R=>{x||i(R)},[x,i]),er=r.useCallback(R=>{x||d(R)},[x,d]),ns=ve&&Le===kt&&Q,ht=r.useRef(null),qs=r.useRef(B.requestCollapse);return qs.current=B.requestCollapse,r.useEffect(()=>{ns?ht.current||(ht.current=qs.current()):ht.current&&(ht.current(),ht.current=null)},[ns]),r.useEffect(()=>()=>{ht.current&&(ht.current(),ht.current=null)},[]),t.jsx(Fn,{spaceId:s,onRequestOpen:Ce&&!V?Xa:void 0,children:t.jsxs(w,{className:Ue.vibeChatDetailLayout,ref:Lt,children:[t.jsx(w,{className:Ue.vibeChatDetailChatPane,ref:Qa,role:"region","aria-label":"Conversation",tabIndex:-1,hidden:!!(se&&Q&&Mt),"data-side-panel-open":se&&Q||ns?"true":void 0,children:t.jsx(Zs,{value:Bs,children:t.jsx(Xo,{hasChatStarted:e,scrollRef:a,state:n,spaceId:s,onRespondToPermission:Za,onRespondToUserInput:er,isWaitingForResponse:l||n.isProcessing,snackBar:{visible:l||n.isProcessing,onAction:c},aboveInput:x?t.jsx(pi,{}):t.jsxs(t.Fragment,{children:[Ne?t.jsx(om,{liveReauth:o}):null,it?t.jsx(Xf,{visible:it,onGiveFeedback:Je,onDismiss:Ge}):null]}),header:e?t.jsxs(w,{className:Ue.toolbar,children:[t.jsx(w,{className:Ue.toolbarLeft,children:t.jsx(w,{style:{minWidth:120,minHeight:32},children:t.jsx(_r,{mounted:!!f,transition:"fade",duration:200,children:R=>t.jsx("div",{style:R,children:t.jsx(ua,{title:f??"",fallbackTitle:f??"",onSave:g,isPending:h})})})})}),t.jsxs(mt,{gap:"xs",className:Ue.toolbarActions,children:[t.jsx(Be,{label:"Refresh session",position:"bottom",children:t.jsx(ze,{variant:"transparent",size:"lg",onClick:y,disabled:!m||n.isProcessing||l||u,"aria-label":"Refresh session",children:t.jsx(Y,{id:"refresh",size:"md"})})}),t.jsx(Be,{label:"Give feedback",position:"bottom",children:t.jsx(ze,{variant:"transparent",size:"lg",onClick:Re,"aria-label":"Give feedback",children:t.jsx(Y,{id:"feedback",size:"sm"})})}),se&&!Q?t.jsx(bn,{summaryActive:!1,onToggle:Ks,autoFocus:_t?.target==="summary-toggle",onAutoFocusHandled:Ct}):null]})]}):t.jsxs(w,{className:Ue.toolbar,children:[t.jsx(w,{className:Ue.toolbarLeft}),t.jsxs(mt,{gap:"xs",className:Ue.toolbarActions,children:[t.jsx(Be,{label:"Give feedback",position:"bottom",children:t.jsx(ze,{variant:"transparent",size:"lg",onClick:Re,"aria-label":"Give feedback",children:t.jsx(Y,{id:"feedback",size:"sm"})})}),se&&!Q?t.jsx(bn,{summaryActive:!1,onToggle:Ks,autoFocus:_t?.target==="summary-toggle",onAutoFocusHandled:Ct}):null]})]}),chatInputProps:{storageKey:ra(s),initialValue:b,initialValueTransient:!0,messageHistory:$,placeholder:x?"Upgrade your plan to continue this session...":"Ask a question or describe a task...",onSubmit:Ja,enableAttachments:!x,hideInternalImageButton:!0,imageButtonRef:ee,submitDisabled:x||Hs,submitDisabledReason:x?"Subscription required for Kiro Web":Hs?"Waiting for response...":void 0,rightActions:t.jsxs(mt,{gap:"xs",align:"center",children:[t.jsx(si,{currentGroup:z,groupNames:J,onSelectGroup:pe,isLastSessionInGroup:W,isGroupUnknown:!I,disabled:M}),t.jsx(aa,{disabled:x||l||n.isProcessing,forceAuto:E,sessionModelId:Fo(n),sessionId:m}),E?null:t.jsx(Jo,{disabled:x||l||n.isProcessing,isLoading:Te,option:ce,spaceId:s}),t.jsx(oa,{enabled:E,onToggle:ge,disabled:h||l||n.isProcessing})]}),belowActions:t.jsxs(t.Fragment,{children:[t.jsxs(w,{style:{display:"flex",alignItems:"center",gap:"var(--spacing-kiro-sm, 8px)"},children:[!q&&K?t.jsx(ti,{networkAccess:K,isUpdating:!1,onUpdateNetworkAccess:async()=>{},readOnly:!0}):null,t.jsx(na,{disabled:x||l||n.isProcessing,isFull:ee.current?.isFull,onClick:()=>ee.current?.open()}),t.jsx($i,{latestTurnUsage:te}),t.jsx(fa,{disabled:x||l||n.isProcessing,selectedRepo:D?.space?.githubRepo,providerResources:D?.space?.providerResources,onCloneRepo:R=>{x||G(ui(R,Ee))}}),t.jsx(w,{style:{width:"1px",height:"16px",background:"var(--color-border-subtle)",flexShrink:0}})]}),t.jsx(w,{style:{display:"flex",alignItems:"center",gap:"var(--spacing-kiro-sm, 8px)",minWidth:0,flex:1,overflow:"hidden"},children:t.jsx(ma,{selectedRepo:D?.space?.githubRepo,providerResources:D?.space?.providerResources})})]})}})})}),se&&Q&&!Mt?t.jsx(da,{className:Ue.floatingPanelDivider,position:100-Os,onPositionChange:R=>ft(100-R),minLeftWidth:Bt,minRightWidth:At,containerRef:Lt,onDragStateChange:Ua,ariaLabel:"Resize session panel"}):null,se?t.jsx(hd,{enabled:se,filesEnabled:Ce,fileTabsDisabled:V,filesCount:Pt,artifactsCount:za,reviews:ts,isOpen:Q,onClose:Gs,spaceId:s,fileSidebar:Ce?t.jsx(tf,{api:$e}):void 0,widthPercent:Os,minWidthPx:Mt?0:At,isResizing:qa,summaryActive:Le==="summary",onSummarySelect:()=>{st(),ut(null),We("summary"),Nt()},onFileTabSelect:R=>{st(),ut(null),We(R),ft(vt)},reviewTab:m&&ts?{value:"pull-request",label:"Reviews",active:Le==="pull-request",onSelect:()=>{st(),ut(null),We("pull-request"),ft(vt)},content:de?t.jsx(Jc,{pullRequest:de,spaceId:s,sessionId:m,autoFocusBack:_t?.target==="review-detail-back",onBack
6Focused:Ct,onBack:()=>{jt({target:"reviews-list",review:de}),Ke(null)},onViewModeChange:R=>{ft(R==="split"?80:vt)}},`${s}-${m}-${de.owner}-${de.repo}-${de.prId}`):t.jsx(wl,{...ts,autoFocus:_t?.target==="reviews-list",autoFocusReview:_t?.target==="reviews-list"?_t.review:null,onAutoFocusHandled:Ct})}:void 0,workflowTab:ve?{value:kt,label:"Workflows",active:Le===kt,onSelect:()=>{We(kt),es()},summaryItems:Fe.map(R=>({workflowId:R.workflowId,title:R.name,status:R.status,createdAt:R.createdAt,endedAt:R.endedAt,onSelect:()=>{Dt({spaceId:s,workflowId:R.workflowId,collapseRunList:!1,...R.selectedNodePathKey?{selectNodePathKey:R.selectedNodePathKey}:{}})}})),content:t.jsx(Zs,{value:Bs,children:t.jsx(qf,{spaceId:s,workflows:Fe,panelRequest:Ka,routingSessionId:m,sessionLabel:f,onSelectWorkflow:Dt,onClosePanel:Gs})})}:void 0}):null,t.jsx(Ys,{config:_n,opened:fe,template:ue,userId:p?.userId,metadata:{...m?{sessionId:m}:{},pageURL:window.location.href},onClose:_e}),t.jsx(Ys,{config:Ze,opened:lt,template:Oe,userId:p?.userId,metadata:{...m?{sessionId:m}:{},pageURL:window.location.href},onClose:Ve})]})})}const Sm="_sessionDetailLoader_1vy66_1",km="_resumingContent_1vy66_8",jm="_dots_1vy66_15",xs={sessionDetailLoader:Sm,resumingContent:km,dots:jm},Ds=["Tinkering","Figuring out a path to the stars","Hydrating the environment","Do or do not, there is no try...catch","I'm gonna make this code an offer it can't refuse","Just keep coding, just keep coding","To production and beyond","After all, tomorrow is another deploy","Hacks on, hacks off","May the source be with you","Here's looking at you, code","Semicolons? Where we're going we don't need semicolons"],Cm=5e3;let Ba=Math.floor(Math.random()*Ds.length);function Cn(s){const e=dt.c(13),{className:a}=s,[n,o]=r.useState(Ba),[i,d]=r.useState("");let l,u;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const re=setInterval(()=>{o(Rm)},Cm);return()=>clearInterval(re)},u=[],e[0]=l,e[1]=u):(l=e[0],u=e[1]),r.useEffect(l,u);let c,f;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{const re=setInterval(()=>{d(Nm)},500);return()=>clearInterval(re)},f=[],e[2]=c,e[3]=f):(c=e[2],f=e[3]),r.useEffect(c,f);const g=a??xs.sessionDetailLoader;let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(bt,{size:"lg"}),e[4]=h):h=e[4];const y=Ds[n];let m;e[5]!==i?(m=t.jsx("span",{className:xs.dots,children:i}),e[5]=i,e[6]=m):m=e[6];let v;e[7]!==y||e[8]!==m?(v=t.jsxs(w,{className:xs.resumingContent,children:[h,t.jsxs(k,{c:"var(--color-text-secondary)",fw:500,mt:"md",size:"md",children:[y,m]})]}),e[7]=y,e[8]=m,e[9]=v):v=e[9];let _;return e[10]!==g||e[11]!==v?(_=t.jsx(w,{className:g,children:v}),e[10]=g,e[11]=v,e[12]=_):_=e[12],_}function Nm(s){return s.length>=3?"":`${s}.`}function Rm(s){const e=(s+1)%Ds.length;return Ba=e,e}const $m=Ln.lazy(()=>kr(()=>import("./index.js.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]),import.meta.url).then(s=>({default:s.SpaceDetail})));function qm(){const s=dt.c(11),{spaceId:e}=Pn(),a=e??"";let n;s[0]!==a?(n={spaceId:a},s[0]=a,s[1]=n):n=s[1];const o=!!e;let i;s[2]!==o?(i={...Xn,enabled:o},s[2]=o,s[3]=i):i=s[3];let d;s[4]!==n||s[5]!==i?(d={input:n,options:i},s[4]=n,s[5]=i,s[6]=d):d=s[6];const{data:l,isLoading:u,error:c}=Yn(d),f=l?.space?.spaceType,g=!!(Gt()||Kt()||en());if(c&&Oo(c,404)){let y;return s[7]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(Sr,{replace:!0,to:"/session"}),s[7]=y):y=s[7],y}if(u&&!g){let y;return s[8]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(Cn,{}),s[8]=y):y=s[8],y}if(f==="SPEC"||en()){let y;return s[9]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(Ln.Suspense,{fallback:t.jsx(Cn,{}),children:t.jsx($m,{})}),s[9]=y):y=s[9],y}let h;return s[10]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(_m,{}),s[10]=h):h=s[10],h}export{qm as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.