dsh-hive-swarm 2.1.0 → 2.1.2
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/README.md +2 -2
- package/client/dist.js +229 -25
- package/host.mjs +24 -10
- package/package.json +2 -2
- package/routes.mjs +10 -3
- package/runner.mjs +53 -8
- package/skills/hive-swarm/SKILL.md +4 -4
package/client/dist.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Generated by scripts/build-dsh-client.mjs. Host React is intentionally external.
|
|
2
2
|
window.__ModuleLoader__.load({id:"dsh-hive-swarm",factory(require){
|
|
3
3
|
var module={exports:{}};var exports=module.exports;
|
|
4
|
-
var Ot=Object.create;var $e=Object.defineProperty;var Ut=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var Yt=Object.getPrototypeOf,$t=Object.prototype.hasOwnProperty;var tt=(n,s)=>()=>(s||n((s={exports:{}}).exports,s),s.exports),Xt=(n,s)=>{for(var l in s)$e(n,l,{get:s[l],enumerable:!0})},dt=(n,s,l,f)=>{if(s&&typeof s=="object"||typeof s=="function")for(let m of Jt(s))!$t.call(n,m)&&m!==l&&$e(n,m,{get:()=>s[m],enumerable:!(f=Ut(s,m))||f.enumerable});return n};var Ue=(n,s,l)=>(l=n!=null?Ot(Yt(n)):{},dt(s||!n||!n.__esModule?$e(l,"default",{value:n,enumerable:!0}):l,n)),Vt=n=>dt($e({},"__esModule",{value:!0}),n);var vt=tt((jn,mt)=>{var it={};(()=>{"use strict";let n=Math.sqrt(3),s=new Set(["for","in","on","to","with","of","by","at","from","into","onto","about","as","and","or","the","a","an","via","per","within"]);function l(t){return t.kind==="brief"||t.kind==="message"||!t.kind&&t.author!=="system"}function f(t,{live:a=!1,now:p=Date.now()}={}){let c=t.map(z=>Date.parse(z.time)).filter(Number.isFinite);if(!c.length)return"<1m";let E=Math.max(0,Math.floor(((a?p:c.at(-1))-c[0])/6e4));return E?E<60?E+"m":Math.floor(E/60)+"h"+(E%60?" "+E%60+"m":""):"<1m"}function m(t){return!!(t.unmentioned&&!t.mentions&&!t.broadcasts)}function r(t){let a=t&&typeof t=="object",p=a?String(t.taskLabel??"").trim():"";if(p)return p;let c=String(a?t.brief??t.task??"":t??""),E=a&&t.name?String(t.name).trim():"";if(!c.trim())return E||"Swarm task";let z=c.replace(/```[\s\S]*?```/g," ").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[`*_~>#]/g," ").replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm,""),J=/^(?:strict\s+file\s+ownership|do\s+not\s+touch|reference\s+screenshots|requirements?|first\s*\(|deliverables?)\b/i,F=(z.split(/\r?\n+/).map(B=>B.trim()).filter(B=>B&&!J.test(B)).slice(0,8).join(" ")||z).replace(/\s+/g," ").trim(),oe=[/^you\s+have\s+just\s+started[.:!]*\s*/i,/^your\s+assignment(?:\s*\([^)]*\))?[:.\s-]*/i,/^you\s+are(?:\s+(?:a|an|the))?\s+(?:hive\s+swarm\s+)?(?:member|agent|worker|owner)(?:\s+['"]?@?[a-z0-9_-]+['"]?)?(?:\s+(?:for|on|in)\s+hive\s+swarm(?:\s+\d+(?:\.\d+)*)?)?[.,:;\s-]*/i,/^as(?:\s+(?:a|an|the))?\s+[a-z0-9 _-]+,\s*/i,/^(?:your\s+)?(?:task|goal|role|mission|assignment)\s*(?:is\s+to|is|:)\s*/i,/^you\s+(?:own|will\s+own|are\s+responsible\s+for|need\s+to|should|must)\s+(?:the\s+)?/i,/^please\s+/i,/^for\s+hive\s+swarm(?:\s+\d+(?:\.\d+)*)?[.,:;\s-]*/i];for(let B=0;B<3;B++){let V=!1;for(let A of oe){let I=F.replace(A,"").trim();I!==F&&(F=I,V=!0)}if(!V)break}if(F=F.replace(/\s+(?:in|on)\s+(?:your|the)\s+(?:shared\s+)?worktree.*$/i,"").replace(/\s+for\s+hive\s+swarm(?:\s+\d+(?:\.\d+)*)?\.?$/i,"").replace(/\s+/g," ").trim(),F.length>64){let B=/^(.{18,64}?)[.!?](?:\s|$)/.exec(F);B&&(F=B[1])}let D=F.replace(/[.,:;!?-]+$/g,"").split(/\s+/).filter(Boolean);D.length>10&&(D=D.slice(0,10));let i=D.join(" ");for(;i.length>64&&D.length>1;)D.pop(),i=D.join(" ");let L=i.lastIndexOf("("),T=i.lastIndexOf(")");if(L!==-1&&L>T){let B=i.slice(0,L).replace(/[,:;-\s]+$/,"").trim();B.split(/\s+/).length>=2?(i=B,D=i.split(/\s+/).filter(Boolean)):(i=i.replace(/\(/g,""),D=i.split(/\s+/).filter(Boolean))}for(;D.length>2&&s.has(D.at(-1).replace(/[,:;!?-]+$/g,"").toLowerCase());)D.pop();return i=D.join(" ").replace(/[,:;!?-]+$/g,"").trim(),i.length>64&&(i=i.slice(0,64).replace(/\s+\S*$/,"").replace(/[,:;!?-]+$/g,"").trim()),i?i[0].toUpperCase()+i.slice(1):E||"Swarm task"}function C(t,a,p,{hideInactive:c=!1,expandBroadcast:E=!1}={}){let z=new Map([["coordinator",{name:"coordinator",role:"coordinator",status:"waiting"}]]);for(let i of a)z.set(i.name,i);let J=new Set,ne=new Map,F=new Map,oe=0;function D(i){z.has(i)||z.set(i,{name:i,status:"observer"}),J.add(i)}for(let i of t){if(i.seq>p||!l(i))continue;let{author:L}=i,T=[...new Set([...i.targets??[],...i.coordinatorMention?["coordinator"]:[]])];D(L);let B=ne.get(L)??{posts:0,mentions:0,broadcasts:0,unmentioned:0,lastSeq:0};B.posts++,B.lastSeq=i.seq,ne.set(L,B);let V=i.broadcast??/(?:^|[^a-z0-9_])@all(?![a-z0-9_-])/i.test(i.text??"");V&&(B.broadcasts++,oe++),!V&&!i.coordinatorMention&&!T.some(A=>A!==L)&&B.unmentioned++;for(let A of new Set(T)){if(A===L||(D(A),V&&!E))continue;let I=L+">"+A,P=F.get(I)??{from:L,to:A,count:0,direct:0,broadcast:0,lastSeq:0};P.count++,V?P.broadcast++:P.direct++,P.lastSeq=i.seq,B.mentions++,F.set(I,P)}}return{nodes:[...z.values()].filter(i=>!c||J.has(i.name)).map(i=>({...i,...ne.get(i.name)})),links:[...F.values()],broadcasts:oe}}function M(t,a){return t>6||t>3&&a<440}function N(t){return Math.max(1,Math.floor(t/120))}function w(t,a){if(M(t,a)){let p=Math.ceil(t/N(a));return Math.max(340,p*124+44)}return t>=6?470:t===5?450:t===4?400:0}function u(t,a,p){let c=new Map;if(!t.length)return c;if(M(t.length,a)){let L=N(a),T=Math.ceil(t.length/L),B=a/L,V=56,A=66,I=Math.max(0,p-V-A);return t.forEach((P,$)=>{let le=Math.floor($/L),Z=Math.min(L,t.length-le*L),re=T===1?Math.max(V,Math.min(p-A,p/2-8)):V+le/(T-1)*I;c.set(P.name,{x:B*($%L+.5+(L-Z)/2),y:re})}),c}let E=t.find(L=>L.role==="coordinator")??t[0];if(!E)return c;let z=t.filter(L=>L!==E),J=56,ne=66,F=(J+(p-ne))/2,oe=Math.max(48,(p-J-ne)/2),D=Math.min(68,Math.max(54,a*.1)),i=Math.max(44,Math.min(a*.4,a/2-D));if(!z.length)return c.set(E.name,{x:a/2,y:F}),c;if(z.length===1){let L=Math.max(54,Math.min(i*.72,a/2-D));return c.set(E.name,{x:a/2-L,y:F}),c.set(z[0].name,{x:a/2+L,y:F}),c}if(z.length===2){let L=Math.max(J,F-oe*.78),T=Math.min(p-ne,F+oe*.72),B=Math.max(54,Math.min(i*.85,a/2-D));return c.set(E.name,{x:a/2,y:L}),c.set(z[0].name,{x:a/2-B,y:T}),c.set(z[1].name,{x:a/2+B,y:T}),c}return c.set(E.name,{x:a/2,y:F}),z.forEach((L,T)=>{let B=-Math.PI/2+T*Math.PI*2/z.length;c.set(L.name,{x:a/2+Math.cos(B)*i,y:F+Math.sin(B)*oe})}),c}function x(t,a){return t>12||t>5&&a<380||t>8&&a<465}function d(t,a){if(x(t,a)){let p=Math.max(1,Math.floor(Math.max(a-24,140)/145)),c=Math.ceil(t/p);return Math.max(360,c*68+80)}return t>=11?680:t>=9?560:t>=7?470:t>=5?400:360}function b(t,a,p){let c=new Map;if(!t?.length)return c;let E=a<465,z=[],J=t.find(A=>A.role==="coordinator"||A.name==="coordinator");J&&z.push(J);for(let A of t)A!==J&&z.push(A);if(x(z.length,a)){let A=Math.max(...z.map(X=>v(X,{variant:"pill",narrow:E}).halfW*2),116),I=Math.max(1,Math.floor((a-24)/(A+14))),P=Math.ceil(z.length/I),$=a/I,le=42,re=Math.max(40,p-le-46);return z.forEach((X,de)=>{let ae=Math.floor(de/I),ue=Math.min(I,z.length-ae*I),_=P===1?p/2:le+ae/(P-1)*re,ie=$*(de%I+.5+(I-ue)/2);c.set(X.name,{x:ie,y:_})}),c}if(z.length===1)return c.set(z[0].name,{x:a/2,y:p/2}),c;let ne=Math.max(...z.map(A=>v(A,{variant:"pill",narrow:E}).halfW),56),F=Math.max(...z.map(A=>v(A,{variant:"pill",narrow:E}).halfH),17),oe=F+18,D=F+22,i=Math.min(a*.28,ne+18),L=a/2,T=(oe+(p-D))/2,B=Math.max(48,Math.min(a*.42,a/2-i)),V=Math.max(44,(p-oe-D)/2);return z.forEach((A,I)=>{let P=-Math.PI/2+I*Math.PI*2/z.length;c.set(A.name,{x:L+Math.cos(P)*B,y:T+Math.sin(P)*V})}),c}function H(t,a){let p=String(t??"").trim();if(!p)return 1;let c=Math.max(6,a),E=p.match(/[^-\s_/]+[-\s_/]*|[-\s_/]+/g)??[p],z=1,J=0;for(let ne of E){let F=ne;for(;F.length>c;)J>0&&(z++,J=0),F=F.slice(c),z++;J>0&&J+F.length>c?(z++,J=F.length):J+=F.length}return Math.max(1,z)}function v(t,{variant:a="card",cardWidth:p,narrow:c=!1}={}){if(a==="pill"){let F=String(t?.name??""),oe=F==="user"?"You":F==="system"?"System":F,D=c?16:18,i=c?156:210,L=c?88:104,T=c?6.4:7.2;return{halfW:Math.min(i,Math.max(L,(c?38:46)+oe.length*T))/2,halfH:D,offsetX:0,offsetY:0,radius:D}}if(a==="hex"){let F=c?84:128,oe=String(t?.name??""),D=oe==="user"?"You":oe==="system"?"System":"@"+oe,i=Math.max(8,Math.floor((F-12)/6.3)),L=H(D,i),T=Math.min(F,Math.max(38,12+D.length*6.3)),B=m(t??{}),V=Math.max(B?32:28,T/2),A=B?32:t?.broadcasts?29:24,I=29+L*15+4;return{halfW:V,halfH:(A+I)/2,offsetX:0,offsetY:(I-A)/2,radius:10}}let E=p??(c?92:112),z=Math.max(7,Math.floor((E-20)/7.4)),ne=64+H(t?.name??"",z)*16;return{halfW:E/2,halfH:ne/2,offsetX:0,offsetY:0,radius:10}}function y(t,a){if(!a)return{cx:t.x,cy:t.y,halfW:26,halfH:26,radius:10};if(Number.isFinite(a.left)&&Number.isFinite(a.right)&&Number.isFinite(a.top)&&Number.isFinite(a.bottom))return{cx:t.x+(a.right-a.left)/2,cy:t.y+(a.bottom-a.top)/2,halfW:(a.left+a.right)/2,halfH:(a.top+a.bottom)/2,radius:Math.max(0,a.radius??8)};let p=Number.isFinite(a.halfW)?a.halfW:Number.isFinite(a.width)?a.width/2:26,c=Number.isFinite(a.halfH)?a.halfH:Number.isFinite(a.height)?a.height/2:26;return{cx:Number.isFinite(a.cx)?a.cx:t.x+(a.offsetX??0),cy:Number.isFinite(a.cy)?a.cy:t.y+(a.offsetY??0),halfW:Math.max(1,p),halfH:Math.max(1,c),radius:Math.max(0,a.radius??8)}}function U(t,a,p){let c=Math.max(0,Math.min(p.radius??0,p.halfW,p.halfH)),E=Math.abs(t-p.cx)-(p.halfW-c),z=Math.abs(a-p.cy)-(p.halfH-c);return Math.hypot(Math.max(E,0),Math.max(z,0))+Math.min(Math.max(E,z),0)-c}function j(t,a,p,c){let E=1-c;return{x:E*E*t.x+2*E*c*a.x+c*c*p.x,y:E*E*t.y+2*E*c*a.y+c*c*p.y}}function k(t,a,p,c,E){let z=(1-c)*(1-E),J=(1-c)*E+c*(1-E),ne=c*E;return{x:z*t.x+J*a.x+ne*p.x,y:z*t.y+J*a.y+ne*p.y}}function G(t,a,p,c,E,z,J,ne){let oe=-1;for(let ie=0;ie<=32;ie++){let he=j(t,a,p,ie/32);U(he.x,he.y,c)<=z&&(oe=ie)}if(oe>=32)return null;let D=0;if(oe>=0){let ie=oe/32,he=(oe+1)/32;for(let pe=0;pe<22;pe++){let ke=(ie+he)/2,xe=j(t,a,p,ke);U(xe.x,xe.y,c)<=z?ie=ke:he=ke}D=he}let i=-1,L=Math.max(0,oe+1);for(let ie=L;ie<=32;ie++){let he=j(t,a,p,ie/32);if(U(he.x,he.y,E)<=J){i=ie;break}}if(i<=0)return null;let T=(i-1)/32,B=i/32;for(let ie=0;ie<22;ie++){let he=(T+B)/2,pe=j(t,a,p,he);U(pe.x,pe.y,E)<=J?B=he:T=he}let V=T;if(V<=D+1e-4)return null;let A=j(t,a,p,D),I=j(t,a,p,V),P=Math.hypot(I.x-A.x,I.y-A.y);if(P<ne)return null;let $=k(t,a,p,D,V),le=j(t,a,p,(D+V)/2),Z=I.x-$.x,re=I.y-$.y,X=$.x-A.x,de=$.y-A.y,ae=Math.hypot(Z,re)>1e-4?Math.atan2(re,Z):Math.atan2(I.y-A.y,I.x-A.x),ue=Math.hypot(X,de)>1e-4?Math.atan2(de,X):Math.atan2(I.y-A.y,I.x-A.x),_="M"+A.x.toFixed(1)+" "+A.y.toFixed(1)+" Q"+$.x.toFixed(1)+" "+$.y.toFixed(1)+" "+I.x.toFixed(1)+" "+I.y.toFixed(1);return{start:A,control:$,end:I,mid:le,startAngle:ue,endAngle:ae,length:P,tStart:D,tEnd:V,d:_}}function ce(t,a){if(!a.length)return 1/0;let p=1/0;for(let c=0;c<=24;c++){let E=j(t.start,t.control,t.end,c/24);for(let z of a){let J=U(E.x,E.y,z);J<p&&(p=J)}}for(let c of a){let E=U(t.mid.x,t.mid.y,c)-10;E<p&&(p=E)}return p}function O(t,a,p,c,{marginStart:E=6,marginEnd:z=7,bidirectional:J=!1,bend:ne,obstacles:F=[],obstacleMargin:oe=8,minLength:D=8}={}){if(!t||!a)return null;let i=y(t,p),L=y(a,c),T={x:i.cx,y:i.cy},B={x:L.cx,y:L.cy},V=B.x-T.x,A=B.y-T.y,I=Math.hypot(V,A);if(I<1)return null;let P=V/I,le=-(A/I),Z=P,re=F.map(ae=>ae?.box?y(ae,ae.box):y(ae,ae)),X=[];if(Number.isFinite(ne))X.push(ne);else if(J){let ae=Math.min(34,Math.max(18,I*.145));X.push(ae,Math.min(54,ae*1.45),Math.max(10,ae*.55),Math.min(72,I*.3),Math.max(6,ae*.3))}else{let ae=Math.min(20,Math.max(8,I*.065)),ue=Math.min(82,I*.34);X.push(ae,-ae,0,Math.min(ue,ae*2),-Math.min(ue,ae*2),Math.min(ue,ae*3.2),-Math.min(ue,ae*3.2),ue,-ue)}let de=(ae,ue,_)=>{let ie=null,he=-1/0;for(let pe of X){let ke={x:(T.x+B.x)/2+le*pe,y:(T.y+B.y)/2+Z*pe},xe=G(T,ke,B,i,L,ae,ue,_);if(!xe)continue;let Me=ce(xe,re),qe={...xe,bend:pe,clearance:Me};if(Me>=oe)return qe;Me>he&&(he=Me,ie=qe)}return ie};return de(E,z,D)??de(Math.min(E,2),Math.min(z,3),Math.min(D,4))}function R(t,a,{variant:p="card",boxes:c,cardWidth:E,narrow:z=!1,marginStart:J=6,marginEnd:ne=7,obstacleMargin:F=8,minLength:oe=8}={}){let D=new Map;for(let P of t.nodes??[]){let $=c?.get?.(P.name);D.set(P.name,$??v(P,{variant:p,cardWidth:E,narrow:z}))}let i=new Set((t.links??[]).map(P=>P.from+">"+P.to)),L=new Map,T=[],B=(P,$)=>{let le=[];for(let Z of t.nodes??[]){if(Z.name===P||Z.name===$)continue;let re=a.get(Z.name);re&&le.push({x:re.x,y:re.y,box:D.get(Z.name)})}return le};for(let P of t.links??[]){let $=a.get(P.from),le=a.get(P.to);if(!$||!le)continue;let Z=D.get(P.from)??v({name:P.from},{variant:p,cardWidth:E,narrow:z}),re=D.get(P.to)??v({name:P.to},{variant:p,cardWidth:E,narrow:z}),X=B(P.from,P.to),de=i.has(P.to+">"+P.from),ae=O($,le,Z,re,{marginStart:J,marginEnd:ne,bidirectional:de,obstacles:X,obstacleMargin:F,minLength:oe});if(ae){let ue={link:P,edge:ae,bidirectional:de,fromBox:Z,toBox:re,obstacles:X};T.push(ue),L.set(P.from+">"+P.to,ue)}}for(let P of T){if(!P.bidirectional||P.edge.clearance>=Math.min(F,16))continue;let $=L.get(P.link.to+">"+P.link.from);if(!$||$.edge.clearance<Math.min(F,16))continue;let le=a.get(P.link.from),Z=a.get(P.link.to);for(let re of[-18,-26,-36,-48]){let X=O(le,Z,P.fromBox,P.toBox,{marginStart:J,marginEnd:ne,bidirectional:!0,bend:re,obstacles:P.obstacles,obstacleMargin:F,minLength:oe});if(!X||X.clearance<10)continue;let de=Math.max($.edge.bend,Math.abs(re)+28),ae=O(Z,le,$.fromBox,$.toBox,{marginStart:J,marginEnd:ne,bidirectional:!0,bend:de,obstacles:$.obstacles,obstacleMargin:F,minLength:oe});if(ae&&ae.clearance>=10&&Math.hypot(X.mid.x-ae.mid.x,X.mid.y-ae.mid.y)>=12){P.edge=X,$.edge=ae;break}}}let V=[],A=(P,$,le)=>{for(let Z of $){let re=Z?.box?y(Z,Z.box):y(Z,Z);if(U(P.x,P.y,re)<le)return!1}for(let Z of V)if(Math.hypot(P.x-Z.x,P.y-Z.y)<26)return!1;return!0},I=[];for(let P of t.nodes??[]){let $=a.get(P.name);$&&I.push({x:$.x,y:$.y,box:D.get(P.name)})}for(let P of T){let{edge:$,link:le}=P;if($.length<40)continue;let Z=$.start,re=$.control,X=$.end,de=$.mid;if(!A(de,I,12))for(let ae of[.38,.62,.32,.68,.44,.56]){let ue=j(Z,re,X,ae);if(A(ue,I,12)){de=ue;break}}$.mid=de,le.count>1&&V.push(de)}return T.map(({link:P,edge:$,bidirectional:le})=>({link:P,edge:$,bidirectional:le}))}function Y(t,a,p){let c=p==null?1/0:Number(p),E=(t??[]).filter(_=>l(_)&&Number.isFinite(_.seq)).slice().sort((_,ie)=>_.seq-ie.seq),z=E.reduce((_,ie)=>Math.max(_,ie.seq),0),J=c>=z,ne=E.filter(_=>_.seq<=c),F=ne.at(-1)??null,oe=new Map,D=new Map,i=new Map,L=new Map;for(let _ of ne){D.set(_.author,_.seq),oe.set(_.author,_);let ie=new Set([..._.targets??[],..._.coordinatorMention?["coordinator"]:[]]);for(let he of ie)_.kind==="brief"&&i.set(he,_.seq),L.set(he,_.seq)}let T=a??[],B=T.find(_=>_.role==="coordinator"||_.name==="coordinator")??{name:"coordinator",role:"coordinator",status:"waiting"},V=T.filter(_=>_.role!=="coordinator"&&_.name!=="coordinator"),A=[{id:"working",label:"Working",tone:"working"},{id:"waiting",label:"Waiting",tone:"waiting"},{id:"needs",label:"Needs you",tone:"needs"},{id:"done",label:"Done",tone:"done"}],I=new Map(A.map(_=>[_.id,{..._,count:0,members:[]}])),P=new Map([["coordinator","coordinator"]]);for(let _ of V){let ie=D.get(_.name)??0,he,pe=!1,ke=[];if(J)he=_.status??"waiting",pe=!!_.recoveryRequired,ke=[..._.pendingWaitFor??_.waitFor??[]];else{let He=oe.get(_.name),Le=i.get(_.name)??0,et=L.get(_.name)??0;c<=0?he="waiting":He&&/\[done\]/i.test(String(He.text??""))?he="done":F?.author===_.name||Math.max(Le,et)>(He?.seq??0)?he="working":he="waiting"}let xe;pe||he==="failed"||he==="quota"?xe="needs":he==="working"?xe="working":he==="done"||he==="retired"?xe="done":xe="waiting";let Me=xe==="done",qe={name:_.name,status:he,role:_.role??"worker",tint:_.tint,muted:Me,latestSeq:ie,pendingWaitFor:ke},Ie=I.get(xe);Ie.members.push(qe),Ie.count=Ie.members.length,P.set(_.name,xe)}let $=A.map(_=>I.get(_.id)).filter(_=>_.count>0),le=V.length,Z=I.get("done").count,re;I.get("needs").count>0?re="stalled":I.get("working").count>0||J&&B.status==="working"?re="working":le>0&&Z===le?re="done":re="waiting";let X={name:"coordinator",status:J?B.status??re:F?.author==="coordinator"?"working":re,role:"coordinator",doneCount:Z,totalWorkers:le,phase:re,latestSeq:D.get("coordinator")??0,tint:B.tint},de=[],ae=new Set,ue=_=>{let ie=`${_.from}>${_.to}>${_.kind}`;ae.has(ie)||(ae.add(ie),de.push(_))};if(I.get("done").count>0&&ue({from:"done",to:"coordinator",kind:"done",label:"Tasks done"}),F&&(c===1/0||F.seq===c||!J)){let _=P.get(F.author);if(_){let ie=F.broadcast??/(?:^|[^a-z0-9_])@all(?![a-z0-9_-])/i.test(F.text??""),he=[...F.targets??[],...F.coordinatorMention?["coordinator"]:[]];if(ie){for(let pe of $)pe.id!==_&&ue({from:_,to:pe.id,kind:"message",label:"Message just sent",seq:F.seq});_!=="coordinator"&&ue({from:_,to:"coordinator",kind:"message",label:"Message just sent",seq:F.seq})}else for(let pe of he){let ke=P.get(pe);ke&&ke!==_&&ue({from:_,to:ke,kind:"message",label:"Message just sent",seq:F.seq})}}}for(let _ of $)for(let ie of _.members)for(let he of ie.pendingWaitFor??[]){let pe=P.get(he);pe&&ue({from:_.id,to:pe,kind:"waiting",label:"Waiting on"})}return{currentSeq:F?.seq??0,lastPost:F,coordinator:X,clusters:$,connectors:de}}function S(t,a,p){let c=[];for(let E=0;E<6;E++){let z=E*Math.PI/3;c.push({x:t+p*Math.cos(z),y:a+p*Math.sin(z)})}return c}function ee(t){if(t<=0)return[];if(t<=3)return[t];if(t===4)return[2,2];if(t===5)return[3,2];if(t===6)return[3,3];if(t===7)return[4,3];if(t===8)return[4,4];if(t===9)return[3,4,2];if(t===10)return[4,4,2];if(t===11)return[4,4,3];if(t===12)return[4,4,4];let a=[],p=t;for(;p>0;){let c=Math.min(4,p);a.push(c),p-=c}return a}function se(t,a,p,c){let E=c.length;if(!E)return[];let z=n/2*p,J=ee(E),ne=J.length,F=-z*.14,oe=z*.5,D=ne===1?z*.1:(F+oe)/2,i=oe-F,L=E>6?Math.max(.7,Math.min(.98,p/106)):Math.max(.82,Math.min(1.08,p/98)),T=[],B=0;for(let V=0;V<ne;V++){let A=J[V],I=ne===1?a+D:a+F+V/(ne-1)*i,P=I-a,$=Math.max(18,p-Math.max(Math.abs(P-15),Math.abs(P+18))/n-8),le=E>6?42:52,Z=A===1?0:Math.min(le,($*2-4)/A),re=A===1?Math.min(88,$*1.85):Math.max(30,Z-2);for(let X=0;X<A;X++){let de=t+(X-(A-1)/2)*Z;T.push({member:c[B++],x:de,y:I,slotWidth:re,beeScale:L})}}return T}function te(t,a){return t<=1?a<420?380:440:t===2?a<420?440:430:490}function W(t,a=680,p=460){let c=t?.clusters??[],E=34,z=14,ne=Math.max(200,a-16*2),F=Math.max(220,p-z-E),oe,D=[];if(c.length===0)oe=Math.max(48,Math.min(ne/2.2,F/(n*1.15),114)),D.push({id:"coordinator",ux:0,uy:0,isCoord:!0});else if(c.length===1){let ie=Math.max(12,Math.min(20,F*.036));oe=Math.max(46,Math.min(ne/2.15,(F-ie)/(2*n),112));let he=n*oe+ie,pe=a/2,ke=z+F/2,xe=new Map,Me={x:pe,y:ke-he/2},qe={x:pe,y:ke+he/2},Ie=c[0],He={id:Ie.id,label:Ie.label,tone:Ie.tone,count:Ie.count,x:Me.x,y:Me.y,radius:oe,vertices:S(Me.x,Me.y,oe),slots:se(Me.x,Me.y,oe,Ie.members??[])},Le={id:"coordinator",x:qe.x,y:qe.y,radius:oe,vertices:S(qe.x,qe.y,oe),model:t.coordinator};return xe.set(He.id,He),xe.set("coordinator",Le),{width:a,height:p,radius:oe,coordinator:Le,clusters:[He],cellsById:xe}}else if(c.length===2)D.push({id:"coordinator",ux:0,uy:.35,isCoord:!0}),ne>=F*.85?(D.push({id:c[0].id,cluster:c[0],ux:-n/2,uy:-.15}),D.push({id:c[1].id,cluster:c[1],ux:n/2,uy:-.15})):(D.push({id:c[0].id,cluster:c[0],ux:0,uy:-.65}),D.push({id:c[1].id,cluster:c[1],ux:0,uy:1.35}));else if(c.length===3)D.push({id:"coordinator",ux:0,uy:0,isCoord:!0}),D.push({id:c[0].id,cluster:c[0],ux:0,uy:-1}),D.push({id:c[1].id,cluster:c[1],ux:-n/2,uy:.5}),D.push({id:c[2].id,cluster:c[2],ux:n/2,uy:.5});else{D.push({id:"coordinator",ux:0,uy:0,isCoord:!0}),D.push({id:c[0].id,cluster:c[0],ux:-n/2,uy:-.5}),D.push({id:c[1].id,cluster:c[1],ux:n/2,uy:-.5}),D.push({id:c[2].id,cluster:c[2],ux:-n/2,uy:.5}),D.push({id:c[3].id,cluster:c[3],ux:n/2,uy:.5});for(let ie=4;ie<c.length;ie++)D.push({id:c[ie].id,cluster:c[ie],ux:0,uy:ie===4?-1:1})}let i=Math.min(...D.map(ie=>ie.ux)),L=Math.max(...D.map(ie=>ie.ux)),T=Math.min(...D.map(ie=>ie.uy)),B=Math.max(...D.map(ie=>ie.uy)),V=L-i,A=B-T,I=Math.max(10,Math.min(18,F*.03)),P=(ne-V*I)/(V*n+2),$=(F-A*I)/(A*n+n);oe=Math.max(40,Math.min(P,$,108));let le=n*oe+I,Z=(i+L)/2,re=(T+B)/2,X=a/2-Z*le,de=z+F/2-re*le,ae=new Map,ue=null,_=[];for(let ie of D){let he=X+ie.ux*le,pe=de+ie.uy*le,ke=S(he,pe,oe);if(ie.isCoord)ue={id:"coordinator",x:he,y:pe,radius:oe,vertices:ke,model:t?.coordinator},ae.set("coordinator",ue);else{let xe=ie.cluster,Me={id:xe.id,label:xe.label,tone:xe.tone,count:xe.count,x:he,y:pe,radius:oe,vertices:ke,slots:se(he,pe,oe,xe.members??[])};_.push(Me),ae.set(Me.id,Me)}}return{width:a,height:p,radius:oe,coordinator:ue,clusters:_,cellsById:ae}}function Q(t,a,p){let c=n/2*t.radius,E=Math.abs(p),z=Math.abs(.8660254037844386*a+.5*p),J=Math.abs(.8660254037844386*a-.5*p);return c/Math.max(E,z,J,1e-6)}function o(t,a,p,c){let z=Math.sqrt(3)*22;t.strokeStyle=c,t.lineWidth=.8,t.beginPath();for(let J=-1;J<a/(22*1.5)+1;J++)for(let ne=-1;ne<p/z+1;ne++){let F=J*1.5*22,oe=ne*z+J%2*z/2;for(let D=0;D<6;D++){let i=D*Math.PI/3,L=F+22*Math.cos(i),T=oe+22*Math.sin(i);D===0?t.moveTo(L,T):t.lineTo(L,T)}t.closePath()}t.stroke()}function h(t,a,p,c,E,z){let J=Math.min(z,c/2,E/2),ne=a-c/2,F=p-E/2,oe=a+c/2,D=p+E/2;t.beginPath(),t.moveTo(ne+J,F),t.lineTo(oe-J,F),t.quadraticCurveTo(oe,F,oe,F+J),t.lineTo(oe,D-J),t.quadraticCurveTo(oe,D,oe-J,D),t.lineTo(ne+J,D),t.quadraticCurveTo(ne,D,ne,D-J),t.lineTo(ne,F+J),t.quadraticCurveTo(ne,F,ne+J,F),t.closePath()}function g(t,a,p,c,E,z){let J=t.clientWidth,ne=t.clientHeight;if(!J||!ne)return;let F=Math.min(devicePixelRatio||1,2),oe=Math.round(J*F),D=Math.round(ne*F);(t.width!==oe||t.height!==D)&&(t.width=oe,t.height=D);let i=t.getContext("2d");i.setTransform(F,0,0,F,0,0),i.clearRect(0,0,J,ne),o(i,J,ne,z.grid),i.strokeStyle=z.accent,i.lineWidth=1.4,i.setLineDash([3,3]);for(let T of a.nodes){let B=p.get(T.name);!B||!m(T)||(i.globalAlpha=!c||c===T.name?.85:.2,i.beginPath(),i.arc(B.x,B.y,31,0,Math.PI*2),i.stroke())}i.setLineDash([]),i.font="600 10px ui-monospace, monospace",i.textAlign="center",i.textBaseline="middle";let L=R(a,p,{variant:"hex",narrow:J<465,marginStart:6,marginEnd:6,obstacleMargin:J<465?14:24});for(let{link:T,edge:B}of L){let{start:V,control:A,end:I,mid:P,endAngle:$}=B,le=T.lastSeq===E,Z=!c||T.from===c||T.to===c,re=le&&Z?z.accent:z.link;i.globalAlpha=Z?le?1:.78:.16,i.strokeStyle=i.fillStyle=re,i.lineWidth=Math.min(3.8,1.1+Math.sqrt(T.count)*.65),i.lineCap="round",i.setLineDash(T.direct?[]:[4,4]);let X=Math.min(4.5,B.length*.25),de=I.x-Math.cos($)*X,ae=I.y-Math.sin($)*X;i.beginPath(),i.moveTo(V.x,V.y),i.quadraticCurveTo(A.x,A.y,de,ae),i.stroke(),i.setLineDash([]);let ue=9;if(i.beginPath(),i.moveTo(I.x,I.y),i.lineTo(I.x-ue*Math.cos($-.44),I.y-ue*Math.sin($-.44)),i.lineTo(I.x-ue*.72*Math.cos($),I.y-ue*.72*Math.sin($)),i.lineTo(I.x-ue*Math.cos($+.44),I.y-ue*Math.sin($+.44)),i.closePath(),i.fill(),Z&&B.length>=40&&(T.count>1||le||c)){let _=String(T.count),ie=Math.max(20,_.length*6.5+10);i.globalAlpha=.98,h(i,P.x,P.y,ie,15,7.5),i.fillStyle=z.paper,i.fill(),i.lineWidth=1,i.strokeStyle=le?z.accent:z.link,i.stroke(),i.fillStyle=le?z.accent:z.text,i.fillText(_,P.x,P.y+.25)}}i.globalAlpha=1}function q(t){return t==="dark"?{bg:"#17140f",surface:"#221d16",ink:"#f5eddd",muted:"#bdb19a",border:"#43392b",edge:"#8c785c",pulse:"#c297ff",accent:"#f0b84b",doneFill:"#18281c",doneStroke:"#6ac47e",workingFill:"#2a2213",workingStroke:"#f0b84b",waitingFill:"#192133",waitingStroke:"#7da3f0",needsFill:"#2d1919",needsStroke:"#ef766e"}:{bg:"#f8f9fb",surface:"#ffffff",ink:"#24292f",muted:"#6e7781",border:"#d0d7de",edge:"#b4bcc6",pulse:"#8250df",accent:"#bf8700",doneFill:"#eef6ee",doneStroke:"#55943c",workingFill:"#fdf6e7",workingStroke:"#d18d22",waitingFill:"#eef3fc",waitingStroke:"#4d78cc",needsFill:"#fdf0ef",needsStroke:"#cf483f"}}function K(t,a){return t==="done"?{fill:a.doneFill,stroke:a.doneStroke}:t==="working"?{fill:a.workingFill,stroke:a.workingStroke}:t==="needs"||t==="stalled"?{fill:a.needsFill,stroke:a.needsStroke}:{fill:a.waitingFill,stroke:a.waitingStroke}}function ye(t,a){return t==="working"?a.doneStroke:t==="failed"||t==="quota"?a.needsStroke:t==="waiting"||t==="queued"?a.waitingStroke:a.muted}function fe(t){return t||(typeof window<"u"&&window.HiveBee?window.HiveBee:it.HiveBee)}function Se(t,a,p,c,E,z){if(z?.drawSprite){z.drawSprite(t,a,p,c,E);return}if(z?.sprite&&typeof document<"u"){let J=z.sprite(c,E),ne=E?.scale??1;t.drawImage?.(J,a,p,J.width*ne,J.height*ne)}}function ve(t,a){let p=String(t??"");return p.length<=a?p:a<=3?p.slice(0,a):p.slice(0,a-1)+"\u2026"}function ge(t,a,p,c,E=8){t.beginPath(),t.moveTo(a,p),t.lineTo(a-E*Math.cos(c-.44),p-E*Math.sin(c-.44)),t.lineTo(a-E*.7*Math.cos(c),p-E*.7*Math.sin(c)),t.lineTo(a-E*Math.cos(c+.44),p-E*Math.sin(c+.44)),t.closePath(),t.fill()}function be(t,a){t.beginPath(),a.forEach((p,c)=>{c===0?t.moveTo(p.x,p.y):t.lineTo(p.x,p.y)}),t.closePath()}function Ne(t,a,p,c){let{posts:E=[],members:z=[],cursor:J=null,phase:ne,width:F=680,height:oe=460,focus:D=null}=a,i=Y(E,z,J);ne&&J==null&&(ne==="done"&&i.coordinator.totalWorkers>0&&i.coordinator.doneCount===i.coordinator.totalWorkers?i.coordinator.phase="done":(ne==="stalled"||ne==="budget")&&(i.coordinator.phase="stalled"));let L=W(i,F,oe);for(let A of i.connectors){let I=L.cellsById.get(A.from),P=L.cellsById.get(A.to);if(!I||!P)continue;let $=A.kind==="message"?p.pulse:A.kind==="waiting"?p.workingStroke:p.doneStroke;if(t.strokeStyle=$,t.fillStyle=$,t.lineWidth=A.kind==="message"?2.2:1.5,t.setLineDash?.(A.kind==="waiting"?[4,4]:[]),I===P){let qe=I.x+I.radius*.72,Ie=I.y-n/2*I.radius*.4;t.beginPath(),t.arc(qe+8,Ie,10,-Math.PI*.8,Math.PI*.8),t.stroke(),t.setLineDash?.([]);continue}let le=P.x-I.x,Z=P.y-I.y,re=Math.hypot(le,Z);if(re<1)continue;let X=le/re,de=Z/re,ae=Q(I,X,de),ue=Q(P,-X,-de),_=A.kind==="message"?8:A.kind==="waiting"?-8:0,ie=-de,he=X,pe=I.x+X*(ae+2)+ie*_,ke=I.y+de*(ae+2)+he*_,xe=P.x-X*(ue+2)+ie*_,Me=P.y-de*(ue+2)+he*_;t.beginPath(),t.moveTo(pe,ke),t.lineTo(xe,Me),t.stroke(),t.setLineDash?.([]),A.kind!=="done"&&ge(t,xe,Me,Math.atan2(Me-ke,xe-pe),7)}t.textAlign="center",t.textBaseline="middle";for(let A of L.clusters){let I=K(A.tone,p),P=!!D,$=!P||A.slots.some(Z=>Z.member.name===D);t.globalAlpha=$?1:.38,be(t,A.vertices),t.fillStyle=I.fill,t.fill(),t.lineWidth=2,t.strokeStyle=I.stroke,t.stroke();let le=n/2*A.radius;t.fillStyle=p.ink,t.font='600 12px "Segoe UI", system-ui, sans-serif',t.fillText(A.label,A.x,A.y-le*.68),t.fillStyle=p.muted,t.font='500 11px "Segoe UI", system-ui, sans-serif',t.fillText(String(A.count),A.x,A.y-le*.5);for(let Z of A.slots){let re=Z.beeScale,X=20*re,de=18*re,ae=P&&D!==Z.member.name;t.globalAlpha=ae?.35:1,P&&D===Z.member.name&&(t.strokeStyle=p.accent,t.lineWidth=1.5,t.beginPath(),t.arc(Z.x,Z.y-2,Math.max(X,de)*.72,0,Math.PI*2),t.stroke()),Se(t,Z.x-X/2,Z.y-de*.68,Z.member.name,{status:Z.member.status,coordinator:!1,tint:Z.member.tint,muted:Z.member.muted,scale:re},c),t.fillStyle=Z.member.muted?p.muted:p.ink,t.font='500 9.5px "Segoe UI", system-ui, sans-serif';let ue=Math.max(6,Math.floor(Z.slotWidth/4.6));t.fillText(ve(Z.member.name,ue),Z.x,Z.y+de*.62)}}let T=L.coordinator;if(T){let A=K(T.model?.phase??"waiting",p);t.globalAlpha=!D||D==="coordinator"?1:.45,be(t,T.vertices),t.fillStyle=A.fill,t.fill(),t.lineWidth=2,t.strokeStyle=A.stroke,t.stroke();let I=Math.max(1.2,Math.min(2.1,T.radius/48)),P=20*I,$=18*I;Se(t,T.x-P/2,T.y-$*.78,"coordinator",{status:T.model?.status??"waiting",coordinator:!0,tint:T.model?.tint,muted:!1,scale:I},c);let le=n/2*T.radius;t.fillStyle=p.ink,t.font='650 12px "Segoe UI", system-ui, sans-serif',t.fillText("Coordinator",T.x,T.y+le*.34),t.fillStyle=p.muted,t.font='500 11px "Segoe UI", system-ui, sans-serif',t.fillText(`${T.model?.doneCount??0} of ${T.model?.totalWorkers??0} done`,T.x,T.y+le*.56)}t.globalAlpha=1;let B=oe-16,V=24;t.textAlign="left",t.textBaseline="middle",t.font='500 11px "Segoe UI", system-ui, sans-serif',t.strokeStyle=p.doneStroke,t.lineWidth=1.6,t.beginPath(),t.moveTo(V,B),t.lineTo(V+16,B),t.stroke(),t.fillStyle=p.muted,t.fillText("Tasks done",V+22,B),V+=102,t.strokeStyle=p.pulse,t.beginPath(),t.moveTo(V,B),t.lineTo(V+16,B),t.stroke(),t.fillText("Message just sent",V+22,B),V+=136,t.strokeStyle=p.workingStroke,t.fillStyle=p.workingStroke,t.setLineDash?.([3,3]),t.beginPath(),t.moveTo(V,B),t.lineTo(V+16,B),t.stroke(),t.setLineDash?.([]),ge(t,V+20,B,0,5),t.fillStyle=p.muted,t.fillText("Waiting on",V+26,B)}function we(t,a,p,c){let{posts:E=[],members:z=[],cursor:J=null,width:ne=680,height:F=460,hideInactive:oe=!1,expandBroadcast:D=!1,focus:i=null}=a,L=(E??[]).filter(l).slice().sort((X,de)=>X.seq-de.seq),T=J==null?L.at(-1)?.seq??1/0:Number(J),B=L.filter(X=>X.seq<=T).at(-1)??null,V=C(E,z,T,{hideInactive:oe,expandBroadcast:D}),A=Math.max(220,F-42),I=ne<465,P=b(V.nodes,ne,A),$=new Map;for(let X of V.nodes)$.set(X.name,v(X,{variant:"pill",narrow:I}));let le=R(V,P,{variant:"pill",boxes:$,narrow:I,marginStart:4,marginEnd:6,obstacleMargin:10});t.textAlign="center",t.textBaseline="middle";for(let{link:X,edge:de}of le){let{start:ae,control:ue,end:_,mid:ie,endAngle:he}=de,pe=!!(B&&X.lastSeq===B.seq),ke=!i||X.from===i||X.to===i,xe=pe&&ke?p.pulse:p.edge;t.globalAlpha=ke?pe?.96:.72:.16,t.strokeStyle=t.fillStyle=xe,t.lineWidth=Math.min(4.2,1.2+Math.sqrt(X.count)*.72),t.setLineDash?.(X.direct?[]:[4,4]);let Me=Math.min(4.5,de.length*.25),qe=_.x-Math.cos(he)*Me,Ie=_.y-Math.sin(he)*Me;if(t.beginPath(),t.moveTo(ae.x,ae.y),t.quadraticCurveTo(ue.x,ue.y,qe,Ie),t.stroke(),t.setLineDash?.([]),ge(t,_.x,_.y,he,8),ke&&de.length>=36&&(X.count>1||pe||i)){let He=String(X.count),Le=Math.max(16,He.length*6.5+8);t.globalAlpha=.96,h(t,ie.x,ie.y,Le,14,7),t.fillStyle=p.bg,t.fill(),t.fillStyle=pe?p.pulse:p.ink,t.font="600 10px ui-monospace, monospace",t.fillText(He,ie.x,ie.y+.5)}}for(let X of V.nodes){let de=P.get(X.name),ae=$.get(X.name);if(!de||!ae)continue;let ue=X.role==="coordinator"||X.name==="coordinator",_=X.status==="retired",ie=X.status==="done"||_,he=!i||i===X.name||V.links.some(Be=>Be.from===i&&Be.to===X.name||Be.to===i&&Be.from===X.name);t.globalAlpha=he?_?.56:1:.24;let pe=m(X);h(t,de.x,de.y,ae.halfW*2,ae.halfH*2,ae.radius),t.fillStyle=p.surface,t.fill(),t.lineWidth=i===X.name?1.8:1.1,t.strokeStyle=i===X.name?p.pulse:p.border,t.setLineDash?.(pe?[3,3]:[]),t.stroke(),t.setLineDash?.([]);let ke=de.x-ae.halfW,xe=de.x+ae.halfW,Me=I?.85:.92,qe=20*Me,Ie=18*Me;Se(t,ke+10,de.y-Ie/2,X.name,{status:X.status??"observer",coordinator:ue,tint:X.tint,muted:!ue&&ie,scale:Me},c);let He=X.name==="user"?"You":X.name==="system"?"System":X.name,Le=(ke+10+qe+6+xe-14)/2;t.fillStyle=_?p.muted:p.ink,t.font='600 11px "Segoe UI", system-ui, sans-serif';let et=Math.max(5,Math.floor((ae.halfW*2-qe-28)/6.2)),lt=ve(He,et);if(t.fillText(lt,Le,de.y+.5),_){let Be=Math.min(ae.halfW*2-qe-28,lt.length*6.2);t.strokeStyle=p.muted,t.lineWidth=1,t.beginPath(),t.moveTo(Le-Be/2,de.y+.5),t.lineTo(Le+Be/2,de.y+.5),t.stroke()}t.fillStyle=ye(X.status,p),t.beginPath(),t.arc(xe-10,de.y,3,0,Math.PI*2),t.fill()}t.globalAlpha=1;let Z=F-22,re=24;if(t.textAlign="left",t.textBaseline="middle",t.font='500 11px "Segoe UI", system-ui, sans-serif',t.strokeStyle=p.edge,t.fillStyle=p.edge,t.lineWidth=1.4,t.beginPath(),t.moveTo(re,Z),t.lineTo(re+14,Z),t.stroke(),ge(t,re+18,Z,0,5),t.fillStyle=p.muted,t.fillText("@mention, width = count",re+24,Z),re+=168,t.strokeStyle=p.edge,t.fillStyle=p.edge,t.setLineDash?.([3,3]),t.beginPath(),t.moveTo(re,Z),t.lineTo(re+14,Z),t.stroke(),t.setLineDash?.([]),ge(t,re+18,Z,0,5),t.fillStyle=p.muted,t.fillText("via @all",re+24,Z),re+=78,t.strokeStyle=p.border,t.setLineDash?.([2,2]),h(t,re+8,Z,16,10,5),t.stroke(),t.setLineDash?.([]),t.fillStyle=p.muted,t.fillText("posted with no mention",re+22,Z),V.broadcasts>0&&F>=60){let X="@all "+V.broadcasts,de=F-7;h(t,40,de-1,36,14,7),t.fillStyle=p.border,t.fill(),t.fillStyle=p.ink,t.font="600 9.5px ui-monospace, monospace",t.textAlign="center",t.fillText(X,40,de),t.textAlign="left",t.fillStyle=p.muted,t.font='500 10.5px "Segoe UI", system-ui, sans-serif',t.fillText("@all posts, drawn by Expand @all",64,de)}}function me(t,a={}){if(!t)return;let p=a.width??680,c=a.height??460,E=a.theme==="dark"?"dark":"light",z=a.mode==="mentions"?"mentions":"hive",J=q(E),ne=fe(a.bees);t.save?.(),t.clearRect?.(0,0,p,c),t.fillStyle=J.bg,t.fillRect(0,0,p,c),z==="mentions"?we(t,a,J,ne):Ne(t,a,J,ne),t.restore?.()}it.HiveGraph=Object.freeze({isPost:l,project:C,elapsedSpan:f,unmentionedNode:m,minimumHeight:w,layout:u,nodeBox:v,roundedRectSignedDistance:U,clipEdge:O,routeEdges:R,draw:g,smartTaskLabel:r,mentionsMinimumHeight:d,layoutMentions:b,projectHive:Y,hiveMinimumHeight:te,layoutHive:W,renderGraphFrame:me})})();mt.exports=it.HiveGraph});var yt=tt((Gn,bt)=>{var gt={};(()=>{"use strict";let n=[["#efac37","#ffe18d","#bb641d"],["#75baef","#cdefff","#3974bb"],["#55cbb2","#b8f8df","#268c7d"],["#e68db3","#ffcee2","#a24275"],["#b3ce64","#e9f6a1","#6c9137"],["#ad9ce8","#e3d4ff","#6d58af"],["#f09a71","#ffd3b7","#af5833"],["#95cbd1","#defbfa","#4a8d9d"],["#d1a76a","#ffe2a9","#987044"]],s=["#aaafb6","#d6dae0","#848991"];function l(N,w,u){if(w)return n[0];if(Number.isInteger(u))return n[1+Math.abs(u)%(n.length-1)];let x=[...String(N??"")].reduce((d,b)=>d*31+b.charCodeAt(0),0)>>>0;return n[x%n.length]}function f(N){let w=String(N).replace("#",""),u=Number.parseInt(w,16);return[u>>16&255,u>>8&255,u&255]}function m(N,w,u){let[x,d,b]=l(N,w,u),[H,v,y]=f(x),[U,j,k]=f(b),G=Math.round(U*.78),ce=Math.round(j*.78),O=Math.round(k*.78),R="#"+[G,ce,O].map(Y=>Y.toString(16).padStart(2,"0")).join("");return{base:x,highlight:d,shade:b,bg:`rgba(${H}, ${v}, ${y}, 0.14)`,border:`rgba(${H}, ${v}, ${y}, 0.42)`,text:R}}function r(N,w,u,x=0,d=0,b=1){N.fillStyle=w;for(let[H,v,y,U]of u)x===0&&d===0&&b===1?N.fillRect(H,v,y,U):N.fillRect(x+H*b,d+v*b,y*b,U*b)}function C(N,w,u,x,{status:d="working",coordinator:b=!1,tint:H,muted:v=!1,scale:y=1}={}){if(!N)return;let[U,j,k]=v?s:l(x,b,H),G=!v&&["waiting","quota","retired","done"].includes(d),ce=v?"#727880":"#201915",O=v?"#828a94":"#24313d",R=v?"#ced3d9":"#a9c6db",Y=v?"#eef1f4":"#e7f2fa",S=v?"#767c84":"#2c221c";r(N,ce,[[3,2,1,3],[6,3,1,2],[5,1,2,1],[2,3,1,1],[5,5,10,8],[3,7,13,5],[4,12,11,2],[6,14,7,1],[16,9,2,2],[7,14,1,2],[12,14,1,2]],w,u,y),r(N,O,[[7,3,6,4],[8,2,4,6],[12,3,4,4],[13,2,2,1]],w,u,y),r(N,R,[[8,3,3,4],[12,4,3,2],[9,7,2,1]],w,u,y),r(N,Y,[[9,3,2,2],[12,4,2,1],[8,4,1,2]],w,u,y),r(N,U,[[4,7,8,5],[5,6,6,7],[12,7,3,5],[13,12,1,1],[6,13,1,1]],w,u,y),r(N,j,[[5,7,3,1],[4,9,2,2],[10,7,2,1],[13,8,1,2],[5,12,2,1]],w,u,y),r(N,k,[[6,12,7,1],[12,11,3,1],[13,12,1,1]],w,u,y),r(N,S,[[8,6,2,7],[12,7,1,6],[15,9,2,1]],w,u,y),G?(r(N,ce,[[4,10,2,1]],w,u,y),r(N,"#d7dcff",b?[[0,0,2,1],[1,1,1,1],[0,2,2,1],[15,0,4,1],[17,1,1,2],[15,3,4,1]]:[[1,1,3,1],[2,2,1,1],[1,3,3,1],[15,0,4,1],[17,1,1,2],[15,3,4,1]],w,u,y)):(r(N,v?"#555b63":"#201915",[[5,8,1,2]],w,u,y),r(N,v?"#e5e8ec":"#fff6d7",[[5,8,1,1]],w,u,y)),b&&(r(N,v?"#727880":"#6d4219",[[2,1,1,4],[8,1,1,4],[2,4,7,1]],w,u,y),r(N,v?"#c7cbd1":"#ffd86b",[[2,0,1,2],[5,0,1,3],[8,0,1,2],[3,2,5,2],[4,1,3,1]],w,u,y),r(N,v?"#9da3ab":"#e7a52f",[[3,4,5,1],[3,3,5,1]],w,u,y),r(N,v?"#eceef1":"#fff3bf",[[3,2,1,1],[7,2,1,1],[5,3,1,1]],w,u,y))}function M(N,{status:w="working",coordinator:u=!1,tint:x,muted:d=!1}={}){let b=document.createElement("canvas");b.className="bee-pixel",b.width=20,b.height=18,b.setAttribute("aria-hidden","true");let H=!d&&["waiting","quota","retired","done"].includes(w);b.dataset.pose=d?"muted":H?"sleeping":"awake",d&&(b.dataset.muted="true");let v=b.getContext("2d");return C(v,0,0,N,{status:w,coordinator:u,tint:x,muted:d,scale:1}),b}gt.HiveBee=Object.freeze({sprite:M,colors:l,tintStyle:m,drawSprite:C})})();bt.exports=gt.HiveBee});var wt=tt((_n,xt)=>{var Ve={};(()=>{"use strict";function n(u){return u||(typeof window<"u"&&window.HiveGraph?window.HiveGraph:Ve.HiveGraph)}function s(u){return u||(typeof window<"u"&&window.HiveBee?window.HiveBee:Ve.HiveBee)}function l(u,x=128){let d=Math.max(2,Math.min(256,x|0)),b=new Map,H=Math.min(u.length,16),v=u.length<=H?1:(u.length-1)/(H-1),y=new Set;for(let te=0;te<H;te++)y.add(Math.round(te*v));y.add(0),y.add(u.length-1);let U=u[0].rgba,j=U.length>=4&&U[3]>=128?U[0]<<16|U[1]<<8|U[2]:16777215;for(let te of y){let W=u[te].rgba,Q=-1,o=0;for(let h=0;h+3<W.length;h+=4){let g=W[h+3]<128?j:W[h]<<16|W[h+1]<<8|W[h+2];g===Q?o++:(Q!==-1&&b.set(Q,(b.get(Q)??0)+o),Q=g,o=1)}Q!==-1&&b.set(Q,(b.get(Q)??0)+o)}let k;if(b.size<=d)k=[...b.keys()];else{let te=[...b.entries()].sort((q,K)=>K[1]-q[1]),W=Math.min(te.length,Math.max(2,Math.floor(d*.48)));k=te.slice(0,W).map(q=>q[0]);let Q=new Set(k),o=new Map;for(let q=W;q<te.length;q++){let[K,ye]=te[q],fe=K>>19&31,Se=K>>11&31,ve=K>>3&31,ge=fe<<10|Se<<5|ve,be=o.get(ge);be||(be={rSum:0,gSum:0,bSum:0,w:0},o.set(ge,be)),be.rSum+=(K>>16&255)*ye,be.gSum+=(K>>8&255)*ye,be.bSum+=(K&255)*ye,be.w+=ye}let h=[];for(let q of o.values())h.push({r:Math.round(q.rSum/q.w),g:Math.round(q.gSum/q.w),b:Math.round(q.bSum/q.w),w:q.w});let g=d-k.length;if(h.length<=g)for(let q of h){let K=q.r<<16|q.g<<8|q.b;Q.has(K)||(Q.add(K),k.push(K))}else{let q=ye=>{let fe=255,Se=0,ve=255,ge=0,be=255,Ne=0,we=0;for(let c of ye)c.r<fe&&(fe=c.r),c.r>Se&&(Se=c.r),c.g<ve&&(ve=c.g),c.g>ge&&(ge=c.g),c.b<be&&(be=c.b),c.b>Ne&&(Ne=c.b),we+=c.w;let me=Se-fe,t=ge-ve,a=Ne-be,p=t>=me&&t>=a?"g":me>=a?"r":"b";return{list:ye,span:Math.max(me,t,a),axis:p,totalW:we}},K=[q(h)];for(;K.length<g;){let ye=-1,fe=-1;for(let we=0;we<K.length;we++){let me=K[we];if(me.list.length>1&&me.span>0){let t=me.span*Math.log2(me.totalW+2);t>fe&&(fe=t,ye=we)}}if(ye===-1)break;let Se=K.splice(ye,1)[0],ve=Se.axis;Se.list.sort((we,me)=>we[ve]-me[ve]);let ge=Se.totalW/2,be=0,Ne=1;for(let we=0;we<Se.list.length-1;we++)if(be+=Se.list[we].w,be>=ge){Ne=we+1;break}K.push(q(Se.list.slice(0,Ne)),q(Se.list.slice(Ne)))}for(let ye of K){let fe=0,Se=0,ve=0,ge=0;for(let t of ye.list)fe+=t.r*t.w,Se+=t.g*t.w,ve+=t.b*t.w,ge+=t.w;let be=Math.round(fe/ge),Ne=Math.round(Se/ge),we=Math.round(ve/ge),me=be<<16|Ne<<8|we;Q.has(me)||(Q.add(me),k.push(me))}}}k.length||(k=[16777215]);let G=1;for(;1<<G<k.length&&G<8;)G++;let ce=1<<G,O=Math.max(2,G),R=G-1,Y=new Uint8Array(k.length),S=new Uint8Array(k.length),ee=new Uint8Array(k.length),se=new Map;for(let te=0;te<k.length;te++){let W=k[te];Y[te]=W>>16&255,S[te]=W>>8&255,ee[te]=W&255,se.set(W,te)}return{colors:k,paletteR:Y,paletteG:S,paletteB:ee,tableLength:ce,minCodeSize:O,tableSizeFlag:R,bgRgb:j,exactLookup:se}}function f(u,x,d){let{paletteR:b,paletteG:H,paletteB:v,bgRgb:y,exactLookup:U}=d,j=b.length,k=new Uint8Array(x),G=-1,ce=0;for(let O=0,R=0;O<x;O++,R+=4){let Y=u[R+3]<128?y:u[R]<<16|u[R+1]<<8|u[R+2];if(Y===G){k[O]=ce;continue}let S=U.get(Y);if(S===void 0){let ee=Y>>16&255,se=Y>>8&255,te=Y&255,W=1/0;S=0;for(let Q=0;Q<j;Q++){let o=ee-b[Q],h=se-H[Q],g=te-v[Q],q=o*o+h*h+g*g;if(q<W&&(W=q,S=Q,q===0))break}U.size<65536&&U.set(Y,S)}G=Y,ce=S,k[O]=S}return k}class m{constructor(x=32768){this.buf=new Uint8Array(x),this.pos=0}ensure(x){if(this.pos+x<=this.buf.length)return;let d=this.buf.length*2;for(;d<this.pos+x;)d*=2;let b=new Uint8Array(d);b.set(this.buf.subarray(0,this.pos)),this.buf=b}byte(x){this.ensure(1),this.buf[this.pos++]=x&255}u16(x){this.ensure(2),this.buf[this.pos++]=x&255,this.buf[this.pos++]=x>>8&255}bytes(x){this.ensure(x.length),this.buf.set(x,this.pos),this.pos+=x.length}ascii(x){this.ensure(x.length);for(let d=0;d<x.length;d++)this.buf[this.pos++]=x.charCodeAt(d)}finish(){return this.buf.slice(0,this.pos)}}function r(u,x,d){let b=1<<x,H=b+1,v=8192,y=v-1,U=new Int32Array(v).fill(-1),j=new Int16Array(v),k=new Uint8Array(255),G=0,ce=0,O=0;function R(){G&&(d.byte(G),d.bytes(k.subarray(0,G)),G=0)}function Y(W,Q){for(ce|=W<<O,O+=Q;O>=8;)k[G++]=ce&255,G===255&&R(),ce>>>=8,O-=8}let S=x+1,ee=H+1,se=1<<S;if(Y(b,S),!u.length){Y(H,S),O>0&&(k[G++]=ce&255),R(),d.byte(0);return}let te=u[0];for(let W=1;W<u.length;W++){let Q=u[W],o=te<<8|Q,h=(te<<5^Q^te>>>3)&y,g=(te^Q<<3|1)&y,q=!1;for(;U[h]!==-1;){if(U[h]===o){te=j[h],q=!0;break}h=h+g&y}q||(Y(te,S),ee<4096?(U[h]=o,j[h]=ee++,ee>se&&S<12&&(S++,se=1<<S)):(Y(b,S),U.fill(-1),S=x+1,ee=H+1,se=1<<S),te=Q)}Y(te,S),Y(H,S),O>0&&(k[G++]=ce&255,G===255&&R()),R(),d.byte(0)}function C(u,{width:x,height:d,loop:b=0,maxColors:H=128}={}){if(!Array.isArray(u)||!u.length)throw new Error("encodeGif requires at least one frame.");let v=Math.floor(Number(x)),y=Math.floor(Number(d));if(!Number.isFinite(v)||v<=0||v>65535||!Number.isFinite(y)||y<=0||y>65535)throw new Error("encodeGif requires valid width and height (1..65535).");let U=v*y;for(let G=0;G<u.length;G++)if(!u[G]?.rgba||u[G].rgba.length<U*4)throw new Error(`Frame ${G} RGBA buffer is smaller than ${v}x${y}x4 bytes.`);let j=l(u,H),k=new m(Math.max(16384,U));k.ascii("GIF89a"),k.u16(v),k.u16(y),k.byte(240|j.tableSizeFlag),k.byte(0),k.byte(0);for(let G=0;G<j.tableLength;G++)G<j.colors.length?(k.byte(j.paletteR[G]),k.byte(j.paletteG[G]),k.byte(j.paletteB[G])):(k.byte(0),k.byte(0),k.byte(0));if(b!==!1&&b!==null&&b!==void 0){let G=Math.max(0,Math.min(65535,Math.floor(Number(b))));k.byte(33),k.byte(255),k.byte(11),k.ascii("NETSCAPE2.0"),k.byte(3),k.byte(1),k.u16(G),k.byte(0)}for(let G of u){let ce=Math.max(1,Math.min(65535,Math.round(G.delayCs??50)));k.byte(33),k.byte(249),k.byte(4),k.byte(4),k.u16(ce),k.byte(0),k.byte(0),k.byte(44),k.u16(0),k.u16(0),k.u16(v),k.u16(y),k.byte(0),k.byte(j.minCodeSize);let O=f(G.rgba,U,j);r(O,j.minCodeSize,k)}return k.byte(59),k.finish()}function M(u){let x=String(u??"").trim();if(x.startsWith("#")){let b=x.slice(1);if(b.length===3)return[Number.parseInt(b[0]+b[0],16),Number.parseInt(b[1]+b[1],16),Number.parseInt(b[2]+b[2],16),255];if(b.length>=6)return[Number.parseInt(b.slice(0,2),16),Number.parseInt(b.slice(2,4),16),Number.parseInt(b.slice(4,6),16),b.length===8?Number.parseInt(b.slice(6,8),16):255]}let d=/^rgba?\(([^)]+)\)$/i.exec(x);if(d){let b=d[1].split(",").map(H=>Number.parseFloat(H.trim()));return[b[0]||0,b[1]||0,b[2]||0,b.length>=4?Math.round(b[3]*255):255]}return[0,0,0,255]}function N(u,x){let d=new Uint8ClampedArray(u*x*4),b=[],H={fillStyle:"#000000",strokeStyle:"#000000",lineWidth:1,globalAlpha:1},v=[],y=0,U=0,j=0,k=0;function G(R,Y,S){let ee=Math.round(R),se=Math.round(Y);if(ee<0||ee>=u||se<0||se>=x)return;let te=S[3]/255*H.globalAlpha;if(te<=0)return;let W=(se*u+ee)*4;if(te>=.995)d[W]=S[0],d[W+1]=S[1],d[W+2]=S[2],d[W+3]=255;else{let Q=1-te;d[W]=Math.round(d[W]*Q+S[0]*te),d[W+1]=Math.round(d[W+1]*Q+S[1]*te),d[W+2]=Math.round(d[W+2]*Q+S[2]*te),d[W+3]=255}}function ce(R,Y,S,ee,se,te){let W=Math.max(1,Math.ceil(Math.hypot(S-R,ee-Y))),Q=Math.max(0,Math.floor((te-1)/2));for(let o=0;o<=W;o++){let h=R+(S-R)*o/W,g=Y+(ee-Y)*o/W;for(let q=-Q;q<=Q;q++)for(let K=-Q;K<=Q;K++)G(h+K,g+q,se)}}let O={get fillStyle(){return H.fillStyle},set fillStyle(R){H.fillStyle=R},get strokeStyle(){return H.strokeStyle},set strokeStyle(R){H.strokeStyle=R},get lineWidth(){return H.lineWidth},set lineWidth(R){H.lineWidth=R},get globalAlpha(){return H.globalAlpha},set globalAlpha(R){H.globalAlpha=R},font:"",textAlign:"left",textBaseline:"alphabetic",lineCap:"butt",save(){b.push({...H})},restore(){b.length&&(H=b.pop())},setLineDash(){},clearRect(R,Y,S,ee){let se=Math.max(0,Math.floor(R)),te=Math.max(0,Math.floor(Y)),W=Math.min(u,Math.ceil(R+S)),Q=Math.min(x,Math.ceil(Y+ee));for(let o=te;o<Q;o++)for(let h=se;h<W;h++){let g=(o*u+h)*4;d[g]=d[g+1]=d[g+2]=d[g+3]=0}},fillRect(R,Y,S,ee){let se=M(H.fillStyle),te=Math.max(0,Math.floor(R)),W=Math.max(0,Math.floor(Y)),Q=Math.min(u,Math.ceil(R+S)),o=Math.min(x,Math.ceil(Y+ee));for(let h=W;h<o;h++)for(let g=te;g<Q;g++)G(g,h,se)},beginPath(){v=[]},moveTo(R,Y){y=j=R,U=k=Y,v.push([{x:R,y:Y}])},lineTo(R,Y){v.length||v.push([{x:y,y:U}]),v[v.length-1].push({x:R,y:Y}),y=R,U=Y},quadraticCurveTo(R,Y,S,ee){v.length||v.push([{x:y,y:U}]);let se=v[v.length-1],te=y,W=U;for(let Q=1;Q<=12;Q++){let o=Q/12,h=1-o;se.push({x:h*h*te+2*h*o*R+o*o*S,y:h*h*W+2*h*o*Y+o*o*ee})}y=S,U=ee},arc(R,Y,S,ee,se){let te=[];for(let Q=0;Q<=18;Q++){let o=ee+(se-ee)*Q/18;te.push({x:R+S*Math.cos(o),y:Y+S*Math.sin(o)})}v.push(te),te.length&&(y=te.at(-1).x,U=te.at(-1).y,j=te[0].x,k=te[0].y)},closePath(){v.length&&v[v.length-1].length&&(v[v.length-1].push({x:j,y:k}),y=j,U=k)},fill(){let R=M(H.fillStyle);for(let Y of v){if(Y.length<3)continue;let S=x,ee=0;for(let W of Y)W.y<S&&(S=W.y),W.y>ee&&(ee=W.y);let se=Math.max(0,Math.floor(S)),te=Math.min(x-1,Math.ceil(ee));for(let W=se;W<=te;W++){let Q=[];for(let o=0,h=Y.length-1;o<Y.length;h=o++){let g=Y[o],q=Y[h];(g.y<=W&&q.y>W||q.y<=W&&g.y>W)&&Q.push(g.x+(W-g.y)/(q.y-g.y)*(q.x-g.x))}Q.sort((o,h)=>o-h);for(let o=0;o+1<Q.length;o+=2){let h=Math.max(0,Math.ceil(Q[o])),g=Math.min(u-1,Math.floor(Q[o+1]));for(let q=h;q<=g;q++)G(q,W,R)}}}},stroke(){let R=M(H.strokeStyle),Y=H.lineWidth||1;for(let S of v)for(let ee=1;ee<S.length;ee++)ce(S[ee-1].x,S[ee-1].y,S[ee].x,S[ee].y,R,Y)},fillText(R,Y,S){let ee=String(R??"");if(!ee)return;let se=M(H.fillStyle),te=Math.min(ee.length*5,120),W=H.textAlign==="center"?Y-te/2:H.textAlign==="right"?Y-te:Y,Q=S-3;for(let o=Math.max(0,Math.floor(W));o<Math.min(u,Math.ceil(W+te));o+=2)for(let h=Math.max(0,Math.floor(Q));h<Math.min(x,Math.ceil(Q+5));h+=2)G(o,h,se)},drawImage(){},getImageData(R,Y,S,ee){return R===0&&Y===0&&S===u&&ee===x?{data:new Uint8ClampedArray(d),width:u,height:x}:{data:new Uint8ClampedArray(S*ee*4),width:S,height:ee}}};return{width:u,height:x,getContext:()=>O}}function w({mode:u="hive",posts:x=[],members:d=[],phase:b="done",pacing:H="even",speed:v=1,hideInactive:y=!1,expandBroadcast:U=!1,focus:j=null,theme:k="light",width:G=680,height:ce=460,graph:O,bees:R,createCanvas:Y,maxFrames:S=90}={}){let ee=n(O),se=s(R);if(typeof ee?.renderGraphFrame!="function")throw new Error("HiveGraph.renderGraphFrame is required to export a graph replay GIF.");let te=ee.isPost??(ve=>ve&&(ve.kind==="brief"||ve.kind==="message"||!ve.kind&&ve.author!=="system")),W=(x??[]).filter(te).slice().sort((ve,ge)=>(ve.seq??0)-(ge.seq??0)),Q=[{seq:0,post:null}],o=Math.max(2,Math.floor(Number(S)||90));if(W.length>0)if(W.length+1<=o)for(let ve of W)Q.push({seq:ve.seq,post:ve});else{let ve=o-1,ge=new Set([0,W.length-1]);for(let be=1;be<ve-1;be++)ge.add(Math.round(be*(W.length-1)/(ve-1)));for(let be of[...ge].sort((Ne,we)=>Ne-we))Q.push({seq:W[be].seq,post:W[be]})}let g=(Y??(typeof document<"u"?(ve,ge)=>{let be=document.createElement("canvas");return be.width=ve,be.height=ge,be}:N))(G,ce);g.width!==G&&(g.width=G),g.height!==ce&&(g.height=ce);let q=g.getContext("2d");if(!q)throw new Error("Could not obtain 2D canvas context for GIF export.");let K=Math.max(.25,Number(v)||1),ye=[];for(let ve=0;ve<Q.length;ve++){let ge=Q[ve],be=ve===Q.length-1,Ne=ve>0?Q[ve-1].post:null,we=620;if(H==="real"&&ge.post?.time&&Ne?.time){let p=Date.parse(ge.post.time)-Date.parse(Ne.time);Number.isFinite(p)&&(we=Math.max(110,Math.min(p,2e3)))}let me=Math.round(we/K/10),t=be?Math.max(150,me):Math.max(4,Math.min(300,me));ee.renderGraphFrame(q,{mode:u,posts:x,members:d,cursor:be&&W.length?null:ge.seq,phase:be?b:"working",width:G,height:ce,theme:k,hideInactive:y,expandBroadcast:U,focus:j,bees:se});let a=q.getImageData(0,0,G,ce);ye.push({rgba:a.data instanceof Uint8ClampedArray?a.data:new Uint8ClampedArray(a.data),delayCs:t})}let fe=C(ye,{width:G,height:ce,loop:0}),Se=typeof Blob<"u"?new Blob([fe],{type:"image/gif"}):void 0;return{bytes:fe,blob:Se,frameCount:ye.length,width:G,height:ce}}Ve.HiveGif=Object.freeze({encodeGif:C,exportGraphReplayGif:w})})();xt.exports=Ve.HiveGif});var zn={};Xt(zn,{apply:()=>Wn,inject:()=>Fn,name:()=>Oe});module.exports=Vt(zn);var Qt={snapshot:"hive-swarm/v1/snapshot",command:"hive-swarm/v1/command",wait:"hive-swarm/v1/events"},Xe="deepseek-harness",nt=n=>(n?.events??[]).reduce((s,l)=>Math.max(s,l.seq),n?.head??0),Ae=n=>({message:typeof n=="string"?n:n?.message??"The Swarm connection is unavailable.",code:typeof n?.code=="string"?n.code:"connection"}),ht=()=>globalThis.crypto.randomUUID(),Pe=n=>n?.session?.host===Xe?n.session.id:void 0;function Kt(n,s){let l=Pe(s);return l?s?.executionMode==="subagent"&&typeof n?.parentSessionId=="string"&&n.parentSessionId.trim()?{parentSessionId:n.parentSessionId.trim(),childSessionId:l,mode:"continuable"}:l:null}async function ct(n,s,l,f){if(typeof n?.rpc?.call!="function")throw Error("DSH Connection RPC is unavailable. Enable the Connection capability and reload Hive Swarm.");let m=await n.rpc.call("/api",Qt[s],l,f);if(f.aborted)throw f.reason??new DOMException("Cancelled","AbortError");if(!m?.ok){let r=Error(Ae(m?.error).message);throw r.code=m?.error?.code,r}return m.value}async function ut(n,s,l){let{team:f}=await ct(n,"snapshot",{teamId:s},l)??{};if(f?.id!==s||f.host!==Xe||typeof f.cwd!="string"||!f.cwd.trim())throw Error("The Swarm team is unavailable in this Host. Check its workspace and access.");return f}function Zt(n){return Array.isArray(n)?n.map((s,l)=>{let f=Array.isArray(s.items)?s.items:[],m=Number(s.turn??s.id);return{turn:Number.isSafeInteger(m)&&m>0?m:l+1,status:s.status,steps:s.steps??f.filter(r=>r.type==="activity"),report:s.report??f.findLast(r=>r.type==="agentMessage"&&r.phase==="final")?.text}}):[]}function ot(n){return typeof n!="string"||!n?null:(/^(?:[a-z]:[\\/]|\\\\)/i.test(n)?n.replaceAll("\\","/").toLowerCase():n).replace(/\/+$/,"")||"/"}function pt({connection:n,teamId:s=null,sessionId:l=null,workspace:f=null,openSession:m}={}){let r=ot(f),C=o=>!r||ot(o.cwd)===r,M=s||null,N=0,w=!1,u=0,x=null,d=null,b=null,H=0,v=null,y={teams:[],team:null,selectedId:M,sessionId:l,workspace:f,loading:!1,connection:"idle",error:null,pending:!1,models:[],modelsLoading:!1,journal:null,history:[],hasMoreHistory:!1,historyLoading:!1},U=new Set,j=new Set,k=o=>{if(!w){y={...y,...o};for(let h of U)h()}},G=(o,h)=>!w&&N>0&&o===u&&!h.aborted;function ce(){u++,x?.abort(),x=null;for(let o of j)o.abort();j.clear()}let O=(o,h,g)=>ct(n,o,h,g);function R(o){let h=new Map(y.history.map(g=>[g.seq,g]));for(let g of o)h.set(g.seq,g);return[...h.values()].sort((g,q)=>g.seq-q.seq)}function Y(o){if(!o||o.id!==M)throw Error("The Host returned a different team. Select the team again.");if(o.host!==Xe)throw Error("This team does not belong to the native DSH Host.");if(!C(o))throw Error("This team is outside the parent workspace. Choose a team from this workspace.");d??=nt(o),!(y.team&&nt(o)<nt(y.team))&&k({team:o,history:R(o.events??[])})}async function S(o,h){let g=await O("snapshot",M?{teamId:M}:{},o);if(!G(h,o))return;if(!Array.isArray(g?.teams))throw Error("The Swarm snapshot is invalid. Refresh to reconnect.");let q=g.teams.filter(K=>K.host===Xe&&C(K));if(M){try{Y(g.team)}catch(K){throw k({teams:q,team:null}),K}q.some(K=>K.id===M)||q.push(g.team)}else k({team:null});k({teams:q,loading:!1,error:y.error?.action?y.error:null,connection:"connected"})}async function ee(o,h){try{for(;M&&G(h,o);){let g=d??0,q=y.team?.revision,K=await O("wait",{teamId:M,since:g,...q?{revision:q}:{},timeoutSec:50},o);if(!G(h,o))return;if(!Number.isSafeInteger(K?.head)||K.head<0)throw Error("The Swarm event cursor is invalid. Refresh to reconnect.");let ye=Array.isArray(K.posts)?K.posts:[];if(K.hasMore){let fe=ye.at(-1)?.seq;if(!Number.isSafeInteger(fe)||fe<=g||fe>K.head)throw Error("The Swarm history page has an invalid cursor. Refresh to reconnect.");d=fe}else d=Math.max(g,K.head);ye.length&&k({history:R(ye)}),!(K.wokeBy==="timeout"&&d===g&&K.revision===q&&!ye.length)&&await S(o,h)}}catch(g){G(h,o)&&k({loading:!1,connection:"disconnected",error:Ae(g)})}}async function se(){if(x?.abort(),x=null,w||!N)return;let o=new AbortController;x=o;let h=u,g=o.signal;k({loading:y.team===null,connection:"connecting",error:y.error?.action?y.error:null});try{await S(g,h),G(h,g)&&M&&ee(g,h)}catch(q){G(h,g)&&k({loading:!1,connection:"disconnected",error:Ae(q)})}}async function te(o,h={},g=new AbortController){j.add(g);let q=u;try{let K=await O("command",{action:o,args:M?{...h,teamId:M}:h,requestId:ht()},g.signal);if(w||q!==u)throw new DOMException("Selection changed","AbortError");return K}finally{j.delete(g)}}async function W(o){if(w||!M||!y.team)throw Error("Select a team before changing it.");if(y.connection!=="connected")throw Error("Refresh the connection before changing the team.");if(y.pending)throw Error("Wait for the current action to finish.");let h=new AbortController;j.add(h);let g=u;k({pending:!0,error:null});try{let q=await O("command",o,h.signal);if(w||g!==u)throw new DOMException("Selection changed","AbortError");return b=null,q?.id?Y(q):await S(x.signal,g),k({pending:!1,error:null}),q}catch(q){if(!w&&g===u){let K=Ae(q),ye=!K.code.startsWith("hive-swarm/")||/outcome unconfirmed/i.test(K.message);b=ye?o:null,k({pending:!1,error:{...K,action:ye}})}throw q}finally{j.delete(h)}}let Q={getSnapshot:()=>y,subscribe:o=>(U.add(o),()=>U.delete(o)),retain(){if(w)return()=>{};N++,N===1&&se();let o=!1;return()=>{o||(o=!0,--N===0&&(ce(),k({connection:"idle",loading:!1,pending:!1,modelsLoading:!1,historyLoading:!1,journal:null})))}},async selectTeam(o){ce(),M=o||null,d=null,H=0,b=null,k({team:null,selectedId:M,journal:null,history:[],hasMoreHistory:!1,historyLoading:!1,modelsLoading:!1,error:null,pending:!1,loading:!!N}),await se()},refresh:()=>{se()},showTeams:()=>Q.selectTeam(null),command(o,h={}){let g={...h,teamId:M},q=b?.action===o&&JSON.stringify(b.args)===JSON.stringify(g);return W(q?b:{action:o,args:g,requestId:ht()})},retryCommand:()=>b?W(b):Promise.reject(Error("There is no action to retry.")),async loadModels(){k({modelsLoading:!0});try{let o=await te("list_models");k({models:o.models??[],modelsLoading:!1})}catch(o){o?.name!=="AbortError"&&k({modelsLoading:!1,error:Ae(o)})}},async openJournal(o){let h=y.team?.members.find(K=>K.name===o),g=Pe(h);if(!g){k({error:{message:"This member has no owned session yet."}});return}v?.abort();let q=new AbortController;v=q,k({journal:{member:o,loading:!0,turns:[],error:null}});try{let K=await te("read_journal",{member:o},q);if(K.threadId&&K.threadId!==g)throw Error("The member\u2019s session changed. Refresh its Journal to continue.");v===q&&y.journal?.member===o&&k({journal:{...K,member:o,turns:Zt(K.turns),loading:!1}})}catch(K){K?.name!=="AbortError"&&v===q&&y.journal?.member===o&&k({journal:{...y.journal,loading:!1,error:Ae(K)}})}},closeJournal:()=>{v?.abort(),v=null,k({journal:null})},async loadHistory({reset:o=!1}={}){if(!(y.historyLoading||!M)){k({historyLoading:!0});try{let h=o?0:H,g=await te("board_history",{after:h,limit:200}),q=g.posts??g.events??[];H=q.at(-1)?.seq??h,k({history:R(q),historyLoading:!1,hasMoreHistory:g.hasMore===!0})}catch(h){h?.name!=="AbortError"&&k({historyLoading:!1,error:Ae(h)})}}},async openSession(o,{fallbackToJournal:h=!0}={}){let g=y.team?.members.find(K=>K.name===o),q=Kt(y.team,g);if(!q)return k({error:{message:"This member has no owned session yet."}}),"none";if(typeof m=="function")try{return await m(q),"session"}catch{return h?(await Q.openJournal(o),"journal"):"fallback"}return h?(await Q.openJournal(o),"journal"):"fallback"},setError:o=>k({error:Ae(o)}),dispose(){w||(ce(),w=!0,U.clear())}};return Q}function ft(n){let s=new Map,l=new Set,f=null,m=(C,M,N)=>{let w=JSON.stringify([C??null,M??null,ot(N)]);return s.has(w)||s.set(w,n(C,M,N)),s.get(w)},r=m(null);return{forSession:m,getSnapshot:()=>f??r,subscribe:C=>(l.add(C),()=>l.delete(C)),select(C){f=C;for(let M of l)M()},reconnect(){for(let C of s.values())C.refresh()},dispose(){for(let C of s.values())C.dispose();s.clear(),l.clear()}}}var e=Ue(require("react"),1),Ce=Ue(vt(),1),We=Ue(yt(),1),Lt=Ue(wt(),1);var kt=`<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256" role="img" aria-labelledby="title"><title id="title">Hive Swarm crowned bee</title>
|
|
4
|
+
var Xt=Object.create;var Ke=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var Zt=Object.getPrototypeOf,Rt=Object.prototype.hasOwnProperty;var it=(o,n)=>()=>(n||o((n={exports:{}}).exports,n),n.exports),eo=(o,n)=>{for(var d in n)Ke(o,d,{get:n[d],enumerable:!0})},ft=(o,n,d,p)=>{if(n&&typeof n=="object"||typeof n=="function")for(let m of Qt(n))!Rt.call(o,m)&&m!==d&&Ke(o,m,{get:()=>n[m],enumerable:!(p=Kt(n,m))||p.enumerable});return o};var Je=(o,n,d)=>(d=o!=null?Xt(Zt(o)):{},ft(n||!o||!o.__esModule?Ke(d,"default",{value:o,enumerable:!0}):d,o)),to=o=>ft(Ke({},"__esModule",{value:!0}),o);var wt=it((Ko,xt)=>{var at={};(()=>{"use strict";let o=Math.sqrt(3),n=new Set(["for","in","on","to","with","of","by","at","from","into","onto","about","as","and","or","the","a","an","via","per","within"]);function d(t){return t.kind==="brief"||t.kind==="message"||!t.kind&&t.author!=="system"}function p(t,{live:l=!1,now:u=Date.now()}={}){let v=t.map(j=>Date.parse(j.time)).filter(Number.isFinite);if(!v.length)return"<1m";let E=Math.max(0,Math.floor(((l?u:v.at(-1))-v[0])/6e4));return E?E<60?E+"m":Math.floor(E/60)+"h"+(E%60?" "+E%60+"m":""):"<1m"}function m(t){return!!(t.unmentioned&&!t.mentions&&!t.broadcasts)}function i(t){let l=t&&typeof t=="object",u=l?String(t.taskLabel??"").trim():"";if(u)return u;let v=String(l?t.brief??t.task??"":t??""),E=l&&t.name?String(t.name).trim():"";if(!v.trim())return E||"Swarm task";let j=v.replace(/```[\s\S]*?```/g," ").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[`*_~>#]/g," ").replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm,""),ee=/^(?:strict\s+file\s+ownership|do\s+not\s+touch|reference\s+screenshots|requirements?|first\s*\(|deliverables?)\b/i,Q=(j.split(/\r?\n+/).map(s=>s.trim()).filter(s=>s&&!ee.test(s)).slice(0,8).join(" ")||j).replace(/\s+/g," ").trim(),se=[/^you\s+have\s+just\s+started[.:!]*\s*/i,/^your\s+assignment(?:\s*\([^)]*\))?[:.\s-]*/i,/^you\s+are(?:\s+(?:a|an|the))?\s+(?:hive\s+swarm\s+)?(?:member|agent|worker|owner)(?:\s+['"]?@?[a-z0-9_-]+['"]?)?(?:\s+(?:for|on|in)\s+hive\s+swarm(?:\s+\d+(?:\.\d+)*)?)?[.,:;\s-]*/i,/^as(?:\s+(?:a|an|the))?\s+[a-z0-9 _-]+,\s*/i,/^(?:your\s+)?(?:task|goal|role|mission|assignment)\s*(?:is\s+to|is|:)\s*/i,/^you\s+(?:own|will\s+own|are\s+responsible\s+for|need\s+to|should|must)\s+(?:the\s+)?/i,/^please\s+/i,/^for\s+hive\s+swarm(?:\s+\d+(?:\.\d+)*)?[.,:;\s-]*/i];for(let s=0;s<3;s++){let D=!1;for(let S of se){let I=Q.replace(S,"").trim();I!==Q&&(Q=I,D=!0)}if(!D)break}if(Q=Q.replace(/\s+(?:in|on)\s+(?:your|the)\s+(?:shared\s+)?worktree.*$/i,"").replace(/\s+for\s+hive\s+swarm(?:\s+\d+(?:\.\d+)*)?\.?$/i,"").replace(/\s+/g," ").trim(),Q.length>64){let s=/^(.{18,64}?)[.!?](?:\s|$)/.exec(Q);s&&(Q=s[1])}let B=Q.replace(/[.,:;!?-]+$/g,"").split(/\s+/).filter(Boolean);B.length>10&&(B=B.slice(0,10));let H=B.join(" ");for(;H.length>64&&B.length>1;)B.pop(),H=B.join(" ");let ce=H.lastIndexOf("("),_=H.lastIndexOf(")");if(ce!==-1&&ce>_){let s=H.slice(0,ce).replace(/[,:;-\s]+$/,"").trim();s.split(/\s+/).length>=2?(H=s,B=H.split(/\s+/).filter(Boolean)):(H=H.replace(/\(/g,""),B=H.split(/\s+/).filter(Boolean))}for(;B.length>2&&n.has(B.at(-1).replace(/[,:;!?-]+$/g,"").toLowerCase());)B.pop();return H=B.join(" ").replace(/[,:;!?-]+$/g,"").trim(),H.length>64&&(H=H.slice(0,64).replace(/\s+\S*$/,"").replace(/[,:;!?-]+$/g,"").trim()),H?H[0].toUpperCase()+H.slice(1):E||"Swarm task"}function N(t){let l=t??[],u=l.some(E=>(E.role==="coordinator"||E.name==="coordinator")&&!E.external),v=l.some(E=>E.name==="user");return!u&&!v}function k(t,l,u,{hideInactive:v=!1,expandBroadcast:E=!1}={}){let j=N(l),ee=_=>j&&_==="user"?"coordinator":_,oe=new Map([["coordinator",{name:"coordinator",role:"coordinator",status:"waiting"}]]);for(let _ of l)oe.set(_.name,_);let Q=new Set,se=new Map,B=new Map,H=0;function ce(_){oe.has(_)||oe.set(_,{name:_,status:"observer"}),Q.add(_)}for(let _ of t){if(_.seq>u||!d(_))continue;let s=ee(_.author),D=[...new Set([...(_.targets??[]).map(ee),..._.coordinatorMention?["coordinator"]:[]])];ce(s);let S=se.get(s)??{posts:0,mentions:0,broadcasts:0,unmentioned:0,lastSeq:0};S.posts++,S.lastSeq=_.seq,se.set(s,S);let I=_.broadcast??/(?:^|[^a-z0-9_])@all(?![a-z0-9_-])/i.test(_.text??"");I&&(S.broadcasts++,H++),!I&&!D.some(F=>F!==s)&&S.unmentioned++;for(let F of new Set(D)){if(F===s||(ce(F),I&&!E))continue;let V=s+">"+F,ne=B.get(V)??{from:s,to:F,count:0,direct:0,broadcast:0,lastSeq:0};ne.count++,I?ne.broadcast++:ne.direct++,ne.lastSeq=_.seq,S.mentions++,B.set(V,ne)}}return{nodes:[...oe.values()].filter(_=>!v||Q.has(_.name)).map(_=>({..._,...se.get(_.name)})),links:[...B.values()],broadcasts:H}}function C(t,l){return t>6||t>3&&l<440}function y(t){return Math.max(1,Math.floor(t/120))}function c(t,l){if(C(t,l)){let u=Math.ceil(t/y(l));return Math.max(340,u*124+44)}return t>=6?470:t===5?450:t===4?400:0}function w(t,l,u){let v=new Map;if(!t.length)return v;if(C(t.length,l)){let ce=y(l),_=Math.ceil(t.length/ce),s=l/ce,D=56,S=66,I=Math.max(0,u-D-S);return t.forEach((F,V)=>{let ne=Math.floor(V/ce),X=Math.min(ce,t.length-ne*ce),de=_===1?Math.max(D,Math.min(u-S,u/2-8)):D+ne/(_-1)*I;v.set(F.name,{x:s*(V%ce+.5+(ce-X)/2),y:de})}),v}let E=t.find(ce=>ce.role==="coordinator")??t[0];if(!E)return v;let j=t.filter(ce=>ce!==E),ee=56,oe=66,Q=(ee+(u-oe))/2,se=Math.max(48,(u-ee-oe)/2),B=Math.min(68,Math.max(54,l*.1)),H=Math.max(44,Math.min(l*.4,l/2-B));if(!j.length)return v.set(E.name,{x:l/2,y:Q}),v;if(j.length===1){let ce=Math.max(54,Math.min(H*.72,l/2-B));return v.set(E.name,{x:l/2-ce,y:Q}),v.set(j[0].name,{x:l/2+ce,y:Q}),v}if(j.length===2){let ce=Math.max(ee,Q-se*.78),_=Math.min(u-oe,Q+se*.72),s=Math.max(54,Math.min(H*.85,l/2-B));return v.set(E.name,{x:l/2,y:ce}),v.set(j[0].name,{x:l/2-s,y:_}),v.set(j[1].name,{x:l/2+s,y:_}),v}return v.set(E.name,{x:l/2,y:Q}),j.forEach((ce,_)=>{let s=-Math.PI/2+_*Math.PI*2/j.length;v.set(ce.name,{x:l/2+Math.cos(s)*H,y:Q+Math.sin(s)*se})}),v}function x(t,l){return t>12||t>5&&l<380||t>8&&l<465}function b(t,l){if(x(t,l)){let u=Math.max(1,Math.floor(Math.max(l-24,140)/145)),v=Math.ceil(t/u);return Math.max(360,v*68+80)}return t>=11?680:t>=9?560:t>=7?470:t>=5?400:360}function P(t,l,u){let v=new Map;if(!t?.length)return v;let E=l<465,j=[],ee=t.find(S=>S.role==="coordinator"||S.name==="coordinator");ee&&j.push(ee);for(let S of t)S!==ee&&j.push(S);if(x(j.length,l)){let S=Math.max(...j.map(K=>z(K,{variant:"pill",narrow:E}).halfW*2),116),I=Math.max(1,Math.floor((l-24)/(S+14))),F=Math.ceil(j.length/I),V=l/I,ne=42,de=Math.max(40,u-ne-46);return j.forEach((K,le)=>{let he=Math.floor(le/I),me=Math.min(I,j.length-he*I),Se=F===1?u/2:ne+he/(F-1)*de,ue=V*(le%I+.5+(I-me)/2);v.set(K.name,{x:ue,y:Se})}),v}if(j.length===1)return v.set(j[0].name,{x:l/2,y:u/2}),v;let oe=Math.max(...j.map(S=>z(S,{variant:"pill",narrow:E}).halfW),56),Q=Math.max(...j.map(S=>z(S,{variant:"pill",narrow:E}).halfH),17),se=Q+18,B=Q+22,H=Math.min(l*.28,oe+18),ce=l/2,_=(se+(u-B))/2,s=Math.max(48,Math.min(l*.42,l/2-H)),D=Math.max(44,(u-se-B)/2);return j.forEach((S,I)=>{let F=-Math.PI/2+I*Math.PI*2/j.length;v.set(S.name,{x:ce+Math.cos(F)*s,y:_+Math.sin(F)*D})}),v}function q(t,l){let u=String(t??"").trim();if(!u)return 1;let v=Math.max(6,l),E=u.match(/[^-\s_/]+[-\s_/]*|[-\s_/]+/g)??[u],j=1,ee=0;for(let oe of E){let Q=oe;for(;Q.length>v;)ee>0&&(j++,ee=0),Q=Q.slice(v),j++;ee>0&&ee+Q.length>v?(j++,ee=Q.length):ee+=Q.length}return Math.max(1,j)}function z(t,{variant:l="card",cardWidth:u,narrow:v=!1}={}){if(l==="pill"){let Q=String(t?.name??""),se=Q==="user"?"You":Q==="system"?"System":Q,B=v?16:18,H=v?156:210,ce=v?88:104,_=v?6.4:7.2;return{halfW:Math.min(H,Math.max(ce,(v?38:46)+se.length*_))/2,halfH:B,offsetX:0,offsetY:0,radius:B}}if(l==="hex"){let Q=v?84:128,se=String(t?.name??""),B=se==="user"?"You":se==="system"?"System":"@"+se,H=Math.max(8,Math.floor((Q-12)/6.3)),ce=q(B,H),_=Math.min(Q,Math.max(38,12+B.length*6.3)),s=m(t??{}),D=Math.max(s?32:28,_/2),S=s?32:t?.broadcasts?29:24,I=29+ce*15+4;return{halfW:D,halfH:(S+I)/2,offsetX:0,offsetY:(I-S)/2,radius:10}}let E=u??(v?92:112),j=Math.max(7,Math.floor((E-20)/7.4)),oe=64+q(t?.name??"",j)*16;return{halfW:E/2,halfH:oe/2,offsetX:0,offsetY:0,radius:10}}function J(t,l){if(!l)return{cx:t.x,cy:t.y,halfW:26,halfH:26,radius:10};if(Number.isFinite(l.left)&&Number.isFinite(l.right)&&Number.isFinite(l.top)&&Number.isFinite(l.bottom))return{cx:t.x+(l.right-l.left)/2,cy:t.y+(l.bottom-l.top)/2,halfW:(l.left+l.right)/2,halfH:(l.top+l.bottom)/2,radius:Math.max(0,l.radius??8)};let u=Number.isFinite(l.halfW)?l.halfW:Number.isFinite(l.width)?l.width/2:26,v=Number.isFinite(l.halfH)?l.halfH:Number.isFinite(l.height)?l.height/2:26;return{cx:Number.isFinite(l.cx)?l.cx:t.x+(l.offsetX??0),cy:Number.isFinite(l.cy)?l.cy:t.y+(l.offsetY??0),halfW:Math.max(1,u),halfH:Math.max(1,v),radius:Math.max(0,l.radius??8)}}function g(t,l,u){let v=Math.max(0,Math.min(u.radius??0,u.halfW,u.halfH)),E=Math.abs(t-u.cx)-(u.halfW-v),j=Math.abs(l-u.cy)-(u.halfH-v);return Math.hypot(Math.max(E,0),Math.max(j,0))+Math.min(Math.max(E,j),0)-v}function T(t,l,u,v){let E=1-v;return{x:E*E*t.x+2*E*v*l.x+v*v*u.x,y:E*E*t.y+2*E*v*l.y+v*v*u.y}}function G(t,l,u,v,E){let j=(1-v)*(1-E),ee=(1-v)*E+v*(1-E),oe=v*E;return{x:j*t.x+ee*l.x+oe*u.x,y:j*t.y+ee*l.y+oe*u.y}}function $(t,l,u,v,E,j,ee,oe){let se=-1;for(let ue=0;ue<=32;ue++){let U=T(t,l,u,ue/32);g(U.x,U.y,v)<=j&&(se=ue)}if(se>=32)return null;let B=0;if(se>=0){let ue=se/32,U=(se+1)/32;for(let ve=0;ve<22;ve++){let be=(ue+U)/2,ye=T(t,l,u,be);g(ye.x,ye.y,v)<=j?ue=be:U=be}B=U}let H=-1,ce=Math.max(0,se+1);for(let ue=ce;ue<=32;ue++){let U=T(t,l,u,ue/32);if(g(U.x,U.y,E)<=ee){H=ue;break}}if(H<=0)return null;let _=(H-1)/32,s=H/32;for(let ue=0;ue<22;ue++){let U=(_+s)/2,ve=T(t,l,u,U);g(ve.x,ve.y,E)<=ee?s=U:_=U}let D=_;if(D<=B+1e-4)return null;let S=T(t,l,u,B),I=T(t,l,u,D),F=Math.hypot(I.x-S.x,I.y-S.y);if(F<oe)return null;let V=G(t,l,u,B,D),ne=T(t,l,u,(B+D)/2),X=I.x-V.x,de=I.y-V.y,K=V.x-S.x,le=V.y-S.y,he=Math.hypot(X,de)>1e-4?Math.atan2(de,X):Math.atan2(I.y-S.y,I.x-S.x),me=Math.hypot(K,le)>1e-4?Math.atan2(le,K):Math.atan2(I.y-S.y,I.x-S.x),Se="M"+S.x.toFixed(1)+" "+S.y.toFixed(1)+" Q"+V.x.toFixed(1)+" "+V.y.toFixed(1)+" "+I.x.toFixed(1)+" "+I.y.toFixed(1);return{start:S,control:V,end:I,mid:ne,startAngle:me,endAngle:he,length:F,tStart:B,tEnd:D,d:Se}}function O(t,l){if(!l.length)return 1/0;let u=1/0;for(let v=0;v<=24;v++){let E=T(t.start,t.control,t.end,v/24);for(let j of l){let ee=g(E.x,E.y,j);ee<u&&(u=ee)}}for(let v of l){let E=g(t.mid.x,t.mid.y,v)-10;E<u&&(u=E)}return u}function h(t,l,u,v,{marginStart:E=6,marginEnd:j=7,bidirectional:ee=!1,bend:oe,obstacles:Q=[],obstacleMargin:se=8,minLength:B=8}={}){if(!t||!l)return null;let H=J(t,u),ce=J(l,v),_={x:H.cx,y:H.cy},s={x:ce.cx,y:ce.cy},D=s.x-_.x,S=s.y-_.y,I=Math.hypot(D,S);if(I<1)return null;let F=D/I,ne=-(S/I),X=F,de=Q.map(he=>he?.box?J(he,he.box):J(he,he)),K=[];if(Number.isFinite(oe))K.push(oe);else if(ee){let he=Math.min(34,Math.max(18,I*.145));K.push(he,Math.min(54,he*1.45),Math.max(10,he*.55),Math.min(72,I*.3),Math.max(6,he*.3))}else{let he=Math.min(20,Math.max(8,I*.065)),me=Math.min(82,I*.34);K.push(he,-he,0,Math.min(me,he*2),-Math.min(me,he*2),Math.min(me,he*3.2),-Math.min(me,he*3.2),me,-me)}let le=(he,me,Se)=>{let ue=null,U=-1/0;for(let ve of K){let be={x:(_.x+s.x)/2+ne*ve,y:(_.y+s.y)/2+X*ve},ye=$(_,be,s,H,ce,he,me,Se);if(!ye)continue;let ke=O(ye,de),qe={...ye,bend:ve,clearance:ke};if(ke>=se)return qe;ke>U&&(U=ke,ue=qe)}return ue};return le(E,j,B)??le(Math.min(E,2),Math.min(j,3),Math.min(B,4))}function W(t,l,{variant:u="card",boxes:v,cardWidth:E,narrow:j=!1,marginStart:ee=6,marginEnd:oe=7,obstacleMargin:Q=8,minLength:se=8}={}){let B=new Map;for(let F of t.nodes??[]){let V=v?.get?.(F.name);B.set(F.name,V??z(F,{variant:u,cardWidth:E,narrow:j}))}let H=new Set((t.links??[]).map(F=>F.from+">"+F.to)),ce=new Map,_=[],s=(F,V)=>{let ne=[];for(let X of t.nodes??[]){if(X.name===F||X.name===V)continue;let de=l.get(X.name);de&&ne.push({x:de.x,y:de.y,box:B.get(X.name)})}return ne};for(let F of t.links??[]){let V=l.get(F.from),ne=l.get(F.to);if(!V||!ne)continue;let X=B.get(F.from)??z({name:F.from},{variant:u,cardWidth:E,narrow:j}),de=B.get(F.to)??z({name:F.to},{variant:u,cardWidth:E,narrow:j}),K=s(F.from,F.to),le=H.has(F.to+">"+F.from),he=h(V,ne,X,de,{marginStart:ee,marginEnd:oe,bidirectional:le,obstacles:K,obstacleMargin:Q,minLength:se});if(he){let me={link:F,edge:he,bidirectional:le,fromBox:X,toBox:de,obstacles:K};_.push(me),ce.set(F.from+">"+F.to,me)}}for(let F of _){if(!F.bidirectional||F.edge.clearance>=Math.min(Q,16))continue;let V=ce.get(F.link.to+">"+F.link.from);if(!V||V.edge.clearance<Math.min(Q,16))continue;let ne=l.get(F.link.from),X=l.get(F.link.to);for(let de of[-18,-26,-36,-48]){let K=h(ne,X,F.fromBox,F.toBox,{marginStart:ee,marginEnd:oe,bidirectional:!0,bend:de,obstacles:F.obstacles,obstacleMargin:Q,minLength:se});if(!K||K.clearance<10)continue;let le=Math.max(V.edge.bend,Math.abs(de)+28),he=h(X,ne,V.fromBox,V.toBox,{marginStart:ee,marginEnd:oe,bidirectional:!0,bend:le,obstacles:V.obstacles,obstacleMargin:Q,minLength:se});if(he&&he.clearance>=10&&Math.hypot(K.mid.x-he.mid.x,K.mid.y-he.mid.y)>=12){F.edge=K,V.edge=he;break}}}let D=[],S=(F,V,ne)=>{for(let X of V){let de=X?.box?J(X,X.box):J(X,X);if(g(F.x,F.y,de)<ne)return!1}for(let X of D)if(Math.hypot(F.x-X.x,F.y-X.y)<26)return!1;return!0},I=[];for(let F of t.nodes??[]){let V=l.get(F.name);V&&I.push({x:V.x,y:V.y,box:B.get(F.name)})}for(let F of _){let{edge:V,link:ne}=F;if(V.length<40)continue;let X=V.start,de=V.control,K=V.end,le=V.mid;if(!S(le,I,12))for(let he of[.38,.62,.32,.68,.44,.56]){let me=T(X,de,K,he);if(S(me,I,12)){le=me;break}}V.mid=le,ne.count>1&&D.push(le)}return _.map(({link:F,edge:V,bidirectional:ne})=>({link:F,edge:V,bidirectional:ne}))}function Z(t,l,u){let v=N(l),E=U=>v&&U==="user"?"coordinator":U,j=u==null?1/0:Number(u),ee=(t??[]).filter(U=>d(U)&&Number.isFinite(U.seq)).slice().sort((U,ve)=>U.seq-ve.seq),oe=ee.reduce((U,ve)=>Math.max(U,ve.seq),0),Q=j>=oe,se=ee.filter(U=>U.seq<=j),B=se.at(-1)??null,H=new Map,ce=new Map,_=new Map,s=new Map;for(let U of se){let ve=E(U.author);ce.set(ve,U.seq),H.set(ve,U);let be=new Set([...(U.targets??[]).map(E),...U.coordinatorMention?["coordinator"]:[]]);for(let ye of be)U.kind==="brief"&&_.set(ye,U.seq),s.set(ye,U.seq)}let D=l??[],S=D.find(U=>U.role==="coordinator"||U.name==="coordinator")??{name:"coordinator",role:"coordinator",status:"waiting"},I=D.filter(U=>U.role!=="coordinator"&&U.name!=="coordinator"),F=[{id:"working",label:"Working",tone:"working"},{id:"waiting",label:"Waiting",tone:"waiting"},{id:"needs",label:"Needs you",tone:"needs"},{id:"done",label:"Done",tone:"done"}],V=new Map(F.map(U=>[U.id,{...U,count:0,members:[]}])),ne=new Map([["coordinator","coordinator"]]);for(let U of I){let ve=ce.get(U.name)??0,be,ye=!1,ke=[];if(Q)be=U.status??"waiting",ye=!!U.recoveryRequired,ke=[...U.pendingWaitFor??U.waitFor??[]];else{let Ye=H.get(U.name),Xe=_.get(U.name)??0,Be=s.get(U.name)??0;j<=0?be="waiting":Ye&&/\[done\]/i.test(String(Ye.text??""))?be="done":E(B?.author)===U.name||Math.max(Xe,Be)>(Ye?.seq??0)?be="working":be="waiting"}let qe;ye||be==="failed"||be==="quota"?qe="needs":be==="working"?qe="working":be==="done"||be==="retired"?qe="done":qe="waiting";let ze=qe==="done",Pe={name:U.name,status:be,role:U.role??"worker",tint:U.tint,muted:ze,latestSeq:ve,pendingWaitFor:ke},He=V.get(qe);He.members.push(Pe),He.count=He.members.length,ne.set(U.name,qe)}let X=F.map(U=>V.get(U.id)).filter(U=>U.count>0),de=I.length,K=V.get("done").count,le;V.get("needs").count>0?le="stalled":V.get("working").count>0||Q&&S.status==="working"?le="working":de>0&&K===de?le="done":le="waiting";let he={name:"coordinator",status:Q?S.status??le:E(B?.author)==="coordinator"?"working":le,role:"coordinator",doneCount:K,totalWorkers:de,phase:le,latestSeq:ce.get("coordinator")??0,tint:S.tint},me=[],Se=new Set,ue=U=>{let ve=`${U.from}>${U.to}>${U.kind}`;Se.has(ve)||(Se.add(ve),me.push(U))};if(V.get("done").count>0&&ue({from:"done",to:"coordinator",kind:"done",label:"Tasks done"}),B&&(j===1/0||B.seq===j||!Q)){let U=ne.get(E(B.author));if(U){let ve=B.broadcast??/(?:^|[^a-z0-9_])@all(?![a-z0-9_-])/i.test(B.text??""),be=[...(B.targets??[]).map(E),...B.coordinatorMention?["coordinator"]:[]];if(ve){for(let ye of X)ye.id!==U&&ue({from:U,to:ye.id,kind:"message",label:"Message just sent",seq:B.seq});U!=="coordinator"&&ue({from:U,to:"coordinator",kind:"message",label:"Message just sent",seq:B.seq})}else for(let ye of be){let ke=ne.get(ye);ke&&ke!==U&&ue({from:U,to:ke,kind:"message",label:"Message just sent",seq:B.seq})}}}for(let U of X)for(let ve of U.members)for(let be of ve.pendingWaitFor??[]){let ye=ne.get(be);ye&&ue({from:U.id,to:ye,kind:"waiting",label:"Waiting on"})}return{currentSeq:B?.seq??0,lastPost:B,coordinator:he,clusters:X,connectors:me}}function re(t,l,u){let v=[];for(let E=0;E<6;E++){let j=E*Math.PI/3;v.push({x:t+u*Math.cos(j),y:l+u*Math.sin(j)})}return v}function pe(t){if(t<=0)return[];if(t<=3)return[t];if(t===4)return[2,2];if(t===5)return[3,2];if(t===6)return[3,3];if(t===7)return[4,3];if(t===8)return[4,4];if(t===9)return[3,4,2];if(t===10)return[4,4,2];if(t===11)return[4,4,3];if(t===12)return[4,4,4];let l=[],u=t;for(;u>0;){let v=Math.min(4,u);l.push(v),u-=v}return l}function ie(t,l,u,v){let E=v.length;if(!E)return[];let j=o/2*u,ee=pe(E),oe=ee.length,Q=-j*.14,se=j*.5,B=oe===1?j*.1:(Q+se)/2,H=se-Q,ce=E>6?Math.max(.7,Math.min(.98,u/106)):Math.max(.82,Math.min(1.08,u/98)),_=[],s=0;for(let D=0;D<oe;D++){let S=ee[D],I=oe===1?l+B:l+Q+D/(oe-1)*H,F=I-l,V=Math.max(18,u-Math.max(Math.abs(F-15),Math.abs(F+18))/o-8),ne=E>6?42:52,X=S===1?0:Math.min(ne,(V*2-4)/S),de=S===1?Math.min(88,V*1.85):Math.max(30,X-2);for(let K=0;K<S;K++){let le=t+(K-(S-1)/2)*X;_.push({member:v[s++],x:le,y:I,slotWidth:de,beeScale:ce})}}return _}function L(t,l){return t<=1?l<420?380:440:t===2?l<420?440:430:490}function R(t,l=680,u=460){let v=t?.clusters??[],E=34,j=14,oe=Math.max(200,l-16*2),Q=Math.max(220,u-j-E),se,B=[];if(v.length===0)se=Math.max(48,Math.min(oe/2.2,Q/(o*1.15),114)),B.push({id:"coordinator",ux:0,uy:0,isCoord:!0});else if(v.length===1){let ue=Math.max(12,Math.min(20,Q*.036));se=Math.max(46,Math.min(oe/2.15,(Q-ue)/(2*o),112));let U=o*se+ue,ve=l/2,be=j+Q/2,ye=new Map,ke={x:ve,y:be-U/2},qe={x:ve,y:be+U/2},ze=v[0],Pe={id:ze.id,label:ze.label,tone:ze.tone,count:ze.count,x:ke.x,y:ke.y,radius:se,vertices:re(ke.x,ke.y,se),slots:ie(ke.x,ke.y,se,ze.members??[])},He={id:"coordinator",x:qe.x,y:qe.y,radius:se,vertices:re(qe.x,qe.y,se),model:t.coordinator};return ye.set(Pe.id,Pe),ye.set("coordinator",He),{width:l,height:u,radius:se,coordinator:He,clusters:[Pe],cellsById:ye}}else if(v.length===2)B.push({id:"coordinator",ux:0,uy:.35,isCoord:!0}),oe>=Q*.85?(B.push({id:v[0].id,cluster:v[0],ux:-o/2,uy:-.15}),B.push({id:v[1].id,cluster:v[1],ux:o/2,uy:-.15})):(B.push({id:v[0].id,cluster:v[0],ux:0,uy:-.65}),B.push({id:v[1].id,cluster:v[1],ux:0,uy:1.35}));else if(v.length===3)B.push({id:"coordinator",ux:0,uy:0,isCoord:!0}),B.push({id:v[0].id,cluster:v[0],ux:0,uy:-1}),B.push({id:v[1].id,cluster:v[1],ux:-o/2,uy:.5}),B.push({id:v[2].id,cluster:v[2],ux:o/2,uy:.5});else{B.push({id:"coordinator",ux:0,uy:0,isCoord:!0}),B.push({id:v[0].id,cluster:v[0],ux:-o/2,uy:-.5}),B.push({id:v[1].id,cluster:v[1],ux:o/2,uy:-.5}),B.push({id:v[2].id,cluster:v[2],ux:-o/2,uy:.5}),B.push({id:v[3].id,cluster:v[3],ux:o/2,uy:.5});for(let ue=4;ue<v.length;ue++)B.push({id:v[ue].id,cluster:v[ue],ux:0,uy:ue===4?-1:1})}let H=Math.min(...B.map(ue=>ue.ux)),ce=Math.max(...B.map(ue=>ue.ux)),_=Math.min(...B.map(ue=>ue.uy)),s=Math.max(...B.map(ue=>ue.uy)),D=ce-H,S=s-_,I=Math.max(10,Math.min(18,Q*.03)),F=(oe-D*I)/(D*o+2),V=(Q-S*I)/(S*o+o);se=Math.max(40,Math.min(F,V,108));let ne=o*se+I,X=(H+ce)/2,de=(_+s)/2,K=l/2-X*ne,le=j+Q/2-de*ne,he=new Map,me=null,Se=[];for(let ue of B){let U=K+ue.ux*ne,ve=le+ue.uy*ne,be=re(U,ve,se);if(ue.isCoord)me={id:"coordinator",x:U,y:ve,radius:se,vertices:be,model:t?.coordinator},he.set("coordinator",me);else{let ye=ue.cluster,ke={id:ye.id,label:ye.label,tone:ye.tone,count:ye.count,x:U,y:ve,radius:se,vertices:be,slots:ie(U,ve,se,ye.members??[])};Se.push(ke),he.set(ke.id,ke)}}return{width:l,height:u,radius:se,coordinator:me,clusters:Se,cellsById:he}}function a(t,l,u){let v=o/2*t.radius,E=Math.abs(u),j=Math.abs(.8660254037844386*l+.5*u),ee=Math.abs(.8660254037844386*l-.5*u);return v/Math.max(E,j,ee,1e-6)}function A(t,l,u,v){let j=Math.sqrt(3)*22;t.strokeStyle=v,t.lineWidth=.8,t.beginPath();for(let ee=-1;ee<l/(22*1.5)+1;ee++)for(let oe=-1;oe<u/j+1;oe++){let Q=ee*1.5*22,se=oe*j+ee%2*j/2;for(let B=0;B<6;B++){let H=B*Math.PI/3,ce=Q+22*Math.cos(H),_=se+22*Math.sin(H);B===0?t.moveTo(ce,_):t.lineTo(ce,_)}t.closePath()}t.stroke()}function r(t,l,u,v,E,j){let ee=Math.min(j,v/2,E/2),oe=l-v/2,Q=u-E/2,se=l+v/2,B=u+E/2;t.beginPath(),t.moveTo(oe+ee,Q),t.lineTo(se-ee,Q),t.quadraticCurveTo(se,Q,se,Q+ee),t.lineTo(se,B-ee),t.quadraticCurveTo(se,B,se-ee,B),t.lineTo(oe+ee,B),t.quadraticCurveTo(oe,B,oe,B-ee),t.lineTo(oe,Q+ee),t.quadraticCurveTo(oe,Q,oe+ee,Q),t.closePath()}function M(t,l,u,v,E,j){let ee=t.clientWidth,oe=t.clientHeight;if(!ee||!oe)return;let Q=Math.min(devicePixelRatio||1,2),se=Math.round(ee*Q),B=Math.round(oe*Q);(t.width!==se||t.height!==B)&&(t.width=se,t.height=B);let H=t.getContext("2d");H.setTransform(Q,0,0,Q,0,0),H.clearRect(0,0,ee,oe),A(H,ee,oe,j.grid),H.strokeStyle=j.accent,H.lineWidth=1.4,H.setLineDash([3,3]);for(let _ of l.nodes){let s=u.get(_.name);!s||!m(_)||(H.globalAlpha=!v||v===_.name?.85:.2,H.beginPath(),H.arc(s.x,s.y,31,0,Math.PI*2),H.stroke())}H.setLineDash([]),H.font="600 10px ui-monospace, monospace",H.textAlign="center",H.textBaseline="middle";let ce=W(l,u,{variant:"hex",narrow:ee<465,marginStart:6,marginEnd:6,obstacleMargin:ee<465?14:24});for(let{link:_,edge:s}of ce){let{start:D,control:S,end:I,mid:F,endAngle:V}=s,ne=_.lastSeq===E,X=!v||_.from===v||_.to===v,de=ne&&X?j.accent:j.link;H.globalAlpha=X?ne?1:.78:.16,H.strokeStyle=H.fillStyle=de,H.lineWidth=Math.min(3.8,1.1+Math.sqrt(_.count)*.65),H.lineCap="round",H.setLineDash(_.direct?[]:[4,4]);let K=Math.min(4.5,s.length*.25),le=I.x-Math.cos(V)*K,he=I.y-Math.sin(V)*K;H.beginPath(),H.moveTo(D.x,D.y),H.quadraticCurveTo(S.x,S.y,le,he),H.stroke(),H.setLineDash([]);let me=9;if(H.beginPath(),H.moveTo(I.x,I.y),H.lineTo(I.x-me*Math.cos(V-.44),I.y-me*Math.sin(V-.44)),H.lineTo(I.x-me*.72*Math.cos(V),I.y-me*.72*Math.sin(V)),H.lineTo(I.x-me*Math.cos(V+.44),I.y-me*Math.sin(V+.44)),H.closePath(),H.fill(),X&&s.length>=40&&(_.count>1||ne||v)){let Se=String(_.count),ue=Math.max(20,Se.length*6.5+10);H.globalAlpha=.98,r(H,F.x,F.y,ue,15,7.5),H.fillStyle=j.paper,H.fill(),H.lineWidth=1,H.strokeStyle=ne?j.accent:j.link,H.stroke(),H.fillStyle=ne?j.accent:j.text,H.fillText(Se,F.x,F.y+.25)}}H.globalAlpha=1}function f(t){return t==="dark"?{bg:"#17140f",surface:"#221d16",ink:"#f5eddd",muted:"#bdb19a",border:"#43392b",edge:"#8c785c",pulse:"#c297ff",accent:"#f0b84b",doneFill:"#18281c",doneStroke:"#6ac47e",workingFill:"#2a2213",workingStroke:"#f0b84b",waitingFill:"#192133",waitingStroke:"#7da3f0",needsFill:"#2d1919",needsStroke:"#ef766e"}:{bg:"#f8f9fb",surface:"#ffffff",ink:"#24292f",muted:"#6e7781",border:"#d0d7de",edge:"#b4bcc6",pulse:"#8250df",accent:"#bf8700",doneFill:"#eef6ee",doneStroke:"#55943c",workingFill:"#fdf6e7",workingStroke:"#d18d22",waitingFill:"#eef3fc",waitingStroke:"#4d78cc",needsFill:"#fdf0ef",needsStroke:"#cf483f"}}function te(t,l){return t==="done"?{fill:l.doneFill,stroke:l.doneStroke}:t==="working"?{fill:l.workingFill,stroke:l.workingStroke}:t==="needs"||t==="stalled"?{fill:l.needsFill,stroke:l.needsStroke}:{fill:l.waitingFill,stroke:l.waitingStroke}}function Y(t,l){return t==="working"?l.doneStroke:t==="failed"||t==="quota"?l.needsStroke:t==="waiting"||t==="queued"?l.waitingStroke:l.muted}function Me(t){return t||(typeof window<"u"&&window.HiveBee?window.HiveBee:at.HiveBee)}function fe(t,l,u,v,E,j){if(j?.drawSprite){j.drawSprite(t,l,u,v,E);return}if(j?.sprite&&typeof document<"u"){let ee=j.sprite(v,E),oe=E?.scale??1;t.drawImage?.(ee,l,u,ee.width*oe,ee.height*oe)}}function ae(t,l){let u=String(t??"");return u.length<=l?u:l<=3?u.slice(0,l):u.slice(0,l-1)+"\u2026"}function xe(t,l,u,v,E=8){t.beginPath(),t.moveTo(l,u),t.lineTo(l-E*Math.cos(v-.44),u-E*Math.sin(v-.44)),t.lineTo(l-E*.7*Math.cos(v),u-E*.7*Math.sin(v)),t.lineTo(l-E*Math.cos(v+.44),u-E*Math.sin(v+.44)),t.closePath(),t.fill()}function Ce(t,l){t.beginPath(),l.forEach((u,v)=>{v===0?t.moveTo(u.x,u.y):t.lineTo(u.x,u.y)}),t.closePath()}function Ne(t,l,u,v){let{posts:E=[],members:j=[],cursor:ee=null,phase:oe,width:Q=680,height:se=460,focus:B=null}=l,H=Z(E,j,ee);oe&&ee==null&&(oe==="done"&&H.coordinator.totalWorkers>0&&H.coordinator.doneCount===H.coordinator.totalWorkers?H.coordinator.phase="done":(oe==="stalled"||oe==="budget")&&(H.coordinator.phase="stalled"));let ce=R(H,Q,se);for(let S of H.connectors){let I=ce.cellsById.get(S.from),F=ce.cellsById.get(S.to);if(!I||!F)continue;let V=S.kind==="message"?u.pulse:S.kind==="waiting"?u.workingStroke:u.doneStroke;if(t.strokeStyle=V,t.fillStyle=V,t.lineWidth=S.kind==="message"?2.2:1.5,t.setLineDash?.(S.kind==="waiting"?[4,4]:[]),I===F){let qe=I.x+I.radius*.72,ze=I.y-o/2*I.radius*.4;t.beginPath(),t.arc(qe+8,ze,10,-Math.PI*.8,Math.PI*.8),t.stroke(),t.setLineDash?.([]);continue}let ne=F.x-I.x,X=F.y-I.y,de=Math.hypot(ne,X);if(de<1)continue;let K=ne/de,le=X/de,he=a(I,K,le),me=a(F,-K,-le),Se=S.kind==="message"?8:S.kind==="waiting"?-8:0,ue=-le,U=K,ve=I.x+K*(he+2)+ue*Se,be=I.y+le*(he+2)+U*Se,ye=F.x-K*(me+2)+ue*Se,ke=F.y-le*(me+2)+U*Se;t.beginPath(),t.moveTo(ve,be),t.lineTo(ye,ke),t.stroke(),t.setLineDash?.([]),S.kind!=="done"&&xe(t,ye,ke,Math.atan2(ke-be,ye-ve),7)}t.textAlign="center",t.textBaseline="middle";for(let S of ce.clusters){let I=te(S.tone,u),F=!!B,V=!F||S.slots.some(X=>X.member.name===B);t.globalAlpha=V?1:.38,Ce(t,S.vertices),t.fillStyle=I.fill,t.fill(),t.lineWidth=2,t.strokeStyle=I.stroke,t.stroke();let ne=o/2*S.radius;t.fillStyle=u.ink,t.font='600 12px "Segoe UI", system-ui, sans-serif',t.fillText(S.label,S.x,S.y-ne*.68),t.fillStyle=u.muted,t.font='500 11px "Segoe UI", system-ui, sans-serif',t.fillText(String(S.count),S.x,S.y-ne*.5);for(let X of S.slots){let de=X.beeScale,K=20*de,le=18*de,he=F&&B!==X.member.name;t.globalAlpha=he?.35:1,F&&B===X.member.name&&(t.strokeStyle=u.accent,t.lineWidth=1.5,t.beginPath(),t.arc(X.x,X.y-2,Math.max(K,le)*.72,0,Math.PI*2),t.stroke()),fe(t,X.x-K/2,X.y-le*.68,X.member.name,{status:X.member.status,coordinator:!1,tint:X.member.tint,muted:X.member.muted,scale:de},v),t.fillStyle=X.member.muted?u.muted:u.ink,t.font='500 9.5px "Segoe UI", system-ui, sans-serif';let me=Math.max(6,Math.floor(X.slotWidth/4.6));t.fillText(ae(X.member.name,me),X.x,X.y+le*.62)}}let _=ce.coordinator;if(_){let S=te(_.model?.phase??"waiting",u);t.globalAlpha=!B||B==="coordinator"?1:.45,Ce(t,_.vertices),t.fillStyle=S.fill,t.fill(),t.lineWidth=2,t.strokeStyle=S.stroke,t.stroke();let I=Math.max(1.2,Math.min(2.1,_.radius/48)),F=20*I,V=18*I;fe(t,_.x-F/2,_.y-V*.78,"coordinator",{status:_.model?.status??"waiting",coordinator:!0,tint:_.model?.tint,muted:!1,scale:I},v);let ne=o/2*_.radius;t.fillStyle=u.ink,t.font='650 12px "Segoe UI", system-ui, sans-serif',t.fillText("Coordinator",_.x,_.y+ne*.34),t.fillStyle=u.muted,t.font='500 11px "Segoe UI", system-ui, sans-serif',t.fillText(`${_.model?.doneCount??0} of ${_.model?.totalWorkers??0} done`,_.x,_.y+ne*.56)}t.globalAlpha=1;let s=se-16,D=24;t.textAlign="left",t.textBaseline="middle",t.font='500 11px "Segoe UI", system-ui, sans-serif',t.strokeStyle=u.doneStroke,t.lineWidth=1.6,t.beginPath(),t.moveTo(D,s),t.lineTo(D+16,s),t.stroke(),t.fillStyle=u.muted,t.fillText("Tasks done",D+22,s),D+=102,t.strokeStyle=u.pulse,t.beginPath(),t.moveTo(D,s),t.lineTo(D+16,s),t.stroke(),t.fillText("Message just sent",D+22,s),D+=136,t.strokeStyle=u.workingStroke,t.fillStyle=u.workingStroke,t.setLineDash?.([3,3]),t.beginPath(),t.moveTo(D,s),t.lineTo(D+16,s),t.stroke(),t.setLineDash?.([]),xe(t,D+20,s,0,5),t.fillStyle=u.muted,t.fillText("Waiting on",D+26,s)}function ge(t,l,u,v){let{posts:E=[],members:j=[],cursor:ee=null,width:oe=680,height:Q=460,hideInactive:se=!1,expandBroadcast:B=!1,focus:H=null}=l,ce=(E??[]).filter(d).slice().sort((K,le)=>K.seq-le.seq),_=ee==null?ce.at(-1)?.seq??1/0:Number(ee),s=ce.filter(K=>K.seq<=_).at(-1)??null,D=k(E,j,_,{hideInactive:se,expandBroadcast:B}),S=Math.max(220,Q-42),I=oe<465,F=P(D.nodes,oe,S),V=new Map;for(let K of D.nodes)V.set(K.name,z(K,{variant:"pill",narrow:I}));let ne=W(D,F,{variant:"pill",boxes:V,narrow:I,marginStart:4,marginEnd:6,obstacleMargin:10});t.textAlign="center",t.textBaseline="middle";for(let{link:K,edge:le}of ne){let{start:he,control:me,end:Se,mid:ue,endAngle:U}=le,ve=!!(s&&K.lastSeq===s.seq),be=!H||K.from===H||K.to===H,ye=ve&&be?u.pulse:u.edge;t.globalAlpha=be?ve?.96:.72:.16,t.strokeStyle=t.fillStyle=ye,t.lineWidth=Math.min(4.2,1.2+Math.sqrt(K.count)*.72),t.setLineDash?.(K.direct?[]:[4,4]);let ke=Math.min(4.5,le.length*.25),qe=Se.x-Math.cos(U)*ke,ze=Se.y-Math.sin(U)*ke;if(t.beginPath(),t.moveTo(he.x,he.y),t.quadraticCurveTo(me.x,me.y,qe,ze),t.stroke(),t.setLineDash?.([]),xe(t,Se.x,Se.y,U,8),be&&le.length>=36&&(K.count>1||ve||H)){let Pe=String(K.count),He=Math.max(16,Pe.length*6.5+8);t.globalAlpha=.96,r(t,ue.x,ue.y,He,14,7),t.fillStyle=u.bg,t.fill(),t.fillStyle=ve?u.pulse:u.ink,t.font="600 10px ui-monospace, monospace",t.fillText(Pe,ue.x,ue.y+.5)}}for(let K of D.nodes){let le=F.get(K.name),he=V.get(K.name);if(!le||!he)continue;let me=K.role==="coordinator"||K.name==="coordinator",Se=K.status==="retired",ue=K.status==="done"||Se,U=!H||H===K.name||D.links.some(Be=>Be.from===H&&Be.to===K.name||Be.to===H&&Be.from===K.name);t.globalAlpha=U?Se?.56:1:.24;let ve=m(K);r(t,le.x,le.y,he.halfW*2,he.halfH*2,he.radius),t.fillStyle=u.surface,t.fill(),t.lineWidth=H===K.name?1.8:1.1,t.strokeStyle=H===K.name?u.pulse:u.border,t.setLineDash?.(ve?[3,3]:[]),t.stroke(),t.setLineDash?.([]);let be=le.x-he.halfW,ye=le.x+he.halfW,ke=I?.85:.92,qe=20*ke,ze=18*ke;fe(t,be+10,le.y-ze/2,K.name,{status:K.status??"observer",coordinator:me,tint:K.tint,muted:!me&&ue,scale:ke},v);let Pe=K.name==="user"?"You":K.name==="system"?"System":K.name,He=(be+10+qe+6+ye-14)/2;t.fillStyle=Se?u.muted:u.ink,t.font='600 11px "Segoe UI", system-ui, sans-serif';let Ye=Math.max(5,Math.floor((he.halfW*2-qe-28)/6.2)),Xe=ae(Pe,Ye);if(t.fillText(Xe,He,le.y+.5),Se){let Be=Math.min(he.halfW*2-qe-28,Xe.length*6.2);t.strokeStyle=u.muted,t.lineWidth=1,t.beginPath(),t.moveTo(He-Be/2,le.y+.5),t.lineTo(He+Be/2,le.y+.5),t.stroke()}t.fillStyle=Y(K.status,u),t.beginPath(),t.arc(ye-10,le.y,3,0,Math.PI*2),t.fill()}t.globalAlpha=1;let X=Q-22,de=24;if(t.textAlign="left",t.textBaseline="middle",t.font='500 11px "Segoe UI", system-ui, sans-serif',t.strokeStyle=u.edge,t.fillStyle=u.edge,t.lineWidth=1.4,t.beginPath(),t.moveTo(de,X),t.lineTo(de+14,X),t.stroke(),xe(t,de+18,X,0,5),t.fillStyle=u.muted,t.fillText("@mention, width = count",de+24,X),de+=168,t.strokeStyle=u.edge,t.fillStyle=u.edge,t.setLineDash?.([3,3]),t.beginPath(),t.moveTo(de,X),t.lineTo(de+14,X),t.stroke(),t.setLineDash?.([]),xe(t,de+18,X,0,5),t.fillStyle=u.muted,t.fillText("via @all",de+24,X),de+=78,t.strokeStyle=u.border,t.setLineDash?.([2,2]),r(t,de+8,X,16,10,5),t.stroke(),t.setLineDash?.([]),t.fillStyle=u.muted,t.fillText("posted with no mention",de+22,X),D.broadcasts>0&&Q>=60){let K="@all "+D.broadcasts,le=Q-7;r(t,40,le-1,36,14,7),t.fillStyle=u.border,t.fill(),t.fillStyle=u.ink,t.font="600 9.5px ui-monospace, monospace",t.textAlign="center",t.fillText(K,40,le),t.textAlign="left",t.fillStyle=u.muted,t.font='500 10.5px "Segoe UI", system-ui, sans-serif',t.fillText("@all posts, drawn by Expand @all",64,le)}}function we(t,l={}){if(!t)return;let u=l.width??680,v=l.height??460,E=l.theme==="dark"?"dark":"light",j=l.mode==="mentions"?"mentions":"hive",ee=f(E),oe=Me(l.bees);t.save?.(),t.clearRect?.(0,0,u,v),t.fillStyle=ee.bg,t.fillRect(0,0,u,v),j==="mentions"?ge(t,l,ee,oe):Ne(t,l,ee,oe),t.restore?.()}at.HiveGraph=Object.freeze({isPost:d,shouldMergeUserToCoordinator:N,project:k,elapsedSpan:p,unmentionedNode:m,minimumHeight:c,layout:w,nodeBox:z,roundedRectSignedDistance:g,clipEdge:h,routeEdges:W,draw:M,smartTaskLabel:i,mentionsMinimumHeight:b,layoutMentions:P,projectHive:Z,hiveMinimumHeight:L,layoutHive:R,renderGraphFrame:we})})();xt.exports=at.HiveGraph});var St=it((Qo,Mt)=>{var kt={};(()=>{"use strict";let o=[["#efac37","#ffe18d","#bb641d"],["#75baef","#cdefff","#3974bb"],["#55cbb2","#b8f8df","#268c7d"],["#e68db3","#ffcee2","#a24275"],["#b3ce64","#e9f6a1","#6c9137"],["#ad9ce8","#e3d4ff","#6d58af"],["#f09a71","#ffd3b7","#af5833"],["#95cbd1","#defbfa","#4a8d9d"],["#d1a76a","#ffe2a9","#987044"]],n=["#aaafb6","#d6dae0","#848991"];function d(C,y,c){if(y)return o[0];if(Number.isInteger(c))return o[1+Math.abs(c)%(o.length-1)];let w=[...String(C??"")].reduce((x,b)=>x*31+b.charCodeAt(0),0)>>>0;return o[w%o.length]}function p(C){let y=String(C).replace("#",""),c=Number.parseInt(y,16);return[c>>16&255,c>>8&255,c&255]}function m(C,y,c){let[w,x,b]=d(C,y,c),[P,q,z]=p(w),[J,g,T]=p(b),G=Math.round(J*.78),$=Math.round(g*.78),O=Math.round(T*.78),h="#"+[G,$,O].map(W=>W.toString(16).padStart(2,"0")).join("");return{base:w,highlight:x,shade:b,bg:`rgba(${P}, ${q}, ${z}, 0.14)`,border:`rgba(${P}, ${q}, ${z}, 0.42)`,text:h}}function i(C,y,c,w=0,x=0,b=1){C.fillStyle=y;for(let[P,q,z,J]of c)w===0&&x===0&&b===1?C.fillRect(P,q,z,J):C.fillRect(w+P*b,x+q*b,z*b,J*b)}function N(C,y,c,w,{status:x="working",coordinator:b=!1,tint:P,muted:q=!1,scale:z=1}={}){if(!C)return;let[J,g,T]=q?n:d(w,b,P),G=!q&&["waiting","quota","retired","done"].includes(x),$=q?"#727880":"#201915",O=q?"#828a94":"#24313d",h=q?"#ced3d9":"#a9c6db",W=q?"#eef1f4":"#e7f2fa",Z=q?"#767c84":"#2c221c";i(C,$,[[3,2,1,3],[6,3,1,2],[5,1,2,1],[2,3,1,1],[5,5,10,8],[3,7,13,5],[4,12,11,2],[6,14,7,1],[16,9,2,2],[7,14,1,2],[12,14,1,2]],y,c,z),i(C,O,[[7,3,6,4],[8,2,4,6],[12,3,4,4],[13,2,2,1]],y,c,z),i(C,h,[[8,3,3,4],[12,4,3,2],[9,7,2,1]],y,c,z),i(C,W,[[9,3,2,2],[12,4,2,1],[8,4,1,2]],y,c,z),i(C,J,[[4,7,8,5],[5,6,6,7],[12,7,3,5],[13,12,1,1],[6,13,1,1]],y,c,z),i(C,g,[[5,7,3,1],[4,9,2,2],[10,7,2,1],[13,8,1,2],[5,12,2,1]],y,c,z),i(C,T,[[6,12,7,1],[12,11,3,1],[13,12,1,1]],y,c,z),i(C,Z,[[8,6,2,7],[12,7,1,6],[15,9,2,1]],y,c,z),G?(i(C,$,[[4,10,2,1]],y,c,z),i(C,"#d7dcff",b?[[0,0,2,1],[1,1,1,1],[0,2,2,1],[15,0,4,1],[17,1,1,2],[15,3,4,1]]:[[1,1,3,1],[2,2,1,1],[1,3,3,1],[15,0,4,1],[17,1,1,2],[15,3,4,1]],y,c,z)):(i(C,q?"#555b63":"#201915",[[5,8,1,2]],y,c,z),i(C,q?"#e5e8ec":"#fff6d7",[[5,8,1,1]],y,c,z)),b&&(i(C,q?"#727880":"#6d4219",[[2,1,1,4],[8,1,1,4],[2,4,7,1]],y,c,z),i(C,q?"#c7cbd1":"#ffd86b",[[2,0,1,2],[5,0,1,3],[8,0,1,2],[3,2,5,2],[4,1,3,1]],y,c,z),i(C,q?"#9da3ab":"#e7a52f",[[3,4,5,1],[3,3,5,1]],y,c,z),i(C,q?"#eceef1":"#fff3bf",[[3,2,1,1],[7,2,1,1],[5,3,1,1]],y,c,z))}function k(C,{status:y="working",coordinator:c=!1,tint:w,muted:x=!1}={}){let b=document.createElement("canvas");b.className="bee-pixel",b.width=20,b.height=18,b.setAttribute("aria-hidden","true");let P=!x&&["waiting","quota","retired","done"].includes(y);b.dataset.pose=x?"muted":P?"sleeping":"awake",x&&(b.dataset.muted="true");let q=b.getContext("2d");return N(q,0,0,C,{status:y,coordinator:c,tint:w,muted:x,scale:1}),b}kt.HiveBee=Object.freeze({sprite:k,colors:d,tintStyle:m,drawSprite:N})})();Mt.exports=kt.HiveBee});var Ct=it((Zo,Nt)=>{var Ze={};(()=>{"use strict";function o(c){return c||(typeof window<"u"&&window.HiveGraph?window.HiveGraph:Ze.HiveGraph)}function n(c){return c||(typeof window<"u"&&window.HiveBee?window.HiveBee:Ze.HiveBee)}function d(c,w=128){let x=Math.max(2,Math.min(256,w|0)),b=new Map,P=Math.min(c.length,16),q=c.length<=P?1:(c.length-1)/(P-1),z=new Set;for(let ie=0;ie<P;ie++)z.add(Math.round(ie*q));z.add(0),z.add(c.length-1);let J=c[0].rgba,g=J.length>=4&&J[3]>=128?J[0]<<16|J[1]<<8|J[2]:16777215;for(let ie of z){let L=c[ie].rgba,R=-1,a=0;for(let A=0;A+3<L.length;A+=4){let r=L[A+3]<128?g:L[A]<<16|L[A+1]<<8|L[A+2];r===R?a++:(R!==-1&&b.set(R,(b.get(R)??0)+a),R=r,a=1)}R!==-1&&b.set(R,(b.get(R)??0)+a)}let T;if(b.size<=x)T=[...b.keys()];else{let ie=[...b.entries()].sort((M,f)=>f[1]-M[1]),L=Math.min(ie.length,Math.max(2,Math.floor(x*.48)));T=ie.slice(0,L).map(M=>M[0]);let R=new Set(T),a=new Map;for(let M=L;M<ie.length;M++){let[f,te]=ie[M],Y=f>>19&31,Me=f>>11&31,fe=f>>3&31,ae=Y<<10|Me<<5|fe,xe=a.get(ae);xe||(xe={rSum:0,gSum:0,bSum:0,w:0},a.set(ae,xe)),xe.rSum+=(f>>16&255)*te,xe.gSum+=(f>>8&255)*te,xe.bSum+=(f&255)*te,xe.w+=te}let A=[];for(let M of a.values())A.push({r:Math.round(M.rSum/M.w),g:Math.round(M.gSum/M.w),b:Math.round(M.bSum/M.w),w:M.w});let r=x-T.length;if(A.length<=r)for(let M of A){let f=M.r<<16|M.g<<8|M.b;R.has(f)||(R.add(f),T.push(f))}else{let M=te=>{let Y=255,Me=0,fe=255,ae=0,xe=255,Ce=0,Ne=0;for(let u of te)u.r<Y&&(Y=u.r),u.r>Me&&(Me=u.r),u.g<fe&&(fe=u.g),u.g>ae&&(ae=u.g),u.b<xe&&(xe=u.b),u.b>Ce&&(Ce=u.b),Ne+=u.w;let ge=Me-Y,we=ae-fe,t=Ce-xe,l=we>=ge&&we>=t?"g":ge>=t?"r":"b";return{list:te,span:Math.max(ge,we,t),axis:l,totalW:Ne}},f=[M(A)];for(;f.length<r;){let te=-1,Y=-1;for(let Ne=0;Ne<f.length;Ne++){let ge=f[Ne];if(ge.list.length>1&&ge.span>0){let we=ge.span*Math.log2(ge.totalW+2);we>Y&&(Y=we,te=Ne)}}if(te===-1)break;let Me=f.splice(te,1)[0],fe=Me.axis;Me.list.sort((Ne,ge)=>Ne[fe]-ge[fe]);let ae=Me.totalW/2,xe=0,Ce=1;for(let Ne=0;Ne<Me.list.length-1;Ne++)if(xe+=Me.list[Ne].w,xe>=ae){Ce=Ne+1;break}f.push(M(Me.list.slice(0,Ce)),M(Me.list.slice(Ce)))}for(let te of f){let Y=0,Me=0,fe=0,ae=0;for(let we of te.list)Y+=we.r*we.w,Me+=we.g*we.w,fe+=we.b*we.w,ae+=we.w;let xe=Math.round(Y/ae),Ce=Math.round(Me/ae),Ne=Math.round(fe/ae),ge=xe<<16|Ce<<8|Ne;R.has(ge)||(R.add(ge),T.push(ge))}}}T.length||(T=[16777215]);let G=1;for(;1<<G<T.length&&G<8;)G++;let $=1<<G,O=Math.max(2,G),h=G-1,W=new Uint8Array(T.length),Z=new Uint8Array(T.length),re=new Uint8Array(T.length),pe=new Map;for(let ie=0;ie<T.length;ie++){let L=T[ie];W[ie]=L>>16&255,Z[ie]=L>>8&255,re[ie]=L&255,pe.set(L,ie)}return{colors:T,paletteR:W,paletteG:Z,paletteB:re,tableLength:$,minCodeSize:O,tableSizeFlag:h,bgRgb:g,exactLookup:pe}}function p(c,w,x){let{paletteR:b,paletteG:P,paletteB:q,bgRgb:z,exactLookup:J}=x,g=b.length,T=new Uint8Array(w),G=-1,$=0;for(let O=0,h=0;O<w;O++,h+=4){let W=c[h+3]<128?z:c[h]<<16|c[h+1]<<8|c[h+2];if(W===G){T[O]=$;continue}let Z=J.get(W);if(Z===void 0){let re=W>>16&255,pe=W>>8&255,ie=W&255,L=1/0;Z=0;for(let R=0;R<g;R++){let a=re-b[R],A=pe-P[R],r=ie-q[R],M=a*a+A*A+r*r;if(M<L&&(L=M,Z=R,M===0))break}J.size<65536&&J.set(W,Z)}G=W,$=Z,T[O]=Z}return T}class m{constructor(w=32768){this.buf=new Uint8Array(w),this.pos=0}ensure(w){if(this.pos+w<=this.buf.length)return;let x=this.buf.length*2;for(;x<this.pos+w;)x*=2;let b=new Uint8Array(x);b.set(this.buf.subarray(0,this.pos)),this.buf=b}byte(w){this.ensure(1),this.buf[this.pos++]=w&255}u16(w){this.ensure(2),this.buf[this.pos++]=w&255,this.buf[this.pos++]=w>>8&255}bytes(w){this.ensure(w.length),this.buf.set(w,this.pos),this.pos+=w.length}ascii(w){this.ensure(w.length);for(let x=0;x<w.length;x++)this.buf[this.pos++]=w.charCodeAt(x)}finish(){return this.buf.slice(0,this.pos)}}function i(c,w,x){let b=1<<w,P=b+1,q=8192,z=q-1,J=new Int32Array(q).fill(-1),g=new Int16Array(q),T=new Uint8Array(255),G=0,$=0,O=0;function h(){G&&(x.byte(G),x.bytes(T.subarray(0,G)),G=0)}function W(L,R){for($|=L<<O,O+=R;O>=8;)T[G++]=$&255,G===255&&h(),$>>>=8,O-=8}let Z=w+1,re=P+1,pe=1<<Z;if(W(b,Z),!c.length){W(P,Z),O>0&&(T[G++]=$&255),h(),x.byte(0);return}let ie=c[0];for(let L=1;L<c.length;L++){let R=c[L],a=ie<<8|R,A=(ie<<5^R^ie>>>3)&z,r=(ie^R<<3|1)&z,M=!1;for(;J[A]!==-1;){if(J[A]===a){ie=g[A],M=!0;break}A=A+r&z}M||(W(ie,Z),re<4096?(J[A]=a,g[A]=re++,re>pe&&Z<12&&(Z++,pe=1<<Z)):(W(b,Z),J.fill(-1),Z=w+1,re=P+1,pe=1<<Z),ie=R)}W(ie,Z),W(P,Z),O>0&&(T[G++]=$&255,G===255&&h()),h(),x.byte(0)}function N(c,{width:w,height:x,loop:b=0,maxColors:P=128}={}){if(!Array.isArray(c)||!c.length)throw new Error("encodeGif requires at least one frame.");let q=Math.floor(Number(w)),z=Math.floor(Number(x));if(!Number.isFinite(q)||q<=0||q>65535||!Number.isFinite(z)||z<=0||z>65535)throw new Error("encodeGif requires valid width and height (1..65535).");let J=q*z;for(let G=0;G<c.length;G++)if(!c[G]?.rgba||c[G].rgba.length<J*4)throw new Error(`Frame ${G} RGBA buffer is smaller than ${q}x${z}x4 bytes.`);let g=d(c,P),T=new m(Math.max(16384,J));T.ascii("GIF89a"),T.u16(q),T.u16(z),T.byte(240|g.tableSizeFlag),T.byte(0),T.byte(0);for(let G=0;G<g.tableLength;G++)G<g.colors.length?(T.byte(g.paletteR[G]),T.byte(g.paletteG[G]),T.byte(g.paletteB[G])):(T.byte(0),T.byte(0),T.byte(0));if(b!==!1&&b!==null&&b!==void 0){let G=Math.max(0,Math.min(65535,Math.floor(Number(b))));T.byte(33),T.byte(255),T.byte(11),T.ascii("NETSCAPE2.0"),T.byte(3),T.byte(1),T.u16(G),T.byte(0)}for(let G of c){let $=Math.max(1,Math.min(65535,Math.round(G.delayCs??50)));T.byte(33),T.byte(249),T.byte(4),T.byte(4),T.u16($),T.byte(0),T.byte(0),T.byte(44),T.u16(0),T.u16(0),T.u16(q),T.u16(z),T.byte(0),T.byte(g.minCodeSize);let O=p(G.rgba,J,g);i(O,g.minCodeSize,T)}return T.byte(59),T.finish()}function k(c){let w=String(c??"").trim();if(w.startsWith("#")){let b=w.slice(1);if(b.length===3)return[Number.parseInt(b[0]+b[0],16),Number.parseInt(b[1]+b[1],16),Number.parseInt(b[2]+b[2],16),255];if(b.length>=6)return[Number.parseInt(b.slice(0,2),16),Number.parseInt(b.slice(2,4),16),Number.parseInt(b.slice(4,6),16),b.length===8?Number.parseInt(b.slice(6,8),16):255]}let x=/^rgba?\(([^)]+)\)$/i.exec(w);if(x){let b=x[1].split(",").map(P=>Number.parseFloat(P.trim()));return[b[0]||0,b[1]||0,b[2]||0,b.length>=4?Math.round(b[3]*255):255]}return[0,0,0,255]}function C(c,w){let x=new Uint8ClampedArray(c*w*4),b=[],P={fillStyle:"#000000",strokeStyle:"#000000",lineWidth:1,globalAlpha:1},q=[],z=0,J=0,g=0,T=0;function G(h,W,Z){let re=Math.round(h),pe=Math.round(W);if(re<0||re>=c||pe<0||pe>=w)return;let ie=Z[3]/255*P.globalAlpha;if(ie<=0)return;let L=(pe*c+re)*4;if(ie>=.995)x[L]=Z[0],x[L+1]=Z[1],x[L+2]=Z[2],x[L+3]=255;else{let R=1-ie;x[L]=Math.round(x[L]*R+Z[0]*ie),x[L+1]=Math.round(x[L+1]*R+Z[1]*ie),x[L+2]=Math.round(x[L+2]*R+Z[2]*ie),x[L+3]=255}}function $(h,W,Z,re,pe,ie){let L=Math.max(1,Math.ceil(Math.hypot(Z-h,re-W))),R=Math.max(0,Math.floor((ie-1)/2));for(let a=0;a<=L;a++){let A=h+(Z-h)*a/L,r=W+(re-W)*a/L;for(let M=-R;M<=R;M++)for(let f=-R;f<=R;f++)G(A+f,r+M,pe)}}let O={get fillStyle(){return P.fillStyle},set fillStyle(h){P.fillStyle=h},get strokeStyle(){return P.strokeStyle},set strokeStyle(h){P.strokeStyle=h},get lineWidth(){return P.lineWidth},set lineWidth(h){P.lineWidth=h},get globalAlpha(){return P.globalAlpha},set globalAlpha(h){P.globalAlpha=h},font:"",textAlign:"left",textBaseline:"alphabetic",lineCap:"butt",save(){b.push({...P})},restore(){b.length&&(P=b.pop())},setLineDash(){},clearRect(h,W,Z,re){let pe=Math.max(0,Math.floor(h)),ie=Math.max(0,Math.floor(W)),L=Math.min(c,Math.ceil(h+Z)),R=Math.min(w,Math.ceil(W+re));for(let a=ie;a<R;a++)for(let A=pe;A<L;A++){let r=(a*c+A)*4;x[r]=x[r+1]=x[r+2]=x[r+3]=0}},fillRect(h,W,Z,re){let pe=k(P.fillStyle),ie=Math.max(0,Math.floor(h)),L=Math.max(0,Math.floor(W)),R=Math.min(c,Math.ceil(h+Z)),a=Math.min(w,Math.ceil(W+re));for(let A=L;A<a;A++)for(let r=ie;r<R;r++)G(r,A,pe)},beginPath(){q=[]},moveTo(h,W){z=g=h,J=T=W,q.push([{x:h,y:W}])},lineTo(h,W){q.length||q.push([{x:z,y:J}]),q[q.length-1].push({x:h,y:W}),z=h,J=W},quadraticCurveTo(h,W,Z,re){q.length||q.push([{x:z,y:J}]);let pe=q[q.length-1],ie=z,L=J;for(let R=1;R<=12;R++){let a=R/12,A=1-a;pe.push({x:A*A*ie+2*A*a*h+a*a*Z,y:A*A*L+2*A*a*W+a*a*re})}z=Z,J=re},arc(h,W,Z,re,pe){let ie=[];for(let R=0;R<=18;R++){let a=re+(pe-re)*R/18;ie.push({x:h+Z*Math.cos(a),y:W+Z*Math.sin(a)})}q.push(ie),ie.length&&(z=ie.at(-1).x,J=ie.at(-1).y,g=ie[0].x,T=ie[0].y)},closePath(){q.length&&q[q.length-1].length&&(q[q.length-1].push({x:g,y:T}),z=g,J=T)},fill(){let h=k(P.fillStyle);for(let W of q){if(W.length<3)continue;let Z=w,re=0;for(let L of W)L.y<Z&&(Z=L.y),L.y>re&&(re=L.y);let pe=Math.max(0,Math.floor(Z)),ie=Math.min(w-1,Math.ceil(re));for(let L=pe;L<=ie;L++){let R=[];for(let a=0,A=W.length-1;a<W.length;A=a++){let r=W[a],M=W[A];(r.y<=L&&M.y>L||M.y<=L&&r.y>L)&&R.push(r.x+(L-r.y)/(M.y-r.y)*(M.x-r.x))}R.sort((a,A)=>a-A);for(let a=0;a+1<R.length;a+=2){let A=Math.max(0,Math.ceil(R[a])),r=Math.min(c-1,Math.floor(R[a+1]));for(let M=A;M<=r;M++)G(M,L,h)}}}},stroke(){let h=k(P.strokeStyle),W=P.lineWidth||1;for(let Z of q)for(let re=1;re<Z.length;re++)$(Z[re-1].x,Z[re-1].y,Z[re].x,Z[re].y,h,W)},fillText(h,W,Z){let re=String(h??"");if(!re)return;let pe=k(P.fillStyle),ie=Math.min(re.length*5,120),L=P.textAlign==="center"?W-ie/2:P.textAlign==="right"?W-ie:W,R=Z-3;for(let a=Math.max(0,Math.floor(L));a<Math.min(c,Math.ceil(L+ie));a+=2)for(let A=Math.max(0,Math.floor(R));A<Math.min(w,Math.ceil(R+5));A+=2)G(a,A,pe)},drawImage(){},getImageData(h,W,Z,re){return h===0&&W===0&&Z===c&&re===w?{data:new Uint8ClampedArray(x),width:c,height:w}:{data:new Uint8ClampedArray(Z*re*4),width:Z,height:re}}};return{width:c,height:w,getContext:()=>O}}function y({mode:c="hive",posts:w=[],members:x=[],phase:b="done",pacing:P="even",speed:q=1,hideInactive:z=!1,expandBroadcast:J=!1,focus:g=null,theme:T="light",width:G=680,height:$=460,graph:O,bees:h,createCanvas:W,maxFrames:Z=90}={}){let re=o(O),pe=n(h);if(typeof re?.renderGraphFrame!="function")throw new Error("HiveGraph.renderGraphFrame is required to export a graph replay GIF.");let ie=re.isPost??(fe=>fe&&(fe.kind==="brief"||fe.kind==="message"||!fe.kind&&fe.author!=="system")),L=(w??[]).filter(ie).slice().sort((fe,ae)=>(fe.seq??0)-(ae.seq??0)),R=[{seq:0,post:null}],a=Math.max(2,Math.floor(Number(Z)||90));if(L.length>0)if(L.length+1<=a)for(let fe of L)R.push({seq:fe.seq,post:fe});else{let fe=a-1,ae=new Set([0,L.length-1]);for(let xe=1;xe<fe-1;xe++)ae.add(Math.round(xe*(L.length-1)/(fe-1)));for(let xe of[...ae].sort((Ce,Ne)=>Ce-Ne))R.push({seq:L[xe].seq,post:L[xe]})}let r=(W??(typeof document<"u"?(fe,ae)=>{let xe=document.createElement("canvas");return xe.width=fe,xe.height=ae,xe}:C))(G,$);r.width!==G&&(r.width=G),r.height!==$&&(r.height=$);let M=r.getContext("2d");if(!M)throw new Error("Could not obtain 2D canvas context for GIF export.");let f=Math.max(.25,Number(q)||1),te=[];for(let fe=0;fe<R.length;fe++){let ae=R[fe],xe=fe===R.length-1,Ce=fe>0?R[fe-1].post:null,Ne=620;if(P==="real"&&ae.post?.time&&Ce?.time){let l=Date.parse(ae.post.time)-Date.parse(Ce.time);Number.isFinite(l)&&(Ne=Math.max(110,Math.min(l,2e3)))}let ge=Math.round(Ne/f/10),we=xe?Math.max(150,ge):Math.max(4,Math.min(300,ge));re.renderGraphFrame(M,{mode:c,posts:w,members:x,cursor:xe&&L.length?null:ae.seq,phase:xe?b:"working",width:G,height:$,theme:T,hideInactive:z,expandBroadcast:J,focus:g,bees:pe});let t=M.getImageData(0,0,G,$);te.push({rgba:t.data instanceof Uint8ClampedArray?t.data:new Uint8ClampedArray(t.data),delayCs:we})}let Y=N(te,{width:G,height:$,loop:0}),Me=typeof Blob<"u"?new Blob([Y],{type:"image/gif"}):void 0;return{bytes:Y,blob:Me,frameCount:te.length,width:G,height:$}}Ze.HiveGif=Object.freeze({encodeGif:N,exportGraphReplayGif:y})})();Nt.exports=Ze.HiveGif});var $o={};eo($o,{apply:()=>Jo,inject:()=>Uo,name:()=>Ge});module.exports=to($o);var oo={snapshot:"hive-swarm/v1/snapshot",command:"hive-swarm/v1/command",wait:"hive-swarm/v1/events"},Qe="deepseek-harness",rt=o=>(o?.events??[]).reduce((n,d)=>Math.max(n,d.seq),o?.head??0),Fe=o=>({message:typeof o=="string"?o:o?.message??"The Swarm connection is unavailable.",code:typeof o?.code=="string"?o.code:"connection"}),mt=()=>globalThis.crypto.randomUUID(),Le=o=>o?.session?.host===Qe?o.session.id:void 0;function no(o,n){let d=Le(n);return d?n?.executionMode==="subagent"&&typeof o?.parentSessionId=="string"&&o.parentSessionId.trim()?{parentSessionId:o.parentSessionId.trim(),childSessionId:d,mode:"continuable"}:d:(n?.role==="coordinator"||n?.name==="coordinator")&&typeof o?.parentSessionId=="string"&&o.parentSessionId.trim()?o.parentSessionId.trim():null}async function vt(o,n,d,p){if(typeof o?.rpc?.call!="function")throw Error("DSH Connection RPC is unavailable. Enable the Connection capability and reload Hive Swarm.");let m=await o.rpc.call("/api",oo[n],d,p);if(p.aborted)throw p.reason??new DOMException("Cancelled","AbortError");if(!m?.ok){let i=Error(Fe(m?.error).message);throw i.code=m?.error?.code,i}return m.value}async function gt(o,n,d){let{team:p}=await vt(o,"snapshot",{teamId:n},d)??{};if(p?.id!==n||p.host!==Qe||typeof p.cwd!="string"||!p.cwd.trim())throw Error("The Swarm team is unavailable in this Host. Check its workspace and access.");return p}function io(o){return Array.isArray(o)?o.map((n,d)=>{let p=Array.isArray(n.items)?n.items:[],m=Number(n.turn??n.id);return{turn:Number.isSafeInteger(m)&&m>0?m:d+1,status:n.status,steps:n.steps??p.filter(i=>i.type==="activity"),report:n.report??p.findLast(i=>i.type==="agentMessage"&&i.phase==="final")?.text}}):[]}function st(o){return typeof o!="string"||!o?null:(/^(?:[a-z]:[\\/]|\\\\)/i.test(o)?o.replaceAll("\\","/").toLowerCase():o).replace(/\/+$/,"")||"/"}function bt({connection:o,teamId:n=null,sessionId:d=null,workspace:p=null,openSession:m}={}){let i=st(p),N=r=>!i||st(r.cwd)===i,k=n||null,C=0,y=!1,c=0,w=null,x=null,b=null,P=0,q=null,z=!1,J=null,g={teams:[],team:null,selectedId:k,sessionId:d,workspace:p,loading:!1,connection:"idle",error:null,pending:!1,models:[],modelsLoading:!1,journal:null,history:[],hasMoreHistory:!1,historyLoading:!1,version:null,update:null},T=new Set,G=new Set,$=r=>{if(!y){g={...g,...r};for(let M of T)M()}},O=(r,M)=>!y&&C>0&&r===c&&!M.aborted;function h(){c++,w?.abort(),w=null,clearTimeout(J),J=null;for(let r of G)r.abort();G.clear()}let W=(r,M,f)=>vt(o,r,M,f);function Z(r){let M=new Map(g.history.map(f=>[f.seq,f]));for(let f of r)M.set(f.seq,f);return[...M.values()].sort((f,te)=>f.seq-te.seq)}function re(r){if(!r||r.id!==k)throw Error("The Host returned a different team. Select the team again.");if(r.host!==Qe)throw Error("This team does not belong to the native DSH Host.");if(!N(r))throw Error("This team is outside the parent workspace. Choose a team from this workspace.");x??=rt(r),!(g.team&&rt(r)<rt(g.team))&&$({team:r,history:Z(r.events??[])})}async function pe(r,M){let f=await W("snapshot",k?{teamId:k}:{},r);if(!O(M,r))return;if(!Array.isArray(f?.teams))throw Error("The Swarm snapshot is invalid. Refresh to reconnect.");let te=f.teams.filter(Y=>Y.host===Qe&&N(Y));if(k){try{re(f.team)}catch(Y){throw $({teams:te,team:null}),Y}te.some(Y=>Y.id===k)||te.push(f.team)}else $({team:null});$({teams:te,loading:!1,error:g.error?.action?g.error:null,connection:"connected",...typeof f.version=="string"&&f.version.trim()?{version:f.version.trim()}:{},...f.update&&typeof f.update=="object"?{update:f.update}:{}}),f.update?.checked===!1&&!z&&(z=!0,J=setTimeout(()=>{J=null,O(M,r)&&g.update?.checked===!1&&pe(r,M).catch(()=>{})},2500),J.unref?.())}async function ie(r,M){try{for(;k&&O(M,r);){let f=x??0,te=g.team?.revision,Y=await W("wait",{teamId:k,since:f,...te?{revision:te}:{},timeoutSec:50},r);if(!O(M,r))return;if(!Number.isSafeInteger(Y?.head)||Y.head<0)throw Error("The Swarm event cursor is invalid. Refresh to reconnect.");let Me=Array.isArray(Y.posts)?Y.posts:[];if(Y.hasMore){let fe=Me.at(-1)?.seq;if(!Number.isSafeInteger(fe)||fe<=f||fe>Y.head)throw Error("The Swarm history page has an invalid cursor. Refresh to reconnect.");x=fe}else x=Math.max(f,Y.head);Me.length&&$({history:Z(Me)}),!(Y.wokeBy==="timeout"&&x===f&&Y.revision===te&&!Me.length)&&await pe(r,M)}}catch(f){O(M,r)&&$({loading:!1,connection:"disconnected",error:Fe(f)})}}async function L(){if(w?.abort(),w=null,y||!C)return;let r=new AbortController;w=r;let M=c,f=r.signal;$({loading:g.team===null,connection:"connecting",error:g.error?.action?g.error:null});try{await pe(f,M),O(M,f)&&k&&ie(f,M)}catch(te){O(M,f)&&$({loading:!1,connection:"disconnected",error:Fe(te)})}}async function R(r,M={},f=new AbortController){G.add(f);let te=c;try{let Y=await W("command",{action:r,args:k?{...M,teamId:k}:M,requestId:mt()},f.signal);if(y||te!==c)throw new DOMException("Selection changed","AbortError");return Y}finally{G.delete(f)}}async function a(r){if(y||!k||!g.team)throw Error("Select a team before changing it.");if(g.connection!=="connected")throw Error("Refresh the connection before changing the team.");if(g.pending)throw Error("Wait for the current action to finish.");let M=new AbortController;G.add(M);let f=c;$({pending:!0,error:null});try{let te=await W("command",r,M.signal);if(y||f!==c)throw new DOMException("Selection changed","AbortError");return b=null,te?.id?re(te):await pe(w.signal,f),$({pending:!1,error:null}),te}catch(te){if(!y&&f===c){let Y=Fe(te),Me=!Y.code.startsWith("hive-swarm/")||/outcome unconfirmed/i.test(Y.message);b=Me?r:null,$({pending:!1,error:{...Y,action:Me}})}throw te}finally{G.delete(M)}}let A={getSnapshot:()=>g,subscribe:r=>(T.add(r),()=>T.delete(r)),retain(){if(y)return()=>{};C++,C===1&&L();let r=!1;return()=>{r||(r=!0,--C===0&&(h(),$({connection:"idle",loading:!1,pending:!1,modelsLoading:!1,historyLoading:!1,journal:null})))}},async selectTeam(r){h(),k=r||null,x=null,P=0,b=null,$({team:null,selectedId:k,journal:null,history:[],hasMoreHistory:!1,historyLoading:!1,modelsLoading:!1,error:null,pending:!1,loading:!!C}),await L()},refresh:()=>{L()},showTeams:()=>A.selectTeam(null),command(r,M={}){let f={...M,teamId:k},te=b?.action===r&&JSON.stringify(b.args)===JSON.stringify(f);return a(te?b:{action:r,args:f,requestId:mt()})},retryCommand:()=>b?a(b):Promise.reject(Error("There is no action to retry.")),async loadModels(){$({modelsLoading:!0});try{let r=await R("list_models");$({models:r.models??[],modelsLoading:!1})}catch(r){r?.name!=="AbortError"&&$({modelsLoading:!1,error:Fe(r)})}},async openJournal(r){let M=g.team?.members.find(Y=>Y.name===r),f=Le(M);if(!f){$({error:{message:"This member has no owned session yet."}});return}q?.abort();let te=new AbortController;q=te,$({journal:{member:r,loading:!0,turns:[],error:null}});try{let Y=await R("read_journal",{member:r},te);if(Y.threadId&&Y.threadId!==f)throw Error("The member\u2019s session changed. Refresh its Journal to continue.");q===te&&g.journal?.member===r&&$({journal:{...Y,member:r,turns:io(Y.turns),loading:!1}})}catch(Y){Y?.name!=="AbortError"&&q===te&&g.journal?.member===r&&$({journal:{...g.journal,loading:!1,error:Fe(Y)}})}},closeJournal:()=>{q?.abort(),q=null,$({journal:null})},async loadHistory({reset:r=!1}={}){if(!(g.historyLoading||!k)){$({historyLoading:!0});try{let M=r?0:P,f=await R("board_history",{after:M,limit:200}),te=f.posts??f.events??[];P=te.at(-1)?.seq??M,$({history:Z(te),historyLoading:!1,hasMoreHistory:f.hasMore===!0})}catch(M){M?.name!=="AbortError"&&$({historyLoading:!1,error:Fe(M)})}}},async openSession(r,{fallbackToJournal:M=!0}={}){let f=g.team?.members.find(Y=>Y.name===r)??(r==="coordinator"?{name:"coordinator",role:"coordinator"}:void 0),te=no(g.team,f);if(!te)return $({error:{message:"This member has no owned session yet."}}),"none";if(typeof m=="function")try{return await m(te),"session"}catch{return M?(await A.openJournal(r),"journal"):"fallback"}return M?(await A.openJournal(r),"journal"):"fallback"},setError:r=>$({error:Fe(r)}),dispose(){y||(h(),clearTimeout(J),J=null,y=!0,T.clear())}};return A}function yt(o){let n=new Map,d=new Set,p=null,m=(N,k,C)=>{let y=JSON.stringify([N??null,k??null,st(C)]);return n.has(y)||n.set(y,o(N,k,C)),n.get(y)},i=m(null);return{forSession:m,getSnapshot:()=>p??i,subscribe:N=>(d.add(N),()=>d.delete(N)),select(N){p=N;for(let k of d)k()},reconnect(){for(let N of n.values())N.refresh()},dispose(){for(let N of n.values())N.dispose();n.clear(),d.clear()}}}var e=Je(require("react"),1),Te=Je(wt(),1),De=Je(St(),1),Bt=Je(Ct(),1);var Tt=`<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256" role="img" aria-labelledby="title"><title id="title">Hive Swarm crowned bee</title>
|
|
5
5
|
<rect x="2" y="2" width="252" height="252" rx="48" fill="#281d10" stroke="#9a7138" stroke-width="4"/>
|
|
6
6
|
<g transform="translate(28 48) scale(10)" shape-rendering="crispEdges"><rect x="3" y="2" width="1" height="3" fill="#201915"/><rect x="6" y="3" width="1" height="2" fill="#201915"/><rect x="5" y="1" width="2" height="1" fill="#201915"/><rect x="2" y="3" width="1" height="1" fill="#201915"/><rect x="5" y="5" width="10" height="8" fill="#201915"/><rect x="3" y="7" width="13" height="5" fill="#201915"/><rect x="4" y="12" width="11" height="2" fill="#201915"/><rect x="6" y="14" width="7" height="1" fill="#201915"/><rect x="16" y="9" width="2" height="2" fill="#201915"/><rect x="7" y="14" width="1" height="2" fill="#201915"/><rect x="12" y="14" width="1" height="2" fill="#201915"/><rect x="7" y="3" width="6" height="4" fill="#24313d"/><rect x="8" y="2" width="4" height="6" fill="#24313d"/><rect x="12" y="3" width="4" height="4" fill="#24313d"/><rect x="13" y="2" width="2" height="1" fill="#24313d"/><rect x="8" y="3" width="3" height="4" fill="#a9c6db"/><rect x="12" y="4" width="3" height="2" fill="#a9c6db"/><rect x="9" y="7" width="2" height="1" fill="#a9c6db"/><rect x="9" y="3" width="2" height="2" fill="#e7f2fa"/><rect x="12" y="4" width="2" height="1" fill="#e7f2fa"/><rect x="8" y="4" width="1" height="2" fill="#e7f2fa"/><rect x="4" y="7" width="8" height="5" fill="#efac37"/><rect x="5" y="6" width="6" height="7" fill="#efac37"/><rect x="12" y="7" width="3" height="5" fill="#efac37"/><rect x="13" y="12" width="1" height="1" fill="#efac37"/><rect x="6" y="13" width="1" height="1" fill="#efac37"/><rect x="5" y="7" width="3" height="1" fill="#ffe18d"/><rect x="4" y="9" width="2" height="2" fill="#ffe18d"/><rect x="10" y="7" width="2" height="1" fill="#ffe18d"/><rect x="13" y="8" width="1" height="2" fill="#ffe18d"/><rect x="5" y="12" width="2" height="1" fill="#ffe18d"/><rect x="6" y="12" width="7" height="1" fill="#bb641d"/><rect x="12" y="11" width="3" height="1" fill="#bb641d"/><rect x="13" y="12" width="1" height="1" fill="#bb641d"/><rect x="8" y="6" width="2" height="7" fill="#2c221c"/><rect x="12" y="7" width="1" height="6" fill="#2c221c"/><rect x="15" y="9" width="2" height="1" fill="#2c221c"/><rect x="5" y="8" width="1" height="2" fill="#201915"/><rect x="5" y="8" width="1" height="1" fill="#fff6d7"/><rect x="2" y="1" width="1" height="4" fill="#6d4219"/><rect x="8" y="1" width="1" height="4" fill="#6d4219"/><rect x="2" y="4" width="7" height="1" fill="#6d4219"/><rect x="2" y="0" width="1" height="2" fill="#ffd86b"/><rect x="5" y="0" width="1" height="3" fill="#ffd86b"/><rect x="8" y="0" width="1" height="2" fill="#ffd86b"/><rect x="3" y="2" width="5" height="2" fill="#ffd86b"/><rect x="4" y="1" width="3" height="1" fill="#ffd86b"/><rect x="3" y="4" width="5" height="1" fill="#e7a52f"/><rect x="3" y="3" width="5" height="1" fill="#e7a52f"/><rect x="3" y="2" width="1" height="1" fill="#fff3bf"/><rect x="7" y="2" width="1" height="1" fill="#fff3bf"/><rect x="5" y="3" width="1" height="1" fill="#fff3bf"/></g></svg>
|
|
7
|
-
`;var
|
|
7
|
+
`;var qt=`.dsh-hive {
|
|
8
8
|
--hive-surface: var(--dsw-alias-bg-base);
|
|
9
9
|
--hive-layer: var(--dsw-alias-bg-layer-2);
|
|
10
10
|
--hive-card: color-mix(in oklab, var(--hive-layer) 76%, var(--hive-surface));
|
|
@@ -91,8 +91,44 @@ var Ot=Object.create;var $e=Object.defineProperty;var Ut=Object.getOwnPropertyDe
|
|
|
91
91
|
/* Header */
|
|
92
92
|
.dsh-hive-header { padding: 12px 16px 8px; display: grid; gap: 8px; }
|
|
93
93
|
.dsh-hive[data-dsh-hive-swarm="main"] .dsh-hive-header { padding-inline-start: max(20px, var(--dsh-frame-leading-clearance, 0px)); }
|
|
94
|
-
.dsh-hive-header-top { display: flex; align-items:
|
|
95
|
-
.dsh-hive-title-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
|
|
94
|
+
.dsh-hive-header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; min-width: 0; }
|
|
95
|
+
.dsh-hive-title-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; padding-top: 1px; }
|
|
96
|
+
.dsh-hive-header-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; position: relative; }
|
|
97
|
+
.dsh-hive-header-status-row { display: inline-flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
|
|
98
|
+
.dsh-hive-version-tag {
|
|
99
|
+
font-family: var(--hive-mono); font-variant-numeric: tabular-nums; font-size: .78em; font-weight: 580;
|
|
100
|
+
color: var(--hive-muted); padding: 1px 7px; border-radius: 999px;
|
|
101
|
+
border: 1px solid color-mix(in oklab, var(--hive-border) 85%, transparent);
|
|
102
|
+
background: color-mix(in oklab, var(--hive-layer) 75%, transparent);
|
|
103
|
+
white-space: nowrap;
|
|
104
|
+
}
|
|
105
|
+
.dsh-hive-update-wrap { position: relative; display: flex; justify-content: flex-end; }
|
|
106
|
+
.dsh-hive .dsh-hive-update-pill {
|
|
107
|
+
min-height: 22px; padding: 1px 8px; border-radius: 999px; font-size: .76em; font-weight: 620;
|
|
108
|
+
color: var(--hive-gold); background: var(--hive-gold-soft);
|
|
109
|
+
border-color: color-mix(in oklab, var(--hive-gold) 48%, var(--hive-border));
|
|
110
|
+
white-space: nowrap;
|
|
111
|
+
}
|
|
112
|
+
.dsh-hive .dsh-hive-update-pill:hover:not(:disabled) {
|
|
113
|
+
background: color-mix(in oklab, var(--hive-gold) 22%, transparent);
|
|
114
|
+
border-color: var(--hive-gold);
|
|
115
|
+
}
|
|
116
|
+
.dsh-hive-update-popover {
|
|
117
|
+
position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 40;
|
|
118
|
+
width: min(300px, calc(100cqi - 32px)); padding: 10px 12px; border-radius: 10px;
|
|
119
|
+
border: 1px solid var(--hive-border); background: var(--hive-surface);
|
|
120
|
+
box-shadow: 0 12px 28px rgba(0, 0, 0, .28); display: grid; gap: 8px; font-size: .86em;
|
|
121
|
+
}
|
|
122
|
+
.dsh-hive-update-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
|
|
123
|
+
.dsh-hive-update-head .dsh-hive-mono { color: var(--hive-gold); font-weight: 620; }
|
|
124
|
+
.dsh-hive-update-cmd {
|
|
125
|
+
display: block; padding: 6px 8px; border-radius: 7px;
|
|
126
|
+
background: var(--hive-layer); border: 1px solid var(--hive-border);
|
|
127
|
+
font-family: var(--hive-mono); font-size: .88em; color: var(--hive-ink);
|
|
128
|
+
overflow-wrap: anywhere; user-select: all;
|
|
129
|
+
}
|
|
130
|
+
.dsh-hive-update-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
|
|
131
|
+
.dsh-hive-update-actions a { color: var(--hive-gold); font-size: .92em; text-underline-offset: 3px; }
|
|
96
132
|
.dsh-hive-header-status {
|
|
97
133
|
display: inline-flex; align-items: center; gap: 6px;
|
|
98
134
|
font-size: .86em; font-weight: 560; color: var(--hive-muted); white-space: nowrap; flex: none;
|
|
@@ -350,13 +386,61 @@ details[open] > summary .dsh-hive-chevron { rotate: 180deg; }
|
|
|
350
386
|
.dsh-hive-facts dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
|
|
351
387
|
|
|
352
388
|
.dsh-hive-feed, .dsh-hive-members, .dsh-hive-attention, .dsh-hive-journal { list-style: none; margin: 0; padding: 0; }
|
|
353
|
-
.dsh-hive-feed {
|
|
354
|
-
.dsh-hive-
|
|
355
|
-
.dsh-hive-post
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
389
|
+
.dsh-hive-feed-wrap { position: relative; min-width: 0; }
|
|
390
|
+
.dsh-hive-feed { display: grid; gap: 4px; max-height: min(54dvh, 520px); overflow: auto; scrollbar-gutter: stable; overscroll-behavior: contain; padding-inline-end: 2px; }
|
|
391
|
+
.dsh-hive-post {
|
|
392
|
+
padding: 12px 10px; border-radius: 10px;
|
|
393
|
+
display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: start;
|
|
394
|
+
transition: background-color 140ms ease;
|
|
395
|
+
}
|
|
396
|
+
.dsh-hive-post:hover { background: color-mix(in oklab, var(--hive-layer) 55%, transparent); }
|
|
397
|
+
.dsh-hive-post[data-kind="monitor"], .dsh-hive-post[data-kind="checkpoint"] {
|
|
398
|
+
border-inline-start: 3px solid var(--hive-gold); background: var(--hive-gold-soft);
|
|
399
|
+
}
|
|
400
|
+
.dsh-hive-post[data-focused="true"] {
|
|
401
|
+
background: var(--hive-layer); outline: 2px solid var(--hive-gold); outline-offset: -2px;
|
|
402
|
+
}
|
|
403
|
+
.dsh-hive .dsh-hive-post-avatar-btn {
|
|
404
|
+
padding: 0; border: 0; background: transparent; min-height: 0; border-radius: 9px; cursor: pointer;
|
|
405
|
+
}
|
|
406
|
+
.dsh-hive .dsh-hive-post-avatar-btn:hover:not(:disabled) { filter: brightness(1.06); background: transparent; border-color: transparent; }
|
|
407
|
+
.dsh-hive-post-tile {
|
|
408
|
+
width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none;
|
|
409
|
+
background: var(--tile-bg, var(--hive-layer));
|
|
410
|
+
border: 1px solid var(--tile-border, var(--hive-border));
|
|
411
|
+
}
|
|
412
|
+
.dsh-hive-post-tile.dsh-hive-coord-mini {
|
|
413
|
+
background-color: #191c22; border-color: rgb(255 255 255 / 14%);
|
|
414
|
+
background-image: radial-gradient(circle at 50% 42%, rgb(246 188 85 / 18%), transparent 72%);
|
|
415
|
+
}
|
|
416
|
+
.dsh-hive-post-tile.dsh-hive-system-tile { color: var(--hive-muted); font-size: .88em; }
|
|
417
|
+
.dsh-hive-post-main { min-width: 0; display: grid; gap: 5px; }
|
|
418
|
+
.dsh-hive-post-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .9em; }
|
|
419
|
+
.dsh-hive-post-who { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; min-width: 0; }
|
|
420
|
+
.dsh-hive-targets-inline { color: var(--hive-muted); font-size: .9em; overflow-wrap: anywhere; }
|
|
421
|
+
.dsh-hive-channel-pill {
|
|
422
|
+
padding: 0 6px; border-radius: 5px; border: 1px solid var(--hive-border);
|
|
423
|
+
background: var(--hive-layer); color: var(--hive-gold); font-family: var(--hive-mono); font-size: .82em; font-weight: 600;
|
|
424
|
+
}
|
|
425
|
+
.dsh-hive-post-stamp { color: var(--hive-muted); font-size: .82em; white-space: nowrap; margin-inline-start: auto; font-variant-numeric: tabular-nums; }
|
|
426
|
+
.dsh-hive-post-body { min-width: 0; font-size: .94em; color: var(--hive-ink); }
|
|
427
|
+
.dsh-hive-post-body[data-clamped="true"] {
|
|
428
|
+
max-height: 132px; overflow: hidden; cursor: pointer;
|
|
429
|
+
mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
|
|
430
|
+
-webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
|
|
431
|
+
}
|
|
432
|
+
.dsh-hive .dsh-hive-expand-btn {
|
|
433
|
+
justify-self: start; min-height: 0; padding: 1px 0; border: 0; background: transparent;
|
|
434
|
+
color: var(--hive-gold); font-size: .82em; font-weight: 600;
|
|
435
|
+
}
|
|
436
|
+
.dsh-hive .dsh-hive-expand-btn:hover:not(:disabled) { text-decoration: underline; background: transparent; border-color: transparent; }
|
|
437
|
+
.dsh-hive .dsh-hive-latest-pill {
|
|
438
|
+
position: sticky; bottom: 10px; float: right; margin: 4px 8px 4px auto; z-index: 2;
|
|
439
|
+
min-height: 28px; padding: 3px 11px; border-radius: 999px;
|
|
440
|
+
border: 1px solid var(--hive-border); background: var(--hive-surface); color: var(--hive-ink);
|
|
441
|
+
font-size: .84em; font-weight: 600; box-shadow: 0 4px 14px rgb(0 0 0 / 22%);
|
|
442
|
+
}
|
|
443
|
+
.dsh-hive .dsh-hive-latest-pill:hover:not(:disabled) { border-color: var(--hive-gold); }
|
|
360
444
|
|
|
361
445
|
.dsh-hive-attention { display: grid; gap: 8px; }
|
|
362
446
|
.dsh-hive-alert-card { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--hive-border); border-inline-start: 3px solid var(--hive-amber); border-radius: 8px; background: var(--hive-card); }
|
|
@@ -366,19 +450,139 @@ details[open] > summary .dsh-hive-chevron { rotate: 180deg; }
|
|
|
366
450
|
.dsh-hive-live li { display: flex; gap: 8px; flex-wrap: wrap; font-size: .92em; }
|
|
367
451
|
|
|
368
452
|
/* Board & Members */
|
|
369
|
-
.dsh-hive-board { display: grid; gap:
|
|
370
|
-
.dsh-hive-toolbar { display: grid; gap: 10px;
|
|
371
|
-
.dsh-hive-
|
|
372
|
-
.dsh-hive-
|
|
373
|
-
|
|
374
|
-
|
|
453
|
+
.dsh-hive-board { display: grid; gap: 12px; }
|
|
454
|
+
.dsh-hive-toolbar { display: grid; gap: 10px; }
|
|
455
|
+
.dsh-hive-board-bar { display: flex; align-items: center; gap: 8px; }
|
|
456
|
+
.dsh-hive-search-box {
|
|
457
|
+
flex: 1 1 auto; min-width: 0; display: flex !important; align-items: center; gap: 8px;
|
|
458
|
+
padding: 0 11px; min-height: 34px; border-radius: 999px;
|
|
459
|
+
border: 1px solid var(--hive-border); background: var(--hive-layer); color: var(--hive-muted);
|
|
460
|
+
}
|
|
461
|
+
.dsh-hive-search-box:focus-within { border-color: var(--hive-focus); color: var(--hive-ink); }
|
|
462
|
+
.dsh-hive-search-box input {
|
|
463
|
+
flex: 1 1 auto; min-width: 0; width: 100%; border: 0 !important; background: transparent !important;
|
|
464
|
+
padding: 4px 0 !important; min-height: 28px !important; outline: none; font-size: .9em; color: var(--hive-ink);
|
|
465
|
+
}
|
|
466
|
+
.dsh-hive .dsh-hive-filter-btn {
|
|
467
|
+
position: relative; flex: 0 0 auto; width: 34px; height: 34px; min-height: 34px; padding: 0;
|
|
468
|
+
display: inline-grid; place-items: center; border-radius: 10px;
|
|
469
|
+
border: 1px solid transparent; background: transparent; color: var(--hive-muted);
|
|
470
|
+
}
|
|
471
|
+
.dsh-hive .dsh-hive-filter-btn:hover:not(:disabled),
|
|
472
|
+
.dsh-hive .dsh-hive-filter-btn[aria-expanded="true"] {
|
|
473
|
+
background: var(--hive-layer); border-color: var(--hive-border); color: var(--hive-ink);
|
|
474
|
+
}
|
|
475
|
+
.dsh-hive .dsh-hive-filter-btn[data-active="true"]::after {
|
|
476
|
+
content: ""; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px;
|
|
477
|
+
border-radius: 50%; background: var(--hive-gold);
|
|
478
|
+
}
|
|
479
|
+
.dsh-hive-filter-drawer {
|
|
480
|
+
display: grid; gap: 10px; padding: 12px; border: 1px solid var(--hive-border);
|
|
481
|
+
border-radius: 10px; background: var(--hive-layer);
|
|
482
|
+
}
|
|
483
|
+
.dsh-hive-filter-drawer[hidden] { display: none; }
|
|
484
|
+
|
|
485
|
+
.dsh-hive-members-view { display: grid; gap: 12px; }
|
|
486
|
+
.dsh-hive-member-bar { display: flex; align-items: center; gap: 8px; }
|
|
487
|
+
.dsh-hive-members { display: grid; gap: 2px; }
|
|
488
|
+
.dsh-hive-member {
|
|
489
|
+
display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 12px; align-items: start;
|
|
490
|
+
padding: 10px 10px; border-radius: 10px; border: 1px solid transparent; position: relative;
|
|
491
|
+
transition: background-color 140ms ease;
|
|
492
|
+
}
|
|
493
|
+
.dsh-hive-member[data-clickable="true"] { cursor: pointer; }
|
|
494
|
+
.dsh-hive-member:hover { background: var(--hive-layer); }
|
|
495
|
+
.dsh-hive-member[data-menu-open="true"] { z-index: 6; background: var(--hive-layer); }
|
|
375
496
|
.dsh-hive-member[data-status="retired"] { opacity: .76; }
|
|
376
|
-
.dsh-hive-member-
|
|
377
|
-
.dsh-hive-
|
|
497
|
+
.dsh-hive-member-avatar { position: relative; width: 40px; height: 40px; flex: none; margin-top: 1px; }
|
|
498
|
+
.dsh-hive-member-tile {
|
|
499
|
+
width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
|
|
500
|
+
background: var(--tile-bg, var(--hive-layer));
|
|
501
|
+
border: 1px solid var(--tile-border, var(--hive-border));
|
|
502
|
+
}
|
|
503
|
+
.dsh-hive-member-tile.is-coordinator {
|
|
504
|
+
background-color: #191c22; border-color: rgb(255 255 255 / 14%);
|
|
505
|
+
background-image:
|
|
506
|
+
radial-gradient(circle at 50% 42%, rgb(246 188 85 / 18%), transparent 72%),
|
|
507
|
+
linear-gradient(30deg, rgb(255 255 255 / 5%) 12%, transparent 12.5%, transparent 87%, rgb(255 255 255 / 5%) 87.5%);
|
|
508
|
+
background-size: 100% 100%, 14px 24px;
|
|
509
|
+
}
|
|
510
|
+
.dsh-hive-avatar-dot {
|
|
511
|
+
position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%;
|
|
512
|
+
border: 2px solid var(--hive-surface); background: var(--hive-good-fill);
|
|
513
|
+
}
|
|
514
|
+
.dsh-hive-avatar-dot[data-tone="danger"] { background: var(--hive-danger); }
|
|
515
|
+
.dsh-hive-member-main { min-width: 0; display: grid; gap: 4px; }
|
|
516
|
+
.dsh-hive-member-line1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: nowrap; min-width: 0; }
|
|
517
|
+
.dsh-hive-member-ident { display: flex; align-items: baseline; gap: 7px; min-width: 0; flex: 1 1 auto; }
|
|
518
|
+
.dsh-hive-member-ident h2 { font-size: .96em; font-weight: 660; flex: none; color: var(--hive-ink); }
|
|
519
|
+
.dsh-hive-member-sub { font-size: .88em; color: var(--hive-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
|
|
520
|
+
.dsh-hive-member-meta { display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: .82em; color: var(--hive-muted); }
|
|
521
|
+
.dsh-hive-member-model { font-family: var(--hive-mono); font-size: .92em; color: var(--hive-muted); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
522
|
+
.dsh-hive-member-preview {
|
|
523
|
+
font-size: .89em; color: var(--hive-muted); overflow-wrap: anywhere;
|
|
524
|
+
display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-clamp: 2; overflow: hidden;
|
|
525
|
+
}
|
|
526
|
+
.dsh-hive-member-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 1px; }
|
|
527
|
+
.dsh-hive-member-workspace { margin: 0; display: inline-flex; max-width: min(100%, 380px); }
|
|
528
|
+
.dsh-hive-member-workspace > div {
|
|
529
|
+
display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
|
|
530
|
+
padding: 1px 8px; border-radius: 999px; border: 1px solid var(--hive-border);
|
|
531
|
+
background: color-mix(in oklab, var(--hive-layer) 82%, transparent);
|
|
532
|
+
font-family: var(--hive-mono); font-size: .78em; color: var(--hive-muted);
|
|
533
|
+
}
|
|
534
|
+
.dsh-hive-member-workspace dt { display: none; }
|
|
535
|
+
.dsh-hive-member-workspace dd { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
|
|
536
|
+
.dsh-hive-chip {
|
|
537
|
+
display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px;
|
|
538
|
+
border: 1px solid var(--hive-border); background: color-mix(in oklab, var(--hive-layer) 82%, transparent);
|
|
539
|
+
font-size: .78em; color: var(--hive-muted);
|
|
540
|
+
}
|
|
541
|
+
.dsh-hive-chip[data-tone="wait"] { color: var(--hive-wait); border-color: color-mix(in oklab, var(--hive-wait) 36%, var(--hive-border)); }
|
|
542
|
+
.dsh-hive-row-menu { position: relative; flex: none; }
|
|
543
|
+
.dsh-hive .dsh-hive-row-menu-btn {
|
|
544
|
+
min-height: 24px; min-width: 24px; padding: 0 5px; border: 0; background: transparent;
|
|
545
|
+
color: var(--hive-muted); font-size: 1em; line-height: 1; border-radius: 6px; opacity: .48;
|
|
546
|
+
}
|
|
547
|
+
.dsh-hive-member:hover .dsh-hive-row-menu-btn,
|
|
548
|
+
.dsh-hive-member:focus-within .dsh-hive-row-menu-btn,
|
|
549
|
+
.dsh-hive .dsh-hive-row-menu-btn[aria-expanded="true"] { opacity: 1; }
|
|
550
|
+
.dsh-hive .dsh-hive-row-menu-btn:hover:not(:disabled),
|
|
551
|
+
.dsh-hive .dsh-hive-row-menu-btn[aria-expanded="true"] { background: var(--dsw-alias-interactive-bg-hover); color: var(--hive-ink); border-color: transparent; }
|
|
552
|
+
.dsh-hive-row-menu-pop {
|
|
553
|
+
display: none; position: absolute; right: 0; top: calc(100% + 4px); min-width: 162px; z-index: 20;
|
|
554
|
+
padding: 5px; border-radius: 10px; border: 1px solid var(--hive-border); background: var(--hive-surface);
|
|
555
|
+
box-shadow: 0 10px 28px rgb(0 0 0 / 28%);
|
|
556
|
+
}
|
|
557
|
+
.dsh-hive-row-menu-pop[data-open="true"] { display: grid; gap: 2px; }
|
|
558
|
+
.dsh-hive .dsh-hive-menu-item {
|
|
559
|
+
width: 100%; justify-content: flex-start; text-align: left; display: flex; align-items: center;
|
|
560
|
+
min-height: 28px; padding: 4px 9px; border: 0; border-radius: 6px; background: transparent;
|
|
561
|
+
color: var(--hive-ink); font-size: .88em;
|
|
562
|
+
}
|
|
563
|
+
.dsh-hive .dsh-hive-menu-item:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); border-color: transparent; }
|
|
564
|
+
.dsh-hive-menu-brief { padding: 4px 6px 2px; font-size: .84em; }
|
|
565
|
+
.dsh-hive-inline-actions { margin-top: 2px; }
|
|
566
|
+
.dsh-hive-retired-group { margin-top: 6px; border-top: 1px solid var(--hive-border); padding-top: 6px; }
|
|
567
|
+
.dsh-hive-retired-summary {
|
|
568
|
+
list-style: none; display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 8px;
|
|
569
|
+
cursor: pointer; user-select: none; font-size: .78em; font-weight: 680; letter-spacing: .04em; color: var(--hive-muted);
|
|
570
|
+
}
|
|
571
|
+
.dsh-hive-retired-summary .dsh-hive-chevron { margin-left: auto; }
|
|
572
|
+
.dsh-hive-retired-summary::-webkit-details-marker { display: none; }
|
|
573
|
+
.dsh-hive-retired-count { font-family: var(--hive-mono); color: var(--hive-muted); }
|
|
574
|
+
|
|
378
575
|
.dsh-hive-filters { display: flex; gap: 10px 12px; flex-wrap: wrap; align-items: flex-end; }
|
|
379
576
|
.dsh-hive-filters > label { flex: 1 1 130px; }
|
|
380
577
|
.dsh-hive-filters > button { flex: 0 0 auto; align-self: flex-end; }
|
|
381
|
-
.dsh-hive-compose {
|
|
578
|
+
.dsh-hive-compose {
|
|
579
|
+
display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--hive-border);
|
|
580
|
+
border-radius: 12px; background: var(--hive-layer);
|
|
581
|
+
}
|
|
582
|
+
.dsh-hive-compose textarea { min-height: 52px; border: 0 !important; background: transparent !important; padding: 2px 4px !important; resize: vertical; }
|
|
583
|
+
.dsh-hive-compose-foot { justify-content: space-between; align-items: center; }
|
|
584
|
+
.dsh-hive-channel-pick { display: inline-flex !important; flex-direction: row; align-items: center; gap: 6px; font-size: .84em !important; }
|
|
585
|
+
.dsh-hive-channel-pick select { min-height: 26px !important; padding: 2px 6px !important; font-size: .88em !important; }
|
|
382
586
|
.dsh-hive-form { display: grid; gap: 14px; }
|
|
383
587
|
.dsh-hive .dsh-hive-check { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--hive-ink); font-size: .92em; cursor: pointer; }
|
|
384
588
|
.dsh-hive .dsh-hive-check input { min-height: 16px; width: 16px; height: 16px; padding: 0; accent-color: var(--hive-gold); }
|
|
@@ -660,8 +864,8 @@ details[open] > summary .dsh-hive-chevron { rotate: 180deg; }
|
|
|
660
864
|
.dsh-hive-line time { width: 100%; margin: 0; }
|
|
661
865
|
.dsh-hive-team-card { flex-direction: column; }
|
|
662
866
|
}
|
|
663
|
-
`;var
|
|
664
|
-
`),s,w))),m=[]},N=()=>{if(!r)return;let w=l+"-l"+C++,u=r.items.map((x,d)=>e.default.createElement("li",{key:d},Ye(x,s,w+"-"+d)));f.push(r.ordered?e.default.createElement("ol",{key:w,className:"dsh-hive-list",start:r.start},u):e.default.createElement("ul",{key:w,className:"dsh-hive-list"},u)),r=null};for(let w of n.split(/\r?\n/)){let u=/^ {0,3}(#{1,3})\s+(.+)$/.exec(w),x=/^ {0,3}([-*+]|\d+[.)])\s+(.+)$/.exec(w);if(u){M(),N();let d=l+"-h"+C++,b="h"+(2+u[1].length);f.push(e.default.createElement(b,{key:d},Ye(u[2],s,d)))}else if(x){M();let d=/^\d/.test(x[1]);(!r||r.ordered!==d)&&(N(),r={ordered:d,start:d?Number.parseInt(x[1],10):1,items:[]}),r.items.push(x[2])}else N(),w.trim()?m.push(w):M()}return M(),N(),f}function Ge({text:n,onJumpPost:s}){let l=String(n??""),f=[],m=0,r=0,C=/^[ \t]*\x60{3}[^\r\n\x60]*\r?\n([\s\S]*?)^[ \t]*\x60{3}[ \t]*\r?$/gm;for(let N of l.matchAll(C)){let w=l.slice(m,N.index);w.trim()&&f.push(...Ct(w,s,"s"+r++)),f.push(e.default.createElement("pre",{key:"c"+r++,className:"dsh-hive-code"},e.default.createElement("code",null,N[1].replace(/\r?\n$/,"")))),m=N.index+N[0].length}let M=l.slice(m);return(M.trim()||!f.length)&&f.push(...Ct(M,s,"s"+r++)),e.default.createElement("div",{className:"dsh-hive-rich"},f)}function Fe(n,s=140){let l=String(n??"").replace(/\s+/g," ").trim();return l.length>s?l.slice(0,s-1).trimEnd()+"\u2026":l}function Tt(n){if(typeof Ce.default.smartTaskLabel=="function")return Ce.default.smartTaskLabel(n);let s=String(n?.taskLabel??"").trim();if(s)return Fe(s,64);let l=String(n?.brief??"").replace(/[`*_#>\[\]]/g," ").replace(/\s+/g," ").trim();l=l.replace(/^You are\s+(?:@[a-z0-9_-]+\s+)?(?:an?\s+|the\s+)?(?:Hive Swarm\s+)?(?:member|worker|agent|author|verifier|researcher|investigator|auditor|reviewer)?[^.:\n]*?(?:[.:]\s+|\s+—\s+|\s+-\s+)/i,""),l=l.replace(/^(?:Your\s+)?(?:assignment|mission|role|task)(?:\s*\([^)]*\))?\s*[:\-–—]\s*/i,""),l=l.replace(/^You\s+own\s+(?:the\s+)?/i,"");let m=(l.split(/(?<=[.!?])\s+|\s*;\s*|\r?\n/)[0]?.trim()??"").replace(/[.:,;!?]+$/,"").split(/\s+/).filter(Boolean);for(m.length>10&&(m=m.slice(0,10));m.length>2&&/^(?:for|in|on|with|to|of|from|by|at|and|or|the|a|an)$/i.test(m.at(-1));)m.pop();let r=m.join(" ").trim();return Fe(r||n?.name||"Task",64)}function dn(n,s=!1,l){if(typeof We.default.tintStyle=="function")return We.default.tintStyle(n,s,l);let[f,m,r]=We.default.colors(n,s,l);return{base:f,highlight:m,shade:r,bg:"color-mix(in oklab, "+f+" 16%, transparent)",border:"color-mix(in oklab, "+r+" 42%, var(--hive-border))",text:"var(--hive-ink)"}}function zt(n){let s=n?.members??[],f=s.some(r=>r.role==="coordinator"||r.name==="coordinator")?s:[{name:"coordinator",role:"coordinator",status:n?.phase==="done"?"done":"waiting",model:n?.model,effort:n?.effort,brief:n?.task??"Coordinator",waitFor:[]},...s],m=0;return f.map(r=>r.role==="coordinator"||r.name==="coordinator"?{...r,role:"coordinator",tint:0}:{...r,tint:m++})}function Je({member:n,name:s,coordinator:l=!1,tint:f,muted:m=!1,onClick:r,title:C,ariaLabel:M}){let N=s??n?.name??"member",w=dn(N,l,f??n?.tint),u={"--bee-pill-bg":w.bg,"--bee-pill-border":w.border},x=e.default.createElement(e.default.Fragment,null,e.default.createElement(De,{name:N,status:n?.status??"waiting",coordinator:l,tint:f??n?.tint,muted:m,size:"xs"}),e.default.createElement("span",null,N));return r?e.default.createElement("button",{type:"button",className:"dsh-hive-bee-pill",style:u,title:C,"aria-label":M??"Inspect "+N,onClick:r},x):e.default.createElement("span",{className:"dsh-hive-bee-pill","data-static":"true",style:u,title:C},x)}function hn(n,s){let l=(n.members??[]).map(f=>s.find(m=>m.name===f)).filter(Boolean);return l.some(f=>f.recoveryRequired||["failed","quota"].includes(f.status))?{key:"blocked",rank:0}:l.some(f=>f.status==="working")?{key:"active",rank:1}:l.some(f=>f.status==="queued")?{key:"queued",rank:2}:l.some(f=>f.status==="waiting")?{key:"waiting",rank:3}:l.length&&l.every(f=>["done","retired"].includes(f.status))?{key:"done",rank:4}:{key:"queued",rank:2}}function cn(n,s,l){if(n.status==="working"){let r=s?.steps?.findLast(C=>C?.label?.trim())?.label;return Fe(r)||(n.lastTurn?"Working on turn "+n.lastTurn:"Working on the current turn")}if(n.recoveryRequired)return"Outcome unconfirmed. Inspect journal before continuing.";if(["quota","failed"].includes(n.status))return Fe(l?.text)||je[n.status]||n.status;let f=n.pendingWaitFor??n.waitFor;if(f?.length)return Fe("Waiting on "+f.map(r=>"@"+r).join(", "));let m=/\[done\]\s*([^\r?\n]+)/i.exec(l?.text??"");return m?Fe(m[1]):n.status==="waiting"?"Waiting for an @mention":n.status==="queued"?"Queued for the next turn":Fe(l?.text?.split(/\r?\n/)[0])||je[n.status]||n.status}function Re({title:n,onClose:s,opener:l,closeOnBackdrop:f=!1,className:m="dsh-hive-dialog",children:r}){let C=(0,e.useRef)(null),M=(0,e.useRef)(null),N=(0,e.useId)().replace(/[^a-zA-Z0-9_-]/g,"");return(0,e.useLayoutEffect)(()=>{let w=C.current;if(!w)return;typeof w.showModal=="function"?w.showModal():w.setAttribute("open",""),M.current?.focus();let u;if(f&&typeof HTMLDialogElement<"u"&&!("closedBy"in HTMLDialogElement.prototype)){let x=!1,d=v=>{let y=w.getBoundingClientRect();return v.clientX<y.left||v.clientX>y.right||v.clientY<y.top||v.clientY>y.bottom},b=v=>{x=d(v)},H=v=>{x&&d(v)&&s()};w.addEventListener("pointerdown",b),w.addEventListener("pointerup",H),u=()=>{w.removeEventListener("pointerdown",b),w.removeEventListener("pointerup",H)}}return()=>{u?.(),w.open&&typeof w.close=="function"&&w.close(),l?.isConnected&&l.focus()}},[l,f,s]),e.default.createElement("dialog",{ref:C,className:m,"aria-labelledby":N,...f?{closedby:"any"}:{},onCancel:w=>{w.preventDefault(),s()},onKeyDown:w=>{w.key==="Escape"&&(w.preventDefault(),s())}},e.default.createElement("header",{className:"dsh-hive-dialog-head"},e.default.createElement("h2",{id:N},n),e.default.createElement("button",{type:"button",ref:M,"aria-label":"Close "+n,onClick:s},"Close")),r)}function un({step:n}){let s=typeof n=="string"?n:String(n?.label??""),l=typeof n=="object"&&n?.detail?String(n.detail):"",f=/^Verified route:\s*(.+)$/i.exec(s);if(f||typeof n=="object"&&n?.kind==="route"){let m=f?f[1]:s;return e.default.createElement("li",{className:"dsh-hive-route-item"},e.default.createElement("span",{className:"dsh-hive-route-badge"},e.default.createElement("span",{className:"dsh-hive-route-check","aria-hidden":"true"},"\u2713"),"Verified route: ",e.default.createElement("code",null,m)),l?e.default.createElement("span",{className:"dsh-hive-secondary"}," \u2014 ",l):null)}return e.default.createElement("li",null,s,l?" \u2014 "+l:"")}function pn({controller:n,journal:s,opener:l,onClose:f,onJumpPost:m}){let r=C=>{f(),m(C)};return e.default.createElement(Re,{title:"Journal",onClose:f,opener:l,closeOnBackdrop:!0},e.default.createElement("div",{className:"dsh-hive-actions dsh-hive-journal-bar"},e.default.createElement("strong",null,"@",s.member),e.default.createElement("button",{type:"button",disabled:s.loading,onClick:()=>{n.openJournal(s.member)}},"Refresh Journal")),s.loading?e.default.createElement("p",{role:"status"},"Loading Journal\u2026"):s.error?e.default.createElement(Wt,{error:s.error,controller:{...n,refresh:()=>n.openJournal(s.member)}}):s.turns.length?e.default.createElement("ol",{className:"dsh-hive-journal"},s.turns.map((C,M)=>e.default.createElement("li",{key:C.turn??M,className:"dsh-hive-journal-turn"},e.default.createElement("div",{className:"dsh-hive-line"},e.default.createElement("h3",null,"Turn ",C.turn??M+1),e.default.createElement(Ze,{value:C.status})),C.steps?.length?e.default.createElement("ul",{className:"dsh-hive-journal-steps"},C.steps.map((N,w)=>e.default.createElement(un,{key:w,step:N}))):null,C.report?e.default.createElement(Ge,{text:C.report,onJumpPost:r}):e.default.createElement("p",{className:"dsh-hive-secondary"},"No report saved for this turn.")))):e.default.createElement("p",null,"No saved turns yet. Live work appears here after the Host records it."),s.live?.steps?.length?e.default.createElement("section",{className:"dsh-hive-live"},e.default.createElement("h3",null,"Current activity"),e.default.createElement("ul",null,s.live.steps.map((C,M)=>e.default.createElement("li",{key:M},typeof C=="string"?C:C.label)))):null)}function Qe({memberName:n,pending:s,controller:l}){return e.default.createElement(e.default.Fragment,null,e.default.createElement("button",{type:"button",disabled:s,"aria-label":"Retry fresh turn for @"+n,onClick:()=>ze(l,"resolve_recovery",{member:n,action:"retry"})},"Retry fresh turn"),e.default.createElement("button",{type:"button",disabled:s,"aria-label":"Dismiss unconfirmed run for @"+n,onClick:()=>ze(l,"resolve_recovery",{member:n,action:"dismiss"})},"Dismiss"))}function qt({className:n,defaultOpen:s=!1,summary:l,children:f}){let[m,r]=(0,e.useState)(s);return e.default.createElement("details",{className:n,open:m},e.default.createElement("summary",{className:n==="dsh-hive-task-card"?"dsh-hive-task-summary":"dsh-hive-thread-head",onClick:C=>{C.preventDefault(),r(M=>!M)}},l),f)}function fn({state:n,controller:s,onJournal:l,onJumpPost:f,onMention:m}){let r=n.team,C=n.history.length?n.history:r.events??[],M=(0,e.useMemo)(()=>zt(r),[r]),N=(0,e.useMemo)(()=>new Map(M.map(o=>[o.name,o])),[M]),w=(0,e.useMemo)(()=>{let o=new Map;for(let h of C)h.kind!=="brief"&&h.author!=="system"&&o.set(h.author,h);return o},[C]),u=r.members.filter(o=>o.role!=="coordinator"&&o.name!=="coordinator"&&o.status!=="retired"),x=u.filter(o=>o.status==="done").length,d=u.length>0&&x===u.length,b=r.task?.trim()??"",H=r.goalLine?.trim()??"",v=b.length>140||/\n/.test(b),y=r.members.filter(o=>o.recoveryRequired||["quota","failed"].includes(o.status)),U=(r.attention??[]).filter(o=>["stalled","budget"].includes(r.phase)||["recovery","input","quota","failed","dependency","cycle"].includes(o.kind)),j=U.length>0||y.length>0||r.phase==="budget"||r.phase==="stalled",k=(0,e.useMemo)(()=>M.filter(o=>o.role!=="coordinator"&&o.name!=="coordinator"&&o.status!=="retired").map(o=>({member:o,latest:w.get(o.name)})).sort((o,h)=>(h.latest?.seq??0)-(o.latest?.seq??0)),[M,w]),G=(0,e.useMemo)(()=>(r.threads?.length?r.threads:u.length?[{id:"tasks",title:"Tasks",members:u.map(h=>h.name)}]:[]).map(h=>({thread:h,state:hn(h,r.members)})).sort((h,g)=>h.state.rank-g.state.rank),[r.threads,r.members,u]),ce=(0,e.useMemo)(()=>(r.screenshots??[]).map((o,h)=>{let g=ln(o?.url);return g?{...o,id:o.id??o.seq+":"+h,url:g}:null}).filter(Boolean),[r.screenshots]),[O,R]=(0,e.useState)(null),Y=M.find(o=>o.role==="coordinator"||o.name==="coordinator"),S=r.members.some(o=>o.role==="coordinator"||o.name==="coordinator"),ee=(0,e.useMemo)(()=>C.findLast(o=>o.author==="coordinator"&&o.kind!=="brief")??C.findLast(o=>o.author==="user"&&o.kind!=="brief"&&/\[done\]/i.test(o.text??""))??(S?void 0:C.findLast(o=>o.author==="user"&&o.kind!=="brief")),[C,S]),se=ee?.text?.trim()??"",te=se?Fe(se.replace(/^\[done\]\s*/i,""),180):"",W=se.length>180||/\n/.test(se),Q=(o,h)=>{if(Pe(o)){l(o.name,h);return}let g=w.get(o.name);g?f(g.seq):o.status!=="retired"&&!o.retireAfterTurn&&m(o.name)};return e.default.createElement("div",{className:"dsh-hive-overview"},H?e.default.createElement("p",{className:"dsh-hive-goal-line"},H):!v&&b&&b!==r.title?e.default.createElement("p",{className:"dsh-hive-goal-line"},b):null,v?e.default.createElement("details",{className:"dsh-hive-details dsh-hive-brief-disclosure"},e.default.createElement("summary",null,"Full brief"),e.default.createElement(Ge,{text:b,onJumpPost:f})):null,e.default.createElement(qt,{className:"dsh-hive-task-card",defaultOpen:!1,summary:e.default.createElement(e.default.Fragment,null,e.default.createElement(st,{status:y.length?"failed":d?"done":"working",recovery:y.some(o=>o.recoveryRequired)}),e.default.createElement("span",{className:"dsh-hive-task-count"},e.default.createElement("strong",null,x," of ",u.length)," tasks done"),e.default.createElement("span",{className:"dsh-hive-task-turns"},"Turns ",r.turns,"/",r.turnLimit),e.default.createElement(Nt,null))},e.default.createElement("div",{className:"dsh-hive-task-body"},k.length?e.default.createElement("ul",{className:"dsh-hive-task-list"},k.map(({member:o,latest:h})=>{let g=cn(o,r.activity?.[o.name],h),q=o.status==="retired";return e.default.createElement("li",{key:o.name,className:"dsh-hive-task-row"},e.default.createElement(st,{status:o.status,recovery:o.recoveryRequired}),e.default.createElement("div",{className:"dsh-hive-task-main"},e.default.createElement("div",{className:"dsh-hive-task-title"},Tt(o)),e.default.createElement("div",{className:"dsh-hive-task-sub"},g),o.recoveryRequired?e.default.createElement("div",{className:"dsh-hive-actions dsh-hive-inline-actions"},e.default.createElement(Qe,{memberName:o.name,pending:n.pending||o.status==="working",controller:s})):null),e.default.createElement(Je,{member:o,muted:q,title:Pe(o)?"Inspect @"+o.name+" Journal":"View @"+o.name,ariaLabel:(Pe(o)?"Inspect journal for @":"Jump to @")+o.name,onClick:K=>Q(o,K.currentTarget)}))})):e.default.createElement("p",{className:"dsh-hive-secondary dsh-hive-task-empty"},"No worker tasks assigned yet."))),j?e.default.createElement("section",{className:"dsh-hive-section"},e.default.createElement("h2",null,"Needs you"),e.default.createElement("ul",{className:"dsh-hive-attention"},U.map((o,h)=>{let g=r.members.find(q=>q.name===o.member);return e.default.createElement("li",{key:"a-"+h,className:"dsh-hive-alert-card","data-kind":o.kind},e.default.createElement("p",null,o.text??o.message??o.kind),e.default.createElement("div",{className:"dsh-hive-actions"},o.seq?e.default.createElement(Ee,{seq:o.seq,onJumpPost:f}):null,o.kind==="budget"?e.default.createElement("button",{type:"button",disabled:n.pending,onClick:()=>ze(s,"resume_team",{extraTurns:8})},"Add 8 turns and resume"):null,Pe(g)?e.default.createElement("button",{type:"button",onClick:q=>l(o.member,q.currentTarget)},"Inspect @",o.member):null,g?.recoveryRequired?e.default.createElement(Qe,{memberName:g.name,pending:n.pending||g.status==="working",controller:s}):null))}),y.filter(o=>!U.some(h=>h.member===o.name)).map(o=>e.default.createElement("li",{key:o.name,className:"dsh-hive-alert-card","data-kind":o.recoveryRequired?"recovery":o.status},e.default.createElement("p",null,"@",o.name,": ",o.recoveryRequired?"Outcome unconfirmed. Inspect the owned session before continuing.":o.status==="quota"?"Model quota reached. Choose an available model before resuming.":"The last turn failed. Inspect the Journal for recovery details."),e.default.createElement("div",{className:"dsh-hive-actions"},Pe(o)?e.default.createElement("button",{type:"button",onClick:h=>l(o.name,h.currentTarget)},"Inspect Journal"):null,o.recoveryRequired?e.default.createElement(Qe,{memberName:o.name,pending:n.pending||o.status==="working",controller:s}):null))),r.phase==="budget"&&!U.some(o=>o.kind==="budget")?e.default.createElement("li",{key:"budget-alert",className:"dsh-hive-alert-card","data-kind":"budget"},e.default.createElement("p",null,"Turn limit reached (",r.turns,"/",r.turnLimit,"). Add 8 turns to continue."),e.default.createElement("div",{className:"dsh-hive-actions"},e.default.createElement("button",{type:"button",disabled:n.pending,onClick:()=>ze(s,"resume_team",{extraTurns:8})},"Add 8 turns and resume"))):null)):null,G.length?e.default.createElement("section",{className:"dsh-hive-section"},e.default.createElement("h2",null,"Threads"),e.default.createElement("div",{className:"dsh-hive-threads"},G.map(({thread:o,state:h})=>{let g=(o.members??[]).map(fe=>N.get(fe)??{name:fe,status:"queued",brief:o.goal??fe}),q=g.length,K=g.filter(fe=>["done","retired"].includes(fe.status)).length,ye=G.length===1||["blocked","active","done"].includes(h.key);return e.default.createElement(qt,{key:o.id??o.title,className:"dsh-hive-thread-card",defaultOpen:ye,summary:e.default.createElement(e.default.Fragment,null,e.default.createElement("span",{className:"dsh-hive-thread-left"},e.default.createElement("span",{className:"dsh-hive-thread-dot","data-status":h.key,"aria-hidden":"true"}),e.default.createElement("strong",{className:"dsh-hive-thread-title"},o.title),e.default.createElement("span",{className:"dsh-hive-thread-state"},Bt[h.key]??h.key)),e.default.createElement("span",{className:"dsh-hive-thread-right"},e.default.createElement("progress",{className:"dsh-hive-mini-progress",max:Math.max(q,1),value:K,"aria-label":o.title+" progress"}),e.default.createElement("span",{className:"dsh-hive-thread-ratio"},K,"/",q),e.default.createElement(Nt,null)))},e.default.createElement("div",{className:"dsh-hive-thread-body"},o.goal?e.default.createElement("p",{className:"dsh-hive-thread-goal"},o.goal):null,g.length?e.default.createElement("ul",{className:"dsh-hive-thread-rows"},g.map(fe=>e.default.createElement("li",{key:fe.name,className:"dsh-hive-thread-task"},e.default.createElement(st,{status:fe.status,recovery:fe.recoveryRequired}),e.default.createElement("span",{className:"dsh-hive-thread-task-title"},Tt(fe)),e.default.createElement(Je,{member:fe,muted:fe.status==="retired",ariaLabel:(Pe(fe)?"Inspect journal for @":"Jump to @")+fe.name,onClick:Se=>Q(fe,Se.currentTarget)})))):e.default.createElement("p",{className:"dsh-hive-secondary"},"No members assigned to this thread.")))}))):null,ce.length?e.default.createElement("section",{className:"dsh-hive-section"},e.default.createElement("h2",null,"Screenshots"),e.default.createElement("ul",{className:"dsh-hive-screenshots-strip"},ce.map(o=>{let h=N.get(o.author);return e.default.createElement("li",{key:o.id,className:"dsh-hive-shot-card"},e.default.createElement("button",{type:"button",className:"dsh-hive-shot-thumb","aria-label":"Preview screenshot: "+o.caption,onClick:g=>R({shot:o,opener:g.currentTarget})},e.default.createElement("img",{src:o.url,alt:o.caption,loading:"lazy"})),e.default.createElement("div",{className:"dsh-hive-shot-meta"},e.default.createElement("p",{className:"dsh-hive-shot-caption"},o.caption),e.default.createElement("div",{className:"dsh-hive-shot-foot"},o.seq?e.default.createElement(Ee,{seq:o.seq,onJumpPost:f}):null,o.author?e.default.createElement(Je,{member:h,name:o.author,coordinator:o.author==="coordinator",onClick:h?g=>Q(h,g.currentTarget):void 0}):null)))}))):null,e.default.createElement("section",{className:"dsh-hive-section"},e.default.createElement("h2",null,"The team"),e.default.createElement("div",{className:"dsh-hive-team-card"},e.default.createElement("div",{className:"dsh-hive-coordinator-tile","aria-hidden":"true"},e.default.createElement(De,{name:"coordinator",status:"working",coordinator:!0,size:"lg"})),e.default.createElement("div",{className:"dsh-hive-team-body"},e.default.createElement("div",{className:"dsh-hive-line"},e.default.createElement("strong",{className:"dsh-hive-team-name"},"Coordinator"),e.default.createElement("div",{className:"dsh-hive-pill-group"},ee?.seq?e.default.createElement(Ee,{seq:ee.seq,onJumpPost:f}):null,Pe(Y)?e.default.createElement("button",{type:"button",className:"dsh-hive-ghost-btn",onClick:o=>l(Y.name,o.currentTarget)},"Journal"):null)),e.default.createElement("p",{className:"dsh-hive-team-summary"},te||(b?Fe(b,180):"Coordinating team progress.")),W?e.default.createElement("details",{className:"dsh-hive-details"},e.default.createElement("summary",null,"Full summary"),e.default.createElement(Ge,{text:se,onJumpPost:f})):null,e.default.createElement("details",{className:"dsh-hive-details dsh-hive-exec"},e.default.createElement("summary",null,"Execution"),e.default.createElement("dl",{className:"dsh-hive-facts"},e.default.createElement("div",null,e.default.createElement("dt",null,"Turns"),e.default.createElement("dd",null,r.turns," of ",r.turnLimit," used")),e.default.createElement("div",null,e.default.createElement("dt",null,"Members"),e.default.createElement("dd",null,r.members.filter(o=>o.status!=="retired").length," active \xB7 ",r.members.filter(o=>o.status==="working").length," working")),e.default.createElement("div",null,e.default.createElement("dt",null,"Model"),e.default.createElement("dd",null,r.model??"Host default",r.effort?" \xB7 "+r.effort:"")),r.fallbackModel?e.default.createElement("div",null,e.default.createElement("dt",null,"Fallback"),e.default.createElement("dd",null,r.fallbackModel,r.fallbackEffort?" \xB7 "+r.fallbackEffort:"")):null,e.default.createElement("div",null,e.default.createElement("dt",null,"Workspace"),e.default.createElement("dd",null,r.cwd)))),r.phase==="budget"?e.default.createElement("div",{className:"dsh-hive-actions"},e.default.createElement("button",{type:"button",className:"dsh-hive-primary",disabled:n.pending,onClick:()=>ze(s,"resume_team",{extraTurns:8})},"+8 turns")):null))),O?e.default.createElement(Re,{title:O.shot.caption||"Screenshot",opener:O.opener,closeOnBackdrop:!0,className:"dsh-hive-dialog dsh-hive-lightbox",onClose:()=>R(null)},e.default.createElement("figure",{className:"dsh-hive-lightbox-figure"},e.default.createElement("img",{src:O.shot.url,alt:O.shot.caption,className:"dsh-hive-lightbox-img"}),e.default.createElement("figcaption",{className:"dsh-hive-lightbox-meta"},e.default.createElement("span",null,O.shot.caption),e.default.createElement("div",{className:"dsh-hive-actions"},O.shot.seq?e.default.createElement(Ee,{seq:O.shot.seq,onJumpPost:o=>{R(null),f(o)}}):null,O.shot.author?e.default.createElement(Je,{member:N.get(O.shot.author),name:O.shot.author,coordinator:O.shot.author==="coordinator"}):null,O.shot.time?e.default.createElement("time",{className:"dsh-hive-secondary dsh-hive-mono",dateTime:O.shot.time},new Date(O.shot.time).toLocaleString()):null)))):null)}function mn({event:n,onJumpPost:s,focused:l=!1}){return e.default.createElement("li",{className:"dsh-hive-post","data-seq":n.seq,"data-kind":n.kind??"message","data-focused":l?"true":void 0},e.default.createElement("div",{className:"dsh-hive-line"},e.default.createElement("strong",{className:"dsh-hive-author"},n.author==="system"?"System":"@"+n.author),n.targets?.length?e.default.createElement("span",{className:"dsh-hive-targets"},"\u2192 "+n.targets.map(f=>"@"+f).join(" ")):null,e.default.createElement("span",{className:"dsh-hive-secondary dsh-hive-mono"},"#",n.seq," \xB7 ",n.channel??"main"),n.time?e.default.createElement("time",{dateTime:n.time},new Date(n.time).toLocaleString()):null),e.default.createElement(Ge,{text:n.text,onJumpPost:s}))}function vn({state:n,controller:s,focusedSeq:l,onClearFocus:f,mentionRequest:m,onConsumeMention:r,onJumpPost:C}){let[M,N]=(0,e.useState)(""),[w,u]=(0,e.useState)("*"),[x,d]=(0,e.useState)("*"),[b,H]=(0,e.useState)(""),[v,y]=(0,e.useState)("main"),[U,j]=(0,e.useState)(!0),k=(0,e.useRef)(null),G=(0,e.useRef)(null);(0,e.useEffect)(()=>{if(!m?.name)return;let S="@"+m.name;H(ee=>new RegExp("(?:^|[^a-z0-9_])@"+m.name+"(?![a-z0-9_-])","i").test(ee)?ee:S+" "+ee),G.current?.focus?.(),r?.()},[m,r]);let ce=(0,e.useMemo)(()=>{let S=new Set(["user","coordinator"]),ee=[];for(let se of n.team.members)se?.name&&!S.has(se.name)&&(S.add(se.name),ee.push({value:se.name,label:se.name}));for(let se of n.history)se?.author&&se.author!=="system"&&!S.has(se.author)&&(S.add(se.author),ee.push({value:se.author,label:se.author}));return[{value:"*",label:"Everyone"},{value:"user",label:"You (user)"},{value:"coordinator",label:"Coordinator"},...ee]},[n.team.members,n.history]),O=n.history.filter(S=>(w==="*"||(S.channel??"main")===w)&&(x==="*"||S.author===x)&&(!M||S.text?.toLowerCase().includes(M.toLowerCase())));(0,e.useEffect)(()=>{if(l==null)return;!O.some(ee=>ee.seq===l)&&n.history.some(ee=>ee.seq===l)&&(N(""),u("*"),d("*")),j(!1),k.current?.querySelector?.('[data-seq="'+l+'"]')?.scrollIntoView?.({block:"nearest"})},[l,n.history.length,O.length]),(0,e.useEffect)(()=>{U&&k.current&&(k.current.scrollTop=k.current.scrollHeight)},[U,O.length]);let R=n.team.members.filter(S=>S.status==="working");async function Y(S){if(S.preventDefault(),!!b.trim())try{await s.command("post_message",{text:b.trim(),channel:v}),H(""),f?.()}catch{}}return e.default.createElement("div",{className:"dsh-hive-board"},R.length?e.default.createElement("section",{className:"dsh-hive-live","aria-label":"Live activity"},e.default.createElement("h3",null,"Live activity"),e.default.createElement("ul",null,R.map(S=>{let se=n.team.activity?.[S.name]?.steps?.at(-1);return e.default.createElement("li",{key:S.name},e.default.createElement("strong",null,"@",S.name),e.default.createElement("span",null,se?se.label+(se.detail?" \xB7 "+se.detail:""):"Working\u2026"))}))):null,e.default.createElement("div",{className:"dsh-hive-toolbar"},e.default.createElement("div",{className:"dsh-hive-filters"},e.default.createElement("label",null,"Search board",e.default.createElement("input",{type:"search",value:M,onChange:S=>N(S.target.value)})),e.default.createElement("label",null,"Channel",e.default.createElement("select",{value:w,onChange:S=>u(S.target.value)},e.default.createElement("option",{value:"*"},"All channels"),n.team.channels.filter(S=>!S.archived).map(S=>e.default.createElement("option",{key:S.name},S.name)))),e.default.createElement("label",null,"Author",e.default.createElement("select",{"aria-label":"Author",value:x,onChange:S=>d(S.target.value)},ce.map(S=>e.default.createElement("option",{key:S.value,value:S.value},S.label)))),e.default.createElement("button",{type:"button","aria-pressed":U,onClick:()=>j(S=>!S)},"Follow")),e.default.createElement("div",{className:"dsh-hive-actions"},e.default.createElement("button",{type:"button",disabled:n.historyLoading,onClick:()=>{s.loadHistory({reset:!0})}},"Load earlier history"),n.hasMoreHistory?e.default.createElement("button",{type:"button",disabled:n.historyLoading,onClick:()=>{s.loadHistory()}},"Load next history page"):null,n.historyLoading?e.default.createElement("span",{role:"status",className:"dsh-hive-secondary"},"Loading history\u2026"):null)),O.length?e.default.createElement("ol",{ref:k,className:"dsh-hive-feed","aria-label":"Board posts"},O.map(S=>e.default.createElement(mn,{key:S.seq,event:S,onJumpPost:C,focused:l===S.seq}))):e.default.createElement("p",{role:"status",className:"dsh-hive-secondary"},"No posts match these filters."),e.default.createElement("form",{className:"dsh-hive-compose",onSubmit:Y},e.default.createElement("label",null,"Post to the board",e.default.createElement("textarea",{ref:G,required:!0,rows:"3",maxLength:"6000",value:b,onChange:S=>H(S.target.value),placeholder:"Share direction or unblock a member\u2026"})),e.default.createElement("div",{className:"dsh-hive-actions"},e.default.createElement("label",null,"Post channel",e.default.createElement("select",{value:v,onChange:S=>y(S.target.value)},n.team.channels.filter(S=>!S.archived).map(S=>e.default.createElement("option",{key:S.name},S.name)))),e.default.createElement("button",{type:"submit",className:"dsh-hive-primary",disabled:n.pending||!b.trim()},"Post message"))))}function gn({state:n,controller:s,member:l,opener:f,onClose:m}){let[r,C]=(0,e.useState)(""),[M,N]=(0,e.useState)(""),[w,u]=(0,e.useState)(!1),[x,d]=(0,e.useState)(l?.model??""),[b,H]=(0,e.useState)(l?.effort??""),[v,y]=(0,e.useState)(!1);(0,e.useEffect)(()=>{s.loadModels()},[s]);let U=n.models.find(O=>O.id===x),j=!x||!!U,k=!b||!!U?.efforts?.includes(b),G=!!(l&&["waiting","failed","quota"].includes(l.status)&&!l.recoveryRequired);async function ce(O){O.preventDefault();try{l?await s.command("set_member_model",{member:l.name,model:x,effort:b||null,resume:!!(G&&v)}):await s.command("add_member",{member:{name:r,brief:M,writable:w,...x?{model:x}:{},...b?{effort:b}:{}}}),m()}catch{}}return e.default.createElement(Re,{title:l?"Change model":"Add member",onClose:m,opener:f},e.default.createElement("form",{onSubmit:ce,className:"dsh-hive-form"},l?e.default.createElement("p",null,"Apply to the next turn for @",l.name,"."):e.default.createElement(e.default.Fragment,null,e.default.createElement("label",null,"Member name",e.default.createElement("input",{required:!0,pattern:"[a-z][a-z0-9_\\-]*",maxLength:"30",value:r,onChange:O=>C(O.target.value)})),e.default.createElement("label",null,"Assignment",e.default.createElement("textarea",{required:!0,rows:"4",maxLength:"6000",value:M,onChange:O=>N(O.target.value)})),e.default.createElement("label",{className:"dsh-hive-check"},e.default.createElement("input",{type:"checkbox",checked:w,onChange:O=>u(O.target.checked)}),"Request workspace write access"),e.default.createElement("p",{className:"dsh-hive-secondary"},"The Host verifies workspace scope and permission before execution.")),e.default.createElement("label",null,"Model",e.default.createElement("select",{value:x,disabled:n.modelsLoading,onChange:O=>{d(O.target.value),H("")}},e.default.createElement("option",{value:""},l?"Choose a model":"Use the team model"),x&&!U?e.default.createElement("option",{value:x},x," (unavailable)"):null,n.models.map(O=>e.default.createElement("option",{key:O.id,value:O.id},O.label)))),n.modelsLoading?e.default.createElement("p",{role:"status"},"Loading native models\u2026"):n.models.length?null:e.default.createElement("p",null,"No models are available. Enable a model in DSH, then reload the model list."),j?null:e.default.createElement("p",{role:"alert"},"This model is unavailable. Choose a model from the native catalog."),e.default.createElement("label",null,"Reasoning effort",e.default.createElement("select",{value:b,disabled:!U,onChange:O=>H(O.target.value)},e.default.createElement("option",{value:""},"Model default"),U?.efforts?.map(O=>e.default.createElement("option",{key:O},O)))),G?e.default.createElement("label",{className:"dsh-hive-check"},e.default.createElement("input",{type:"checkbox",checked:v,onChange:O=>y(O.target.checked)}),"Resume now"):null,n.error?e.default.createElement("p",{role:"alert"},n.error.message):null,e.default.createElement("div",{className:"dsh-hive-actions"},e.default.createElement("button",{type:"button",disabled:n.modelsLoading,onClick:()=>{s.loadModels()}},"Reload models"),e.default.createElement("button",{type:"submit",className:"dsh-hive-primary",disabled:n.pending||!j||!k||l&&!x||!l&&(!r||!M.trim())},n.pending?"Saving\u2026":l?"Apply model":"Add member"))))}function bn({workspace:n}){let s=[n?.cwd,n?.path,n].find(l=>typeof l=="string"&&l.trim());return s?e.default.createElement("div",null,e.default.createElement("dt",null,"Workspace"),e.default.createElement("dd",null,s)):null}function yn({state:n,controller:s,onJournal:l,onOpenSession:f,onMention:m}){let[r,C]=(0,e.useState)(""),[M,N]=(0,e.useState)(null),[w,u]=(0,e.useState)(null),x=n.team.members.filter(d=>d.name.toLowerCase().includes(r.toLowerCase()));return e.default.createElement("div",{className:"dsh-hive-members-view"},e.default.createElement("div",{className:"dsh-hive-actions dsh-hive-member-bar"},e.default.createElement("label",null,"Find a member",e.default.createElement("input",{type:"search",value:r,onChange:d=>C(d.target.value)})),e.default.createElement("button",{type:"button",disabled:n.pending,onClick:d=>N({member:null,opener:d.currentTarget})},"Add member")),x.length?e.default.createElement("ul",{className:"dsh-hive-members"},x.map(d=>{let b=d.brief?.trim()??"",H=b.length>220||/\n/.test(b),v=d.role==="coordinator"||d.name==="coordinator";return e.default.createElement("li",{key:d.name,className:"dsh-hive-member","data-role":v?"coordinator":"worker","data-status":d.status},e.default.createElement("div",{className:"dsh-hive-line dsh-hive-member-head"},e.default.createElement(De,{name:d.name,status:d.status,coordinator:v}),e.default.createElement("h2",null,"@",d.name),e.default.createElement("div",{className:"dsh-hive-pill-group"},e.default.createElement(sn,{mode:d.executionMode,subagentName:d.subagentName}),e.default.createElement(Ze,{value:d.status}))),H?e.default.createElement(e.default.Fragment,null,e.default.createElement("p",{className:"dsh-hive-prose"},Fe(b,200)),e.default.createElement("details",{className:"dsh-hive-details"},e.default.createElement("summary",null,"Full brief"),e.default.createElement("p",{className:"dsh-hive-prose"},b))):e.default.createElement("p",{className:"dsh-hive-prose"},d.brief),e.default.createElement("dl",{className:"dsh-hive-facts"},e.default.createElement("div",null,e.default.createElement("dt",null,"Model"),e.default.createElement("dd",null,d.model,d.effort?" \xB7 "+d.effort:"")),d.fallbackModel?e.default.createElement("div",null,e.default.createElement("dt",null,"Fallback"),e.default.createElement("dd",null,d.fallbackModel,d.fallbackEffort?" \xB7 "+d.fallbackEffort:"")):null,e.default.createElement("div",null,e.default.createElement("dt",null,"Permission"),e.default.createElement("dd",null,d.writable?"Workspace write requested":"Read only")),e.default.createElement(bn,{workspace:d.workspace}),d.group?e.default.createElement("div",null,e.default.createElement("dt",null,"Group"),e.default.createElement("dd",null,"@",d.group)):null,d.channels?.length?e.default.createElement("div",null,e.default.createElement("dt",null,"Channels"),e.default.createElement("dd",null,d.channels.map(y=>"#"+y).join(", "))):null,d.pendingWaitFor?.length?e.default.createElement("div",null,e.default.createElement("dt",null,"Waiting for"),e.default.createElement("dd",null,d.pendingWaitFor.map(y=>"@"+y).join(", "))):null),d.recoveryRequired?e.default.createElement("p",{role:"status",className:"dsh-hive-recovery-note"},"Outcome unconfirmed. Inspect the owned session before continuing."):null,n.team.activity?.[d.name]?.steps?.length?e.default.createElement("p",{className:"dsh-hive-secondary"},n.team.activity[d.name].steps.at(-1).label):null,e.default.createElement("div",{className:"dsh-hive-actions"},e.default.createElement("button",{type:"button","aria-label":"Journal for "+d.name,disabled:!Pe(d),onClick:y=>l(d.name,y.currentTarget)},"Journal"),e.default.createElement("button",{type:"button","aria-label":"Open session for @"+d.name,disabled:!Pe(d),onClick:y=>f(d.name,y.currentTarget)},"Open session"),d.status!=="retired"&&!d.retireAfterTurn?e.default.createElement("button",{type:"button","aria-label":"@mention @"+d.name+" on board",onClick:()=>m(d.name)},"@mention"):null,e.default.createElement("button",{type:"button","aria-label":"Change model for @"+d.name,disabled:n.pending||d.status==="working"||d.status==="retired",onClick:y=>N({member:d,opener:y.currentTarget})},"Change model"),e.default.createElement("button",{type:"button","aria-label":"Retire @"+d.name,disabled:n.pending||d.status==="retired"||d.retireAfterTurn,onClick:y=>u({member:d,opener:y.currentTarget})},d.retireAfterTurn?"Retiring after turn":"Retire"),d.recoveryRequired?e.default.createElement(Qe,{memberName:d.name,pending:n.pending||d.status==="working",controller:s}):null,d.workspace&&(d.status==="retired"||n.team.phase==="done")?e.default.createElement("button",{type:"button",disabled:n.pending,"aria-label":"Clean worktree for @"+d.name,onClick:()=>ze(s,"remove_worktree",{member:d.name})},"Clean worktree"):null))})):e.default.createElement("p",{className:"dsh-hive-secondary"},"No members match your search."),M?e.default.createElement(gn,{key:M.member?.name??"new",...M,state:n,controller:s,onClose:()=>N(null)}):null,w?e.default.createElement(Re,{title:"Retire "+w.member.name+"?",opener:w.opener,onClose:()=>u(null)},e.default.createElement("p",null,"This member will receive no further turns. Its Journal and session remain available."),n.error?e.default.createElement("p",{role:"alert"},n.error.message):null,e.default.createElement("button",{type:"button",disabled:n.pending,onClick:async()=>{try{await s.command("retire_member",{member:w.member.name}),u(null)}catch{}}},"Retire member")):null)}function xn(){try{let n=globalThis.sessionStorage?.getItem?.(Ft);return n==="mentions"||n==="hive"?n:"hive"}catch{return"hive"}}function wn(n){try{globalThis.sessionStorage?.setItem?.(Ft,n)}catch{}}function kn(n){let s=typeof document<"u"?document.documentElement?.dataset?.theme:void 0;if(s==="dark"||s==="light")return s;try{if(n&&typeof getComputedStyle=="function"){let l=getComputedStyle(n),f=l.colorScheme;if(f==="dark"||f==="light")return f;let m=/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/.exec(l.backgroundColor??"");if(m)return .299*Number(m[1])+.587*Number(m[2])+.114*Number(m[3])<128?"dark":"light"}}catch{}try{if(globalThis.matchMedia?.("(prefers-color-scheme: dark)")?.matches)return"dark"}catch{}return"light"}function Mn(n,s){let l=Math.cos(s),f=Math.sin(s),m=(r,C)=>(n.x+r*l-C*f).toFixed(1)+","+(n.y+r*f+C*l).toFixed(1);return m(1,0)+" "+m(-8,-3.8)+" "+m(-6.1,0)+" "+m(-8,3.8)}function Sn(n,s,l){let f=n.filter(v=>v.seq<=l&&Ce.default.isPost(v)),m=f.at(-1)??null,r=l>=(n.at(-1)?.seq??0),C=s.find(v=>v.role==="coordinator"||v.name==="coordinator")??{name:"coordinator",role:"coordinator",status:"waiting"},M=s.filter(v=>v.role!=="coordinator"&&v.name!=="coordinator"),N=new Map;for(let v of f)N.set(v.author,v.seq);let w=[{id:"working",label:"Working",tone:"working",members:[]},{id:"waiting",label:"Waiting",tone:"waiting",members:[]},{id:"needs",label:"Needs you",tone:"needs",members:[]},{id:"done",label:"Done",tone:"done",members:[]}],u=new Map(w.map(v=>[v.id,v]));for(let v of M){let y=r?v.status:N.has(v.name)&&v.status==="done"?"done":"waiting",U=v.recoveryRequired||["failed","quota"].includes(y)?"needs":y==="working"?"working":["done","retired"].includes(y)?"done":"waiting";u.get(U).members.push({name:v.name,status:y,role:v.role??"worker",tint:v.tint,muted:["done","retired"].includes(y),latestSeq:N.get(v.name)??0,pendingWaitFor:v.pendingWaitFor??[]})}let x=w.filter(v=>v.members.length>0).map(v=>({...v,count:v.members.length})),d=u.get("done").members.length,b=u.get("needs").members.length?"stalled":u.get("working").members.length?"working":M.length&&d===M.length?"done":"waiting",H=[];if(u.get("done").members.length&&H.push({from:"done",to:"coordinator",kind:"done",label:"Tasks done"}),m){let v=m.author==="coordinator"?"coordinator":x.find(U=>U.members.some(j=>j.name===m.author))?.id,y=[...m.targets??[],...m.coordinatorMention?["coordinator"]:[]];for(let U of y){let j=U==="coordinator"?"coordinator":x.find(k=>k.members.some(G=>G.name===U))?.id;if(v&&j&&v!==j){H.push({from:v,to:j,kind:"message",label:"Message just sent",seq:m.seq});break}}}for(let v of x)for(let y of v.members)for(let U of y.pendingWaitFor??[]){let j=x.find(k=>k.members.some(G=>G.name===U))?.id;j&&j!==v.id&&!H.some(k=>k.kind==="waiting"&&k.from===v.id&&k.to===j)&&H.push({from:v.id,to:j,kind:"waiting",label:"Waiting on"})}return{currentSeq:m?.seq??0,lastPost:m,coordinator:{name:"coordinator",status:C.status,role:"coordinator",doneCount:d,totalWorkers:M.length,phase:b,latestSeq:N.get("coordinator")??0,tint:0},clusters:x,connectors:H}}function rt(n,s,l){return Array.from({length:6},(f,m)=>({x:n+l*Math.cos(m*Math.PI/3),y:s+l*Math.sin(m*Math.PI/3)}))}function It(n,s,l,f){if(!f.length)return[];let m=f.length,r=m<=2?m:m<=6?3:4,C=Math.ceil(m/r),M=l*1.48,N=Math.min(72,Math.max(46,M/r)),w=C===1?0:C===2?46:38,u=s-(C-1)*w/2+14;return f.map((x,d)=>{let b=Math.floor(d/r),H=Math.min(r,m-b*r),v=d%r,y=n+(v-(H-1)/2)*N,U=u+b*w;return{member:x,x:y,y:U,slotWidth:N,beeScale:C>=3?.9:1}})}function Nn(n,s,l){let f=n.clusters??[],m=18,r=new Map,C,M,N=[];if(!f.length)C=Math.max(76,Math.min(118,s*.24,l*.32)),M={x:s/2,y:l/2};else if(f.length===1){C=Math.max(76,Math.min(120,s*.24,(l-36)/(2*Math.sqrt(3)+.35)));let u=C*Math.sqrt(3)/2,x=l/2,d=u+m/2,b=f[0],H={x:s/2,y:x-d};M={x:s/2,y:x+d};let v={...b,x:H.x,y:H.y,radius:C,vertices:rt(H.x,H.y,C),slots:It(H.x,H.y,C,b.members)};N.push(v),r.set(b.id,v)}else{M={x:s/2,y:l*.7};let u=f.length===2?Math.PI*.44:f.length===3?Math.PI*.64:Math.PI*.74,x=u/(f.length-1),d=Math.max(110,Math.min(s*.34,M.y-82)),b=Math.min(d,2*d*Math.sin(x/2)),H=Math.max(46,(b-m)/2);C=Math.max(54,Math.min(92,H/(Math.sqrt(3)/2))),f.forEach((v,y)=>{let U=-Math.PI/2-u/2+y*x,j=M.x+Math.cos(U)*d,k=M.y+Math.sin(U)*d,G={...v,x:j,y:k,radius:C,vertices:rt(j,k,C),slots:It(j,k,C,v.members)};N.push(G),r.set(v.id,G)})}let w={id:"coordinator",x:M.x,y:M.y,radius:C,vertices:rt(M.x,M.y,C),model:n.coordinator};return r.set("coordinator",w),{width:s,height:l,radius:C,coordinator:w,clusters:N,cellsById:r}}function Pt(n,s){let l=n*Math.sqrt(3)/2,f=1/0;for(let m of[Math.PI/6,Math.PI/2,5*Math.PI/6,-Math.PI/6,-Math.PI/2,-5*Math.PI/6]){let r=Math.cos(s-m);r>1e-4&&(f=Math.min(f,l/r))}return f}function Cn(n,s,l){let f=new Map;if(!n.length)return f;if(n.length>12||s<300)return Ce.default.layout(n,s,l);let m=n.findIndex(b=>b.role==="coordinator"||b.name==="coordinator"),r=m>=0?[n[m],...n.filter((b,H)=>H!==m)]:n,C=42,M=42,N=Math.min(92,Math.max(58,s*.14)),w=s/2,u=(C+(l-M))/2,x=Math.max(56,Math.min(s*.38,s/2-N)),d=Math.max(46,(l-C-M)/2);return r.length===1?(f.set(r[0].name,{x:w,y:u}),f):(r.forEach((b,H)=>{let v=-Math.PI/2+H*(Math.PI*2/r.length);f.set(b.name,{x:w+Math.cos(v)*x,y:u+Math.sin(v)*d})}),f)}function Tn(n,s){if(typeof Ce.default.nodeBox=="function"){let r=Ce.default.nodeBox(n,{variant:"pill",narrow:s});if(r&&r.radius>=r.halfH-1)return r}let l=String(n?.name??""),f=s?14:16;return{halfW:Math.max(44,Math.min(96,24+l.length*4.1)),halfH:f,offsetX:0,offsetY:0,radius:f}}function qn({state:n,controller:s,onJournal:l,onJumpPost:f}){let[m,r]=(0,e.useState)(xn),[C,M]=(0,e.useState)(null),[N,w]=(0,e.useState)(!1),[u,x]=(0,e.useState)("even"),[d,b]=(0,e.useState)(1),[H,v]=(0,e.useState)(!1),[y,U]=(0,e.useState)(!1),[j,k]=(0,e.useState)(null),[G,ce]=(0,e.useState)(null),[O,R]=(0,e.useState)(null),[Y,S]=(0,e.useState)({busy:!1,message:"",error:!1}),ee=(0,e.useRef)(null),se=(0,e.useRef)(null),te=(0,e.useRef)(new Map),[W,Q]=(0,e.useState)(480),o=(0,e.useId)().replaceAll(":","");(0,e.useEffect)(()=>{let i=se.current;if(!i||typeof ResizeObserver>"u")return;let L=new ResizeObserver(T=>Q(Math.max(280,T[0].contentRect.width)));return L.observe(i),()=>L.disconnect()},[]);let h=(0,e.useMemo)(()=>zt(n.team),[n.team]),g=(0,e.useMemo)(()=>n.history.filter(Ce.default.isPost),[n.history]),q=C===null?g.length:Math.max(0,Math.min(g.length,g.findIndex(i=>i.seq>C)===-1?g.length:g.findIndex(i=>i.seq>C))),K=g[q-1],ye=K?.seq??0;(0,e.useEffect)(()=>{if(!N)return;if(q>=g.length){w(!1);return}let i=Date.parse(g[q].time)-Date.parse(g[q-1]?.time),L=u==="real"&&Number.isFinite(i)?Math.max(110,Math.min(i,2e3)):620,T=setTimeout(()=>{M(g[q].seq)},L/d);return()=>clearTimeout(T)},[N,q,g,u,d]);let fe=i=>{w(!1),M(g[i-1]?.seq??0)},Se=()=>{if(N){w(!1);return}g.length&&((C===null||q>=g.length)&&M(0),w(!0))},ve=i=>{i!==m&&(r(i),wn(i),k(null),ce(null))},ge=W<440,be=Ce.default.elapsedSpan(g.slice(0,q),{live:C===null&&["working","queued"].includes(n.team.phase)}),Ne=(0,e.useMemo)(()=>m!=="hive"?null:typeof Ce.default.projectHive=="function"?Ce.default.projectHive(g,h,ye):Sn(g,h,ye),[m,g,h,ye]),we=(0,e.useMemo)(()=>{if(m!=="hive"||!Ne)return 420;let i=typeof Ce.default.hiveMinimumHeight=="function"?Ce.default.hiveMinimumHeight(Ne.clusters.length,W):Ne.clusters.length<=1?400:440;return Math.max(380,i)},[m,Ne,W]),me=(0,e.useMemo)(()=>m!=="hive"||!Ne?null:typeof Ce.default.layoutHive=="function"?Ce.default.layoutHive(Ne,W,we):Nn(Ne,W,we),[m,Ne,W,we]),t=(0,e.useMemo)(()=>Ce.default.project(g,h,ye,{hideInactive:H,expandBroadcast:y}),[g,h,ye,H,y]),a=(0,e.useMemo)(()=>typeof Ce.default.mentionsMinimumHeight=="function"?Math.max(380,Ce.default.mentionsMinimumHeight(t.nodes.length,W)):Math.max(380,Ce.default.minimumHeight(t.nodes.length,W)),[t.nodes.length,W]),p=(0,e.useMemo)(()=>m!=="mentions"?new Map:typeof Ce.default.layoutMentions=="function"?Ce.default.layoutMentions(t.nodes,W,a):Cn(t.nodes,W,a),[m,t.nodes,W,a]);tn(()=>{if(m!=="mentions")return;let i=new Map,L=!1;for(let T of t.nodes){let B=te.current.get(T.name);if(B&&B.offsetWidth>0&&B.offsetHeight>0){let V=B.offsetHeight/2,A={halfW:B.offsetWidth/2,halfH:V,offsetX:0,offsetY:0,radius:V};i.set(T.name,A);let I=O?.get(T.name);(!I||Math.abs(I.halfW-A.halfW)>.5||Math.abs(I.halfH-A.halfH)>.5)&&(L=!0)}}i.size&&(L||!O||O.size!==i.size)&&R(i)},[m,t.nodes,W,ge]);let c=(0,e.useMemo)(()=>{if(m!=="mentions")return null;if(O&&O.size===t.nodes.length)return O;let i=new Map;for(let L of t.nodes)i.set(L.name,O?.get(L.name)??Tn(L,ge));return i},[m,t.nodes,O,ge]),E=(0,e.useMemo)(()=>m!=="mentions"?[]:Ce.default.routeEdges(t,p,{variant:"pill",boxes:c,narrow:ge,marginStart:5,marginEnd:6,obstacleMargin:ge?14:22}),[m,t,p,c,ge]),z=G?G.split(">"):null,J=(0,e.useMemo)(()=>{if(z)return new Set(z);if(!j)return null;let i=new Set([j]);for(let L of t.links)L.from===j&&i.add(L.to),L.to===j&&i.add(L.from);return i},[j,G,t.links]),ne=m==="hive"?we:a,F=j?h.find(i=>i.name===j):null;async function oe(){if(!g.length||Y.busy)return;let i=(typeof globalThis.HiveGif?.exportGraphReplayGif=="function"?globalThis.HiveGif:null)??Lt.default;if(typeof i?.exportGraphReplayGif!="function"){S({busy:!1,message:"GIF export is unavailable until the GIF module is bundled.",error:!0});return}S({busy:!0,message:"Rendering GIF replay\u2026",error:!1});try{let L=kn(ee.current),T=await Promise.resolve(i.exportGraphReplayGif({mode:m,posts:g,members:h,phase:n.team.phase,pacing:u,speed:d,hideInactive:H,expandBroadcast:y,focus:j,theme:L,width:Math.max(480,Math.round(W)),height:Math.max(360,Math.round(ne)),graph:Ce.default,bees:We.default})),B=typeof Blob<"u"&&T?.blob instanceof Blob?T.blob:T?.bytes&&typeof Blob<"u"?new Blob([T.bytes],{type:"image/gif"}):null;if(!B&&!T?.bytes)throw Error("GIF encoder returned empty data.");let A=((n.team.title||"hive-swarm").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"hive-swarm")+"-graph.gif";if(B&&typeof URL.createObjectURL=="function"&&typeof document<"u"&&typeof document.createElement=="function"){let I=URL.createObjectURL(B),P=document.createElement("a");P.href=I,P.download=A,P.style.display="none",document.body?.appendChild?.(P),P.click?.(),P.remove?.(),setTimeout(()=>{try{URL.revokeObjectURL(I)}catch{}},1e3)}S({busy:!1,message:"Exported "+A+(T.frameCount?" ("+T.frameCount+" frames)":"")+".",error:!1})}catch(L){S({busy:!1,message:"GIF export failed: "+(L?.message??String(L)),error:!0})}}let D=i=>i==="done"?"done":i==="working"||i==="active"?"working":i==="needs"||i==="stalled"||i==="blocked"?"needs":"waiting";return e.default.createElement("div",{ref:ee,className:"dsh-hive-graph-view"},e.default.createElement("div",{className:"dsh-hive-graph-controls"},e.default.createElement("div",{className:"dsh-hive-replay-row1"},e.default.createElement("div",{className:"dsh-hive-actions dsh-hive-transport"},e.default.createElement("button",{type:"button","aria-label":"First post",disabled:!g.length||q===1,onClick:()=>fe(1)},"|\u2039"),e.default.createElement("button",{type:"button","aria-label":"Previous post",disabled:q===0,onClick:()=>fe(Math.max(0,q-1))},"\u2039"),e.default.createElement("button",{type:"button","aria-label":N?"Pause replay":"Replay",disabled:!g.length,onClick:Se},N?"\u2161":"\u25B6"),e.default.createElement("button",{type:"button","aria-label":"Next post",disabled:q>=g.length,onClick:()=>fe(q+1)},"\u203A")),e.default.createElement("input",{className:"dsh-hive-scrubber","aria-label":"Replay through post",type:"range",min:"0",max:g.length,value:q,onChange:i=>fe(Number(i.target.value))}),e.default.createElement("button",{type:"button",className:"dsh-hive-live-btn","aria-pressed":C===null,onClick:()=>{w(!1),M(null)}},e.default.createElement("span",{className:"dsh-hive-status-dot","aria-hidden":"true"}),"Live")),e.default.createElement("div",{className:"dsh-hive-replay-row2"},e.default.createElement("span",{className:"dsh-hive-graph-stat"},e.default.createElement("strong",null,g.length," posts")," over ",be,C!==null?" \xB7 "+q+"/"+g.length:""),e.default.createElement("div",{className:"dsh-hive-segmented",role:"group","aria-label":"Graph view mode"},e.default.createElement("button",{type:"button","aria-pressed":m==="hive",onClick:()=>ve("hive")},"Hive"),e.default.createElement("button",{type:"button","aria-pressed":m==="mentions",onClick:()=>ve("mentions")},"Mentions")),e.default.createElement("div",{className:"dsh-hive-graph-options"},e.default.createElement("label",{className:"dsh-hive-inline-select"},e.default.createElement("span",{className:"dsh-hive-sr-only"},"Pacing"),e.default.createElement("select",{"aria-label":"Pacing",value:u,onChange:i=>x(i.target.value)},e.default.createElement("option",{value:"even"},"Even pacing"),e.default.createElement("option",{value:"real"},"Real-time"))),e.default.createElement("label",{className:"dsh-hive-inline-select"},e.default.createElement("span",{className:"dsh-hive-sr-only"},"Speed"),e.default.createElement("select",{"aria-label":"Speed",value:d,onChange:i=>b(Number(i.target.value))},e.default.createElement("option",{value:"0.5"},"0.5\xD7"),e.default.createElement("option",{value:"1"},"1\xD7"),e.default.createElement("option",{value:"2"},"2\xD7"),e.default.createElement("option",{value:"4"},"4\xD7"))),m==="mentions"?e.default.createElement("div",{className:"dsh-hive-graph-toggles"},e.default.createElement("label",{className:"dsh-hive-switch"},e.default.createElement("input",{type:"checkbox",role:"switch",className:"dsh-hive-switch-input",checked:H,onChange:i=>v(i.target.checked)}),e.default.createElement("span",{className:"dsh-hive-switch-track","aria-hidden":"true"}),e.default.createElement("span",null,"Hide inactive")),e.default.createElement("label",{className:"dsh-hive-switch"},e.default.createElement("input",{type:"checkbox",role:"switch",className:"dsh-hive-switch-input",checked:y,onChange:i=>U(i.target.checked)}),e.default.createElement("span",{className:"dsh-hive-switch-track","aria-hidden":"true"}),e.default.createElement("span",null,"Expand @all"))):null,e.default.createElement("button",{type:"button",className:"dsh-hive-export-gif",disabled:!g.length||Y.busy,onClick:()=>{oe()}},e.default.createElement("span",{"aria-hidden":"true"},"\u2B07"),Y.busy?"Exporting\u2026":"Export GIF"),n.hasMoreHistory?e.default.createElement("button",{type:"button",className:"dsh-hive-ghost-btn",disabled:n.historyLoading,onClick:()=>{s.loadHistory()}},"Load earlier"):null)),Y.message?e.default.createElement("p",{role:"status",className:Y.error?"dsh-hive-gif-error":"dsh-hive-secondary"},Y.message):null),m==="hive"&&me?e.default.createElement(e.default.Fragment,null,e.default.createElement("div",{ref:se,className:"dsh-hive-graph dsh-hive-graph-hive",style:{height:we},role:"group","aria-label":"Hive cluster graph"},e.default.createElement("svg",{width:"100%",height:we,viewBox:"0 0 "+W+" "+we,"aria-hidden":"true"},e.default.createElement("defs",null,e.default.createElement("marker",{id:o,markerUnits:"userSpaceOnUse",markerWidth:"10",markerHeight:"10",refX:"8.5",refY:"5",orient:"auto"},e.default.createElement("path",{d:"M0.5 1.2L9.5 5L0.5 8.8L2.4 5Z",fill:"context-stroke"}))),me.clusters.map(i=>e.default.createElement("g",{key:i.id,className:"dsh-hive-hex-cell","data-tone":D(i.tone)},e.default.createElement("polygon",{points:i.vertices.map(L=>L.x.toFixed(1)+","+L.y.toFixed(1)).join(" "),className:"dsh-hive-hex-poly"}),e.default.createElement("text",{x:i.x,y:i.y-i.radius*.56,textAnchor:"middle",className:"dsh-hive-hex-title"},i.label),e.default.createElement("text",{x:i.x,y:i.y-i.radius*.41,textAnchor:"middle",className:"dsh-hive-hex-count"},i.count))),e.default.createElement("g",{className:"dsh-hive-hex-cell","data-role":"coordinator","data-tone":D(me.coordinator.model.phase==="done"?"done":me.coordinator.model.phase==="stalled"?"needs":"working")},e.default.createElement("polygon",{points:me.coordinator.vertices.map(i=>i.x.toFixed(1)+","+i.y.toFixed(1)).join(" "),className:"dsh-hive-hex-poly"}),e.default.createElement("text",{x:me.coordinator.x,y:me.coordinator.y+me.coordinator.radius*.34,textAnchor:"middle",className:"dsh-hive-hex-title"},"Coordinator"),e.default.createElement("text",{x:me.coordinator.x,y:me.coordinator.y+me.coordinator.radius*.5,textAnchor:"middle",className:"dsh-hive-hex-count"},me.coordinator.model.doneCount," of ",me.coordinator.model.totalWorkers," done")),(Ne?.connectors??[]).map((i,L)=>{let T=pe=>me.cellsById?.get?.(pe)??me.cellsById?.[pe]??(pe==="coordinator"?me.coordinator:me.clusters.find(ke=>ke.id===pe)),B=T(i.from),V=T(i.to);if(!B||!V||B===V)return null;let A=V.x-B.x,I=V.y-B.y,P=Math.hypot(A,I);if(P<2)return null;let $=Math.atan2(I,A),le=i.kind==="message"?8:i.kind==="waiting"?-8:0,Z=le?6:3,re=Pt(B.radius,$)+Z,X=Pt(V.radius,$+Math.PI)+Z;if(re+X>=P)return null;let de=-Math.sin($),ae=Math.cos($),ue=B.x+Math.cos($)*re+de*le,_=B.y+Math.sin($)*re+ae*le,ie=V.x-Math.cos($)*X+de*le,he=V.y-Math.sin($)*X+ae*le;return e.default.createElement("line",{key:i.from+">"+i.to+":"+i.kind+":"+L,x1:ue.toFixed(1),y1:_.toFixed(1),x2:ie.toFixed(1),y2:he.toFixed(1),className:"dsh-hive-hex-connector","data-kind":i.kind,strokeDasharray:i.kind==="waiting"?"4 4":void 0,markerEnd:i.kind==="waiting"?"url(#"+o+")":void 0})})),me.clusters.flatMap(i=>i.slots.map(L=>{let T=L.member,B=j===T.name;return e.default.createElement("button",{key:T.name,type:"button",className:"dsh-hive-hex-bee-btn","data-status":T.status,"aria-pressed":B,style:{left:L.x/W*100+"%",top:L.y,maxWidth:L.slotWidth},title:"@"+T.name+" \xB7 "+(je[T.status]??T.status),"aria-label":"Inspect @"+T.name+" ("+(je[T.status]??T.status)+")",onClick:()=>k(B?null:T.name)},e.default.createElement(De,{name:T.name,status:T.status,tint:T.tint,muted:T.muted,size:"hive"}),e.default.createElement("span",{className:"dsh-hive-hex-bee-name"},T.name))})),e.default.createElement("button",{type:"button",className:"dsh-hive-hex-coord-btn","aria-pressed":j==="coordinator",style:{left:me.coordinator.x/W*100+"%",top:me.coordinator.y-me.coordinator.radius*.14},"aria-label":"Inspect Coordinator",onClick:()=>k(j==="coordinator"?null:"coordinator")},e.default.createElement(De,{name:"coordinator",status:me.coordinator.model.phase==="working"?"working":"active",coordinator:!0,size:"lg"}))),e.default.createElement("div",{className:"dsh-hive-graph-legend"},e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"done"},"Tasks done"),e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"message"},"Message just sent"),e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"waiting"},"Waiting on"))):e.default.createElement(e.default.Fragment,null,e.default.createElement("div",{ref:se,className:"dsh-hive-graph dsh-hive-graph-mentions",style:{height:a},role:"group","aria-label":"Message flow graph"},e.default.createElement("svg",{width:"100%",height:a,viewBox:"0 0 "+W+" "+a,"aria-hidden":"true"},e.default.createElement("defs",null,e.default.createElement("marker",{id:o,markerUnits:"userSpaceOnUse",markerWidth:"10",markerHeight:"10",refX:"8.5",refY:"5",orient:"auto"},e.default.createElement("path",{d:"M0.5 1.2L9.5 5L0.5 8.8L2.4 5Z",fill:"context-stroke"}))),E.map(({link:i,edge:L})=>{let T=i.from+">"+i.to,B=!!(K&&i.lastSeq===K.seq),V=G===T,A=G?V:!j||j===i.from||j===i.to,I=V||B&&A,P=Math.min(4.2,1.1+Math.sqrt(i.count)*.72),$=A&&L.length>=36&&(i.count>1||I||V),le=String(i.count),Z=Math.max(18,le.length*7+8);return e.default.createElement("g",{key:T,className:"dsh-hive-edge-group","data-active":I?"true":void 0},e.default.createElement("path",{d:L.d,fill:"none",stroke:"transparent",strokeWidth:"14",className:"dsh-hive-edge-hit",onMouseEnter:()=>ce(T),onMouseLeave:()=>ce(re=>re===T?null:re)}),e.default.createElement("path",{"data-hive-edge":T,d:L.d,className:"dsh-hive-edge","data-active":I?"true":void 0,strokeWidth:I?Math.max(2.4,P+.4):P,strokeDasharray:i.direct?void 0:"4 4",opacity:A?I?1:.72:.16,markerEnd:"url(#"+o+")"}),I?e.default.createElement("polygon",{className:"dsh-hive-edge-tip",points:Mn(L.end,L.endAngle)}):null,$?e.default.createElement("g",{className:"dsh-hive-edge-pill","data-active":I?"true":void 0,transform:"translate("+L.mid.x.toFixed(1)+","+L.mid.y.toFixed(1)+")"},e.default.createElement("rect",{x:-Z/2,y:"-8",width:Z,height:"16",rx:"8"}),e.default.createElement("text",{textAnchor:"middle",dominantBaseline:"central"},le)):null)})),t.nodes.map(i=>{let L=p.get(i.name)??{x:W/2,y:a/2},T=Ce.default.unmentionedNode(i),B=i.role==="coordinator"||i.name==="coordinator",V=i.status==="retired",A=!B&&["done","retired"].includes(i.status),I=!!(J&&!J.has(i.name));return e.default.createElement("button",{key:i.name,ref:P=>{P?te.current.set(i.name,P):te.current.delete(i.name)},type:"button",className:"dsh-hive-graph-pill","data-role":B?"coordinator":"worker","data-status":i.status??"observer","data-retired":V?"true":void 0,"data-unmentioned":T?"true":void 0,"data-dimmed":I?"true":void 0,style:{left:L.x/W*100+"%",top:L.y},"aria-pressed":j===i.name,title:i.name+" \xB7 "+(je[i.status]??i.status)+(T?" \xB7 Posted with no mention":""),onClick:()=>k(j===i.name?null:i.name)},e.default.createElement(De,{name:i.name,status:i.status,coordinator:B,tint:i.tint,muted:A,size:"sm"}),e.default.createElement("span",{className:"dsh-hive-graph-pill-name"},i.name),e.default.createElement("span",{className:"dsh-hive-node-dot","aria-hidden":"true"}),i.broadcasts?e.default.createElement("span",{className:"dsh-hive-node-broadcast"},"@all ",i.broadcasts):null)})),e.default.createElement("div",{className:"dsh-hive-graph-legend"},e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"mention"},"@mention, width = count"),e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"broadcast"},"via @all"),e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"unmentioned"},"posted with no mention"),e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"all-badge"},e.default.createElement("span",{className:"dsh-hive-all-badge"},"@all ",t.broadcasts),"@all posts, drawn by Expand @all"))),j&&F?e.default.createElement("section",{className:"dsh-hive-selected-post"},e.default.createElement("div",{className:"dsh-hive-line"},e.default.createElement(Je,{member:F,coordinator:F.role==="coordinator"||F.name==="coordinator",muted:F.status==="retired"}),e.default.createElement(Ze,{value:F.status}),e.default.createElement("div",{className:"dsh-hive-pill-group"},Pe(F)?e.default.createElement("button",{type:"button",onClick:i=>l(j,i.currentTarget)},"Inspect @",j," Journal"):null,e.default.createElement("button",{type:"button",className:"dsh-hive-ghost-btn",onClick:()=>k(null)},"Clear"))),K&&K.author===j?e.default.createElement(Ge,{text:K.text,onJumpPost:f}):null):null,K?e.default.createElement("section",{className:"dsh-hive-selected-post"},e.default.createElement("div",{className:"dsh-hive-line"},e.default.createElement("h3",null,"Selected post"),e.default.createElement("strong",null,K.author==="system"?"System":"@"+K.author),e.default.createElement(Ee,{seq:K.seq,onJumpPost:f})),e.default.createElement(Ge,{text:K.text,onJumpPost:f})):null,m==="mentions"&&(t.links.length?e.default.createElement("ul",{className:"dsh-hive-flow-list","aria-label":"Message flow counts"},t.links.filter(i=>!j||i.from===j||i.to===j).map(i=>e.default.createElement("li",{key:i.from+">"+i.to},"@",i.from," \u2192 @",i.to,": ",i.count," ",i.count===1?"mention":"mentions"))):e.default.createElement("p",{className:"dsh-hive-secondary"},"No directed mentions at this point in the replay.")))}var at=["Overview","Board","Members","Graph"];function Et({controller:n,onExpand:s,mode:l="dock",visible:f=!0}){let m=(0,e.useSyncExternalStore)(n.subscribe,n.getSnapshot,n.getSnapshot),r={...m,pending:m.pending||m.connection!=="connected"},[C,M]=(0,e.useState)("Overview"),[N,w]=(0,e.useState)(null),[u,x]=(0,e.useState)(!1),[d,b]=(0,e.useState)(""),[H,v]=(0,e.useState)(null),[y,U]=(0,e.useState)(null),j=(0,e.useRef)([]),k=(0,e.useId)().replace(/[^a-zA-Z0-9_-]/g,""),G=(0,e.useRef)(!1);(0,e.useEffect)(()=>{if(!f)return;let h=n.retain();return()=>{G.current&&(n.closeJournal(),G.current=!1),h()}},[n,f]),(0,e.useEffect)(()=>{x(!1),v(null),U(null)},[r.team?.id]);let ce=(h,g)=>{G.current=!0,w({opener:g,controller:n}),n.openJournal(h)},O=async(h,g)=>{await n.openSession(h,{fallbackToJournal:!1})==="fallback"&&ce(h,g)},R=()=>{G.current=!1,w(null),n.closeJournal()},Y=h=>{v(h),M("Board"),r.history.some(g=>g.seq===h)||n.loadHistory({reset:!0})},S=h=>{U({name:h,id:Date.now()}),M("Board")},ee=h=>{M(h);let g=at.indexOf(h);j.current[g]?.scrollIntoView?.({block:"nearest",inline:"nearest"})};function se(h,g){let q={ArrowRight:(g+1)%4,ArrowLeft:(g+3)%4,Home:0,End:3}[h.key];q!==void 0&&(h.preventDefault(),ee(at[q]),j.current[q]?.focus())}async function te(h){h.preventDefault();let g=d.trim();if(g)try{await n.command("set_team_title",{title:g}),x(!1)}catch{}}let W=(0,e.useMemo)(()=>(r.history.length?r.history:r.team?.events??[]).filter(Ce.default.isPost).length,[r.history,r.team?.events]),Q=(0,e.useMemo)(()=>r.team?r.team.members.filter(h=>h.status!=="retired").length:0,[r.team]),o={Board:W,Members:Q};return e.default.createElement("div",{className:"dsh-hive","data-dsh-hive-swarm":l},e.default.createElement("style",null,Mt),e.default.createElement("header",{className:"dsh-hive-header"},e.default.createElement("div",{className:"dsh-hive-header-top"},e.default.createElement("div",{className:"dsh-hive-title-wrap"},e.default.createElement(Ke,{size:20}),e.default.createElement("h1",null,r.team?.title??"Hive Swarm")),r.team?e.default.createElement(Ze,{value:r.team.paused?"paused":r.team.phase,compactView:!0}):null),r.team&&u?e.default.createElement("form",{className:"dsh-hive-rename",onSubmit:te},e.default.createElement("input",{"aria-label":"Swarm title",maxLength:"95",required:!0,value:d,onChange:h=>b(h.target.value)}),e.default.createElement("button",{type:"submit",disabled:r.pending||!d.trim()},"Save"),e.default.createElement("button",{type:"button",onClick:()=>x(!1)},"Cancel")):null,e.default.createElement("div",{className:"dsh-hive-header-actions"},e.default.createElement("select",{"aria-label":"Team",value:r.team?.id??"",disabled:r.loading||m.pending,onChange:h=>n.selectTeam(h.target.value)},e.default.createElement("option",{value:""},"Choose a team"),r.teams.map(h=>e.default.createElement("option",{key:h.id,value:h.id},h.title," \xB7 ",h.cwd))),r.team&&!u?e.default.createElement("button",{type:"button",className:"dsh-hive-compact-btn",disabled:r.pending,onClick:()=>{b(r.team.title??""),x(!0)}},"Rename"):null,e.default.createElement("button",{type:"button",className:"dsh-hive-compact-btn",disabled:r.loading,onClick:n.refresh},"Refresh"),r.team?e.default.createElement("button",{type:"button",className:"dsh-hive-compact-btn",disabled:r.pending,onClick:()=>ze(n,r.team.paused?"resume_team":"pause_team")},r.team.paused?"Resume":"Pause"):null,s?e.default.createElement("button",{type:"button",className:"dsh-hive-compact-btn","aria-label":"Open full view",onClick:()=>s(n)},"Open full view"):null),r.loading||r.connection==="disconnected"||m.pending||!r.team?e.default.createElement("p",{className:"dsh-hive-secondary dsh-hive-context",role:"status"},r.loading?"Loading Swarm\u2026":r.connection==="disconnected"?"Disconnected \xB7 refresh to reconnect":m.pending?"Saving action\u2026":r.workspace??"Teams in the Host\u2019s permitted workspace scope"):null),r.error?e.default.createElement(Wt,{error:r.error,controller:n}):null,r.team?e.default.createElement(e.default.Fragment,null,e.default.createElement("nav",{role:"tablist","aria-label":"Swarm views",className:"dsh-hive-tabs"},at.map((h,g)=>e.default.createElement("button",{key:h,ref:q=>{j.current[g]=q},type:"button",role:"tab",id:k+"-tab-"+h,"aria-controls":k+"-panel-"+h,"aria-selected":C===h,tabIndex:C===h?0:-1,onClick:()=>ee(h),onKeyDown:q=>se(q,g)},h,Object.hasOwn(o,h)?e.default.createElement("span",{className:"dsh-hive-tab-count"},o[h]):null))),e.default.createElement("section",{role:"tabpanel",tabIndex:"0",id:k+"-panel-"+C,"aria-labelledby":k+"-tab-"+C,className:"dsh-hive-content"},C==="Overview"?e.default.createElement(fn,{state:r,controller:n,onJournal:ce,onJumpPost:Y,onMention:S}):C==="Board"?e.default.createElement(vn,{key:r.team.id,state:r,controller:n,focusedSeq:H,onClearFocus:()=>v(null),mentionRequest:y,onConsumeMention:()=>U(null),onJumpPost:Y}):C==="Members"?e.default.createElement(yn,{key:r.team.id,state:r,controller:n,onJournal:ce,onOpenSession:O,onMention:S}):e.default.createElement(qn,{key:r.team.id,state:r,controller:n,onJournal:ce,onJumpPost:Y}))):e.default.createElement(rn,{title:r.loading?"Loading teams\u2026":r.teams.length?"Choose a team":"No teams in this workspace"},r.loading?"Reading the native Host.":r.teams.length?"Select a team to inspect its work. Opening Swarm does not start workers.":"Create a team through /hive-swarm in an authorized parent session, then refresh."),f&&N?.controller===n&&r.journal?e.default.createElement(pn,{controller:n,journal:r.journal,opener:N.opener,onClose:R,onJumpPost:Y}):null)}function Dt({surfaces:n}){let s=(0,e.useSyncExternalStore)(n.subscribe,n.getSnapshot,n.getSnapshot);return e.default.createElement(Et,{controller:s,mode:"main"})}var Ht=()=>null,In=/^hive-swarm:\/\/team\/([0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i;function jt({parentSessionId:n,controllerForTeam:s,onExpand:l,useTabInfo:f=Ht,useSessions:m=Ht}){let r=f()?.tab,C=r?.navigation?.params,M=m(u=>u?.byId?.[n]?.cwd),N=typeof C?.teamId=="string"?"hive-swarm://team/"+C.teamId:r?.contentId,w=typeof N=="string"?In.exec(N)?.[1]?.toLowerCase():void 0;return e.default.createElement(Et,{controller:s(w,M),onExpand:l,visible:r?.visible!==!1})}var Te=Ue(require("react"),1);var Gt=`.dsh-hive-tool {
|
|
867
|
+
`;var ao=typeof document<"u"?e.useLayoutEffect:e.useEffect,Ft="hive-swarm:dsh:graph-mode",Et="hive-swarm:dsh:dismissed-update",lo="2.1.2".trim(),ho=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/,co=typeof De.default.drawSprite=="function",uo="data:image/svg+xml,"+encodeURIComponent(Tt);function et({size:o=22,className:n}){return e.default.createElement("img",{src:uo,width:o,height:o,className:n,alt:"","aria-hidden":"true","data-dsh-panel-entry":"dsh-hive-swarm"})}function Ee({name:o,status:n,coordinator:d=!1,tint:p,muted:m=!1,size:i="md"}){let N=(0,e.useRef)(null),k=m&&!co?"working":n;return(0,e.useEffect)(()=>{let C=N.current;if(!C)return;let y=C.getContext("2d");if(y){y.clearRect(0,0,C.width,C.height);let c=De.default.sprite(o,{status:k,coordinator:d,tint:p,muted:m});c&&y.drawImage(c,0,0)}},[o,k,d,p,m]),e.default.createElement("canvas",{ref:N,width:"20",height:"18","aria-hidden":"true",className:"dsh-hive-bee","data-size":i,"data-muted":m?"true":void 0})}var Wt=()=>{},We=(o,n,d)=>{o.command(n,d).catch(Wt)},Dt={working:"Live",waiting:"Waiting",done:"Done",paused:"Paused",budget:"Turn limit",stalled:"Needs you",quota:"Quota reached",retired:"Retired",failed:"Needs you",queued:"Queued",blocked:"Blocked",active:"Active"},_e={working:"Working",waiting:"Waiting",done:"Done",paused:"Paused",budget:"Turn limit",stalled:"Needs you",quota:"Quota reached",retired:"Retired",failed:"Failed",queued:"Queued",blocked:"Blocked",active:"Active"},It={subagent:"Subagent",attached:"Attached",session:"Session"};function tt({value:o,compactView:n=!1}){return e.default.createElement("span",{className:n?"dsh-hive-header-status":"dsh-hive-status","data-status":o},e.default.createElement("span",{className:"dsh-hive-status-dot","aria-hidden":"true"}),(n?Dt:_e)[o]??o??"Ready")}function po({mode:o,subagentName:n}){return!o||!Object.hasOwn(It,o)?null:e.default.createElement("span",{className:"dsh-hive-mode","data-mode":o,title:n?"Subagent: "+n:void 0},It[o])}function fo({title:o,children:n}){return e.default.createElement("section",{className:"dsh-hive-empty"},e.default.createElement("h2",null,o),e.default.createElement("p",null,n))}function jt({error:o,controller:n}){return e.default.createElement("div",{role:"alert",className:"dsh-hive-error"},e.default.createElement("p",null,o.message),e.default.createElement("p",{className:"dsh-hive-secondary"},o.action?"The action may have reached the Host. Refresh to inspect the result, or retry the same request.":"Check the Host connection and workspace permission, then refresh."),e.default.createElement("div",{className:"dsh-hive-actions"},e.default.createElement("button",{type:"button",onClick:()=>n.refresh()},"Refresh"),n.getSnapshot().selectedId&&!n.getSnapshot().team?e.default.createElement("button",{type:"button",onClick:n.showTeams},"Show teams"):null,o.action?e.default.createElement("button",{type:"button",disabled:n.getSnapshot().pending,onClick:()=>{n.retryCommand().catch(Wt)}},"Retry action"):null))}function ct({className:o="dsh-hive-chevron"}){return e.default.createElement("svg",{className:o,width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},e.default.createElement("path",{d:"M4 6l4 4 4-4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}))}function lt({status:o,recovery:n=!1}){return n||["failed","quota","stalled","blocked"].includes(o)?e.default.createElement("span",{className:"dsh-hive-glyph","data-tone":"danger","aria-hidden":"true"},"!"):o==="done"?e.default.createElement("span",{className:"dsh-hive-glyph","data-tone":"done","aria-hidden":"true"},"\u2713"):o==="working"||o==="active"?e.default.createElement("span",{className:"dsh-hive-glyph","data-tone":"active","aria-hidden":"true"},e.default.createElement("span",{className:"dsh-hive-glyph-dot"})):e.default.createElement("span",{className:"dsh-hive-glyph","data-tone":"idle","aria-hidden":"true"},e.default.createElement("span",{className:"dsh-hive-glyph-dot"}))}function je({seq:o,onJumpPost:n}){return n?e.default.createElement("button",{type:"button",className:"dsh-hive-ref","aria-label":"Jump to post #"+o,onClick:()=>n(o)},"#",o):"#"+o}function _t(o){try{let n=new URL(o);return["http:","https:"].includes(n.protocol)?n.href:null}catch{return null}}function mo(o){if(typeof o!="string")return null;let n=o.trim();if(!n)return null;if(n.startsWith("/api/hive-swarm/v1/screenshot")||n.startsWith("/board/")||/^data:image\/(png|jpe?g|webp|gif);base64,/i.test(n))return n;try{let d=new URL(n);return["http:","https:","blob:"].includes(d.protocol)?d.href:null}catch{return null}}function Ve(o,n,d="i"){let p=[],m=0,i=0,N=/\x60([^\x60\n]+)\x60|\*\*([^\n]+?)\*\*|\*([^*\n]+)\*|\[([^\]\n]+)\]\(([^\s)]+)\)|\[(done|stall)\]|(?<![a-z0-9_])(@#?[a-z][a-z0-9_-]*|#[1-9]\d*\b)/gi;for(let k of o.matchAll(N)){m<k.index&&p.push(o.slice(m,k.index));let C=d+"-"+i++;if(k[1])p.push(e.default.createElement("code",{key:C},k[1]));else if(k[2])p.push(e.default.createElement("strong",{key:C},Ve(k[2],n,C)));else if(k[3])p.push(e.default.createElement("em",{key:C},Ve(k[3],n,C)));else if(k[4]){let y=_t(k[5]);p.push(y?e.default.createElement("a",{key:C,href:y,target:"_blank",rel:"noopener noreferrer"},k[4]):k[0])}else if(k[6])p.push(e.default.createElement("span",{key:C,className:"dsh-hive-badge","data-badge":k[6].toLowerCase()},k[0]));else if(k[0].startsWith("@"))p.push(e.default.createElement("span",{key:C,className:"dsh-hive-mention"},k[0]));else{let y=Number(k[0].slice(1));p.push(Number.isSafeInteger(y)?e.default.createElement(je,{key:C,seq:y,onJumpPost:n}):k[0])}m=k.index+k[0].length}return m<o.length&&p.push(o.slice(m)),p}function zt(o,n,d="b"){let p=[],m=[],i=null,N=0,k=()=>{if(!m.length)return;let y=d+"-p"+N++;p.push(e.default.createElement("p",{key:y,className:"dsh-hive-prose"},Ve(m.join(`
|
|
868
|
+
`),n,y))),m=[]},C=()=>{if(!i)return;let y=d+"-l"+N++,c=i.items.map((w,x)=>e.default.createElement("li",{key:x},Ve(w,n,y+"-"+x)));p.push(i.ordered?e.default.createElement("ol",{key:y,className:"dsh-hive-list",start:i.start},c):e.default.createElement("ul",{key:y,className:"dsh-hive-list"},c)),i=null};for(let y of o.split(/\r?\n/)){let c=/^ {0,3}(#{1,3})\s+(.+)$/.exec(y),w=/^ {0,3}([-*+]|\d+[.)])\s+(.+)$/.exec(y);if(c){k(),C();let x=d+"-h"+N++,b="h"+(2+c[1].length);p.push(e.default.createElement(b,{key:x},Ve(c[2],n,x)))}else if(w){k();let x=/^\d/.test(w[1]);(!i||i.ordered!==x)&&(C(),i={ordered:x,start:x?Number.parseInt(w[1],10):1,items:[]}),i.items.push(w[2])}else C(),y.trim()?m.push(y):k()}return k(),C(),p}function Oe({text:o,onJumpPost:n}){let d=String(o??""),p=[],m=0,i=0,N=/^[ \t]*\x60{3}[^\r\n\x60]*\r?\n([\s\S]*?)^[ \t]*\x60{3}[ \t]*\r?$/gm;for(let C of d.matchAll(N)){let y=d.slice(m,C.index);y.trim()&&p.push(...zt(y,n,"s"+i++)),p.push(e.default.createElement("pre",{key:"c"+i++,className:"dsh-hive-code"},e.default.createElement("code",null,C[1].replace(/\r?\n$/,"")))),m=C.index+C[0].length}let k=d.slice(m);return(k.trim()||!p.length)&&p.push(...zt(k,n,"s"+i++)),e.default.createElement("div",{className:"dsh-hive-rich"},p)}function Ae(o,n=140){let d=String(o??"").replace(/\s+/g," ").trim();return d.length>n?d.slice(0,n-1).trimEnd()+"\u2026":d}function ut(o){if(typeof Te.default.smartTaskLabel=="function")return Te.default.smartTaskLabel(o);let n=String(o?.taskLabel??"").trim();if(n)return Ae(n,64);let d=String(o?.brief??"").replace(/[`*_#>\[\]]/g," ").replace(/\s+/g," ").trim();d=d.replace(/^You are\s+(?:@[a-z0-9_-]+\s+)?(?:an?\s+|the\s+)?(?:Hive Swarm\s+)?(?:member|worker|agent|author|verifier|researcher|investigator|auditor|reviewer)?[^.:\n]*?(?:[.:]\s+|\s+—\s+|\s+-\s+)/i,""),d=d.replace(/^(?:Your\s+)?(?:assignment|mission|role|task)(?:\s*\([^)]*\))?\s*[:\-–—]\s*/i,""),d=d.replace(/^You\s+own\s+(?:the\s+)?/i,"");let m=(d.split(/(?<=[.!?])\s+|\s*;\s*|\r?\n/)[0]?.trim()??"").replace(/[.:,;!?]+$/,"").split(/\s+/).filter(Boolean);for(m.length>10&&(m=m.slice(0,10));m.length>2&&/^(?:for|in|on|with|to|of|from|by|at|and|or|the|a|an)$/i.test(m.at(-1));)m.pop();let i=m.join(" ").trim();return Ae(i||o?.name||"Task",64)}function pt(o,n=!1,d){if(typeof De.default.tintStyle=="function")return De.default.tintStyle(o,n,d);let[p,m,i]=De.default.colors(o,n,d);return{base:p,highlight:m,shade:i,bg:"color-mix(in oklab, "+p+" 16%, transparent)",border:"color-mix(in oklab, "+i+" 42%, var(--hive-border))",text:"var(--hive-ink)"}}function ot(o){let n=o?.members??[],p=n.some(i=>i.role==="coordinator"||i.name==="coordinator")?n:[{name:"coordinator",role:"coordinator",external:!0,status:o?.phase==="done"?"done":"waiting",model:o?.model,effort:o?.effort,brief:o?.task??"Coordinator",waitFor:[]},...n],m=0;return p.map(i=>i.role==="coordinator"||i.name==="coordinator"?{...i,role:"coordinator",tint:0}:{...i,tint:m++})}function $e({member:o,name:n,coordinator:d=!1,tint:p,muted:m=!1,onClick:i,title:N,ariaLabel:k}){let C=n??o?.name??"member",y=pt(C,d,p??o?.tint),c={"--bee-pill-bg":y.bg,"--bee-pill-border":y.border},w=e.default.createElement(e.default.Fragment,null,e.default.createElement(Ee,{name:C,status:o?.status??"waiting",coordinator:d,tint:p??o?.tint,muted:m,size:"xs"}),e.default.createElement("span",null,C));return i?e.default.createElement("button",{type:"button",className:"dsh-hive-bee-pill",style:c,title:N,"aria-label":k??"Inspect "+C,onClick:i},w):e.default.createElement("span",{className:"dsh-hive-bee-pill","data-static":"true",style:c,title:N},w)}function vo(o,n){let d=(o.members??[]).map(p=>n.find(m=>m.name===p)).filter(Boolean);return d.some(p=>p.recoveryRequired||["failed","quota"].includes(p.status))?{key:"blocked",rank:0}:d.some(p=>p.status==="working")?{key:"active",rank:1}:d.some(p=>p.status==="queued")?{key:"queued",rank:2}:d.some(p=>p.status==="waiting")?{key:"waiting",rank:3}:d.length&&d.every(p=>["done","retired"].includes(p.status))?{key:"done",rank:4}:{key:"queued",rank:2}}function Ot(o,n,d){if(o.status==="working"){let i=n?.steps?.findLast(N=>N?.label?.trim())?.label;return Ae(i)||(o.lastTurn?"Working on turn "+o.lastTurn:"Working on the current turn")}if(o.recoveryRequired)return"Outcome unconfirmed. Inspect journal before continuing.";if(["quota","failed"].includes(o.status))return Ae(d?.text)||_e[o.status]||o.status;let p=o.pendingWaitFor??o.waitFor;if(p?.length)return Ae("Waiting on "+p.map(i=>"@"+i).join(", "));let m=/\[done\]\s*([^\r?\n]+)/i.exec(d?.text??"");return m?Ae(m[1]):o.status==="waiting"?"Waiting for an @mention":o.status==="queued"?"Queued for the next turn":Ae(d?.text?.split(/\r?\n/)[0])||_e[o.status]||o.status}function nt({title:o,onClose:n,opener:d,closeOnBackdrop:p=!1,className:m="dsh-hive-dialog",children:i}){let N=(0,e.useRef)(null),k=(0,e.useRef)(null),C=(0,e.useId)().replace(/[^a-zA-Z0-9_-]/g,"");return(0,e.useLayoutEffect)(()=>{let y=N.current;if(!y)return;typeof y.showModal=="function"?y.showModal():y.setAttribute("open",""),k.current?.focus();let c;if(p&&typeof HTMLDialogElement<"u"&&!("closedBy"in HTMLDialogElement.prototype)){let w=!1,x=q=>{let z=y.getBoundingClientRect();return q.clientX<z.left||q.clientX>z.right||q.clientY<z.top||q.clientY>z.bottom},b=q=>{w=x(q)},P=q=>{w&&x(q)&&n()};y.addEventListener("pointerdown",b),y.addEventListener("pointerup",P),c=()=>{y.removeEventListener("pointerdown",b),y.removeEventListener("pointerup",P)}}return()=>{c?.(),y.open&&typeof y.close=="function"&&y.close(),d?.isConnected&&d.focus()}},[d,p,n]),e.default.createElement("dialog",{ref:N,className:m,"aria-labelledby":C,...p?{closedby:"any"}:{},onCancel:y=>{y.preventDefault(),n()},onKeyDown:y=>{y.key==="Escape"&&(y.preventDefault(),n())}},e.default.createElement("header",{className:"dsh-hive-dialog-head"},e.default.createElement("h2",{id:C},o),e.default.createElement("button",{type:"button",ref:k,"aria-label":"Close "+o,onClick:n},"Close")),i)}function go({step:o}){let n=typeof o=="string"?o:String(o?.label??""),d=typeof o=="object"&&o?.detail?String(o.detail):"",p=/^Verified route:\s*(.+)$/i.exec(n);if(p||typeof o=="object"&&o?.kind==="route"){let m=p?p[1]:n;return e.default.createElement("li",{className:"dsh-hive-route-item"},e.default.createElement("span",{className:"dsh-hive-route-badge"},e.default.createElement("span",{className:"dsh-hive-route-check","aria-hidden":"true"},"\u2713"),"Verified route: ",e.default.createElement("code",null,m)),d?e.default.createElement("span",{className:"dsh-hive-secondary"}," \u2014 ",d):null)}return e.default.createElement("li",null,n,d?" \u2014 "+d:"")}function bo({controller:o,journal:n,opener:d,onClose:p,onJumpPost:m}){let i=N=>{p(),m(N)};return e.default.createElement(nt,{title:"Journal",onClose:p,opener:d,closeOnBackdrop:!0},e.default.createElement("div",{className:"dsh-hive-actions dsh-hive-journal-bar"},e.default.createElement("strong",null,"@",n.member),e.default.createElement("button",{type:"button",disabled:n.loading,onClick:()=>{o.openJournal(n.member)}},"Refresh Journal")),n.loading?e.default.createElement("p",{role:"status"},"Loading Journal\u2026"):n.error?e.default.createElement(jt,{error:n.error,controller:{...o,refresh:()=>o.openJournal(n.member)}}):n.turns.length?e.default.createElement("ol",{className:"dsh-hive-journal"},n.turns.map((N,k)=>e.default.createElement("li",{key:N.turn??k,className:"dsh-hive-journal-turn"},e.default.createElement("div",{className:"dsh-hive-line"},e.default.createElement("h3",null,"Turn ",N.turn??k+1),e.default.createElement(tt,{value:N.status})),N.steps?.length?e.default.createElement("ul",{className:"dsh-hive-journal-steps"},N.steps.map((C,y)=>e.default.createElement(go,{key:y,step:C}))):null,N.report?e.default.createElement(Oe,{text:N.report,onJumpPost:i}):e.default.createElement("p",{className:"dsh-hive-secondary"},"No report saved for this turn.")))):e.default.createElement("p",null,"No saved turns yet. Live work appears here after the Host records it."),n.live?.steps?.length?e.default.createElement("section",{className:"dsh-hive-live"},e.default.createElement("h3",null,"Current activity"),e.default.createElement("ul",null,n.live.steps.map((N,k)=>e.default.createElement("li",{key:k},typeof N=="string"?N:N.label)))):null)}function Re({memberName:o,pending:n,controller:d}){return e.default.createElement(e.default.Fragment,null,e.default.createElement("button",{type:"button",disabled:n,"aria-label":"Retry fresh turn for @"+o,onClick:()=>We(d,"resolve_recovery",{member:o,action:"retry"})},"Retry fresh turn"),e.default.createElement("button",{type:"button",disabled:n,"aria-label":"Dismiss unconfirmed run for @"+o,onClick:()=>We(d,"resolve_recovery",{member:o,action:"dismiss"})},"Dismiss"))}function Lt({className:o,defaultOpen:n=!1,summary:d,children:p}){let[m,i]=(0,e.useState)(n);return e.default.createElement("details",{className:o,open:m},e.default.createElement("summary",{className:o==="dsh-hive-task-card"?"dsh-hive-task-summary":"dsh-hive-thread-head",onClick:N=>{N.preventDefault(),i(k=>!k)}},d),p)}function yo({state:o,controller:n,onJournal:d,onJumpPost:p,onMention:m}){let i=o.team,N=o.history.length?o.history:i.events??[],k=(0,e.useMemo)(()=>ot(i),[i]),C=(0,e.useMemo)(()=>new Map(k.map(a=>[a.name,a])),[k]),y=(0,e.useMemo)(()=>{let a=new Map;for(let A of N)A.kind!=="brief"&&A.author!=="system"&&a.set(A.author,A);return a},[N]),c=i.members.filter(a=>a.role!=="coordinator"&&a.name!=="coordinator"&&a.status!=="retired"),w=c.filter(a=>a.status==="done").length,x=c.length>0&&w===c.length,b=i.task?.trim()??"",P=i.goalLine?.trim()??"",q=b.length>140||/\n/.test(b),z=i.members.filter(a=>a.recoveryRequired||["quota","failed"].includes(a.status)),J=(i.attention??[]).filter(a=>["stalled","budget"].includes(i.phase)||["recovery","input","quota","failed","dependency","cycle"].includes(a.kind)),g=J.length>0||z.length>0||i.phase==="budget"||i.phase==="stalled",T=(0,e.useMemo)(()=>k.filter(a=>a.role!=="coordinator"&&a.name!=="coordinator"&&a.status!=="retired").map(a=>({member:a,latest:y.get(a.name)})).sort((a,A)=>(A.latest?.seq??0)-(a.latest?.seq??0)),[k,y]),G=(0,e.useMemo)(()=>(i.threads?.length?i.threads:c.length?[{id:"tasks",title:"Tasks",members:c.map(A=>A.name)}]:[]).map(A=>({thread:A,state:vo(A,i.members)})).sort((A,r)=>A.state.rank-r.state.rank),[i.threads,i.members,c]),$=(0,e.useMemo)(()=>(i.screenshots??[]).map((a,A)=>{let r=mo(a?.url);return r?{...a,id:a.id??a.seq+":"+A,url:r}:null}).filter(Boolean),[i.screenshots]),[O,h]=(0,e.useState)(null),W=k.find(a=>a.role==="coordinator"||a.name==="coordinator"),Z=i.members.some(a=>a.role==="coordinator"||a.name==="coordinator"),re=(0,e.useMemo)(()=>N.findLast(a=>a.author==="coordinator"&&a.kind!=="brief")??N.findLast(a=>a.author==="user"&&a.kind!=="brief"&&/\[done\]/i.test(a.text??""))??(Z?void 0:N.findLast(a=>a.author==="user"&&a.kind!=="brief")),[N,Z]),pe=re?.text?.trim()??"",ie=pe?Ae(pe.replace(/^\[done\]\s*/i,""),180):"",L=pe.length>180||/\n/.test(pe),R=(a,A)=>{if(Le(a)){d(a.name,A);return}let r=y.get(a.name);r?p(r.seq):a.status!=="retired"&&!a.retireAfterTurn&&m(a.name)};return e.default.createElement("div",{className:"dsh-hive-overview"},P?e.default.createElement("p",{className:"dsh-hive-goal-line"},P):!q&&b&&b!==i.title?e.default.createElement("p",{className:"dsh-hive-goal-line"},b):null,q?e.default.createElement("details",{className:"dsh-hive-details dsh-hive-brief-disclosure"},e.default.createElement("summary",null,"Full brief"),e.default.createElement(Oe,{text:b,onJumpPost:p})):null,e.default.createElement(Lt,{className:"dsh-hive-task-card",defaultOpen:!1,summary:e.default.createElement(e.default.Fragment,null,e.default.createElement(lt,{status:z.length?"failed":x?"done":"working",recovery:z.some(a=>a.recoveryRequired)}),e.default.createElement("span",{className:"dsh-hive-task-count"},e.default.createElement("strong",null,w," of ",c.length)," tasks done"),e.default.createElement("span",{className:"dsh-hive-task-turns"},"Turns ",i.turns,"/",i.turnLimit),e.default.createElement(ct,null))},e.default.createElement("div",{className:"dsh-hive-task-body"},T.length?e.default.createElement("ul",{className:"dsh-hive-task-list"},T.map(({member:a,latest:A})=>{let r=Ot(a,i.activity?.[a.name],A),M=a.status==="retired";return e.default.createElement("li",{key:a.name,className:"dsh-hive-task-row"},e.default.createElement(lt,{status:a.status,recovery:a.recoveryRequired}),e.default.createElement("div",{className:"dsh-hive-task-main"},e.default.createElement("div",{className:"dsh-hive-task-title"},ut(a)),e.default.createElement("div",{className:"dsh-hive-task-sub"},r),a.recoveryRequired?e.default.createElement("div",{className:"dsh-hive-actions dsh-hive-inline-actions"},e.default.createElement(Re,{memberName:a.name,pending:o.pending||a.status==="working",controller:n})):null),e.default.createElement($e,{member:a,muted:M,title:Le(a)?"Inspect @"+a.name+" Journal":"View @"+a.name,ariaLabel:(Le(a)?"Inspect journal for @":"Jump to @")+a.name,onClick:f=>R(a,f.currentTarget)}))})):e.default.createElement("p",{className:"dsh-hive-secondary dsh-hive-task-empty"},"No worker tasks assigned yet."))),g?e.default.createElement("section",{className:"dsh-hive-section"},e.default.createElement("h2",null,"Needs you"),e.default.createElement("ul",{className:"dsh-hive-attention"},J.map((a,A)=>{let r=i.members.find(M=>M.name===a.member);return e.default.createElement("li",{key:"a-"+A,className:"dsh-hive-alert-card","data-kind":a.kind},e.default.createElement("p",null,a.text??a.message??a.kind),e.default.createElement("div",{className:"dsh-hive-actions"},a.seq?e.default.createElement(je,{seq:a.seq,onJumpPost:p}):null,a.kind==="budget"?e.default.createElement("button",{type:"button",disabled:o.pending,onClick:()=>We(n,"resume_team",{extraTurns:8})},"Add 8 turns and resume"):null,Le(r)?e.default.createElement("button",{type:"button",onClick:M=>d(a.member,M.currentTarget)},"Inspect @",a.member):null,r?.recoveryRequired?e.default.createElement(Re,{memberName:r.name,pending:o.pending||r.status==="working",controller:n}):null))}),z.filter(a=>!J.some(A=>A.member===a.name)).map(a=>e.default.createElement("li",{key:a.name,className:"dsh-hive-alert-card","data-kind":a.recoveryRequired?"recovery":a.status},e.default.createElement("p",null,"@",a.name,": ",a.recoveryRequired?"Outcome unconfirmed. Inspect the owned session before continuing.":a.status==="quota"?"Model quota reached. Choose an available model before resuming.":"The last turn failed. Inspect the Journal for recovery details."),e.default.createElement("div",{className:"dsh-hive-actions"},Le(a)?e.default.createElement("button",{type:"button",onClick:A=>d(a.name,A.currentTarget)},"Inspect Journal"):null,a.recoveryRequired?e.default.createElement(Re,{memberName:a.name,pending:o.pending||a.status==="working",controller:n}):null))),i.phase==="budget"&&!J.some(a=>a.kind==="budget")?e.default.createElement("li",{key:"budget-alert",className:"dsh-hive-alert-card","data-kind":"budget"},e.default.createElement("p",null,"Turn limit reached (",i.turns,"/",i.turnLimit,"). Add 8 turns to continue."),e.default.createElement("div",{className:"dsh-hive-actions"},e.default.createElement("button",{type:"button",disabled:o.pending,onClick:()=>We(n,"resume_team",{extraTurns:8})},"Add 8 turns and resume"))):null)):null,G.length?e.default.createElement("section",{className:"dsh-hive-section"},e.default.createElement("h2",null,"Threads"),e.default.createElement("div",{className:"dsh-hive-threads"},G.map(({thread:a,state:A})=>{let r=(a.members??[]).map(Y=>C.get(Y)??{name:Y,status:"queued",brief:a.goal??Y}),M=r.length,f=r.filter(Y=>["done","retired"].includes(Y.status)).length,te=G.length===1||["blocked","active","done"].includes(A.key);return e.default.createElement(Lt,{key:a.id??a.title,className:"dsh-hive-thread-card",defaultOpen:te,summary:e.default.createElement(e.default.Fragment,null,e.default.createElement("span",{className:"dsh-hive-thread-left"},e.default.createElement("span",{className:"dsh-hive-thread-dot","data-status":A.key,"aria-hidden":"true"}),e.default.createElement("strong",{className:"dsh-hive-thread-title"},a.title),e.default.createElement("span",{className:"dsh-hive-thread-state"},Dt[A.key]??A.key)),e.default.createElement("span",{className:"dsh-hive-thread-right"},e.default.createElement("progress",{className:"dsh-hive-mini-progress",max:Math.max(M,1),value:f,"aria-label":a.title+" progress"}),e.default.createElement("span",{className:"dsh-hive-thread-ratio"},f,"/",M),e.default.createElement(ct,null)))},e.default.createElement("div",{className:"dsh-hive-thread-body"},a.goal?e.default.createElement("p",{className:"dsh-hive-thread-goal"},a.goal):null,r.length?e.default.createElement("ul",{className:"dsh-hive-thread-rows"},r.map(Y=>e.default.createElement("li",{key:Y.name,className:"dsh-hive-thread-task"},e.default.createElement(lt,{status:Y.status,recovery:Y.recoveryRequired}),e.default.createElement("span",{className:"dsh-hive-thread-task-title"},ut(Y)),e.default.createElement($e,{member:Y,muted:Y.status==="retired",ariaLabel:(Le(Y)?"Inspect journal for @":"Jump to @")+Y.name,onClick:Me=>R(Y,Me.currentTarget)})))):e.default.createElement("p",{className:"dsh-hive-secondary"},"No members assigned to this thread.")))}))):null,$.length?e.default.createElement("section",{className:"dsh-hive-section"},e.default.createElement("h2",null,"Screenshots"),e.default.createElement("ul",{className:"dsh-hive-screenshots-strip"},$.map(a=>{let A=C.get(a.author);return e.default.createElement("li",{key:a.id,className:"dsh-hive-shot-card"},e.default.createElement("button",{type:"button",className:"dsh-hive-shot-thumb","aria-label":"Preview screenshot: "+a.caption,onClick:r=>h({shot:a,opener:r.currentTarget})},e.default.createElement("img",{src:a.url,alt:a.caption,loading:"lazy"})),e.default.createElement("div",{className:"dsh-hive-shot-meta"},e.default.createElement("p",{className:"dsh-hive-shot-caption"},a.caption),e.default.createElement("div",{className:"dsh-hive-shot-foot"},a.seq?e.default.createElement(je,{seq:a.seq,onJumpPost:p}):null,a.author?e.default.createElement($e,{member:A,name:a.author,coordinator:a.author==="coordinator",onClick:A?r=>R(A,r.currentTarget):void 0}):null)))}))):null,e.default.createElement("section",{className:"dsh-hive-section"},e.default.createElement("h2",null,"The team"),e.default.createElement("div",{className:"dsh-hive-team-card"},e.default.createElement("div",{className:"dsh-hive-coordinator-tile","aria-hidden":"true"},e.default.createElement(Ee,{name:"coordinator",status:"working",coordinator:!0,size:"lg"})),e.default.createElement("div",{className:"dsh-hive-team-body"},e.default.createElement("div",{className:"dsh-hive-line"},e.default.createElement("strong",{className:"dsh-hive-team-name"},"Coordinator"),e.default.createElement("div",{className:"dsh-hive-pill-group"},re?.seq?e.default.createElement(je,{seq:re.seq,onJumpPost:p}):null,Le(W)?e.default.createElement("button",{type:"button",className:"dsh-hive-ghost-btn",onClick:a=>d(W.name,a.currentTarget)},"Journal"):null)),e.default.createElement("p",{className:"dsh-hive-team-summary"},ie||(b?Ae(b,180):"Coordinating team progress.")),L?e.default.createElement("details",{className:"dsh-hive-details"},e.default.createElement("summary",null,"Full summary"),e.default.createElement(Oe,{text:pe,onJumpPost:p})):null,e.default.createElement("details",{className:"dsh-hive-details dsh-hive-exec"},e.default.createElement("summary",null,"Execution"),e.default.createElement("dl",{className:"dsh-hive-facts"},e.default.createElement("div",null,e.default.createElement("dt",null,"Turns"),e.default.createElement("dd",null,i.turns," of ",i.turnLimit," used")),e.default.createElement("div",null,e.default.createElement("dt",null,"Members"),e.default.createElement("dd",null,i.members.filter(a=>a.status!=="retired").length," active \xB7 ",i.members.filter(a=>a.status==="working").length," working")),e.default.createElement("div",null,e.default.createElement("dt",null,"Model"),e.default.createElement("dd",null,i.model??"Host default",i.effort?" \xB7 "+i.effort:"")),i.fallbackModel?e.default.createElement("div",null,e.default.createElement("dt",null,"Fallback"),e.default.createElement("dd",null,i.fallbackModel,i.fallbackEffort?" \xB7 "+i.fallbackEffort:"")):null,e.default.createElement("div",null,e.default.createElement("dt",null,"Workspace"),e.default.createElement("dd",null,i.cwd)))),i.phase==="budget"?e.default.createElement("div",{className:"dsh-hive-actions"},e.default.createElement("button",{type:"button",className:"dsh-hive-primary",disabled:o.pending,onClick:()=>We(n,"resume_team",{extraTurns:8})},"+8 turns")):null))),O?e.default.createElement(nt,{title:O.shot.caption||"Screenshot",opener:O.opener,closeOnBackdrop:!0,className:"dsh-hive-dialog dsh-hive-lightbox",onClose:()=>h(null)},e.default.createElement("figure",{className:"dsh-hive-lightbox-figure"},e.default.createElement("img",{src:O.shot.url,alt:O.shot.caption,className:"dsh-hive-lightbox-img"}),e.default.createElement("figcaption",{className:"dsh-hive-lightbox-meta"},e.default.createElement("span",null,O.shot.caption),e.default.createElement("div",{className:"dsh-hive-actions"},O.shot.seq?e.default.createElement(je,{seq:O.shot.seq,onJumpPost:a=>{h(null),p(a)}}):null,O.shot.author?e.default.createElement($e,{member:C.get(O.shot.author),name:O.shot.author,coordinator:O.shot.author==="coordinator"}):null,O.shot.time?e.default.createElement("time",{className:"dsh-hive-secondary dsh-hive-mono",dateTime:O.shot.time},new Date(O.shot.time).toLocaleString()):null)))):null)}function xo(){return e.default.createElement("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},e.default.createElement("path",{d:"M2.5 3.5h11l-4.2 5v3.7l-2.6 1.3V8.5l-4.2-5Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}))}function Ut(){return e.default.createElement("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},e.default.createElement("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:"1.4"}),e.default.createElement("path",{d:"M10.5 10.5L13.5 13.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}))}function wo(o){if(!o)return"";try{return new Date(o).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}catch{return""}}function ko({event:o,member:n,canOpenSession:d=!1,onOpenSession:p,onJumpPost:m,focused:i=!1}){let[N,k]=(0,e.useState)(!1),C=String(o.text??""),y=C.length>360||C.split(/\r?\n/).length>6,c=y&&!N&&!i,w=o.author==="coordinator"||n?.role==="coordinator",x=o.author==="system",b=!w&&!x&&n?pt(n.name,!1,n.tint):null,P=b?{"--tile-bg":b.bg,"--tile-border":b.border}:void 0,q=!w&&["done","retired"].includes(n?.status),z=w?e.default.createElement("div",{className:"dsh-hive-post-tile dsh-hive-coord-mini"},e.default.createElement(Ee,{name:"coordinator",status:n?.status??"waiting",coordinator:!0,size:"sm"})):x?e.default.createElement("div",{className:"dsh-hive-post-tile dsh-hive-system-tile","aria-hidden":"true"},"\u2699"):e.default.createElement("div",{className:"dsh-hive-post-tile",style:P},e.default.createElement(Ee,{name:o.author,status:n?.status??"observer",tint:n?.tint,muted:q,size:"sm"}));return e.default.createElement("li",{className:"dsh-hive-post","data-seq":o.seq,"data-kind":o.kind??"message","data-focused":i?"true":void 0},d&&p?e.default.createElement("button",{type:"button",className:"dsh-hive-post-avatar-btn","aria-label":"Open session for @"+o.author,title:"Open @"+o.author+" session",onClick:J=>p(o.author,J.currentTarget)},z):e.default.createElement("div",{className:"dsh-hive-post-avatar-slot","aria-hidden":"true"},z),e.default.createElement("div",{className:"dsh-hive-post-main"},e.default.createElement("div",{className:"dsh-hive-post-head"},e.default.createElement("div",{className:"dsh-hive-post-who"},e.default.createElement("strong",{className:"dsh-hive-author"},x?"System":"@"+o.author),o.targets?.length?e.default.createElement("span",{className:"dsh-hive-targets-inline"},"\u2192 "+o.targets.map(J=>"@"+J).join(" ")):null,o.channel&&o.channel!=="main"?e.default.createElement("span",{className:"dsh-hive-channel-pill"},"#",o.channel):null),e.default.createElement("span",{className:"dsh-hive-post-stamp"},e.default.createElement("span",{className:"dsh-hive-mono"},"#",o.seq),o.time?e.default.createElement("time",{dateTime:o.time,title:new Date(o.time).toLocaleString()}," \xB7 "+wo(o.time)):null)),e.default.createElement("div",{className:"dsh-hive-post-body","data-clamped":c?"true":void 0,onClick:c?J=>{J.target?.closest?.("a, button, code, pre")||globalThis.getSelection?.()?.toString?.()||k(!0)}:void 0},e.default.createElement(Oe,{text:o.text,onJumpPost:m})),y&&!i?e.default.createElement("button",{type:"button",className:"dsh-hive-expand-btn","aria-expanded":N,onClick:()=>k(J=>!J)},N?"Show less":"Show more"):null))}function Mo({state:o,controller:n,focusedSeq:d,onClearFocus:p,mentionRequest:m,onConsumeMention:i,onJumpPost:N,onOpenSession:k}){let[C,y]=(0,e.useState)(""),[c,w]=(0,e.useState)("*"),[x,b]=(0,e.useState)("*"),[P,q]=(0,e.useState)(""),[z,J]=(0,e.useState)("main"),[g,T]=(0,e.useState)(!0),[G,$]=(0,e.useState)(!1),[O,h]=(0,e.useState)(!1),W=(0,e.useRef)(null),Z=(0,e.useRef)(null),re=(0,e.useMemo)(()=>ot(o.team),[o.team]),pe=(0,e.useMemo)(()=>new Map(re.map(f=>[f.name,f])),[re]);(0,e.useEffect)(()=>{if(!m?.name)return;let f="@"+m.name;q(te=>new RegExp("(?:^|[^a-z0-9_])@"+m.name+"(?![a-z0-9_-])","i").test(te)?te:f+" "+te),Z.current?.focus?.(),i?.()},[m,i]);let ie=(0,e.useMemo)(()=>{let f=new Set(["user","coordinator"]),te=[];for(let Y of o.team.members)Y?.name&&!f.has(Y.name)&&(f.add(Y.name),te.push({value:Y.name,label:Y.name}));for(let Y of o.history)Y?.author&&Y.author!=="system"&&!f.has(Y.author)&&(f.add(Y.author),te.push({value:Y.author,label:Y.author}));return[{value:"*",label:"Everyone"},{value:"user",label:"You (user)"},{value:"coordinator",label:"Coordinator"},...te]},[o.team.members,o.history]),L=o.history.filter(f=>(c==="*"||(f.channel??"main")===c)&&(x==="*"||f.author===x)&&(!C||f.text?.toLowerCase().includes(C.toLowerCase())));(0,e.useEffect)(()=>{if(d==null)return;!L.some(te=>te.seq===d)&&o.history.some(te=>te.seq===d)&&(y(""),w("*"),b("*")),T(!1),W.current?.querySelector?.('[data-seq="'+d+'"]')?.scrollIntoView?.({block:"nearest"})},[d,o.history.length,L.length]),(0,e.useEffect)(()=>{g&&W.current&&(W.current.scrollTop=W.current.scrollHeight,h(!1))},[g,L.length]);let R=o.team.members.filter(f=>f.status==="working"),a=c!=="*"||x!=="*"||!g;async function A(f){if(f.preventDefault(),!!P.trim())try{await n.command("post_message",{text:P.trim(),channel:z}),q(""),p?.()}catch{}}let r=()=>{let f=W.current;f&&h(f.scrollHeight-f.scrollTop-f.clientHeight>48)},M=()=>{T(!0),h(!1),W.current&&(W.current.scrollTop=W.current.scrollHeight)};return e.default.createElement("div",{className:"dsh-hive-board"},R.length?e.default.createElement("section",{className:"dsh-hive-live","aria-label":"Live activity"},e.default.createElement("h3",null,"Live activity"),e.default.createElement("ul",null,R.map(f=>{let Y=o.team.activity?.[f.name]?.steps?.at(-1);return e.default.createElement("li",{key:f.name},e.default.createElement("strong",null,"@",f.name),e.default.createElement("span",null,Y?Y.label+(Y.detail?" \xB7 "+Y.detail:""):"Working\u2026"))}))):null,e.default.createElement("div",{className:"dsh-hive-toolbar"},e.default.createElement("div",{className:"dsh-hive-board-bar"},e.default.createElement("label",{className:"dsh-hive-search-box"},e.default.createElement(Ut,null),e.default.createElement("input",{type:"search","aria-label":"Search board",placeholder:"Search",value:C,onChange:f=>y(f.target.value)})),e.default.createElement("button",{type:"button",className:"dsh-hive-filter-btn","aria-label":"Toggle board filters","aria-expanded":G,"data-active":a?"true":void 0,onClick:()=>$(f=>!f)},e.default.createElement(xo,null))),e.default.createElement("div",{className:"dsh-hive-filter-drawer",hidden:!G},e.default.createElement("div",{className:"dsh-hive-filters"},e.default.createElement("label",null,"Channel",e.default.createElement("select",{value:c,onChange:f=>w(f.target.value)},e.default.createElement("option",{value:"*"},"All channels"),o.team.channels.filter(f=>!f.archived).map(f=>e.default.createElement("option",{key:f.name},f.name)))),e.default.createElement("label",null,"Author",e.default.createElement("select",{"aria-label":"Author",value:x,onChange:f=>b(f.target.value)},ie.map(f=>e.default.createElement("option",{key:f.value,value:f.value},f.label)))),e.default.createElement("button",{type:"button","aria-pressed":g,onClick:()=>T(f=>!f)},"Follow")),e.default.createElement("div",{className:"dsh-hive-actions"},e.default.createElement("button",{type:"button",disabled:o.historyLoading,onClick:()=>{n.loadHistory({reset:!0})}},"Load earlier history"),o.hasMoreHistory?e.default.createElement("button",{type:"button",disabled:o.historyLoading,onClick:()=>{n.loadHistory()}},"Load next history page"):null,o.historyLoading?e.default.createElement("span",{role:"status",className:"dsh-hive-secondary"},"Loading history\u2026"):null))),e.default.createElement("div",{className:"dsh-hive-feed-wrap"},L.length?e.default.createElement("ol",{ref:W,onScroll:r,className:"dsh-hive-feed","aria-label":"Board posts"},L.map(f=>{let te=pe.get(f.author),Y=f.author==="coordinator"||te?.role==="coordinator",Me=!!(Le(te)||Y&&typeof o.team.parentSessionId=="string"&&o.team.parentSessionId.trim());return e.default.createElement(ko,{key:f.seq,event:f,member:te,canOpenSession:Me,onOpenSession:k,onJumpPost:N,focused:d===f.seq})})):e.default.createElement("p",{role:"status",className:"dsh-hive-secondary"},"No posts match these filters."),(!g||O)&&L.length?e.default.createElement("button",{type:"button",className:"dsh-hive-latest-pill","aria-label":"Jump to latest posts",onClick:M},"\u2193 Latest"):null),e.default.createElement("form",{className:"dsh-hive-compose",onSubmit:A},e.default.createElement("label",{className:"sr-only",htmlFor:"dsh-hive-compose-input"},"Post to the board"),e.default.createElement("textarea",{id:"dsh-hive-compose-input",ref:Z,required:!0,rows:"2",maxLength:"6000",value:P,onChange:f=>q(f.target.value),placeholder:"Send a message or @mention a member\u2026"}),e.default.createElement("div",{className:"dsh-hive-actions dsh-hive-compose-foot"},e.default.createElement("label",{className:"dsh-hive-channel-pick"},e.default.createElement("span",null,"Channel"),e.default.createElement("select",{value:z,onChange:f=>J(f.target.value)},o.team.channels.filter(f=>!f.archived).map(f=>e.default.createElement("option",{key:f.name},f.name)))),e.default.createElement("button",{type:"submit",className:"dsh-hive-primary",disabled:o.pending||!P.trim()},"Post message"))))}function So({state:o,controller:n,member:d,opener:p,onClose:m}){let[i,N]=(0,e.useState)(""),[k,C]=(0,e.useState)(""),[y,c]=(0,e.useState)(!1),[w,x]=(0,e.useState)(d?.model??""),[b,P]=(0,e.useState)(d?.effort??""),[q,z]=(0,e.useState)(!1);(0,e.useEffect)(()=>{n.loadModels()},[n]);let J=o.models.find(O=>O.id===w),g=!w||!!J,T=!b||!!J?.efforts?.includes(b),G=!!(d&&["waiting","failed","quota"].includes(d.status)&&!d.recoveryRequired);async function $(O){O.preventDefault();try{d?await n.command("set_member_model",{member:d.name,model:w,effort:b||null,resume:!!(G&&q)}):await n.command("add_member",{member:{name:i,brief:k,writable:y,...w?{model:w}:{},...b?{effort:b}:{}}}),m()}catch{}}return e.default.createElement(nt,{title:d?"Change model":"Add member",onClose:m,opener:p},e.default.createElement("form",{onSubmit:$,className:"dsh-hive-form"},d?e.default.createElement("p",null,"Apply to the next turn for @",d.name,"."):e.default.createElement(e.default.Fragment,null,e.default.createElement("label",null,"Member name",e.default.createElement("input",{required:!0,pattern:"[a-z][a-z0-9_\\-]*",maxLength:"30",value:i,onChange:O=>N(O.target.value)})),e.default.createElement("label",null,"Assignment",e.default.createElement("textarea",{required:!0,rows:"4",maxLength:"6000",value:k,onChange:O=>C(O.target.value)})),e.default.createElement("label",{className:"dsh-hive-check"},e.default.createElement("input",{type:"checkbox",checked:y,onChange:O=>c(O.target.checked)}),"Request workspace write access"),e.default.createElement("p",{className:"dsh-hive-secondary"},"The Host verifies workspace scope and permission before execution.")),e.default.createElement("label",null,"Model",e.default.createElement("select",{value:w,disabled:o.modelsLoading,onChange:O=>{x(O.target.value),P("")}},e.default.createElement("option",{value:""},d?"Choose a model":"Use the team model"),w&&!J?e.default.createElement("option",{value:w},w," (unavailable)"):null,o.models.map(O=>e.default.createElement("option",{key:O.id,value:O.id},O.label)))),o.modelsLoading?e.default.createElement("p",{role:"status"},"Loading native models\u2026"):o.models.length?null:e.default.createElement("p",null,"No models are available. Enable a model in DSH, then reload the model list."),g?null:e.default.createElement("p",{role:"alert"},"This model is unavailable. Choose a model from the native catalog."),e.default.createElement("label",null,"Reasoning effort",e.default.createElement("select",{value:b,disabled:!J,onChange:O=>P(O.target.value)},e.default.createElement("option",{value:""},"Model default"),J?.efforts?.map(O=>e.default.createElement("option",{key:O},O)))),G?e.default.createElement("label",{className:"dsh-hive-check"},e.default.createElement("input",{type:"checkbox",checked:q,onChange:O=>z(O.target.checked)}),"Resume now"):null,o.error?e.default.createElement("p",{role:"alert"},o.error.message):null,e.default.createElement("div",{className:"dsh-hive-actions"},e.default.createElement("button",{type:"button",disabled:o.modelsLoading,onClick:()=>{n.loadModels()}},"Reload models"),e.default.createElement("button",{type:"submit",className:"dsh-hive-primary",disabled:o.pending||!g||!T||d&&!w||!d&&(!i||!k.trim())},o.pending?"Saving\u2026":d?"Apply model":"Add member"))))}function No({workspace:o}){let n=[o?.cwd,o?.path,o].find(d=>typeof d=="string"&&d.trim());return n?e.default.createElement("dl",{className:"dsh-hive-member-workspace"},e.default.createElement("div",null,e.default.createElement("dt",null,"Workspace"),e.default.createElement("dd",{title:n},n))):null}function Co({state:o,controller:n,onJournal:d,onOpenSession:p,onMention:m}){let[i,N]=(0,e.useState)(""),[k,C]=(0,e.useState)(null),[y,c]=(0,e.useState)(null),[w,x]=(0,e.useState)(null),b=o.history.length?o.history:o.team.events??[],P=(0,e.useMemo)(()=>{let h=new Map;for(let W of b)W.kind!=="brief"&&W.author!=="system"&&h.set(W.author,W);return h},[b]),q=(0,e.useMemo)(()=>new Map(ot(o.team).map(h=>[h.name,h.tint])),[o.team]),z=i.trim().toLowerCase(),J=o.team.members.filter(h=>!z||[h.name,h.group,h.model,h.taskLabel,h.brief,...h.channels??[]].filter(Boolean).join(" ").toLowerCase().includes(z)),g=h=>h.role==="coordinator"||h.name==="coordinator"?0:h.recoveryRequired||["failed","quota"].includes(h.status)?1:h.status==="working"?2:["waiting","queued"].includes(h.status)?3:4,T=J.filter(h=>h.status!=="retired").sort((h,W)=>g(h)-g(W)),G=J.filter(h=>h.status==="retired"),$=h=>h?.stopPropagation?.(),O=h=>{let W=h.brief?.trim()??"",Z=W.length>220||/\n/.test(W),re=h.role==="coordinator"||h.name==="coordinator",pe=q.get(h.name),ie=!!Le(h),L=ie||re&&typeof o.team.parentSessionId=="string"&&o.team.parentSessionId.trim().length>0,R=P.get(h.name),a=h.recoveryRequired?"Outcome unconfirmed. Inspect the owned session before continuing.":Ot(h,o.team.activity?.[h.name],R)||Ae(W,180),A=re?"Coordinator":ut(h),r=re?null:pt(h.name,!1,pe),M=r?{"--tile-bg":r.bg,"--tile-border":r.border}:void 0,f=!re&&["done","retired"].includes(h.status),te=h.recoveryRequired||["working","failed","quota","stalled"].includes(h.status),Y=w===h.name,Me=ae=>{L&&(ae?.target?.closest?.('button, a, input, select, textarea, summary, details, .dsh-hive-row-menu, [role="button"]')||globalThis.getSelection?.()?.toString?.()||(x(null),p(h.name,ae.currentTarget)))},fe=L?ae=>{ae.target===ae.currentTarget&&(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),x(null),p(h.name,ae.currentTarget))}:void 0;return e.default.createElement("li",{key:h.name,className:"dsh-hive-member","data-role":re?"coordinator":"worker","data-status":h.status,"data-clickable":L?"true":void 0,"data-menu-open":Y?"true":void 0,tabIndex:L?0:void 0,title:L?"Click to open @"+h.name+" session":void 0,onClick:Me,onKeyDown:fe},e.default.createElement("div",{className:"dsh-hive-member-avatar","aria-hidden":"true"},e.default.createElement("div",{className:"dsh-hive-member-tile"+(re?" is-coordinator":""),style:M},e.default.createElement(Ee,{name:h.name,status:h.status,coordinator:re,tint:pe,muted:f,size:"md"})),h.status==="working"||h.recoveryRequired||["failed","quota"].includes(h.status)?e.default.createElement("span",{className:"dsh-hive-avatar-dot","data-tone":h.status==="working"?"working":"danger"}):null),e.default.createElement("div",{className:"dsh-hive-member-main"},e.default.createElement("div",{className:"dsh-hive-member-line1"},e.default.createElement("div",{className:"dsh-hive-member-ident"},e.default.createElement("h2",null,"@",h.name),e.default.createElement("span",{className:"dsh-hive-member-sub"},A)),e.default.createElement("div",{className:"dsh-hive-member-meta"},e.default.createElement(po,{mode:h.executionMode,subagentName:h.subagentName}),te?e.default.createElement(tt,{value:h.status,compactView:!0}):null,h.model?e.default.createElement("span",{className:"dsh-hive-member-model"},h.model,h.effort?" \xB7 "+h.effort:""):null,R?.seq?e.default.createElement("span",{className:"dsh-hive-mono dsh-hive-secondary"},"#",R.seq):null,e.default.createElement("div",{className:"dsh-hive-row-menu",onClick:$,onKeyDown:ae=>{ae.key==="Escape"&&($(ae),x(null))}},e.default.createElement("button",{type:"button",className:"dsh-hive-row-menu-btn","aria-label":"More actions for @"+h.name,"aria-expanded":Y,onClick:ae=>{$(ae),x(Y?null:h.name)}},"\u22EF"),e.default.createElement("div",{className:"dsh-hive-row-menu-pop","data-open":Y?"true":void 0},e.default.createElement("button",{type:"button",className:"dsh-hive-menu-item","aria-label":"Journal for "+h.name,disabled:!ie,onClick:ae=>{$(ae),x(null),d(h.name,ae.currentTarget)}},"Journal"),e.default.createElement("button",{type:"button",className:"dsh-hive-menu-item","aria-label":"Open session for @"+h.name,disabled:!L,onClick:ae=>{$(ae),x(null),p(h.name,ae.currentTarget)}},"Open session"),h.status!=="retired"&&!h.retireAfterTurn?e.default.createElement("button",{type:"button",className:"dsh-hive-menu-item","aria-label":"@mention @"+h.name+" on board",onClick:ae=>{$(ae),x(null),m(h.name)}},"@mention"):null,h.status==="working"?e.default.createElement("button",{type:"button",className:"dsh-hive-menu-item","aria-label":"Cancel turn for @"+h.name,disabled:o.pending,onClick:ae=>{$(ae),x(null),We(n,"cancel_turn",{member:h.name})}},"Cancel turn"):null,e.default.createElement("button",{type:"button",className:"dsh-hive-menu-item","aria-label":"Change model for @"+h.name,disabled:o.pending||h.status==="working"||h.status==="retired",onClick:ae=>{$(ae),x(null),C({member:h,opener:ae.currentTarget})}},"Change model"),e.default.createElement("button",{type:"button",className:"dsh-hive-menu-item","aria-label":"Retire @"+h.name,disabled:o.pending||h.status==="retired"||h.retireAfterTurn,onClick:ae=>{$(ae),x(null),c({member:h,opener:ae.currentTarget})}},h.retireAfterTurn?"Retiring after turn":"Retire"),h.workspace&&(h.status==="retired"||o.team.phase==="done")?e.default.createElement("button",{type:"button",className:"dsh-hive-menu-item",disabled:o.pending,"aria-label":"Clean worktree for @"+h.name,onClick:ae=>{$(ae),x(null),We(n,"remove_worktree",{member:h.name})}},"Clean worktree"):null,Z?e.default.createElement("details",{className:"dsh-hive-details dsh-hive-menu-brief",onClick:$},e.default.createElement("summary",null,"Full brief"),e.default.createElement("p",{className:"dsh-hive-prose"},W)):null)))),h.workspace||h.group||h.channels?.length||h.pendingWaitFor?.length||h.fallbackModel?e.default.createElement("div",{className:"dsh-hive-member-chips"},e.default.createElement(No,{workspace:h.workspace}),h.group?e.default.createElement("span",{className:"dsh-hive-chip"},"@",h.group):null,h.channels?.length?e.default.createElement("span",{className:"dsh-hive-chip"},h.channels.map(ae=>"#"+ae).join(" ")):null,h.pendingWaitFor?.length?e.default.createElement("span",{className:"dsh-hive-chip","data-tone":"wait"},"Waiting on ",h.pendingWaitFor.map(ae=>"@"+ae).join(", ")):null,h.fallbackModel?e.default.createElement("span",{className:"dsh-hive-chip"},"Fallback: ",h.fallbackModel,h.fallbackEffort?" \xB7 "+h.fallbackEffort:""):null):null,a?e.default.createElement("p",{className:"dsh-hive-member-preview",title:a},a):null,h.recoveryRequired?e.default.createElement("div",{className:"dsh-hive-actions dsh-hive-inline-actions",onClick:$},e.default.createElement(Re,{memberName:h.name,pending:o.pending||h.status==="working",controller:n})):null))};return e.default.createElement("div",{className:"dsh-hive-members-view"},e.default.createElement("div",{className:"dsh-hive-member-bar"},e.default.createElement("label",{className:"dsh-hive-search-box"},e.default.createElement(Ut,null),e.default.createElement("input",{type:"search","aria-label":"Find a member",placeholder:"Search members",value:i,onChange:h=>N(h.target.value)})),e.default.createElement("button",{type:"button",className:"dsh-hive-compact-btn",disabled:o.pending,onClick:h=>C({member:null,opener:h.currentTarget})},"Add member")),T.length?e.default.createElement("ul",{className:"dsh-hive-members"},T.map(O)):G.length?null:e.default.createElement("p",{className:"dsh-hive-secondary"},"No members match your search."),G.length?e.default.createElement("details",{className:"dsh-hive-retired-group",open:!0},e.default.createElement("summary",{className:"dsh-hive-retired-summary"},e.default.createElement("span",null,"RETIRED"),e.default.createElement("span",{className:"dsh-hive-retired-count"},G.length),e.default.createElement(ct,null)),e.default.createElement("ul",{className:"dsh-hive-members"},G.map(O))):null,k?e.default.createElement(So,{key:k.member?.name??"new",...k,state:o,controller:n,onClose:()=>C(null)}):null,y?e.default.createElement(nt,{title:"Retire "+y.member.name+"?",opener:y.opener,onClose:()=>c(null)},e.default.createElement("p",null,"This member will receive no further turns. Its Journal and session remain available."),o.error?e.default.createElement("p",{role:"alert"},o.error.message):null,e.default.createElement("button",{type:"button",disabled:o.pending,onClick:async()=>{try{await n.command("retire_member",{member:y.member.name}),c(null)}catch{}}},"Retire member")):null)}function To(){try{let o=globalThis.sessionStorage?.getItem?.(Ft);return o==="mentions"||o==="hive"?o:"hive"}catch{return"hive"}}function qo(o){try{globalThis.sessionStorage?.setItem?.(Ft,o)}catch{}}function Io(o){let n=typeof document<"u"?document.documentElement?.dataset?.theme:void 0;if(n==="dark"||n==="light")return n;try{if(o&&typeof getComputedStyle=="function"){let d=getComputedStyle(o),p=d.colorScheme;if(p==="dark"||p==="light")return p;let m=/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/.exec(d.backgroundColor??"");if(m)return .299*Number(m[1])+.587*Number(m[2])+.114*Number(m[3])<128?"dark":"light"}}catch{}try{if(globalThis.matchMedia?.("(prefers-color-scheme: dark)")?.matches)return"dark"}catch{}return"light"}function zo(o,n){let d=Math.cos(n),p=Math.sin(n),m=(i,N)=>(o.x+i*d-N*p).toFixed(1)+","+(o.y+i*p+N*d).toFixed(1);return m(1,0)+" "+m(-8,-3.8)+" "+m(-6.1,0)+" "+m(-8,3.8)}function Lo(o,n,d){let p=n??[],m=!p.some(g=>(g.role==="coordinator"||g.name==="coordinator")&&!g.external)&&!p.some(g=>g.name==="user"),i=g=>m&&g==="user"?"coordinator":g,N=o.filter(g=>g.seq<=d&&Te.default.isPost(g)),k=N.at(-1)??null,C=d>=(o.at(-1)?.seq??0),y=p.find(g=>g.role==="coordinator"||g.name==="coordinator")??{name:"coordinator",role:"coordinator",status:"waiting"},c=p.filter(g=>g.role!=="coordinator"&&g.name!=="coordinator"),w=new Map;for(let g of N)w.set(i(g.author),g.seq);let x=[{id:"working",label:"Working",tone:"working",members:[]},{id:"waiting",label:"Waiting",tone:"waiting",members:[]},{id:"needs",label:"Needs you",tone:"needs",members:[]},{id:"done",label:"Done",tone:"done",members:[]}],b=new Map(x.map(g=>[g.id,g]));for(let g of c){let T=C?g.status:w.has(g.name)&&g.status==="done"?"done":"waiting",G=g.recoveryRequired||["failed","quota"].includes(T)?"needs":T==="working"?"working":["done","retired"].includes(T)?"done":"waiting";b.get(G).members.push({name:g.name,status:T,role:g.role??"worker",tint:g.tint,muted:["done","retired"].includes(T),latestSeq:w.get(g.name)??0,pendingWaitFor:g.pendingWaitFor??[]})}let P=x.filter(g=>g.members.length>0).map(g=>({...g,count:g.members.length})),q=b.get("done").members.length,z=b.get("needs").members.length?"stalled":b.get("working").members.length?"working":c.length&&q===c.length?"done":"waiting",J=[];if(b.get("done").members.length&&J.push({from:"done",to:"coordinator",kind:"done",label:"Tasks done"}),k){let g=i(k.author),T=g==="coordinator"?"coordinator":P.find($=>$.members.some(O=>O.name===g))?.id,G=[...(k.targets??[]).map(i),...k.coordinatorMention?["coordinator"]:[]];for(let $ of G){let O=$==="coordinator"?"coordinator":P.find(h=>h.members.some(W=>W.name===$))?.id;if(T&&O&&T!==O){J.push({from:T,to:O,kind:"message",label:"Message just sent",seq:k.seq});break}}}for(let g of P)for(let T of g.members)for(let G of T.pendingWaitFor??[]){let $=P.find(O=>O.members.some(h=>h.name===G))?.id;$&&$!==g.id&&!J.some(O=>O.kind==="waiting"&&O.from===g.id&&O.to===$)&&J.push({from:g.id,to:$,kind:"waiting",label:"Waiting on"})}return{currentSeq:k?.seq??0,lastPost:k,coordinator:{name:"coordinator",status:y.status,role:"coordinator",doneCount:q,totalWorkers:c.length,phase:z,latestSeq:w.get("coordinator")??0,tint:0},clusters:P,connectors:J}}function dt(o,n,d){return Array.from({length:6},(p,m)=>({x:o+d*Math.cos(m*Math.PI/3),y:n+d*Math.sin(m*Math.PI/3)}))}function Ht(o,n,d,p){if(!p.length)return[];let m=p.length,i=m<=2?m:m<=6?3:4,N=Math.ceil(m/i),k=d*1.48,C=Math.min(72,Math.max(46,k/i)),y=N===1?0:N===2?46:38,c=n-(N-1)*y/2+14;return p.map((w,x)=>{let b=Math.floor(x/i),P=Math.min(i,m-b*i),q=x%i,z=o+(q-(P-1)/2)*C,J=c+b*y;return{member:w,x:z,y:J,slotWidth:C,beeScale:N>=3?.9:1}})}function Ho(o,n,d){let p=o.clusters??[],m=18,i=new Map,N,k,C=[];if(!p.length)N=Math.max(76,Math.min(118,n*.24,d*.32)),k={x:n/2,y:d/2};else if(p.length===1){N=Math.max(76,Math.min(120,n*.24,(d-36)/(2*Math.sqrt(3)+.35)));let c=N*Math.sqrt(3)/2,w=d/2,x=c+m/2,b=p[0],P={x:n/2,y:w-x};k={x:n/2,y:w+x};let q={...b,x:P.x,y:P.y,radius:N,vertices:dt(P.x,P.y,N),slots:Ht(P.x,P.y,N,b.members)};C.push(q),i.set(b.id,q)}else{k={x:n/2,y:d*.7};let c=p.length===2?Math.PI*.44:p.length===3?Math.PI*.64:Math.PI*.74,w=c/(p.length-1),x=Math.max(110,Math.min(n*.34,k.y-82)),b=Math.min(x,2*x*Math.sin(w/2)),P=Math.max(46,(b-m)/2);N=Math.max(54,Math.min(92,P/(Math.sqrt(3)/2))),p.forEach((q,z)=>{let J=-Math.PI/2-c/2+z*w,g=k.x+Math.cos(J)*x,T=k.y+Math.sin(J)*x,G={...q,x:g,y:T,radius:N,vertices:dt(g,T,N),slots:Ht(g,T,N,q.members)};C.push(G),i.set(q.id,G)})}let y={id:"coordinator",x:k.x,y:k.y,radius:N,vertices:dt(k.x,k.y,N),model:o.coordinator};return i.set("coordinator",y),{width:n,height:d,radius:N,coordinator:y,clusters:C,cellsById:i}}function Pt(o,n){let d=o*Math.sqrt(3)/2,p=1/0;for(let m of[Math.PI/6,Math.PI/2,5*Math.PI/6,-Math.PI/6,-Math.PI/2,-5*Math.PI/6]){let i=Math.cos(n-m);i>1e-4&&(p=Math.min(p,d/i))}return p}function Po(o,n,d){let p=new Map;if(!o.length)return p;if(o.length>12||n<300)return Te.default.layout(o,n,d);let m=o.findIndex(b=>b.role==="coordinator"||b.name==="coordinator"),i=m>=0?[o[m],...o.filter((b,P)=>P!==m)]:o,N=42,k=42,C=Math.min(92,Math.max(58,n*.14)),y=n/2,c=(N+(d-k))/2,w=Math.max(56,Math.min(n*.38,n/2-C)),x=Math.max(46,(d-N-k)/2);return i.length===1?(p.set(i[0].name,{x:y,y:c}),p):(i.forEach((b,P)=>{let q=-Math.PI/2+P*(Math.PI*2/i.length);p.set(b.name,{x:y+Math.cos(q)*w,y:c+Math.sin(q)*x})}),p)}function Ao(o,n){if(typeof Te.default.nodeBox=="function"){let i=Te.default.nodeBox(o,{variant:"pill",narrow:n});if(i&&i.radius>=i.halfH-1)return i}let d=String(o?.name??""),p=n?14:16;return{halfW:Math.max(44,Math.min(96,24+d.length*4.1)),halfH:p,offsetX:0,offsetY:0,radius:p}}function Bo({state:o,controller:n,onJournal:d,onJumpPost:p}){let[m,i]=(0,e.useState)(To),[N,k]=(0,e.useState)(null),[C,y]=(0,e.useState)(!1),[c,w]=(0,e.useState)("even"),[x,b]=(0,e.useState)(1),[P,q]=(0,e.useState)(!1),[z,J]=(0,e.useState)(!1),[g,T]=(0,e.useState)(null),[G,$]=(0,e.useState)(null),[O,h]=(0,e.useState)(null),[W,Z]=(0,e.useState)({busy:!1,message:"",error:!1}),re=(0,e.useRef)(null),pe=(0,e.useRef)(null),ie=(0,e.useRef)(new Map),[L,R]=(0,e.useState)(480),a=(0,e.useId)().replaceAll(":","");(0,e.useEffect)(()=>{let s=pe.current;if(!s||typeof ResizeObserver>"u")return;let D=new ResizeObserver(S=>R(Math.max(280,S[0].contentRect.width)));return D.observe(s),()=>D.disconnect()},[]);let A=(0,e.useMemo)(()=>ot(o.team),[o.team]),r=(0,e.useMemo)(()=>o.history.filter(Te.default.isPost),[o.history]),M=N===null?r.length:Math.max(0,Math.min(r.length,r.findIndex(s=>s.seq>N)===-1?r.length:r.findIndex(s=>s.seq>N))),f=r[M-1],te=f?.seq??0;(0,e.useEffect)(()=>{if(!C)return;if(M>=r.length){y(!1);return}let s=Date.parse(r[M].time)-Date.parse(r[M-1]?.time),D=c==="real"&&Number.isFinite(s)?Math.max(110,Math.min(s,2e3)):620,S=setTimeout(()=>{k(r[M].seq)},D/x);return()=>clearTimeout(S)},[C,M,r,c,x]);let Y=s=>{y(!1),k(r[s-1]?.seq??0)},Me=()=>{if(C){y(!1);return}r.length&&((N===null||M>=r.length)&&k(0),y(!0))},fe=s=>{s!==m&&(i(s),qo(s),T(null),$(null))},ae=L<440,xe=Te.default.elapsedSpan(r.slice(0,M),{live:N===null&&["working","queued"].includes(o.team.phase)}),Ce=(0,e.useMemo)(()=>m!=="hive"?null:typeof Te.default.projectHive=="function"?Te.default.projectHive(r,A,te):Lo(r,A,te),[m,r,A,te]),Ne=(0,e.useMemo)(()=>{if(m!=="hive"||!Ce)return 420;let s=typeof Te.default.hiveMinimumHeight=="function"?Te.default.hiveMinimumHeight(Ce.clusters.length,L):Ce.clusters.length<=1?400:440;return Math.max(380,s)},[m,Ce,L]),ge=(0,e.useMemo)(()=>m!=="hive"||!Ce?null:typeof Te.default.layoutHive=="function"?Te.default.layoutHive(Ce,L,Ne):Ho(Ce,L,Ne),[m,Ce,L,Ne]),we=(0,e.useMemo)(()=>Te.default.project(r,A,te,{hideInactive:P,expandBroadcast:z}),[r,A,te,P,z]),t=(0,e.useMemo)(()=>typeof Te.default.mentionsMinimumHeight=="function"?Math.max(380,Te.default.mentionsMinimumHeight(we.nodes.length,L)):Math.max(380,Te.default.minimumHeight(we.nodes.length,L)),[we.nodes.length,L]),l=(0,e.useMemo)(()=>m!=="mentions"?new Map:typeof Te.default.layoutMentions=="function"?Te.default.layoutMentions(we.nodes,L,t):Po(we.nodes,L,t),[m,we.nodes,L,t]);ao(()=>{if(m!=="mentions")return;let s=new Map,D=!1;for(let S of we.nodes){let I=ie.current.get(S.name);if(I&&I.offsetWidth>0&&I.offsetHeight>0){let F=I.offsetHeight/2,V={halfW:I.offsetWidth/2,halfH:F,offsetX:0,offsetY:0,radius:F};s.set(S.name,V);let ne=O?.get(S.name);(!ne||Math.abs(ne.halfW-V.halfW)>.5||Math.abs(ne.halfH-V.halfH)>.5)&&(D=!0)}}s.size&&(D||!O||O.size!==s.size)&&h(s)},[m,we.nodes,L,ae]);let u=(0,e.useMemo)(()=>{if(m!=="mentions")return null;if(O&&O.size===we.nodes.length)return O;let s=new Map;for(let D of we.nodes)s.set(D.name,O?.get(D.name)??Ao(D,ae));return s},[m,we.nodes,O,ae]),v=(0,e.useMemo)(()=>m!=="mentions"?[]:Te.default.routeEdges(we,l,{variant:"pill",boxes:u,narrow:ae,marginStart:5,marginEnd:6,obstacleMargin:ae?14:22}),[m,we,l,u,ae]),E=G?G.split(">"):null,j=(0,e.useMemo)(()=>{if(E)return new Set(E);if(!g)return null;let s=new Set([g]);for(let D of we.links)D.from===g&&s.add(D.to),D.to===g&&s.add(D.from);return s},[g,G,we.links]),ee=m==="hive"?Ne:t,oe=g?A.find(s=>s.name===g):null,Q=typeof Te.default.shouldMergeUserToCoordinator=="function"?Te.default.shouldMergeUserToCoordinator(A):!A.some(s=>(s.role==="coordinator"||s.name==="coordinator")&&!s.external)&&!A.some(s=>s.name==="user"),se=s=>s==="user"?"You":s==="system"?"System":s,B=s=>s==="user"?"You":s==="system"?"System":"@"+s,H=Q&&f?.author==="user"?"coordinator":f?.author;async function ce(){if(!r.length||W.busy)return;let s=(typeof globalThis.HiveGif?.exportGraphReplayGif=="function"?globalThis.HiveGif:null)??Bt.default;if(typeof s?.exportGraphReplayGif!="function"){Z({busy:!1,message:"GIF export is unavailable until the GIF module is bundled.",error:!0});return}Z({busy:!0,message:"Rendering GIF replay\u2026",error:!1});try{let D=Io(re.current),S=await Promise.resolve(s.exportGraphReplayGif({mode:m,posts:r,members:A,phase:o.team.phase,pacing:c,speed:x,hideInactive:P,expandBroadcast:z,focus:g,theme:D,width:Math.max(480,Math.round(L)),height:Math.max(360,Math.round(ee)),graph:Te.default,bees:De.default})),I=typeof Blob<"u"&&S?.blob instanceof Blob?S.blob:S?.bytes&&typeof Blob<"u"?new Blob([S.bytes],{type:"image/gif"}):null;if(!I&&!S?.bytes)throw Error("GIF encoder returned empty data.");let V=((o.team.title||"hive-swarm").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"hive-swarm")+"-graph.gif";if(I&&typeof URL.createObjectURL=="function"&&typeof document<"u"&&typeof document.createElement=="function"){let ne=URL.createObjectURL(I),X=document.createElement("a");X.href=ne,X.download=V,X.style.display="none",document.body?.appendChild?.(X),X.click?.(),X.remove?.(),setTimeout(()=>{try{URL.revokeObjectURL(ne)}catch{}},1e3)}Z({busy:!1,message:"Exported "+V+(S.frameCount?" ("+S.frameCount+" frames)":"")+".",error:!1})}catch(D){Z({busy:!1,message:"GIF export failed: "+(D?.message??String(D)),error:!0})}}let _=s=>s==="done"?"done":s==="working"||s==="active"?"working":s==="needs"||s==="stalled"||s==="blocked"?"needs":"waiting";return e.default.createElement("div",{ref:re,className:"dsh-hive-graph-view"},e.default.createElement("div",{className:"dsh-hive-graph-controls"},e.default.createElement("div",{className:"dsh-hive-replay-row1"},e.default.createElement("div",{className:"dsh-hive-actions dsh-hive-transport"},e.default.createElement("button",{type:"button","aria-label":"First post",disabled:!r.length||M===1,onClick:()=>Y(1)},"|\u2039"),e.default.createElement("button",{type:"button","aria-label":"Previous post",disabled:M===0,onClick:()=>Y(Math.max(0,M-1))},"\u2039"),e.default.createElement("button",{type:"button","aria-label":C?"Pause replay":"Replay",disabled:!r.length,onClick:Me},C?"\u2161":"\u25B6"),e.default.createElement("button",{type:"button","aria-label":"Next post",disabled:M>=r.length,onClick:()=>Y(M+1)},"\u203A")),e.default.createElement("input",{className:"dsh-hive-scrubber","aria-label":"Replay through post",type:"range",min:"0",max:r.length,value:M,onChange:s=>Y(Number(s.target.value))}),e.default.createElement("button",{type:"button",className:"dsh-hive-live-btn","aria-pressed":N===null,onClick:()=>{y(!1),k(null)}},e.default.createElement("span",{className:"dsh-hive-status-dot","aria-hidden":"true"}),"Live")),e.default.createElement("div",{className:"dsh-hive-replay-row2"},e.default.createElement("span",{className:"dsh-hive-graph-stat"},e.default.createElement("strong",null,r.length," posts")," over ",xe,N!==null?" \xB7 "+M+"/"+r.length:""),e.default.createElement("div",{className:"dsh-hive-segmented",role:"group","aria-label":"Graph view mode"},e.default.createElement("button",{type:"button","aria-pressed":m==="hive",onClick:()=>fe("hive")},"Hive"),e.default.createElement("button",{type:"button","aria-pressed":m==="mentions",onClick:()=>fe("mentions")},"Mentions")),e.default.createElement("div",{className:"dsh-hive-graph-options"},e.default.createElement("label",{className:"dsh-hive-inline-select"},e.default.createElement("span",{className:"dsh-hive-sr-only"},"Pacing"),e.default.createElement("select",{"aria-label":"Pacing",value:c,onChange:s=>w(s.target.value)},e.default.createElement("option",{value:"even"},"Even pacing"),e.default.createElement("option",{value:"real"},"Real-time"))),e.default.createElement("label",{className:"dsh-hive-inline-select"},e.default.createElement("span",{className:"dsh-hive-sr-only"},"Speed"),e.default.createElement("select",{"aria-label":"Speed",value:x,onChange:s=>b(Number(s.target.value))},e.default.createElement("option",{value:"0.5"},"0.5\xD7"),e.default.createElement("option",{value:"1"},"1\xD7"),e.default.createElement("option",{value:"2"},"2\xD7"),e.default.createElement("option",{value:"4"},"4\xD7"))),m==="mentions"?e.default.createElement("div",{className:"dsh-hive-graph-toggles"},e.default.createElement("label",{className:"dsh-hive-switch"},e.default.createElement("input",{type:"checkbox",role:"switch",className:"dsh-hive-switch-input",checked:P,onChange:s=>q(s.target.checked)}),e.default.createElement("span",{className:"dsh-hive-switch-track","aria-hidden":"true"}),e.default.createElement("span",null,"Hide inactive")),e.default.createElement("label",{className:"dsh-hive-switch"},e.default.createElement("input",{type:"checkbox",role:"switch",className:"dsh-hive-switch-input",checked:z,onChange:s=>J(s.target.checked)}),e.default.createElement("span",{className:"dsh-hive-switch-track","aria-hidden":"true"}),e.default.createElement("span",null,"Expand @all"))):null,e.default.createElement("button",{type:"button",className:"dsh-hive-export-gif",disabled:!r.length||W.busy,onClick:()=>{ce()}},e.default.createElement("span",{"aria-hidden":"true"},"\u2B07"),W.busy?"Exporting\u2026":"Export GIF"),o.hasMoreHistory?e.default.createElement("button",{type:"button",className:"dsh-hive-ghost-btn",disabled:o.historyLoading,onClick:()=>{n.loadHistory()}},"Load earlier"):null)),W.message?e.default.createElement("p",{role:"status",className:W.error?"dsh-hive-gif-error":"dsh-hive-secondary"},W.message):null),m==="hive"&&ge?e.default.createElement(e.default.Fragment,null,e.default.createElement("div",{ref:pe,className:"dsh-hive-graph dsh-hive-graph-hive",style:{height:Ne},role:"group","aria-label":"Hive cluster graph"},e.default.createElement("svg",{width:"100%",height:Ne,viewBox:"0 0 "+L+" "+Ne,"aria-hidden":"true"},e.default.createElement("defs",null,e.default.createElement("marker",{id:a,markerUnits:"userSpaceOnUse",markerWidth:"10",markerHeight:"10",refX:"8.5",refY:"5",orient:"auto"},e.default.createElement("path",{d:"M0.5 1.2L9.5 5L0.5 8.8L2.4 5Z",fill:"context-stroke"}))),ge.clusters.map(s=>e.default.createElement("g",{key:s.id,className:"dsh-hive-hex-cell","data-tone":_(s.tone)},e.default.createElement("polygon",{points:s.vertices.map(D=>D.x.toFixed(1)+","+D.y.toFixed(1)).join(" "),className:"dsh-hive-hex-poly"}),e.default.createElement("text",{x:s.x,y:s.y-s.radius*.56,textAnchor:"middle",className:"dsh-hive-hex-title"},s.label),e.default.createElement("text",{x:s.x,y:s.y-s.radius*.41,textAnchor:"middle",className:"dsh-hive-hex-count"},s.count))),e.default.createElement("g",{className:"dsh-hive-hex-cell","data-role":"coordinator","data-tone":_(ge.coordinator.model.phase==="done"?"done":ge.coordinator.model.phase==="stalled"?"needs":"working")},e.default.createElement("polygon",{points:ge.coordinator.vertices.map(s=>s.x.toFixed(1)+","+s.y.toFixed(1)).join(" "),className:"dsh-hive-hex-poly"}),e.default.createElement("text",{x:ge.coordinator.x,y:ge.coordinator.y+ge.coordinator.radius*.34,textAnchor:"middle",className:"dsh-hive-hex-title"},"Coordinator"),e.default.createElement("text",{x:ge.coordinator.x,y:ge.coordinator.y+ge.coordinator.radius*.5,textAnchor:"middle",className:"dsh-hive-hex-count"},ge.coordinator.model.doneCount," of ",ge.coordinator.model.totalWorkers," done")),(Ce?.connectors??[]).map((s,D)=>{let S=ke=>ge.cellsById?.get?.(ke)??ge.cellsById?.[ke]??(ke==="coordinator"?ge.coordinator:ge.clusters.find(qe=>qe.id===ke)),I=S(s.from),F=S(s.to);if(!I||!F||I===F)return null;let V=F.x-I.x,ne=F.y-I.y,X=Math.hypot(V,ne);if(X<2)return null;let de=Math.atan2(ne,V),K=s.kind==="message"?8:s.kind==="waiting"?-8:0,le=K?6:3,he=Pt(I.radius,de)+le,me=Pt(F.radius,de+Math.PI)+le;if(he+me>=X)return null;let Se=-Math.sin(de),ue=Math.cos(de),U=I.x+Math.cos(de)*he+Se*K,ve=I.y+Math.sin(de)*he+ue*K,be=F.x-Math.cos(de)*me+Se*K,ye=F.y-Math.sin(de)*me+ue*K;return e.default.createElement("line",{key:s.from+">"+s.to+":"+s.kind+":"+D,x1:U.toFixed(1),y1:ve.toFixed(1),x2:be.toFixed(1),y2:ye.toFixed(1),className:"dsh-hive-hex-connector","data-kind":s.kind,strokeDasharray:s.kind==="waiting"?"4 4":void 0,markerEnd:s.kind==="waiting"?"url(#"+a+")":void 0})})),ge.clusters.flatMap(s=>s.slots.map(D=>{let S=D.member,I=g===S.name;return e.default.createElement("button",{key:S.name,type:"button",className:"dsh-hive-hex-bee-btn","data-status":S.status,"aria-pressed":I,style:{left:D.x/L*100+"%",top:D.y,maxWidth:D.slotWidth},title:"@"+S.name+" \xB7 "+(_e[S.status]??S.status),"aria-label":"Inspect @"+S.name+" ("+(_e[S.status]??S.status)+")",onClick:()=>T(I?null:S.name)},e.default.createElement(Ee,{name:S.name,status:S.status,tint:S.tint,muted:S.muted,size:"hive"}),e.default.createElement("span",{className:"dsh-hive-hex-bee-name"},S.name))})),e.default.createElement("button",{type:"button",className:"dsh-hive-hex-coord-btn","aria-pressed":g==="coordinator",style:{left:ge.coordinator.x/L*100+"%",top:ge.coordinator.y-ge.coordinator.radius*.14},"aria-label":"Inspect Coordinator",onClick:()=>T(g==="coordinator"?null:"coordinator")},e.default.createElement(Ee,{name:"coordinator",status:ge.coordinator.model.phase==="working"?"working":"active",coordinator:!0,size:"lg"}))),e.default.createElement("div",{className:"dsh-hive-graph-legend"},e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"done"},"Tasks done"),e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"message"},"Message just sent"),e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"waiting"},"Waiting on"))):e.default.createElement(e.default.Fragment,null,e.default.createElement("div",{ref:pe,className:"dsh-hive-graph dsh-hive-graph-mentions",style:{height:t},role:"group","aria-label":"Message flow graph"},e.default.createElement("svg",{width:"100%",height:t,viewBox:"0 0 "+L+" "+t,"aria-hidden":"true"},e.default.createElement("defs",null,e.default.createElement("marker",{id:a,markerUnits:"userSpaceOnUse",markerWidth:"10",markerHeight:"10",refX:"8.5",refY:"5",orient:"auto"},e.default.createElement("path",{d:"M0.5 1.2L9.5 5L0.5 8.8L2.4 5Z",fill:"context-stroke"}))),v.map(({link:s,edge:D})=>{let S=s.from+">"+s.to,I=!!(f&&s.lastSeq===f.seq),F=G===S,V=G?F:!g||g===s.from||g===s.to,ne=F||I&&V,X=Math.min(4.2,1.1+Math.sqrt(s.count)*.72),de=V&&D.length>=36&&(s.count>1||ne||F),K=String(s.count),le=Math.max(18,K.length*7+8);return e.default.createElement("g",{key:S,className:"dsh-hive-edge-group","data-active":ne?"true":void 0},e.default.createElement("path",{d:D.d,fill:"none",stroke:"transparent",strokeWidth:"14",className:"dsh-hive-edge-hit",onMouseEnter:()=>$(S),onMouseLeave:()=>$(he=>he===S?null:he)}),e.default.createElement("path",{"data-hive-edge":S,d:D.d,className:"dsh-hive-edge","data-active":ne?"true":void 0,strokeWidth:ne?Math.max(2.4,X+.4):X,strokeDasharray:s.direct?void 0:"4 4",opacity:V?ne?1:.72:.16,markerEnd:"url(#"+a+")"}),ne?e.default.createElement("polygon",{className:"dsh-hive-edge-tip",points:zo(D.end,D.endAngle)}):null,de?e.default.createElement("g",{className:"dsh-hive-edge-pill","data-active":ne?"true":void 0,transform:"translate("+D.mid.x.toFixed(1)+","+D.mid.y.toFixed(1)+")"},e.default.createElement("rect",{x:-le/2,y:"-8",width:le,height:"16",rx:"8"}),e.default.createElement("text",{textAnchor:"middle",dominantBaseline:"central"},K)):null)})),we.nodes.map(s=>{let D=l.get(s.name)??{x:L/2,y:t/2},S=Te.default.unmentionedNode(s),I=s.role==="coordinator"||s.name==="coordinator",F=s.status==="retired",V=!I&&["done","retired"].includes(s.status),ne=!!(j&&!j.has(s.name)),X=se(s.name);return e.default.createElement("button",{key:s.name,ref:de=>{de?ie.current.set(s.name,de):ie.current.delete(s.name)},type:"button",className:"dsh-hive-graph-pill","data-role":I?"coordinator":"worker","data-status":s.status??"observer","data-retired":F?"true":void 0,"data-unmentioned":S?"true":void 0,"data-dimmed":ne?"true":void 0,style:{left:D.x/L*100+"%",top:D.y},"aria-pressed":g===s.name,title:X+" \xB7 "+(_e[s.status]??s.status)+(S?" \xB7 Posted with no mention":""),onClick:()=>T(g===s.name?null:s.name)},e.default.createElement(Ee,{name:s.name,status:s.status,coordinator:I,tint:s.tint,muted:V,size:"sm"}),e.default.createElement("span",{className:"dsh-hive-graph-pill-name"},X),e.default.createElement("span",{className:"dsh-hive-node-dot","aria-hidden":"true"}),s.broadcasts?e.default.createElement("span",{className:"dsh-hive-node-broadcast"},"@all ",s.broadcasts):null)})),e.default.createElement("div",{className:"dsh-hive-graph-legend"},e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"mention"},"@mention, width = count"),e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"broadcast"},"via @all"),e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"unmentioned"},"posted with no mention"),e.default.createElement("span",{className:"dsh-hive-legend-item","data-legend":"all-badge"},e.default.createElement("span",{className:"dsh-hive-all-badge"},"@all ",we.broadcasts),"@all posts, drawn by Expand @all"))),g&&oe?e.default.createElement("section",{className:"dsh-hive-selected-post"},e.default.createElement("div",{className:"dsh-hive-line"},e.default.createElement($e,{member:oe,name:oe.name==="user"?"You":void 0,coordinator:oe.role==="coordinator"||oe.name==="coordinator",muted:oe.status==="retired"}),e.default.createElement(tt,{value:oe.status}),e.default.createElement("div",{className:"dsh-hive-pill-group"},Le(oe)?e.default.createElement("button",{type:"button",onClick:s=>d(g,s.currentTarget)},"Inspect @",g," Journal"):null,e.default.createElement("button",{type:"button",className:"dsh-hive-ghost-btn",onClick:()=>T(null)},"Clear"))),f&&H===g?e.default.createElement(Oe,{text:f.text,onJumpPost:p}):null):null,f?e.default.createElement("section",{className:"dsh-hive-selected-post"},e.default.createElement("div",{className:"dsh-hive-line"},e.default.createElement("h3",null,"Selected post"),e.default.createElement("strong",null,B(f.author)),e.default.createElement(je,{seq:f.seq,onJumpPost:p})),e.default.createElement(Oe,{text:f.text,onJumpPost:p})):null,m==="mentions"&&(we.links.length?e.default.createElement("ul",{className:"dsh-hive-flow-list","aria-label":"Message flow counts"},we.links.filter(s=>!g||s.from===g||s.to===g).map(s=>e.default.createElement("li",{key:s.from+">"+s.to},B(s.from)," \u2192 ",B(s.to),": ",s.count," ",s.count===1?"mention":"mentions"))):e.default.createElement("p",{className:"dsh-hive-secondary"},"No directed mentions at this point in the replay.")))}function Fo(){try{return globalThis.localStorage?.getItem?.(Et)??null}catch{return null}}function Eo(o){try{globalThis.localStorage?.setItem?.(Et,o)}catch{}}function Wo({version:o,update:n}){let[d,p]=(0,e.useState)(!1),[m,i]=(0,e.useState)(!1),[N,k]=(0,e.useState)(()=>Fo()),C=(0,e.useRef)(null),y=typeof n?.latest=="string"?n.latest.trim():"",c=!!(n?.available===!0&&y&&ho.test(y)&&N!==y);if((0,e.useEffect)(()=>{c||p(!1)},[c,y]),(0,e.useEffect)(()=>{if(!d||typeof document>"u"||typeof document.addEventListener!="function")return;let z=g=>{C.current?.contains?.(g.target)||p(!1)},J=g=>{g.key==="Escape"&&p(!1)};return document.addEventListener("pointerdown",z),document.addEventListener("keydown",J),()=>{document.removeEventListener("pointerdown",z),document.removeEventListener("keydown",J)}},[d]),!c)return null;let w="dsh plugin --profile desktop add dsh-hive-swarm@"+y,x=_t(n?.url)??"https://github.com/snowmiku601-cpu/hive-swarm/releases/tag/v"+y,b=o||(typeof n?.current=="string"?n.current.trim():""),P=async()=>{try{await globalThis.navigator?.clipboard?.writeText?.(w)}catch{}i(!0),setTimeout(()=>i(!1),1800)},q=()=>{Eo(y),k(y),p(!1)};return e.default.createElement("div",{ref:C,className:"dsh-hive-update-wrap"},e.default.createElement("button",{type:"button",className:"dsh-hive-update-pill","aria-expanded":d,title:"Hive Swarm v"+y+" is available on npm",onClick:()=>p(z=>!z)},"\u2191 v",y," available"),d?e.default.createElement("div",{className:"dsh-hive-update-popover",role:"region","aria-label":"Update available"},e.default.createElement("div",{className:"dsh-hive-update-head"},e.default.createElement("strong",null,"Update available"),e.default.createElement("span",{className:"dsh-hive-mono"},b?"v"+b+" \u2192 v"+y:"v"+y)),e.default.createElement("p",{className:"dsh-hive-secondary"},"Close DSH Desktop after active turns finish, then run:"),e.default.createElement("code",{className:"dsh-hive-update-cmd"},w),e.default.createElement("div",{className:"dsh-hive-update-actions"},e.default.createElement("button",{type:"button",className:"dsh-hive-ghost-btn",onClick:()=>{P()}},m?"Copied":"Copy command"),e.default.createElement("a",{href:x,target:"_blank",rel:"noopener noreferrer"},"Release notes"),e.default.createElement("button",{type:"button",className:"dsh-hive-ghost-btn",onClick:q},"Dismiss"))):null)}var ht=["Overview","Board","Members","Graph"];function Gt({controller:o,onExpand:n,mode:d="dock",visible:p=!0}){let m=(0,e.useSyncExternalStore)(o.subscribe,o.getSnapshot,o.getSnapshot),i={...m,pending:m.pending||m.connection!=="connected"},[N,k]=(0,e.useState)("Overview"),[C,y]=(0,e.useState)(null),[c,w]=(0,e.useState)(!1),[x,b]=(0,e.useState)(""),[P,q]=(0,e.useState)(null),[z,J]=(0,e.useState)(null),g=(0,e.useRef)([]),T=(0,e.useId)().replace(/[^a-zA-Z0-9_-]/g,""),G=(0,e.useRef)(!1);(0,e.useEffect)(()=>{if(!p)return;let r=o.retain();return()=>{G.current&&(o.closeJournal(),G.current=!1),r()}},[o,p]),(0,e.useEffect)(()=>{w(!1),q(null),J(null)},[i.team?.id]);let $=(r,M)=>{G.current=!0,y({opener:M,controller:o}),o.openJournal(r)},O=async(r,M)=>{await o.openSession(r,{fallbackToJournal:!1})==="fallback"&&$(r,M)},h=()=>{G.current=!1,y(null),o.closeJournal()},W=r=>{q(r),k("Board"),i.history.some(M=>M.seq===r)||o.loadHistory({reset:!0})},Z=r=>{J({name:r,id:Date.now()}),k("Board")},re=r=>{k(r);let M=ht.indexOf(r);g.current[M]?.scrollIntoView?.({block:"nearest",inline:"nearest"})};function pe(r,M){let f={ArrowRight:(M+1)%4,ArrowLeft:(M+3)%4,Home:0,End:3}[r.key];f!==void 0&&(r.preventDefault(),re(ht[f]),g.current[f]?.focus())}async function ie(r){r.preventDefault();let M=x.trim();if(M)try{await o.command("set_team_title",{title:M}),w(!1)}catch{}}let L=(0,e.useMemo)(()=>(i.history.length?i.history:i.team?.events??[]).filter(Te.default.isPost).length,[i.history,i.team?.events]),R=(0,e.useMemo)(()=>i.team?i.team.members.filter(r=>r.status!=="retired").length:0,[i.team]),a={Board:L,Members:R},A=typeof i.version=="string"&&i.version.trim()||lo;return e.default.createElement("div",{className:"dsh-hive","data-dsh-hive-swarm":d},e.default.createElement("style",null,qt),e.default.createElement("header",{className:"dsh-hive-header"},e.default.createElement("div",{className:"dsh-hive-header-top"},e.default.createElement("div",{className:"dsh-hive-title-wrap"},e.default.createElement(et,{size:20}),e.default.createElement("h1",null,i.team?.title??"Hive Swarm")),e.default.createElement("div",{className:"dsh-hive-header-meta"},e.default.createElement("div",{className:"dsh-hive-header-status-row"},i.team?e.default.createElement(tt,{value:i.team.paused?"paused":i.team.phase,compactView:!0}):null,A?e.default.createElement("span",{className:"dsh-hive-version-tag",title:"Hive Swarm v"+A},"v",A):null),e.default.createElement(Wo,{version:A,update:i.update}))),i.team&&c?e.default.createElement("form",{className:"dsh-hive-rename",onSubmit:ie},e.default.createElement("input",{"aria-label":"Swarm title",maxLength:"95",required:!0,value:x,onChange:r=>b(r.target.value)}),e.default.createElement("button",{type:"submit",disabled:i.pending||!x.trim()},"Save"),e.default.createElement("button",{type:"button",onClick:()=>w(!1)},"Cancel")):null,e.default.createElement("div",{className:"dsh-hive-header-actions"},e.default.createElement("select",{"aria-label":"Team",value:i.team?.id??"",disabled:i.loading||m.pending,onChange:r=>o.selectTeam(r.target.value)},e.default.createElement("option",{value:""},"Choose a team"),i.teams.map(r=>e.default.createElement("option",{key:r.id,value:r.id},r.title," \xB7 ",r.cwd))),i.team&&!c?e.default.createElement("button",{type:"button",className:"dsh-hive-compact-btn",disabled:i.pending,onClick:()=>{b(i.team.title??""),w(!0)}},"Rename"):null,e.default.createElement("button",{type:"button",className:"dsh-hive-compact-btn",disabled:i.loading,onClick:o.refresh},"Refresh"),i.team?e.default.createElement("button",{type:"button",className:"dsh-hive-compact-btn",disabled:i.pending,onClick:()=>We(o,i.team.paused?"resume_team":"pause_team")},i.team.paused?"Resume":"Pause"):null,n?e.default.createElement("button",{type:"button",className:"dsh-hive-compact-btn","aria-label":"Open full view",onClick:()=>n(o)},"Open full view"):null),i.loading||i.connection==="disconnected"||m.pending||!i.team?e.default.createElement("p",{className:"dsh-hive-secondary dsh-hive-context",role:"status"},i.loading?"Loading Swarm\u2026":i.connection==="disconnected"?"Disconnected \xB7 refresh to reconnect":m.pending?"Saving action\u2026":i.workspace??"Teams in the Host\u2019s permitted workspace scope"):null),i.error?e.default.createElement(jt,{error:i.error,controller:o}):null,i.team?e.default.createElement(e.default.Fragment,null,e.default.createElement("nav",{role:"tablist","aria-label":"Swarm views",className:"dsh-hive-tabs"},ht.map((r,M)=>e.default.createElement("button",{key:r,ref:f=>{g.current[M]=f},type:"button",role:"tab",id:T+"-tab-"+r,"aria-controls":T+"-panel-"+r,"aria-selected":N===r,tabIndex:N===r?0:-1,onClick:()=>re(r),onKeyDown:f=>pe(f,M)},r,Object.hasOwn(a,r)?e.default.createElement("span",{className:"dsh-hive-tab-count"},a[r]):null))),e.default.createElement("section",{role:"tabpanel",tabIndex:"0",id:T+"-panel-"+N,"aria-labelledby":T+"-tab-"+N,className:"dsh-hive-content"},N==="Overview"?e.default.createElement(yo,{state:i,controller:o,onJournal:$,onJumpPost:W,onMention:Z}):N==="Board"?e.default.createElement(Mo,{key:i.team.id,state:i,controller:o,focusedSeq:P,onClearFocus:()=>q(null),mentionRequest:z,onConsumeMention:()=>J(null),onJumpPost:W,onOpenSession:O}):N==="Members"?e.default.createElement(Co,{key:i.team.id,state:i,controller:o,onJournal:$,onOpenSession:O,onMention:Z}):e.default.createElement(Bo,{key:i.team.id,state:i,controller:o,onJournal:$,onJumpPost:W}))):e.default.createElement(fo,{title:i.loading?"Loading teams\u2026":i.teams.length?"Choose a team":"No teams in this workspace"},i.loading?"Reading the native Host.":i.teams.length?"Select a team to inspect its work. Opening Swarm does not start workers.":"Create a team through /hive-swarm in an authorized parent session, then refresh."),p&&C?.controller===o&&i.journal?e.default.createElement(bo,{controller:o,journal:i.journal,opener:C.opener,onClose:h,onJumpPost:W}):null)}function Yt({surfaces:o}){let n=(0,e.useSyncExternalStore)(o.subscribe,o.getSnapshot,o.getSnapshot);return e.default.createElement(Gt,{controller:n,mode:"main"})}var At=()=>null,Do=/^hive-swarm:\/\/team\/([0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i;function Jt({parentSessionId:o,controllerForTeam:n,onExpand:d,useTabInfo:p=At,useSessions:m=At}){let i=p()?.tab,N=i?.navigation?.params,k=m(c=>c?.byId?.[o]?.cwd),C=typeof N?.teamId=="string"?"hive-swarm://team/"+N.teamId:i?.contentId,y=typeof C=="string"?Do.exec(C)?.[1]?.toLowerCase():void 0;return e.default.createElement(Gt,{controller:n(y,k),onExpand:d,visible:i?.visible!==!1})}var Ie=Je(require("react"),1);var $t=`.dsh-hive-tool {
|
|
665
869
|
min-width: 0;
|
|
666
870
|
color: var(--dsw-alias-label-primary);
|
|
667
871
|
font: inherit;
|
|
@@ -686,9 +890,9 @@ details[open] > summary .dsh-hive-chevron { rotate: 180deg; }
|
|
|
686
890
|
.dsh-hive-tool p, .dsh-hive-tool details { margin: 4px 0 0; overflow-wrap: anywhere; }
|
|
687
891
|
.dsh-hive-tool summary { cursor: pointer; }
|
|
688
892
|
.dsh-hive-tool pre { margin: 6px 0 0; max-height: 14rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
689
|
-
`;var
|
|
690
|
-
`):"",
|
|
691
|
-
`,1)[0]||"The Host could not complete this tool call."):null,b?
|
|
893
|
+
`;var _o=/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;function Oo(o){return o?.kind==="hive-swarm"&&typeof o.teamId=="string"&&_o.test(o.teamId)?o.teamId.toLowerCase():null}function Vt({toolName:o,phase:n,block:d,callId:p,openSwarm:m}){let i=(0,Ie.useRef)(null),[N,k]=(0,Ie.useState)(null),C=n==="result"&&d?.kind==="tool-result",y=C&&d.isError,c=C&&d.isError===!1?Oo(d.meta?.navigation):null,w=n==="preparing"?"Preparing\u2026":C?y?"Failed":"Completed":"Running\u2026",x=o==="hive_swarm_start_team"?"Start Swarm":"Find Swarm team",b=C?(d.content??[]).filter(z=>z.type==="text").map(z=>z.text).join(`
|
|
894
|
+
`):"",P=N?.callId===p&&N?.target===c?N:null;(0,Ie.useEffect)(()=>()=>{i.current?.abort(),i.current=null},[p,c]);async function q(){if(!c||i.current)return;let z=new AbortController;i.current=z,k({callId:p,target:c,pending:!0});try{await m(c,z.signal),z.signal.aborted||k(null)}catch(J){z.signal.aborted||k({callId:p,target:c,error:J?.message??"Try opening the team again."})}finally{i.current===z&&(i.current=null)}}return Ie.default.createElement("section",{className:"dsh-hive-tool","aria-label":x},Ie.default.createElement("style",null,$t),Ie.default.createElement("div",{className:"dsh-hive-tool-line"},Ie.default.createElement("strong",null,x),Ie.default.createElement("span",{role:"status","data-failed":y||void 0},w),c?Ie.default.createElement("button",{type:"button",onClick:q,disabled:!!P?.pending},"Open Swarm"):null),y?Ie.default.createElement("p",{role:"alert"},d.error?.reason||b.split(`
|
|
895
|
+
`,1)[0]||"The Host could not complete this tool call."):null,b?Ie.default.createElement("details",null,Ie.default.createElement("summary",null,"Tool result"),Ie.default.createElement("pre",null,b)):null,P?.pending?Ie.default.createElement("p",{role:"status"},"Opening team\u2026"):null,P?.error?Ie.default.createElement("p",{role:"alert"},"Could not open Swarm: ",P.error):null)}var Ge="dsh-hive-swarm",Uo=["slots","connection","layout","sidebarRightTabs","uiWorkspace"],Go=Symbol.for("hive-swarm.native-client.registrations"),Ue=globalThis[Go]??=new WeakMap,Yo=["hive_swarm_open_swarm_panel","hive_swarm_start_team"];function Jo(o){let n=o.slots;if(!Ue.has(n)){if(typeof n?.inject!="function"||typeof n?.register!="function"||typeof o.sidebarRightTabs?.register!="function"||typeof o.layout?.selectPanel!="function"){o.logger?.warn?.("Hive Swarm needs DSH right-tab, slot and layout capabilities. Enable them and reload the bundle.");return}o.effect(()=>{if(Ue.has(n))return()=>{};let d=yt((c,w,x)=>bt({connection:o.connection,sessionId:c,teamId:w,workspace:x,openSession:b=>{let P=o.uiWorkspace;if(typeof P?.openSession!="function")throw Error("Enable the DSH workspace capability to open a worker session.");return P.openSession(b)}})),p=[],m={},i=null;Ue.set(n,m);function N(){i?.abort();for(let c of p.splice(0).reverse())c?.();d.dispose(),Ue.get(n)===m&&Ue.delete(n)}function k(c){let w=d.getSnapshot();d.select(c);try{o.layout.selectPanel(Ge)}catch(x){throw d.select(w),x}}function C(c){i?.abort();try{k(c)}catch(w){c.setError(w)}}async function y(c,w,x){if(!c||Ue.get(n)!==m)throw Error("The original DSH session is unavailable.");i?.abort();let b=new AbortController;i=b;let P;try{let q=o.layout.beginNavigation?.();P=AbortSignal.any([b.signal,x,...q?[q]:[]]);let z=await gt(o.connection,w,P);P.throwIfAborted(),k(d.forSession(c,z.id,z.cwd))}catch(q){if(!P?.aborted)throw q}finally{i===b&&(i=null)}}try{p.push(o.sidebarRightTabs.register({id:Ge,kind:"hive-swarm",title:()=>"Swarm",patterns:["hive-swarm://team/**"],guide:[{id:"open",order:900,title:()=>"Swarm",icon:et}]})),p.push(n.inject("sidebar.right.pane.tab",()=>n.register({name:"sidebar.right.pane.tab",key:Ge,inject:w=>({parentSessionId:w,controllerForTeam:(x,b)=>d.forSession(w,x,b),onExpand:C})},Jt))),p.push(n.inject("sidebar.panellist",()=>n.register({name:"sidebar.panellist",id:Ge,order:30,label:()=>"Hive Swarm"},et))),p.push(n.inject("main",()=>n.register({name:"main",key:Ge,inject:()=>({surfaces:d})},Yt)));for(let w of Yo)p.push(n.inject("tool.call.toolview",()=>n.register({name:"tool.call.toolview",key:w,inject:x=>({openSwarm:(b,P)=>y(x,b,P)})},Vt)));let c=o.connection?.generation;typeof c?.subscribe=="function"?p.push(c.subscribe(()=>{c.getSnapshot()!==void 0&&d.reconnect()})):typeof o.on=="function"&&p.push(o.on("connection/reset",()=>d.reconnect()))}catch(c){return N(),o.logger?.warn?.("Hive Swarm could not register its native UI: "+c.message),()=>{}}return N},"hive-swarm: native launcher and views")}}
|
|
692
896
|
|
|
693
897
|
return module.exports;
|
|
694
898
|
}});
|