import{c as Je,a as _,d as lt,o as kt,s as p,e as se,f as S,t as Ke}from"../chunks/BLoZk-4Q.js";import{f as he,P as Re,R as s,U as l,T as a,K as e,t as F,Q as Ee,V as Z,bn as jt,Y as nt,as as At,Z as Ft,B as at,X as d,W as ue,a6 as dt}from"../chunks/CkWh75VR.js";import{l as We,s as Xe,i as I,b as ye,a as Oe,p as W}from"../chunks/BIAtSU2q.js";import{p as Dt,T as Bt,C as Ut}from"../chunks/TuDKvZ2x.js";import{a as Ne,d as ke,b as ze,i as Ht,c as Vt}from"../chunks/Cxgk6Ihq.js";import{s as wt,t as ut,l as Nt,a as zt,b as St}from"../chunks/CLAQm0y3.js";import{I as Ze,s as Ge,e as He,i as Ve,b as st,t as Qe,a as Pe,c as It,r as mt,g as qt}from"../chunks/Bmr4jBBJ.js";import{g as Qt}from"../chunks/Dz-gMz0b.js";import{X as Kt,L as Ue,r as Jt,p as Wt}from"../chunks/Dm3B8RZy.js";import{R as Xt,F as Zt}from"../chunks/Bjwim7Hg.js";import"../chunks/DnbEMVOy.js";import{C as it}from"../chunks/SdiQyPyy.js";import{P as Gt,B as Yt,a as ea}from"../chunks/BK8gH9sp.js";import{R as ft}from"../chunks/BTSNPSgB.js";import{S as ta}from"../chunks/BWaw-pIO.js";import{C as aa}from"../chunks/D6PP_X6J.js";import{F as sa}from"../chunks/D4o-w7gg.js";import{b as pt}from"../chunks/DppCjq5L.js";import{S as Mt,P as na}from"../chunks/4tZ2hhAR.js";import{F as Pt,C as la}from"../chunks/Bwyoybv3.js";import{C as Ct}from"../chunks/CxSD3vMp.js";import{o as $t,a as ra}from"../chunks/C4C6gRQf.js";import{h as ia}from"../chunks/CvI6nzPm.js";import{b as Rt}from"../chunks/_Q0si_gD.js";import{C as oa}from"../chunks/C7csppvN.js";import{C as Tt}from"../chunks/DgwqUAbK.js";import{P as va}from"../chunks/B_7Cvyi8.js";function ca(q,t){const r=We(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=[["path",{d:"m12 19-7-7 7-7"}],["path",{d:"M19 12H5"}]];Ze(q,Xe({name:"arrow-left"},()=>r,{get iconNode(){return D},children:(g,m)=>{var h=Je(),v=he(h);Ge(v,t,"default",{}),_(g,h)},$$slots:{default:!0}}))}function da(q,t){const r=We(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=[["path",{d:"m5 12 7-7 7 7"}],["path",{d:"M12 19V5"}]];Ze(q,Xe({name:"arrow-up"},()=>r,{get iconNode(){return D},children:(g,m)=>{var h=Je(),v=he(h);Ge(v,t,"default",{}),_(g,h)},$$slots:{default:!0}}))}function ua(q,t){const r=We(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=[["path",{d:"M12 8V4H8"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}],["path",{d:"M2 14h2"}],["path",{d:"M20 14h2"}],["path",{d:"M15 13v2"}],["path",{d:"M9 13v2"}]];Ze(q,Xe({name:"bot"},()=>r,{get iconNode(){return D},children:(g,m)=>{var h=Je(),v=he(h);Ge(v,t,"default",{}),_(g,h)},$$slots:{default:!0}}))}function fa(q,t){const r=We(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=[["circle",{cx:"12",cy:"12",r:"10"}],["circle",{cx:"12",cy:"12",r:"1"}]];Ze(q,Xe({name:"circle-dot"},()=>r,{get iconNode(){return D},children:(g,m)=>{var h=Je(),v=he(h);Ge(v,t,"default",{}),_(g,h)},$$slots:{default:!0}}))}function ma(q,t){const r=We(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}],["path",{d:"M9 15h6"}],["path",{d:"M12 18v-6"}]];Ze(q,Xe({name:"file-plus"},()=>r,{get iconNode(){return D},children:(g,m)=>{var h=Je(),v=he(h);Ge(v,t,"default",{}),_(g,h)},$$slots:{default:!0}}))}function pa(q,t){const r=We(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9"}],["path",{d:"m18 15 4-4"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5"}]];Ze(q,Xe({name:"hammer"},()=>r,{get iconNode(){return D},children:(g,m)=>{var h=Je(),v=he(h);Ge(v,t,"default",{}),_(g,h)},$$slots:{default:!0}}))}function _a(q,t){const r=We(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"}],["path",{d:"m21.854 2.147-10.94 10.939"}]];Ze(q,Xe({name:"send"},()=>r,{get iconNode(){return D},children:(g,m)=>{var h=Je(),v=he(h);Ge(v,t,"default",{}),_(g,h)},$$slots:{default:!0}}))}function ga(q,t){const r=We(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];Ze(q,Xe({name:"square"},()=>r,{get iconNode(){return D},children:(g,m)=>{var h=Je(),v=he(h);Ge(v,t,"default",{}),_(g,h)},$$slots:{default:!0}}))}function ha(q,t){const r=We(t,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=[["polyline",{points:"4 17 10 11 4 5"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19"}]];Ze(q,Xe({name:"terminal"},()=>r,{get iconNode(){return D},children:(g,m)=>{var h=Je(),v=he(h);Ge(v,t,"default",{}),_(g,h)},$$slots:{default:!0}}))}function xa(q,t,r){if(r||q==null)return t.split(`
`).map((m,h)=>({type:"add",num:h+1,oldNum:"",newNum:h+1,text:m}));const D=q.split(`
`),g=t.split(`
`);return ba(D,g)}function ba(q,t){const r=q.length,D=t.length;if(r*D>5e5)return ya(q,t);const g=Array.from({length:r+1},()=>new Uint32Array(D+1));for(let N=1;N<=r;N++)for(let te=1;te<=D;te++)g[N][te]=q[N-1]===t[te-1]?g[N-1][te-1]+1:Math.max(g[N-1][te],g[N][te-1]);const m=[];let h=r,v=D;for(;h>0||v>0;)h>0&&v>0&&q[h-1]===t[v-1]?(m.push({type:"ctx",oldNum:h,newNum:v,text:q[h-1]}),h--,v--):v>0&&(h===0||g[h][v-1]>=g[h-1][v])?(m.push({type:"add",oldNum:"",newNum:v,text:t[v-1]}),v--):(m.push({type:"del",oldNum:h,newNum:"",text:q[h-1]}),h--);return m.reverse(),ka(m)}function ya(q,t){function r(j){const E=new Map;for(const Q of j)E.set(Q,(E.get(Q)||0)+1);return E}const D=r(t),g=r(q),m=new Map(D),h=new Map(g),v=[];let N=1;for(const j of q){const E=m.get(j)||0;E>0?m.set(j,E-1):v.push({type:"del",oldNum:N,newNum:"",text:j}),N++}let te=1;for(const j of t){const E=h.get(j)||0;E>0?h.set(j,E-1):v.push({type:"add",oldNum:"",newNum:te,text:j}),te++}return v}function ka(q,t=3){const r=new Uint8Array(q.length);for(let m=0;m<q.length;m++)if(q[m].type!=="ctx")for(let h=Math.max(0,m-t);h<=Math.min(q.length-1,m+t);h++)r[h]=1;const D=[];let g=!1;for(let m=0;m<q.length;m++)r[m]?(g=!1,D.push(q[m])):g||(g=!0,D.push({type:"sep",oldNum:"",newNum:"",text:"···"}));return D}function wa(q){let t=0,r=0;for(const D of q)D.type==="add"?t++:D.type==="del"&&r++;return{added:t,removed:r}}var Ca=S('<span class="stat-add svelte-yyme92"> </span>'),Na=S('<span class="stat-del svelte-yyme92"> </span>'),za=S('<span class="badge-new svelte-yyme92"> </span>'),Sa=S('<tr><td class="line-num old-num svelte-yyme92"> </td><td class="line-num new-num svelte-yyme92"> </td><td class="line-marker svelte-yyme92"><!></td><td class="line-text svelte-yyme92"><pre class="svelte-yyme92"> </pre></td></tr>'),qa=S('<span class="applied-badge svelte-yyme92"><!> </span>'),$a=S('<button class="btn btn-success"><!> </button>'),Ta=S('<div class="overlay svelte-yyme92" role="dialog" aria-modal="true" tabindex="-1"><div class="modal svelte-yyme92" role="document"><div class="modal-header svelte-yyme92"><div class="file-path svelte-yyme92"><!> </div> <div class="stats svelte-yyme92"><!> <!> <!></div> <button class="close-x svelte-yyme92"><!></button></div> <div class="diff-scroll svelte-yyme92"><table class="diff-table svelte-yyme92"><tbody></tbody></table></div> <div class="modal-footer svelte-yyme92"><!> <button class="btn"> </button></div></div></div>');function Et(q,t){Re(t,!0);const r=()=>ye(Qe,"$t",D),[D,g]=Oe();let m=Z(()=>xa(t.oldContent,t.newContent,t.isNew)),h=Z(()=>wa(e(m)));function v(o){o.key==="Escape"&&t.onClose()}var N=Ta();kt("keydown",jt,v);var te=s(N),j=s(te),E=s(j),Q=s(E);{var G=o=>{ma(o,{size:14,class:"new-icon"})};I(Q,o=>{t.isNew&&o(G)})}var ne=l(Q);a(E);var P=l(E,2),re=s(P);{var ie=o=>{var f=Ca(),M=s(f);a(f),F(()=>p(M,`+${e(h).added??""}`)),_(o,f)};I(re,o=>{e(h).added>0&&o(ie)})}var le=l(re,2);{var R=o=>{var f=Na(),M=s(f);a(f),F(()=>p(M,`-${e(h).removed??""}`)),_(o,f)};I(le,o=>{e(h).removed>0&&o(R)})}var H=l(le,2);{var B=o=>{var f=za(),M=s(f,!0);a(f),F(ee=>p(M,ee),[()=>r()("fix.new_file")]),_(o,f)};I(H,o=>{t.isNew&&o(B)})}a(P);var oe=l(P,2),K=s(oe);Kt(K,{size:16}),a(oe),a(j);var X=l(j,2),A=s(X),$=s(A);He($,21,()=>e(m),Ve,(o,f)=>{var M=Sa(),ee=s(M),L=s(ee,!0);a(ee);var w=l(ee),J=s(w,!0);a(w);var k=l(w),c=s(k);{var y=ae=>{var me=Ke("+");_(ae,me)},T=ae=>{var me=Ke("-");_(ae,me)},ce=ae=>{var me=Ke("⋯");_(ae,me)},ve=ae=>{var me=Ke(" ");_(ae,me)};I(c,ae=>{e(f).type==="add"?ae(y):e(f).type==="del"?ae(T,1):e(f).type==="sep"?ae(ce,2):ae(ve,!1)})}a(k);var fe=l(k),ge=s(fe),we=s(ge,!0);a(ge),a(fe),a(M),F(()=>{Pe(M,1,`diff-row diff-${e(f).type??""}`,"svelte-yyme92"),p(L,e(f).oldNum),p(J,e(f).newNum),p(we,e(f).text)}),_(o,M)}),a($),a(A),a(X);var O=l(X,2),Y=s(O);{var C=o=>{var f=qa(),M=s(f);it(M,{size:14});var ee=l(M);a(f),F(L=>p(ee,` ${L??""}`),[()=>r()("fix.already_applied")]),_(o,f)},x=o=>{var f=$a(),M=s(f);it(M,{size:14});var ee=l(M);a(f),F(L=>p(ee,` ${L??""}`),[()=>r()("fix.apply_file")]),se("click",f,function(...L){var w;(w=t.onApply)==null||w.apply(this,L)}),_(o,f)};I(Y,o=>{t.applied?o(C):o(x,!1)})}var b=l(Y,2),i=s(b,!0);a(b),a(O),a(te),a(N),F(o=>{st(N,"aria-label",t.filepath),p(ne,` ${t.filepath??""}`),p(i,o)},[()=>r()("fix.close")]),se("keydown",N,v),se("click",N,function(...o){var f;(f=t.onClose)==null||f.apply(this,o)}),se("click",te,o=>o.stopPropagation()),se("click",oe,function(...o){var f;(f=t.onClose)==null||f.apply(this,o)}),se("click",b,function(...o){var f;(f=t.onClose)==null||f.apply(this,o)}),_(q,N),Ee(),g()}lt(["keydown","click"]);var Aa=S('<span class="status-icon complete svelte-1ocgme9"><!></span>'),Fa=S('<span class="status-icon wip svelte-1ocgme9"><!></span>'),Da=S('<div> </div> <div class="progress-bar svelte-1ocgme9"><div class="progress-fill svelte-1ocgme9"></div></div>',1),Ia=S('<button class="back svelte-1ocgme9" type="button"><!> </button> <div class="main-header"><h2><!> </h2></div> <!> <!>',1);function Ma(q,t){Re(t,!0);const r=()=>ye(Qe,"$t",D),[D,g]=Oe();let m=W(t,"phases",19,()=>({})),h=W(t,"currentPhase",3,""),v=W(t,"currentStage",3,0),N=W(t,"totalStages",3,0),te=Z(()=>N()>0?Math.round(v()/N()*100):0),j=Z(()=>m()&&Object.values(m()).length>0&&Object.values(m()).every(A=>A==="complete")),E=Z(()=>h()==="implement"&&N()>0);var Q=Ia(),G=he(Q),ne=s(G);ca(ne,{size:14});var P=l(ne);a(G);var re=l(G,2),ie=s(re),le=s(ie);{var R=A=>{var $=Aa(),O=s($);Yt(O,{size:24}),a($),_(A,$)},H=A=>{var $=Fa(),O=s($);ea(O,{size:24}),a($),_(A,$)};I(le,A=>{e(j)?A(R):A(H,!1)})}var B=l(le);a(ie),a(re);var oe=l(re,2);Gt(oe,{get phases(){return m()}});var K=l(oe,2);{var X=A=>{var $=Da(),O=he($);let Y;var C=s(O);a(O);var x=l(O,2),b=s(x);a(x),F(i=>{Y=Pe(O,1,"progress-label svelte-1ocgme9",null,Y,{"progress-complete":e(te)>=100}),p(C,`${i??""}: ${v()??""}/${N()??""} (${e(te)??""}%)`),It(b,`width: ${e(te)??""}%`)},[()=>r()("task.implement_progress")]),_(A,$)};I(K,A=>{e(E)&&A(X)})}F((A,$)=>{p(P,` ${A??""}`),p(B,` ${$??""}`)},[()=>r()("task.back"),()=>r()("task.detail_title",{name:t.taskName})]),se("click",G,function(...A){var $;($=t.onBack)==null||$.apply(this,A)}),_(q,Q),Ee(),g()}lt(["click"]);var Pa=S('<p class="phase-hint svelte-z64ibl"><strong> </strong> </p> <div class="btn-group"><button class="btn btn-primary"><!> </button></div>',1),Ra=S('<p class="phase-hint svelte-z64ibl"><strong> </strong> </p> <div class="btn-group"><button class="btn btn-primary"><!> </button> <button class="btn"><!> </button></div>',1),Ea=S('<button class="btn"><!> </button>'),Oa=S('<p class="phase-hint svelte-z64ibl"><strong> </strong> </p> <div class="btn-group"><button class="btn btn-primary"><!> </button> <!></div>',1),La=S('<button class="btn"><!> </button>'),ja=S('<p class="phase-hint svelte-z64ibl"><strong> </strong> </p> <div class="btn-group"><button class="btn btn-primary"><!> </button> <!></div>',1),Ba=S('<div class="loading-text"><!> <!></div>'),Ua=S('<div class="actions-block svelte-z64ibl"><!></div> <!>',1);function Ha(q,t){Re(t,!0);const r=()=>ye(Qe,"$t",D),[D,g]=Oe();let m=W(t,"phases",19,()=>({})),h=W(t,"currentStage",3,0),v=W(t,"totalStages",3,0),N=W(t,"actionLoading",3,""),te=W(t,"hasUnanswered",3,!1),j=W(t,"onClarify",3,()=>{}),E=W(t,"onPlan",3,()=>{}),Q=W(t,"onImplement",3,()=>{}),G=W(t,"onTests",3,()=>{});var ne=Ua(),P=he(ne),re=s(P);{var ie=K=>{var X=Pa(),A=he(X),$=s(A),O=s($,!0);a($);var Y=l($,1,!0);a(A);var C=l(A,2),x=s(C),b=s(x);{var i=M=>{Ue(M,{size:14,class:"spin"})},o=M=>{ta(M,{size:14})};I(b,M=>{N()==="clarify"?M(i):M(o,!1)})}var f=l(b);a(x),a(C),F((M,ee,L)=>{p(O,M),p(Y,ee),x.disabled=!!N(),p(f,` ${L??""}`)},[()=>r()("phase_hint.prefix"),()=>r()("phase_hint.clarify"),()=>r()("action.clarify")]),se("click",x,function(...M){var ee;(ee=j())==null||ee.apply(this,M)}),_(K,X)},le=K=>{var X=Ra(),A=he(X),$=s(A),O=s($,!0);a($);var Y=l($,1,!0);a(A);var C=l(A,2),x=s(C),b=s(x);{var i=w=>{Ue(w,{size:14,class:"spin"})},o=w=>{aa(w,{size:14})};I(b,w=>{N()==="plan"?w(i):w(o,!1)})}var f=l(b);a(x);var M=l(x,2),ee=s(M);ft(ee,{size:14});var L=l(ee);a(M),a(C),F((w,J,k,c)=>{p(O,w),p(Y,J),x.disabled=!!N(),p(f,` ${k??""}`),M.disabled=!!N(),p(L,` ${c??""}`)},[()=>r()("phase_hint.prefix"),()=>r()("phase_hint.plan"),()=>r()("action.gen_plan"),()=>r()("action.re_clarify")]),se("click",x,function(...w){var J;(J=E())==null||J.apply(this,w)}),se("click",M,function(...w){var J;(J=j())==null||J.apply(this,w)}),_(K,X)},R=K=>{const X=Z(()=>h()+1);var A=Oa(),$=he(A),O=s($),Y=s(O,!0);a(O);var C=l(O,1,!0);a($);var x=l($,2),b=s(x),i=s(b);{var o=w=>{Ue(w,{size:14,class:"spin"})},f=w=>{pa(w,{size:14})};I(i,w=>{N()==="implement"?w(o):w(f,!1)})}var M=l(i);a(b);var ee=l(b,2);{var L=w=>{var J=Ea(),k=s(J);ft(k,{size:14});var c=l(k);a(J),F(y=>{J.disabled=!!N(),p(c,` ${y??""}`)},[()=>r()("action.re_clarify")]),se("click",J,function(...y){var T;(T=j())==null||T.apply(this,y)}),_(w,J)};I(ee,w=>{m().clarify==="complete"&&!te()&&w(L)})}a(x),F((w,J,k)=>{p(Y,w),p(C,J),b.disabled=!!N(),p(M,` ${k??""}`)},[()=>r()("phase_hint.prefix"),()=>r()("phase_hint.implement",{n:e(X),total:v()||"?"}),()=>r()("action.implement_stage",{n:e(X)})]),se("click",b,function(...w){var J;(J=Q())==null||J.apply(this,w)}),_(K,A)},H=K=>{var X=ja(),A=he(X),$=s(A),O=s($,!0);a($);var Y=l($,1,!0);a(A);var C=l(A,2),x=s(C),b=s(x);{var i=L=>{Ue(L,{size:14,class:"spin"})},o=L=>{sa(L,{size:14})};I(b,L=>{N()==="tests"?L(i):L(o,!1)})}var f=l(b);a(x);var M=l(x,2);{var ee=L=>{var w=La(),J=s(w);ft(J,{size:14});var k=l(J);a(w),F(c=>{w.disabled=!!N(),p(k,` ${c??""}`)},[()=>r()("action.re_clarify")]),se("click",w,function(...c){var y;(y=j())==null||y.apply(this,c)}),_(L,w)};I(M,L=>{m().clarify==="complete"&&!te()&&L(ee)})}a(C),F((L,w,J)=>{p(O,L),p(Y,w),x.disabled=!!N(),p(f,` ${J??""}`)},[()=>r()("phase_hint.prefix"),()=>r()("phase_hint.tests"),()=>r()("action.run_tests")]),se("click",x,function(...L){var w;(w=G())==null||w.apply(this,L)}),_(K,X)};I(re,K=>{m().clarify!=="complete"&&!te()?K(ie):m().clarify==="complete"&&m().plan!=="complete"?K(le,1):m().plan==="complete"&&(v()===0||h()+1<=v())?K(R,2):(m().implement==="complete"||h()>0&&h()>=v())&&K(H,3)})}a(P);var B=l(P,2);{var oe=K=>{var X=Ba(),A=s(X);Ue(A,{size:14,class:"spin"});var $=l(A,2);{var O=i=>{var o=Ke();F(f=>p(o,f),[()=>r()("action.clarifying")]),_(i,o)},Y=i=>{var o=Ke();F(f=>p(o,f),[()=>r()("action.planning")]),_(i,o)},C=i=>{var o=Ke();F(f=>p(o,f),[()=>r()("action.implementing",{n:h()+1})]),_(i,o)},x=i=>{var o=Ke();F(f=>p(o,f),[()=>r()("action.running_tests")]),_(i,o)},b=i=>{var o=Ke();F(f=>p(o,f),[()=>r()("clarify.updating")]),_(i,o)};I($,i=>{N()==="clarify"?i(O):N()==="plan"?i(Y,1):N()==="implement"?i(C,2):N()==="tests"?i(x,3):N()==="submit"&&i(b,4)})}a(X),_(K,X)};I(B,K=>{N()&&!te()&&K(oe)})}_(q,ne),Ee(),g()}lt(["click"]);var Va=S('<div class="question-context svelte-rwa6kx"> </div>'),Qa=S('<label><input type="radio" class="svelte-rwa6kx"/> <span class="option-letter svelte-rwa6kx"> </span> <span class="option-text svelte-rwa6kx"> </span></label>'),Ka=S('<div class="options-list svelte-rwa6kx"><!> <label><input type="radio" class="svelte-rwa6kx"/> <span class="option-letter svelte-rwa6kx">✎</span> <span class="option-text svelte-rwa6kx"> </span></label></div>'),Ja=S('<textarea class="qa-input svelte-rwa6kx" rows="2"></textarea>'),Wa=S('<div class="qa-block svelte-rwa6kx"><div class="question-label svelte-rwa6kx"><strong> </strong></div> <div class="question-text svelte-rwa6kx"> </div> <!> <!> <!></div>'),Xa=S('<div class="card" style="margin-top: 2rem"><h3> </h3> <p class="subtitle"> </p> <p class="hint"> </p> <!> <div class="btn-group"><button class="btn btn-success"><!> <!> </button> <button class="btn"><!> </button> <button class="btn"><!> </button></div></div>');function Za(q,t){Re(t,!0);const r=()=>ye(Qe,"$t",D),[D,g]=Oe(),m="ABCDEFGHIJ";let h=W(t,"parsedQA",19,()=>[]),v=W(t,"clarifyAnswers",31,()=>nt({})),N=W(t,"actionLoading",3,""),te=W(t,"draftSaving",3,!1),j=W(t,"draftSaved",3,!1),E=W(t,"onSubmit",3,()=>{}),Q=W(t,"onSaveDraft",3,()=>{}),G=W(t,"onReClarify",3,()=>{}),ne=nt({});function P(c,y){const T=(v()[c]||"").trim().toUpperCase(),ce=m[y];return T===ce}function re(c,y){ne[c]=!1,v(v()[c]=m[y],!0)}function ie(c){ne[c]=!0;const y=(v()[c]||"").trim().toUpperCase();y.length===1&&m.includes(y)&&v(v()[c]="",!0)}function le(c,y){if(ne[c]||!(y!=null&&y.length))return!0;const T=(v()[c]||"").trim().toUpperCase();return T?T.length===1&&m.includes(T)?m.indexOf(T)>=y.length:!0:!1}var R=Xa(),H=s(R),B=s(H,!0);a(H);var oe=l(H,2),K=s(oe,!0);a(oe);var X=l(oe,2),A=s(X,!0);a(X);var $=l(X,2);He($,17,h,Ve,(c,y)=>{const T=Z(()=>e(y).num),ce=Z(()=>e(y).options||[]),ve=Z(()=>le(e(T),e(ce)));var fe=Wa(),ge=s(fe),we=s(ge),ae=s(we,!0);a(we),a(ge);var me=l(ge,2),$e=s(me,!0);a(me);var Te=l(me,2);{var Le=n=>{var u=Va(),z=s(u,!0);a(u),F(()=>p(z,e(y).context)),_(n,u)};I(Te,n=>{e(y).context&&n(Le)})}var pe=l(Te,2);{var Ie=n=>{var u=Ka(),z=s(u);He(z,17,()=>e(ce),Ve,(de,xe,_e)=>{const Se=Z(()=>m[_e]);var je=Qa();let Fe;var qe=s(je);mt(qe);var et=l(qe,2),tt=s(et);a(et);var De=l(et,2),_t=s(De,!0);a(De),a(je),F((gt,ht)=>{Fe=Pe(je,1,"option-row svelte-rwa6kx",null,Fe,gt),st(qe,"name",`q${e(T)??""}`),qt(qe,ht),p(tt,`${e(Se)??""})`),p(_t,e(xe))},[()=>({selected:P(e(T),_e)}),()=>P(e(T),_e)]),se("change",qe,()=>re(e(T),_e)),_(de,je)});var Ae=l(z,2);let Ce;var be=s(Ae);mt(be);var U=l(be,4),V=s(U,!0);a(U),a(Ae),a(u),F(de=>{Ce=Pe(Ae,1,"option-row svelte-rwa6kx",null,Ce,{selected:e(ve)}),st(be,"name",`q${e(T)??""}`),qt(be,e(ve)),p(V,de)},[()=>r()("clarify.custom_answer")]),se("change",be,()=>ie(e(T))),_(n,u)};I(pe,n=>{e(ce).length>0&&n(Ie)})}var Ye=l(pe,2);{var Me=n=>{var u=Ja();At(u),F(z=>st(u,"placeholder",z),[()=>r()("clarify.placeholder",{n:e(T)})]),pt(u,()=>v()[e(T)],z=>v(v()[e(T)]=z,!0)),_(n,u)};I(Ye,n=>{(e(ce).length===0||e(ve))&&n(Me)})}a(fe),F(n=>{p(ae,n),p($e,e(y).question)},[()=>r()("clarify.question",{n:e(T)})]),_(c,fe)});var O=l($,2),Y=s(O),C=s(Y);{var x=c=>{Ue(c,{size:14,class:"spin"})};I(C,c=>{N()==="submit"&&c(x)})}var b=l(C,2);it(b,{size:14});var i=l(b);a(Y);var o=l(Y,2),f=s(o);{var M=c=>{Ue(c,{size:14,class:"spin"})},ee=c=>{Mt(c,{size:14})};I(f,c=>{te()?c(M):c(ee,!1)})}var L=l(f);a(o);var w=l(o,2),J=s(w);ft(J,{size:14});var k=l(J);a(w),a(O),a(R),F((c,y,T,ce,ve,fe)=>{p(B,c),p(K,y),p(A,T),Y.disabled=N()==="submit",p(i,` ${ce??""}`),o.disabled=te(),p(L,` ${ve??""}`),w.disabled=!!N(),p(k,` ${fe??""}`)},[()=>r()("clarify.title"),()=>r()("clarify.subtitle"),()=>r()("clarify.persisted_hint"),()=>r()("clarify.submit"),()=>j()?r()("clarify.draft_saved"):r()("clarify.save_draft"),()=>r()("action.re_clarify")]),se("click",Y,function(...c){var y;(y=E())==null||y.apply(this,c)}),se("click",o,function(...c){var y;(y=Q())==null||y.apply(this,c)}),se("click",w,function(...c){var y;(y=G())==null||y.apply(this,c)}),_(q,R),Ee(),g()}lt(["change","click"]);var Ga=S('<span class="impl-badge-new svelte-ii1cle"> </span>'),Ya=S('<div><!> <span class="impl-file-name svelte-ii1cle"> </span> <!> <!></div>'),es=S('<button class="btn btn-primary" style="margin-top: 10px"><!> </button>'),ts=S('<p class="subtitle"> </p> <div class="impl-file-list svelte-ii1cle"></div> <!>',1),as=S('<div class="card" style="margin-top: 2rem"><h3> </h3> <!> <div class="alert alert-info" style="margin-top: 10px"> </div></div>');function ss(q,t){Re(t,!0);const r=()=>ye(Qe,"$t",D),[D,g]=Oe();let m=W(t,"stage",3,0),h=W(t,"filesMap",19,()=>({})),v=W(t,"appliedFiles",19,()=>({})),N=W(t,"onOpenDiff",3,(R,H)=>{}),te=W(t,"onApplyAll",3,()=>{}),j=Z(()=>Object.entries(h())),E=Z(()=>e(j).length>0&&e(j).every(([R])=>v()[R]));var Q=as(),G=s(Q),ne=s(G,!0);a(G);var P=l(G,2);{var re=R=>{var H=ts(),B=he(H),oe=s(B,!0);a(B);var K=l(B,2);He(K,21,()=>e(j),Ve,($,O)=>{var Y=Z(()=>Ft(e(O),2));let C=()=>e(Y)[0],x=()=>e(Y)[1];const b=Z(()=>!!v()[C()]);var i=Ya();let o;var f=s(i);Pt(f,{size:14});var M=l(f,2),ee=s(M,!0);a(M);var L=l(M,2);{var w=c=>{var y=Ga(),T=s(y,!0);a(y),F(ce=>p(T,ce),[()=>r()("fix.new")]),_(c,y)};I(L,c=>{x().is_new&&c(w)})}var J=l(L,2);{var k=c=>{it(c,{size:14,class:"impl-applied-icon"})};I(J,c=>{e(b)&&c(k)})}a(i),F(()=>{o=Pe(i,1,"impl-file-item svelte-ii1cle",null,o,{"impl-file-applied":e(b)}),p(ee,C())}),se("click",i,()=>N()(C(),x())),_($,i)}),a(K);var X=l(K,2);{var A=$=>{var O=es(),Y=s(O);Ct(Y,{size:14});var C=l(Y);a(O),F(x=>p(C,` ${x??""}`),[()=>r()("impl.apply_all")]),se("click",O,function(...x){var b;(b=te())==null||b.apply(this,x)}),_($,O)};I(X,$=>{e(E)||$(A)})}F($=>p(oe,$),[()=>r()("impl.files_generated")]),_(R,H)};I(P,R=>{e(j).length>0&&R(re)})}var ie=l(P,2),le=s(ie,!0);a(ie),a(Q),F((R,H)=>{p(ne,R),p(le,H)},[()=>r()("impl.stage_complete",{n:m()}),()=>r()("impl.review_hint")]),_(q,Q),Ee(),g()}lt(["click"]);var ns=S('<span class="badge-new svelte-txbq8e"> </span>'),ls=S('<div><!> <span class="file-name svelte-txbq8e"> </span> <!> <!></div>'),rs=S('<div class="file-list svelte-txbq8e"><div class="file-list-header svelte-txbq8e"> </div> <!></div>'),is=S('<div class="turn-label svelte-txbq8e"><!> </div> <div class="turn-text svelte-txbq8e"><!></div> <!>',1),os=S('<div class="user-overlay svelte-txbq8e"><button class="expand-btn svelte-txbq8e"> </button></div>'),vs=S('<div class="user-overlay user-overlay-hidden svelte-txbq8e"><button class="expand-btn svelte-txbq8e"> </button></div>'),cs=S('<div class="turn-label svelte-txbq8e"> </div> <div class="turn-body-user svelte-txbq8e"><div class="turn-text user-text svelte-txbq8e"> </div> <!></div> <!>',1),ds=S("<div><!></div>");function us(q,t){Re(t,!0);const r=()=>ye(Qe,"$t",D),[D,g]=Oe();let m=W(t,"turn",19,()=>({})),h=W(t,"index",3,0),v=W(t,"appliedFiles",19,()=>({})),N=W(t,"modelDisplay",3,""),te=W(t,"onOpenDiff",3,(R,H,B)=>{});function j(R){return R.replace(/```[\w./\\-]+\n[\s\S]*?```/g,"").trim()}let E=Z(()=>m().turnIndex??h()),Q=ue(null),G=ue(!1),ne=ue(!1);at(()=>{m().role==="user"&&e(Q)&&requestAnimationFrame(()=>{d(G,e(Q).scrollHeight>e(Q).clientHeight)})});var P=ds(),re=s(P);{var ie=R=>{var H=is(),B=he(H),oe=s(B);ua(oe,{size:14});var K=l(oe);a(B);var X=l(B,2),A=s(X);ia(A,()=>Jt(j(m().content))),a(X);var $=l(X,2);{var O=C=>{var x=rs(),b=s(x),i=s(b);a(b);var o=l(b,2);He(o,17,()=>Object.entries(m().files),Ve,(f,M)=>{var ee=Z(()=>Ft(e(M),2));let L=()=>e(ee)[0],w=()=>e(ee)[1];const J=Z(()=>{var ae;return!!((ae=v()[e(E)])!=null&&ae[L()])});var k=ls();let c;var y=s(k);Pt(y,{size:13});var T=l(y,2),ce=s(T,!0);a(T);var ve=l(T,2);{var fe=ae=>{var me=ns(),$e=s(me,!0);a(me),F(Te=>p($e,Te),[()=>r()("fix.new")]),_(ae,me)};I(ve,ae=>{w().is_new&&ae(fe)})}var ge=l(ve,2);{var we=ae=>{it(ae,{size:13,class:"applied-icon"})};I(ge,ae=>{e(J)&&ae(we)})}a(k),F(()=>{c=Pe(k,1,"file-item svelte-txbq8e",null,c,{"file-applied":e(J)}),p(ce,L())}),se("click",k,()=>te()(e(E),L(),w())),_(f,k)}),a(x),F(f=>p(i,`${f??""}:`),[()=>r()("fix.proposed_files")]),_(C,x)},Y=Z(()=>m().files&&Object.keys(m().files).length>0);I($,C=>{e(Y)&&C(O)})}F(C=>p(K,` ${C??""}`),[()=>N()||r()("fix.llm")]),_(R,H)},le=R=>{var H=cs(),B=he(H),oe=s(B,!0);a(B);var K=l(B,2),X=s(K),A=s(X,!0);a(X);var $=l(X,2);{var O=x=>{var b=os(),i=s(b),o=s(i,!0);a(i),a(b),F(f=>p(o,f),[()=>r()("fix.expand")]),se("click",i,()=>d(ne,!0)),_(x,b)};I($,x=>{e(G)&&!e(ne)&&x(O)})}a(K),Rt(K,x=>d(Q,x),()=>e(Q));var Y=l(K,2);{var C=x=>{var b=vs(),i=s(b),o=s(i,!0);a(i),a(b),F(f=>p(o,f),[()=>r()("fix.collapse")]),se("click",i,()=>d(ne,!1)),_(x,b)};I(Y,x=>{e(ne)&&x(C)})}F(x=>{p(oe,x),It(K,e(ne)?"max-height: none":""),p(A,m().content)},[()=>r()("fix.you")]),_(R,H)};I(re,R=>{m().role==="assistant"?R(ie):R(le,!1)})}a(P),F(()=>Pe(P,1,`turn turn-${m().role??""}`,"svelte-txbq8e")),_(q,P),Ee(),g()}lt(["click"]);var fs=S('<span class="model-info svelte-91p52o"><!> </span>'),ms=S('<button class="cancel-circle svelte-91p52o"><!></button>'),ps=S('<button class="send-circle svelte-91p52o"><!></button>'),_s=S('<div><textarea class="compose-input svelte-91p52o"></textarea> <div class="compose-bar svelte-91p52o"><div class="bar-spacer svelte-91p52o"></div> <!> <!></div></div> <div class="token-estimate svelte-91p52o"> </div>',1);function gs(q,t){Re(t,!0);const r=()=>ye(Qe,"$t",D),[D,g]=Oe();let m=W(t,"message",15,""),h=W(t,"loading",3,!1),v=W(t,"tokenDisplay",3,""),N=W(t,"modelDisplay",3,""),te=W(t,"onSend",3,()=>{}),j=W(t,"onCancel",3,()=>{}),E=ue(!1),Q=ue(null);function G(C){const x=C.target;x.style.height="auto",x.style.height=Math.min(x.scrollHeight,200)+"px"}function ne(){e(Q)&&(e(Q).style.height="auto")}function P(C){if(C.key==="Enter"){if(C.ctrlKey||C.metaKey)return;C.preventDefault(),re()}}function re(){te()(),ne()}var ie=_s(),le=he(ie);let R;var H=s(le);At(H),Rt(H,C=>d(Q,C),()=>e(Q));var B=l(H,2),oe=l(s(B),2);{var K=C=>{var x=fs(),b=s(x);oa(b,{size:11});var i=l(b);a(x),F(()=>p(i,` ${N()??""}`)),_(C,x)};I(oe,C=>{N()&&C(K)})}var X=l(oe,2);{var A=C=>{var x=ms(),b=s(x);ga(b,{size:12}),a(x),se("click",x,function(...i){var o;(o=j())==null||o.apply(this,i)}),_(C,x)},$=C=>{var x=ps(),b=s(x);da(b,{size:16}),a(x),F(i=>x.disabled=i,[()=>!m().trim()]),se("click",x,re),_(C,x)};I(X,C=>{h()?C(A):C($,!1)})}a(B),a(le);var O=l(le,2),Y=s(O,!0);a(O),F(C=>{R=Pe(le,1,"composebox svelte-91p52o",null,R,{"composebox-focus":e(E)}),st(H,"placeholder",C),H.disabled=h(),p(Y,v())},[()=>r()("fix.placeholder")]),se("keydown",H,P),kt("focus",H,()=>d(E,!0)),kt("blur",H,()=>d(E,!1)),se("input",H,G),pt(H,m),_(q,ie),Ee(),g()}lt(["keydown","input","click"]);var hs=S('<div class="fix-conversation svelte-1o3q2k6"><div class="turn turn-user skel-turn svelte-1o3q2k6"><div class="skel-label skel-pulse svelte-1o3q2k6" style="width: 3rem"></div> <div class="skel-body-user svelte-1o3q2k6"><div class="skel-line skel-pulse svelte-1o3q2k6" style="width: 90%"></div> <div class="skel-line skel-pulse svelte-1o3q2k6" style="width: 70%"></div></div></div> <div class="turn turn-assistant skel-turn svelte-1o3q2k6"><div class="skel-label skel-pulse svelte-1o3q2k6" style="width: 8rem"></div> <div class="skel-body-assistant svelte-1o3q2k6"><div class="skel-line skel-pulse svelte-1o3q2k6" style="width: 100%"></div> <div class="skel-line skel-pulse svelte-1o3q2k6" style="width: 95%"></div> <div class="skel-line skel-pulse svelte-1o3q2k6" style="width: 60%"></div> <div class="skel-line skel-pulse svelte-1o3q2k6" style="width: 85%"></div> <div class="skel-line skel-pulse svelte-1o3q2k6" style="width: 40%"></div></div> <div class="skel-file skel-pulse svelte-1o3q2k6"></div></div> <div class="turn turn-user skel-turn svelte-1o3q2k6"><div class="skel-label skel-pulse svelte-1o3q2k6" style="width: 3rem"></div> <div class="skel-body-user svelte-1o3q2k6"><div class="skel-line skel-pulse svelte-1o3q2k6" style="width: 80%"></div></div></div> <div class="turn turn-assistant skel-turn svelte-1o3q2k6"><div class="skel-label skel-pulse svelte-1o3q2k6" style="width: 8rem"></div> <div class="skel-body-assistant svelte-1o3q2k6"><div class="skel-line skel-pulse svelte-1o3q2k6" style="width: 100%"></div> <div class="skel-line skel-pulse svelte-1o3q2k6" style="width: 75%"></div> <div class="skel-line skel-pulse svelte-1o3q2k6" style="width: 90%"></div></div></div></div>'),xs=S('<div class="turn turn-assistant svelte-1o3q2k6"><div class="turn-label svelte-1o3q2k6"> </div> <div class="thinking svelte-1o3q2k6"><!> </div></div>'),bs=S('<div class="fix-conversation svelte-1o3q2k6"><!> <!></div>'),ys=S('<!> <!> <div class="fix-bar svelte-1o3q2k6"><!></div>',1);function ks(q,t){Re(t,!0);const r=()=>ye(Dt,"$page",m),D=()=>ye(wt,"$status",m),g=()=>ye(Qe,"$t",m),[m,h]=Oe();let v=W(t,"task",3,"");const N={constitution:null,architecture:"architect",adr:"architect",devplan:"architect",tasks:"coder",settings:null};let te=Z(()=>r().url.pathname.split("/").filter(Boolean)[0]||"dashboard");function j(k,c){var ce;if(!(k!=null&&k.config))return"—";const y=N[c],T=k.config;if(y&&((ce=T.roles)!=null&&ce[y])){const ve=T.roles[y];return`${ve.provider} / ${ve.model}`}return`${T.llm_provider} / ${T.llm_model}`}let E=Z(()=>j(D(),e(te))),Q=ue(""),G=ue(!1),ne=ue(!1),P=ue(nt([])),re=ue(0),ie=ue(!1),le=ue(nt({})),R=ue(null),H=ue(null);at(()=>{v()&&!e(ie)&&(d(ie,!0),K())}),at(()=>{e(P).length,e(G),B("smooth")});function B(k="instant"){requestAnimationFrame(()=>{const c=document.querySelector(".main");c&&c.scrollTo({top:c.scrollHeight,behavior:k})})}$t(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{B()})})});function oe(k){var y;const c=(y=k.detail)==null?void 0:y.message;c&&(d(Q,c,!0),B("smooth"))}$t(()=>{window.addEventListener("skaro:prefill-fix",oe)}),ra(()=>{window.removeEventListener("skaro:prefill-fix",oe)});async function K(){var k;d(ne,!0);try{const c=await Ne.loadFixConversation(v());((k=c.conversation)==null?void 0:k.length)>0&&d(P,c.conversation,!0),d(re,c.context_tokens||0,!0)}catch{}d(ne,!1)}let X=Z(()=>Math.round(e(P).reduce((k,c)=>{var y;return k+(((y=c.content)==null?void 0:y.length)||0)},0)/4)),A=Z(()=>Math.round(e(Q).length/4)),$=Z(()=>e(re)+e(X)+e(A)),O=Z(()=>{const k=e($)/1e3;return k>=1?`~${k.toFixed(0)}k ${g()("fix.tokens")}`:`~${e($)} ${g()("fix.tokens")}`});async function Y(){const k=e(Q).trim();if(!k||e(G))return;d(G,!0),d(Q,""),d(P,[...e(P),{role:"user",content:k}],!0);const c=new AbortController;d(H,c,!0);try{const y=e(P).slice(0,-1).map(ce=>({role:ce.role,content:ce.content})),T=await Ne.sendFix(v(),k,y,c.signal);T.success?(d(P,[...e(P),{role:"assistant",content:T.message,files:T.files||{},turnIndex:e(P).length}],!0),ke(g()("log.fix_response",{name:v()}))):ze(T.message||"Fix request failed","fix")}catch(y){y.name==="AbortError"?ke(g()("fix.cancelled")):ze(y.message,"sendFix")}d(H,null),d(G,!1)}function C(){e(H)&&e(H).abort()}async function x(k,c,y){try{const T=await Ne.applyFixFile(v(),c,y);T.success?(e(le)[k]||(e(le)[k]={}),e(le)[k][c]=!0,d(le,{...e(le)},!0),ke(g()("log.fix_applied",{file:c})),d(R,null)):ze(T.message,"applyFix")}catch(T){ze(T.message,"applyFix")}}function b(k,c,y){var T;d(R,{filepath:c,oldContent:y.old,newContent:y.new,isNew:y.is_new,applied:!!((T=e(le)[k])!=null&&T[c]),turnIndex:k},!0)}var i=ys(),o=he(i);{var f=k=>{var c=hs();_(k,c)},M=k=>{var c=bs(),y=s(c);He(y,17,()=>e(P),Ve,(ve,fe,ge)=>{us(ve,{get turn(){return e(fe)},index:ge,get appliedFiles(){return e(le)},get modelDisplay(){return e(E)},onOpenDiff:b})});var T=l(y,2);{var ce=ve=>{var fe=xs(),ge=s(fe),we=s(ge,!0);a(ge);var ae=l(ge,2),me=s(ae);Ue(me,{size:14,class:"spin"});var $e=l(me);a(ae),a(fe),F((Te,Le)=>{p(we,Te),p($e,` ${Le??""}`)},[()=>e(E)||g()("fix.llm"),()=>g()("fix.thinking")]),_(ve,fe)};I(T,ve=>{e(G)&&ve(ce)})}a(c),_(k,c)};I(o,k=>{e(ne)?k(f):e(P).length>0&&k(M,1)})}var ee=l(o,2);{var L=k=>{Et(k,{get filepath(){return e(R).filepath},get oldContent(){return e(R).oldContent},get newContent(){return e(R).newContent},get isNew(){return e(R).isNew},get applied(){return e(R).applied},onApply:()=>x(e(R).turnIndex,e(R).filepath,e(R).newContent),onClose:()=>d(R,null)})};I(ee,k=>{e(R)&&k(L)})}var w=l(ee,2),J=s(w);gs(J,{get loading(){return e(G)},get tokenDisplay(){return e(O)},get modelDisplay(){return e(E)},onSend:Y,onCancel:C,get message(){return e(Q)},set message(k){d(Q,k,!0)}}),a(w),_(q,i),Ee(),h()}var ws=S('<pre class="cmd-pre svelte-1ax5xd4"> </pre>'),Cs=S('<pre class="cmd-pre cmd-stderr svelte-1ax5xd4"> </pre>'),Ns=S('<span class="cmd-empty svelte-1ax5xd4"> </span>'),zs=S('<div class="cmd-output svelte-1ax5xd4"><!> <!> <!></div>'),Ss=S('<div><div class="cmd-header svelte-1ax5xd4"><!> <!> <span class="cmd-name svelte-1ax5xd4"> </span> <code class="cmd-code svelte-1ax5xd4"> </code> <span class="cmd-exit svelte-1ax5xd4"> </span> <!></div> <!></div>'),qs=S('<div><!> <span class="check-label svelte-1ax5xd4"> </span> <span class="check-detail svelte-1ax5xd4"> </span></div>'),$s=S('<button class="btn-icon svelte-1ax5xd4"><!></button>'),Ts=S('<div class="cmd-edit-row svelte-1ax5xd4"><input class="cmd-input cmd-input-name svelte-1ax5xd4"/> <input class="cmd-input cmd-input-cmd svelte-1ax5xd4"/> <button class="btn-icon btn-danger svelte-1ax5xd4" title="Remove"><!></button></div>'),As=S('<div class="cmd-editor svelte-1ax5xd4"><!> <div class="cmd-edit-actions svelte-1ax5xd4"><button class="btn btn-sm svelte-1ax5xd4"><!> </button> <div class="cmd-edit-right svelte-1ax5xd4"><button class="btn btn-sm svelte-1ax5xd4"> </button> <button class="btn btn-sm btn-primary svelte-1ax5xd4"><!> </button></div></div></div>'),Fs=S('<div class="commands svelte-1ax5xd4"></div>'),Ds=S('<div class="hint svelte-1ax5xd4"> </div>'),Is=S('<div class="tests-section svelte-1ax5xd4"><h4 class="section-title svelte-1ax5xd4"> </h4> <div class="commands svelte-1ax5xd4"></div></div>'),Ms=S('<button class="btn btn-primary"><!> </button>'),Ps=S('<button class="btn btn-success svelte-1ax5xd4"><!> </button>'),Rs=S('<div class="tests-section svelte-1ax5xd4"><h4 class="section-title svelte-1ax5xd4"> </h4> <div class="check-list svelte-1ax5xd4"></div></div> <div class="tests-section svelte-1ax5xd4"><div class="section-header svelte-1ax5xd4"><h4 class="section-title svelte-1ax5xd4"> </h4> <!></div> <!></div> <!> <div><!> <span> </span></div> <div class="tests-actions svelte-1ax5xd4"><!> <button class="btn"><!> </button> <!></div>',1),Es=S('<div class="tests-empty svelte-1ax5xd4"><p> </p></div>'),Os=S('<div class="tests-panel svelte-1ax5xd4"><!></div>');function Ls(q,t){Re(t,!0);const r=()=>ye(Qe,"$t",D),[D,g]=Oe(),m=(b,i=dt,o=dt,f=dt,M=dt)=>{var ee=Ss();let L;var w=s(ee),J=s(w);{var k=pe=>{Ct(pe,{size:15,class:"icon-pass"})},c=pe=>{Tt(pe,{size:15,class:"icon-fail"})};I(J,pe=>{i().success?pe(k):pe(c,!1)})}var y=l(J,2);ha(y,{size:13});var T=l(y,2),ce=s(T,!0);a(T);var ve=l(T,2),fe=s(ve,!0);a(ve);var ge=l(ve,2),we=s(ge);a(ge);var ae=l(ge,2);{var me=pe=>{Ut(pe,{size:14})},$e=pe=>{la(pe,{size:14})};I(ae,pe=>{e(G)[o()]?pe(me):pe($e,!1)})}a(w);var Te=l(w,2);{var Le=pe=>{var Ie=zs(),Ye=s(Ie);{var Me=Ce=>{var be=ws(),U=s(be,!0);a(be),F(()=>p(U,i().stdout)),_(Ce,be)};I(Ye,Ce=>{i().stdout&&Ce(Me)})}var n=l(Ye,2);{var u=Ce=>{var be=Cs(),U=s(be,!0);a(be),F(()=>p(U,i().stderr)),_(Ce,be)};I(n,Ce=>{i().stderr&&Ce(u)})}var z=l(n,2);{var Ae=Ce=>{var be=Ns(),U=s(be,!0);a(be),F(V=>p(U,V),[()=>r()("tests.no_output")]),_(Ce,be)};I(z,Ce=>{!i().stdout&&!i().stderr&&Ce(Ae)})}a(Ie),_(pe,Ie)};I(Te,pe=>{e(G)[o()]&&pe(Le)})}a(ee),F(()=>{L=Pe(ee,1,"cmd-item svelte-1ax5xd4",null,L,{"cmd-pass":i().success,"cmd-fail":!i().success}),p(ce,i().name),p(fe,i().command),p(we,`exit ${i().exit_code??""}`)}),se("click",w,()=>R(f(),M())),_(b,ee)};let h=W(t,"taskName",3,""),v=W(t,"results",3,null),N=W(t,"loading",3,!1),te=W(t,"confirmed",3,!1),j=W(t,"onRunTests",3,()=>{}),E=W(t,"onConfirm",3,()=>{}),Q=W(t,"onSendToLlm",3,()=>{}),G=ue(nt({})),ne=ue(!1),P=ue(nt([])),re=ue(!1),ie=Z(()=>v()&&!v().passed),le=Z(()=>v()!==null);function R(b,i){const o=`${b}-${i}`;e(G)[o]=!e(G)[o],d(G,{...e(G)},!0)}async function H(){var b;try{const i=await Ne.getVerifyCommands(h());d(P,(i.commands||[]).map(o=>({...o})),!0)}catch{d(P,(((b=v())==null?void 0:b.task_commands)||[]).map(i=>({name:i.name,command:i.command})),!0)}d(ne,!0)}function B(){d(P,[...e(P),{name:"",command:""}],!0)}function oe(b){d(P,e(P).filter((i,o)=>o!==b),!0)}async function K(){const b=e(P).filter(i=>i.command.trim());d(re,!0);try{await Ne.saveVerifyCommands(h(),b),ke(r()("tests.commands_saved")),d(ne,!1)}catch(i){ze(i.message,"saveVerifyCommands")}d(re,!1)}function X(){d(ne,!1),d(P,[],!0)}function A(){if(!v())return"";const b=[];for(const i of v().checklist||[])i.passed||b.push(`[FAIL] ${i.label}: ${i.detail}`);for(const i of[...v().task_commands||[],...v().global_commands||[]])if(!i.success){const o=(i.stderr||i.stdout||"").trim(),f=o.length>2e3?o.slice(-2e3):o;b.push(`[FAIL] ${i.name} (${i.command})
Exit code: ${i.exit_code}
${f}`)}return b.join(`

---

`)}function $(){Q()(A())}var O=Os(),Y=s(O);{var C=b=>{var i=Rs(),o=he(i),f=s(o),M=s(f,!0);a(f);var ee=l(f,2);He(ee,21,()=>v().checklist,Ve,(U,V)=>{var de=qs();let xe;var _e=s(de);{var Se=De=>{Ct(De,{size:15,class:"icon-pass"})},je=De=>{Tt(De,{size:15,class:"icon-fail"})};I(_e,De=>{e(V).passed?De(Se):De(je,!1)})}var Fe=l(_e,2),qe=s(Fe,!0);a(Fe);var et=l(Fe,2),tt=s(et,!0);a(et),a(de),F(()=>{xe=Pe(de,1,"check-item svelte-1ax5xd4",null,xe,{pass:e(V).passed,fail:!e(V).passed}),p(qe,e(V).label),p(tt,e(V).detail)}),_(U,de)}),a(ee),a(o);var L=l(o,2),w=s(L),J=s(w),k=s(J,!0);a(J);var c=l(J,2);{var y=U=>{var V=$s(),de=s(V);na(de,{size:13}),a(V),F(xe=>st(V,"title",xe),[()=>r()("tests.edit_commands")]),se("click",V,H),_(U,V)};I(c,U=>{e(ne)||U(y)})}a(w);var T=l(w,2);{var ce=U=>{var V=As(),de=s(V);He(de,17,()=>e(P),Ve,(Be,rt,xt)=>{var bt=Ts(),vt=s(bt);mt(vt);var ct=l(vt,2);mt(ct);var yt=l(ct,2),Ot=s(yt);Bt(Ot,{size:13}),a(yt),a(bt),F((ot,Lt)=>{st(vt,"placeholder",ot),st(ct,"placeholder",Lt)},[()=>r()("tests.cmd_name_placeholder"),()=>r()("tests.cmd_command_placeholder")]),pt(vt,()=>e(rt).name,ot=>e(rt).name=ot),pt(ct,()=>e(rt).command,ot=>e(rt).command=ot),se("click",yt,()=>oe(xt)),_(Be,bt)});var xe=l(de,2),_e=s(xe),Se=s(_e);va(Se,{size:13});var je=l(Se);a(_e);var Fe=l(_e,2),qe=s(Fe),et=s(qe,!0);a(qe);var tt=l(qe,2),De=s(tt);{var _t=Be=>{Ue(Be,{size:13,class:"spin"})},gt=Be=>{Mt(Be,{size:13})};I(De,Be=>{e(re)?Be(_t):Be(gt,!1)})}var ht=l(De);a(tt),a(Fe),a(xe),a(V),F((Be,rt,xt)=>{p(je,` ${Be??""}`),p(et,rt),tt.disabled=e(re),p(ht,` ${xt??""}`)},[()=>r()("tests.add_command"),()=>r()("tests.cancel"),()=>r()("tests.save_commands")]),se("click",_e,B),se("click",qe,X),se("click",tt,K),_(U,V)},ve=U=>{var V=Fs();He(V,21,()=>v().task_commands,Ve,(de,xe,_e)=>{const Se=Z(()=>`task-${_e}`);m(de,()=>e(xe),()=>e(Se),()=>"task",()=>_e)}),a(V),_(U,V)},fe=U=>{var V=Ds(),de=s(V,!0);a(V),F(xe=>p(de,xe),[()=>r()("tests.no_task_commands")]),_(U,V)};I(T,U=>{e(ne)?U(ce):v().task_commands&&v().task_commands.length>0?U(ve,1):U(fe,!1)})}a(L);var ge=l(L,2);{var we=U=>{var V=Is(),de=s(V),xe=s(de,!0);a(de);var _e=l(de,2);He(_e,21,()=>v().global_commands,Ve,(Se,je,Fe)=>{const qe=Z(()=>`global-${Fe}`);m(Se,()=>e(je),()=>e(qe),()=>"global",()=>Fe)}),a(_e),a(V),F(Se=>p(xe,Se),[()=>r()("tests.global_commands_title")]),_(U,V)};I(ge,U=>{v().global_commands&&v().global_commands.length>0&&U(we)})}var ae=l(ge,2);let me;var $e=s(ae);fa($e,{size:16});var Te=l($e,2),Le=s(Te,!0);a(Te),a(ae);var pe=l(ae,2),Ie=s(pe);{var Ye=U=>{var V=Ms(),de=s(V);_a(de,{size:14});var xe=l(de);a(V),F(_e=>p(xe,` ${_e??""}`),[()=>r()("tests.send_to_llm")]),se("click",V,$),_(U,V)};I(Ie,U=>{e(ie)&&U(Ye)})}var Me=l(Ie,2),n=s(Me);{var u=U=>{Ue(U,{size:14,class:"spin"})},z=U=>{Xt(U,{size:14})};I(n,U=>{N()?U(u):U(z,!1)})}var Ae=l(n);a(Me);var Ce=l(Me,2);{var be=U=>{var V=Ps(),de=s(V);it(de,{size:14});var xe=l(de);a(V),F(_e=>p(xe,` ${_e??""}`),[()=>r()("tests.confirm")]),se("click",V,function(..._e){var Se;(Se=E())==null||Se.apply(this,_e)}),_(U,V)};I(Ce,U=>{te()||U(be)})}a(pe),F((U,V,de,xe)=>{p(M,U),p(k,V),me=Pe(ae,1,"tests-summary svelte-1ax5xd4",null,me,{"summary-pass":v().passed,"summary-fail":!v().passed}),p(Le,de),Me.disabled=N(),p(Ae,` ${xe??""}`)},[()=>r()("tests.checklist_title"),()=>r()("tests.task_commands_title"),()=>v().passed?r()("tests.all_passed"):r()("tests.has_failures"),()=>r()("tests.rerun")]),se("click",Me,function(...U){var V;(V=j())==null||V.apply(this,U)}),_(b,i)},x=b=>{var i=Es(),o=s(i),f=s(o,!0);a(o),a(i),F(M=>p(f,M),[()=>r()("tests.not_run_yet")]),_(b,i)};I(Y,b=>{e(le)?b(C):b(x,!1)})}a(O),_(q,O),Ee(),g()}lt(["click"]);var js=S('<div class="detail page-with-tabs svelte-s6dbrt"><!> <!> <!> <!> <!> <!></div>');function Bs(q,t){Re(t,!0);const r=()=>ye(ut,"$taskDetail",N),D=()=>ye(wt,"$status",N),g=()=>ye(Qe,"$t",N),m=()=>ye(Nt,"$lastImplementResult",N),h=()=>ye(St,"$lastImplementTask",N),v=()=>ye(zt,"$lastImplementStage",N),[N,te]=Oe();let j=ue(""),E=ue(""),Q=ue(""),G=ue(nt({})),ne=ue(!1),P=ue(!1),re=ue(nt({})),ie=ue(null),le=ue(null),R=!1,H=ue("");at(()=>{t.taskName,d(j,""),d(E,""),d(Q,""),d(G,{},!0),d(ne,!1),d(P,!1),d(re,{},!0),d(ie,null),d(le,null),R=!1,d(H,"")});let B=Z(r),oe=Z(()=>{var n,u;return((u=(n=D())==null?void 0:n.tasks)==null?void 0:u.find(z=>z.name===t.taskName))??null}),K=Z(()=>{var n,u,z;return((n=e(oe))==null?void 0:n.current_stage)??((z=(u=e(B))==null?void 0:u.state)==null?void 0:z.current_stage)??0}),X=Z(()=>{var n,u,z;return((n=e(oe))==null?void 0:n.total_stages)??((z=(u=e(B))==null?void 0:u.state)==null?void 0:z.total_stages)??0}),A=Z(()=>{var n,u,z;return((n=e(oe))==null?void 0:n.phases)??((z=(u=e(B))==null?void 0:u.state)==null?void 0:z.phases)??{}}),$=Z(()=>{var n,u,z;return((n=e(oe))==null?void 0:n.current_phase)??((z=(u=e(B))==null?void 0:u.state)==null?void 0:z.current_phase)??""}),O=Z(()=>e(A).tests==="complete");at(()=>{var n,u,z;if(((n=e(B))==null?void 0:n.name)===t.taskName&&((z=(u=e(B))==null?void 0:u.files)!=null&&z["tests.json"])&&!e(le))try{d(le,JSON.parse(e(B).files["tests.json"]),!0)}catch{}});let Y=Z(()=>{var n,u;return((u=(n=e(B))==null?void 0:n.files)==null?void 0:u["clarifications.md"])||""}),C=Z(()=>e(Y)?Wt(e(Y)):[]),x=Z(()=>e(C).length>0),b=Z(()=>e(x)&&e(C).some(n=>!n.answer.trim()));at(()=>{const n=e(C).map(u=>`${u.num}:${u.answer.length}`).join(",");if(e(x)&&n!==e(H)){d(H,n,!0);const u={};for(const z of e(C))u[z.num]=z.answer||"";d(G,u,!0),d(P,!1)}});let i=Z(()=>{if(!e(B))return[];const n=[];return e(B).files["spec.md"]&&n.push({id:"spec.md",label:g()("tab.specification")}),e(B).files["clarifications.md"]&&!e(b)&&n.push({id:"clarifications.md",label:g()("tab.clarifications")}),e(B).files["plan.md"]&&n.push({id:"plan.md",label:g()("tab.plan")}),e(B).files["tasks.md"]&&n.push({id:"tasks.md",label:g()("tab.tasks")}),Object.keys(e(B).stages||{}).map(Number).sort((u,z)=>u-z).forEach(u=>n.push({id:`stage-${u}`,label:g()("tab.stage_notes",{n:u})})),(e(le)||e(A).tests==="in_progress"||e(A).tests==="complete")&&n.push({id:"tests",label:g()("tab.tests")}),e(K)>0&&n.push({id:"chat",label:g()("tab.chat")}),n});at(()=>{e(i).length>0&&!R&&(R=!0,d(Q,e(i)[0].id,!0))});let o=Z(()=>{var u,z,Ae;if(!e(B))return"";const n=e(Q)||((u=e(i)[e(i).length-1])==null?void 0:u.id)||"";return n==="chat"||n==="tests"?"":n.startsWith("stage-")?((z=e(B).stages)==null?void 0:z[n.replace("stage-","")])||"":((Ae=e(B).files)==null?void 0:Ae[n])||""});async function f(){d(E,"clarify"),d(j,""),ke(g()("log.clarify_run",{name:t.taskName}));try{const n=await Ne.runClarify(t.taskName);n.success?(ke(g()("log.clarify_questions_saved")),d(H,""),await fe()):ve(n)}catch(n){ze(n.message,"runClarify"),d(j,n.message,!0)}d(E,"")}async function M(){if(e(x)){d(ne,!0);try{const n=e(C).map(u=>({num:u.num,question:u.question,context:u.context||"",options:u.options||[],answer:e(G)[u.num]||""}));await Ne.saveClarifyDraft(t.taskName,n),d(P,!0),ke(g()("log.clarify_draft_saved",{name:t.taskName})),setTimeout(()=>{d(P,!1)},2e3)}catch(n){ze(n.message,"saveDraft")}d(ne,!1)}}async function ee(){const n=Object.entries(e(G)).filter(([,u])=>u.trim());if(n.length===0){ke(g()("clarify.no_answers"));return}d(E,"submit");try{await Ne.answerClarify(t.taskName,{questions:e(Y),answers:Object.fromEntries(n)}),ke(g()("log.clarify_done",{name:t.taskName})),d(G,{},!0),d(H,""),await fe()}catch(u){ze(u.message,"submitClarify"),d(j,u.message,!0)}d(E,"")}async function L(){var n;d(E,"plan"),d(j,""),ke(g()("log.plan_run",{name:t.taskName}));try{const u=await Ne.runPlan(t.taskName);u.success?(ke(g()("log.plan_done",{n:((n=u.data)==null?void 0:n.stage_count)||"?"})),await fe()):ve(u)}catch(u){ze(u.message,"runPlan"),d(j,u.message,!0)}d(E,"")}async function w(){var u;const n=e(K)+1;d(E,"implement"),d(j,""),ke(g()("log.impl_run",{name:t.taskName,n}));try{const z=await Ne.runImplement(t.taskName,{stage:n});z.success?(d(re,{},!0),Nt.set(z),zt.set(n),St.set(t.taskName),ke(g()("log.impl_done",{n,files:Object.keys(((u=z.data)==null?void 0:u.files)||{}).length})),await fe(),d(Q,`stage-${n}`)):ve(z)}catch(z){ze(z.message,"runImplement"),d(j,z.message,!0)}d(E,"")}async function J(){d(E,"tests"),d(j,""),ke(g()("log.tests_run",{name:t.taskName}));try{const n=await Ne.runTests(t.taskName);n.success?(d(le,n.data,!0),ke(g()("log.tests_done",{name:t.taskName})),await fe(),d(Q,"tests")):ve(n)}catch(n){ze(n.message,"runTests"),d(j,n.message,!0)}d(E,"")}async function k(){try{const n=await Ne.confirmTests(t.taskName);n.success?(ke(g()("log.tests_confirmed",{name:t.taskName})),await fe()):ve(n)}catch(n){ze(n.message,"confirmTests")}}function c(n){d(Q,"chat"),setTimeout(()=>{window.dispatchEvent(new CustomEvent("skaro:prefill-fix",{detail:{message:n}}))},100)}function y(n,u){d(ie,{filepath:n,oldContent:u.old,newContent:u.new,isNew:u.is_new,applied:!!e(re)[n]},!0)}async function T(n,u){try{const z=await Ne.applyImplementFile(t.taskName,n,u);z.success?(e(re)[n]=!0,d(re,{...e(re)},!0),ke(g()("log.fix_applied",{file:n})),d(ie,null)):ze(z.message,"applyImplFile")}catch(z){ze(z.message,"applyImplFile")}}async function ce(n){for(const[u,z]of Object.entries(n))e(re)[u]||await T(u,z.new)}function ve(n){ze(n.message||g()("error.unknown"),n.error_type||""),d(j,n.message||g()("error.unknown"),!0)}async function fe(){Ht("status",`task:${t.taskName}`),wt.set(await Ne.getStatus()),t.taskName&&ut.set(await Ne.getTask(t.taskName))}function ge(){ut.set(null),Qt("/tasks")}var we=js(),ae=s(we);Ma(ae,{get taskName(){return t.taskName},get phases(){return e(A)},get currentPhase(){return e($)},get currentStage(){return e(K)},get totalStages(){return e(X)},onBack:ge});var me=l(ae,2);Ha(me,{get phases(){return e(A)},get currentStage(){return e(K)},get totalStages(){return e(X)},get actionLoading(){return e(E)},get hasUnanswered(){return e(b)},onClarify:f,onPlan:L,onImplement:w,onTests:J});var $e=l(me,2);{var Te=n=>{Za(n,{get parsedQA(){return e(C)},get actionLoading(){return e(E)},get draftSaving(){return e(ne)},get draftSaved(){return e(P)},onSubmit:ee,onSaveDraft:M,onReClarify:f,get clarifyAnswers(){return e(G)},set clarifyAnswers(u){d(G,u,!0)}})};I($e,n=>{e(b)&&n(Te)})}var Le=l($e,2);{var pe=n=>{{let u=Z(()=>{var z;return((z=m().data)==null?void 0:z.files)||{}});ss(n,{get stage(){return v()},get filesMap(){return e(u)},get appliedFiles(){return e(re)},onOpenDiff:y,onApplyAll:()=>{var z;return ce(((z=m().data)==null?void 0:z.files)||{})}})}};I(Le,n=>{m()&&h()===t.taskName&&n(pe)})}var Ie=l(Le,2);{var Ye=n=>{Et(n,{get filepath(){return e(ie).filepath},get oldContent(){return e(ie).oldContent},get newContent(){return e(ie).newContent},get isNew(){return e(ie).isNew},get applied(){return e(ie).applied},onApply:()=>T(e(ie).filepath,e(ie).newContent),onClose:()=>d(ie,null)})};I(Ie,n=>{e(ie)&&n(Ye)})}var Me=l(Ie,2);Zt(Me,{get tabs(){return e(i)},get activeTab(){return e(Q)},get content(){return e(o)},onSelectTab:z=>d(Q,z,!0),chatSlot:z=>{ks(z,{get task(){return t.taskName}})},testsSlot:z=>{{let Ae=Z(()=>e(E)==="tests");Ls(z,{get taskName(){return t.taskName},get results(){return e(le)},get loading(){return e(Ae)},get confirmed(){return e(O)},onRunTests:J,onConfirm:k,onSendToLlm:c})}},$$slots:{chatSlot:!0,testsSlot:!0}}),a(we),_(q,we),Ee(),te()}function gn(q,t){Re(t,!0);const r=()=>ye(Dt,"$page",D),[D,g]=Oe();let m=Z(()=>decodeURIComponent(r().params.name));at(()=>{e(m)&&h(e(m))});async function h(v){try{ut.set(await Vt(`task:${v}`,()=>Ne.getTask(v)))}catch(N){ze(N.message,"loadTaskDetail")}}Bs(q,{get taskName(){return e(m)}}),Ee(),g()}export{gn as component};
