import{o as e}from"./chunk-CFjPhJqf.js";import{a as t,i as n,o as r,r as i,t as a}from"./compiler-runtime-Cs91PcD2.js";import{t as o}from"./button-B_6r-4tt.js";import{a as s,c,i as l,n as u,o as d,s as f,t as p,y as m}from"./dialog-uNuZn7gJ.js";import{t as h}from"./checkbox-qnHi6HI6.js";import{t as g}from"./label-DLO_wxY0.js";import{n as _}from"./mcp-consent-store-CijO54Jd.js";var v=a(),y=e(t(),1),b=r();function x(e){let t=new Set;for(let n of e)n.detected&&t.add(n.id);return t}function S(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function C(e,t){let n=[];for(let r of t)e.has(r.id)&&n.push(r.id);return n}var w={error:e=>m.error(e)};function T(e){let t=(0,v.c)(9),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{store:r,toast:i,payload:a}=n,o=r===void 0?_:r,s=i===void 0?w:i,c;t[2]!==a||t[3]!==o?(c=a??o.getSnapshot(),t[2]=a,t[3]=o,t[4]=c):c=t[4];let l=c;if(!l)return null;let u;return t[5]!==l||t[6]!==o||t[7]!==s?(u=(0,b.jsx)(E,{payload:l,store:o,toast:s}),t[5]=l,t[6]=o,t[7]=s,t[8]=u):u=t[8],u}function E(e){let t=(0,v.c)(52),{payload:r,store:a,toast:m}=e,{_}=n(),w=r.detectedEditors,T;t[0]===w?T=t[1]:(T=()=>x(w),t[0]=w,t[1]=T);let[E,D]=(0,y.useState)(T),[O,k]=(0,y.useState)(!1),A=(0,y.useId)(),j;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(j=function(e){D(t=>S(t,e))},t[2]=j):j=t[2];let M=j,N;t[3]!==w||t[4]!==E||t[5]!==a||t[6]!==m?(N=async function(){k(!0);let e=await a.confirm(C(E,w));e.ok||(m.error(e.error),k(!1))},t[3]=w,t[4]=E,t[5]=a,t[6]=m,t[7]=N):N=t[7];let P=N,F;t[8]!==a||t[9]!==m?(F=async function(){k(!0);let e=await a.skip();e.ok||(m.error(e.error),k(!1))},t[8]=a,t[9]=m,t[10]=F):F=t[10];let I=F,L;t[11]!==O||t[12]!==I?(L=function(e){!e&&!O&&I()},t[11]=O,t[12]=I,t[13]=L):L=t[13];let R=L,z;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,b.jsx)(c,{children:(0,b.jsx)(i,{id:`C0NPNd`})}),t[14]=z):z=t[14];let B;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,b.jsxs)(f,{children:[z,(0,b.jsx)(s,{children:(0,b.jsx)(i,{id:`AThCb_`,components:{0:(0,b.jsx)(`code`,{}),1:(0,b.jsx)(`code`,{}),2:(0,b.jsx)(`code`,{}),3:(0,b.jsx)(`code`,{})}})})]}),t[15]=B):B=t[15];let V;if(t[16]!==_||t[17]!==O||t[18]!==w||t[19]!==A||t[20]!==E){let e;t[22]!==_||t[23]!==O||t[24]!==A||t[25]!==E?(e=e=>{let t=E.has(e.id),n=`${A}-${e.id}`,r=e.willReplace?_({id:`hA8GQ6`}):e.detected?_({id:`bBE5tC`}):_({id:`yu8Pzy`}),i=e.willReplace?`text-xs text-amber-600 dark:text-amber-400`:`text-xs text-muted-foreground`;return(0,b.jsx)(`li`,{children:(0,b.jsxs)(g,{htmlFor:n,className:`flex cursor-pointer items-start gap-2.5 px-3 py-2.5 font-normal hover:bg-accent`,children:[(0,b.jsx)(h,{id:n,checked:t,disabled:O,onCheckedChange:()=>M(e.id),className:`mt-0.5`,"data-testid":`mcp-consent-checkbox-${e.id}`}),(0,b.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,b.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.label}),(0,b.jsx)(`span`,{className:i,"data-testid":`mcp-consent-status-${e.id}`,children:r})]})]})},e.id)},t[22]=_,t[23]=O,t[24]=A,t[25]=E,t[26]=e):e=t[26],V=w.map(e),t[16]=_,t[17]=O,t[18]=w,t[19]=A,t[20]=E,t[21]=V}else V=t[21];let H;t[27]===V?H=t[28]:(H=(0,b.jsx)(u,{children:(0,b.jsx)(`ul`,{className:`rounded-md border border-border bg-card/50 divide-y divide-border overflow-hidden`,children:V})}),t[27]=V,t[28]=H);let U;t[29]===I?U=t[30]:(U=()=>void I(),t[29]=I,t[30]=U);let W;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,b.jsx)(i,{id:`6Uau97`}),t[31]=W):W=t[31];let G;t[32]!==O||t[33]!==U?(G=(0,b.jsx)(o,{variant:`outline`,className:`font-mono uppercase`,onClick:U,disabled:O,"data-testid":`mcp-consent-skip`,children:W}),t[32]=O,t[33]=U,t[34]=G):G=t[34];let K;t[35]===P?K=t[36]:(K=()=>void P(),t[35]=P,t[36]=K);let q=O||E.size===0,J;t[37]===O?J=t[38]:(J=O?(0,b.jsx)(i,{id:`b4itZn`}):(0,b.jsx)(i,{id:`m16xKo`}),t[37]=O,t[38]=J);let Y;t[39]!==K||t[40]!==q||t[41]!==J?(Y=(0,b.jsx)(o,{onClick:K,disabled:q,"data-testid":`mcp-consent-add`,children:J}),t[39]=K,t[40]=q,t[41]=J,t[42]=Y):Y=t[42];let X;t[43]!==G||t[44]!==Y?(X=(0,b.jsxs)(d,{children:[G,Y]}),t[43]=G,t[44]=Y,t[45]=X):X=t[45];let Z;t[46]!==X||t[47]!==H?(Z=(0,b.jsxs)(l,{className:`sm:max-w-md`,children:[B,H,X]}),t[46]=X,t[47]=H,t[48]=Z):Z=t[48];let Q;return t[49]!==R||t[50]!==Z?(Q=(0,b.jsx)(p,{open:!0,onOpenChange:R,children:Z}),t[49]=R,t[50]=Z,t[51]=Q):Q=t[51],Q}export{T as McpConsentDialogBody,T as default,x as computeInitialSelection,C as selectedIdsOrdered,S as toggleSelectedId};