/* esm.sh - @assistant-ui/core@0.3.31/dist/store/clients/thread-message-client */
import{getThreadMessageText as U}from"../../utils/text.mjs";import{COMPLETE_STATUS as R,normalizePartStatus as j}from"../../utils/normalizePartStatus.mjs";import{getMessagePartKeys as q}from"../../utils/getMessagePartKeys.mjs";import{NoOpComposerClient as D}from"./no-op-composer-client.mjs";import{useClientLookup as H,useClientResource as G}from"../../../../../../store@0.3.22/X-ZEBhc3Npc3RhbnQtdWkvdGFwQDAuOS4yNCxyZWFjdEAxOS4zLjE/es2022/client.mjs";import{c as O}from"../../../../../../tap@0.9.24/X-ZHJlYWN0QDE5LjMuMQ/es2022/react-shim/compiler-runtime.mjs";import{useState as K}from"../../../../../../tap@0.9.24/X-ZHJlYWN0QDE5LjMuMQ/es2022/react-shim.mjs";import{resource as L,withKey as $}from"../../../../../../tap@0.9.24/X-ZHJlYWN0QDE5LjMuMQ/es2022/tap.mjs";var J=s=>{let e=O(8),{part:t,isMessageRunning:i}=s,r;e[0]!==i||e[1]!==t?(r=i?j(t)??R:R,e[0]=i,e[1]=t,e[2]=r):r=e[2];let a;e[3]!==t||e[4]!==r?(a={...t,status:r},e[3]=t,e[4]=r,e[5]=a):a=e[5];let p=a,o;return e[6]!==p?(o={getState:()=>p,addToolResult:Y,resumeToolCall:Z,respondToToolApproval:ee,unstable_recordInteraction:te},e[6]=p,e[7]=o):o=e[7],o},Q=L(J),V=({attachment:s})=>({getState:()=>s,remove:()=>{throw new Error("Not supported")}}),W=L(V),X=s=>{let e=O(38),{message:t,index:i,isLast:r,branchNumber:a,branchCount:p,submission:o}=s,b=r===void 0?!0:r,P=a===void 0?1:a,y=p===void 0?1:p,[x,z]=K(!1),[I,B]=K(!1),T=t.role==="assistant"&&t.status.type==="running",w,C;if(e[0]!==T||e[1]!==t.content){let n=q(t.content);w=H,C=t.content.map((g,F)=>$(n[F],Q({part:g,isMessageRunning:T}),[g,T])),e[0]=T,e[1]=t.content,e[2]=w,e[3]=C}else w=e[2],C=e[3];let c=w(C),l;e[4]!==t.attachments||e[5]!==o?.attachments?(l=o?.attachments??t.attachments??[],e[4]=t.attachments,e[5]=o?.attachments,e[6]=l):l=e[6];let M;e[7]!==l?(M=l.map(oe),e[7]=l,e[8]=M):M=e[8];let v=H(M),N;e[9]===Symbol.for("react.memo_cache_sentinel")?(N=D({type:"edit"}),e[9]=N):N=e[9];let E=G(N),k=E.state,S;e[10]!==y||e[11]!==P||e[12]!==k||e[13]!==i||e[14]!==x||e[15]!==I||e[16]!==b||e[17]!==t||e[18]!==c.state||e[19]!==o?(S={...t,parts:c.state,composer:k,parentId:null,index:i,isLast:b,branchNumber:P,branchCount:y,speech:void 0,isCopied:x,isHovering:I,submission:o},e[10]=y,e[11]=P,e[12]=k,e[13]=i,e[14]=x,e[15]=I,e[16]=b,e[17]=t,e[18]=c.state,e[19]=o,e[20]=S):S=e[20];let A=S,d;e[21]!==A?(d=()=>A,e[21]=A,e[22]=d):d=e[22];let m;e[23]!==E.methods?(m=()=>E.methods,e[23]=E.methods,e[24]=m):m=e[24];let u;e[25]!==t.content||e[26]!==c?(u=n=>"index"in n?c.get({index:n.index}):c.get({index:t.content.findIndex(g=>g.type==="tool-call"&&g.toolCallId===n.toolCallId)}),e[25]=t.content,e[26]=c,e[27]=u):u=e[27];let h;e[28]!==v?(h=n=>"id"in n?v.get({key:n.id}):v.get(n),e[28]=v,e[29]=h):h=e[29];let f;e[30]!==t?(f=()=>U(t),e[30]=t,e[31]=f):f=e[31];let _;return e[32]!==d||e[33]!==m||e[34]!==u||e[35]!==h||e[36]!==f?(_={getState:d,composer:m,part:u,attachment:h,delete:se,reload:re,speak:ne,stopSpeaking:ie,submitFeedback:ae,switchToBranch:ce,getCopyText:f,setIsCopied:z,setIsHovering:B},e[32]=d,e[33]=m,e[34]=u,e[35]=h,e[36]=f,e[37]=_):_=e[37],_},Te=L(X);function Y(){throw new Error("Not supported")}function Z(){throw new Error("Not supported")}function ee(){throw new Error("Not supported")}async function te(){}function oe(s){return $(s.id,W({attachment:s}),[s])}function se(){throw new Error("Not supported in ThreadMessageProvider")}function re(){throw new Error("Not supported in ThreadMessageProvider")}function ne(){throw new Error("Not supported in ThreadMessageProvider")}function ie(){throw new Error("Not supported in ThreadMessageProvider")}function ae(){throw new Error("Not supported in ThreadMessageProvider")}function ce(){throw new Error("Not supported in ThreadMessageProvider")}export{Te as ThreadMessageClient};
//# sourceMappingURL=thread-message-client.mjs.map