PageSourceSearch

https://kanvo.ai/assets/BranchPanel-DNCtp-My.js

js kanvo.ai collected 2026-10-05 12:20:00 UTC 3,953 bytes, 1 lines download raw bytes

1import{s as w,e as _,a7 as v,r as E,j as e,B as M}from"./index-CyV9aJqm.js";import{I as p}from"./icon-button-BHc1TM2G.js";import{T as S}from"./textarea-jzvE6hjW.js";import{R as f}from"./RichText-DC3R0j-M.js";import{a as k}from"./useMutation-FX7s25rq.js";import{B as y,M as T}from"./cache-DvhK4ytk.js";import{a as C,s as B,b as q}from"./messages-DlBQOM4D.js";import{u as A}from"./useUserQuery-C7uQBtcz.js";import{M as K}from"./messages-square-BBlGB_Mx.js";import{X as R}from"./x-DdN-xT1D.js";import{S as D}from"./send-B-hgpRmV.js";import{f as b}from"./format-CyFEjeMq.js";import"./en-US-4RaJY4CL.js";async function H(r){const{data:n,error:i}=await w.from("kanvo_messages").select(`${C}, hides:kanvo_message_hides(user_id, hidden)`).eq("root_id",r).order("created_at",{ascending:!0});if(i)throw i;return(n??[]).filter(a=>{var t;return!((t=a.hides)!=null&&t.some(d=>d.hidden))}).map(({hides:a,...t})=>t)}function L(r,n){const{user:i}=_(),o=v(),a=A({key:[y,r??""],fallback:[],when:!!r,query:()=>H(r)}),t=k({mutationFn:async d=>{if(!r||!i)throw new Error("Sign in to reply.");return B(n,i.id,d.body,null,d.replyTo??null,void 0,null,r)},onSuccess:()=>{o.invalidateQueries({queryKey:[y,r??""]}),o.invalidateQueries({queryKey:[T,n]})}});return{replies:a.data??[],isLoading:a.isPending,isError:a.isError,retry:()=>{a.refetch()},reply:t}}function Z({root:r,threadId:n,roster:i,viewerHandle:o,onClose:a}){const{replies:t,isLoading:d,isError:j,retry:N,reply:l}=L(r.id,n),[m,c]=E.useState(""),h=()=>{const s=m.trim();s&&(c(""),l.mutate({body:s},{onError:()=>c(s)}))},u=s=>{var x;return s&&((x=i.find(g=>g.user_id===s))==null?void 0:x.display_name)||"Someone"};return e.jsxs("aside",{className:"flex h-full min-h-0 w-full flex-col border-s border-border bg-card sm:w-96","aria-label":"Thread",children:[e.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b border-border px-4 py-3",children:[e.jsx(K,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),e.jsx("h2",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:"Thread"}),e.jsx(p,{label:"Close this thread",variant:"ghost",onClick:a,children:e.jsx(R,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-3",children:[e.jsxs("article",{className:"border-b border-border pb-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[u(r.sender_id)," · ",b(new Date(r.created_at),"d MMM, HH:mm")]}),e.jsx("div",{className:"mt-1",children:e.jsx(f,{body:r.body,tone:"muted",viewerHandle:o})})]}),j?e.jsxs("div",{className:"py-4 text-sm text-muted-foreground",children:[e.jsx("p",{children:"These replies could not be loaded."}),e.jsx(M,{variant:"ghost",size:"sm",className:"mt-1 px-0",onClick:N,children:"Try again"})]}):d?e.jsx("p",{className:"py-4 text-sm text-muted-foreground",children:"Loading…"}):t.length===0?e.jsx("p",{className:"py-4 text-sm text-muted-foreground",children:"No replies yet. What you write here stays in this thread."}):e.jsx("ol",{className:"space-y-3 py-3",children:t.map(s=>e.jsxs("li",{children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[u(s.sender_id)," ·"," ",b(new Date(s.created_at),"d MMM, HH:mm")]}),e.jsx("div",{className:"mt-0.5",children:e.jsx(f,{body:s.body,tone:"muted",viewerHandle:o})})]},s.id))})]}),e.jsxs("div",{className:"shrink-0 border-t border-border p-3",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(S,{value:m,onChange:s=>c(s.target.value.slice(0,q)),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),h())},placeholder:"Reply in thread","aria-label":"Reply in thread",rows:2,className:"min-h-0 resize-none"}),e.jsx(p,{label:"Send this reply",disabled:!m.trim()||l.isPending,onClick:h,children:e.jsx(D,{className:"h-4 w-4"})})]}),l.isError&&e.jsx("p",{className:"mt-1 text-xs text-destructive",children:"That reply did not send. What you wrote is still in the box."})]})]})}export{Z as BranchPanel};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.