"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("../ui/button.cjs.js"),r=require("../../utils/tailwindUtil.cjs.js"),j=require("../../providers/Stream.cjs.js"),s=require("lucide-react"),y=require("react"),l=require("sonner");function m({message:t,onRegenerate:a,feedback:n,onFeedback:o,className:v}){const[g,h]=y.useState(!1),[d,u]=y.useState(!1),x=j.useStreamContext().getMessagesMetadata(t)?.firstSeenState?.parent_checkpoint,w=async()=>{try{let i="";typeof t.content=="string"?i=t.content:Array.isArray(t.content)&&(i=t.content.map(p=>p.type==="text"?p.text:"").filter(Boolean).join(`
`)),await navigator.clipboard.writeText(i),h(!0),l.toast.success("Copied to clipboard"),setTimeout(()=>h(!1),2e3)}catch(i){l.toast.error("Failed to copy"),console.error("Copy failed:",i)}},f=async()=>{if(!(!a||!x||!t.id))try{u(!0),await a(x,t.id,t)}catch(i){l.toast.error("Failed to regenerate"),console.error("Regenerate failed:",i)}finally{u(!1)}},z=()=>{if(!o||!t.id)return;const i=n==="like"?null:"like";o(t.id,i)},C=()=>{if(!o||!t.id)return;const i=n==="dislike"?null:"dislike";o(t.id,i)};return e.jsxs("div",{className:r.cn("flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200",v),children:[e.jsx(c.Button,{variant:"ghost",size:"icon",onClick:w,className:"h-7 w-7 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800",title:"Copy message",children:g?e.jsx(s.Check,{className:"h-3.5 w-3.5"}):e.jsx(s.Copy,{className:"h-3.5 w-3.5"})}),a&&e.jsx(c.Button,{variant:"ghost",size:"icon",onClick:f,disabled:d,className:"h-7 w-7 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 disabled:opacity-50",title:"Regenerate response",children:e.jsx(s.RefreshCw,{className:r.cn("h-3.5 w-3.5",d&&"animate-spin")})}),o&&e.jsxs(e.Fragment,{children:[e.jsx(c.Button,{variant:"ghost",size:"icon",onClick:z,className:r.cn("h-7 w-7 hover:bg-zinc-800",n==="like"?"text-green-500 hover:text-green-400":"text-zinc-500 hover:text-zinc-300"),title:"Good response",children:e.jsx(s.ThumbsUp,{className:r.cn("h-3.5 w-3.5",n==="like"&&"fill-current")})}),e.jsx(c.Button,{variant:"ghost",size:"icon",onClick:C,className:r.cn("h-7 w-7 hover:bg-zinc-800",n==="dislike"?"text-red-500 hover:text-red-400":"text-zinc-500 hover:text-zinc-300"),title:"Bad response",children:e.jsx(s.ThumbsDown,{className:r.cn("h-3.5 w-3.5",n==="dislike"&&"fill-current")})})]})]})}exports.MessageActions=m;
//# sourceMappingURL=MessageActions.cjs.js.map
