@goodfish/jarvy 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to Jarvy. Versions follow [semantic versioning](https://semver.org/) as used before 1.0: a patch release only fixes bugs; a minor release adds features or upgrades the database.
4
4
 
5
+ ## 0.10.1 — 2026-10-29
6
+
7
+ No database change: upgrading from 0.10.0 needs nothing else.
8
+
9
+ ### Fixed
10
+
11
+ - Bots work with Gemini models. The `chat` tool's parameters are now a plain string enum and object: Gemini refuses `anyOf`/`const` and `patternProperties` in a function definition, so every request that carried the `chat` tool failed (a relay answered 500) on every protocol but OpenAI Responses. What the tool accepts is unchanged.
12
+
5
13
  ## 0.10.0 — 2026-10-29
6
14
 
7
15
  Upgrading moves the database from schema v25 to v29 on first start: the inbox gets a category for each delivery (v26), SSH machines get a description (v27), attachment contents move out of the database into files under `attachments/` in the data directory, after which the database is compacted (v28), and every Bot's default environment becomes its own sandbox (v29). A start interrupted midway finishes the job on the next start. Read **Before you upgrade** first.
@@ -9598,9 +9598,9 @@ var agentTools = [
9598
9598
  // src/server/service/bot/tools.ts
9599
9599
  var EVERY_BOT = [...historyTools, ...chatTools, ...messageTools, ...fileTools, ...environmentTools2, ...secretTools, ...taskTools];
9600
9600
  var Gateway = Type11.Object({
9601
- action: Type11.Union([Type11.Literal("list"), Type11.Literal("describe"), Type11.Literal("call")]),
9601
+ action: Type11.Unsafe({ type: "string", enum: ["list", "describe", "call"] }),
9602
9602
  tool: Type11.Optional(Type11.String()),
9603
- args: Type11.Optional(Type11.Record(Type11.String(), Type11.Unknown()))
9603
+ args: Type11.Optional(Type11.Unsafe({ type: "object" }))
9604
9604
  }, { additionalProperties: false });
9605
9605
  var Tools = class {
9606
9606
  send;
@@ -570,7 +570,7 @@ ${e.tail}`:e.head+e.tail:""}const _b=e=>e.omitted?`${x("npc.live.omitted",{count
570
570
  `),title:e.state==="running"?x("npc.step.ask.running"):y?x("npc.step.ask.ok",{answer:y}):x(e.state==="failed"?"npc.live.askFailed":"npc.live.askClosed")}}if(u==="environments.switch")return{...a,look:"action",icon:"tool",title:x(`npc.live.switch.${Mi(e)}`),detail:r};const m=d?Ab(d):"",v=wp.has(u)?m?x(`npc.live.browse.${e.state==="running"?"running":"ok"}`,{chat:m}):x(`npc.live.browseAll.${e.state==="running"?"running":"ok"}`):x(`npc.live.tool.${Mi(e)}`,{tool:u||"chat"});return{...a,look:"action",icon:wp.has(u)?"chat":"tool",title:e.state==="failed"&&wp.has(u)?x("npc.live.tool.failed",{tool:u}):v,detail:r}}function RB(e){try{const a=JSON.parse(e.output?e.output.head+e.output.tail:"");return a.status!=="answered"?null:[...(a.selected??[]).map(i=>i.label??""),a.custom??""].filter(Boolean).join(x("common.listSeparator"))}catch{return null}}function Mb(e,a){const i=new Map(e.steps.map(s=>[s.id,s.parentId])),r=s=>{let u=0,d=s.parentId;for(;d&&u<4;)u++,d=i.get(d)??null;return u};return e.steps.map(s=>_B(s,r(s),a))}function wd(e){var i;const a=((i=e.line)==null?void 0:i.length)??0;if(e.look==="speech"){const r=Math.min(7e3,Math.max(2500,1500+50*a))+Math.min(1500,a/.06);return{firm:r,light:r}}return e.look==="mutter"?{firm:1500,light:Math.min(3500,Math.max(1500,800+30*a))}:e.state==="failed"?{firm:2e3,light:2e3}:{firm:0,light:e.look==="action"?900:0}}const DB=4e3,Rb=1500;function Db(e,a,i,r){var j;const s=w=>w-i;let u=null;for(const w of e)w.state==="running"&&(!u||w.startedAt>=u.startedAt)&&(u=w);const d=[];for(const w of e.filter(k=>k.state!=="running"&&k.endedAt!==null&&wd(k).firm).sort((k,C)=>k.endedAt-C.endedAt)){const k=s(w.endedAt),C=d.at(-1);C&&w.look==="speech"&&(C.end=Math.min(C.end,Math.max(C.start+Rb,k)));const T=Math.max(k,(C==null?void 0:C.end)??0);T-k>DB||d.push({step:w,start:T,end:T+wd(w).firm})}const f=(u==null?void 0:u.look)==="speech"?u:null;if(f){const w=s(f.startedAt);for(let k=d.length-1;k>=0;k--){const C=d[k];C.start>=w&&C.start>a?d.splice(k,1):C.end>w&&(C.end=Math.max(C.start+Rb,w))}}let m=null;for(const w of e){if(w.state==="running"||w.endedAt===null||!wd(w).light)continue;const k=s(w.endedAt)+wd(w).light;k>a&&(!m||w.endedAt>=m.step.endedAt)&&(m={step:w,end:k})}const v=d.find(w=>w.start<=a&&a<w.end),y=(v==null?void 0:v.step)??(f||u&&u.look!=="thought"||m==null?void 0:m.step),g=y??f??u??(r?e.at(-1)??null:null),b=[...d.flatMap(w=>[w.start,w.end]),(m==null?void 0:m.end)??0].filter(w=>w>a);return{shown:g,lingering:!!y,next:b.length?Math.min(...b):0,wordsEnd:((j=d.at(-1))==null?void 0:j.end)??0}}const Ob=6e3,zb=500,Lb=2200,OB=2e4,zB=10*6e4,Bb=3e4,LB=2e4,BB=2800;function IB(e,a,i,r,s){var V;const{turn:u,last:d,skew:f}=TB(e),[m,v]=S.useState(null),[y,g]=S.useState(0),[b,j]=S.useState(0),[,w]=S.useState(0),k=S.useRef(new Set),C=S.useRef(Date.now()),T=S.useMemo(()=>u?Mb(u,a):d?Mb(d,a):[],[u,d,a]);S.useEffect(()=>{for(const F of(u==null?void 0:u.steps)??[])F.state==="failed"&&!k.current.has(F.id)&&(k.current.add(F.id),g(J=>J+1),v({mood:"dizzy",until:Date.now()+2600}))},[u]),S.useEffect(()=>{d&&(k.current.clear(),C.current=Date.now(),j(Math.max(Date.now(),Db(T,Date.now(),f,!1).wordsEnd)+Ob),d.outcome==="completed"&&d.endedAt-d.startedAt>OB&&v({mood:"happy",until:Date.now()+3200}))},[d]),S.useEffect(()=>{u&&(C.current=Date.now())},[u!==null]);const M=Date.now(),E=Db(T,M,f,u!==null),R=E.shown,D=T.filter(F=>F.state==="running").sort((F,J)=>J.startedAt-F.startedAt)[0],A=!u&&(d==null?void 0:d.outcome)==="completed"&&M+f-d.endedAt<Lb,H=M-C.current,U=!u&&(i==null?void 0:i.status)==="idle"&&H>Bb&&(H-Bb)%LB<BB,Y=D&&D.look!=="thought"?Cp(D):E.lingering&&R?Cp(R):D?Cp(D):u?{motion:"think",fast:!1}:A?{motion:"stretch",fast:!1}:U?{motion:"groom",fast:!1}:s,z=!u&&!R&&d!==null&&M<b;return S.useEffect(()=>{const F=[(m==null?void 0:m.until)??0,b-zb,b,((d==null?void 0:d.endedAt)??0)-f+Lb,E.next].filter(G=>G>Date.now()),J=setTimeout(()=>w(G=>G+1),F.length?Math.min(...F)-Date.now()+20:1e3);return()=>clearTimeout(J)}),{view:{steps:T,shown:R,skew:f,startedAt:((V=u??d)==null?void 0:V.startedAt)??0,endedAt:u?null:(d==null?void 0:d.endedAt)??null,done:z?{ms:d.endedAt-d.startedAt,outcome:d.outcome,fading:M>=b-zb}:null},motion:Y.motion,fast:Y.fast,mood:m&&m.until>M?m.mood:r,shake:y,canRecap:!u&&d!==null&&!z&&M+f-d.endedAt<zB,showRecap:()=>j(Date.now()+Ob)}}const k5="jarvy-floating-bot",as=10,PB=4,Sd=new URLSearchParams(location.search).get("npc")==="demo";function HB(e){return!e||e.status==="stop"?{motion:"sleep",fast:!1}:e.status!=="running"||e.activity==="asking"?{motion:"idle",fast:!1}:["compacting","retrying","aborting"].includes(e.phase)?{motion:"busy",fast:!1}:e.activity==="tool_calling"||e.phase==="tool"?{motion:"work",fast:!0}:e.activity==="texting"||e.phase==="texting"?{motion:"work",fast:!1}:{motion:"think",fast:!1}}function UB(){try{const e=JSON.parse(localStorage.getItem(k5)??"");if(e.x>=0&&e.x<=1&&e.y>=0&&e.y<=1)return e}catch{}return{x:1,y:0}}function qB({bot:e,chatId:a,status:i,area:r,avoid:s,onOpen:u}){const d=S.useRef(null),f=S.useRef(null),m=S.useRef(UB()),v=S.useRef(null),y=S.useRef(!1),g=S.useRef(null),b=S.useRef({motion:"sleep",mood:"normal",lookX:0,lookY:0}),j=S.useRef(null),[w,k]=S.useState(!1),C=S.useRef(null),T=CB(Sd,e.mood),M=IB(Sd?null:e.id,a,i,e.mood,HB(i)),E=Sd?T:M;b.current.motion=E.motion,b.current.fast=E.fast,b.current.mood=E.mood;function R(){const U=r.current.getBoundingClientRect(),Y=d.current.offsetWidth,z=s.current?s.current.getBoundingClientRect().top-U.top:U.height,V=Math.max(as,U.width-Y-as),F=Math.max(as,z-Y-as);return{minX:as,minY:as,maxX:V,maxY:F}}function D(){var V;const U=(V=r.current)==null?void 0:V.getBoundingClientRect(),Y=d.current;if(!U||!Y)return 0;const z=U.width/2-Y.offsetWidth/2;return z>0?Math.max(-1,Math.min(1,(z-Y.offsetLeft)/z)):0}function A(){var z;if(!d.current||!r.current)return;const U=R(),Y=d.current;Y.style.left=`${U.minX+m.current.x*(U.maxX-U.minX)}px`,Y.style.top=`${U.minY+m.current.y*(U.maxY-U.minY)}px`,(z=C.current)==null||z.call(C)}S.useLayoutEffect(()=>{A();const U=new ResizeObserver(A);for(const Y of[r.current,s.current,d.current])Y&&U.observe(Y);return()=>U.disconnect()},[]),S.useEffect(()=>{var U;(U=j.current)==null||U.setColor(($a[e.color]??$a.gray).hex)},[e.color]),S.useEffect(()=>{var U;(U=j.current)==null||U.setCrown(e.agent)},[e.agent]);const H=i!=null&&i.error?`${i.runId??""}:${i.error}`:null;return S.useEffect(()=>{var U;H&&((U=j.current)==null||U.shake(performance.now()))},[H]),S.useEffect(()=>{var U;E.shake&&((U=j.current)==null||U.shake(performance.now()))},[E.shake]),S.useEffect(()=>{const U=V=>{(V.pointerType==="mouse"||V.type==="pointerdown")&&(g.current={x:V.clientX,y:V.clientY})},Y=V=>{V.relatedTarget||(g.current=null)},z=V=>{const F=V.target;if(F.id!=="jarvy-composer")return;const J=F.getBoundingClientRect();g.current={x:J.left+J.width/2,y:J.top+J.height/2}};return window.addEventListener("pointermove",U),window.addEventListener("pointerdown",U),document.addEventListener("pointerout",Y),document.addEventListener("input",z),document.addEventListener("focusin",z),()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerdown",U),document.removeEventListener("pointerout",Y),document.removeEventListener("input",z),document.removeEventListener("focusin",z)}},[]),S.useEffect(()=>{let U=!0,Y=0,z=()=>{};const V=matchMedia("(prefers-reduced-motion: reduce)");return Promise.all([Yd(()=>import("./three.module-BdMZo7zQ.js"),[]),Yd(()=>import("./figure-DQGUDG-4.js"),[])]).then(([F,J])=>{if(!U||!f.current)return;const G=new F.WebGLRenderer({canvas:f.current,antialias:!0,alpha:!0});J.configureRenderer(F,G);const{scene:$,camera:K}=J.createStage(F),I=new J.CatFigure(F,($a[e.color]??$a.gray).hex);I.setCrown(e.agent),I.pose(b.current.mood),$.add(I.root),J.frameCamera(K,1,3.3),j.current=I;let P=0;const W=ae=>{var L;const ie=d.current;if(ie){const q=Math.round(ie.offsetWidth*Math.min(2,devicePixelRatio||1));q!==P&&(P=q,G.setSize(q,q,!1));const ue=ie.getBoundingClientRect(),xe=g.current;b.current.lookX=xe?Math.max(-1,Math.min(1,(xe.x-ue.left-ue.width/2)/320)):0,b.current.lookY=xe?Math.max(-1,Math.min(1,(xe.y-ue.top-ue.height/2)/320)):0,b.current.reduced=V.matches;const be=b.current.motion,je=!!((L=v.current)!=null&&L.moved)&&(be==="idle"||be==="groom"||be==="stretch");(b.current.faceX===void 0||!(je||be==="sleep"))&&(b.current.faceX=D()),I.frame(ae,b.current),G.render($,K)}Y=requestAnimationFrame(W)},_=()=>{cancelAnimationFrame(Y),document.hidden||(Y=requestAnimationFrame(W))};document.addEventListener("visibilitychange",_),_(),k(!0),z=()=>{document.removeEventListener("visibilitychange",_),cancelAnimationFrame(Y),I.dispose(),G.dispose(),G.forceContextLoss(),j.current=null}}).catch(()=>{}),()=>{U=!1,z()}},[]),o.jsxs(o.Fragment,{children:[o.jsxs("button",{ref:d,type:"button",className:"jv-floating-bot","data-live":w||void 0,"data-motion":E.motion,title:e.name,"aria-label":x("avatar.openInfo",{name:e.name}),onPointerDown:U=>{if(U.button!==0)return;const Y=U.currentTarget;Y.setPointerCapture(U.pointerId),v.current={id:U.pointerId,x:U.clientX,y:U.clientY,left:Y.offsetLeft,top:Y.offsetTop,moved:!1}},onPointerMove:U=>{const Y=v.current;if(!Y||Y.id!==U.pointerId)return;const z=U.clientX-Y.x,V=U.clientY-Y.y;if(!Y.moved&&Math.hypot(z,V)<PB)return;Y.moved=!0;const F=R(),J=Math.min(F.maxX,Math.max(F.minX,Y.left+z)),G=Math.min(F.maxY,Math.max(F.minY,Y.top+V));m.current={x:F.maxX>F.minX?(J-F.minX)/(F.maxX-F.minX):0,y:F.maxY>F.minY?(G-F.minY)/(F.maxY-F.minY):0},A()},onPointerUp:U=>{const Y=v.current;!Y||Y.id!==U.pointerId||(v.current=null,y.current=Y.moved,Y.moved&&localStorage.setItem(k5,JSON.stringify(m.current)))},onPointerCancel:()=>{v.current=null},onClick:()=>{if(y.current){y.current=!1;return}E.canRecap?E.showRecap():u()},style:{"--jv-avatar-size":"100%"},children:[o.jsx("canvas",{ref:f,"aria-hidden":"true"}),!w&&o.jsx(so,{color:e.color,mood:e.mood,size:88,crown:e.agent})]}),o.jsx(mB,{view:E.view,name:e.name,cat:d,area:r,avoid:s,layout:C,facing:D,toolbar:Sd?(U,Y)=>o.jsx(xB,{controls:T.controls,toolbar:U,onReplay:()=>{Y(),T.controls.replay()}}):void 0})]})}function FB({className:e,...a}){return o.jsx("div",{"data-slot":"card",className:an("flex flex-col gap-4 rounded-xl border bg-card py-5 text-card-foreground shadow-sm",e),...a})}function VB({className:e,...a}){return o.jsx("div",{"data-slot":"card-header",className:an("grid gap-1 px-5",e),...a})}function $B({className:e,...a}){return o.jsx("div",{"data-slot":"card-title",className:an("font-semibold leading-none",e),...a})}function GB({className:e,...a}){return o.jsx("div",{"data-slot":"card-content",className:an("px-5",e),...a})}function YB({bot:e,connections:a,onSaved:i,onManage:r}){return o.jsxs(FB,{className:"jarvy-model-picker jv-ui",children:[o.jsx(VB,{children:o.jsx($B,{children:x("botModel.pickFor",{name:e.name})})}),o.jsx(GB,{children:o.jsx(DS,{bot:e,connections:a,onSaved:i,onManage:r})})]})}function XB({chat:e,inChannel:a,bots:i,members:r,meId:s,drafts:u,composeReady:d,botName:f,activeBot:m,status:v,connections:y,activity:g,history:b,divider:j,activeQuestion:w,pane:k,onPane:C,onToggleInfo:T,find:M,onNav:E,onBot:R,hasBotDirects:D,onInvite:A,onQuote:H,onReply:U,onReact:Y,onFold:z,onJump:V,onSettled:F,onSend:J,onPreview:G,onSaveNote:$,notice:K,createBot:I,creating:P,updateBot:W,onManageModels:_,error:ae,chatArea:ie,transcript:L,composeWrap:q,hidden:ue,onOpenThread:xe}){const{messages:be,loading:je,hasOlder:Ae,loadingOlder:Re,top:ye,away:Q,unseen:he,toLatest:ke}=b;return o.jsxs("main",{className:"ui-chat","aria-label":x("chat.area"),ref:ie,hidden:ue,children:[!a&&o.jsx(st,{icon:"layout-sidebar-left",className:"ui-mobile-only jv-floating-nav",label:x("common.openNav"),onClick:E}),!a&&D&&o.jsx(st,{icon:"people",className:"jv-floating-dms",label:x("chat.botDms",{name:f}),"aria-pressed":(k==null?void 0:k.kind)==="botdms",onClick:()=>C((k==null?void 0:k.kind)==="botdms"?null:{kind:"botdms"})}),o.jsx("span",{className:"sr-only",role:"status","aria-label":x("chat.botStatus"),children:a?"":g}),e?o.jsxs(o.Fragment,{children:[a?o.jsx(IL,{chat:e,members:si(r),bots:i,onNav:E,infoOpen:(k==null?void 0:k.kind)==="info"&&k.page==="main",onInfo:()=>T("main"),membersOpen:(k==null?void 0:k.kind)==="info"&&k.page==="members",onMembers:()=>T("members"),threadsOpen:(k==null?void 0:k.kind)==="threads",onThreads:()=>C((k==null?void 0:k.kind)==="threads"?null:{kind:"threads"}),searchOpen:(k==null?void 0:k.kind)==="search",onSearch:()=>(k==null?void 0:k.kind)==="search"?C(null):M.search(e)}):m&&o.jsx(qB,{bot:m,chatId:e.id,status:v,area:ie,avoid:q,onOpen:()=>R(m.id)}),a&&o.jsx(PL,{chat:e,onSave:$}),o.jsxs("div",{className:`ui-transcript jarvy-transcript${a?" jv-channel-transcript":""}`,ref:L,"aria-label":x("chat.transcript"),role:"log",children:[!a&&!(m!=null&&m.connectionId)&&m&&o.jsx("div",{className:"jarvy-model-onboarding",children:o.jsx(YB,{bot:m,connections:y,onSaved:W,onManage:_})}),je?o.jsx("p",{className:"jarvy-empty-text",children:x("chat.loading")}):be.length===0?a?o.jsx("div",{className:"jarvy-empty-chat",children:o.jsx("p",{children:x("chat.empty")})}):m!=null&&m.connectionId?o.jsx("div",{className:"jarvy-empty-chat",children:o.jsx("h2",{children:x("chat.start",{name:f})})}):null:o.jsxs(o.Fragment,{children:[Ae&&o.jsx("div",{ref:ye,className:"jv-history-more","aria-live":"polite",children:Re?x("chat.loadingOlder"):""}),a?o.jsx(Xd,{messages:be,members:r,bots:i,me:s,divider:j,activeQuestion:w,onSettled:F,onPreview:G,onReply:U,onOpenThread:xe,onQuote:H,onReact:Y,onFold:z,onJump:V,onError:ae}):o.jsx(cB,{messages:be,members:r,me:s,activeQuestion:w,bot:m,onSettled:F,onPreview:G,onQuote:H,onReact:Y,onFold:z,onJump:V,onError:ae})]}),Q&&be.length>0&&o.jsx("div",{className:"jv-to-latest",children:o.jsxs("button",{type:"button",onClick:ke,"aria-label":x("chat.toLatest"),children:[he>0&&o.jsx("span",{children:x("chat.unseen",{count:he})}),o.jsx(Be,{name:"chevron-down"})]})})]}),o.jsx(j5,{chatId:e.id,id:"jarvy-composer",drafts:u,formRef:q,scrollRef:L,disabled:!d,placeholder:a?x("chat.toChannel",{name:e.title}):m!=null&&m.connectionId?x("chat.toBot",{name:f}):x("chat.pickModel"),mention:a?{bots:i,inside:si(r).filter(Ee=>Ee.id!==s&&e.memberIds.includes(Ee.id)),outside:si(r).filter(Ee=>!e.memberIds.includes(Ee.id)),onInvite:Ee=>A(e.id,Ee)}:void 0,onSend:J,onError:ae,onNotice:K})]}):o.jsx("div",{className:"jarvy-empty-chat jarvy-first-chat",children:i.length?o.jsx("p",{children:x("chat.pick")}):o.jsxs("button",{className:"ui-button ui-primary",onClick:I,disabled:P,children:[o.jsx(Be,{name:"person-add"}),x("sidebar.newBot")]})}),e&&o.jsx(t5,{container:L,drafts:u,chatId:e.id,source:Ee=>be.find(Ie=>Ie.id===Ee),members:r,onNotice:K})]})}const KB=e=>ua(e,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});function QB(e,a){const[i,r]=S.useState([]);return S.useEffect(()=>{if(r([]),!e)return;let s=!0;return fe.botDirects(e).then(u=>{s&&r(u.chats)}).catch(()=>{}),()=>{s=!1}},[e,a]),i}function ZB({bot:e,chats:a,members:i,bots:r,me:s,tick:u,onClose:d,onPreview:f,onError:m}){const[v,y]=S.useState(null),[g,b]=S.useState(null);S.useEffect(()=>{if(b(null),!v)return;let k=!0;return fe.messages(v).then(C=>{k&&b(C.messages)}).catch(C=>{k&&m(C)}),()=>{k=!1}},[v,u]);const j=k=>i.find(C=>C.id!==e.id&&k.memberIds.includes(C.id)),w=a.find(k=>k.id===v);return o.jsxs("aside",{className:"ui-pane jv-pane","aria-label":x("chat.botDms",{name:e.name}),children:[o.jsxs("header",{className:"ui-pane-header jv-pane-header",children:[w&&o.jsx(st,{icon:"chevron-left",label:x("directs.back"),onClick:()=>y(null)}),o.jsx("strong",{children:w?x("directs.between",{name:e.name,other:Hi(j(w))}):x("chat.botDms",{name:e.name})}),o.jsx("span",{className:"jv-spacer"}),o.jsx(st,{icon:"close",label:x("common.close"),onClick:d})]}),w?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"ui-pane-body jv-pane-body",children:g===null?o.jsx("p",{className:"jv-picker-empty",children:x("threads.loading")}):g.length===0?o.jsx("p",{className:"jv-picker-empty",children:x("chat.empty")}):o.jsx(Xd,{messages:g,members:i,bots:r,me:s,divider:Number.MAX_SAFE_INTEGER,onSettled:()=>{},onPreview:f})}),o.jsx("p",{className:"jv-readonly",children:x("directs.readOnly")})]}):o.jsx("div",{className:"ui-pane-body jv-pane-body",children:a.length===0?o.jsx("p",{className:"jv-picker-empty",children:x("sidebar.noDms")}):a.map(k=>{const C=j(k);return o.jsxs("button",{type:"button",className:"jv-thread-item",onClick:()=>y(k.id),children:[o.jsxs("span",{className:"jv-thread-item-head",children:[o.jsx(Cr,{member:C,bots:r,size:20}),o.jsx("strong",{children:Hi(C)}),o.jsx("span",{className:"jv-muted",children:KB(k.updatedAt)})]}),k.lastMessage&&o.jsx("span",{className:"jv-muted jv-thread-item-meta",children:bs(k.lastMessage)})]},k.id)})})]})}function JB(e,a){return e!=null&&e.connectionId?a!=null&&a.error?{label:x("activity.error"),tone:"error"}:(a==null?void 0:a.status)==="running"?{label:QS(a.activity),tone:"busy"}:{label:x((a==null?void 0:a.status)==="idle"?"activity.idle":"activity.stopped")}:{label:x("activity.noModel")}}function WB({channel:e,members:a,bots:i,statuses:r,me:s,onAdd:u,onBot:d,onChanged:f,onError:m}){const[v,y]=S.useState(null),g=a.filter(k=>e.memberIds.includes(k.id)),b=g.filter(k=>k.kind!=="bot").sort((k,C)=>+(C.id===s)-+(k.id===s)),j=g.filter(k=>k.kind==="bot"),w=k=>{const C=k.kind==="bot"?i.find(R=>R.id===k.id):void 0,T=r[k.id],M=k.kind==="bot"?JB(C,T):void 0,E=o.jsxs(o.Fragment,{children:[o.jsx(Cr,{member:k,bots:i,size:28,working:(T==null?void 0:T.status)==="running"&&T.activity!=="asking"}),o.jsxs("span",{className:"jv-member-name",children:[k.name,k.id===s&&o.jsx("span",{className:"jv-role",children:x("common.you")})]}),M&&o.jsx("span",{className:"jv-member-state","data-tone":M.tone,children:M.label})]});return o.jsxs("div",{className:"jv-member-row",children:[C?o.jsx("button",{type:"button",className:"jv-member-main","aria-label":x("members.view",{name:k.name}),onClick:()=>d(k.id),children:E}):o.jsx("div",{className:"jv-member-main",children:E}),k.id!==s&&o.jsx(st,{icon:"close",label:x("members.remove",{name:k.name}),className:"jv-member-remove",onClick:()=>y(k)})]},k.id)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"jv-member-bar",children:[o.jsx("span",{children:x("members.count",{count:g.length})}),o.jsxs("button",{type:"button",className:"ui-button ui-primary jv-member-pane-add",onClick:u,children:[o.jsx(Be,{name:"person-add"}),x("common.add")]})]}),o.jsx("div",{className:"ui-pane-body jv-pane-body",children:[["people",x("members.people"),b],["bots","Bot",j]].map(([k,C,T])=>T.length>0&&o.jsxs("section",{className:"jv-member-group","aria-label":C,children:[o.jsxs("h3",{children:[C," · ",T.length]}),T.map(w)]},k))}),v&&o.jsx(f5,{title:x("members.removeTitle",{name:v.name,channel:e.title}),body:x("members.removeBody"),confirm:x("members.removeConfirm"),onClose:()=>y(null),onConfirm:async()=>{try{f(await fe.removeMember(e.id,v.id)),y(null)}catch(k){m(k)}}})]})}function Ib({label:e,value:a,empty:i,maxLength:r,required:s=!1,onSave:u}){const d=S.useId(),[f,m]=S.useState(null),[v,y]=S.useState(!1);S.useEffect(()=>m(null),[a]);const g=async()=>{if(!(f===null||v||s&&!f.trim())){if(f.trim()===a){m(null);return}y(!0);try{await u(f.trim()),m(null)}catch{}finally{y(!1)}}};return o.jsxs("div",{className:"jv-info-field",children:[o.jsxs("div",{className:"jv-info-label",children:[o.jsx("label",{htmlFor:d,children:e}),f===null&&o.jsx(st,{icon:"pencil",label:x("info.edit",{name:e}),className:"jv-info-edit",onClick:()=>m(a)})]}),f===null?o.jsx("p",{className:"jv-info-value","data-empty":!a||void 0,children:a||i}):o.jsxs("div",{className:"jv-inline-edit",children:[o.jsx("input",{id:d,value:f,maxLength:r,autoFocus:!0,placeholder:i,onChange:b=>m(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),g()),b.key==="Escape"&&(b.stopPropagation(),m(null))}}),o.jsx("button",{type:"button",className:"ui-button",onClick:()=>m(null),children:x("common.cancel")}),o.jsx("button",{type:"button",className:"ui-button ui-primary",disabled:v||s&&!f.trim(),onClick:()=>void g(),children:x("common.save")})]})]})}function eI({channel:e,page:a,sections:i,members:r,bots:s,statuses:u,me:d,onPage:f,onPin:m,onMute:v,onAdd:y,onBot:g,onDelete:b,onChanged:j,onClose:w,onError:k}){const C=S.useId(),T=async E=>{try{j(await fe.updateChannel(e.id,E))}catch(R){throw k(R),R}},M=r.filter(E=>e.memberIds.includes(E.id)).length;return o.jsxs("aside",{className:"ui-pane jv-pane","aria-label":x(a==="members"?"info.memberList":"entry.channelInfo"),children:[o.jsxs("header",{className:"ui-pane-header jv-pane-header",children:[a==="members"&&o.jsx(st,{icon:"chevron-left",label:x("info.back"),className:"jv-pane-back",onClick:()=>f("main")}),o.jsx("strong",{children:x(a==="members"?"channel.members":"entry.channelInfo")}),o.jsxs("span",{className:"jv-muted jv-pane-sub",children:["#",e.title]}),o.jsx("span",{className:"jv-spacer"}),o.jsx(st,{icon:"close",label:x("common.close"),onClick:w})]}),a==="members"?o.jsx(WB,{channel:e,members:r,bots:s,statuses:u,me:d,onAdd:y,onBot:g,onChanged:j,onError:k}):o.jsxs("div",{className:"ui-pane-body jv-pane-body jv-info",children:[o.jsxs("div",{className:"jv-info-actions",children:[o.jsxs("button",{type:"button","aria-pressed":e.pinned,onClick:m,children:[o.jsx(Be,{name:"pin"}),x("entry.pin")]}),o.jsxs("button",{type:"button","aria-pressed":e.muted,onClick:v,children:[o.jsx(Be,{name:e.muted?"bell-slash":"bell"}),x("entry.mute")]}),o.jsxs("button",{type:"button",onClick:y,children:[o.jsx(Be,{name:"person-add"}),x("info.addMembers")]})]}),o.jsx(Ib,{label:x("info.name"),value:e.title,empty:x("info.newChannel"),maxLength:80,required:!0,onSave:E=>T({name:E})}),o.jsx(Ib,{label:x("info.topic"),value:e.topic,empty:x("info.noTopic"),maxLength:200,onSave:E=>T({topic:E})}),o.jsxs("div",{className:"jv-info-field",children:[o.jsx("div",{className:"jv-info-label",children:o.jsx("label",{htmlFor:C,children:x("info.section")})}),o.jsx(BS,{id:C,value:e.sectionId,sections:i,onChange:E=>void T({sectionId:E}).catch(()=>{})})]}),o.jsxs("nav",{className:"jv-info-menu","aria-label":x("info.menu"),children:[o.jsxs("button",{type:"button",className:"ui-menu-item",onClick:()=>f("members"),children:[o.jsx(Be,{name:"people"}),o.jsx("span",{className:"ui-menu-copy",children:x("channel.members")}),o.jsx("span",{className:"jv-muted",children:M}),o.jsx(Be,{name:"chevron-right"})]}),o.jsxs("button",{type:"button",className:"ui-menu-item jv-menu-danger",onClick:b,children:[o.jsx(Be,{name:"trash"}),o.jsx("span",{className:"ui-menu-copy",children:x("entry.deleteChannel")})]})]})]})]})}function tI({chat:e,chats:a,members:i,focusKey:r,onOpenMessage:s,onClose:u,onError:d}){const[f,m]=S.useState(""),v=S.useRef(null);S.useEffect(()=>{var j,w;(j=v.current)==null||j.focus(),(w=v.current)==null||w.select()},[r,e.id]);const{result:y,loading:g}=h5(f,e.id,d),b=e.type==="channel"?`#${e.title}`:x(e.type==="thread"?"search.inThread":"search.inDm");return o.jsxs("aside",{className:"ui-pane jv-pane jv-search-pane","aria-label":x("search.paneLabel"),children:[o.jsxs("header",{className:"ui-pane-header jv-pane-header",children:[o.jsx("strong",{children:x("search.title")}),o.jsx("span",{className:"jv-muted jv-pane-sub",children:b}),o.jsx("span",{className:"jv-spacer"}),o.jsx(st,{icon:"close",label:x("search.close"),onClick:u})]}),o.jsx("div",{className:"jv-pane-search",children:o.jsx("input",{ref:v,type:"search",value:f,placeholder:x(e.type==="channel"?"search.channelPlaceholder":"search.placeholder"),"aria-label":x("search.placeholder"),onChange:j=>m(j.target.value),onKeyDown:j=>{j.key==="Escape"&&(j.preventDefault(),f?m(""):u())}})}),o.jsx("div",{className:"ui-pane-body jv-pane-body jv-results","aria-live":"polite",children:f.trim()?y?y.messages.length?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"jv-result-count",children:x(y.messages.length>=60?"search.countLatest":"search.count",{count:y.messages.length})}),y.messages.map(({message:j,chat:w})=>o.jsx(g5,{message:j,chat:w,chats:a,members:i,query:f,showPlace:w.id!==e.id,onOpen:s},j.id))]}):o.jsx("p",{className:"jv-result-empty",children:x("search.noMessages")}):g&&o.jsx("p",{className:"jv-result-empty",children:x("search.searching")}):o.jsx("p",{className:"jv-result-empty",children:x("search.prompt")})})]})}const nI=e=>ua(e,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});function aI({chat:e,channelName:a,expanded:i=!1,onTitle:r,onStatus:s,onSummary:u,onConclude:d}){var E;const[f,m]=S.useState(null),[v,y]=S.useState(null),[g,b]=S.useState(!1),[j,w]=S.useState(i);S.useEffect(()=>{m(null),y(null),w(i)},[e.id,i]);const k=async(R,D)=>{b(!0);try{await R(),D()}catch{}finally{b(!1)}},C=e.status==="done",T=e.note,M=((E=T==null?void 0:T.text.split(`
571
571
  `).find(R=>R.trim()&&!R.startsWith("#")))==null?void 0:E.replace(/[*`|>-]/g,"").trim())??"";return o.jsxs("div",{className:"jv-thread-meta","data-open":j||void 0,children:[o.jsxs("div",{className:"jv-thread-title-row",children:[f===null?o.jsxs(o.Fragment,{children:[o.jsx("h2",{className:"jv-thread-title",title:e.title,children:e.title}),o.jsx(st,{icon:"pencil",label:x("thread.rename"),onClick:()=>m(e.title)})]}):o.jsxs("form",{className:"jv-inline-edit",onSubmit:R=>{R.preventDefault(),f.trim()&&k(()=>r(f.trim()),()=>m(null))},children:[o.jsx("input",{value:f,autoFocus:!0,maxLength:80,"aria-label":x("thread.title"),onChange:R=>m(R.target.value),onKeyDown:R=>{R.key==="Escape"&&m(null)}}),o.jsx("button",{type:"submit",className:"ui-button ui-primary",disabled:g||!f.trim(),children:x("common.save")})]}),o.jsx("button",{type:"button",className:"jv-thread-status","data-done":C||void 0,disabled:g,title:x("thread.toggleStatus"),onClick:()=>void k(()=>s(C?"open":"done"),()=>{}),children:C?o.jsxs(o.Fragment,{children:[o.jsx(Be,{name:"check"}),x("channel.threadDone")]}):x("threads.open")})]}),v!==null?o.jsxs("div",{className:"jv-summary","data-editing":!0,children:[o.jsx("textarea",{className:"jv-notice-input",value:v,autoFocus:!0,"aria-label":x("thread.summary"),onChange:R=>y(R.target.value)}),o.jsxs("div",{className:"jv-notice-actions",children:[o.jsx("button",{type:"button",className:"ui-button",onClick:()=>y(null),children:x("common.cancel")}),o.jsx("button",{type:"button",className:"ui-button ui-primary",disabled:g||!v.trim(),onClick:()=>void k(()=>u(v.trim()),()=>y(null)),children:x("common.save")})]})]}):T?o.jsxs("div",{className:"jv-summary",children:[o.jsxs("div",{className:"jv-summary-head",children:[o.jsxs("button",{type:"button",className:"jv-summary-toggle","aria-expanded":j,onClick:()=>w(!j),children:[o.jsx("strong",{children:x("thread.summary")}),!j&&o.jsx("span",{className:"jv-summary-first",children:M}),o.jsx(Be,{name:j?"chevron-down":"chevron-right"})]}),j&&o.jsxs("span",{className:"jv-muted jv-summary-meta",children:[T.updatedBy.name," · ",nI(T.updatedAt)," · ",x("notice.version",{version:T.version})]}),o.jsx(st,{icon:"pencil",label:x("thread.editSummary"),onClick:()=>y(T.text)})]}),j&&o.jsx("div",{className:"jv-summary-body ui-bubble jv-flat",children:o.jsx(Fc,{text:T.text})}),j&&!C&&o.jsxs("button",{type:"button",className:"ui-button jv-conclude",disabled:g,onClick:()=>void k(d,()=>{}),children:[o.jsx(Be,{name:"check"}),x("thread.conclude",{channel:a})]})]}):o.jsxs("button",{type:"button",className:"jv-summary-empty",onClick:()=>y(""),children:[o.jsx(Be,{name:"add"}),x("thread.addSummary")]})]})}function Pb({threadId:e,mode:a,showSummary:i=!1,focus:r,onSearch:s,channel:u,drafts:d,members:f,bots:m,me:v,tick:y,onClose:g,onToggleMode:b,onNav:j,onChanged:w,onInvite:k,onPreview:C,onError:T,onNotice:M}){const[E,R]=S.useState(null),[D,A]=S.useState(null),[H,U]=S.useState([]),[Y,z]=S.useState(null),V=S.useRef(H);V.current=H;const F=S.useRef(null),J=S.useRef(null),G=S.useRef(null),$=S.useRef(!1),K=S.useRef(!0),[I,P]=S.useState(!1),W=S.useRef(0),_=S.useRef(0);S.useEffect(()=>{R(null),A(null),U([]),z(null),$.current=!1,K.current=!0,P(!1),W.current=0,_.current=0},[e]),S.useEffect(()=>{let Q=!0;return Promise.all([fe.chat(e),fe.messages(e)]).then(async([he,ke])=>{if(Q&&(R(he),U(ke.messages),G.current!==e&&(G.current=e,z(he.readSequence)),he.rootMessageId)){const Ee=await fe.message(he.rootMessageId);Q&&A(Ee)}}).catch(he=>{Q&&T(he)}),()=>{Q=!1}},[e,y]),S.useLayoutEffect(()=>{const Q=F.current;if(!Q||!E)return;const he=()=>Q.scrollTo({top:Q.scrollHeight,behavior:"instant"}),ke=H.at(-1),Ee=(ke==null?void 0:ke.senderId)===v&&ke.sequence>_.current;if(_.current=Math.max(_.current,(ke==null?void 0:ke.sequence)??0),$.current)(K.current||Ee)&&Q.scrollTo({top:Q.scrollHeight,behavior:"smooth"});else{if(!H.length&&!D)return;$.current=!0;const Ie=r?Q.querySelector(`[data-message="${r.id}"]`):null;if(Ie){if(K.current=!1,Ie.scrollIntoView({block:"center"}),r!=null&&r.passage&&WS(Ie,r.passage))return;Ie.classList.add("jv-jump"),setTimeout(()=>Ie.classList.remove("jv-jump"),1600);return}he(),requestAnimationFrame(he)}(K.current||Ee)&&(W.current=(ke==null?void 0:ke.sequence)??0)},[H,D,E]),S.useEffect(()=>{$.current&&r&&q(r.id,r.passage)},[r]),S.useEffect(()=>{const Q=F.current,he=J.current;if(!Q||!he)return;const ke=new ResizeObserver(()=>{!$.current||!K.current||Q.scrollHeight-Q.scrollTop-Q.clientHeight<8||Q.scrollTo({top:Q.scrollHeight,behavior:"instant"})});ke.observe(he);const Ee=()=>{var Ie;K.current=Q.scrollHeight-Q.scrollTop-Q.clientHeight<120,K.current&&(W.current=Math.max(W.current,((Ie=V.current.at(-1))==null?void 0:Ie.sequence)??0)),P(!K.current)};return Ee(),Q.addEventListener("scroll",Ee,{passive:!0}),()=>{ke.disconnect(),Q.removeEventListener("scroll",Ee)}},[F.current,e,E]),S.useEffect(()=>{const Q=H.at(-1);if(!E||!Q||Q.chatId!==E.id)return;const he=()=>{if(document.visibilityState!=="visible"||E.readSequence>=Q.sequence)return;const ke={...E,readSequence:Q.sequence,unread:0,mentions:0,alerts:0,atMe:!1,hint:null};R(ke),fe.markRead(E.id,Q.sequence).then(()=>w(ke)).catch(T)};return he(),document.addEventListener("visibilitychange",he),()=>document.removeEventListener("visibilitychange",he)},[H,E]);const ae=async Q=>{try{const he=await Q();R(he),w(he)}catch(he){throw T(he),he}},ie=async(Q,he,ke)=>{try{const Ee=await fe.react(Q.id,he,ke),Ie=Ye=>Ye.id===Ee.id?{...Ye,reactions:Ee.reactions}:Ye;U(Ye=>Ye.map(Ie)),A(Ye=>Ye&&Ie(Ye))}catch(Ee){T(Ee)}},L=async(Q,he)=>{try{const ke=await fe.fold(Q.id,he),Ee=Ie=>Ie.id===ke.id?{...Ie,folded:ke.folded}:Ie;U(Ie=>Ie.map(Ee)),A(Ie=>Ie&&Ee(Ie))}catch(ke){T(ke)}},q=(Q,he)=>{var Ee;const ke=Q&&((Ee=F.current)==null?void 0:Ee.querySelector(`[data-message="${Q}"]`));if(!ke){M(x(Q?"thread.sourceElsewhere":"app.sourceGone"));return}e5(ke,he)},ue={onQuote:Q=>b5(d,Q,f),onReact:ie,onFold:L,onJump:q,onError:T},xe=async(Q,he,ke,Ee,Ie=[],Ye=!1)=>{await fe.send(e,Q,he,ke,Ye,Ee,Ie);const Ke=u?[...new Set(kg(Q,si(f)).filter(gt=>!u.memberIds.includes(gt.member.id)).map(gt=>gt.member.name))]:[];Ke.length&&M(x("app.notInChannel",{names:Ke.join(x("common.listSeparator")),count:Ke.length})),Promise.all([fe.chat(e),fe.messages(e)]).then(([gt,rn])=>{R(gt),U(rn.messages),w(gt)}).catch(T)},be=(u==null?void 0:u.title)??x("search.channel"),je=f.find(Q=>Q.id===(D==null?void 0:D.senderId)),Ae=I?H.filter(Q=>Q.sequence>W.current&&Q.senderId!==v).length:0,Re=a==="pane"?"aside":a==="embed"?"section":"main",ye=new Set([...D?[D.senderId,...D.mentions]:[],...H.flatMap(Q=>[Q.senderId,...Q.mentions])]);return ye.delete(v),o.jsxs(Re,{className:a==="pane"?"ui-pane jv-pane":a==="embed"?"ui-chat jv-thread-full jv-thread-embed":"ui-chat jv-thread-full","aria-label":x("thread.label"),onKeyDown:Q=>{E&&s&&(Q.ctrlKey||Q.metaKey)&&Q.key.toLowerCase()==="f"&&(Q.preventDefault(),s(E))},children:[o.jsxs("header",{className:a==="pane"?"ui-pane-header jv-pane-header":"ui-chat-header jv-pane-header",children:[a==="full"&&o.jsx(st,{icon:"layout-sidebar-left",className:"ui-mobile-only",label:x("common.openNav"),onClick:j}),a==="embed"&&o.jsx(st,{icon:"chevron-left",className:"ui-mobile-only",label:x("thread.backToList"),onClick:g}),a==="full"?o.jsxs("button",{type:"button",className:"jv-crumb",onClick:g,children:[o.jsx(Be,{name:"chevron-left"}),o.jsx("span",{className:"jv-hash",children:"#"}),be]}):a==="embed"?o.jsxs("button",{type:"button",className:"jv-crumb",title:x("thread.inChannel"),onClick:b,children:[o.jsx("span",{className:"jv-hash",children:"#"}),be]}):o.jsxs(o.Fragment,{children:[o.jsx("strong",{children:x("thread.label")}),o.jsxs("span",{className:"jv-muted jv-pane-sub",children:["#",be]})]}),o.jsx("span",{className:"jv-spacer"}),E&&s&&o.jsx(st,{icon:"search",label:x("thread.search"),onClick:()=>s(E)}),E&&o.jsxs("button",{type:"button",className:"ui-button jv-follow","data-on":E.following||void 0,title:x(E.following?"thread.followingHint":"thread.notFollowingHint"),onClick:()=>void ae(()=>fe.follow(e,!E.following)).catch(()=>{}),children:[o.jsx(Be,{name:"bell"}),x(E.following?"threads.following":"thread.follow")]}),a!=="embed"&&o.jsx(st,{icon:a==="pane"?"arrows-expand":"arrows-contract",className:"jv-desktop-only",label:x(a==="pane"?"thread.expand":"thread.collapse"),onClick:b}),a==="pane"&&o.jsx(st,{icon:"close",label:x("thread.close"),onClick:g})]}),E&&o.jsx("div",{className:a==="pane"?"jv-thread-pin":"jv-thread-pin jv-thread-pin-wide",children:o.jsx(aI,{chat:E,channelName:be,expanded:i,onTitle:Q=>ae(()=>fe.updateThread(e,{title:Q})),onStatus:Q=>ae(()=>fe.updateThread(e,{status:Q})),onSummary:Q=>ae(()=>fe.setNote(e,Q)),onConclude:async()=>{var Q;try{await xe(`${x("thread.conclusion")}
572
572
 
573
- ${((Q=E.note)==null?void 0:Q.text)??""}`,[],Array.from(crypto.getRandomValues(new Uint8Array(16)),he=>he.toString(16).padStart(2,"0")).join(""),void 0,[],!0),await ae(()=>fe.updateThread(e,{status:"done"})),M(x("thread.concluded",{channel:be}))}catch(he){throw T(he),he}}})}),o.jsxs("div",{ref:F,className:a==="pane"?"ui-pane-body jv-pane-body":"ui-transcript jv-thread-wide",children:[o.jsxs("div",{ref:J,children:[D&&o.jsx(Xd,{messages:[{...D,thread:null}],members:f,bots:m,me:v,divider:Number.MAX_SAFE_INTEGER,onSettled:()=>{},onPreview:C,onReact:ie,onFold:L,onJump:q,onError:T}),o.jsx("div",{className:"jv-divider","data-tone":"count",role:"separator",children:o.jsx("span",{children:H.length?x("channel.replies",{count:H.length}):x("thread.noReplies")})}),o.jsx(Xd,{messages:H,members:f,bots:m,me:v,divider:Y??Number.MAX_SAFE_INTEGER,before:D==null?void 0:D.createdAt,onSettled:Q=>U(he=>he.map(ke=>ke.id===Q.id?Q:ke)),onPreview:C,...ue})]}),I&&H.length>0&&o.jsx("div",{className:"jv-to-latest",children:o.jsxs("button",{type:"button","aria-label":x("thread.toLatest"),onClick:()=>{var Q;return(Q=F.current)==null?void 0:Q.scrollTo({top:F.current.scrollHeight,behavior:"smooth"})},children:[Ae>0&&o.jsx("span",{children:x("chat.unseen",{count:Ae})}),o.jsx(Be,{name:"chevron-down"})]})})]}),o.jsx(j5,{chatId:e,id:"jarvy-thread-composer",drafts:d,placeholder:x("thread.reply"),scrollRef:F,disabled:!E,initialText:H.length===0&&D&&D.senderId!==v&&je&&!je.deleted?`@${je.name} `:void 0,mention:{bots:m,inside:si(f).filter(Q=>Q.id!==v&&!!(u!=null&&u.memberIds.includes(Q.id))),outside:si(f).filter(Q=>!(u!=null&&u.memberIds.includes(Q.id))),onInvite:k,participants:ye},onSend:xe,onError:T,onNotice:M}),o.jsx(t5,{container:F,drafts:d,chatId:e,members:f,onNotice:M,source:Q=>Q===(D==null?void 0:D.id)?D:H.find(he=>he.id===Q)})]})}const Np={updated:"threadSort.updated",created:"threadSort.created",status:"threadSort.status"},kd=e=>e.lastReplyAt??e.createdAt;function C5(e,a){const i=a==="created"?(r,s)=>s.createdAt-r.createdAt:a==="status"?(r,s)=>+(r.status==="done")-+(s.status==="done")||kd(s)-kd(r):(r,s)=>kd(s)-kd(r);return[...e].sort(i)}function N5(e){const a=`jarvy-thread-sort-${e}`,[i,r]=S.useState(()=>{const s=localStorage.getItem(a);return s==="created"||s==="status"?s:"updated"});return[i,s=>{r(s),localStorage.setItem(a,s)}]}function E5({value:e,onChange:a}){return o.jsxs(gr,{value:e,onValueChange:i=>a(i),children:[o.jsxs(yr,{className:"jv-thread-sort","aria-label":x("threadSort.current",{order:x(Np[e])}),title:x("threadSort.title"),children:[o.jsx(m8,{}),o.jsx(vr,{})]}),o.jsx(xr,{className:"jv-select-menu",position:"popper",sideOffset:4,align:"end",children:Object.keys(Np).map(i=>o.jsx(sa,{value:i,children:x(Np[i])},i))})]})}const T5=e=>ua(e,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});function iI({channel:e,members:a,bots:i,tick:r,onOpen:s,onClose:u,onError:d}){const[f,m]=S.useState(null),[v,y]=S.useState("open"),[g,b]=N5("channel");S.useEffect(()=>{let k=!0;return fe.channelThreads(e.id).then(C=>{k&&m(C.threads)}).catch(C=>{k&&d(C)}),()=>{k=!1}},[e.id,r]);const j=C5((f??[]).filter(k=>v==="all"||k.status===v),g),w=k=>(f??[]).filter(C=>C.status===k).length;return o.jsxs("aside",{className:"ui-pane jv-pane","aria-label":x("threads.list"),children:[o.jsxs("header",{className:"ui-pane-header jv-pane-header",children:[o.jsx("strong",{children:x("channel.threads")}),o.jsxs("span",{className:"jv-muted jv-pane-sub",children:["#",e.title]}),o.jsx("span",{className:"jv-spacer"}),o.jsx(E5,{value:g,onChange:b}),o.jsx(st,{icon:"close",label:x("threads.closeList"),onClick:u})]}),o.jsx("div",{className:"jv-tabs",role:"tablist","aria-label":x("threads.byStatus"),children:[["open",x("threads.openCount",{count:w("open")})],["done",x("threads.doneCount",{count:w("done")})],["all",x("threads.all")]].map(([k,C])=>o.jsx("button",{type:"button",role:"tab","aria-selected":v===k,onClick:()=>y(k),children:C},k))}),o.jsx("div",{className:"ui-pane-body jv-pane-body",children:f===null?o.jsx("p",{className:"jv-picker-empty",children:x("threads.loading")}):j.length===0?o.jsx("p",{className:"jv-picker-empty",children:x("threads.none")}):j.map(k=>{const C=a.find(T=>{var M;return T.id===((M=k.root)==null?void 0:M.senderId)});return o.jsxs("button",{type:"button",className:"jv-thread-item","data-unread":k.unread>0||void 0,onClick:()=>s(k.id),children:[o.jsxs("span",{className:"jv-thread-item-head",children:[o.jsx("strong",{children:k.title}),k.alerts>0?o.jsx("span",{className:"jv-badge",children:k.alerts}):k.unread>0&&o.jsx("span",{className:"jv-count",children:k.unread}),o.jsx("span",{className:"jv-thread-status","data-done":k.status==="done"||void 0,children:x(k.status==="done"?"channel.threadDone":"threads.open")})]}),k.root&&o.jsxs("span",{className:"jv-thread-item-root",children:[o.jsx(Cr,{member:C,bots:i,size:16}),o.jsx("span",{children:bs(k.root)})]}),o.jsxs("span",{className:"jv-muted jv-thread-item-meta",children:[x("channel.replies",{count:k.replies}),k.lastReplyAt?` · ${T5(k.lastReplyAt)}`:"",k.following?` · ${x("threads.following")}`:""]})]},k.id)})})]})}function rI({threads:e,chats:a,members:i,bots:r,onNav:s,renderThread:u}){const[d,f]=S.useState(e),[m,v]=S.useState(null),[y,g]=S.useState("all"),[b,j]=N5("followed");S.useEffect(()=>f(M=>[...e,...M.filter(E=>!e.some(R=>R.id===E.id)).map(E=>({...E,following:!1,unread:0,alerts:0}))]),[e]);const w=C5(d,b).filter(M=>y==="all"||(y==="unread"?M.unread>0:M.status===y)),k=d.filter(M=>M.unread>0).length,C=d.find(M=>M.id===m),T=M=>d.filter(E=>E.status===M).length;return o.jsxs("main",{className:"ui-chat jv-followed-page","aria-label":x("sidebar.followed"),"data-open":C?"":void 0,children:[o.jsxs("section",{className:"jv-followed-list","aria-label":x("threads.list"),children:[o.jsxs("header",{className:"ui-chat-header jv-channel-header",children:[o.jsxs("div",{className:"ui-header-left",children:[o.jsx(st,{icon:"layout-sidebar-left",className:"ui-mobile-only",label:x("common.openNav"),onClick:s}),o.jsx("strong",{className:"jv-channel-title",children:x("sidebar.followed")})]}),o.jsx(E5,{value:b,onChange:j})]}),o.jsx("div",{className:"jv-tabs",role:"tablist","aria-label":x("threads.filter"),children:[["all",x("threads.all")],["unread",k?x("threads.unreadCount",{count:k}):x("threads.unread")],["open",x("threads.openCount",{count:T("open")})],["done",x("threads.doneCount",{count:T("done")})]].map(([M,E])=>o.jsx("button",{type:"button",role:"tab","aria-selected":y===M,onClick:()=>g(M),children:E},M))}),o.jsx("div",{className:"jv-followed-items",children:w.length===0?o.jsx("p",{className:"jv-picker-empty",children:x({all:"threads.none",unread:"threads.noneUnread",open:"threads.noneOpen",done:"threads.noneDone"}[y])}):w.map(M=>{const E=i.find(D=>{var A;return D.id===((A=M.root)==null?void 0:A.senderId)}),R=a.find(D=>D.id===M.parentId);return o.jsxs("button",{type:"button",className:"jv-thread-item","data-unread":M.unread>0||void 0,"aria-current":M.id===m||void 0,onClick:()=>v(M.id),children:[o.jsxs("span",{className:"jv-thread-item-head",children:[o.jsx("strong",{children:M.title}),M.alerts>0?o.jsx("span",{className:"jv-badge",children:M.alerts}):M.unread>0&&o.jsx("span",{className:"jv-count",children:M.unread}),o.jsx("span",{className:"jv-thread-status","data-done":M.status==="done"||void 0,children:x(M.status==="done"?"channel.threadDone":"threads.open")})]}),M.root&&o.jsxs("span",{className:"jv-thread-item-root",children:[o.jsx(Cr,{member:E,bots:r,size:16}),o.jsx("span",{children:bs(M.root)})]}),o.jsxs("span",{className:"jv-muted jv-thread-item-meta",children:["#",(R==null?void 0:R.title)??""," · ",x("channel.replies",{count:M.replies}),M.lastReplyAt?` · ${T5(M.lastReplyAt)}`:"",M.following?"":` · ${x("threads.notFollowing")}`]})]},M.id)})})]}),C?u(C,()=>v(null)):o.jsx("div",{className:"jv-followed-empty",children:o.jsx("p",{children:x("threads.pick")})})]})}function lI({pane:e,followedView:a,followed:i,chats:r,sections:s,members:u,bots:d,statuses:f,meId:m,drafts:v,tick:y,paneChannel:g,activeBot:b,botDirects:j,find:w,onPane:k,onNav:C,onBackToChannel:T,onAddMembers:M,onOpenBot:E,onPin:R,onMute:D,onDeleteChannel:A,onChannelSaved:H,onThreadChanged:U,onInvite:Y,onPreview:z,onNotice:V,onError:F,paneWidth:J,onResize:G}){var P,W;const $=(e==null?void 0:e.kind)==="thread"?e:null,K=($==null?void 0:$.mode)==="full",I=()=>k(null);return o.jsxs(o.Fragment,{children:[a&&!K&&o.jsx(rI,{threads:i,chats:r,members:u,bots:d,onNav:C,renderThread:(_,ae)=>o.jsx(Pb,{threadId:_.id,mode:"embed",channel:r.find(ie=>ie.id===_.parentId),drafts:v,members:u,bots:d,me:m,tick:y,onNav:C,onChanged:U,onClose:ae,onToggleMode:()=>T({id:_.id,parentId:_.parentId},!0),onInvite:ie=>Y(_.parentId,ie),onPreview:z,onError:F,onNotice:V},_.id)}),$&&o.jsx(Pb,{threadId:$.id,mode:$.mode,showSummary:$.summary,focus:$.focus,onSearch:w.search,channel:r.find(_=>_.id===$.parentId),drafts:v,members:u,bots:d,me:m,tick:y,onNav:C,onChanged:U,onClose:()=>K?T($,!1):I(),onToggleMode:()=>K?T($,!0):k({...$,mode:"full"}),onInvite:_=>Y($.parentId,_),onPreview:z,onError:F,onNotice:V},`${$.id}:${((P=$.focus)==null?void 0:P.id)??""}:${((W=$.focus)==null?void 0:W.passage)??""}`),(e==null?void 0:e.kind)==="search"&&o.jsx(tI,{chat:e.chat,chats:r,members:u,focusKey:w.focusKey,onOpenMessage:w.openMessage,onClose:I,onError:F}),(e==null?void 0:e.kind)==="threads"&&g&&o.jsx(iI,{channel:g,members:u,bots:d,tick:y,onOpen:_=>k({kind:"thread",id:_,parentId:g.id,mode:"pane"}),onClose:I,onError:F}),(e==null?void 0:e.kind)==="info"&&g&&o.jsx(eI,{channel:g,page:e.page,sections:s,members:si(u),bots:d,statuses:f,me:m,onPage:_=>k({kind:"info",page:_}),onPin:()=>R(g),onMute:()=>D(g),onAdd:()=>M(g),onBot:E,onDelete:()=>A(g),onChanged:H,onClose:I,onError:F}),(e==null?void 0:e.kind)==="botdms"&&b&&!g&&o.jsx(ZB,{bot:b,chats:j,members:u,bots:d,me:m,tick:y,onClose:I,onPreview:z,onError:F}),e&&!K&&o.jsx("div",{className:"jv-resize",style:{right:J-4},onPointerDown:G,role:"separator","aria-orientation":"vertical","aria-label":x("app.resizePane")})]})}const Hb="@goodfish/jarvy",A5="0.10.0",oI={url:"git+https://github.com/AzzzGoodFish/Jarvy.git"},sI="Apache-2.0",m0=oI.url.replace(/^git\+/,"").replace(/\.git$/,""),Ub=`${m0}/blob/v${A5}`,cI=[{label:"about.source",detail:m0.replace(/^https:\/\//,""),href:m0},{label:"about.package",detail:Hb,href:`https://www.npmjs.com/package/${Hb}`},{label:"about.license",detail:sI,href:`${Ub}/LICENSE`},{label:"about.notices",detail:"THIRD_PARTY_NOTICE.md",href:`${Ub}/THIRD_PARTY_NOTICE.md`}];function uI(){return o.jsxs("div",{className:"jv-page",children:[o.jsx("header",{className:"jv-page-header",children:o.jsx("h2",{children:x("settings.about")})}),o.jsxs("div",{className:"jv-list",children:[o.jsxs("div",{className:"jv-list-row jv-static-row jv-about-intro",children:[o.jsxs("div",{className:"jv-row-text",children:[o.jsx("strong",{children:"Jarvy"}),o.jsx("span",{children:x("about.tagline")})]}),o.jsx("span",{className:"jv-row-meta",children:x("about.version",{version:A5})})]}),cI.map(e=>o.jsxs("a",{className:"jv-list-row jv-link-row",href:e.href,target:"_blank",rel:"noreferrer",children:[o.jsxs("div",{className:"jv-row-text",children:[o.jsx("strong",{children:x(e.label)}),o.jsx("span",{children:e.detail})]}),o.jsx(S8,{"aria-hidden":"true"})]},e.label))]})]})}function dI(){const[e,a]=S.useState(document.documentElement.classList.contains("dark")),i=s=>{Gd(s?"dark":"light"),a(s)},r=(s,u,d,f,m)=>o.jsxs("button",{type:"button",role:"radio","aria-checked":d,lang:m,className:"jv-list-row jv-choice-row",onClick:f,children:[o.jsx("span",{className:"jv-row-text",children:o.jsx("strong",{children:u})}),d&&o.jsx(Ra,{"aria-hidden":"true"})]},s);return o.jsxs("div",{className:"jv-page",children:[o.jsx("header",{className:"jv-page-header",children:o.jsx("h2",{children:x("settings.general")})}),o.jsxs("section",{className:"jv-section","aria-labelledby":"general-language",children:[o.jsx("h3",{id:"general-language",className:"jv-section-title",children:x("general.language")}),o.jsx("div",{className:"jv-list",role:"radiogroup","aria-labelledby":"general-language",children:Jb.map(s=>r(s,_p(s,"name"),to()===s,()=>tj(s),s))})]}),o.jsxs("section",{className:"jv-section","aria-labelledby":"general-theme",children:[o.jsx("h3",{id:"general-theme",className:"jv-section-title",children:x("general.theme")}),o.jsxs("div",{className:"jv-list",role:"radiogroup","aria-labelledby":"general-theme",children:[r("light",x("general.light"),!e,()=>i(!1)),r("dark",x("general.dark"),e,()=>i(!0))]})]})]})}const fI=`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M9.797 6.282a.451.451 0 01-.336-.315 1.019 1.019 0 010-.505c.156-.86.3-1.725.501-2.577.14-.7.42-1.367.823-1.96.305-.431.75-.746 1.262-.89.877-.217 1.24.629.937 1.348-.259.593-.877.914-1.334 1.348-.835.795-1.096 2.14-1.336 3.212a.427.427 0 01-.186.277.437.437 0 01-.331.062z" fill="url(#lobe-icons-ant-group-0-_R_0_)" transform="translate(3)"></path><path d="M6.334 4.672c.33-.121.682.146.946.297.278.145.587.219.901.214.231.01.466 0 .688.018 4.098.176 7.484 3.22 8.05 7.237.565 4.016-1.852 7.859-5.745 9.134-3.894 1.276-8.153-.38-10.126-3.935A8.339 8.339 0 013.133 7.081c.348-.278.716-.53 1.102-.755a8.404 8.404 0 001.318-.79c.28-.243.45-.742.781-.864zm4.406 2.15c-2.841.003-4.898 2.533-4.628 5.642.27 3.109 2.781 5.641 5.613 5.665 2.832.024 4.932-2.512 4.658-5.644-.273-3.133-2.802-5.666-5.643-5.663zm.357.57a4.707 4.707 0 013.304 1.446 5.703 5.703 0 011.643 3.49 4.841 4.841 0 01-1.141 3.705v.015a3.923 3.923 0 01-2.808 1.303 4.664 4.664 0 01-3.367-1.387 5.678 5.678 0 01-1.71-3.518 4.832 4.832 0 011.14-3.753 3.923 3.923 0 012.813-1.3h.126z" fill="url(#lobe-icons-ant-group-1-_R_0_)" transform="translate(3)"></path><path d="M2.346 2.054a1.26 1.26 0 01.384-.594.842.842 0 011.165.11c.694.82.169 2.078.142 3.02.013.805.208 1.597.57 2.318.084.134.147.279.186.43a.539.539 0 01-.3.577c-.345.17-.568-.19-.709-.446-.324-.6-.617-1.216-.877-1.846a8.698 8.698 0 01-.618-1.987 7.523 7.523 0 01-.051-.37 3.717 3.717 0 01-.024-.34 2.506 2.506 0 01.132-.872z" fill="url(#lobe-icons-ant-group-2-_R_0_)" transform="translate(3)"></path><defs><linearGradient id="lobe-icons-ant-group-0-_R_0_" x1="31.373%" x2="61.365%" y1="95.551%" y2="-.348%"><stop offset="0%" stop-color="#06F"></stop><stop offset="20%" stop-color="#1677FF"></stop><stop offset="100%" stop-color="#04A6FF"></stop></linearGradient><linearGradient id="lobe-icons-ant-group-1-_R_0_" x1="4.366%" x2="94.359%" y1="65.982%" y2="32.918%"><stop offset="0%" stop-color="#06F"></stop><stop offset="20%" stop-color="#1677FF"></stop><stop offset="100%" stop-color="#04A6FF"></stop></linearGradient><linearGradient id="lobe-icons-ant-group-2-_R_0_" x1="56.255%" x2="45.986%" y1="99.257%" y2="1.384%"><stop offset="0%" stop-color="#06F"></stop><stop offset="20%" stop-color="#1677FF"></stop><stop offset="100%" stop-color="#04A6FF"></stop></linearGradient></defs></svg>
573
+ ${((Q=E.note)==null?void 0:Q.text)??""}`,[],Array.from(crypto.getRandomValues(new Uint8Array(16)),he=>he.toString(16).padStart(2,"0")).join(""),void 0,[],!0),await ae(()=>fe.updateThread(e,{status:"done"})),M(x("thread.concluded",{channel:be}))}catch(he){throw T(he),he}}})}),o.jsxs("div",{ref:F,className:a==="pane"?"ui-pane-body jv-pane-body":"ui-transcript jv-thread-wide",children:[o.jsxs("div",{ref:J,children:[D&&o.jsx(Xd,{messages:[{...D,thread:null}],members:f,bots:m,me:v,divider:Number.MAX_SAFE_INTEGER,onSettled:()=>{},onPreview:C,onReact:ie,onFold:L,onJump:q,onError:T}),o.jsx("div",{className:"jv-divider","data-tone":"count",role:"separator",children:o.jsx("span",{children:H.length?x("channel.replies",{count:H.length}):x("thread.noReplies")})}),o.jsx(Xd,{messages:H,members:f,bots:m,me:v,divider:Y??Number.MAX_SAFE_INTEGER,before:D==null?void 0:D.createdAt,onSettled:Q=>U(he=>he.map(ke=>ke.id===Q.id?Q:ke)),onPreview:C,...ue})]}),I&&H.length>0&&o.jsx("div",{className:"jv-to-latest",children:o.jsxs("button",{type:"button","aria-label":x("thread.toLatest"),onClick:()=>{var Q;return(Q=F.current)==null?void 0:Q.scrollTo({top:F.current.scrollHeight,behavior:"smooth"})},children:[Ae>0&&o.jsx("span",{children:x("chat.unseen",{count:Ae})}),o.jsx(Be,{name:"chevron-down"})]})})]}),o.jsx(j5,{chatId:e,id:"jarvy-thread-composer",drafts:d,placeholder:x("thread.reply"),scrollRef:F,disabled:!E,initialText:H.length===0&&D&&D.senderId!==v&&je&&!je.deleted?`@${je.name} `:void 0,mention:{bots:m,inside:si(f).filter(Q=>Q.id!==v&&!!(u!=null&&u.memberIds.includes(Q.id))),outside:si(f).filter(Q=>!(u!=null&&u.memberIds.includes(Q.id))),onInvite:k,participants:ye},onSend:xe,onError:T,onNotice:M}),o.jsx(t5,{container:F,drafts:d,chatId:e,members:f,onNotice:M,source:Q=>Q===(D==null?void 0:D.id)?D:H.find(he=>he.id===Q)})]})}const Np={updated:"threadSort.updated",created:"threadSort.created",status:"threadSort.status"},kd=e=>e.lastReplyAt??e.createdAt;function C5(e,a){const i=a==="created"?(r,s)=>s.createdAt-r.createdAt:a==="status"?(r,s)=>+(r.status==="done")-+(s.status==="done")||kd(s)-kd(r):(r,s)=>kd(s)-kd(r);return[...e].sort(i)}function N5(e){const a=`jarvy-thread-sort-${e}`,[i,r]=S.useState(()=>{const s=localStorage.getItem(a);return s==="created"||s==="status"?s:"updated"});return[i,s=>{r(s),localStorage.setItem(a,s)}]}function E5({value:e,onChange:a}){return o.jsxs(gr,{value:e,onValueChange:i=>a(i),children:[o.jsxs(yr,{className:"jv-thread-sort","aria-label":x("threadSort.current",{order:x(Np[e])}),title:x("threadSort.title"),children:[o.jsx(m8,{}),o.jsx(vr,{})]}),o.jsx(xr,{className:"jv-select-menu",position:"popper",sideOffset:4,align:"end",children:Object.keys(Np).map(i=>o.jsx(sa,{value:i,children:x(Np[i])},i))})]})}const T5=e=>ua(e,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});function iI({channel:e,members:a,bots:i,tick:r,onOpen:s,onClose:u,onError:d}){const[f,m]=S.useState(null),[v,y]=S.useState("open"),[g,b]=N5("channel");S.useEffect(()=>{let k=!0;return fe.channelThreads(e.id).then(C=>{k&&m(C.threads)}).catch(C=>{k&&d(C)}),()=>{k=!1}},[e.id,r]);const j=C5((f??[]).filter(k=>v==="all"||k.status===v),g),w=k=>(f??[]).filter(C=>C.status===k).length;return o.jsxs("aside",{className:"ui-pane jv-pane","aria-label":x("threads.list"),children:[o.jsxs("header",{className:"ui-pane-header jv-pane-header",children:[o.jsx("strong",{children:x("channel.threads")}),o.jsxs("span",{className:"jv-muted jv-pane-sub",children:["#",e.title]}),o.jsx("span",{className:"jv-spacer"}),o.jsx(E5,{value:g,onChange:b}),o.jsx(st,{icon:"close",label:x("threads.closeList"),onClick:u})]}),o.jsx("div",{className:"jv-tabs",role:"tablist","aria-label":x("threads.byStatus"),children:[["open",x("threads.openCount",{count:w("open")})],["done",x("threads.doneCount",{count:w("done")})],["all",x("threads.all")]].map(([k,C])=>o.jsx("button",{type:"button",role:"tab","aria-selected":v===k,onClick:()=>y(k),children:C},k))}),o.jsx("div",{className:"ui-pane-body jv-pane-body",children:f===null?o.jsx("p",{className:"jv-picker-empty",children:x("threads.loading")}):j.length===0?o.jsx("p",{className:"jv-picker-empty",children:x("threads.none")}):j.map(k=>{const C=a.find(T=>{var M;return T.id===((M=k.root)==null?void 0:M.senderId)});return o.jsxs("button",{type:"button",className:"jv-thread-item","data-unread":k.unread>0||void 0,onClick:()=>s(k.id),children:[o.jsxs("span",{className:"jv-thread-item-head",children:[o.jsx("strong",{children:k.title}),k.alerts>0?o.jsx("span",{className:"jv-badge",children:k.alerts}):k.unread>0&&o.jsx("span",{className:"jv-count",children:k.unread}),o.jsx("span",{className:"jv-thread-status","data-done":k.status==="done"||void 0,children:x(k.status==="done"?"channel.threadDone":"threads.open")})]}),k.root&&o.jsxs("span",{className:"jv-thread-item-root",children:[o.jsx(Cr,{member:C,bots:i,size:16}),o.jsx("span",{children:bs(k.root)})]}),o.jsxs("span",{className:"jv-muted jv-thread-item-meta",children:[x("channel.replies",{count:k.replies}),k.lastReplyAt?` · ${T5(k.lastReplyAt)}`:"",k.following?` · ${x("threads.following")}`:""]})]},k.id)})})]})}function rI({threads:e,chats:a,members:i,bots:r,onNav:s,renderThread:u}){const[d,f]=S.useState(e),[m,v]=S.useState(null),[y,g]=S.useState("all"),[b,j]=N5("followed");S.useEffect(()=>f(M=>[...e,...M.filter(E=>!e.some(R=>R.id===E.id)).map(E=>({...E,following:!1,unread:0,alerts:0}))]),[e]);const w=C5(d,b).filter(M=>y==="all"||(y==="unread"?M.unread>0:M.status===y)),k=d.filter(M=>M.unread>0).length,C=d.find(M=>M.id===m),T=M=>d.filter(E=>E.status===M).length;return o.jsxs("main",{className:"ui-chat jv-followed-page","aria-label":x("sidebar.followed"),"data-open":C?"":void 0,children:[o.jsxs("section",{className:"jv-followed-list","aria-label":x("threads.list"),children:[o.jsxs("header",{className:"ui-chat-header jv-channel-header",children:[o.jsxs("div",{className:"ui-header-left",children:[o.jsx(st,{icon:"layout-sidebar-left",className:"ui-mobile-only",label:x("common.openNav"),onClick:s}),o.jsx("strong",{className:"jv-channel-title",children:x("sidebar.followed")})]}),o.jsx(E5,{value:b,onChange:j})]}),o.jsx("div",{className:"jv-tabs",role:"tablist","aria-label":x("threads.filter"),children:[["all",x("threads.all")],["unread",k?x("threads.unreadCount",{count:k}):x("threads.unread")],["open",x("threads.openCount",{count:T("open")})],["done",x("threads.doneCount",{count:T("done")})]].map(([M,E])=>o.jsx("button",{type:"button",role:"tab","aria-selected":y===M,onClick:()=>g(M),children:E},M))}),o.jsx("div",{className:"jv-followed-items",children:w.length===0?o.jsx("p",{className:"jv-picker-empty",children:x({all:"threads.none",unread:"threads.noneUnread",open:"threads.noneOpen",done:"threads.noneDone"}[y])}):w.map(M=>{const E=i.find(D=>{var A;return D.id===((A=M.root)==null?void 0:A.senderId)}),R=a.find(D=>D.id===M.parentId);return o.jsxs("button",{type:"button",className:"jv-thread-item","data-unread":M.unread>0||void 0,"aria-current":M.id===m||void 0,onClick:()=>v(M.id),children:[o.jsxs("span",{className:"jv-thread-item-head",children:[o.jsx("strong",{children:M.title}),M.alerts>0?o.jsx("span",{className:"jv-badge",children:M.alerts}):M.unread>0&&o.jsx("span",{className:"jv-count",children:M.unread}),o.jsx("span",{className:"jv-thread-status","data-done":M.status==="done"||void 0,children:x(M.status==="done"?"channel.threadDone":"threads.open")})]}),M.root&&o.jsxs("span",{className:"jv-thread-item-root",children:[o.jsx(Cr,{member:E,bots:r,size:16}),o.jsx("span",{children:bs(M.root)})]}),o.jsxs("span",{className:"jv-muted jv-thread-item-meta",children:["#",(R==null?void 0:R.title)??""," · ",x("channel.replies",{count:M.replies}),M.lastReplyAt?` · ${T5(M.lastReplyAt)}`:"",M.following?"":` · ${x("threads.notFollowing")}`]})]},M.id)})})]}),C?u(C,()=>v(null)):o.jsx("div",{className:"jv-followed-empty",children:o.jsx("p",{children:x("threads.pick")})})]})}function lI({pane:e,followedView:a,followed:i,chats:r,sections:s,members:u,bots:d,statuses:f,meId:m,drafts:v,tick:y,paneChannel:g,activeBot:b,botDirects:j,find:w,onPane:k,onNav:C,onBackToChannel:T,onAddMembers:M,onOpenBot:E,onPin:R,onMute:D,onDeleteChannel:A,onChannelSaved:H,onThreadChanged:U,onInvite:Y,onPreview:z,onNotice:V,onError:F,paneWidth:J,onResize:G}){var P,W;const $=(e==null?void 0:e.kind)==="thread"?e:null,K=($==null?void 0:$.mode)==="full",I=()=>k(null);return o.jsxs(o.Fragment,{children:[a&&!K&&o.jsx(rI,{threads:i,chats:r,members:u,bots:d,onNav:C,renderThread:(_,ae)=>o.jsx(Pb,{threadId:_.id,mode:"embed",channel:r.find(ie=>ie.id===_.parentId),drafts:v,members:u,bots:d,me:m,tick:y,onNav:C,onChanged:U,onClose:ae,onToggleMode:()=>T({id:_.id,parentId:_.parentId},!0),onInvite:ie=>Y(_.parentId,ie),onPreview:z,onError:F,onNotice:V},_.id)}),$&&o.jsx(Pb,{threadId:$.id,mode:$.mode,showSummary:$.summary,focus:$.focus,onSearch:w.search,channel:r.find(_=>_.id===$.parentId),drafts:v,members:u,bots:d,me:m,tick:y,onNav:C,onChanged:U,onClose:()=>K?T($,!1):I(),onToggleMode:()=>K?T($,!0):k({...$,mode:"full"}),onInvite:_=>Y($.parentId,_),onPreview:z,onError:F,onNotice:V},`${$.id}:${((P=$.focus)==null?void 0:P.id)??""}:${((W=$.focus)==null?void 0:W.passage)??""}`),(e==null?void 0:e.kind)==="search"&&o.jsx(tI,{chat:e.chat,chats:r,members:u,focusKey:w.focusKey,onOpenMessage:w.openMessage,onClose:I,onError:F}),(e==null?void 0:e.kind)==="threads"&&g&&o.jsx(iI,{channel:g,members:u,bots:d,tick:y,onOpen:_=>k({kind:"thread",id:_,parentId:g.id,mode:"pane"}),onClose:I,onError:F}),(e==null?void 0:e.kind)==="info"&&g&&o.jsx(eI,{channel:g,page:e.page,sections:s,members:si(u),bots:d,statuses:f,me:m,onPage:_=>k({kind:"info",page:_}),onPin:()=>R(g),onMute:()=>D(g),onAdd:()=>M(g),onBot:E,onDelete:()=>A(g),onChanged:H,onClose:I,onError:F}),(e==null?void 0:e.kind)==="botdms"&&b&&!g&&o.jsx(ZB,{bot:b,chats:j,members:u,bots:d,me:m,tick:y,onClose:I,onPreview:z,onError:F}),e&&!K&&o.jsx("div",{className:"jv-resize",style:{right:J-4},onPointerDown:G,role:"separator","aria-orientation":"vertical","aria-label":x("app.resizePane")})]})}const Hb="@goodfish/jarvy",A5="0.10.1",oI={url:"git+https://github.com/AzzzGoodFish/Jarvy.git"},sI="Apache-2.0",m0=oI.url.replace(/^git\+/,"").replace(/\.git$/,""),Ub=`${m0}/blob/v${A5}`,cI=[{label:"about.source",detail:m0.replace(/^https:\/\//,""),href:m0},{label:"about.package",detail:Hb,href:`https://www.npmjs.com/package/${Hb}`},{label:"about.license",detail:sI,href:`${Ub}/LICENSE`},{label:"about.notices",detail:"THIRD_PARTY_NOTICE.md",href:`${Ub}/THIRD_PARTY_NOTICE.md`}];function uI(){return o.jsxs("div",{className:"jv-page",children:[o.jsx("header",{className:"jv-page-header",children:o.jsx("h2",{children:x("settings.about")})}),o.jsxs("div",{className:"jv-list",children:[o.jsxs("div",{className:"jv-list-row jv-static-row jv-about-intro",children:[o.jsxs("div",{className:"jv-row-text",children:[o.jsx("strong",{children:"Jarvy"}),o.jsx("span",{children:x("about.tagline")})]}),o.jsx("span",{className:"jv-row-meta",children:x("about.version",{version:A5})})]}),cI.map(e=>o.jsxs("a",{className:"jv-list-row jv-link-row",href:e.href,target:"_blank",rel:"noreferrer",children:[o.jsxs("div",{className:"jv-row-text",children:[o.jsx("strong",{children:x(e.label)}),o.jsx("span",{children:e.detail})]}),o.jsx(S8,{"aria-hidden":"true"})]},e.label))]})]})}function dI(){const[e,a]=S.useState(document.documentElement.classList.contains("dark")),i=s=>{Gd(s?"dark":"light"),a(s)},r=(s,u,d,f,m)=>o.jsxs("button",{type:"button",role:"radio","aria-checked":d,lang:m,className:"jv-list-row jv-choice-row",onClick:f,children:[o.jsx("span",{className:"jv-row-text",children:o.jsx("strong",{children:u})}),d&&o.jsx(Ra,{"aria-hidden":"true"})]},s);return o.jsxs("div",{className:"jv-page",children:[o.jsx("header",{className:"jv-page-header",children:o.jsx("h2",{children:x("settings.general")})}),o.jsxs("section",{className:"jv-section","aria-labelledby":"general-language",children:[o.jsx("h3",{id:"general-language",className:"jv-section-title",children:x("general.language")}),o.jsx("div",{className:"jv-list",role:"radiogroup","aria-labelledby":"general-language",children:Jb.map(s=>r(s,_p(s,"name"),to()===s,()=>tj(s),s))})]}),o.jsxs("section",{className:"jv-section","aria-labelledby":"general-theme",children:[o.jsx("h3",{id:"general-theme",className:"jv-section-title",children:x("general.theme")}),o.jsxs("div",{className:"jv-list",role:"radiogroup","aria-labelledby":"general-theme",children:[r("light",x("general.light"),!e,()=>i(!1)),r("dark",x("general.dark"),e,()=>i(!0))]})]})]})}const fI=`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M9.797 6.282a.451.451 0 01-.336-.315 1.019 1.019 0 010-.505c.156-.86.3-1.725.501-2.577.14-.7.42-1.367.823-1.96.305-.431.75-.746 1.262-.89.877-.217 1.24.629.937 1.348-.259.593-.877.914-1.334 1.348-.835.795-1.096 2.14-1.336 3.212a.427.427 0 01-.186.277.437.437 0 01-.331.062z" fill="url(#lobe-icons-ant-group-0-_R_0_)" transform="translate(3)"></path><path d="M6.334 4.672c.33-.121.682.146.946.297.278.145.587.219.901.214.231.01.466 0 .688.018 4.098.176 7.484 3.22 8.05 7.237.565 4.016-1.852 7.859-5.745 9.134-3.894 1.276-8.153-.38-10.126-3.935A8.339 8.339 0 013.133 7.081c.348-.278.716-.53 1.102-.755a8.404 8.404 0 001.318-.79c.28-.243.45-.742.781-.864zm4.406 2.15c-2.841.003-4.898 2.533-4.628 5.642.27 3.109 2.781 5.641 5.613 5.665 2.832.024 4.932-2.512 4.658-5.644-.273-3.133-2.802-5.666-5.643-5.663zm.357.57a4.707 4.707 0 013.304 1.446 5.703 5.703 0 011.643 3.49 4.841 4.841 0 01-1.141 3.705v.015a3.923 3.923 0 01-2.808 1.303 4.664 4.664 0 01-3.367-1.387 5.678 5.678 0 01-1.71-3.518 4.832 4.832 0 011.14-3.753 3.923 3.923 0 012.813-1.3h.126z" fill="url(#lobe-icons-ant-group-1-_R_0_)" transform="translate(3)"></path><path d="M2.346 2.054a1.26 1.26 0 01.384-.594.842.842 0 011.165.11c.694.82.169 2.078.142 3.02.013.805.208 1.597.57 2.318.084.134.147.279.186.43a.539.539 0 01-.3.577c-.345.17-.568-.19-.709-.446-.324-.6-.617-1.216-.877-1.846a8.698 8.698 0 01-.618-1.987 7.523 7.523 0 01-.051-.37 3.717 3.717 0 01-.024-.34 2.506 2.506 0 01.132-.872z" fill="url(#lobe-icons-ant-group-2-_R_0_)" transform="translate(3)"></path><defs><linearGradient id="lobe-icons-ant-group-0-_R_0_" x1="31.373%" x2="61.365%" y1="95.551%" y2="-.348%"><stop offset="0%" stop-color="#06F"></stop><stop offset="20%" stop-color="#1677FF"></stop><stop offset="100%" stop-color="#04A6FF"></stop></linearGradient><linearGradient id="lobe-icons-ant-group-1-_R_0_" x1="4.366%" x2="94.359%" y1="65.982%" y2="32.918%"><stop offset="0%" stop-color="#06F"></stop><stop offset="20%" stop-color="#1677FF"></stop><stop offset="100%" stop-color="#04A6FF"></stop></linearGradient><linearGradient id="lobe-icons-ant-group-2-_R_0_" x1="56.255%" x2="45.986%" y1="99.257%" y2="1.384%"><stop offset="0%" stop-color="#06F"></stop><stop offset="20%" stop-color="#1677FF"></stop><stop offset="100%" stop-color="#04A6FF"></stop></linearGradient></defs></svg>
574
574
  `,hI=`<svg fill="currentColor" fill-rule="evenodd" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13.827 3.52h3.603L24 20h-3.603l-6.57-16.48zm-7.258 0h3.767L16.906 20h-3.674l-1.343-3.461H5.017l-1.344 3.46H0L6.57 3.522zm4.132 9.959L8.453 7.687 6.205 13.48H10.7z"></path></svg>
575
575
  `,mI=`<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7.242 1.613A1.11 1.11 0 018.295.857h6.977L8.03 22.316a1.11 1.11 0 01-1.052.755h-5.43a1.11 1.11 0 01-1.053-1.466L7.242 1.613z" fill="url(#lobe-icons-azure-0-_R_0_)"></path><path d="M18.397 15.296H7.4a.51.51 0 00-.347.882l7.066 6.595c.206.192.477.298.758.298h6.226l-2.706-7.775z" fill="#0078D4"></path><path d="M15.272.857H7.497L0 23.071h7.775l1.596-4.73 5.068 4.73h6.665l-2.707-7.775h-7.998L15.272.857z" fill="url(#lobe-icons-azure-1-_R_0_)"></path><path d="M17.193 1.613a1.11 1.11 0 00-1.052-.756h-7.81.035c.477 0 .9.304 1.052.756l6.748 19.992a1.11 1.11 0 01-1.052 1.466h-.12 7.895a1.11 1.11 0 001.052-1.466L17.193 1.613z" fill="url(#lobe-icons-azure-2-_R_0_)"></path><defs><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-azure-0-_R_0_" x1="8.247" x2="1.002" y1="1.626" y2="23.03"><stop stop-color="#114A8B"></stop><stop offset="1" stop-color="#0669BC"></stop></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-azure-1-_R_0_" x1="14.042" x2="12.324" y1="15.302" y2="15.888"><stop stop-opacity=".3"></stop><stop offset=".071" stop-opacity=".2"></stop><stop offset=".321" stop-opacity=".1"></stop><stop offset=".623" stop-opacity=".05"></stop><stop offset="1" stop-opacity="0"></stop></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-azure-2-_R_0_" x1="12.841" x2="20.793" y1="1.626" y2="22.814"><stop stop-color="#3CCBF4"></stop><stop offset="1" stop-color="#2892DF"></stop></linearGradient></defs></svg>
576
576
  `,pI=`<svg fill="currentColor" fill-rule="evenodd" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M2.316 4.8h14.682v4.8H7.31a.302.302 0 00-.308.3v4.2c0 .171.14.3.308.3h9.688v4.8h-4.686a.302.302 0 00-.308.3v4.2c0 .171.141.3.308.3h4.378a.297.297 0 00.308-.3v-4.5h4.694a.302.302 0 00.308-.3v-4.2c0-.171-.14-.3-.308-.3h-4.694V9.6h4.694A.302.302 0 0022 9.3V5.1c0-.171-.14-.3-.308-.3h-4.694V.3c0-.171-.14-.3-.308-.3H2.316A.31.31 0 002 .3v4.2c0 .171.14.3.316.3z"></path></svg>
@@ -1,4 +1,4 @@
1
1
  <!doctype html>
2
- <html lang="zh-CN"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#fdfdfe"/><title>Jarvy</title><link rel="icon" href="/favicon.svg" type="image/svg+xml"/><link rel="icon" href="/favicon-32.png" sizes="32x32" type="image/png"/><link rel="apple-touch-icon" href="/apple-touch-icon.png"/><link rel="manifest" href="/manifest.webmanifest"/> <script type="module" crossorigin src="/assets/index-4qw6VTNA.js"></script>
2
+ <html lang="zh-CN"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#fdfdfe"/><title>Jarvy</title><link rel="icon" href="/favicon.svg" type="image/svg+xml"/><link rel="icon" href="/favicon-32.png" sizes="32x32" type="image/png"/><link rel="apple-touch-icon" href="/apple-touch-icon.png"/><link rel="manifest" href="/manifest.webmanifest"/> <script type="module" crossorigin src="/assets/index-Bj3AzL-c.js"></script>
3
3
  <link rel="stylesheet" crossorigin href="/assets/index-BoYSS3TL.css">
4
4
  </head><body><div id="root"></div></body></html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodfish/jarvy",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "A local chat where people and AI Bots work together: DMs, channels and threads, with long-running Pi agents as members.",
5
5
  "keywords": [
6
6
  "chat",