import{r as e,j as s}from"./vendor-react-RSDKEZ60.js";import{c as t}from"./vendor-zustand-IIUY2Tf-.js";import{u as a}from"./vendor-query-AdjnXGiH.js";import{Tq as n,kD as i,jO as o,y as r,f as l,m as d,aT as c,ba as p}from"./c818056db-BBpc4u6S.js";import{ix as u,hE as x,iu as m,sq as h}from"./ca9c256b9-B7ADeATc.js";import{u as f,M as g}from"./vendor-intl-BNW8a19h.js";import{B as j,S as v}from"./vendor-ant-cds-CBh5POw1.js";const b=t()(e=>({efSuppressorCount:0,pushEfSuppressor:()=>e(e=>({efSuppressorCount:e.efSuppressorCount+1})),popEfSuppressor:()=>e(e=>({efSuppressorCount:Math.max(0,e.efSuppressorCount-1)}))}));function _(s){const t=b(e=>e.pushEfSuppressor),a=b(e=>e.popEfSuppressor);e.useEffect(()=>{if(s)return t(),()=>a()},[s,t,a])}function w(e){if(!e)return;const s="AskUserQuestion"===e.tool_name?"ask_user_question":"ExitPlanMode"===e.tool_name?"exit_plan_mode":"tool_permission",t={requestId:e.request_id||void 0,toolUseId:e.tool_use_id||void 0,toolName:e.tool_name||void 0,input:e.input?n(e.input):e.input};switch(s){case"ask_user_question":return{kind:s,headline:e.input?.questions?.[0]?.header||e.action_description||"Question",...t};case"exit_plan_mode":return{kind:s,headline:e.action_description||"Ready to start?",detail:"string"==typeof e.input?.plan?e.input.plan:void 0,...t};case"tool_permission":return{kind:s,headline:e.action_description||(a=e.tool_name,i(a).replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())),detail:e.input&&Object.keys(e.input).length>0?"Bash"===e.tool_name&&"string"==typeof e.input.command?e.input.command:JSON.stringify(e.input,null,2):void 0,...t}}var a}const N=new Map;function y(e,s){let t=N.get(e);t||(t=new Set,N.set(e,t)),t.add(s)}function E(s,t){const n=u(s),{mutateAsync:i}=o(),r=a(),l=t?.id,d=t?.session_status,c=t?.external_metadata?.pending_action;e.useEffect(()=>{l&&("requires_action"===d||c||N.delete(l))},[l,d,c]);const p=s?.id;e.useEffect(()=>{p&&c&&x.getState().wakeSession(p)},[p,c]);const h=e.useMemo(()=>{if(n)return function(e){const{tool:s}=e;return w({tool_name:s.name,action_description:"",request_id:s.id,tool_use_id:s.id,input:s.input})}(n);const e=w(c);return e?.toolUseId&&l&&N.get(l)?.has(e.toolUseId)?void 0:e},[n,c,l]),f=e.useCallback(async(e,s)=>{if(n)return l&&y(l,n.tool.id),void n.decide(e,s);l&&h?.requestId&&h.toolUseId&&h.toolName&&(x.getState().wakeSession(l),await i({sessionId:l,requestId:h.requestId,toolUseId:h.toolUseId,toolName:h.toolName,decision:e,input:s??h.input}),y(l,h.toolUseId),x.getState().beginPendingTurn(l),r.invalidateQueries({queryKey:m.transcript({id:l,type:"remote"})}))},[n,h,i,l,r]);return e.useMemo(()=>{if(h)return{...h,tool:n?.tool??{id:h.toolUseId??h.requestId??"",name:h.toolName??"",input:h.input??{},status:"awaiting_approval"},hasAlwaysAllow:n?.hasAlwaysAllow??!1,queueDepth:n?.queueDepth??0,decide:f}},[h,n,f])}function S({name:t,children:a}){const{page:n}=r(),i=e.useRef(!1);return"undefined"==typeof window||i.current||(i.current=!0,n(t,{named_page:!0})),s.jsx(s.Fragment,{children:a})}function k({allHref:e,allLabel:t,name:a,nameAriaLabel:n,onRename:i}){const o=f(),{isEditing:r,editValue:l,setEditValue:d,optimisticLabel:c,inputRef:p,startEdit:u,submitEdit:x,cancelEdit:m,handleBlur:g}=h(i,a),v=c??a;return s.jsxs("div",{className:"text-secondary flex max-w-[480px] min-w-0 items-center",children:[s.jsx(j,{variant:"ghost",size:"sm",href:e,className:"-ml-1 min-w-0 shrink df-link-card",children:s.jsx("span",{className:"min-w-0 truncate font-base-bold",children:t})}),s.jsx("span",{className:"opacity-50 px-0.5","aria-hidden":!0,children:"/"}),r?s.jsx("div",{className:"flex h-7 max-w-full items-center rounded-md bg-bg-000 px-1.5 ring-1 ring-inset ring-accent-100",children:s.jsx("input",{ref:p,type:"text",value:l,onChange:e=>d(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.nativeEvent.isComposing||("Enter"===e.key?(e.preventDefault(),x()):"Escape"===e.key&&(e.preventDefault(),m()))},onBlur:g,className:"min-w-[3rem] max-w-full border-none bg-transparent font-base-bold text-text-000 outline-none [field-sizing:content] focus:border-transparent focus:outline-none focus:ring-0",style:{outline:"none",boxShadow:"none"},"aria-label":n??o.formatMessage({defaultMessage:"Name",id:"HAlOn1ZsuY"})})}):i?s.jsx("button",{type:"button",onClick:u,className:"min-w-0 truncate rounded-md px-1.5 py-1 text-left font-base-bold text-text-100 transition-colors hover:bg-fill-ghost-hover","aria-label":o.formatMessage({defaultMessage:"Rename {name}",id:"NZmMEEjudP"},{name:v}),children:v}):s.jsx("span",{className:"min-w-0 truncate pl-1.5 font-base-bold text-text-100",children:v})]})}const q="relative [clip-path:polygon(0_0,calc(100%-16px)_0,100%_16px,100%_100%,0_100%)]";function I(){return s.jsxs("span",{"aria-hidden":!0,className:"pointer-events-none absolute right-0 top-0 z-[1] h-4 w-4",children:[s.jsx("span",{className:"absolute inset-0 [filter:drop-shadow(-1px_2px_1px_var(--cds-shadow-color))_drop-shadow(-3px_3px_5px_var(--cds-shadow-color))]",children:s.jsx("span",{className:"absolute inset-0 rounded-bl-[2px] bg-surface-2 group-hover:bg-surface-1 [clip-path:polygon(0_0,100%_100%,0_100%)]"})}),s.jsx("span",{className:"absolute inset-0 bg-surface-2 group-hover:bg-surface-1 [clip-path:polygon(15px_14.5px,16.5px_16px,15px_16px)]"}),s.jsx("span",{className:"absolute inset-0 bg-alpha-2 [clip-path:polygon(0px_-1px,17px_16px,14.59px_16px,0px_1.41px)]"})]})}function M({count:e=6,columns:t="two",variant:a="text",silent:n=!1,dogEar:i=!1,withSourceBadge:o=!1,className:r}){return s.jsxs("div",{role:n?void 0:"status","aria-hidden":n||void 0,className:r,children:[!n&&s.jsx("span",{className:"sr-only",children:s.jsx(g,{defaultMessage:"Loading",id:"iFsDVRnIHW"})}),s.jsx("div",{"aria-hidden":!0,className:"three"===t?"grid grid-cols-1 gap-6 sm:grid-cols-2 md:grid-cols-3":"grid auto-rows-fr grid-cols-1 gap-3 md:grid-cols-2 md:gap-6",children:Array.from({length:e}).map((e,t)=>"thumbnail"===a?s.jsxs("div",{className:l("flex flex-col rounded-card shadow-card-ring [--cds-ring-inner:1px] [--cds-ring-outer:0px]",i?"bg-surface-2":"bg-surface-1",i&&q),children:[i?s.jsx(A,{withSourceBadge:o}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"h-[164px]"}),s.jsx("div",{className:"mx-px border-t border-alpha-1"}),s.jsxs("div",{className:"flex flex-col gap-xs p-lg pt-md",children:[s.jsx("div",{className:"flex h-5 items-center",children:s.jsx(v,{height:14,width:"70%"})}),s.jsx("div",{className:"flex h-4 items-center",children:s.jsx(v,{height:11,width:"50%"})})]})]}),i&&s.jsx(I,{})]},t):s.jsxs("div",{className:"flex h-[140px] flex-col gap-md rounded-card bg-surface-1 p-lg shadow-card-ring [--cds-ring-inner:1px] [--cds-ring-outer:0px]",children:[s.jsx(v,{height:16,width:"60%"}),s.jsxs("div",{className:"flex flex-grow flex-col gap-xs",children:[s.jsx(v,{height:12}),s.jsx(v,{height:12,width:"85%"})]}),s.jsx(v,{height:10,width:100,className:"mt-auto"})]},t))})]})}function A({withSourceBadge:e}){const t=d("__gb__2387839550"),a=t?"text-caption":"text-footnote",n=s.jsx("div",{className:"flex h-[1lh] items-center text-body",children:s.jsx(v,{height:14,width:"70%"})}),i=s.jsx("div",{className:l("flex h-[1lh] items-center",a),children:s.jsx(v,{height:11,width:"50%"})});return t?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative h-[120px]",children:e&&s.jsx("span",{"data-size":"sm",className:"absolute left-3 top-3 inline-flex h-control-nested w-12 items-center",children:s.jsx(v,{height:"100%",width:"100%",className:"rounded-chip"})})}),s.jsx("div",{className:"mx-px border-t border-alpha-1"}),s.jsxs("div",{className:"flex flex-col gap-xs p-3.5",children:[n,i,s.jsx("div",{className:"flex h-[1lh] items-center text-caption",children:s.jsx(v,{height:11,width:"85%"})})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"h-[120px]"}),s.jsx("div",{className:"mx-px border-t border-alpha-1"}),s.jsxs("div",{className:"flex flex-col gap-xs p-3.5",children:[n,i,e&&s.jsx("div",{children:s.jsx("span",{"data-size":"sm",className:"inline-flex h-control-nested w-12 items-center align-middle",children:s.jsx(v,{height:"100%",width:"100%",className:"rounded-chip"})})})]})]})}function C({href:e,ddActionName:t,title:a,titleEnd:n,description:i,footer:o,overlay:r}){const d=c();return s.jsxs("div",{className:"group relative h-full transition-transform duration-base ease-out has-[a:active]:scale-[0.98] has-[a:active]:duration-fast",children:[s.jsxs(p,{href:e,"data-primary":!0,className:l("flex h-full w-full flex-col gap-md rounded-card bg-surface-1 p-lg shadow-card-ring [--cds-ring-inner:1px] [--cds-ring-outer:0px] group-hover:bg-surface-2","outline-none focus-visible:shadow-focus","[scroll-margin-top:var(--list-header-scroll-offset)]","df-link-card"),"data-dd-action-name":t,children:[s.jsxs("div",{className:"flex items-center overflow-hidden pr-10",children:[s.jsx("div",{className:"truncate text-body font-medium text-primary",children:a}),n]}),s.jsx("div",{className:"line-clamp-3 flex-grow text-body text-secondary",children:i}),s.jsx("div",{className:"mt-auto flex justify-between text-footnote text-muted",children:o})]}),s.jsx("div",{className:l("absolute right-3 top-3 z-10",d?"opacity-100":"opacity-0 group-hover:opacity-100 group-has-[:focus-visible]:opacity-100 has-[[aria-expanded=true]]:opacity-100"),children:r})]})}export{I as D,k as E,C as G,M as L,S as N,_ as a,b,q as c,E as u};
