import{a as ve,s as o,b as r,d as p,r as t,e as g,g as d,f as j,h as _,j as i,k as ie,l as E,m as le,n as ne,o as I,q as O,u as c,A as z,v as de}from"./index-Bkuhln3H.js";var ce=c('<span class="category-badge svelte-422x0j"> </span>'),pe=c('<li class="svelte-422x0j"> </li>'),_e=c('<div class="audit-warnings svelte-422x0j"><strong>Warnings:</strong> <ul class="svelte-422x0j"></ul></div>'),fe=c('<div class="overwrite-notice svelte-422x0j">This file already exists and will be overwritten.</div>'),ue=c('<div class="file-description svelte-422x0j"> </div>'),xe=c('<div class="action-buttons svelte-422x0j"><button class="btn-approve svelte-422x0j"> </button> <button class="btn-reject svelte-422x0j"> </button></div>'),ge=c('<div class="status-approved svelte-422x0j"> </div>'),je=c('<div class="status-rejected svelte-422x0j">&#10007; Rejected</div>'),be=c('<div class="status-error svelte-422x0j"> </div>'),he=c('<div class="file-proposal svelte-422x0j"><div class="file-header svelte-422x0j"><span class="file-icon svelte-422x0j">&#128196;</span> <span class="file-path svelte-422x0j"> </span> <!></div> <!> <!> <div class="code-preview svelte-422x0j"><pre class="svelte-422x0j"><code class="svelte-422x0j"> </code></pre></div> <!> <!></div>');function we(G,q){ve(q,!0);let n=E("pending"),f=E(!1),h=E("");const v=q.result.data??{},w=v.proposal_id;w||(o(n,"error"),o(h,"Invalid proposal data — missing proposal ID"));async function H(){o(f,!0);try{const e=await fetch(`${z}/files/sandbox/${w}/approve`,{method:"POST"});if(!e.ok)throw new Error(await e.text());o(n,"approved")}catch(e){o(h,e instanceof Error?e.message:"Failed to approve",!0),o(n,"error")}finally{o(f,!1)}}async function J(){o(f,!0);try{const e=await fetch(`${z}/files/sandbox/${w}/reject`,{method:"POST"});e.ok?o(n,"rejected"):(o(h,`Reject may not have been saved server-side (${e.status})`),o(n,"error"))}catch(e){console.error(`Failed to reject proposal ${w}:`,e),o(h,"Network error — proposal may still exist server-side"),o(n,"error")}finally{o(f,!1)}}const K={plugins:"Plugin",scripts:"Script",config:"Config",tools:"Tool"};var k=he(),A=r(k),P=p(r(A),2),L=r(P,!0);t(P);var M=p(P,2);{var Q=e=>{var a=ce(),s=r(a,!0);t(a),j(()=>_(s,K[v.category]??v.category)),i(e,a)};g(M,e=>{v.category&&e(Q)})}t(A);var B=p(A,2);{var U=e=>{var a=_e(),s=p(r(a),2);le(s,21,()=>v.audit_warnings,ne,(m,u)=>{var l=pe(),x=r(l,!0);t(l),j(()=>_(x,d(u))),i(m,l)}),t(s),t(a),i(e,a)};g(B,e=>{v.audit_warnings&&v.audit_warnings.length>0&&e(U)})}var C=p(B,2);{var V=e=>{var a=fe();i(e,a)};g(C,e=>{v.file_exists&&e(V)})}var R=p(C,2),D=r(R),N=r(D),X=r(N,!0);t(N),t(D),t(R);var W=p(R,2);{var Y=e=>{var a=ue(),s=r(a,!0);t(a),j(()=>_(s,v.description)),i(e,a)};g(W,e=>{v.description&&e(Y)})}var Z=p(W,2);{var $=e=>{var a=xe(),s=r(a);s.__click=H;var m=r(s,!0);t(s);var u=p(s,2);u.__click=J;var l=r(u,!0);t(u),t(a),j(()=>{s.disabled=d(f),_(m,d(f)?"Approving...":"Approve"),u.disabled=d(f),_(l,d(f)?"Rejecting...":"Reject")}),i(e,a)},ee=e=>{var a=I(),s=O(a);{var m=l=>{var x=ge(),F=r(x);t(x),j(()=>_(F,`✓ File written to ${v.target_path??""}`)),i(l,x)},u=l=>{var x=I(),F=O(x);{var ae=b=>{var y=je();i(b,y)},te=b=>{var y=I(),re=O(y);{var se=S=>{var T=be(),oe=r(T,!0);t(T),j(()=>_(oe,d(h))),i(S,T)};g(re,S=>{d(n)==="error"&&S(se)},!0)}i(b,y)};g(F,b=>{d(n)==="rejected"?b(ae):b(te,!1)},!0)}i(l,x)};g(s,l=>{d(n)==="approved"?l(m):l(u,!1)},!0)}i(e,a)};g(Z,e=>{d(n)==="pending"?e($):e(ee,!1)})}t(k),j(()=>{_(L,v.target_path),_(X,v.content)}),i(G,k),ie()}de(["click"]);export{we as default};
