beads-map 0.2.1 → 0.2.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.
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{6284:function(e,t,n){Promise.resolve().then(n.bind(n,4584))},4584:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return eo}});var r=n(3890),s=n(8496);function i(e){let t="object"==typeof e.source?e.source.id:e.source,n="object"==typeof e.target?e.target.id:e.target;return"".concat(t,"->").concat(n,":").concat(e.type)}function a(e,t){if(!e)return{addedNodeIds:new Set(t.graphData.nodes.map(e=>e.id)),removedNodeIds:new Set,changedNodes:new Map,addedLinkKeys:new Set(t.graphData.links.map(i)),removedLinkKeys:new Set,hasChanges:!0};let n=new Map(e.graphData.nodes.map(e=>[e.id,e])),r=new Map(t.graphData.nodes.map(e=>[e.id,e])),s=new Set,a=new Set,l=new Map;for(let[e,t]of r)if(n.has(e)){let r=n.get(e),s=[];r.status!==t.status&&s.push({field:"status",from:r.status,to:t.status}),r.priority!==t.priority&&s.push({field:"priority",from:String(r.priority),to:String(t.priority)}),r.title!==t.title&&s.push({field:"title",from:r.title,to:t.title}),(r.owner||"")!==(t.owner||"")&&s.push({field:"owner",from:r.owner||"",to:t.owner||""}),s.length>0&&l.set(e,s)}else s.add(e);for(let e of n.keys())r.has(e)||a.add(e);let o=new Set(e.graphData.links.map(i)),c=new Set(t.graphData.links.map(i)),d=new Set,u=new Set;for(let e of c)o.has(e)||d.add(e);for(let e of o)c.has(e)||u.add(e);let x=s.size>0||a.size>0||l.size>0||d.size>0||u.size>0;return{addedNodeIds:s,removedNodeIds:a,changedNodes:l,addedLinkKeys:d,removedLinkKeys:u,hasChanges:x}}var l=n(8232);let o={open:"#10b981",in_progress:"#f59e0b",blocked:"#ef4444",deferred:"#8b5cf6",closed:"#a1a1aa"},c={open:"Open",in_progress:"In Progress",blocked:"Blocked",deferred:"Deferred",closed:"Closed"},d={0:"P0 - Critical",1:"P1 - High",2:"P2 - Medium",3:"P3 - Low",4:"P4 - Backlog"},u={0:"#ef4444",1:"#f97316",2:"#3b82f6",3:"#a1a1aa",4:"#d4d4d8"},x={bug:"\uD83D\uDC1B",feature:"✨",task:"\uD83D\uDCDD",epic:"\uD83C\uDFAF",chore:"\uD83D\uDD27"},h=new Proxy({},{get:(e,t)=>t.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),has:()=>!0}),m=new Proxy({},{get:(e,t)=>(function(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=16777619*t>>>0;let n=t%360;return"hsl(".concat(n,", 65%, 55%)")})(t),has:()=>!0}),p=null;function f(e){let t=e.blockerCount+e.dependentCount;return"epic"===e.issueType&&(t+=3),5+17*Math.min(t/6,1)}function g(e){return o[e.status]||o.open}function v(e){return 1-(1-e)*(1-e)}let b=new Map;function y(e,t){let n=b.get(e);if("loading"===n||"failed"===n)return null;if(n)return n;b.set(e,"loading");let r=new Image;return r.onload=()=>{b.set(e,r),t()},r.onerror=()=>{b.set(e,"failed")},r.src=e,null}function j(e,t,n,r,s,i){e.beginPath(),e.arc(t,n,r,0,2*Math.PI),e.fillStyle="#e4e4e7",e.fill();let a=s.replace("@","").charAt(0).toUpperCase();e.font="600 ".concat(Math.min(7,Math.max(3,1.3*r)),"px 'Inter', system-ui, sans-serif"),e.textAlign="center",e.textBaseline="middle",e.fillStyle="#71717a",e.fillText(a,t,n+.3)}function w(e,t){let n=new Set([e]),r=[{id:e,depth:0}];for(;r.length>0;){let{id:e,depth:s}=r.shift();if(!(s>=2))for(let i of t){let t="object"==typeof i.source?i.source.id:i.source,a="object"==typeof i.target?i.target.id:i.target;t!==e||n.has(a)||(n.add(a),r.push({id:a,depth:s+1})),a!==e||n.has(t)||(n.add(t),r.push({id:t,depth:s+1}))}}return n}function k(e){let t=e.current;if(!t)return;let n=t.zoom();"number"!=typeof n||isNaN(n)||(t.zoom(1.000001*n,0),requestAnimationFrame(()=>{e.current&&e.current.zoom(n,0)}))}let N=(0,s.forwardRef)(function(e,t){let{nodes:i,links:a,selectedNode:d,hoveredNode:u,onNodeClick:x,onNodeHover:h,onBackgroundClick:b,onNodeRightClick:N,commentedNodeIds:C,claimedNodeAvatars:M,onAvatarHover:S,timelineActive:D,stats:L,sidebarOpen:T}=e,A=(0,s.useRef)(null),I=(0,s.useRef)(null),E=(0,s.useRef)(null),P=(0,s.useRef)(0),W=(0,s.useRef)(()=>{}),[B,R]=(0,s.useState)({width:800,height:600}),F=(0,s.useRef)(!1),[_,O]=(0,s.useState)({w:160,h:120}),U=_.w,H=_.h,Y=(0,s.useRef)(null),[q,X]=(0,s.useState)(p);(0,s.useEffect)(()=>{p||n.e(149).then(n.bind(n,3149)).then(e=>{p=e.default||e,X(()=>p)})},[]);let[V,K]=(0,s.useState)("dag"),[$,J]=(0,s.useState)("full"),G=(0,s.useRef)(d),Z=(0,s.useRef)(u),Q=(0,s.useRef)(new Set),ee=(0,s.useRef)(C||new Map),et=(0,s.useRef)(M||new Map),en=(0,s.useRef)(()=>{});en.current=()=>k(A);let er=(0,s.useRef)(S);er.current=S;let es=(0,s.useRef)(null),ei=(0,s.useRef)(i),ea=(0,s.useRef)([]),{viewNodes:el,viewLinks:eo}=(0,s.useMemo)(()=>{if("full"===$)return{viewNodes:i,viewLinks:a};let e=new Map;for(let t of a){let n="object"==typeof t.source?t.source.id:t.source,r="object"==typeof t.target?t.target.id:t.target;"parent-child"===t.type&&e.set(r,n)}let t=new Set(i.map(e=>e.id));for(let n of i)if(!e.has(n.id)&&n.id.includes(".")){let r=n.id.split(".")[0];t.has(r)&&e.set(n.id,r)}let n=new Set(e.keys()),r=new Map,s=new Map,l=new Map;for(let[t,n]of e){r.set(n,(r.get(n)||0)+1);let e=i.find(e=>e.id===t);e&&(s.set(n,(s.get(n)||0)+e.blockerCount),l.set(n,(l.get(n)||0)+e.dependentCount))}let o=i.filter(e=>!n.has(e.id)).map(e=>({...e,blockerCount:e.blockerCount+(s.get(e.id)||0),dependentCount:e.dependentCount+(l.get(e.id)||0),collapsedCount:r.get(e.id)||0})),c=[],d=new Set;for(let t of a){if("parent-child"===t.type)continue;let n="object"==typeof t.source?t.source.id:t.source,r="object"==typeof t.target?t.target.id:t.target;if((n=e.get(n)||n)===(r=e.get(r)||r))continue;let s="".concat(n,"->").concat(r,":").concat(t.type);d.has(s)||(d.add(s),c.push({source:n,target:r,type:t.type}))}return{viewNodes:o,viewLinks:c}},[i,a,$]);ei.current=el,(0,s.useEffect)(()=>{let e=new Map;for(let t of a){let n="object"==typeof t.source?t.source.id:t.source,r="object"==typeof t.target?t.target.id:t.target;"parent-child"===t.type&&e.set(r,n)}let t=new Set(i.map(e=>e.id));for(let n of i)if(!e.has(n.id)&&n.id.includes(".")){let r=n.id.split(".")[0];t.has(r)&&e.set(n.id,r)}let n=new Map;for(let[t,r]of e){let e=n.get(r)||[];e.push(t),n.set(r,e)}let r=new Map(i.map(e=>[e.id,e])),s=[];for(let[e,t]of n){let n=r.get(e);n&&s.push({parentId:e,title:n.title||e,prefix:n.prefix,memberIds:[e,...t]})}ea.current=s},[i,a]),(0,s.useEffect)(()=>{G.current=d;let e=Z.current||d;e?Q.current=w(e.id,eo):Q.current=new Set,k(A),cancelAnimationFrame(P.current),P.current=requestAnimationFrame(()=>W.current())},[d,eo]),(0,s.useEffect)(()=>{Z.current=u;let e=u||G.current;e?Q.current=w(e.id,eo):Q.current=new Set,k(A),cancelAnimationFrame(P.current),P.current=requestAnimationFrame(()=>W.current())},[u,eo]),(0,s.useEffect)(()=>{ee.current=C||new Map,k(A)},[C]),(0,s.useEffect)(()=>{et.current=M||new Map,k(A)},[M]),(0,s.useEffect)(()=>{let e=I.current;if(!e)return;let t=t=>{let n;let r=A.current,s=er.current;if(!r||!s)return;let i=et.current;if(0===i.size){es.current&&(es.current=null,s(null));return}let a=e.getBoundingClientRect(),l=t.clientX-a.left,o=t.clientY-a.top;try{n=r.screen2GraphCoords(l,o)}catch(e){return}let c=Math.max(4,10/(r.zoom()||1));for(let e of ei.current){if(null==e.x||null==e.y)continue;let r=i.get(e.id);if(!r)continue;let a=f(e),l=e.x+.7*a,o=e.y+.7*a,d=n.x-l,u=n.y-o;if(d*d+u*u<=c*c){es.current!==e.id&&(es.current=e.id,s({handle:r.handle,avatar:r.avatar,claimedAt:r.claimedAt,did:r.did,x:t.clientX,y:t.clientY}));return}}es.current&&(es.current=null,s(null))};return e.addEventListener("mousemove",t),()=>e.removeEventListener("mousemove",t)},[]),(0,s.useEffect)(()=>{let e=()=>{if(I.current){let e=I.current.getBoundingClientRect();R({width:e.width,height:e.height})}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let ec=(0,s.useCallback)(e=>{let t=A.current;if(!t)return;let n=el.find(t=>t.id===e.id);n&&void 0!==n.x&&void 0!==n.y&&(t.centerAt(n.x,n.y,500),t.zoom(2.5,500),x(e))},[x,el]);(0,s.useImperativeHandle)(t,()=>({focusNode:ec}),[ec]),(0,s.useEffect)(()=>{var e,t,n,r,s,i;let a=A.current;if(!a||0===el.length)return;"dag"===V?(null===(e=a.d3Force("charge"))||void 0===e||e.strength(-80).distanceMax(300),null===(t=a.d3Force("link"))||void 0===t||t.distance(50).strength(.3),null===(n=a.d3Force("center"))||void 0===n||n.strength(.01),a.d3Force("collision",null)):(null===(r=a.d3Force("charge"))||void 0===r||r.strength(-180).distanceMax(400),null===(s=a.d3Force("link"))||void 0===s||s.distance(e=>{var t,n,r,s;return(((null===(t=e.source)||void 0===t?void 0:t.blockerCount)||0)+((null===(n=e.source)||void 0===n?void 0:n.dependentCount)||0)+(((null===(r=e.target)||void 0===r?void 0:r.blockerCount)||0)+((null===(s=e.target)||void 0===s?void 0:s.dependentCount)||0)))/2>4?90:120}).strength(.6),null===(i=a.d3Force("center"))||void 0===i||i.strength(.03),a.d3Force("collision",(0,l.Z)().radius(e=>f(e)+6).strength(.7)),el.forEach(e=>{delete e.fx,delete e.fy})),a.d3ReheatSimulation();let o=setTimeout(()=>{A.current&&A.current.zoomToFit(400,60)},F.current?600:1e3);return F.current=!0,()=>clearTimeout(o)},[V,el.length]);let ed=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(ed.current||!q||0===i.length)return;ed.current=!0;let e=setTimeout(()=>{K("force")},15);return()=>clearTimeout(e)},[q,i.length]),(0,s.useEffect)(()=>{if(!D&&A.current&&i.length>0){let e=setTimeout(()=>{A.current.zoomToFit(400,60)},800);return()=>clearTimeout(e)}},[i.length,D]);let eu=(0,s.useMemo)(()=>{let e=Math.sqrt(el.length)||1;return el.forEach((t,n)=>{if(null==t.x&&null==t.y){let r=n*Math.PI*(3-Math.sqrt(5)),s=300*Math.sqrt(.5+n)/e;t.x=s*Math.cos(r),t.y=s*Math.sin(r)}}),{nodes:el,links:eo}},[el,eo]),ex=(0,s.useCallback)((e,t,n)=>{var r,s,i;let a=f(e),l=g(e),c=m[e.prefix]||"#a1a1aa",d=(null===(r=G.current)||void 0===r?void 0:r.id)===e.id,u=(null===(s=Z.current)||void 0===s?void 0:s.id)===e.id,x=Q.current,h=x.has(e.id),p=x.size>0,b=Date.now(),w=1,k=e._spawnTime;if(k){let e=b-k;e<500&&(w=1+2.70158*Math.pow((i=e/500)-1,3)+1.70158*Math.pow(i-1,2))}let N=1,C=1,M=e._removeTime;if(M){let e=b-M;if(e<400){let t=e/400;N=1-v(t),C=1-t}else N=0,C=0}let S=w*N;if(S<=.01)return;let D=a*S,L=n<=.1?0:n>=.2?1:(n-.1)/.1,T=(p&&!h?.15:"closed"===e.status?.5:1)*C*L;if(T<=.01)return;t.save(),t.globalAlpha=T,h&&p&&(t.shadowColor="#10b981",t.shadowBlur=d?20:u?16:10),n>.3&&(t.beginPath(),t.arc(e.x,e.y,D+2,0,2*Math.PI),t.strokeStyle=c,t.lineWidth=2,t.stroke()),t.beginPath(),t.arc(e.x,e.y,D,0,2*Math.PI),t.fillStyle=l,t.fill(),t.strokeStyle=d?"#10b981":u?"#3f3f46":"#e4e4e7",t.lineWidth=d?2.5:u?2:1,t.stroke(),t.shadowBlur=0;let A=e._changedAt;if(A){let n=b-A;if(n<800){let r=n/800,s=o[e.status]||"#a1a1aa";t.beginPath(),t.arc(e.x,e.y,D+4+20*r,0,2*Math.PI),t.strokeStyle=s,t.lineWidth=2*(1-r),t.globalAlpha=(1-r)*.6,t.stroke(),t.globalAlpha=T}}if(k){let n=b-k;if(n<500){let r=n/500;t.beginPath(),t.arc(e.x,e.y,D+6+8*r,0,2*Math.PI),t.strokeStyle="#10b981",t.lineWidth=3*(1-r),t.globalAlpha=(1-r)*.4,t.stroke(),t.globalAlpha=T}}if(e.priority<=1&&n>.5&&(t.font="".concat(Math.min(10,Math.max(4,12/n)),"px sans-serif"),t.textAlign="center",t.textBaseline="bottom",t.fillText(0===e.priority?"\uD83D\uDD25\uD83D\uDD25":"\uD83D\uDD25",e.x,e.y-D-2)),n>.5){let r=Math.min(7,Math.max(3,10/n));t.font="500 ".concat(r,"px 'Inter', system-ui, sans-serif"),t.textAlign="center",t.textBaseline="top",t.fillStyle="#3f3f46",t.globalAlpha=.85*T;let s=e.id;n>1.5?s=z(e.title||e.id,30):n>.9&&(s=z(e.title||e.id,18)),t.fillText(s,e.x,e.y+D+3);let i=e.collapsedCount;i&&i>0&&(t.font="400 ".concat(Math.min(5.5,Math.max(2.5,8/n)),"px 'Inter', system-ui, sans-serif"),t.fillStyle="#a1a1aa",t.fillText("".concat(i," task").concat(1!==i?"s":""),e.x,e.y+D+3+r+1))}let I=ee.current.get(e.id);if(I&&I>0&&n>.4){let r=Math.min(6,Math.max(3.5,8/n)),s=e.x+.75*D,i=e.y-.75*D,a=I>99?"99+":String(I);t.save(),t.globalAlpha=Math.min(T,.95),t.beginPath(),t.arc(s,i,r,0,2*Math.PI),t.fillStyle="#ef4444",t.fill(),t.strokeStyle="#ffffff",t.lineWidth=Math.max(.8,1.2/n),t.stroke(),t.font="600 ".concat(Math.min(7,Math.max(3,1.3*r)),"px 'Inter', system-ui, sans-serif"),t.textAlign="center",t.textBaseline="middle",t.fillStyle="#ffffff",t.fillText(a,s,i+.3),t.restore()}let E=et.current.get(e.id);if(E){let r=Math.max(4,10/n),s=e.x+.7*D,i=e.y+.7*D;if(t.save(),t.globalAlpha=1,E.avatar){let e=y(E.avatar,()=>en.current());e?(t.save(),t.beginPath(),t.arc(s,i,r,0,2*Math.PI),t.clip(),t.drawImage(e,s-r,i-r,2*r,2*r),t.restore()):j(t,s,i,r,E.handle,n)}else j(t,s,i,r,E.handle,n);t.beginPath(),t.arc(s,i,r,0,2*Math.PI),t.strokeStyle="#ffffff",t.lineWidth=Math.max(.8,1.2/n),t.stroke(),t.restore()}t.restore()},[]),eh=(0,s.useCallback)((e,t,n)=>{let r=e.source,s=e.target;if(void 0===r.x||void 0===s.x)return;let i=Date.now(),a=1,l=1,o=e._spawnTime;if(o){let e=i-o;if(e<500){let t=e/500;a=v(t),l=1+(1-t)*1.5}}let c=1,d=e._removeTime;if(d){let e=i-d;if(!(e<400))return;c=1-v(e/400)}let u=a*c;if(u<=.01)return;let x=r.id||e.source,h=s.id||e.target,m="parent-child"===e.type,p=Q.current,g=p.size>0,b=g&&p.has(x)&&p.has(h),y=(m?g?b?.5:.05:.2:g?b?.8:.08:.35)*u*(n<=.1?0:n>=.2?1:(n-.1)/.1);if(y<=.01)return;t.save(),t.globalAlpha=y,m?(t.strokeStyle=b?"#71717a":"#a1a1aa",t.lineWidth=Math.max(.6,1.5/n)*l,t.setLineDash([4,3])):(t.strokeStyle=b?"#10b981":"#d4d4d8",t.lineWidth=(b?Math.max(2,2.5/n):Math.max(.8,1.2/n))*l);let j=s.x-r.x,w=s.y-r.y,k=Math.sqrt(j*j+w*w),N=(r.x+s.x)/2+.15*w,z=(r.y+s.y)/2-.15*j;if(t.beginPath(),t.moveTo(r.x,r.y),t.quadraticCurveTo(N,z,s.x,s.y),t.stroke(),m&&t.setLineDash([]),o){let e=i-o;e<300&&(t.save(),t.globalAlpha=(1-e/300)*.5,t.strokeStyle="#10b981",t.lineWidth=(m?3:4)/n,t.beginPath(),t.moveTo(r.x,r.y),t.quadraticCurveTo(N,z,s.x,s.y),t.stroke(),t.restore())}if(!m){let e=f(s);if(k<e+1){t.restore();return}let i=Math.min(8,6/n),a=1-e/k,l=r.x+a*j,o=r.y+a*w,c=Math.atan2(w,j);t.fillStyle=b?"#10b981":"#d4d4d8",t.beginPath(),t.moveTo(l,o),t.lineTo(l-i*Math.cos(c-Math.PI/7),o-i*Math.sin(c-Math.PI/7)),t.lineTo(l-i*Math.cos(c+Math.PI/7),o-i*Math.sin(c+Math.PI/7)),t.closePath(),t.fill()}t.restore()},[]),em=(0,s.useCallback)((e,t)=>{let n=t>=.8?0:t<=.4?1:(.8-t)/.4;if(n<=.01)return;let r=ea.current;if(0===r.length)return;let s=new Map;for(let e of el)null!=e.x&&null!=e.y&&s.set(e.id,{x:e.x,y:e.y});for(let i of(e.save(),r)){let r=0,a=0,l=0;for(let e of i.memberIds){let t=s.get(e);t&&(r+=t.x,a+=t.y,l++)}if(0===l)continue;let o=r/l,c=a/l,d=0;for(let e of i.memberIds){let t=s.get(e);if(t){let e=t.x-o,n=t.y-c,r=Math.sqrt(e*e+n*n);r>d&&(d=r)}}let u=d+30,x=m[i.prefix]||"hsl(0, 0%, 65%)";e.beginPath(),e.arc(o,c,u,0,2*Math.PI),e.globalAlpha=.05*n,e.fillStyle=x,e.fill(),e.globalAlpha=.25*n,e.strokeStyle=x,e.lineWidth=1.5/t,e.setLineDash([8/t,4/t]),e.stroke(),e.setLineDash([]);let h=Math.min(24,Math.max(10,14/t)),p=Math.min(12,Math.max(5,8/t)),f=.35*h;e.font="500 ".concat(p,"px 'Inter', system-ui, sans-serif"),e.textAlign="center",e.textBaseline="middle",e.globalAlpha=.45*n,e.fillStyle="#71717a",e.fillText(i.parentId,o,c-.5*h-f),e.font="600 ".concat(h,"px 'Inter', system-ui, sans-serif"),e.globalAlpha=.85*n,e.fillStyle="#18181b";let g=i.title.length>40?i.title.slice(0,39)+"…":i.title;e.fillText(g,o,c+.15*h);let v=Math.min(14,Math.max(6,9/t));e.font="400 ".concat(v,"px 'Inter', system-ui, sans-serif"),e.globalAlpha=.5*n,e.fillStyle="#71717a",e.fillText("".concat(i.memberIds.length," issue").concat(1!==i.memberIds.length?"s":""),o,c+.15*h+.7*h)}e.restore()},[el,i]),ep=(0,s.useCallback)((e,t,n)=>{let r=f(e)+5;n.fillStyle=t,n.beginPath(),n.arc(e.x,e.y,r,0,2*Math.PI),n.fill()},[]),ef=(0,s.useCallback)(()=>{},[]),eg=(0,s.useCallback)(()=>{var e,t;let n=E.current,r=A.current;if(!n||!r)return;let s=n.getContext("2d");if(!s)return;let i=1/0,a=-1/0,l=1/0,o=-1/0,c=!1;for(let e of el)null!=e.x&&null!=e.y&&(c=!0,e.x<i&&(i=e.x),e.x>a&&(a=e.x),e.y<l&&(l=e.y),e.y>o&&(o=e.y));if(!c)return;let d=(a+=40)-(i-=40)||1,u=(o+=40)-(l-=40)||1,x=U-16,h=H-16,m=Math.min(x/d,h/u),p=8+(x-d*m)/2,f=8+(h-u*m)/2,v=window.devicePixelRatio||1;(n.width!==U*v||n.height!==H*v)&&(n.width=U*v,n.height=H*v,s.setTransform(v,0,0,v,0,0)),s.clearRect(0,0,U,H),s.fillStyle="rgba(250, 250, 250, 0.92)",s.beginPath(),s.roundRect(0,0,U,H,6),s.fill();let b=Q.current,j=b.size>0,w=(null===(e=Z.current)||void 0===e?void 0:e.id)||(null===(t=G.current)||void 0===t?void 0:t.id)||null;for(let e of eo){let t=e.source,n=e.target;if(null==t.x||null==n.x)continue;let r=t.id||e.source,a=n.id||e.target,o=j&&b.has(r)&&b.has(a);s.globalAlpha=j?o?.5:.04:.1,s.strokeStyle=o?"#10b981":"#a1a1aa",s.lineWidth=o?1:.5;let c=p+(t.x-i)*m,d=f+(t.y-l)*m,u=p+(n.x-i)*m,x=f+(n.y-l)*m;s.beginPath(),s.moveTo(c,d),s.lineTo(u,x),s.stroke()}for(let e of(s.globalAlpha=1,el)){if(null==e.x||null==e.y)continue;let t=p+(e.x-i)*m,n=f+(e.y-l)*m,r=e.id===w,a=b.has(e.id);j&&!a?s.globalAlpha=.1:"closed"===e.status?s.globalAlpha=.35:s.globalAlpha=.85,s.fillStyle=g(e);let o="epic"===e.issueType?3:2;r?o=5:j&&a&&(o=4),r&&(s.globalAlpha=.4,s.fillStyle="#10b981",s.beginPath(),s.arc(t,n,o+2,0,2*Math.PI),s.fill(),s.globalAlpha=1,s.fillStyle=g(e)),s.fillRect(t-o/2,n-o/2,o,o)}s.globalAlpha=1;let k=et.current;if(k.size>0)for(let e of el){if(null==e.x||null==e.y)continue;let t=k.get(e.id);if(!t)continue;let n=p+(e.x-i)*m,r=f+(e.y-l)*m;if(s.save(),s.globalAlpha=1,t.avatar){let e=y(t.avatar,()=>en.current());e?(s.save(),s.beginPath(),s.arc(n,r,5,0,2*Math.PI),s.clip(),s.drawImage(e,n-5,r-5,10,10),s.restore()):(s.beginPath(),s.arc(n,r,5,0,2*Math.PI),s.fillStyle="#d4d4d8",s.fill())}else s.beginPath(),s.arc(n,r,5,0,2*Math.PI),s.fillStyle="#d4d4d8",s.fill();s.beginPath(),s.arc(n,r,5,0,2*Math.PI),s.strokeStyle="#ffffff",s.lineWidth=1,s.stroke(),s.restore()}try{let e=r.screen2GraphCoords(0,0),t=r.screen2GraphCoords(B.width,B.height),n=p+(e.x-i)*m,a=f+(e.y-l)*m,o=(t.x-e.x)*m,c=(t.y-e.y)*m,d=Math.max(0,n),u=Math.max(0,a),x=Math.min(U-d,o-(d-n)),h=Math.min(H-u,c-(u-a));x>0&&h>0&&(s.fillStyle="rgba(16, 185, 129, 0.06)",s.fillRect(d,u,x,h),s.strokeStyle="rgba(16, 185, 129, 0.5)",s.lineWidth=1.5,s.strokeRect(d,u,x,h))}catch(e){}},[el,eo,B,U,H,8]);W.current=eg;let ev=(0,s.useCallback)(()=>{cancelAnimationFrame(P.current),P.current=requestAnimationFrame(()=>{eg()})},[eg]);(0,s.useEffect)(()=>{if(!q||0===i.length)return;let e=setInterval(()=>{eg()},200);return()=>clearInterval(e)},[q,i.length,eg]),(0,s.useEffect)(()=>{let e;let t=!0;return function n(){if(!t)return;let r=Date.now();(el.some(e=>!!e._spawnTime&&r-e._spawnTime<500||!!e._removeTime&&r-e._removeTime<400||!!e._changedAt&&r-e._changedAt<800)||eo.some(e=>!!e._spawnTime&&r-e._spawnTime<500||!!e._removeTime&&r-e._removeTime<400))&&k(A),e=requestAnimationFrame(n)}(),()=>{t=!1,cancelAnimationFrame(e)}},[el,eo]);let eb=(0,s.useCallback)(e=>{let t=A.current;if(!t)return;let n=e.currentTarget.getBoundingClientRect(),r=e.clientX-n.left,s=e.clientY-n.top,i=1/0,a=-1/0,l=1/0,o=-1/0;for(let e of el)null!=e.x&&null!=e.y&&(e.x<i&&(i=e.x),e.x>a&&(a=e.x),e.y<l&&(l=e.y),e.y>o&&(o=e.y));let c=(a+=40)-(i-=40)||1,d=(o+=40)-(l-=40)||1,u=U-16,x=H-16,h=Math.min(u/c,x/d),m=i+(r-(8+(u-c*h)/2))/h,p=l+(s-(8+(x-d*h)/2))/h;t.centerAt(m,p,300)},[el,U,H,8]);return(0,r.jsxs)("div",{ref:I,className:"w-full h-full relative",children:[(0,r.jsxs)("div",{className:"absolute top-3 left-3 sm:top-4 sm:left-4 z-10 flex items-start gap-1.5 sm:gap-2",children:[(0,r.jsxs)("div",{className:"flex bg-white/90 backdrop-blur-sm rounded-lg border border-zinc-200 shadow-sm overflow-hidden",children:[(0,r.jsx)("button",{onClick:()=>K("force"),className:"px-3 py-1.5 text-xs font-medium transition-colors ".concat("force"===V?"bg-emerald-500 text-white":"text-zinc-500 hover:text-zinc-700 hover:bg-zinc-50"),children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"4",cy:"4",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"12",cy:"3",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"3",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"13",cy:"11",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("line",{x1:"4",y1:"4",x2:"8",y2:"8",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"12",y1:"3",x2:"8",y2:"8",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"3",y1:"12",x2:"8",y2:"8",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"13",y1:"11",x2:"8",y2:"8",strokeOpacity:"0.5"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Force"})]})}),(0,r.jsx)("div",{className:"w-px bg-zinc-200"}),(0,r.jsx)("button",{onClick:()=>K("dag"),className:"px-3 py-1.5 text-xs font-medium transition-colors ".concat("dag"===V?"bg-emerald-500 text-white":"text-zinc-500 hover:text-zinc-700 hover:bg-zinc-50"),children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"2.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"4",cy:"8",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"12",cy:"8",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"2",cy:"13.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"13.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"12",cy:"13.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("line",{x1:"8",y1:"4",x2:"4",y2:"6.5",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"8",y1:"4",x2:"12",y2:"6.5",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"4",y1:"9.5",x2:"2",y2:"12",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"4",y1:"9.5",x2:"6",y2:"12",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"12",y1:"9.5",x2:"12",y2:"12",strokeOpacity:"0.5"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"DAG"})]})})]}),(0,r.jsxs)("div",{className:"flex bg-white/90 backdrop-blur-sm rounded-lg border border-zinc-200 shadow-sm overflow-hidden",children:[(0,r.jsx)("button",{onClick:()=>J("full"),className:"px-3 py-1.5 text-xs font-medium transition-colors ".concat("full"===$?"bg-emerald-500 text-white":"text-zinc-500 hover:text-zinc-700 hover:bg-zinc-50"),children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"4",cy:"4",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"12",cy:"4",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"4",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"1",fill:"currentColor",stroke:"none",opacity:"0.5"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Full"})]})}),(0,r.jsx)("div",{className:"w-px bg-zinc-200"}),(0,r.jsx)("button",{onClick:()=>J("epics"),className:"px-3 py-1.5 text-xs font-medium transition-colors ".concat("epics"===$?"bg-emerald-500 text-white":"text-zinc-500 hover:text-zinc-700 hover:bg-zinc-50"),children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",fill:"none",opacity:"0.3"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Epics"})]})})]})]}),!D&&(0,r.jsxs)("div",{className:"absolute bottom-4 z-10 bg-white/90 backdrop-blur-sm rounded-lg border border-zinc-200 shadow-sm px-3 py-2 text-xs text-zinc-400 transition-[right] duration-300 ease-out",style:{right:T?"calc(360px + 1rem)":"1rem"},children:[L&&(0,r.jsxs)("div",{className:"text-zinc-500 mb-1.5",children:[(0,r.jsx)("strong",{className:"text-zinc-700",children:L.total})," issues"," \xb7 ",(0,r.jsx)("strong",{className:"text-zinc-700",children:L.edges})," deps"," \xb7 ",(0,r.jsx)("strong",{className:"text-emerald-600",children:L.prefixes.length}),1===L.prefixes.length?" project":" projects"]}),(0,r.jsx)("div",{className:"hidden sm:flex flex-wrap gap-x-3 gap-y-1 mb-1.5",children:["open","in_progress","blocked","deferred","closed"].map(e=>(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:o[e]}}),(0,r.jsx)("span",{className:"text-zinc-500",children:c[e]})]},e))}),(0,r.jsx)("div",{className:"hidden sm:flex flex-col gap-0.5 text-zinc-400",children:(0,r.jsx)("span",{children:"Size = importance \xb7 Ring = project"})}),(0,r.jsx)("span",{className:"sm:hidden",children:"Tap a node for details"})]}),(0,r.jsxs)("div",{className:"hidden sm:block absolute bottom-4 left-4 z-10",style:{width:U,height:H},children:[(0,r.jsx)("canvas",{ref:E,width:U,height:H,onClick:eb,className:"rounded-lg border border-zinc-200 shadow-sm cursor-crosshair",style:{width:U,height:H}}),(0,r.jsx)("div",{className:"absolute top-0 left-2 right-2 h-1.5 cursor-n-resize hover:bg-zinc-300/40 rounded-t-lg transition-colors",onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),Y.current={edge:"top",startX:e.clientX,startY:e.clientY,startW:U,startH:H};let t=e=>{if(!Y.current)return;let t=Y.current.startY-e.clientY,n=Math.max(80,Math.min(400,Y.current.startH+t));O(e=>({...e,h:n}))},n=()=>{Y.current=null,window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",n)};window.addEventListener("mousemove",t),window.addEventListener("mouseup",n)}}),(0,r.jsx)("div",{className:"absolute top-2 right-0 bottom-2 w-1.5 cursor-e-resize hover:bg-zinc-300/40 rounded-r-lg transition-colors",onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),Y.current={edge:"right",startX:e.clientX,startY:e.clientY,startW:U,startH:H};let t=e=>{if(!Y.current)return;let t=e.clientX-Y.current.startX,n=Math.max(100,Math.min(500,Y.current.startW+t));O(e=>({...e,w:n}))},n=()=>{Y.current=null,window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",n)};window.addEventListener("mousemove",t),window.addEventListener("mouseup",n)}}),(0,r.jsx)("div",{className:"absolute top-0 right-0 w-3 h-3 cursor-ne-resize hover:bg-zinc-300/40 rounded-tr-lg transition-colors",onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),Y.current={edge:"top-right",startX:e.clientX,startY:e.clientY,startW:U,startH:H};let t=e=>{if(!Y.current)return;let t=e.clientX-Y.current.startX,n=Y.current.startY-e.clientY;O({w:Math.max(100,Math.min(500,Y.current.startW+t)),h:Math.max(80,Math.min(400,Y.current.startH+n))})},n=()=>{Y.current=null,window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",n)};window.addEventListener("mousemove",t),window.addEventListener("mouseup",n)}})]}),q?(0,r.jsx)(q,{ref:A,graphData:eu,width:B.width,height:B.height,nodeCanvasObject:ex,nodeCanvasObjectMode:()=>"replace",nodePointerAreaPaint:ep,onRenderFramePost:em,linkCanvasObject:eh,linkCanvasObjectMode:()=>"replace",linkDirectionalParticles:e=>"parent-child"===e.type?0:2,linkDirectionalParticleSpeed:.004,linkDirectionalParticleWidth:2.5,linkDirectionalParticleColor:()=>"#10b981",dagMode:"dag"===V?"td":void 0,dagLevelDistance:60,onDagError:ef,d3AlphaDecay:.02,d3VelocityDecay:.3,cooldownTicks:300,warmupTicks:50,onNodeClick:e=>x(e),onNodeHover:e=>h(e||null),onNodeRightClick:(e,t)=>{t.preventDefault(),null==N||N(e,t)},onBackgroundClick:b,onZoom:ev,backgroundColor:"transparent"}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("div",{className:"text-zinc-400 text-sm animate-pulse-soft",children:"Loading graph engine..."})})]})});function z(e,t){return e.length<=t?e:e.slice(0,t-1)+"…"}var C=n(5777),M=n(7827),S=n(1720);function D(e){let{node:t,onClose:n}=e;return t.description?(0,S.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/40 backdrop-blur-sm",onClick:n,children:(0,r.jsxs)("div",{className:"bg-white rounded-xl shadow-2xl w-[90vw] max-w-2xl max-h-[80vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-zinc-100",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"text-xs font-mono font-semibold text-emerald-600 shrink-0",children:t.id}),(0,r.jsx)("span",{className:"text-sm font-semibold text-zinc-900 truncate",children:t.title})]}),(0,r.jsx)("button",{onClick:n,className:"shrink-0 p-1 text-zinc-400 hover:text-zinc-600 transition-colors",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-5 py-4 custom-scrollbar description-markdown text-sm text-zinc-700 leading-relaxed",children:(0,r.jsx)(C.UG,{remarkPlugins:[M.Z],children:t.description})})]})}),document.body):null}function L(e){let{className:t="w-3 h-3",filled:n=!1}=e;return n?(0,r.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor",children:(0,r.jsx)("path",{d:"M11.645 20.91l-.007-.003-.022-.012a15.247 15.247 0 01-.383-.218 25.18 25.18 0 01-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0112 5.052 5.5 5.5 0 0116.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 01-4.244 3.17 15.247 15.247 0 01-.383.219l-.022.012-.007.004-.003.001a.752.752 0 01-.704 0l-.003-.001z"})}):(0,r.jsx)("svg",{className:t,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z"})})}function T(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/1e3);if(n<60)return"just now";let r=Math.floor(n/60);if(r<60)return"".concat(r,"m ago");let s=Math.floor(r/60);if(s<24)return"".concat(s,"h ago");let i=Math.floor(s/24);return i<7?"".concat(i,"d ago"):t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function A(e){let{node:t,allNodes:n,onNodeNavigate:i,comments:a,onPostComment:l,onDeleteComment:p,onLikeComment:f,onReplyComment:g,isAuthenticated:v,currentDid:b,repoUrls:y}=e,[j,w]=(0,s.useState)(null),[k,N]=(0,s.useState)(""),[z,S]=(0,s.useState)(!1),[L,T]=(0,s.useState)(!1),A=e=>{w(e.uri),N("")},I=()=>{w(null),N("")},R=async()=>{if(k.trim()&&j&&g){S(!0);try{let e=t=>{for(let n of t){if(n.uri===j)return n;let t=e(n.replies);if(t)return t}},t=a?e(a):void 0;t&&await g(t,k.trim()),w(null),N("")}catch(e){console.error("Failed to post reply:",e)}finally{S(!1)}}};if(!t)return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)("div",{className:"w-12 h-12 rounded-full bg-zinc-100 flex items-center justify-center mb-4",children:(0,r.jsx)("svg",{className:"w-6 h-6 text-zinc-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122"})})}),(0,r.jsx)("p",{className:"text-sm text-zinc-500 leading-relaxed",children:"Click a node to see details"}),(0,r.jsx)("p",{className:"text-xs text-zinc-400 mt-1",children:"Hover to highlight connections"})]});let F=x[t.issueType]||"\uD83D\uDCCB",_=o[t.status]||o.open,O=c[t.status]||t.status,U=d[t.priority]||"P".concat(t.priority),H=u[t.priority]||"#a1a1aa",Y=h[t.prefix]||t.prefix,q=m[t.prefix]||"#a1a1aa",X=null==y?void 0:y[t.prefix],V=t.blockerIds.map(e=>n.find(t=>t.id===e)).filter(Boolean),K=t.dependentIds.map(e=>n.find(t=>t.id===e)).filter(Boolean),$=e=>{try{let t=new Date(e),n=t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!1});return"".concat(n," at ").concat(r)}catch(t){return e}};return(0,r.jsxs)("div",{className:"animate-fade-in",children:[(0,r.jsxs)("div",{className:"flex items-start gap-3 mb-4",children:[(0,r.jsx)("span",{className:"text-2xl mt-0.5",children:F}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)("span",{className:"text-xs font-mono font-semibold text-emerald-600",children:t.id})}),(0,r.jsx)("h3",{className:"text-sm font-semibold text-zinc-900 mt-1 leading-snug",children:t.title})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 mb-4",children:[(0,r.jsxs)("span",{className:"status-badge",style:{backgroundColor:_+"18",color:_,border:"1px solid ".concat(_,"30")},children:[(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full mr-1.5",style:{backgroundColor:_}}),O]}),(0,r.jsx)("span",{className:"status-badge",style:{backgroundColor:H+"15",color:H,border:"1px solid ".concat(H,"25")},children:U}),X?(0,r.jsxs)("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"status-badge hover:opacity-80 transition-opacity",style:{backgroundColor:q+"15",color:q,border:"1px solid ".concat(q,"25"),textDecoration:"none"},children:[Y,(0,r.jsx)("svg",{className:"w-2.5 h-2.5 ml-1 opacity-50",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25"})})]}):(0,r.jsx)("span",{className:"status-badge",style:{backgroundColor:q+"15",color:q,border:"1px solid ".concat(q,"25")},children:Y})]}),X&&(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsxs)("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-[11px] text-zinc-400 hover:text-zinc-600 transition-colors",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),X.replace(/^https?:\/\//,"")]})}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 mb-4",children:[(0,r.jsx)(E,{label:"Blocks",value:t.blockerCount,color:t.blockerCount>0?"#f59e0b":void 0}),(0,r.jsx)(E,{label:"Blocked by",value:t.dependentCount,color:t.dependentCount>0?"#ef4444":void 0})]}),(0,r.jsxs)("div",{className:"space-y-1.5 mb-4 text-xs text-zinc-500",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Created"}),(0,r.jsx)("span",{className:"text-zinc-700 font-medium",children:$(t.createdAt)})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Updated"}),(0,r.jsx)("span",{className:"text-zinc-700 font-medium",children:$(t.updatedAt)})]}),t.closedAt&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Closed"}),(0,r.jsx)("span",{className:"text-zinc-700 font-medium",children:$(t.closedAt)})]}),t.closeReason&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Reason"}),(0,r.jsx)("span",{className:"text-zinc-700 font-medium truncate ml-2",children:t.closeReason})]}),t.owner&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Owner"}),(0,r.jsx)("span",{className:"text-zinc-700 font-medium truncate ml-2",children:t.owner})]})]}),t.description&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold text-zinc-500 uppercase tracking-wider",children:"Description"}),(0,r.jsx)("button",{onClick:()=>T(!0),className:"text-[10px] text-zinc-400 hover:text-zinc-600 transition-colors",children:"View in window"})]}),(0,r.jsx)("div",{className:"text-xs text-zinc-600 leading-relaxed bg-zinc-50 rounded-lg p-3 max-h-40 overflow-y-auto custom-scrollbar border border-zinc-100 description-markdown",children:(0,r.jsx)(C.UG,{remarkPlugins:[M.Z],children:t.description})})]}),L&&t.description&&(0,r.jsx)(D,{node:t,onClose:()=>T(!1)}),V.length>0&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("h4",{className:"text-xs font-semibold text-zinc-500 uppercase tracking-wider mb-2",children:["Blocks (",V.length,")"]}),(0,r.jsx)("div",{className:"space-y-1",children:V.map(e=>(0,r.jsx)(P,{node:e,onClick:()=>i(e.id)},e.id))})]}),K.length>0&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("h4",{className:"text-xs font-semibold text-zinc-500 uppercase tracking-wider mb-2",children:["Blocked by (",K.length,")"]}),(0,r.jsx)("div",{className:"space-y-1",children:K.map(e=>(0,r.jsx)(P,{node:e,onClick:()=>i(e.id)},e.id))})]}),(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("h4",{className:"text-xs font-semibold text-zinc-500 uppercase tracking-wider mb-2",children:["Comments"," ",a&&a.length>0&&(0,r.jsx)("span",{className:"ml-1 px-1.5 py-0.5 bg-emerald-50 text-emerald-600 rounded-full text-[10px] font-medium",children:a.length})]}),a&&a.length>0?(0,r.jsx)("div",{className:"space-y-1",children:a.map(e=>(0,r.jsx)(W,{comment:e,currentDid:b,isAuthenticated:v,onDelete:p,onLike:f,onStartReply:A,replyingToUri:j,replyText:k,onReplyTextChange:N,onSubmitReply:R,onCancelReply:I,isSubmittingReply:z,depth:0},e.uri))}):(0,r.jsx)("p",{className:"text-xs text-zinc-400 italic",children:"No comments yet"}),v&&l?(0,r.jsx)(B,{onSubmit:l}):v?null:(0,r.jsx)("p",{className:"text-xs text-zinc-400 mt-2",children:"Sign in to leave a comment"})]})]})}function I(e){let{replyingTo:t,replyText:n,onTextChange:s,onSubmit:i,onCancel:a,isSubmitting:l}=e;return(0,r.jsxs)("div",{className:"mt-2 ml-4 pl-3 border-l border-emerald-200 space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] text-zinc-400",children:[(0,r.jsx)("span",{children:"Replying to"}),(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(t.did),target:"_blank",rel:"noopener noreferrer",className:"font-medium text-zinc-600 hover:text-emerald-600 transition-colors",children:t.displayName||t.handle})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",value:n,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||i()},placeholder:"Write a reply...",disabled:l,autoFocus:!0,className:"flex-1 px-2 py-1 text-xs bg-white border border-zinc-200 rounded placeholder-zinc-400 focus:outline-none focus:border-emerald-400 disabled:opacity-50"}),(0,r.jsx)("button",{onClick:i,disabled:!n.trim()||l,className:"px-2 py-1 text-[10px] font-medium text-emerald-600 hover:text-emerald-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:l?"...":"Reply"}),(0,r.jsx)("button",{onClick:a,disabled:l,className:"px-2 py-1 text-[10px] text-zinc-400 hover:text-zinc-600 disabled:opacity-50 transition-colors",children:"Cancel"})]})]})}function E(e){let{label:t,value:n,color:s}=e;return(0,r.jsxs)("div",{className:"bg-zinc-50 rounded-lg p-3 border border-zinc-100",children:[(0,r.jsx)("div",{className:"text-xl font-bold",style:{color:s||"#3f3f46"},children:n}),(0,r.jsx)("div",{className:"text-[10px] text-zinc-400 uppercase tracking-wider mt-0.5",children:t})]})}function P(e){let{node:t,onClick:n}=e,s=o[t.status]||o.open;return(0,r.jsxs)("button",{onClick:n,className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md hover:bg-zinc-50 transition-colors text-left group border border-transparent hover:border-zinc-200",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:s}}),(0,r.jsx)("span",{className:"text-xs font-mono text-emerald-600 group-hover:text-emerald-700 shrink-0",children:t.id}),(0,r.jsx)("span",{className:"text-xs text-zinc-500 truncate",children:t.title})]})}function W(e){let{comment:t,currentDid:n,isAuthenticated:i,onDelete:a,onLike:l,onStartReply:o,replyingToUri:c,replyText:d,onReplyTextChange:u,onSubmitReply:x,onCancelReply:h,isSubmittingReply:m,depth:p}=e,[f,g]=(0,s.useState)(!1),[v,b]=(0,s.useState)(!1),y=n&&n===t.did,j=!!n&&t.likes.some(e=>e.did===n),w=c===t.uri,k=async()=>{if(a&&!f){g(!0);try{await a(t)}catch(e){console.error("Failed to delete comment:",e)}finally{g(!1)}}},N=async()=>{if(l&&!v){b(!0);try{await l(t)}catch(e){console.error("Failed to toggle like:",e)}finally{b(!1)}}};return(0,r.jsxs)("div",{className:"".concat(p>0?"ml-4 pl-3 border-l border-zinc-100":""),children:[(0,r.jsxs)("div",{className:"py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("div",{className:"shrink-0 w-4 h-4 rounded-full bg-zinc-100 overflow-hidden",children:t.avatar?(0,r.jsx)("img",{src:t.avatar,alt:"",className:"w-full h-full object-cover"}):(0,r.jsx)("div",{className:"w-full h-full flex items-center justify-center text-[8px] font-medium text-zinc-400",children:(t.handle||t.did).charAt(0).toUpperCase()})}),(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(t.did),target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-zinc-600 truncate hover:text-emerald-600 transition-colors",children:t.displayName||t.handle||t.did.slice(0,16)+"..."}),(0,r.jsx)("span",{className:"text-[10px] text-zinc-300 shrink-0",children:T(t.createdAt)})]}),(0,r.jsx)("p",{className:"text-xs text-zinc-500 leading-relaxed whitespace-pre-wrap break-words",children:t.text}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1 text-[10px]",children:[(0,r.jsxs)("button",{onClick:N,disabled:!i||v,className:"flex items-center gap-0.5 transition-colors ".concat(j?"text-rose-500":"text-zinc-300 hover:text-rose-500"," disabled:opacity-50"),children:[(0,r.jsx)(L,{className:"w-3 h-3",filled:j}),t.likes.length>0&&(0,r.jsx)("span",{children:t.likes.length})]}),(0,r.jsx)("button",{onClick:()=>o(t),disabled:!i,className:"transition-colors disabled:opacity-50 ".concat(w?"text-emerald-500":"text-zinc-300 hover:text-zinc-500"),children:"reply"}),y&&a&&(0,r.jsx)("button",{onClick:k,disabled:f,className:"ml-auto shrink-0 text-zinc-300 hover:text-red-400 disabled:opacity-50 transition-colors",children:f?"...":"delete"})]})]}),w&&(0,r.jsx)(I,{replyingTo:t,replyText:d,onTextChange:u,onSubmit:x,onCancel:h,isSubmitting:m}),t.replies.length>0&&(0,r.jsx)("div",{children:t.replies.map(e=>(0,r.jsx)(W,{comment:e,currentDid:n,isAuthenticated:i,onDelete:a,onLike:l,onStartReply:o,replyingToUri:c,replyText:d,onReplyTextChange:u,onSubmitReply:x,onCancelReply:h,isSubmittingReply:m,depth:p+1},e.uri))})]})}function B(e){let{onSubmit:t}=e,[n,i]=(0,s.useState)(""),[a,l]=(0,s.useState)(!1),o=async()=>{if(n.trim()&&!a){l(!0);try{await t(n.trim()),i("")}catch(e){console.error("Failed to post comment:",e)}finally{l(!1)}}};return(0,r.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,r.jsx)("textarea",{value:n,onChange:e=>i(e.target.value),placeholder:"Leave a comment...",rows:2,className:"w-full px-2.5 py-1.5 text-xs border border-zinc-200 rounded-md bg-zinc-50 text-zinc-700 placeholder-zinc-400 resize-none focus:outline-none focus:ring-1 focus:ring-emerald-500 focus:border-emerald-500"}),(0,r.jsx)("button",{onClick:o,disabled:!n.trim()||a,className:"px-3 py-1 text-xs font-medium text-white bg-emerald-500 rounded-md hover:bg-emerald-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:a?"Sending...":"Comment"})]})}var R=n(7796);function F(){let{isAuthenticated:e,isLoading:t,session:n,login:i,logout:a}=(0,R.a)(),[l,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(!1),[u,x]=(0,s.useState)(""),[h,m]=(0,s.useState)(!1),[p,f]=(0,s.useState)(""),g=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!c)return;let e=e=>{g.current&&!g.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[c]);let v=async e=>{if(e.preventDefault(),u.trim()){m(!0),f("");try{await i(u.trim())}catch(e){f(e instanceof Error?e.message:"Login failed"),m(!1)}}},b=async()=>{d(!1),await a()};return t?(0,r.jsx)("div",{className:"w-4 h-4 rounded-full border-2 border-zinc-200 border-t-zinc-400 animate-spin"}):e&&n?(0,r.jsxs)("div",{className:"relative",ref:g,children:[(0,r.jsxs)("button",{onClick:()=>d(e=>!e),className:"flex items-center gap-2 px-3 py-1.5 rounded-full hover:bg-zinc-50 transition-colors cursor-pointer",children:[n.avatar?(0,r.jsx)("img",{src:n.avatar,alt:n.handle,width:24,height:24,className:"rounded-full"}):(0,r.jsx)("div",{className:"w-6 h-6 rounded-full bg-emerald-100 flex items-center justify-center text-[11px] text-emerald-700 font-medium",children:(n.displayName||n.handle).charAt(0).toUpperCase()}),(0,r.jsx)("span",{className:"text-sm text-zinc-600 max-w-[100px] truncate",children:n.displayName||n.handle})]}),c&&(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-44 bg-white rounded-xl shadow-xl border border-zinc-100 py-2 z-50",children:[(0,r.jsxs)("a",{href:n.did?"https://www.impactindexer.org/data?did=".concat(n.did):"#",target:"_blank",rel:"noopener noreferrer",className:"block px-3 py-1.5 text-xs text-zinc-400 truncate hover:text-emerald-600 transition-colors",children:["@",n.handle]}),(0,r.jsx)("div",{className:"h-px bg-zinc-100 my-1"}),(0,r.jsxs)("button",{onClick:b,className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs text-zinc-600 hover:bg-zinc-50 transition-colors cursor-pointer",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-zinc-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 9V5.25A2.25 2.25 0 0 1 10.5 3h6a2.25 2.25 0 0 1 2.25 2.25v13.5A2.25 2.25 0 0 1 16.5 21h-6a2.25 2.25 0 0 1-2.25-2.25V15m-3 0-3-3m0 0 3-3m-3 3H15"})}),"Sign out"]})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:()=>o(!0),className:"px-4 py-1.5 text-sm font-medium text-zinc-600 rounded-full hover:text-zinc-900 hover:bg-zinc-50 transition-colors cursor-pointer whitespace-nowrap",children:"Sign in"}),l&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",onClick:()=>o(!1),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/20 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative w-full max-w-sm mx-4 bg-white rounded-xl shadow-lg border border-zinc-200 p-6",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-zinc-900 mb-1",children:"Sign in with ATProto"}),(0,r.jsx)("p",{className:"text-sm text-zinc-400 mb-5",children:"Enter your Bluesky handle to connect."}),(0,r.jsxs)("form",{onSubmit:v,children:[(0,r.jsx)("label",{htmlFor:"auth-handle",className:"block text-sm text-zinc-600 mb-1.5",children:"Handle"}),(0,r.jsx)("input",{id:"auth-handle",type:"text",value:u,onChange:e=>x(e.target.value),placeholder:"alice.bsky.social",disabled:h,autoFocus:!0,className:"w-full px-3 py-2 text-sm bg-white border border-zinc-200 rounded-lg placeholder:text-zinc-300 focus:outline-none focus:ring-2 focus:ring-emerald-500/30 focus:border-emerald-400 disabled:opacity-50 disabled:cursor-not-allowed"}),(0,r.jsx)("p",{className:"text-xs text-zinc-300 mt-1.5",children:"Just a username? We'll add .bsky.social for you."}),p&&(0,r.jsx)("p",{className:"text-sm text-red-500 mt-2",children:p}),(0,r.jsxs)("div",{className:"flex gap-2 mt-5",children:[(0,r.jsx)("button",{type:"button",onClick:()=>o(!1),disabled:h,className:"flex-1 px-3 py-2 text-sm text-zinc-600 bg-zinc-50 rounded-lg hover:bg-zinc-100 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Cancel"}),(0,r.jsx)("button",{type:"submit",disabled:h||!u.trim(),className:"flex-1 px-3 py-2 text-sm text-white bg-emerald-600 rounded-lg hover:bg-emerald-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:h?"Connecting...":"Connect"})]})]})]})]})]})}function _(e){let{className:t}=e;return(0,r.jsxs)("svg",{viewBox:"0 0 32 32",fill:"none",className:t,"aria-hidden":"true",children:[(0,r.jsx)("polygon",{points:"16,3 27,9.5 27,22.5 16,29 5,22.5 5,9.5",stroke:"currentColor",strokeWidth:"1.2",fill:"none",opacity:"0.7",strokeLinejoin:"round",children:(0,r.jsx)("animateTransform",{attributeName:"transform",type:"rotate",values:"0 16 16;360 16 16",dur:"40s",repeatCount:"indefinite"})}),(0,r.jsx)("polygon",{points:"16,8 22.5,11.5 22.5,20.5 16,24 9.5,20.5 9.5,11.5",stroke:"currentColor",strokeWidth:"0.8",fill:"none",opacity:"0.35",strokeLinejoin:"round",children:(0,r.jsx)("animateTransform",{attributeName:"transform",type:"rotate",values:"360 16 16;0 16 16",dur:"30s",repeatCount:"indefinite"})}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"3",stroke:"currentColor",strokeWidth:"0.6",opacity:"0.2",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"0.15;0.35;0.15",dur:"3s",repeatCount:"indefinite"})}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"27",y2:"9.5",stroke:"currentColor",strokeWidth:"0.6",opacity:"0.2",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"0.15;0.35;0.15",dur:"3s",repeatCount:"indefinite",begin:"0.5s"})}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"27",y2:"22.5",stroke:"currentColor",strokeWidth:"0.6",opacity:"0.2",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"0.15;0.35;0.15",dur:"3s",repeatCount:"indefinite",begin:"1s"})}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"29",stroke:"currentColor",strokeWidth:"0.6",opacity:"0.2",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"0.15;0.35;0.15",dur:"3s",repeatCount:"indefinite",begin:"1.5s"})}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"5",y2:"22.5",stroke:"currentColor",strokeWidth:"0.6",opacity:"0.2",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"0.15;0.35;0.15",dur:"3s",repeatCount:"indefinite",begin:"2s"})}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"5",y2:"9.5",stroke:"currentColor",strokeWidth:"0.6",opacity:"0.2",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"0.15;0.35;0.15",dur:"3s",repeatCount:"indefinite",begin:"2.5s"})}),(0,r.jsxs)("circle",{cx:"16",cy:"16",r:"2.5",fill:"currentColor",opacity:"0.8",children:[(0,r.jsx)("animate",{attributeName:"r",values:"2;3;2",dur:"3s",repeatCount:"indefinite"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.7;1;0.7",dur:"3s",repeatCount:"indefinite"})]}),(0,r.jsxs)("circle",{cx:"16",cy:"3",r:"1.5",fill:"currentColor",opacity:"0.5",children:[(0,r.jsx)("animate",{attributeName:"r",values:"1.2;2;1.2",dur:"2.5s",repeatCount:"indefinite"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.4;0.7;0.4",dur:"2.5s",repeatCount:"indefinite"})]}),(0,r.jsxs)("circle",{cx:"27",cy:"9.5",r:"1.5",fill:"currentColor",opacity:"0.5",children:[(0,r.jsx)("animate",{attributeName:"r",values:"1.2;2;1.2",dur:"2.5s",repeatCount:"indefinite",begin:"0.4s"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.4;0.7;0.4",dur:"2.5s",repeatCount:"indefinite",begin:"0.4s"})]}),(0,r.jsxs)("circle",{cx:"27",cy:"22.5",r:"1.5",fill:"currentColor",opacity:"0.5",children:[(0,r.jsx)("animate",{attributeName:"r",values:"1.2;2;1.2",dur:"2.5s",repeatCount:"indefinite",begin:"0.8s"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.4;0.7;0.4",dur:"2.5s",repeatCount:"indefinite",begin:"0.8s"})]}),(0,r.jsxs)("circle",{cx:"16",cy:"29",r:"1.5",fill:"currentColor",opacity:"0.5",children:[(0,r.jsx)("animate",{attributeName:"r",values:"1.2;2;1.2",dur:"2.5s",repeatCount:"indefinite",begin:"1.2s"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.4;0.7;0.4",dur:"2.5s",repeatCount:"indefinite",begin:"1.2s"})]}),(0,r.jsxs)("circle",{cx:"5",cy:"22.5",r:"1.5",fill:"currentColor",opacity:"0.5",children:[(0,r.jsx)("animate",{attributeName:"r",values:"1.2;2;1.2",dur:"2.5s",repeatCount:"indefinite",begin:"1.6s"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.4;0.7;0.4",dur:"2.5s",repeatCount:"indefinite",begin:"1.6s"})]}),(0,r.jsxs)("circle",{cx:"5",cy:"9.5",r:"1.5",fill:"currentColor",opacity:"0.5",children:[(0,r.jsx)("animate",{attributeName:"r",values:"1.2;2;1.2",dur:"2.5s",repeatCount:"indefinite",begin:"2s"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.4;0.7;0.4",dur:"2.5s",repeatCount:"indefinite",begin:"2s"})]}),(0,r.jsxs)("circle",{cx:"16",cy:"16",r:"10",stroke:"currentColor",strokeWidth:"0.4",fill:"none",opacity:"0.15",children:[(0,r.jsx)("animate",{attributeName:"r",values:"9;11;9",dur:"4s",repeatCount:"indefinite"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.1;0.25;0.1",dur:"4s",repeatCount:"indefinite"})]})]})}function O(e){var t;let{node:n,x:i,y:a,onClose:l,onSubmit:o,isAuthenticated:c,existingComments:d}=e,[u,x]=(0,s.useState)(""),[h,p]=(0,s.useState)(!1),f=(0,s.useRef)(null),g=(0,s.useRef)(null),[v,b]=(0,s.useState)({x:0,y:0}),[y,j]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!f.current)return;let e=f.current.getBoundingClientRect(),t=window.innerWidth,n=window.innerHeight,r=i+14,s=a-e.height-14;r+e.width>t-16&&(r=t-e.width-16),r<16&&(r=16),s<16&&(s=a+28),s+e.height>n-16&&(s=n-e.height-16),b({x:r,y:s}),j(!0)},[i,a]),(0,s.useEffect)(()=>{if(c){let e=setTimeout(()=>{var e;return null===(e=g.current)||void 0===e?void 0:e.focus()},100);return()=>clearTimeout(e)}},[c]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&l()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l]),(0,s.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&l()},t=setTimeout(()=>{window.addEventListener("mousedown",e)},50);return()=>{clearTimeout(t),window.removeEventListener("mousedown",e)}},[l]);let w=(0,s.useCallback)(async()=>{if(u.trim()&&!h){p(!0);try{await o(u.trim()),x("")}catch(e){console.error("Failed to post comment:",e)}finally{p(!1)}}},[u,h,o]),k=(0,s.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),w())},[w]),N=m[n.prefix]||"#a1a1aa",z=(null==d?void 0:d.length)||0;return(0,r.jsxs)("div",{ref:f,style:{position:"fixed",left:v.x,top:v.y,width:320,zIndex:100,opacity:y?1:0,transform:y?"translateY(0)":"translateY(4px)",transition:"opacity 0.2s ease, transform 0.2s ease"},className:"bg-white border border-zinc-200 rounded-lg overflow-hidden",onContextMenu:e=>e.preventDefault(),children:[(0,r.jsx)("style",{children:"\n .comment-tooltip-shadow {\n box-shadow: 0 8px 32px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.08);\n }\n "}),(0,r.jsxs)("div",{className:"comment-tooltip-shadow p-[18px_20px]",children:[(0,r.jsx)("div",{className:"rounded-sm mb-2.5",style:{width:24,height:2,background:N,opacity:.6}}),(0,r.jsxs)("div",{className:"mb-3",children:[(0,r.jsx)("span",{className:"text-xs font-mono text-emerald-600",children:n.id}),(0,r.jsx)("h3",{className:"text-sm font-semibold text-zinc-800 leading-tight mt-0.5",children:n.title})]}),z>0&&d&&(0,r.jsxs)("div",{className:"mb-3 pb-3 border-b border-zinc-100",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-2",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-blue-500",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 20.25c4.97 0 9-3.694 9-8.25s-4.03-8.25-9-8.25S3 7.444 3 12c0 2.104.859 4.023 2.273 5.48.432.447.74 1.04.586 1.641a4.483 4.483 0 01-.923 1.785A5.969 5.969 0 006 21c1.282 0 2.47-.402 3.445-1.087.81.22 1.668.337 2.555.337z"})}),(0,r.jsxs)("span",{className:"text-[10px] font-medium text-zinc-500 uppercase tracking-wider",children:[z," comment",1!==z?"s":""]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[d.slice(0,2).map(e=>(0,r.jsxs)("div",{className:"flex gap-1.5",children:[(0,r.jsx)("div",{className:"shrink-0 w-4 h-4 rounded-full bg-zinc-100 overflow-hidden mt-0.5",children:e.avatar?(0,r.jsx)("img",{src:e.avatar,alt:"",className:"w-full h-full object-cover"}):(0,r.jsx)("div",{className:"w-full h-full flex items-center justify-center text-[7px] font-medium text-zinc-400",children:(e.handle||e.did).charAt(0).toUpperCase()})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(e.did),target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-medium text-zinc-500 hover:text-emerald-600 transition-colors",children:e.displayName||e.handle}),(0,r.jsx)("p",{className:"text-[11px] text-zinc-500 line-clamp-2 leading-tight",children:e.text})]})]},e.uri)),z>2&&(0,r.jsxs)("p",{className:"text-[10px] text-zinc-400 italic",children:["+",z-2," more — see detail panel"]})]})]}),c?(0,r.jsxs)("div",{children:[(0,r.jsx)("textarea",{ref:g,value:u,onChange:e=>x(e.target.value),onKeyDown:k,placeholder:"Leave a comment...",rows:3,className:"w-full px-2.5 py-2 text-xs border border-zinc-200 rounded-md bg-zinc-50 text-zinc-700 placeholder-zinc-400 resize-none focus:outline-none focus:ring-1 focus:ring-emerald-500 focus:border-emerald-500"}),(0,r.jsxs)("div",{className:"flex items-center justify-between mt-2",children:[(0,r.jsxs)("span",{className:"text-[10px] text-zinc-300",children:["undefined"!=typeof navigator&&(null===(t=navigator.platform)||void 0===t?void 0:t.includes("Mac"))?"⌘":"Ctrl","+Enter to send"]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:l,className:"px-2.5 py-1 text-[11px] text-zinc-400 hover:text-zinc-600 transition-colors",children:"Cancel"}),(0,r.jsx)("button",{onClick:w,disabled:!u.trim()||h,className:"px-3 py-1 text-[11px] font-medium text-white bg-emerald-500 rounded-md hover:bg-emerald-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:h?(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsxs)("svg",{className:"w-3 h-3 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Sending"]}):"Send"})]})]})]}):(0,r.jsxs)("div",{className:"text-center py-3",children:[(0,r.jsx)("svg",{className:"w-5 h-5 text-zinc-300 mx-auto mb-1.5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 10.5V6.75a4.5 4.5 0 10-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 002.25-2.25v-6.75a2.25 2.25 0 00-2.25-2.25H6.75a2.25 2.25 0 00-2.25 2.25v6.75a2.25 2.25 0 002.25 2.25z"})}),(0,r.jsx)("p",{className:"text-xs text-zinc-400",children:"Sign in to comment"})]})]})]})}function U(e){let{node:t,x:n,y:i,onShowDescription:a,onAddComment:l,onClaimTask:o,onUnclaimTask:c,onClose:d}=e,u=(0,s.useRef)(null),[x,h]=(0,s.useState)({x:0,y:0}),[m,p]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{if(!u.current)return;let e=u.current.getBoundingClientRect(),t=window.innerWidth,r=window.innerHeight,s=n+4,a=i+4;s+e.width>t-16&&(s=t-e.width-16),s<16&&(s=16),a+e.height>r-16&&(a=r-e.height-16),a<16&&(a=16),h({x:s,y:a}),p(!0)},[n,i]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&d()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[d]),(0,s.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&d()},t=setTimeout(()=>window.addEventListener("mousedown",e),50);return()=>{clearTimeout(t),window.removeEventListener("mousedown",e)}},[d]),(0,r.jsx)("div",{ref:u,style:{position:"fixed",left:x.x,top:x.y,zIndex:100,opacity:m?1:0,transform:m?"translateY(0)":"translateY(2px)",transition:"opacity 0.15s ease, transform 0.15s ease"},onContextMenu:e=>e.preventDefault(),children:(0,r.jsxs)("div",{className:"bg-white border border-zinc-200 rounded-lg overflow-hidden",style:{minWidth:180,boxShadow:"0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.06)"},children:[t.description&&(0,r.jsxs)("button",{onClick:a,className:"w-full px-3 py-2.5 text-xs text-zinc-700 hover:bg-zinc-50 flex items-center gap-2 transition-colors border-b border-zinc-100",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-zinc-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),"Show description"]}),(0,r.jsxs)("button",{onClick:l,className:"w-full px-3 py-2.5 text-xs text-zinc-700 hover:bg-zinc-50 flex items-center gap-2 transition-colors".concat(o||c?" border-b border-zinc-100":""),children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-zinc-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 20.25c4.97 0 9-3.694 9-8.25s-4.03-8.25-9-8.25S3 7.444 3 12c0 2.104.859 4.023 2.273 5.48.432.447.74 1.04.586 1.641a4.483 4.483 0 01-.923 1.785A5.969 5.969 0 006 21c1.282 0 2.47-.402 3.445-1.087.81.22 1.668.337 2.555.337z"})}),"Add comment"]}),o&&(0,r.jsxs)("button",{onClick:o,className:"w-full px-3 py-2.5 text-xs text-zinc-700 hover:bg-zinc-50 flex items-center gap-2 transition-colors",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-zinc-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z"})}),"Claim task"]}),c&&(0,r.jsxs)("button",{onClick:c,className:"w-full px-3 py-2.5 text-xs text-red-500 hover:bg-red-50 flex items-center gap-2 transition-colors",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M22 10.5h-6m-2.25-4.125a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zM4 19.235v-.11a6.375 6.375 0 0112.75 0v.109A12.318 12.318 0 0110.374 21c-2.331 0-4.512-.645-6.374-1.766z"})}),"Unclaim task"]})]})})}function H(e){let{isOpen:t,onClose:n,allComments:s,onNodeNavigate:i,isAuthenticated:a,currentDid:l,onLikeComment:o,onDeleteComment:c}=e;return(0,r.jsxs)("aside",{className:"hidden md:flex absolute top-0 right-0 h-full w-[360px] bg-white border-l border-zinc-200 flex-col shadow-xl z-30 transform transition-transform duration-300 ease-out ".concat(t?"translate-x-0":"translate-x-full"),children:[(0,r.jsxs)("div",{className:"shrink-0 px-5 py-3 border-b border-zinc-100 flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold text-zinc-400 uppercase tracking-wider",children:"All Comments"}),s.length>0&&(0,r.jsx)("span",{className:"px-1.5 py-0.5 bg-emerald-50 text-emerald-600 rounded-full text-[10px] font-medium",children:s.length})]}),(0,r.jsx)("button",{onClick:n,className:"p-1 text-zinc-400 hover:text-zinc-600 transition-colors rounded-full hover:bg-zinc-100",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar px-5 py-3",children:s.length>0?(0,r.jsx)("div",{className:"space-y-0",children:s.filter(e=>!e.replyTo).map(e=>(0,r.jsx)(Y,{comment:e,currentDid:l,isAuthenticated:a,onNodeNavigate:i,onLike:o,onDelete:c,depth:0},e.uri))}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)("svg",{className:"w-8 h-8 text-zinc-200 mb-3",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12.76c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.076-4.076a1.526 1.526 0 011.037-.443 48.282 48.282 0 005.68-.494c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z"})}),(0,r.jsx)("p",{className:"text-xs text-zinc-400",children:"No comments yet"}),(0,r.jsx)("p",{className:"text-[10px] text-zinc-300 mt-1",children:"Right-click a node to leave a comment"})]})}),(0,r.jsx)("div",{className:"shrink-0 px-5 py-2.5 border-t border-zinc-100 bg-zinc-50/50",children:(0,r.jsxs)("div",{className:"text-[10px] text-zinc-400",children:[s.length," comment",1!==s.length?"s":""," across all issues"]})})]})}function Y(e){let{comment:t,currentDid:n,isAuthenticated:i,onNodeNavigate:a,onLike:l,onDelete:o,depth:c}=e,[d,u]=(0,s.useState)(!1),[x,h]=(0,s.useState)(!1),m=n&&n===t.did,p=!!n&&t.likes.some(e=>e.did===n),f=async()=>{if(l&&!d){u(!0);try{await l(t)}catch(e){console.error("Failed to toggle like:",e)}finally{u(!1)}}},g=async()=>{if(o&&!x){h(!0);try{await o(t)}catch(e){console.error("Failed to delete comment:",e)}finally{h(!1)}}};return(0,r.jsxs)("div",{className:"".concat(c>0?"ml-4 pl-3 border-l border-zinc-100":""),children:[(0,r.jsxs)("div",{className:"py-3 ".concat(0===c?"border-b border-zinc-50":""),children:[0===c&&(0,r.jsx)("button",{onClick:()=>a(t.nodeId),className:"inline-flex items-center px-1.5 py-0.5 mb-1.5 rounded text-[10px] font-mono bg-emerald-50 text-emerald-600 hover:bg-emerald-100 transition-colors",children:t.nodeId}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("div",{className:"shrink-0 w-4 h-4 rounded-full bg-zinc-100 overflow-hidden",children:t.avatar?(0,r.jsx)("img",{src:t.avatar,alt:"",className:"w-full h-full object-cover"}):(0,r.jsx)("div",{className:"w-full h-full flex items-center justify-center text-[8px] font-medium text-zinc-400",children:(t.handle||t.did).charAt(0).toUpperCase()})}),(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(t.did),target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-zinc-600 truncate hover:text-emerald-600 transition-colors",children:t.displayName||t.handle||t.did.slice(0,16)+"..."}),(0,r.jsx)("span",{className:"text-[10px] text-zinc-300 shrink-0",children:T(t.createdAt)})]}),(0,r.jsx)("p",{className:"text-xs text-zinc-500 leading-relaxed whitespace-pre-wrap break-words",children:t.text}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1 text-[10px]",children:[(0,r.jsxs)("button",{onClick:f,disabled:!i||d,className:"flex items-center gap-0.5 transition-colors ".concat(p?"text-rose-500":"text-zinc-300 hover:text-rose-500"," disabled:opacity-50"),children:[(0,r.jsx)(L,{className:"w-3 h-3",filled:p}),t.likes.length>0&&(0,r.jsx)("span",{children:t.likes.length})]}),m&&o&&(0,r.jsx)("button",{onClick:g,disabled:x,className:"ml-auto text-zinc-300 hover:text-red-400 disabled:opacity-50 transition-colors",children:x?"...":"delete"})]})]}),t.replies.length>0&&(0,r.jsx)("div",{children:t.replies.map(e=>(0,r.jsx)(Y,{comment:e,currentDid:n,isAuthenticated:i,onNodeNavigate:a,onLike:l,onDelete:o,depth:c+1},e.uri))})]})}function q(e){let{type:t,className:n}=e,s=n||"w-3.5 h-3.5 shrink-0";switch(t){case"node-created":return(0,r.jsxs)("svg",{className:"".concat(s," text-emerald-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("line",{x1:"8",y1:"5",x2:"8",y2:"11"}),(0,r.jsx)("line",{x1:"5",y1:"8",x2:"11",y2:"8"})]});case"node-closed":return(0,r.jsxs)("svg",{className:"".concat(s," text-zinc-400"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("polyline",{points:"5.5,8 7.5,10 10.5,6"})]});case"node-status-changed":return(0,r.jsx)("svg",{className:"".concat(s," text-amber-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,r.jsx)("path",{d:"M3 8h10M10 5l3 3-3 3"})});case"node-priority-changed":return(0,r.jsx)("svg",{className:"".concat(s," text-amber-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,r.jsx)("path",{d:"M8 3v7M5 6l3-3 3 3M4 13h8"})});case"node-title-changed":return(0,r.jsx)("svg",{className:"".concat(s," text-amber-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,r.jsx)("path",{d:"M3 4h10M3 8h6M3 12h8"})});case"node-owner-changed":return(0,r.jsxs)("svg",{className:"".concat(s," text-amber-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"6",cy:"6",r:"2.5"}),(0,r.jsx)("path",{d:"M1.5 13c0-2 1.8-3.5 4.5-3.5M10 9l2 2 3-3"})]});case"link-added":return(0,r.jsx)("svg",{className:"".concat(s," text-blue-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,r.jsx)("path",{d:"M6.5 9.5l3-3M4 11a2.5 2.5 0 003.5 0l1-1M8.5 6a2.5 2.5 0 013.5 0l0 0"})});case"link-removed":return(0,r.jsxs)("svg",{className:"".concat(s," text-red-400"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("path",{d:"M4 11a2.5 2.5 0 003.5 0l1-1M8.5 6a2.5 2.5 0 013.5 0l0 0"}),(0,r.jsx)("line",{x1:"3",y1:"3",x2:"13",y2:"13",strokeWidth:"1.5"})]});case"comment-added":case"reply-added":return(0,r.jsx)("svg",{className:"".concat(s," text-blue-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,r.jsx)("path",{d:"M2 4.5a1.5 1.5 0 011.5-1.5h9A1.5 1.5 0 0114 4.5v5a1.5 1.5 0 01-1.5 1.5H5L2 14V4.5z"})});case"task-claimed":return(0,r.jsxs)("svg",{className:"".concat(s," text-emerald-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"5.5",r:"2.5"}),(0,r.jsx)("path",{d:"M3 13.5c0-2.5 2.2-4.5 5-4.5s5 2 5 4.5"})]});case"task-unclaimed":return(0,r.jsxs)("svg",{className:"".concat(s," text-red-400"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"5.5",r:"2.5"}),(0,r.jsx)("path",{d:"M3 13.5c0-2.5 2.2-4.5 5-4.5s5 2 5 4.5"}),(0,r.jsx)("line",{x1:"11",y1:"3",x2:"13",y2:"5"})]});case"like-added":return(0,r.jsx)("svg",{className:"".concat(s," text-rose-400"),viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 13.7l-.6-.5C4 10.2 2 8.3 2 6a3 3 0 016-1 3 3 0 016 1c0 2.3-2 4.2-5.4 7.2l-.6.5z"})})}}function X(e){switch(e){case"node-created":case"task-claimed":return"bg-emerald-400";case"node-closed":return"bg-zinc-300";case"node-status-changed":case"node-priority-changed":case"node-title-changed":case"node-owner-changed":return"bg-amber-400";case"link-added":case"comment-added":case"reply-added":return"bg-blue-400";case"link-removed":case"task-unclaimed":return"bg-red-300";case"like-added":return"bg-rose-300"}}function V(e){var t,n,r;switch(e.type){case"node-created":{let n=(null===(t=e.meta)||void 0===t?void 0:t.issueType)||"task";return"".concat(n," created")}case"node-closed":return"closed".concat(e.detail&&"Closed"!==e.detail?" (".concat(e.detail,")"):"");case"node-status-changed":return e.detail||"status changed";case"node-priority-changed":return"priority ".concat(e.detail||"changed");case"node-title-changed":return"title updated";case"node-owner-changed":return"owner ".concat(e.detail||"changed");case"link-added":return"dep added: ".concat((null===(n=e.meta)||void 0===n?void 0:n.target)||"");case"link-removed":return"dep removed: ".concat((null===(r=e.meta)||void 0===r?void 0:r.target)||"");case"comment-added":return e.detail||"commented";case"reply-added":return e.detail||"replied";case"task-claimed":return"claimed this task";case"task-unclaimed":return"unclaimed this task";case"like-added":return e.detail||"liked a comment"}}function K(e){let{event:t,onNodeClick:n}=e;return(0,r.jsxs)("div",{className:"flex items-center gap-2 py-2 px-3 group hover:bg-zinc-50/60 transition-colors",children:[(0,r.jsx)("div",{className:"w-1 h-1 rounded-full shrink-0 ".concat(X(t.type))}),(0,r.jsx)(q,{type:t.type,className:"w-3 h-3 shrink-0"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 text-[11px] text-zinc-600 truncate",children:[t.actor?(0,r.jsxs)(r.Fragment,{children:[t.actor.did?(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(t.actor.did),target:"_blank",rel:"noopener noreferrer",className:"font-medium text-zinc-800 hover:text-emerald-600 transition-colors",children:t.actor.handle.split(".")[0]}):(0,r.jsx)("span",{className:"font-medium text-zinc-800",children:t.actor.handle.split(".")[0]})," "]}):n?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:()=>n(t.nodeId),className:"font-medium text-zinc-700 hover:text-emerald-600 transition-colors",children:t.nodeId})," "]}):null,(0,r.jsx)("span",{className:"text-zinc-500",children:V(t)})]}),(0,r.jsx)("span",{className:"text-[10px] text-zinc-400 shrink-0 tabular-nums opacity-0 group-hover:opacity-100 transition-opacity",children:T(new Date(t.time).toISOString())})]})}function $(e){var t;let{event:n,onNodeClick:s}=e;return(0,r.jsxs)("div",{className:"flex gap-3 py-3 px-4 hover:bg-zinc-50/50 transition-colors group",children:[(0,r.jsx)("div",{className:"w-0.5 self-stretch rounded-full shrink-0 ".concat(X(n.type))}),(0,r.jsx)("div",{className:"mt-0.5 shrink-0",children:(null===(t=n.actor)||void 0===t?void 0:t.avatar)?(0,r.jsx)("img",{src:n.actor.avatar,alt:n.actor.handle,className:"w-7 h-7 rounded-full ring-1 ring-zinc-100"}):n.actor?(0,r.jsx)("div",{className:"w-7 h-7 rounded-full bg-zinc-100 flex items-center justify-center text-[11px] font-medium text-zinc-500",children:n.actor.handle.charAt(0).toUpperCase()}):(0,r.jsx)("div",{className:"w-7 h-7 rounded-full bg-zinc-50 flex items-center justify-center",children:(0,r.jsx)(q,{type:n.type,className:"w-3.5 h-3.5"})})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-1.5 text-[12px] leading-snug",children:[n.actor&&(n.actor.did?(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(n.actor.did),target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-zinc-800 hover:text-emerald-600 transition-colors truncate max-w-[140px]",children:n.actor.handle.split(".")[0]}):(0,r.jsx)("span",{className:"font-semibold text-zinc-800 truncate max-w-[140px]",children:n.actor.handle.split(".")[0]})),(0,r.jsx)("span",{className:"text-zinc-500",children:V(n)})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mt-1",children:[s&&(0,r.jsx)("button",{onClick:()=>s(n.nodeId),className:"inline-flex items-center px-1.5 py-0.5 text-[10px] font-mono font-medium text-emerald-700 bg-emerald-50 rounded-md hover:bg-emerald-100 transition-colors",children:n.nodeId}),n.nodeTitle&&(0,r.jsx)("span",{className:"text-[11px] text-zinc-400 truncate",children:n.nodeTitle})]})]}),(0,r.jsx)("span",{className:"text-[10px] text-zinc-400 shrink-0 tabular-nums mt-0.5",children:T(new Date(n.time).toISOString())})]})}function J(e){let{event:t,variant:n="compact",onNodeClick:s}=e;return"compact"===n?(0,r.jsx)(K,{event:t,onNodeClick:s}):(0,r.jsx)($,{event:t,onNodeClick:s})}function G(e){let{events:t,collapsed:n,onToggleCollapse:s,onExpandPanel:i,onNodeClick:a}=e,l=t.filter(e=>Date.now()-e.time<3e5).length;return n?(0,r.jsxs)("button",{onClick:s,className:"group flex items-center gap-2 px-3 py-2 bg-white/90 backdrop-blur-sm rounded-full border border-zinc-200/80 shadow-sm hover:bg-white hover:shadow-md transition-all",title:"Show activity feed",children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5 text-zinc-400 group-hover:text-emerald-500 transition-colors",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("polyline",{points:"8,4 8,8 11,10"})]}),(0,r.jsx)("span",{className:"text-xs text-zinc-500 group-hover:text-zinc-700 transition-colors",children:"Activity"}),l>0&&(0,r.jsx)("span",{className:"text-[10px] font-medium text-white bg-emerald-500 rounded-full px-1.5 py-0.5 min-w-[18px] text-center leading-tight",children:l})]}):(0,r.jsxs)("div",{className:"w-72 bg-white/95 backdrop-blur-sm rounded-xl border border-zinc-200/80 shadow-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3.5 py-2.5 border-b border-zinc-100/80",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),(0,r.jsx)("span",{className:"text-[11px] font-semibold text-zinc-600",children:"Live Activity"})]}),(0,r.jsx)("button",{onClick:s,className:"text-zinc-400 hover:text-zinc-600 transition-colors p-1 -mr-0.5 rounded-full hover:bg-zinc-100",title:"Collapse",children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"})})})]}),(0,r.jsx)("div",{className:"py-0.5 max-h-[260px] overflow-y-auto custom-scrollbar",children:0===t.length?(0,r.jsxs)("div",{className:"py-6 text-center",children:[(0,r.jsxs)("svg",{className:"w-5 h-5 text-zinc-200 mx-auto mb-1.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("polyline",{points:"8,4 8,8 11,10"})]}),(0,r.jsx)("p",{className:"text-[11px] text-zinc-400",children:"No activity yet"})]}):t.slice(0,6).map((e,t)=>(0,r.jsx)("div",{className:0===t?"bg-emerald-50/30":"",children:(0,r.jsx)(J,{event:e,variant:"compact",onNodeClick:a})},e.id))}),t.length>0&&(0,r.jsxs)("div",{className:"flex items-center justify-between px-3.5 py-2 border-t border-zinc-100/80 bg-zinc-50/30",children:[(0,r.jsxs)("span",{className:"text-[10px] text-zinc-400",children:[t.length," event",1!==t.length?"s":""]}),(0,r.jsxs)("button",{onClick:i,className:"text-[11px] text-emerald-600 hover:text-emerald-700 transition-colors font-medium flex items-center gap-1",children:["See all",(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]})]})]})}function Z(e,t){let n=new Set(e.map(e=>e.id)),r=[...e];for(let e of t)n.has(e.id)||(n.add(e.id),r.push(e));return r.sort((e,t)=>t.time-e.time),r.slice(0,200)}let Q=[{key:"issues",label:"Issues",icon:"circle"},{key:"deps",label:"Deps",icon:"link"},{key:"comments",label:"Comments",icon:"chat"},{key:"claims",label:"Claims",icon:"user"},{key:"likes",label:"Likes",icon:"heart"}];function ee(e){let{events:t,isOpen:n,onClose:i,onNodeClick:a}=e,[l,o]=(0,s.useState)(""),[c,d]=(0,s.useState)(new Set(Q.map(e=>e.key))),u=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.size>1&&n.delete(e):n.add(e),n})},x=(0,s.useMemo)(()=>{let e=t;if(e=e.filter(e=>c.has(function(e){switch(e){case"node-created":case"node-closed":case"node-status-changed":case"node-priority-changed":case"node-title-changed":case"node-owner-changed":return"issues";case"link-added":case"link-removed":return"deps";case"comment-added":case"reply-added":return"comments";case"task-claimed":case"task-unclaimed":return"claims";case"like-added":return"likes"}}(e.type))),l.trim()){let t=l.trim().toLowerCase();e=e.filter(e=>{var n;return e.nodeId.toLowerCase().includes(t)||e.nodeTitle&&e.nodeTitle.toLowerCase().includes(t)||(null===(n=e.actor)||void 0===n?void 0:n.handle)&&e.actor.handle.toLowerCase().includes(t)||e.detail&&e.detail.toLowerCase().includes(t)})}return e},[t,c,l]),h=(0,s.useMemo)(()=>(function(e){let t=new Map,n=[];for(let r of e){let e=function(e){let t=Date.now()-e,n=t/36e5,r=t/864e5;return n<1?"Just now":n<24?"Today":r<2?"Yesterday":r<7?"This week":r<30?"This month":"Older"}(r.time);t.has(e)||(t.set(e,[]),n.push(e)),t.get(e).push(r)}return n.map(e=>({label:e,events:t.get(e)}))})(x),[x]),m=c.size===Q.length;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("aside",{className:"hidden md:flex absolute top-0 right-0 h-full w-[360px] bg-white border-l border-zinc-200 flex-col shadow-xl z-30 transform transition-transform duration-300 ease-out ".concat(n?"translate-x-0":"translate-x-full"),children:[(0,r.jsxs)("div",{className:"shrink-0 px-5 py-3 border-b border-zinc-100 flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold text-zinc-400 uppercase tracking-wider",children:"Activity"}),t.length>0&&(0,r.jsx)("span",{className:"px-1.5 py-0.5 bg-emerald-50 text-emerald-600 rounded-full text-[10px] font-medium",children:t.length})]}),(0,r.jsx)("button",{onClick:i,className:"p-1 text-zinc-400 hover:text-zinc-600 transition-colors rounded-full hover:bg-zinc-100",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"px-4 pt-3 pb-2 shrink-0",children:(0,r.jsxs)("div",{className:"flex items-center bg-zinc-50/80 rounded-full border border-zinc-200/60 overflow-hidden",children:[(0,r.jsx)("div",{className:"pl-3 pr-1 text-zinc-400",children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),(0,r.jsx)("input",{type:"text",value:l,onChange:e=>o(e.target.value),placeholder:"Search activity...",className:"flex-1 px-2 py-2 text-xs text-zinc-800 bg-transparent outline-none placeholder:text-zinc-400"}),l&&(0,r.jsx)("button",{onClick:()=>o(""),className:"pr-3 text-zinc-400 hover:text-zinc-600",children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5 px-4 pb-3 shrink-0",children:Q.map(e=>{let t=c.has(e.key);return(0,r.jsx)("button",{onClick:()=>u(e.key),className:"px-2.5 py-1 text-[11px] font-medium rounded-full border transition-all ".concat(t?"bg-emerald-50 text-emerald-700 border-emerald-200 shadow-sm":"bg-white text-zinc-400 border-zinc-200 hover:text-zinc-600 hover:border-zinc-300"),children:e.label},e.key)})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar border-t border-zinc-100",children:0===x.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)("svg",{className:"w-8 h-8 text-zinc-200 mb-3",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("p",{className:"text-xs text-zinc-400",children:l.trim()?"No activity matching your search":"No activity yet"}),l.trim()&&(0,r.jsx)("button",{onClick:()=>o(""),className:"text-[11px] text-emerald-600 hover:text-emerald-700 mt-1.5",children:"Clear search"})]}):h.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"sticky top-0 z-[1] px-4 py-1.5 bg-zinc-50/95 backdrop-blur-sm border-b border-zinc-100/60",children:(0,r.jsx)("span",{className:"text-[10px] font-semibold text-zinc-400 uppercase tracking-wider",children:e.label})}),(0,r.jsx)("div",{className:"divide-y divide-zinc-50",children:e.events.map(e=>(0,r.jsx)(J,{event:e,variant:"full",onNodeClick:a},e.id))})]},e.label))}),(0,r.jsx)("div",{className:"shrink-0 px-5 py-2.5 border-t border-zinc-100 bg-zinc-50/50",children:(0,r.jsxs)("div",{className:"text-[10px] text-zinc-400",children:[x.length," event",1!==x.length?"s":"",!m&&" (filtered)",l.trim()&&' matching "'.concat(l.trim(),'"')]})})]}),(0,r.jsx)("div",{className:"md:hidden fixed inset-x-0 bottom-0 z-20 transition-transform duration-300 ease-out ".concat(n?"translate-y-0":"translate-y-full"),children:(0,r.jsxs)("div",{className:"bg-white rounded-t-2xl shadow-xl border-t border-zinc-200 max-h-[60vh] flex flex-col",children:[(0,r.jsx)("div",{className:"flex justify-center pt-3 pb-1",children:(0,r.jsx)("div",{className:"w-8 h-1 bg-zinc-300 rounded-full"})}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"text-sm font-semibold text-zinc-900",children:"Activity"}),t.length>0&&(0,r.jsx)("span",{className:"px-1.5 py-0.5 bg-emerald-50 text-emerald-600 rounded-full text-[10px] font-medium",children:t.length})]}),(0,r.jsx)("button",{onClick:i,className:"p-1 text-zinc-400 hover:text-zinc-600",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5 px-5 pb-3",children:Q.map(e=>(0,r.jsx)("button",{onClick:()=>u(e.key),className:"px-2.5 py-1 text-[11px] font-medium rounded-full border transition-colors ".concat(c.has(e.key)?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-white text-zinc-400 border-zinc-200"),children:e.label},e.key))}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:0===x.length?(0,r.jsx)("div",{className:"py-8 text-center text-xs text-zinc-400",children:"No activity matching filters"}):h.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"sticky top-0 z-[1] px-5 py-1.5 bg-zinc-50/95 backdrop-blur-sm border-b border-zinc-100/60",children:(0,r.jsx)("span",{className:"text-[10px] font-semibold text-zinc-400 uppercase tracking-wider",children:e.label})}),(0,r.jsx)("div",{className:"divide-y divide-zinc-50",children:e.events.map(e=>(0,r.jsx)(J,{event:e,variant:"full",onNodeClick:a},e.id))})]},e.label))})]})})]})}let et=new Map,en=new Map;async function er(e){let t=et.get(e);if(t)return t;let n=en.get(e);if(n)return n;let r=(async()=>{try{let t=await fetch("https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=".concat(encodeURIComponent(e)));if(!t.ok)throw Error("Profile fetch failed: ".concat(t.status));let n=await t.json(),r={did:e,handle:n.handle||e,displayName:n.displayName||void 0,avatar:n.avatar||void 0};return et.set(e,r),r}catch(n){let t={did:e,handle:e.slice(0,20)+"..."};return et.set(e,t),t}finally{en.delete(e)}})();return en.set(e,r),r}async function es(e){let t;let n=[],r=!0,s=0;for(;r&&s<5;){var i,a;let l=await fetch("https://hypergoat-app-production.up.railway.app/graphql",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"\n query FetchRecords($collection: String!, $first: Int, $after: String) {\n records(collection: $collection, first: $first, after: $after) {\n edges {\n node {\n cid\n collection\n did\n rkey\n uri\n value\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n",variables:{collection:e,first:100,after:t}})});if(!l.ok)throw Error("Indexer fetch failed: ".concat(l.status));let o=await l.json();if(null===(i=o.errors)||void 0===i?void 0:i.length)throw Error(o.errors[0].message);let c=null===(a=o.data)||void 0===a?void 0:a.records;if(!c)break;for(let e of c.edges)n.push(e.node);r=c.pageInfo.hasNextPage,t=c.pageInfo.endCursor,s++}return n}function ei(e){let{totalSteps:t,currentStep:n,currentTime:i,isPlaying:a,speed:l,onStepChange:o,onPlayPause:c,onSpeedChange:d}=e,u=(0,s.useCallback)(e=>{o(Number(e.target.value))},[o]),x=(0,s.useCallback)(()=>{d(1===l?2:2===l?4:1)},[l,d]),h=t>1;return(0,r.jsx)("div",{className:"bg-white/90 backdrop-blur-sm rounded-lg border border-zinc-200 shadow-sm px-3 py-2 min-w-[280px] max-w-[480px]",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:c,disabled:!h,className:"shrink-0 w-6 h-6 flex items-center justify-center rounded transition-colors ".concat(a?"text-emerald-500 hover:text-emerald-600":"text-zinc-500 hover:text-zinc-700"," disabled:opacity-40 disabled:cursor-not-allowed"),children:a?(0,r.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:[(0,r.jsx)("rect",{x:"3",y:"2",width:"3.5",height:"12",rx:"1"}),(0,r.jsx)("rect",{x:"9.5",y:"2",width:"3.5",height:"12",rx:"1"})]}):(0,r.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M4 2l10 6-10 6V2z"})})}),(0,r.jsx)("input",{type:"range",min:0,max:Math.max(t-1,0),value:n,onChange:u,disabled:!h,className:"timeline-slider flex-1 h-4 disabled:opacity-40"}),(0,r.jsxs)("span",{className:"shrink-0 text-xs text-zinc-500 font-medium text-right whitespace-nowrap",children:[(0,r.jsxs)("span",{className:"text-zinc-400",children:[n+1,"/",t]})," ",new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]}),(0,r.jsxs)("button",{onClick:x,className:"shrink-0 px-1.5 py-0.5 text-[10px] font-semibold rounded transition-colors ".concat(l>1?"bg-emerald-500 text-white":"text-zinc-500 border border-zinc-200 hover:text-zinc-700"),children:[l,"x"]})]})})}function ea(e,t,n){let r=Date.now(),s=new Map(e.graphData.nodes.map(e=>[e.id,e])),a=new Set(e.graphData.links.map(i)),l=t.graphData.nodes.map(e=>{let i=s.get(e.id);if(!i){let n=function(e,t,n){for(let r of t){let t="object"==typeof r.source?r.source.id:r.source,s="object"==typeof r.target?r.target.id:r.target;if(t===e&&n.has(s)){let e=n.get(s);if(null!=e.x&&null!=e.y)return{x:e.x,y:e.y}}if(s===e&&n.has(t)){let e=n.get(t);if(null!=e.x&&null!=e.y)return{x:e.x,y:e.y}}}return null}(e.id,t.graphData.links,s);return{...e,_spawnTime:r,x:n?n.x+(Math.random()-.5)*40:void 0,y:n?n.y+(Math.random()-.5)*40:void 0}}let a={...e,x:i.x,y:i.y,fx:i.fx,fy:i.fy};if(n.changedNodes.has(e.id)){let t=n.changedNodes.get(e.id).find(e=>"status"===e.field);t&&(a._changedAt=r,a._prevStatus=t.from)}return a});for(let e of n.removedNodeIds){let t=s.get(e);t&&l.push({...t,_removeTime:r})}let o=t.graphData.links.map(e=>{let t=i(e);return a.has(t)?e:{...e,_spawnTime:r}});for(let t of n.removedLinkKeys){let n=e.graphData.links.find(e=>i(e)===t);n&&o.push({source:"object"==typeof n.source?n.source.id:n.source,target:"object"==typeof n.target?n.target.id:n.target,type:n.type,_removeTime:r})}return{...t,graphData:{nodes:l,links:o}}}let el={open:"bg-emerald-500",in_progress:"bg-amber-500",blocked:"bg-red-500",deferred:"bg-violet-500",closed:"bg-zinc-400"};function eo(){var e,t,n;let[i,l]=(0,s.useState)(null),[o,c]=(0,s.useState)(!0),[d,u]=(0,s.useState)(null),[x,h]=(0,s.useState)(null),[m,p]=(0,s.useState)(null),[f,g]=(0,s.useState)("Beads"),[v,b]=(0,s.useState)(0),[y,j]=(0,s.useState)({}),{isAuthenticated:w,session:k}=(0,R.a)(),{commentsByNode:z,commentedNodeIds:C,allComments:M,refetch:S}=function(){let[e,t]=(0,s.useState)(new Map),[n,r]=(0,s.useState)(new Map),[i,a]=(0,s.useState)([]),[l,o]=(0,s.useState)(!0),[c,d]=(0,s.useState)(null),u=(0,s.useRef)(!1),x=(0,s.useCallback)(async()=>{try{o(!0),d(null);let[e,n]=await Promise.all([es("org.impactindexer.review.comment"),es("org.impactindexer.review.like")]),s=e.filter(e=>{let t=e.value.subject;return(null==t?void 0:t.uri)&&"string"==typeof t.uri&&t.uri.startsWith("beads:")}),i=new Map;for(let e of n){let t=e.value.subject;if((null==t?void 0:t.uri)&&"string"==typeof t.uri&&t.uri.startsWith("at://")){let n=i.get(t.uri)||[];n.push(e),i.set(t.uri,n)}}let l=new Set;for(let e of s)l.add(e.did);for(let e of n)l.add(e.did);let c=await Promise.all([...l].map(e=>er(e))),x=new Map(c.map(e=>[e.did,e])),h=[];for(let e of s){let t=e.value,n=t.subject.uri.replace(/^beads:/,""),r=t.text||"",s=t.createdAt||"",a=t.replyTo||void 0,l=x.get(e.did),o=(i.get(e.uri)||[]).map(e=>{let t=x.get(e.did),n=e.value;return{did:e.did,handle:(null==t?void 0:t.handle)||e.did.slice(0,20)+"...",displayName:null==t?void 0:t.displayName,avatar:null==t?void 0:t.avatar,createdAt:n.createdAt||"",uri:e.uri,rkey:e.rkey}}),c={did:e.did,handle:(null==l?void 0:l.handle)||e.did.slice(0,20)+"...",displayName:null==l?void 0:l.displayName,avatar:null==l?void 0:l.avatar,text:r,createdAt:s,uri:e.uri,rkey:e.rkey,nodeId:n,replyTo:a,likes:o,replies:[]};h.push(c)}let m=new Map;for(let e of h)m.set(e.uri,e);let p=[];for(let e of h){if(e.replyTo){let t=m.get(e.replyTo);if(t){t.replies.push(e);continue}}p.push(e)}p.sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()),function e(t){for(let n of t)n.replies.sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),e(n.replies)}(p);let f=new Map;for(let e of p){let t=f.get(e.nodeId)||[];t.push(e),f.set(e.nodeId,t)}let g=new Map;for(let e of h)g.set(e.nodeId,(g.get(e.nodeId)||0)+1);let v=[...h].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());u.current||(t(f),r(g),a(v))}catch(e){if(!u.current){let t=e instanceof Error?e.message:"Failed to fetch comments";console.error("Failed to fetch beads comments:",e),d(t)}}finally{u.current||o(!1)}},[]);return(0,s.useEffect)(()=>(u.current=!1,x(),()=>{u.current=!0}),[x]),{commentsByNode:e,commentedNodeIds:n,allComments:i,isLoading:l,error:c,refetch:x}}(),[L,I]=(0,s.useState)(new Map),[E,P]=(0,s.useState)(new Set),W=(0,s.useMemo)(()=>{let e=new Map;if(M)for(let t of M){if(e.has(t.nodeId)||E.has(t.nodeId))continue;let n=t.text.trim();n.startsWith("@")&&-1===n.indexOf(" ")&&e.set(t.nodeId,{avatar:t.avatar,handle:t.handle,claimedAt:t.createdAt,did:t.did,rkey:t.rkey})}for(let[t,n]of L)e.has(t)||E.has(t)||e.set(t,n);return e},[M,L,E]),[B,Y]=(0,s.useState)(!1),[q,X]=(0,s.useState)([]),[V,K]=(0,s.useState)(!1),[$,J]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!i)return;let e=function(e,t,n){let r=[],s=new Set;function i(e){s.has(e.id)||(s.add(e.id),r.push(e))}for(let t of e){if(t.createdAt){let e=new Date(t.createdAt).getTime();isNaN(e)||i({id:"node-created:".concat(t.id,":").concat(e),type:"node-created",time:e,nodeId:t.id,nodeTitle:t.title,detail:t.issueType,meta:{issueType:t.issueType,prefix:t.prefix}})}if(t.closedAt){let e=new Date(t.closedAt).getTime();isNaN(e)||i({id:"node-closed:".concat(t.id,":").concat(e),type:"node-closed",time:e,nodeId:t.id,nodeTitle:t.title,detail:t.closeReason||"Closed",meta:{prefix:t.prefix}})}}for(let e of t)if(e.createdAt){let t=new Date(e.createdAt).getTime();if(!isNaN(t)){let n="object"==typeof e.source?e.source.id:e.source,r="object"==typeof e.target?e.target.id:e.target;i({id:"link-added:".concat(n,"->").concat(r,":").concat(t),type:"link-added",time:t,nodeId:n,detail:"".concat(e.type," ").concat(r),meta:{linkType:e.type,target:r}})}}if(n)for(let e of n){let t=new Date(e.createdAt).getTime();if(isNaN(t))continue;let n={handle:e.handle,avatar:e.avatar,did:e.did};for(let r of(i(e.text.startsWith("@")&&-1===e.text.trim().indexOf(" ")?{id:"task-claimed:".concat(e.nodeId,":").concat(t),type:"task-claimed",time:t,nodeId:e.nodeId,actor:n,detail:e.text}:e.replyTo?{id:"reply-added:".concat(e.nodeId,":").concat(e.rkey),type:"reply-added",time:t,nodeId:e.nodeId,actor:n,detail:e.text.length>80?e.text.slice(0,80)+"...":e.text}:{id:"comment-added:".concat(e.nodeId,":").concat(e.rkey),type:"comment-added",time:t,nodeId:e.nodeId,actor:n,detail:e.text.length>80?e.text.slice(0,80)+"...":e.text}),e.likes)){let t=new Date(r.createdAt).getTime();isNaN(t)||i({id:"like-added:".concat(e.nodeId,":").concat(r.rkey),type:"like-added",time:t,nodeId:e.nodeId,actor:{handle:r.handle,avatar:r.avatar,did:r.did},detail:"Liked comment by ".concat(e.handle)})}}return r.sort((e,t)=>t.time-e.time),r}(i.graphData.nodes,i.graphData.links,M);X(t=>Z(t,e))},[i,M]);let[Q,et]=(0,s.useState)(null),[en,eo]=(0,s.useState)(null),[ec,ed]=(0,s.useState)(null),[eu,ex]=(0,s.useState)(null),[eh,em]=(0,s.useState)(!1),[ep,ef]=(0,s.useState)(""),[eg,ev]=(0,s.useState)(0),[eb,ey]=(0,s.useState)(!1),[ej,ew]=(0,s.useState)(0),[ek,eN]=(0,s.useState)(!1),[ez,eC]=(0,s.useState)(1),[eM,eS]=(0,s.useState)(null),eD=(0,s.useRef)(null),eL=(0,s.useRef)(null),eT=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=null,t=null,n=null,r=!0;return function s(){(e=new EventSource("/api/beads/stream")).onmessage=e=>{if(r)try{let t=JSON.parse(e.data);if(t.error){u(t.error),c(!1);return}let n=eT.current,r=a(n,t);if(!n){eT.current=t,l(t),c(!1);return}if(!r.hasChanges)return;let s=function(e,t){let n=[],r=Date.now(),s=new Map(t.map(e=>[e.id,e]));for(let t of e.addedNodeIds){let e=s.get(t);n.push({id:"node-created:".concat(t,":").concat(r),type:"node-created",time:r,nodeId:t,nodeTitle:null==e?void 0:e.title,detail:(null==e?void 0:e.issueType)||"task",meta:e?{issueType:e.issueType,prefix:e.prefix}:void 0})}for(let t of e.removedNodeIds)n.push({id:"node-closed:".concat(t,":").concat(r),type:"node-closed",time:r,nodeId:t,detail:"Removed"});for(let[t,i]of e.changedNodes){let e=s.get(t);for(let s of i){let i;switch(s.field){case"status":default:i="node-status-changed";break;case"priority":i="node-priority-changed";break;case"title":i="node-title-changed";break;case"owner":i="node-owner-changed"}n.push({id:"".concat(i,":").concat(t,":").concat(r,":").concat(s.field),type:i,time:r,nodeId:t,nodeTitle:null==e?void 0:e.title,detail:"".concat(s.from," → ").concat(s.to),meta:{field:s.field,from:s.from,to:s.to}})}}for(let t of e.addedLinkKeys){let e=t.match(/^(.+)->(.+):(.+)$/);if(e){let[,s,i,a]=e;n.push({id:"link-added:".concat(t,":").concat(r),type:"link-added",time:r,nodeId:s,detail:"".concat(a," ").concat(i),meta:{linkType:a,target:i}})}}for(let t of e.removedLinkKeys){let e=t.match(/^(.+)->(.+):(.+)$/);if(e){let[,s,i,a]=e;n.push({id:"link-removed:".concat(t,":").concat(r),type:"link-removed",time:r,nodeId:s,detail:"".concat(a," ").concat(i),meta:{linkType:a,target:i}})}}return n}(r,t.graphData.nodes);s.length>0&&X(e=>Z(e,s));let i=ea(n,t,r);eT.current=i,l(i)}catch(e){console.error("Failed to parse SSE message:",e)}},e.onerror=()=>{(null==e?void 0:e.readyState)===EventSource.CLOSED&&(t=setTimeout(s,5e3))},n=setTimeout(()=>{r&&!eT.current&&fetch("/api/beads").then(e=>e.json()).then(e=>{r&&!eT.current&&(eT.current=e,l(e),c(!1))}).catch(()=>{})},5e3)}(),()=>{r=!1,null==e||e.close(),t&&clearTimeout(t),n&&clearTimeout(n)}},[]),(0,s.useEffect)(()=>{fetch("/api/config").then(e=>e.json()).then(e=>{e.name&&g(e.name),e.repoCount&&b(e.repoCount),e.repoUrls&&j(e.repoUrls)}).catch(()=>{})},[]),(0,s.useEffect)(()=>{if(!i)return;let e=setTimeout(()=>{let e=Date.now(),t=i.graphData.nodes.filter(t=>!t._removeTime||e-t._removeTime<600),n=i.graphData.links.filter(t=>!t._removeTime||e-t._removeTime<600);(t.length!==i.graphData.nodes.length||n.length!==i.graphData.links.length)&&l(e=>e?{...e,graphData:{nodes:t,links:n}}:e)},700);return()=>clearTimeout(e)},[i]);let eA=(0,s.useMemo)(()=>i?function(e,t){let n=[];for(let t of e){let e=new Date(t.createdAt).getTime();if(isNaN(e)||n.push({time:e,type:"node-created",id:t.id}),t.closedAt){let e=new Date(t.closedAt).getTime();isNaN(e)||n.push({time:e,type:"node-closed",id:t.id})}}n.sort((e,t)=>e.time-t.time);let r=n.length>0?n[0].time:Date.now(),s=n.length>0?n[n.length-1].time:Date.now();return{events:n,minTime:r,maxTime:s}}(i.graphData.nodes,i.graphData.links):null,[i]),eI=(0,s.useCallback)(()=>{ey(e=>{let t=!e;return t&&ew(-1),eN(!1),eS(null),t})},[]);(0,s.useEffect)(()=>{if(!ek||!eb||!eA)return;let e=setInterval(()=>{ew(e=>{let t=e+1;return t>=eA.events.length?(eN(!1),e):t})},2e3/ez);return()=>clearInterval(e)},[ek,eb,ez,eA]),(0,s.useEffect)(()=>{if(!eb||!i||!eA)return;if(-1===ej){eS(e=>{let t={...i,graphData:{nodes:[],links:[]}};if(!e)return t;let n=a(e,t);return n.hasChanges?ea(e,t,n):e});return}if(0===eA.events.length)return;let e=eA.events[ej];if(!e)return;let t=function(e,t,n){let r=new Set,s=[];for(let t of e){let e=new Date(t.createdAt).getTime();if(isNaN(e)||e>n)continue;r.add(t.id);let i=t.status;if(t.closedAt){let e=new Date(t.closedAt).getTime();!isNaN(e)&&e<=n?i="closed":"closed"===t.status&&(i="open")}i!==t.status?s.push({...t,status:i}):s.push(t)}let i=[];for(let e of t){let t="object"==typeof e.source?e.source.id:e.source,n="object"==typeof e.target?e.target.id:e.target;r.has(t)&&r.has(n)&&i.push({...e,source:t,target:n})}return{nodes:s,links:i}}(i.graphData.nodes,i.graphData.links,e.time),n={...i,graphData:{nodes:t.nodes,links:t.links}};eS(e=>{if(!e)return n;let t=a(e,n);return t.hasChanges?ea(e,n,t):e})},[eb,i,eA,ej]);let eE=(0,s.useCallback)(e=>{h(t=>(null==t?void 0:t.id)===e.id?null:e),Y(!1),K(!1)},[]),eP=(0,s.useCallback)(e=>{p(e)},[]),eW=(0,s.useCallback)(()=>{h(null),et(null),eo(null)},[]),eB=(0,s.useCallback)((e,t)=>{eo(null),e.description||w?et({node:e,x:t.clientX,y:t.clientY}):eo({node:e,x:t.clientX,y:t.clientY})},[w]),eR=(0,s.useCallback)(async(e,t)=>{let n=await fetch("/api/records",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({collection:"org.impactindexer.review.comment",record:{$type:"org.impactindexer.review.comment",subject:{uri:"beads:".concat(e),type:"record"},text:t,createdAt:new Date().toISOString()}})});if(!n.ok)throw Error((await n.json()).error||"Failed to post comment");await S()},[S]),eF=(0,s.useCallback)(async e=>{if(!(null==k?void 0:k.handle))return;let t=k.avatar;if(!t&&k.did)try{let e=await fetch("https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=".concat(encodeURIComponent(k.did)));e.ok&&(t=(await e.json()).avatar)}catch(e){}I(n=>{let r=new Map(n);return r.set(e,{avatar:t,claimedAt:new Date().toISOString(),handle:k.handle}),r}),await eR(e,"@".concat(k.handle)),setTimeout(()=>S(),3e3)},[null==k?void 0:k.handle,null==k?void 0:k.did,null==k?void 0:k.avatar,eR,S]),e_=(0,s.useCallback)(async e=>{let t=await fetch("/api/records?collection=".concat(encodeURIComponent("org.impactindexer.review.comment"),"&rkey=").concat(encodeURIComponent(e.rkey)),{method:"DELETE"});if(!t.ok)throw Error((await t.json()).error||"Failed to delete comment");await S()},[S]),eO=(0,s.useCallback)(async e=>{let t=W.get(e);t&&(P(t=>new Set(t).add(e)),I(t=>{let n=new Map(t);return n.delete(e),n}),t.rkey?(await e_({rkey:t.rkey}),P(t=>{let n=new Set(t);return n.delete(e),n})):setTimeout(async()=>{await S(),P(t=>{let n=new Set(t);return n.delete(e),n})},3e3))},[W,e_,S]),eU=(0,s.useCallback)(async e=>{let t=e.likes.find(e=>e.did===(null==k?void 0:k.did));if(t){let e=await fetch("/api/records?collection=".concat(encodeURIComponent("org.impactindexer.review.like"),"&rkey=").concat(encodeURIComponent(t.rkey)),{method:"DELETE"});if(!e.ok)throw Error((await e.json()).error||"Failed to unlike")}else{let t=await fetch("/api/records",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({collection:"org.impactindexer.review.like",record:{subject:{uri:e.uri,type:"record"},createdAt:new Date().toISOString()}})});if(!t.ok)throw Error((await t.json()).error||"Failed to like")}await S()},[null==k?void 0:k.did,S]),eH=(0,s.useCallback)(async(e,t)=>{let n=await fetch("/api/records",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({collection:"org.impactindexer.review.comment",record:{subject:{uri:"beads:".concat(e.nodeId),type:"record"},text:t,replyTo:e.uri,createdAt:new Date().toISOString()}})});if(!n.ok)throw Error((await n.json()).error||"Failed to post reply");await S()},[S]),eY=(0,s.useCallback)(e=>{if(!i)return;let t=i.graphData.nodes.find(t=>t.id===e);t&&h(t)},[i]),eq=(0,s.useMemo)(()=>{if(!i||!ep.trim())return[];let e=ep.toLowerCase();return i.graphData.nodes.filter(t=>"".concat(t.id," ").concat(t.title," ").concat(t.prefix).toLowerCase().includes(e)).slice(0,8)},[ep,i]);(0,s.useEffect)(()=>{ev(0)},[ep]);let eX=(0,s.useCallback)(e=>{var t;null===(t=eD.current)||void 0===t||t.focusNode(e),em(!1),ef(""),ev(0)},[]);(0,s.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&"f"===e.key&&(e.preventDefault(),em(!0),setTimeout(()=>{var e;return null===(e=eL.current)||void 0===e?void 0:e.focus()},50)),"Escape"===e.key&&eh&&(em(!1),ef(""),ev(0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eh]);let eV=(0,s.useCallback)(e=>{"ArrowDown"===e.key?(e.preventDefault(),ev(e=>Math.min(e+1,eq.length-1))):"ArrowUp"===e.key?(e.preventDefault(),ev(e=>Math.max(e-1,0))):"Enter"===e.key&&eq.length>0&&(e.preventDefault(),eX(eq[eg]))},[eq,eg,eX]);return o?(0,r.jsxs)("div",{className:"h-screen flex flex-col items-center justify-center bg-white",children:[(0,r.jsxs)("div",{className:"relative mb-6",children:[(0,r.jsx)("div",{className:"w-12 h-12 border-2 border-zinc-200 border-t-emerald-500 rounded-full animate-spin"}),(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,r.jsx)("div",{className:"w-2 h-2 rounded-full bg-emerald-500"})})]}),(0,r.jsx)("p",{className:"text-sm text-zinc-500 animate-pulse-soft",children:"Loading beads graph..."}),(0,r.jsx)("p",{className:"text-xs text-zinc-400 mt-1",children:"Parsing issues and dependencies"})]}):d?(0,r.jsx)("div",{className:"h-screen flex items-center justify-center bg-white",children:(0,r.jsxs)("div",{className:"max-w-sm text-center",children:[(0,r.jsx)("div",{className:"w-14 h-14 mx-auto mb-4 bg-red-50 rounded-full flex items-center justify-center",children:(0,r.jsx)("svg",{className:"w-7 h-7 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),(0,r.jsx)("h2",{className:"text-lg font-semibold text-zinc-900 mb-1",children:"Unable to load data"}),(0,r.jsx)("p",{className:"text-sm text-zinc-500 mb-4",children:d}),(0,r.jsxs)("button",{onClick:()=>window.location.reload(),className:"inline-flex items-center gap-2 px-4 py-2 bg-emerald-600 text-white text-sm rounded-lg hover:bg-emerald-700 transition-colors",children:[(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Try Again"]})]})}):i?(0,r.jsxs)("div",{className:"h-screen flex flex-col overflow-hidden bg-white",children:[(0,r.jsx)("header",{className:"sticky top-0 z-50 shrink-0 bg-white/95 backdrop-blur-sm border-b border-zinc-200/80",children:(0,r.jsxs)("div",{className:"px-6 h-14 flex items-center",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 shrink-0 group",children:[(0,r.jsx)(_,{className:"w-8 h-8 text-emerald-500 transition-transform group-hover:scale-105"}),(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("h1",{className:"text-[15px] font-semibold text-zinc-900 tracking-tight",children:f}),(0,r.jsx)("span",{className:"font-normal text-zinc-400 text-[15px] hidden sm:inline",children:"Beads"}),v>1&&(0,r.jsxs)("span",{className:"text-[10px] text-zinc-400 bg-zinc-100 rounded-full px-1.5 py-0.5 font-medium hidden sm:inline",children:[v," repos"]})]})]}),(0,r.jsx)("div",{className:"flex-1 flex justify-center px-4",children:(0,r.jsx)("div",{className:"relative w-full max-w-md",children:eh?(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center bg-white rounded-full border border-zinc-200 shadow-sm overflow-hidden",children:[(0,r.jsx)("div",{className:"pl-3 pr-1 text-zinc-400",children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),(0,r.jsx)("input",{ref:eL,type:"text",value:ep,onChange:e=>ef(e.target.value),onKeyDown:eV,placeholder:"Search issues...",className:"flex-1 px-2 py-1.5 text-xs text-zinc-800 bg-transparent outline-none placeholder:text-zinc-400",autoFocus:!0}),(0,r.jsx)("button",{onClick:()=>{em(!1),ef(""),ev(0)},className:"px-2 py-1.5 text-zinc-400 hover:text-zinc-600",children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),ep.trim()&&(0,r.jsxs)("div",{className:"absolute top-full left-0 right-0 mt-2 bg-white rounded-xl border border-zinc-100 shadow-xl overflow-hidden max-h-72 overflow-y-auto z-50",children:[0===eq.length?(0,r.jsx)("div",{className:"px-3 py-3 text-xs text-zinc-400 text-center",children:"No matching issues"}):eq.map((e,t)=>(0,r.jsxs)("button",{onClick:()=>eX(e),onMouseEnter:()=>ev(t),className:"w-full text-left px-3 py-2 text-xs transition-colors flex items-start gap-2.5 ".concat(t===eg?"bg-emerald-50":"hover:bg-zinc-50"),children:[(0,r.jsx)("div",{className:"shrink-0 mt-1",children:(0,r.jsx)("div",{className:"w-2 h-2 rounded-full ".concat(el[e.status]||"bg-zinc-400")})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"font-medium text-zinc-600 shrink-0",children:e.id}),e.priority<=1&&(0,r.jsx)("span",{className:"text-[10px]",children:0===e.priority?"\uD83D\uDD25\uD83D\uDD25":"\uD83D\uDD25"})]}),(0,r.jsx)("div",{className:"text-zinc-400 truncate mt-0.5",children:e.title})]}),(0,r.jsx)("span",{className:"shrink-0 text-[10px] text-zinc-400 bg-zinc-100 rounded px-1 py-0.5 mt-0.5",children:e.prefix})]},e.id)),eq.length>0&&(0,r.jsxs)("div",{className:"px-3 py-1.5 text-[10px] text-zinc-400 border-t border-zinc-100 bg-zinc-50/50 flex items-center justify-between",children:[(0,r.jsxs)("span",{children:[eq.length," result",1!==eq.length?"s":""]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-white rounded border border-zinc-200 text-[9px] font-mono",children:"Enter"})," ","to focus"]})]})]})]}):(0,r.jsxs)("button",{onClick:()=>{em(!0),setTimeout(()=>{var e;return null===(e=eL.current)||void 0===e?void 0:e.focus()},50)},className:"w-full flex items-center gap-2 px-3.5 py-1.5 text-sm text-zinc-400 rounded-full bg-zinc-50/80 border border-zinc-200/60 hover:text-zinc-500 hover:border-zinc-300 hover:bg-zinc-100/50 transition-all",title:"Search issues (Ctrl+F)",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,r.jsx)("span",{className:"flex-1 text-left",children:"Search issues..."}),(0,r.jsxs)("kbd",{className:"hidden sm:inline-block px-1 py-0.5 bg-zinc-100 rounded border border-zinc-200 text-[9px] font-mono text-zinc-400",children:["undefined"!=typeof navigator&&(null===(e=navigator.platform)||void 0===e?void 0:e.includes("Mac"))?"⌘":"Ctrl","F"]})]})})}),(0,r.jsxs)("div",{className:"hidden md:flex items-center gap-1 shrink-0",children:[(0,r.jsxs)("button",{onClick:eI,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-full transition-colors ".concat(eb?"text-emerald-700 bg-emerald-50":"text-zinc-500 hover:text-zinc-900 hover:bg-zinc-50"),children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("polyline",{points:"8,4 8,8 11,10"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Replay"})]}),(0,r.jsxs)("button",{onClick:()=>{Y(e=>!e),B||(h(null),K(!1))},className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-full transition-colors ".concat(B?"text-emerald-700 bg-emerald-50":"text-zinc-500 hover:text-zinc-900 hover:bg-zinc-50"),children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12.76c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.076-4.076a1.526 1.526 0 011.037-.443 48.282 48.282 0 005.68-.494c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z"})}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Comments"})]}),(0,r.jsxs)("button",{onClick:()=>{K(e=>!e),V||(h(null),Y(!1))},className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-full transition-colors ".concat(V?"text-emerald-700 bg-emerald-50":"text-zinc-500 hover:text-zinc-900 hover:bg-zinc-50"),children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("polyline",{points:"8,4 8,8 11,10"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Activity"})]}),(0,r.jsx)("div",{className:"w-px h-5 bg-zinc-200 mx-2"}),(0,r.jsx)(F,{})]})]})}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden relative",children:[(0,r.jsxs)("div",{className:"flex-1 relative bg-zinc-50/50",children:[(0,r.jsx)("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle, #000 1px, transparent 1px)",backgroundSize:"24px 24px"}}),(0,r.jsx)(N,{ref:eD,nodes:eb&&eM?eM.graphData.nodes:i.graphData.nodes,links:eb&&eM?eM.graphData.links:i.graphData.links,selectedNode:x,hoveredNode:m,onNodeClick:eE,onNodeHover:eP,onBackgroundClick:eW,onNodeRightClick:eB,commentedNodeIds:C,claimedNodeAvatars:W,onAvatarHover:ex,timelineActive:eb,stats:i.stats,sidebarOpen:!!x||B||V}),eb&&eA&&eA.events.length>0&&(0,r.jsx)("div",{className:"absolute bottom-4 z-10 transition-[right] duration-300 ease-out",style:{right:x||B||V?"calc(360px + 1rem)":"1rem"},children:(0,r.jsx)(ei,{totalSteps:eA.events.length,currentStep:Math.max(ej,0),currentTime:ej>=0&&null!==(n=null===(t=eA.events[ej])||void 0===t?void 0:t.time)&&void 0!==n?n:eA.minTime,isPlaying:ek,speed:ez,onStepChange:ew,onPlayPause:()=>eN(e=>!e),onSpeedChange:eC})}),!x&&!B&&!V&&!eb&&(0,r.jsx)("div",{className:"absolute top-3 right-3 sm:top-4 sm:right-4 z-10",children:(0,r.jsx)(G,{events:q,collapsed:$,onToggleCollapse:()=>J(e=>!e),onExpandPanel:()=>{K(!0),h(null),Y(!1)},onNodeClick:e=>{let t=null==i?void 0:i.graphData.nodes.find(t=>t.id===e);t&&eX(t)}})}),Q&&(0,r.jsx)(U,{node:Q.node,x:Q.x,y:Q.y,onShowDescription:()=>{ed(Q.node),et(null)},onAddComment:()=>{eo({node:Q.node,x:Q.x,y:Q.y}),et(null)},onClaimTask:w&&!W.has(Q.node.id)?()=>{eF(Q.node.id),et(null)}:void 0,onUnclaimTask:(()=>{if(!w)return;let e=W.get(Q.node.id);if(e&&(e.did===(null==k?void 0:k.did)||!e.did))return()=>{eO(Q.node.id),et(null)}})(),onClose:()=>et(null)}),en&&(0,r.jsx)(O,{node:en.node,x:en.x,y:en.y,onClose:()=>eo(null),onSubmit:async e=>{await eR(en.node.id,e),eo(null)},isAuthenticated:w,existingComments:z.get(en.node.id)}),ec&&(0,r.jsx)(D,{node:ec,onClose:()=>ed(null)}),eu&&(0,r.jsx)("div",{style:{position:"fixed",left:eu.x+12,top:eu.y-8,zIndex:90,pointerEvents:"none"},children:(0,r.jsxs)("div",{className:"flex items-center gap-2 bg-white border border-zinc-200 rounded-lg shadow-lg px-2.5 py-2",children:[eu.avatar?(0,r.jsx)("img",{src:eu.avatar,alt:"",className:"w-6 h-6 rounded-full shrink-0"}):(0,r.jsx)("div",{className:"w-6 h-6 rounded-full bg-zinc-200 flex items-center justify-center text-[10px] font-medium text-zinc-500 shrink-0",children:eu.handle.charAt(0).toUpperCase()}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsxs)("span",{className:"text-xs text-zinc-700 whitespace-nowrap",children:[eu.did?(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(eu.did),target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-zinc-800 hover:text-emerald-600 transition-colors",style:{pointerEvents:"auto"},children:eu.handle}):(0,r.jsx)("span",{className:"font-semibold text-zinc-800",children:eu.handle})," claimed this task"]}),(0,r.jsx)("span",{className:"text-[10px] text-zinc-400",children:T(eu.claimedAt)})]})]})})]}),(0,r.jsxs)("aside",{className:"hidden md:flex absolute top-0 right-0 h-full w-[360px] bg-white border-l border-zinc-200 flex-col shadow-xl z-30 transform transition-transform duration-300 ease-out ".concat(x?"translate-x-0":"translate-x-full"),children:[(0,r.jsxs)("div",{className:"shrink-0 px-5 py-3 border-b border-zinc-100 flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold text-zinc-400 uppercase tracking-wider",children:"Node Detail"}),(0,r.jsx)("button",{onClick:()=>{h(null)},className:"p-1 text-zinc-400 hover:text-zinc-600 transition-colors rounded-full hover:bg-zinc-100",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar px-5 py-4 space-y-5",children:(0,r.jsx)(A,{node:x,allNodes:i.graphData.nodes,onNodeNavigate:eY,comments:x?z.get(x.id):void 0,onPostComment:x?e=>eR(x.id,e):void 0,onDeleteComment:e_,onLikeComment:eU,onReplyComment:eH,isAuthenticated:w,currentDid:null==k?void 0:k.did,repoUrls:y})})]}),(0,r.jsx)("div",{className:"md:hidden fixed inset-x-0 bottom-0 z-20 transform transition-transform duration-300 ease-out ".concat(x?"translate-y-0":"translate-y-full"),children:(0,r.jsxs)("div",{className:"bg-white rounded-t-2xl border-t border-zinc-200 shadow-lg max-h-[60vh] flex flex-col",children:[(0,r.jsxs)("div",{className:"shrink-0 flex items-center justify-between px-4 pt-3 pb-2",children:[(0,r.jsx)("div",{className:"w-8 h-1 bg-zinc-300 rounded-full mx-auto"}),(0,r.jsx)("button",{onClick:()=>h(null),className:"absolute right-3 top-3 p-1 text-zinc-400 hover:text-zinc-600",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar px-4 pb-6 space-y-4",children:(0,r.jsx)(A,{node:x,allNodes:i.graphData.nodes,onNodeNavigate:eY,comments:x?z.get(x.id):void 0,onPostComment:x?e=>eR(x.id,e):void 0,onDeleteComment:e_,onLikeComment:eU,onReplyComment:eH,isAuthenticated:w,currentDid:null==k?void 0:k.did,repoUrls:y})})]})}),(0,r.jsx)(H,{isOpen:B,onClose:()=>Y(!1),allComments:M,onNodeNavigate:e=>{eY(e),Y(!1)},isAuthenticated:w,currentDid:null==k?void 0:k.did,onLikeComment:eU,onDeleteComment:e_}),(0,r.jsx)(ee,{events:q,isOpen:V,onClose:()=>K(!1),onNodeClick:e=>{let t=null==i?void 0:i.graphData.nodes.find(t=>t.id===e);t&&(eX(t),K(!1))}})]})]}):null}},7796:function(e,t,n){"use strict";n.d(t,{AuthProvider:function(){return a},a:function(){return l}});var r=n(3890),s=n(8496);let i=(0,s.createContext)(null);function a(e){let{children:t}=e,[n,a]=(0,s.useState)({status:"idle",session:null,error:null,isLoading:!0});(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch("/api/status");if(t.ok){let n=await t.json();if(n.did&&!e){a({status:"authenticated",session:{did:n.did,handle:n.handle||n.did,displayName:n.displayName,avatar:n.avatar},error:null,isLoading:!1});return}}}catch(e){console.error("Failed to check auth status:",e)}e||a(e=>({...e,isLoading:!1}))})(),()=>{e=!0}},[]);let l=(0,s.useCallback)(async e=>{a(e=>({...e,status:"authorizing",isLoading:!0,error:null}));try{let t=e.includes(".")?e:"".concat(e,".bsky.social"),n=await fetch("/api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({handle:t,returnTo:window.location.pathname+window.location.search})});if(!n.ok){let e=await n.json();throw Error(e.error||"Login failed")}let r=await n.json();window.location.href=r.redirectUrl}catch(t){let e=t instanceof Error?t:Error("Login failed");throw a({status:"error",session:null,error:e,isLoading:!1}),e}},[]),o=(0,s.useCallback)(async()=>{try{await fetch("/api/logout",{method:"POST"})}catch(e){console.error("Logout request failed:",e)}a({status:"idle",session:null,error:null,isLoading:!1})},[]);return(0,r.jsx)(i.Provider,{value:{state:n,login:l,logout:o},children:t})}function l(){let e=(0,s.useContext)(i);if(!e)throw Error("useAuth must be used within an AuthProvider");let{state:t,login:n,logout:r}=e;return{status:t.status,session:t.session,error:t.error,isLoading:t.isLoading,isAuthenticated:"authenticated"===t.status,login:n,logout:r}}}},function(e){e.O(0,[666,649,945,744],function(){return e(e.s=6284)}),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{6284:function(e,t,n){Promise.resolve().then(n.bind(n,4584))},4584:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return eo}});var r=n(3890),s=n(8496);function i(e){let t="object"==typeof e.source?e.source.id:e.source,n="object"==typeof e.target?e.target.id:e.target;return"".concat(t,"->").concat(n,":").concat(e.type)}function a(e,t){if(!e)return{addedNodeIds:new Set(t.graphData.nodes.map(e=>e.id)),removedNodeIds:new Set,changedNodes:new Map,addedLinkKeys:new Set(t.graphData.links.map(i)),removedLinkKeys:new Set,hasChanges:!0};let n=new Map(e.graphData.nodes.map(e=>[e.id,e])),r=new Map(t.graphData.nodes.map(e=>[e.id,e])),s=new Set,a=new Set,l=new Map;for(let[e,t]of r)if(n.has(e)){let r=n.get(e),s=[];r.status!==t.status&&s.push({field:"status",from:r.status,to:t.status}),r.priority!==t.priority&&s.push({field:"priority",from:String(r.priority),to:String(t.priority)}),r.title!==t.title&&s.push({field:"title",from:r.title,to:t.title}),(r.owner||"")!==(t.owner||"")&&s.push({field:"owner",from:r.owner||"",to:t.owner||""}),s.length>0&&l.set(e,s)}else s.add(e);for(let e of n.keys())r.has(e)||a.add(e);let o=new Set(e.graphData.links.map(i)),c=new Set(t.graphData.links.map(i)),d=new Set,u=new Set;for(let e of c)o.has(e)||d.add(e);for(let e of o)c.has(e)||u.add(e);let x=s.size>0||a.size>0||l.size>0||d.size>0||u.size>0;return{addedNodeIds:s,removedNodeIds:a,changedNodes:l,addedLinkKeys:d,removedLinkKeys:u,hasChanges:x}}var l=n(8232);let o={open:"#10b981",in_progress:"#f59e0b",blocked:"#ef4444",deferred:"#8b5cf6",closed:"#a1a1aa"},c={open:"Open",in_progress:"In Progress",blocked:"Blocked",deferred:"Deferred",closed:"Closed"},d={0:"P0 - Critical",1:"P1 - High",2:"P2 - Medium",3:"P3 - Low",4:"P4 - Backlog"},u={0:"#ef4444",1:"#f97316",2:"#3b82f6",3:"#a1a1aa",4:"#d4d4d8"},x={bug:"\uD83D\uDC1B",feature:"✨",task:"\uD83D\uDCDD",epic:"\uD83C\uDFAF",chore:"\uD83D\uDD27"},h=new Proxy({},{get:(e,t)=>t.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),has:()=>!0}),m=new Proxy({},{get:(e,t)=>(function(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=16777619*t>>>0;let n=t%360;return"hsl(".concat(n,", 65%, 55%)")})(t),has:()=>!0}),p=null;function f(e){let t=e.blockerCount+e.dependentCount;return"epic"===e.issueType&&(t+=3),5+17*Math.min(t/6,1)}function g(e){return o[e.status]||o.open}function v(e){return 1-(1-e)*(1-e)}let b=new Map;function y(e,t){let n=b.get(e);if("loading"===n||"failed"===n)return null;if(n)return n;b.set(e,"loading");let r=new Image;return r.onload=()=>{b.set(e,r),t()},r.onerror=()=>{b.set(e,"failed")},r.src=e,null}function j(e,t,n,r,s,i){e.beginPath(),e.arc(t,n,r,0,2*Math.PI),e.fillStyle="#e4e4e7",e.fill();let a=s.replace("@","").charAt(0).toUpperCase();e.font="600 ".concat(Math.min(7,Math.max(3,1.3*r)),"px 'Inter', system-ui, sans-serif"),e.textAlign="center",e.textBaseline="middle",e.fillStyle="#71717a",e.fillText(a,t,n+.3)}function w(e,t){let n=new Set([e]),r=[{id:e,depth:0}];for(;r.length>0;){let{id:e,depth:s}=r.shift();if(!(s>=2))for(let i of t){let t="object"==typeof i.source?i.source.id:i.source,a="object"==typeof i.target?i.target.id:i.target;t!==e||n.has(a)||(n.add(a),r.push({id:a,depth:s+1})),a!==e||n.has(t)||(n.add(t),r.push({id:t,depth:s+1}))}}return n}function k(e){let t=e.current;if(!t)return;let n=t.zoom();"number"!=typeof n||isNaN(n)||(t.zoom(1.000001*n,0),requestAnimationFrame(()=>{e.current&&e.current.zoom(n,0)}))}let N=(0,s.forwardRef)(function(e,t){let{nodes:i,links:a,selectedNode:d,hoveredNode:u,onNodeClick:x,onNodeHover:h,onBackgroundClick:b,onNodeRightClick:N,commentedNodeIds:C,claimedNodeAvatars:M,onAvatarHover:S,timelineActive:D,stats:L,sidebarOpen:T}=e,A=(0,s.useRef)(null),I=(0,s.useRef)(null),E=(0,s.useRef)(null),P=(0,s.useRef)(0),W=(0,s.useRef)(()=>{}),[B,R]=(0,s.useState)({width:800,height:600}),F=(0,s.useRef)(!1),[_,O]=(0,s.useState)({w:160,h:120}),U=_.w,H=_.h,Y=(0,s.useRef)(null),[q,X]=(0,s.useState)(p);(0,s.useEffect)(()=>{p||n.e(149).then(n.bind(n,3149)).then(e=>{p=e.default||e,X(()=>p)})},[]);let[V,K]=(0,s.useState)("dag"),[$,J]=(0,s.useState)("full"),G=(0,s.useRef)(d),Z=(0,s.useRef)(u),Q=(0,s.useRef)(new Set),ee=(0,s.useRef)(C||new Map),et=(0,s.useRef)(M||new Map),en=(0,s.useRef)(()=>{});en.current=()=>k(A);let er=(0,s.useRef)(S);er.current=S;let es=(0,s.useRef)(null),ei=(0,s.useRef)(i),ea=(0,s.useRef)([]),{viewNodes:el,viewLinks:eo}=(0,s.useMemo)(()=>{if("full"===$)return{viewNodes:i,viewLinks:a};let e=new Map;for(let t of a){let n="object"==typeof t.source?t.source.id:t.source,r="object"==typeof t.target?t.target.id:t.target;"parent-child"===t.type&&e.set(r,n)}let t=new Set(i.map(e=>e.id));for(let n of i)if(!e.has(n.id)&&n.id.includes(".")){let r=n.id.split(".")[0];t.has(r)&&e.set(n.id,r)}let n=new Set(e.keys()),r=new Map,s=new Map,l=new Map;for(let[t,n]of e){r.set(n,(r.get(n)||0)+1);let e=i.find(e=>e.id===t);e&&(s.set(n,(s.get(n)||0)+e.blockerCount),l.set(n,(l.get(n)||0)+e.dependentCount))}let o=i.filter(e=>!n.has(e.id)).map(e=>({...e,blockerCount:e.blockerCount+(s.get(e.id)||0),dependentCount:e.dependentCount+(l.get(e.id)||0),collapsedCount:r.get(e.id)||0})),c=[],d=new Set;for(let t of a){if("parent-child"===t.type)continue;let n="object"==typeof t.source?t.source.id:t.source,r="object"==typeof t.target?t.target.id:t.target;if((n=e.get(n)||n)===(r=e.get(r)||r))continue;let s="".concat(n,"->").concat(r,":").concat(t.type);d.has(s)||(d.add(s),c.push({source:n,target:r,type:t.type}))}return{viewNodes:o,viewLinks:c}},[i,a,$]);ei.current=el,(0,s.useEffect)(()=>{let e=new Map;for(let t of a){let n="object"==typeof t.source?t.source.id:t.source,r="object"==typeof t.target?t.target.id:t.target;"parent-child"===t.type&&e.set(r,n)}let t=new Set(i.map(e=>e.id));for(let n of i)if(!e.has(n.id)&&n.id.includes(".")){let r=n.id.split(".")[0];t.has(r)&&e.set(n.id,r)}let n=new Map;for(let[t,r]of e){let e=n.get(r)||[];e.push(t),n.set(r,e)}let r=new Map(i.map(e=>[e.id,e])),s=[];for(let[e,t]of n){let n=r.get(e);n&&s.push({parentId:e,title:n.title||e,prefix:n.prefix,memberIds:[e,...t]})}ea.current=s},[i,a]),(0,s.useEffect)(()=>{G.current=d;let e=Z.current||d;e?Q.current=w(e.id,eo):Q.current=new Set,k(A),cancelAnimationFrame(P.current),P.current=requestAnimationFrame(()=>W.current())},[d,eo]),(0,s.useEffect)(()=>{Z.current=u;let e=u||G.current;e?Q.current=w(e.id,eo):Q.current=new Set,k(A),cancelAnimationFrame(P.current),P.current=requestAnimationFrame(()=>W.current())},[u,eo]),(0,s.useEffect)(()=>{ee.current=C||new Map,k(A)},[C]),(0,s.useEffect)(()=>{et.current=M||new Map,k(A)},[M]),(0,s.useEffect)(()=>{let e=I.current;if(!e)return;let t=t=>{let n;let r=A.current,s=er.current;if(!r||!s)return;let i=et.current;if(0===i.size){es.current&&(es.current=null,s(null));return}let a=e.getBoundingClientRect(),l=t.clientX-a.left,o=t.clientY-a.top;try{n=r.screen2GraphCoords(l,o)}catch(e){return}let c=Math.max(4,10/(r.zoom()||1));for(let e of ei.current){if(null==e.x||null==e.y)continue;let r=i.get(e.id);if(!r)continue;let a=f(e),l=e.x+.7*a,o=e.y+.7*a,d=n.x-l,u=n.y-o;if(d*d+u*u<=c*c){es.current!==e.id&&(es.current=e.id,s({handle:r.handle,avatar:r.avatar,claimedAt:r.claimedAt,did:r.did,x:t.clientX,y:t.clientY}));return}}es.current&&(es.current=null,s(null))};return e.addEventListener("mousemove",t),()=>e.removeEventListener("mousemove",t)},[]),(0,s.useEffect)(()=>{let e=()=>{if(I.current){let e=I.current.getBoundingClientRect();R({width:e.width,height:e.height})}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let ec=(0,s.useCallback)(e=>{let t=A.current;if(!t)return;let n=el.find(t=>t.id===e.id);n&&void 0!==n.x&&void 0!==n.y&&(t.centerAt(n.x,n.y,500),t.zoom(2.5,500),x(e))},[x,el]);(0,s.useImperativeHandle)(t,()=>({focusNode:ec}),[ec]),(0,s.useEffect)(()=>{var e,t,n,r,s,i;let a=A.current;if(!a||0===el.length)return;"dag"===V?(null===(e=a.d3Force("charge"))||void 0===e||e.strength(-80).distanceMax(300),null===(t=a.d3Force("link"))||void 0===t||t.distance(50).strength(.3),null===(n=a.d3Force("center"))||void 0===n||n.strength(.01),a.d3Force("collision",null)):(null===(r=a.d3Force("charge"))||void 0===r||r.strength(-180).distanceMax(400),null===(s=a.d3Force("link"))||void 0===s||s.distance(e=>{var t,n,r,s;return(((null===(t=e.source)||void 0===t?void 0:t.blockerCount)||0)+((null===(n=e.source)||void 0===n?void 0:n.dependentCount)||0)+(((null===(r=e.target)||void 0===r?void 0:r.blockerCount)||0)+((null===(s=e.target)||void 0===s?void 0:s.dependentCount)||0)))/2>4?90:120}).strength(.6),null===(i=a.d3Force("center"))||void 0===i||i.strength(.03),a.d3Force("collision",(0,l.Z)().radius(e=>f(e)+6).strength(.7)),el.forEach(e=>{delete e.fx,delete e.fy})),a.d3ReheatSimulation();let o=setTimeout(()=>{A.current&&A.current.zoomToFit(400,60)},F.current?600:1e3);return F.current=!0,()=>clearTimeout(o)},[V,el.length]);let ed=(0,s.useRef)(!1);(0,s.useEffect)(()=>{if(ed.current||!q||0===i.length)return;ed.current=!0;let e=setTimeout(()=>{K("force")},15);return()=>clearTimeout(e)},[q,i.length]),(0,s.useEffect)(()=>{if(!D&&A.current&&i.length>0){let e=setTimeout(()=>{A.current.zoomToFit(400,60)},800);return()=>clearTimeout(e)}},[i.length,D]);let eu=(0,s.useMemo)(()=>{let e=Math.sqrt(el.length)||1;return el.forEach((t,n)=>{if(null==t.x&&null==t.y){let r=n*Math.PI*(3-Math.sqrt(5)),s=300*Math.sqrt(.5+n)/e;t.x=s*Math.cos(r),t.y=s*Math.sin(r)}}),{nodes:el,links:eo}},[el,eo]),ex=(0,s.useCallback)((e,t,n)=>{var r,s,i;let a=f(e),l=g(e),c=m[e.prefix]||"#a1a1aa",d=(null===(r=G.current)||void 0===r?void 0:r.id)===e.id,u=(null===(s=Z.current)||void 0===s?void 0:s.id)===e.id,x=Q.current,h=x.has(e.id),p=x.size>0,b=Date.now(),w=1,k=e._spawnTime;if(k){let e=b-k;e<500&&(w=1+2.70158*Math.pow((i=e/500)-1,3)+1.70158*Math.pow(i-1,2))}let N=1,C=1,M=e._removeTime;if(M){let e=b-M;if(e<400){let t=e/400;N=1-v(t),C=1-t}else N=0,C=0}let S=w*N;if(S<=.01)return;let D=a*S,L=n<=.1?0:n>=.2?1:(n-.1)/.1,T=(p&&!h?.15:"closed"===e.status?.5:1)*C*L;if(T<=.01)return;t.save(),t.globalAlpha=T,h&&p&&(t.shadowColor="#10b981",t.shadowBlur=d?20:u?16:10),n>.3&&(t.beginPath(),t.arc(e.x,e.y,D+2,0,2*Math.PI),t.strokeStyle=c,t.lineWidth=2,t.stroke()),t.beginPath(),t.arc(e.x,e.y,D,0,2*Math.PI),t.fillStyle=l,t.fill(),t.strokeStyle=d?"#10b981":u?"#3f3f46":"#e4e4e7",t.lineWidth=d?2.5:u?2:1,t.stroke(),t.shadowBlur=0;let A=e._changedAt;if(A){let n=b-A;if(n<800){let r=n/800,s=o[e.status]||"#a1a1aa";t.beginPath(),t.arc(e.x,e.y,D+4+20*r,0,2*Math.PI),t.strokeStyle=s,t.lineWidth=2*(1-r),t.globalAlpha=(1-r)*.6,t.stroke(),t.globalAlpha=T}}if(k){let n=b-k;if(n<500){let r=n/500;t.beginPath(),t.arc(e.x,e.y,D+6+8*r,0,2*Math.PI),t.strokeStyle="#10b981",t.lineWidth=3*(1-r),t.globalAlpha=(1-r)*.4,t.stroke(),t.globalAlpha=T}}if(e.priority<=1&&n>.5&&(t.font="".concat(Math.min(10,Math.max(4,12/n)),"px sans-serif"),t.textAlign="center",t.textBaseline="bottom",t.fillText(0===e.priority?"\uD83D\uDD25\uD83D\uDD25":"\uD83D\uDD25",e.x,e.y-D-2)),n>.5){let r=Math.min(7,Math.max(3,10/n));t.font="500 ".concat(r,"px 'Inter', system-ui, sans-serif"),t.textAlign="center",t.textBaseline="top",t.fillStyle="#3f3f46",t.globalAlpha=.85*T;let s=e.id;n>1.5?s=z(e.title||e.id,30):n>.9&&(s=z(e.title||e.id,18)),t.fillText(s,e.x,e.y+D+3);let i=e.collapsedCount;i&&i>0&&(t.font="400 ".concat(Math.min(5.5,Math.max(2.5,8/n)),"px 'Inter', system-ui, sans-serif"),t.fillStyle="#a1a1aa",t.fillText("".concat(i," task").concat(1!==i?"s":""),e.x,e.y+D+3+r+1))}let I=ee.current.get(e.id);if(I&&I>0&&n>.4){let r=Math.min(6,Math.max(3.5,8/n)),s=e.x+.75*D,i=e.y-.75*D,a=I>99?"99+":String(I);t.save(),t.globalAlpha=Math.min(T,.95),t.beginPath(),t.arc(s,i,r,0,2*Math.PI),t.fillStyle="#ef4444",t.fill(),t.strokeStyle="#ffffff",t.lineWidth=Math.max(.8,1.2/n),t.stroke(),t.font="600 ".concat(Math.min(7,Math.max(3,1.3*r)),"px 'Inter', system-ui, sans-serif"),t.textAlign="center",t.textBaseline="middle",t.fillStyle="#ffffff",t.fillText(a,s,i+.3),t.restore()}let E=et.current.get(e.id);if(E){let r=Math.max(4,10/n),s=e.x+.7*D,i=e.y+.7*D;if(t.save(),t.globalAlpha=1,E.avatar){let e=y(E.avatar,()=>en.current());e?(t.save(),t.beginPath(),t.arc(s,i,r,0,2*Math.PI),t.clip(),t.drawImage(e,s-r,i-r,2*r,2*r),t.restore()):j(t,s,i,r,E.handle,n)}else j(t,s,i,r,E.handle,n);t.beginPath(),t.arc(s,i,r,0,2*Math.PI),t.strokeStyle="#ffffff",t.lineWidth=Math.max(.8,1.2/n),t.stroke(),t.restore()}t.restore()},[]),eh=(0,s.useCallback)((e,t,n)=>{let r=e.source,s=e.target;if(void 0===r.x||void 0===s.x)return;let i=Date.now(),a=1,l=1,o=e._spawnTime;if(o){let e=i-o;if(e<500){let t=e/500;a=v(t),l=1+(1-t)*1.5}}let c=1,d=e._removeTime;if(d){let e=i-d;if(!(e<400))return;c=1-v(e/400)}let u=a*c;if(u<=.01)return;let x=r.id||e.source,h=s.id||e.target,m="parent-child"===e.type,p=Q.current,g=p.size>0,b=g&&p.has(x)&&p.has(h),y=(m?g?b?.5:.05:.2:g?b?.8:.08:.35)*u*(n<=.1?0:n>=.2?1:(n-.1)/.1);if(y<=.01)return;t.save(),t.globalAlpha=y,m?(t.strokeStyle=b?"#71717a":"#a1a1aa",t.lineWidth=Math.max(.6,1.5/n)*l,t.setLineDash([4,3])):(t.strokeStyle=b?"#10b981":"#d4d4d8",t.lineWidth=(b?Math.max(2,2.5/n):Math.max(.8,1.2/n))*l);let j=s.x-r.x,w=s.y-r.y,k=Math.sqrt(j*j+w*w),N=(r.x+s.x)/2+.15*w,z=(r.y+s.y)/2-.15*j;if(t.beginPath(),t.moveTo(r.x,r.y),t.quadraticCurveTo(N,z,s.x,s.y),t.stroke(),m&&t.setLineDash([]),o){let e=i-o;e<300&&(t.save(),t.globalAlpha=(1-e/300)*.5,t.strokeStyle="#10b981",t.lineWidth=(m?3:4)/n,t.beginPath(),t.moveTo(r.x,r.y),t.quadraticCurveTo(N,z,s.x,s.y),t.stroke(),t.restore())}if(!m){let e=f(s);if(k<e+1){t.restore();return}let i=Math.min(8,6/n),a=1-e/k,l=r.x+a*j,o=r.y+a*w,c=Math.atan2(w,j);t.fillStyle=b?"#10b981":"#d4d4d8",t.beginPath(),t.moveTo(l,o),t.lineTo(l-i*Math.cos(c-Math.PI/7),o-i*Math.sin(c-Math.PI/7)),t.lineTo(l-i*Math.cos(c+Math.PI/7),o-i*Math.sin(c+Math.PI/7)),t.closePath(),t.fill()}t.restore()},[]),em=(0,s.useCallback)((e,t)=>{let n=t>=.8?0:t<=.4?1:(.8-t)/.4;if(n<=.01)return;let r=ea.current;if(0===r.length)return;let s=new Map;for(let e of el)null!=e.x&&null!=e.y&&s.set(e.id,{x:e.x,y:e.y});for(let i of(e.save(),r)){let r=0,a=0,l=0;for(let e of i.memberIds){let t=s.get(e);t&&(r+=t.x,a+=t.y,l++)}if(0===l)continue;let o=r/l,c=a/l,d=0;for(let e of i.memberIds){let t=s.get(e);if(t){let e=t.x-o,n=t.y-c,r=Math.sqrt(e*e+n*n);r>d&&(d=r)}}let u=d+30,x=m[i.prefix]||"hsl(0, 0%, 65%)";e.beginPath(),e.arc(o,c,u,0,2*Math.PI),e.globalAlpha=.05*n,e.fillStyle=x,e.fill(),e.globalAlpha=.25*n,e.strokeStyle=x,e.lineWidth=1.5/t,e.setLineDash([8/t,4/t]),e.stroke(),e.setLineDash([]);let h=Math.min(24,Math.max(10,14/t)),p=Math.min(12,Math.max(5,8/t)),f=.35*h;e.font="500 ".concat(p,"px 'Inter', system-ui, sans-serif"),e.textAlign="center",e.textBaseline="middle",e.globalAlpha=.45*n,e.fillStyle="#71717a",e.fillText(i.parentId,o,c-.5*h-f),e.font="600 ".concat(h,"px 'Inter', system-ui, sans-serif"),e.globalAlpha=.85*n,e.fillStyle="#18181b";let g=i.title.length>40?i.title.slice(0,39)+"…":i.title;e.fillText(g,o,c+.15*h);let v=Math.min(14,Math.max(6,9/t));e.font="400 ".concat(v,"px 'Inter', system-ui, sans-serif"),e.globalAlpha=.5*n,e.fillStyle="#71717a",e.fillText("".concat(i.memberIds.length," issue").concat(1!==i.memberIds.length?"s":""),o,c+.15*h+.7*h)}e.restore()},[el,i]),ep=(0,s.useCallback)((e,t,n)=>{let r=f(e)+5;n.fillStyle=t,n.beginPath(),n.arc(e.x,e.y,r,0,2*Math.PI),n.fill()},[]),ef=(0,s.useCallback)(()=>{},[]),eg=(0,s.useCallback)(()=>{var e,t;let n=E.current,r=A.current;if(!n||!r)return;let s=n.getContext("2d");if(!s)return;let i=1/0,a=-1/0,l=1/0,o=-1/0,c=!1;for(let e of el)null!=e.x&&null!=e.y&&(c=!0,e.x<i&&(i=e.x),e.x>a&&(a=e.x),e.y<l&&(l=e.y),e.y>o&&(o=e.y));if(!c)return;let d=(a+=40)-(i-=40)||1,u=(o+=40)-(l-=40)||1,x=U-16,h=H-16,m=Math.min(x/d,h/u),p=8+(x-d*m)/2,f=8+(h-u*m)/2,v=window.devicePixelRatio||1;(n.width!==U*v||n.height!==H*v)&&(n.width=U*v,n.height=H*v,s.setTransform(v,0,0,v,0,0)),s.clearRect(0,0,U,H),s.fillStyle="rgba(250, 250, 250, 0.92)",s.beginPath(),s.roundRect(0,0,U,H,6),s.fill();let b=Q.current,j=b.size>0,w=(null===(e=Z.current)||void 0===e?void 0:e.id)||(null===(t=G.current)||void 0===t?void 0:t.id)||null;for(let e of eo){let t=e.source,n=e.target;if(null==t.x||null==n.x)continue;let r=t.id||e.source,a=n.id||e.target,o=j&&b.has(r)&&b.has(a);s.globalAlpha=j?o?.5:.04:.1,s.strokeStyle=o?"#10b981":"#a1a1aa",s.lineWidth=o?1:.5;let c=p+(t.x-i)*m,d=f+(t.y-l)*m,u=p+(n.x-i)*m,x=f+(n.y-l)*m;s.beginPath(),s.moveTo(c,d),s.lineTo(u,x),s.stroke()}for(let e of(s.globalAlpha=1,el)){if(null==e.x||null==e.y)continue;let t=p+(e.x-i)*m,n=f+(e.y-l)*m,r=e.id===w,a=b.has(e.id);j&&!a?s.globalAlpha=.1:"closed"===e.status?s.globalAlpha=.35:s.globalAlpha=.85,s.fillStyle=g(e);let o="epic"===e.issueType?3:2;r?o=5:j&&a&&(o=4),r&&(s.globalAlpha=.4,s.fillStyle="#10b981",s.beginPath(),s.arc(t,n,o+2,0,2*Math.PI),s.fill(),s.globalAlpha=1,s.fillStyle=g(e)),s.fillRect(t-o/2,n-o/2,o,o)}s.globalAlpha=1;let k=et.current;if(k.size>0)for(let e of el){if(null==e.x||null==e.y)continue;let t=k.get(e.id);if(!t)continue;let n=p+(e.x-i)*m,r=f+(e.y-l)*m;if(s.save(),s.globalAlpha=1,t.avatar){let e=y(t.avatar,()=>en.current());e?(s.save(),s.beginPath(),s.arc(n,r,5,0,2*Math.PI),s.clip(),s.drawImage(e,n-5,r-5,10,10),s.restore()):(s.beginPath(),s.arc(n,r,5,0,2*Math.PI),s.fillStyle="#d4d4d8",s.fill())}else s.beginPath(),s.arc(n,r,5,0,2*Math.PI),s.fillStyle="#d4d4d8",s.fill();s.beginPath(),s.arc(n,r,5,0,2*Math.PI),s.strokeStyle="#ffffff",s.lineWidth=1,s.stroke(),s.restore()}try{let e=r.screen2GraphCoords(0,0),t=r.screen2GraphCoords(B.width,B.height),n=p+(e.x-i)*m,a=f+(e.y-l)*m,o=(t.x-e.x)*m,c=(t.y-e.y)*m,d=Math.max(0,n),u=Math.max(0,a),x=Math.min(U-d,o-(d-n)),h=Math.min(H-u,c-(u-a));x>0&&h>0&&(s.fillStyle="rgba(16, 185, 129, 0.06)",s.fillRect(d,u,x,h),s.strokeStyle="rgba(16, 185, 129, 0.5)",s.lineWidth=1.5,s.strokeRect(d,u,x,h))}catch(e){}},[el,eo,B,U,H,8]);W.current=eg;let ev=(0,s.useCallback)(()=>{cancelAnimationFrame(P.current),P.current=requestAnimationFrame(()=>{eg()})},[eg]);(0,s.useEffect)(()=>{if(!q||0===i.length)return;let e=setInterval(()=>{eg()},200);return()=>clearInterval(e)},[q,i.length,eg]),(0,s.useEffect)(()=>{let e;let t=!0;return function n(){if(!t)return;let r=Date.now();(el.some(e=>!!e._spawnTime&&r-e._spawnTime<500||!!e._removeTime&&r-e._removeTime<400||!!e._changedAt&&r-e._changedAt<800)||eo.some(e=>!!e._spawnTime&&r-e._spawnTime<500||!!e._removeTime&&r-e._removeTime<400))&&k(A),e=requestAnimationFrame(n)}(),()=>{t=!1,cancelAnimationFrame(e)}},[el,eo]);let eb=(0,s.useCallback)(e=>{let t=A.current;if(!t)return;let n=e.currentTarget.getBoundingClientRect(),r=e.clientX-n.left,s=e.clientY-n.top,i=1/0,a=-1/0,l=1/0,o=-1/0;for(let e of el)null!=e.x&&null!=e.y&&(e.x<i&&(i=e.x),e.x>a&&(a=e.x),e.y<l&&(l=e.y),e.y>o&&(o=e.y));let c=(a+=40)-(i-=40)||1,d=(o+=40)-(l-=40)||1,u=U-16,x=H-16,h=Math.min(u/c,x/d),m=i+(r-(8+(u-c*h)/2))/h,p=l+(s-(8+(x-d*h)/2))/h;t.centerAt(m,p,300)},[el,U,H,8]);return(0,r.jsxs)("div",{ref:I,className:"w-full h-full relative",children:[(0,r.jsxs)("div",{className:"absolute top-3 left-3 sm:top-4 sm:left-4 z-10 flex items-start gap-1.5 sm:gap-2",children:[(0,r.jsxs)("div",{className:"flex bg-white/90 backdrop-blur-sm rounded-lg border border-zinc-200 shadow-sm overflow-hidden",children:[(0,r.jsx)("button",{onClick:()=>K("force"),className:"px-3 py-1.5 text-xs font-medium transition-colors ".concat("force"===V?"bg-emerald-500 text-white":"text-zinc-500 hover:text-zinc-700 hover:bg-zinc-50"),children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"4",cy:"4",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"12",cy:"3",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"3",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"13",cy:"11",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("line",{x1:"4",y1:"4",x2:"8",y2:"8",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"12",y1:"3",x2:"8",y2:"8",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"3",y1:"12",x2:"8",y2:"8",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"13",y1:"11",x2:"8",y2:"8",strokeOpacity:"0.5"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Force"})]})}),(0,r.jsx)("div",{className:"w-px bg-zinc-200"}),(0,r.jsx)("button",{onClick:()=>K("dag"),className:"px-3 py-1.5 text-xs font-medium transition-colors ".concat("dag"===V?"bg-emerald-500 text-white":"text-zinc-500 hover:text-zinc-700 hover:bg-zinc-50"),children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"2.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"4",cy:"8",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"12",cy:"8",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"2",cy:"13.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"6",cy:"13.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"12",cy:"13.5",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("line",{x1:"8",y1:"4",x2:"4",y2:"6.5",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"8",y1:"4",x2:"12",y2:"6.5",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"4",y1:"9.5",x2:"2",y2:"12",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"4",y1:"9.5",x2:"6",y2:"12",strokeOpacity:"0.5"}),(0,r.jsx)("line",{x1:"12",y1:"9.5",x2:"12",y2:"12",strokeOpacity:"0.5"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"DAG"})]})})]}),(0,r.jsxs)("div",{className:"flex bg-white/90 backdrop-blur-sm rounded-lg border border-zinc-200 shadow-sm overflow-hidden",children:[(0,r.jsx)("button",{onClick:()=>J("full"),className:"px-3 py-1.5 text-xs font-medium transition-colors ".concat("full"===$?"bg-emerald-500 text-white":"text-zinc-500 hover:text-zinc-700 hover:bg-zinc-50"),children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"4",cy:"4",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"12",cy:"4",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"4",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"1",fill:"currentColor",stroke:"none",opacity:"0.5"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Full"})]})}),(0,r.jsx)("div",{className:"w-px bg-zinc-200"}),(0,r.jsx)("button",{onClick:()=>J("epics"),className:"px-3 py-1.5 text-xs font-medium transition-colors ".concat("epics"===$?"bg-emerald-500 text-white":"text-zinc-500 hover:text-zinc-700 hover:bg-zinc-50"),children:(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"4",fill:"currentColor",stroke:"none"}),(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",fill:"none",opacity:"0.3"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Epics"})]})})]})]}),!D&&(0,r.jsxs)("div",{className:"absolute bottom-4 z-10 bg-white/90 backdrop-blur-sm rounded-lg border border-zinc-200 shadow-sm px-3 py-2 text-xs text-zinc-400 transition-[right] duration-300 ease-out",style:{right:T?"calc(360px + 1rem)":"1rem"},children:[L&&(0,r.jsxs)("div",{className:"text-zinc-500 mb-1.5",children:[(0,r.jsx)("strong",{className:"text-zinc-700",children:L.total})," issues"," \xb7 ",(0,r.jsx)("strong",{className:"text-zinc-700",children:L.edges})," deps"," \xb7 ",(0,r.jsx)("strong",{className:"text-emerald-600",children:L.prefixes.length}),1===L.prefixes.length?" project":" projects"]}),(0,r.jsx)("div",{className:"hidden sm:flex flex-wrap gap-x-3 gap-y-1 mb-1.5",children:["open","in_progress","blocked","deferred","closed"].map(e=>(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:o[e]}}),(0,r.jsx)("span",{className:"text-zinc-500",children:c[e]})]},e))}),(0,r.jsx)("div",{className:"hidden sm:flex flex-col gap-0.5 text-zinc-400",children:(0,r.jsx)("span",{children:"Size = importance \xb7 Ring = project"})}),(0,r.jsx)("span",{className:"sm:hidden",children:"Tap a node for details"})]}),(0,r.jsxs)("div",{className:"hidden sm:block absolute bottom-4 left-4 z-10",style:{width:U,height:H},children:[(0,r.jsx)("canvas",{ref:E,width:U,height:H,onClick:eb,className:"rounded-lg border border-zinc-200 shadow-sm cursor-crosshair",style:{width:U,height:H}}),(0,r.jsx)("div",{className:"absolute top-0 left-2 right-2 h-1.5 cursor-n-resize hover:bg-zinc-300/40 rounded-t-lg transition-colors",onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),Y.current={edge:"top",startX:e.clientX,startY:e.clientY,startW:U,startH:H};let t=e=>{if(!Y.current)return;let t=Y.current.startY-e.clientY,n=Math.max(80,Math.min(400,Y.current.startH+t));O(e=>({...e,h:n}))},n=()=>{Y.current=null,window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",n)};window.addEventListener("mousemove",t),window.addEventListener("mouseup",n)}}),(0,r.jsx)("div",{className:"absolute top-2 right-0 bottom-2 w-1.5 cursor-e-resize hover:bg-zinc-300/40 rounded-r-lg transition-colors",onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),Y.current={edge:"right",startX:e.clientX,startY:e.clientY,startW:U,startH:H};let t=e=>{if(!Y.current)return;let t=e.clientX-Y.current.startX,n=Math.max(100,Math.min(500,Y.current.startW+t));O(e=>({...e,w:n}))},n=()=>{Y.current=null,window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",n)};window.addEventListener("mousemove",t),window.addEventListener("mouseup",n)}}),(0,r.jsx)("div",{className:"absolute top-0 right-0 w-3 h-3 cursor-ne-resize hover:bg-zinc-300/40 rounded-tr-lg transition-colors",onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),Y.current={edge:"top-right",startX:e.clientX,startY:e.clientY,startW:U,startH:H};let t=e=>{if(!Y.current)return;let t=e.clientX-Y.current.startX,n=Y.current.startY-e.clientY;O({w:Math.max(100,Math.min(500,Y.current.startW+t)),h:Math.max(80,Math.min(400,Y.current.startH+n))})},n=()=>{Y.current=null,window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",n)};window.addEventListener("mousemove",t),window.addEventListener("mouseup",n)}})]}),q?(0,r.jsx)(q,{ref:A,graphData:eu,width:B.width,height:B.height,nodeCanvasObject:ex,nodeCanvasObjectMode:()=>"replace",nodePointerAreaPaint:ep,onRenderFramePost:em,linkCanvasObject:eh,linkCanvasObjectMode:()=>"replace",linkDirectionalParticles:e=>"parent-child"===e.type?0:2,linkDirectionalParticleSpeed:.004,linkDirectionalParticleWidth:2.5,linkDirectionalParticleColor:()=>"#10b981",dagMode:"dag"===V?"td":void 0,dagLevelDistance:60,onDagError:ef,d3AlphaDecay:.02,d3VelocityDecay:.3,cooldownTicks:300,warmupTicks:50,onNodeClick:e=>x(e),onNodeHover:e=>h(e||null),onNodeRightClick:(e,t)=>{t.preventDefault(),null==N||N(e,t)},onBackgroundClick:b,onZoom:ev,backgroundColor:"transparent"}):(0,r.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,r.jsx)("div",{className:"text-zinc-400 text-sm animate-pulse-soft",children:"Loading graph engine..."})})]})});function z(e,t){return e.length<=t?e:e.slice(0,t-1)+"…"}var C=n(5777),M=n(7827),S=n(1720);function D(e){let{node:t,onClose:n}=e;return t.description?(0,S.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/40 backdrop-blur-sm",onClick:n,children:(0,r.jsxs)("div",{className:"bg-white rounded-xl shadow-2xl w-[90vw] max-w-2xl max-h-[80vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b border-zinc-100",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"text-xs font-mono font-semibold text-emerald-600 shrink-0",children:t.id}),(0,r.jsx)("span",{className:"text-sm font-semibold text-zinc-900 truncate",children:t.title})]}),(0,r.jsx)("button",{onClick:n,className:"shrink-0 p-1 text-zinc-400 hover:text-zinc-600 transition-colors",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-5 py-4 custom-scrollbar description-markdown text-sm text-zinc-700 leading-relaxed",children:(0,r.jsx)(C.UG,{remarkPlugins:[M.Z],children:t.description})})]})}),document.body):null}function L(e){let{className:t="w-3 h-3",filled:n=!1}=e;return n?(0,r.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor",children:(0,r.jsx)("path",{d:"M11.645 20.91l-.007-.003-.022-.012a15.247 15.247 0 01-.383-.218 25.18 25.18 0 01-4.244-3.17C4.688 15.36 2.25 12.174 2.25 8.25 2.25 5.322 4.714 3 7.688 3A5.5 5.5 0 0112 5.052 5.5 5.5 0 0116.313 3c2.973 0 5.437 2.322 5.437 5.25 0 3.925-2.438 7.111-4.739 9.256a25.175 25.175 0 01-4.244 3.17 15.247 15.247 0 01-.383.219l-.022.012-.007.004-.003.001a.752.752 0 01-.704 0l-.003-.001z"})}):(0,r.jsx)("svg",{className:t,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z"})})}function T(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/1e3);if(n<60)return"just now";let r=Math.floor(n/60);if(r<60)return"".concat(r,"m ago");let s=Math.floor(r/60);if(s<24)return"".concat(s,"h ago");let i=Math.floor(s/24);return i<7?"".concat(i,"d ago"):t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function A(e){let{node:t,allNodes:n,onNodeNavigate:i,comments:a,onPostComment:l,onDeleteComment:p,onLikeComment:f,onReplyComment:g,isAuthenticated:v,currentDid:b,repoUrls:y}=e,[j,w]=(0,s.useState)(null),[k,N]=(0,s.useState)(""),[z,S]=(0,s.useState)(!1),[L,T]=(0,s.useState)(!1),A=e=>{w(e.uri),N("")},I=()=>{w(null),N("")},R=async()=>{if(k.trim()&&j&&g){S(!0);try{let e=t=>{for(let n of t){if(n.uri===j)return n;let t=e(n.replies);if(t)return t}},t=a?e(a):void 0;t&&await g(t,k.trim()),w(null),N("")}catch(e){console.error("Failed to post reply:",e)}finally{S(!1)}}};if(!t)return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)("div",{className:"w-12 h-12 rounded-full bg-zinc-100 flex items-center justify-center mb-4",children:(0,r.jsx)("svg",{className:"w-6 h-6 text-zinc-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122"})})}),(0,r.jsx)("p",{className:"text-sm text-zinc-500 leading-relaxed",children:"Click a node to see details"}),(0,r.jsx)("p",{className:"text-xs text-zinc-400 mt-1",children:"Hover to highlight connections"})]});let F=x[t.issueType]||"\uD83D\uDCCB",_=o[t.status]||o.open,O=c[t.status]||t.status,U=d[t.priority]||"P".concat(t.priority),H=u[t.priority]||"#a1a1aa",Y=h[t.prefix]||t.prefix,q=m[t.prefix]||"#a1a1aa",X=null==y?void 0:y[t.prefix],V=t.blockerIds.map(e=>n.find(t=>t.id===e)).filter(Boolean),K=t.dependentIds.map(e=>n.find(t=>t.id===e)).filter(Boolean),$=e=>{try{let t=new Date(e),n=t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!1});return"".concat(n," at ").concat(r)}catch(t){return e}};return(0,r.jsxs)("div",{className:"animate-fade-in",children:[(0,r.jsxs)("div",{className:"flex items-start gap-3 mb-4",children:[(0,r.jsx)("span",{className:"text-2xl mt-0.5",children:F}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)("span",{className:"text-xs font-mono font-semibold text-emerald-600",children:t.id})}),(0,r.jsx)("h3",{className:"text-sm font-semibold text-zinc-900 mt-1 leading-snug",children:t.title})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 mb-4",children:[(0,r.jsxs)("span",{className:"status-badge",style:{backgroundColor:_+"18",color:_,border:"1px solid ".concat(_,"30")},children:[(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full mr-1.5",style:{backgroundColor:_}}),O]}),(0,r.jsx)("span",{className:"status-badge",style:{backgroundColor:H+"15",color:H,border:"1px solid ".concat(H,"25")},children:U}),X?(0,r.jsxs)("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"status-badge hover:opacity-80 transition-opacity",style:{backgroundColor:q+"15",color:q,border:"1px solid ".concat(q,"25"),textDecoration:"none"},children:[Y,(0,r.jsx)("svg",{className:"w-2.5 h-2.5 ml-1 opacity-50",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25"})})]}):(0,r.jsx)("span",{className:"status-badge",style:{backgroundColor:q+"15",color:q,border:"1px solid ".concat(q,"25")},children:Y})]}),X&&(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsxs)("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-[11px] text-zinc-400 hover:text-zinc-600 transition-colors",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"})}),X.replace(/^https?:\/\//,"")]})}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 mb-4",children:[(0,r.jsx)(E,{label:"Blocks",value:t.blockerCount,color:t.blockerCount>0?"#f59e0b":void 0}),(0,r.jsx)(E,{label:"Blocked by",value:t.dependentCount,color:t.dependentCount>0?"#ef4444":void 0})]}),(0,r.jsxs)("div",{className:"space-y-1.5 mb-4 text-xs text-zinc-500",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Created"}),(0,r.jsx)("span",{className:"text-zinc-700 font-medium",children:$(t.createdAt)})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Updated"}),(0,r.jsx)("span",{className:"text-zinc-700 font-medium",children:$(t.updatedAt)})]}),t.closedAt&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Closed"}),(0,r.jsx)("span",{className:"text-zinc-700 font-medium",children:$(t.closedAt)})]}),t.closeReason&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Reason"}),(0,r.jsx)("span",{className:"text-zinc-700 font-medium truncate ml-2",children:t.closeReason})]}),t.owner&&(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:"Owner"}),(0,r.jsx)("span",{className:"text-zinc-700 font-medium truncate ml-2",children:t.owner})]})]}),t.description&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsx)("h4",{className:"text-xs font-semibold text-zinc-500 uppercase tracking-wider",children:"Description"}),(0,r.jsx)("button",{onClick:()=>T(!0),className:"text-[10px] text-zinc-400 hover:text-zinc-600 transition-colors",children:"View in window"})]}),(0,r.jsx)("div",{className:"text-xs text-zinc-600 leading-relaxed bg-zinc-50 rounded-lg p-3 max-h-40 overflow-y-auto custom-scrollbar border border-zinc-100 description-markdown",children:(0,r.jsx)(C.UG,{remarkPlugins:[M.Z],children:t.description})})]}),L&&t.description&&(0,r.jsx)(D,{node:t,onClose:()=>T(!1)}),V.length>0&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("h4",{className:"text-xs font-semibold text-zinc-500 uppercase tracking-wider mb-2",children:["Blocks (",V.length,")"]}),(0,r.jsx)("div",{className:"space-y-1",children:V.map(e=>(0,r.jsx)(P,{node:e,onClick:()=>i(e.id)},e.id))})]}),K.length>0&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("h4",{className:"text-xs font-semibold text-zinc-500 uppercase tracking-wider mb-2",children:["Blocked by (",K.length,")"]}),(0,r.jsx)("div",{className:"space-y-1",children:K.map(e=>(0,r.jsx)(P,{node:e,onClick:()=>i(e.id)},e.id))})]}),(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("h4",{className:"text-xs font-semibold text-zinc-500 uppercase tracking-wider mb-2",children:["Comments"," ",a&&a.length>0&&(0,r.jsx)("span",{className:"ml-1 px-1.5 py-0.5 bg-emerald-50 text-emerald-600 rounded-full text-[10px] font-medium",children:a.length})]}),a&&a.length>0?(0,r.jsx)("div",{className:"space-y-1",children:a.map(e=>(0,r.jsx)(W,{comment:e,currentDid:b,isAuthenticated:v,onDelete:p,onLike:f,onStartReply:A,replyingToUri:j,replyText:k,onReplyTextChange:N,onSubmitReply:R,onCancelReply:I,isSubmittingReply:z,depth:0},e.uri))}):(0,r.jsx)("p",{className:"text-xs text-zinc-400 italic",children:"No comments yet"}),v&&l?(0,r.jsx)(B,{onSubmit:l}):v?null:(0,r.jsx)("p",{className:"text-xs text-zinc-400 mt-2",children:"Sign in to leave a comment"})]})]})}function I(e){let{replyingTo:t,replyText:n,onTextChange:s,onSubmit:i,onCancel:a,isSubmitting:l}=e;return(0,r.jsxs)("div",{className:"mt-2 ml-4 pl-3 border-l border-emerald-200 space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] text-zinc-400",children:[(0,r.jsx)("span",{children:"Replying to"}),(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(t.did),target:"_blank",rel:"noopener noreferrer",className:"font-medium text-zinc-600 hover:text-emerald-600 transition-colors",children:t.displayName||t.handle})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{type:"text",value:n,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||i()},placeholder:"Write a reply...",disabled:l,autoFocus:!0,className:"flex-1 px-2 py-1 text-xs bg-white border border-zinc-200 rounded placeholder-zinc-400 focus:outline-none focus:border-emerald-400 disabled:opacity-50"}),(0,r.jsx)("button",{onClick:i,disabled:!n.trim()||l,className:"px-2 py-1 text-[10px] font-medium text-emerald-600 hover:text-emerald-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:l?"...":"Reply"}),(0,r.jsx)("button",{onClick:a,disabled:l,className:"px-2 py-1 text-[10px] text-zinc-400 hover:text-zinc-600 disabled:opacity-50 transition-colors",children:"Cancel"})]})]})}function E(e){let{label:t,value:n,color:s}=e;return(0,r.jsxs)("div",{className:"bg-zinc-50 rounded-lg p-3 border border-zinc-100",children:[(0,r.jsx)("div",{className:"text-xl font-bold",style:{color:s||"#3f3f46"},children:n}),(0,r.jsx)("div",{className:"text-[10px] text-zinc-400 uppercase tracking-wider mt-0.5",children:t})]})}function P(e){let{node:t,onClick:n}=e,s=o[t.status]||o.open;return(0,r.jsxs)("button",{onClick:n,className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-md hover:bg-zinc-50 transition-colors text-left group border border-transparent hover:border-zinc-200",children:[(0,r.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:s}}),(0,r.jsx)("span",{className:"text-xs font-mono text-emerald-600 group-hover:text-emerald-700 shrink-0",children:t.id}),(0,r.jsx)("span",{className:"text-xs text-zinc-500 truncate",children:t.title})]})}function W(e){let{comment:t,currentDid:n,isAuthenticated:i,onDelete:a,onLike:l,onStartReply:o,replyingToUri:c,replyText:d,onReplyTextChange:u,onSubmitReply:x,onCancelReply:h,isSubmittingReply:m,depth:p}=e,[f,g]=(0,s.useState)(!1),[v,b]=(0,s.useState)(!1),y=n&&n===t.did,j=!!n&&t.likes.some(e=>e.did===n),w=c===t.uri,k=async()=>{if(a&&!f){g(!0);try{await a(t)}catch(e){console.error("Failed to delete comment:",e)}finally{g(!1)}}},N=async()=>{if(l&&!v){b(!0);try{await l(t)}catch(e){console.error("Failed to toggle like:",e)}finally{b(!1)}}};return(0,r.jsxs)("div",{className:"".concat(p>0?"ml-4 pl-3 border-l border-zinc-100":""),children:[(0,r.jsxs)("div",{className:"py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("div",{className:"shrink-0 w-4 h-4 rounded-full bg-zinc-100 overflow-hidden",children:t.avatar?(0,r.jsx)("img",{src:t.avatar,alt:"",className:"w-full h-full object-cover"}):(0,r.jsx)("div",{className:"w-full h-full flex items-center justify-center text-[8px] font-medium text-zinc-400",children:(t.handle||t.did).charAt(0).toUpperCase()})}),(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(t.did),target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-zinc-600 truncate hover:text-emerald-600 transition-colors",children:t.displayName||t.handle||t.did.slice(0,16)+"..."}),(0,r.jsx)("span",{className:"text-[10px] text-zinc-300 shrink-0",children:T(t.createdAt)})]}),(0,r.jsx)("p",{className:"text-xs text-zinc-500 leading-relaxed whitespace-pre-wrap break-words",children:t.text}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1 text-[10px]",children:[(0,r.jsxs)("button",{onClick:N,disabled:!i||v,className:"flex items-center gap-0.5 transition-colors ".concat(j?"text-rose-500":"text-zinc-300 hover:text-rose-500"," disabled:opacity-50"),children:[(0,r.jsx)(L,{className:"w-3 h-3",filled:j}),t.likes.length>0&&(0,r.jsx)("span",{children:t.likes.length})]}),(0,r.jsx)("button",{onClick:()=>o(t),disabled:!i,className:"transition-colors disabled:opacity-50 ".concat(w?"text-emerald-500":"text-zinc-300 hover:text-zinc-500"),children:"reply"}),y&&a&&(0,r.jsx)("button",{onClick:k,disabled:f,className:"ml-auto shrink-0 text-zinc-300 hover:text-red-400 disabled:opacity-50 transition-colors",children:f?"...":"delete"})]})]}),w&&(0,r.jsx)(I,{replyingTo:t,replyText:d,onTextChange:u,onSubmit:x,onCancel:h,isSubmitting:m}),t.replies.length>0&&(0,r.jsx)("div",{children:t.replies.map(e=>(0,r.jsx)(W,{comment:e,currentDid:n,isAuthenticated:i,onDelete:a,onLike:l,onStartReply:o,replyingToUri:c,replyText:d,onReplyTextChange:u,onSubmitReply:x,onCancelReply:h,isSubmittingReply:m,depth:p+1},e.uri))})]})}function B(e){let{onSubmit:t}=e,[n,i]=(0,s.useState)(""),[a,l]=(0,s.useState)(!1),o=async()=>{if(n.trim()&&!a){l(!0);try{await t(n.trim()),i("")}catch(e){console.error("Failed to post comment:",e)}finally{l(!1)}}};return(0,r.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,r.jsx)("textarea",{value:n,onChange:e=>i(e.target.value),placeholder:"Leave a comment...",rows:2,className:"w-full px-2.5 py-1.5 text-xs border border-zinc-200 rounded-md bg-zinc-50 text-zinc-700 placeholder-zinc-400 resize-none focus:outline-none focus:ring-1 focus:ring-emerald-500 focus:border-emerald-500"}),(0,r.jsx)("button",{onClick:o,disabled:!n.trim()||a,className:"px-3 py-1 text-xs font-medium text-white bg-emerald-500 rounded-md hover:bg-emerald-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:a?"Sending...":"Comment"})]})}var R=n(7796);function F(){let{isAuthenticated:e,isLoading:t,session:n,login:i,logout:a}=(0,R.a)(),[l,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(!1),[u,x]=(0,s.useState)(""),[h,m]=(0,s.useState)(!1),[p,f]=(0,s.useState)(""),g=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!c)return;let e=e=>{g.current&&!g.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[c]);let v=async e=>{if(e.preventDefault(),u.trim()){m(!0),f("");try{await i(u.trim())}catch(e){f(e instanceof Error?e.message:"Login failed"),m(!1)}}},b=async()=>{d(!1),await a()};return t?(0,r.jsx)("div",{className:"w-4 h-4 rounded-full border-2 border-zinc-200 border-t-zinc-400 animate-spin"}):e&&n?(0,r.jsxs)("div",{className:"relative",ref:g,children:[(0,r.jsxs)("button",{onClick:()=>d(e=>!e),className:"flex items-center gap-2 px-3 py-1.5 rounded-full hover:bg-zinc-50 transition-colors cursor-pointer",children:[n.avatar?(0,r.jsx)("img",{src:n.avatar,alt:n.handle,width:24,height:24,className:"rounded-full"}):(0,r.jsx)("div",{className:"w-6 h-6 rounded-full bg-emerald-100 flex items-center justify-center text-[11px] text-emerald-700 font-medium",children:(n.displayName||n.handle).charAt(0).toUpperCase()}),(0,r.jsx)("span",{className:"text-sm text-zinc-600 max-w-[100px] truncate",children:n.displayName||n.handle})]}),c&&(0,r.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-44 bg-white rounded-xl shadow-xl border border-zinc-100 py-2 z-50",children:[(0,r.jsxs)("a",{href:n.did?"https://www.impactindexer.org/data?did=".concat(n.did):"#",target:"_blank",rel:"noopener noreferrer",className:"block px-3 py-1.5 text-xs text-zinc-400 truncate hover:text-emerald-600 transition-colors",children:["@",n.handle]}),(0,r.jsx)("div",{className:"h-px bg-zinc-100 my-1"}),(0,r.jsxs)("button",{onClick:b,className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs text-zinc-600 hover:bg-zinc-50 transition-colors cursor-pointer",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-zinc-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 9V5.25A2.25 2.25 0 0 1 10.5 3h6a2.25 2.25 0 0 1 2.25 2.25v13.5A2.25 2.25 0 0 1 16.5 21h-6a2.25 2.25 0 0 1-2.25-2.25V15m-3 0-3-3m0 0 3-3m-3 3H15"})}),"Sign out"]})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:()=>o(!0),className:"px-4 py-1.5 text-sm font-medium text-zinc-600 rounded-full hover:text-zinc-900 hover:bg-zinc-50 transition-colors cursor-pointer whitespace-nowrap",children:"Sign in"}),l&&(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",onClick:()=>o(!1),children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/20 backdrop-blur-sm"}),(0,r.jsxs)("div",{className:"relative w-full max-w-sm mx-4 bg-white rounded-xl shadow-lg border border-zinc-200 p-6",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-zinc-900 mb-1",children:"Sign in with ATProto"}),(0,r.jsx)("p",{className:"text-sm text-zinc-400 mb-5",children:"Enter your Bluesky handle to connect."}),(0,r.jsxs)("form",{onSubmit:v,children:[(0,r.jsx)("label",{htmlFor:"auth-handle",className:"block text-sm text-zinc-600 mb-1.5",children:"Handle"}),(0,r.jsx)("input",{id:"auth-handle",type:"text",value:u,onChange:e=>x(e.target.value),placeholder:"alice.bsky.social",disabled:h,autoFocus:!0,className:"w-full px-3 py-2 text-sm bg-white border border-zinc-200 rounded-lg placeholder:text-zinc-300 focus:outline-none focus:ring-2 focus:ring-emerald-500/30 focus:border-emerald-400 disabled:opacity-50 disabled:cursor-not-allowed"}),(0,r.jsx)("p",{className:"text-xs text-zinc-300 mt-1.5",children:"Just a username? We'll add .bsky.social for you."}),p&&(0,r.jsx)("p",{className:"text-sm text-red-500 mt-2",children:p}),(0,r.jsxs)("div",{className:"flex gap-2 mt-5",children:[(0,r.jsx)("button",{type:"button",onClick:()=>o(!1),disabled:h,className:"flex-1 px-3 py-2 text-sm text-zinc-600 bg-zinc-50 rounded-lg hover:bg-zinc-100 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Cancel"}),(0,r.jsx)("button",{type:"submit",disabled:h||!u.trim(),className:"flex-1 px-3 py-2 text-sm text-white bg-emerald-600 rounded-lg hover:bg-emerald-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:h?"Connecting...":"Connect"})]})]})]})]})]})}function _(e){let{className:t}=e;return(0,r.jsxs)("svg",{viewBox:"0 0 32 32",fill:"none",className:t,"aria-hidden":"true",children:[(0,r.jsx)("polygon",{points:"16,3 27,9.5 27,22.5 16,29 5,22.5 5,9.5",stroke:"currentColor",strokeWidth:"1.2",fill:"none",opacity:"0.7",strokeLinejoin:"round",children:(0,r.jsx)("animateTransform",{attributeName:"transform",type:"rotate",values:"0 16 16;360 16 16",dur:"40s",repeatCount:"indefinite"})}),(0,r.jsx)("polygon",{points:"16,8 22.5,11.5 22.5,20.5 16,24 9.5,20.5 9.5,11.5",stroke:"currentColor",strokeWidth:"0.8",fill:"none",opacity:"0.35",strokeLinejoin:"round",children:(0,r.jsx)("animateTransform",{attributeName:"transform",type:"rotate",values:"360 16 16;0 16 16",dur:"30s",repeatCount:"indefinite"})}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"3",stroke:"currentColor",strokeWidth:"0.6",opacity:"0.2",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"0.15;0.35;0.15",dur:"3s",repeatCount:"indefinite"})}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"27",y2:"9.5",stroke:"currentColor",strokeWidth:"0.6",opacity:"0.2",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"0.15;0.35;0.15",dur:"3s",repeatCount:"indefinite",begin:"0.5s"})}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"27",y2:"22.5",stroke:"currentColor",strokeWidth:"0.6",opacity:"0.2",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"0.15;0.35;0.15",dur:"3s",repeatCount:"indefinite",begin:"1s"})}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"29",stroke:"currentColor",strokeWidth:"0.6",opacity:"0.2",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"0.15;0.35;0.15",dur:"3s",repeatCount:"indefinite",begin:"1.5s"})}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"5",y2:"22.5",stroke:"currentColor",strokeWidth:"0.6",opacity:"0.2",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"0.15;0.35;0.15",dur:"3s",repeatCount:"indefinite",begin:"2s"})}),(0,r.jsx)("line",{x1:"16",y1:"16",x2:"5",y2:"9.5",stroke:"currentColor",strokeWidth:"0.6",opacity:"0.2",children:(0,r.jsx)("animate",{attributeName:"opacity",values:"0.15;0.35;0.15",dur:"3s",repeatCount:"indefinite",begin:"2.5s"})}),(0,r.jsxs)("circle",{cx:"16",cy:"16",r:"2.5",fill:"currentColor",opacity:"0.8",children:[(0,r.jsx)("animate",{attributeName:"r",values:"2;3;2",dur:"3s",repeatCount:"indefinite"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.7;1;0.7",dur:"3s",repeatCount:"indefinite"})]}),(0,r.jsxs)("circle",{cx:"16",cy:"3",r:"1.5",fill:"currentColor",opacity:"0.5",children:[(0,r.jsx)("animate",{attributeName:"r",values:"1.2;2;1.2",dur:"2.5s",repeatCount:"indefinite"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.4;0.7;0.4",dur:"2.5s",repeatCount:"indefinite"})]}),(0,r.jsxs)("circle",{cx:"27",cy:"9.5",r:"1.5",fill:"currentColor",opacity:"0.5",children:[(0,r.jsx)("animate",{attributeName:"r",values:"1.2;2;1.2",dur:"2.5s",repeatCount:"indefinite",begin:"0.4s"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.4;0.7;0.4",dur:"2.5s",repeatCount:"indefinite",begin:"0.4s"})]}),(0,r.jsxs)("circle",{cx:"27",cy:"22.5",r:"1.5",fill:"currentColor",opacity:"0.5",children:[(0,r.jsx)("animate",{attributeName:"r",values:"1.2;2;1.2",dur:"2.5s",repeatCount:"indefinite",begin:"0.8s"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.4;0.7;0.4",dur:"2.5s",repeatCount:"indefinite",begin:"0.8s"})]}),(0,r.jsxs)("circle",{cx:"16",cy:"29",r:"1.5",fill:"currentColor",opacity:"0.5",children:[(0,r.jsx)("animate",{attributeName:"r",values:"1.2;2;1.2",dur:"2.5s",repeatCount:"indefinite",begin:"1.2s"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.4;0.7;0.4",dur:"2.5s",repeatCount:"indefinite",begin:"1.2s"})]}),(0,r.jsxs)("circle",{cx:"5",cy:"22.5",r:"1.5",fill:"currentColor",opacity:"0.5",children:[(0,r.jsx)("animate",{attributeName:"r",values:"1.2;2;1.2",dur:"2.5s",repeatCount:"indefinite",begin:"1.6s"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.4;0.7;0.4",dur:"2.5s",repeatCount:"indefinite",begin:"1.6s"})]}),(0,r.jsxs)("circle",{cx:"5",cy:"9.5",r:"1.5",fill:"currentColor",opacity:"0.5",children:[(0,r.jsx)("animate",{attributeName:"r",values:"1.2;2;1.2",dur:"2.5s",repeatCount:"indefinite",begin:"2s"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.4;0.7;0.4",dur:"2.5s",repeatCount:"indefinite",begin:"2s"})]}),(0,r.jsxs)("circle",{cx:"16",cy:"16",r:"10",stroke:"currentColor",strokeWidth:"0.4",fill:"none",opacity:"0.15",children:[(0,r.jsx)("animate",{attributeName:"r",values:"9;11;9",dur:"4s",repeatCount:"indefinite"}),(0,r.jsx)("animate",{attributeName:"opacity",values:"0.1;0.25;0.1",dur:"4s",repeatCount:"indefinite"})]})]})}function O(e){var t;let{node:n,x:i,y:a,onClose:l,onSubmit:o,isAuthenticated:c,existingComments:d}=e,[u,x]=(0,s.useState)(""),[h,p]=(0,s.useState)(!1),f=(0,s.useRef)(null),g=(0,s.useRef)(null),[v,b]=(0,s.useState)({x:0,y:0}),[y,j]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!f.current)return;let e=f.current.getBoundingClientRect(),t=window.innerWidth,n=window.innerHeight,r=i+14,s=a-e.height-14;r+e.width>t-16&&(r=t-e.width-16),r<16&&(r=16),s<16&&(s=a+28),s+e.height>n-16&&(s=n-e.height-16),b({x:r,y:s}),j(!0)},[i,a]),(0,s.useEffect)(()=>{if(c){let e=setTimeout(()=>{var e;return null===(e=g.current)||void 0===e?void 0:e.focus()},100);return()=>clearTimeout(e)}},[c]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&l()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l]),(0,s.useEffect)(()=>{let e=e=>{f.current&&!f.current.contains(e.target)&&l()},t=setTimeout(()=>{window.addEventListener("mousedown",e)},50);return()=>{clearTimeout(t),window.removeEventListener("mousedown",e)}},[l]);let w=(0,s.useCallback)(async()=>{if(u.trim()&&!h){p(!0);try{await o(u.trim()),x("")}catch(e){console.error("Failed to post comment:",e)}finally{p(!1)}}},[u,h,o]),k=(0,s.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),w())},[w]),N=m[n.prefix]||"#a1a1aa",z=(null==d?void 0:d.length)||0;return(0,r.jsxs)("div",{ref:f,style:{position:"fixed",left:v.x,top:v.y,width:320,zIndex:100,opacity:y?1:0,transform:y?"translateY(0)":"translateY(4px)",transition:"opacity 0.2s ease, transform 0.2s ease"},className:"bg-white border border-zinc-200 rounded-lg overflow-hidden",onContextMenu:e=>e.preventDefault(),children:[(0,r.jsx)("style",{children:"\n .comment-tooltip-shadow {\n box-shadow: 0 8px 32px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.08);\n }\n "}),(0,r.jsxs)("div",{className:"comment-tooltip-shadow p-[18px_20px]",children:[(0,r.jsx)("div",{className:"rounded-sm mb-2.5",style:{width:24,height:2,background:N,opacity:.6}}),(0,r.jsxs)("div",{className:"mb-3",children:[(0,r.jsx)("span",{className:"text-xs font-mono text-emerald-600",children:n.id}),(0,r.jsx)("h3",{className:"text-sm font-semibold text-zinc-800 leading-tight mt-0.5",children:n.title})]}),z>0&&d&&(0,r.jsxs)("div",{className:"mb-3 pb-3 border-b border-zinc-100",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-2",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-blue-500",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 20.25c4.97 0 9-3.694 9-8.25s-4.03-8.25-9-8.25S3 7.444 3 12c0 2.104.859 4.023 2.273 5.48.432.447.74 1.04.586 1.641a4.483 4.483 0 01-.923 1.785A5.969 5.969 0 006 21c1.282 0 2.47-.402 3.445-1.087.81.22 1.668.337 2.555.337z"})}),(0,r.jsxs)("span",{className:"text-[10px] font-medium text-zinc-500 uppercase tracking-wider",children:[z," comment",1!==z?"s":""]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[d.slice(0,2).map(e=>(0,r.jsxs)("div",{className:"flex gap-1.5",children:[(0,r.jsx)("div",{className:"shrink-0 w-4 h-4 rounded-full bg-zinc-100 overflow-hidden mt-0.5",children:e.avatar?(0,r.jsx)("img",{src:e.avatar,alt:"",className:"w-full h-full object-cover"}):(0,r.jsx)("div",{className:"w-full h-full flex items-center justify-center text-[7px] font-medium text-zinc-400",children:(e.handle||e.did).charAt(0).toUpperCase()})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(e.did),target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-medium text-zinc-500 hover:text-emerald-600 transition-colors",children:e.displayName||e.handle}),(0,r.jsx)("p",{className:"text-[11px] text-zinc-500 line-clamp-2 leading-tight",children:e.text})]})]},e.uri)),z>2&&(0,r.jsxs)("p",{className:"text-[10px] text-zinc-400 italic",children:["+",z-2," more — see detail panel"]})]})]}),c?(0,r.jsxs)("div",{children:[(0,r.jsx)("textarea",{ref:g,value:u,onChange:e=>x(e.target.value),onKeyDown:k,placeholder:"Leave a comment...",rows:3,className:"w-full px-2.5 py-2 text-xs border border-zinc-200 rounded-md bg-zinc-50 text-zinc-700 placeholder-zinc-400 resize-none focus:outline-none focus:ring-1 focus:ring-emerald-500 focus:border-emerald-500"}),(0,r.jsxs)("div",{className:"flex items-center justify-between mt-2",children:[(0,r.jsxs)("span",{className:"text-[10px] text-zinc-300",children:["undefined"!=typeof navigator&&(null===(t=navigator.platform)||void 0===t?void 0:t.includes("Mac"))?"⌘":"Ctrl","+Enter to send"]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:l,className:"px-2.5 py-1 text-[11px] text-zinc-400 hover:text-zinc-600 transition-colors",children:"Cancel"}),(0,r.jsx)("button",{onClick:w,disabled:!u.trim()||h,className:"px-3 py-1 text-[11px] font-medium text-white bg-emerald-500 rounded-md hover:bg-emerald-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:h?(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsxs)("svg",{className:"w-3 h-3 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Sending"]}):"Send"})]})]})]}):(0,r.jsxs)("div",{className:"text-center py-3",children:[(0,r.jsx)("svg",{className:"w-5 h-5 text-zinc-300 mx-auto mb-1.5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 10.5V6.75a4.5 4.5 0 10-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 002.25-2.25v-6.75a2.25 2.25 0 00-2.25-2.25H6.75a2.25 2.25 0 00-2.25 2.25v6.75a2.25 2.25 0 002.25 2.25z"})}),(0,r.jsx)("p",{className:"text-xs text-zinc-400",children:"Sign in to comment"})]})]})]})}function U(e){let{node:t,x:n,y:i,onShowDescription:a,onAddComment:l,onClaimTask:o,onUnclaimTask:c,onClose:d}=e,u=(0,s.useRef)(null),[x,h]=(0,s.useState)({x:0,y:0}),[m,p]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{if(!u.current)return;let e=u.current.getBoundingClientRect(),t=window.innerWidth,r=window.innerHeight,s=n+4,a=i+4;s+e.width>t-16&&(s=t-e.width-16),s<16&&(s=16),a+e.height>r-16&&(a=r-e.height-16),a<16&&(a=16),h({x:s,y:a}),p(!0)},[n,i]),(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&d()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[d]),(0,s.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&d()},t=setTimeout(()=>window.addEventListener("mousedown",e),50);return()=>{clearTimeout(t),window.removeEventListener("mousedown",e)}},[d]),(0,r.jsx)("div",{ref:u,style:{position:"fixed",left:x.x,top:x.y,zIndex:100,opacity:m?1:0,transform:m?"translateY(0)":"translateY(2px)",transition:"opacity 0.15s ease, transform 0.15s ease"},onContextMenu:e=>e.preventDefault(),children:(0,r.jsxs)("div",{className:"bg-white border border-zinc-200 rounded-lg overflow-hidden",style:{minWidth:180,boxShadow:"0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.06)"},children:[t.description&&(0,r.jsxs)("button",{onClick:a,className:"w-full px-3 py-2.5 text-xs text-zinc-700 hover:bg-zinc-50 flex items-center gap-2 transition-colors border-b border-zinc-100",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-zinc-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),"Show description"]}),(0,r.jsxs)("button",{onClick:l,className:"w-full px-3 py-2.5 text-xs text-zinc-700 hover:bg-zinc-50 flex items-center gap-2 transition-colors".concat(o||c?" border-b border-zinc-100":""),children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-zinc-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 20.25c4.97 0 9-3.694 9-8.25s-4.03-8.25-9-8.25S3 7.444 3 12c0 2.104.859 4.023 2.273 5.48.432.447.74 1.04.586 1.641a4.483 4.483 0 01-.923 1.785A5.969 5.969 0 006 21c1.282 0 2.47-.402 3.445-1.087.81.22 1.668.337 2.555.337z"})}),"Add comment"]}),o&&(0,r.jsxs)("button",{onClick:o,className:"w-full px-3 py-2.5 text-xs text-zinc-700 hover:bg-zinc-50 flex items-center gap-2 transition-colors",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-zinc-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z"})}),"Claim task"]}),c&&(0,r.jsxs)("button",{onClick:c,className:"w-full px-3 py-2.5 text-xs text-red-500 hover:bg-red-50 flex items-center gap-2 transition-colors",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M22 10.5h-6m-2.25-4.125a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zM4 19.235v-.11a6.375 6.375 0 0112.75 0v.109A12.318 12.318 0 0110.374 21c-2.331 0-4.512-.645-6.374-1.766z"})}),"Unclaim task"]})]})})}function H(e){let{isOpen:t,onClose:n,allComments:s,onNodeNavigate:i,isAuthenticated:a,currentDid:l,onLikeComment:o,onDeleteComment:c}=e;return(0,r.jsxs)("aside",{className:"hidden md:flex absolute top-0 right-0 h-full w-[360px] bg-white border-l border-zinc-200 flex-col shadow-xl z-30 transform transition-transform duration-300 ease-out ".concat(t?"translate-x-0":"translate-x-full"),children:[(0,r.jsxs)("div",{className:"shrink-0 px-5 py-3 border-b border-zinc-100 flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold text-zinc-400 uppercase tracking-wider",children:"All Comments"}),s.length>0&&(0,r.jsx)("span",{className:"px-1.5 py-0.5 bg-emerald-50 text-emerald-600 rounded-full text-[10px] font-medium",children:s.length})]}),(0,r.jsx)("button",{onClick:n,className:"p-1 text-zinc-400 hover:text-zinc-600 transition-colors rounded-full hover:bg-zinc-100",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar px-5 py-3",children:s.length>0?(0,r.jsx)("div",{className:"space-y-0",children:s.filter(e=>!e.replyTo).map(e=>(0,r.jsx)(Y,{comment:e,currentDid:l,isAuthenticated:a,onNodeNavigate:i,onLike:o,onDelete:c,depth:0},e.uri))}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)("svg",{className:"w-8 h-8 text-zinc-200 mb-3",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12.76c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.076-4.076a1.526 1.526 0 011.037-.443 48.282 48.282 0 005.68-.494c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z"})}),(0,r.jsx)("p",{className:"text-xs text-zinc-400",children:"No comments yet"}),(0,r.jsx)("p",{className:"text-[10px] text-zinc-300 mt-1",children:"Right-click a node to leave a comment"})]})}),(0,r.jsx)("div",{className:"shrink-0 px-5 py-2.5 border-t border-zinc-100 bg-zinc-50/50",children:(0,r.jsxs)("div",{className:"text-[10px] text-zinc-400",children:[s.length," comment",1!==s.length?"s":""," across all issues"]})})]})}function Y(e){let{comment:t,currentDid:n,isAuthenticated:i,onNodeNavigate:a,onLike:l,onDelete:o,depth:c}=e,[d,u]=(0,s.useState)(!1),[x,h]=(0,s.useState)(!1),m=n&&n===t.did,p=!!n&&t.likes.some(e=>e.did===n),f=async()=>{if(l&&!d){u(!0);try{await l(t)}catch(e){console.error("Failed to toggle like:",e)}finally{u(!1)}}},g=async()=>{if(o&&!x){h(!0);try{await o(t)}catch(e){console.error("Failed to delete comment:",e)}finally{h(!1)}}};return(0,r.jsxs)("div",{className:"".concat(c>0?"ml-4 pl-3 border-l border-zinc-100":""),children:[(0,r.jsxs)("div",{className:"py-3 ".concat(0===c?"border-b border-zinc-50":""),children:[0===c&&(0,r.jsx)("button",{onClick:()=>a(t.nodeId),className:"inline-flex items-center px-1.5 py-0.5 mb-1.5 rounded text-[10px] font-mono bg-emerald-50 text-emerald-600 hover:bg-emerald-100 transition-colors",children:t.nodeId}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,r.jsx)("div",{className:"shrink-0 w-4 h-4 rounded-full bg-zinc-100 overflow-hidden",children:t.avatar?(0,r.jsx)("img",{src:t.avatar,alt:"",className:"w-full h-full object-cover"}):(0,r.jsx)("div",{className:"w-full h-full flex items-center justify-center text-[8px] font-medium text-zinc-400",children:(t.handle||t.did).charAt(0).toUpperCase()})}),(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(t.did),target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-zinc-600 truncate hover:text-emerald-600 transition-colors",children:t.displayName||t.handle||t.did.slice(0,16)+"..."}),(0,r.jsx)("span",{className:"text-[10px] text-zinc-300 shrink-0",children:T(t.createdAt)})]}),(0,r.jsx)("p",{className:"text-xs text-zinc-500 leading-relaxed whitespace-pre-wrap break-words",children:t.text}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1 text-[10px]",children:[(0,r.jsxs)("button",{onClick:f,disabled:!i||d,className:"flex items-center gap-0.5 transition-colors ".concat(p?"text-rose-500":"text-zinc-300 hover:text-rose-500"," disabled:opacity-50"),children:[(0,r.jsx)(L,{className:"w-3 h-3",filled:p}),t.likes.length>0&&(0,r.jsx)("span",{children:t.likes.length})]}),m&&o&&(0,r.jsx)("button",{onClick:g,disabled:x,className:"ml-auto text-zinc-300 hover:text-red-400 disabled:opacity-50 transition-colors",children:x?"...":"delete"})]})]}),t.replies.length>0&&(0,r.jsx)("div",{children:t.replies.map(e=>(0,r.jsx)(Y,{comment:e,currentDid:n,isAuthenticated:i,onNodeNavigate:a,onLike:l,onDelete:o,depth:c+1},e.uri))})]})}function q(e){let{type:t,className:n}=e,s=n||"w-3.5 h-3.5 shrink-0";switch(t){case"node-created":return(0,r.jsxs)("svg",{className:"".concat(s," text-emerald-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("line",{x1:"8",y1:"5",x2:"8",y2:"11"}),(0,r.jsx)("line",{x1:"5",y1:"8",x2:"11",y2:"8"})]});case"node-closed":return(0,r.jsxs)("svg",{className:"".concat(s," text-zinc-400"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("polyline",{points:"5.5,8 7.5,10 10.5,6"})]});case"node-status-changed":return(0,r.jsx)("svg",{className:"".concat(s," text-amber-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,r.jsx)("path",{d:"M3 8h10M10 5l3 3-3 3"})});case"node-priority-changed":return(0,r.jsx)("svg",{className:"".concat(s," text-amber-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,r.jsx)("path",{d:"M8 3v7M5 6l3-3 3 3M4 13h8"})});case"node-title-changed":return(0,r.jsx)("svg",{className:"".concat(s," text-amber-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,r.jsx)("path",{d:"M3 4h10M3 8h6M3 12h8"})});case"node-owner-changed":return(0,r.jsxs)("svg",{className:"".concat(s," text-amber-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"6",cy:"6",r:"2.5"}),(0,r.jsx)("path",{d:"M1.5 13c0-2 1.8-3.5 4.5-3.5M10 9l2 2 3-3"})]});case"link-added":return(0,r.jsx)("svg",{className:"".concat(s," text-blue-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,r.jsx)("path",{d:"M6.5 9.5l3-3M4 11a2.5 2.5 0 003.5 0l1-1M8.5 6a2.5 2.5 0 013.5 0l0 0"})});case"link-removed":return(0,r.jsxs)("svg",{className:"".concat(s," text-red-400"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("path",{d:"M4 11a2.5 2.5 0 003.5 0l1-1M8.5 6a2.5 2.5 0 013.5 0l0 0"}),(0,r.jsx)("line",{x1:"3",y1:"3",x2:"13",y2:"13",strokeWidth:"1.5"})]});case"comment-added":case"reply-added":return(0,r.jsx)("svg",{className:"".concat(s," text-blue-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,r.jsx)("path",{d:"M2 4.5a1.5 1.5 0 011.5-1.5h9A1.5 1.5 0 0114 4.5v5a1.5 1.5 0 01-1.5 1.5H5L2 14V4.5z"})});case"task-claimed":return(0,r.jsxs)("svg",{className:"".concat(s," text-emerald-500"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"5.5",r:"2.5"}),(0,r.jsx)("path",{d:"M3 13.5c0-2.5 2.2-4.5 5-4.5s5 2 5 4.5"})]});case"task-unclaimed":return(0,r.jsxs)("svg",{className:"".concat(s," text-red-400"),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"5.5",r:"2.5"}),(0,r.jsx)("path",{d:"M3 13.5c0-2.5 2.2-4.5 5-4.5s5 2 5 4.5"}),(0,r.jsx)("line",{x1:"11",y1:"3",x2:"13",y2:"5"})]});case"like-added":return(0,r.jsx)("svg",{className:"".concat(s," text-rose-400"),viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M8 13.7l-.6-.5C4 10.2 2 8.3 2 6a3 3 0 016-1 3 3 0 016 1c0 2.3-2 4.2-5.4 7.2l-.6.5z"})})}}function X(e){switch(e){case"node-created":case"task-claimed":return"bg-emerald-400";case"node-closed":return"bg-zinc-300";case"node-status-changed":case"node-priority-changed":case"node-title-changed":case"node-owner-changed":return"bg-amber-400";case"link-added":case"comment-added":case"reply-added":return"bg-blue-400";case"link-removed":case"task-unclaimed":return"bg-red-300";case"like-added":return"bg-rose-300"}}function V(e){var t,n,r;switch(e.type){case"node-created":{let n=(null===(t=e.meta)||void 0===t?void 0:t.issueType)||"task";return"".concat(n," created")}case"node-closed":return"closed".concat(e.detail&&"Closed"!==e.detail?" (".concat(e.detail,")"):"");case"node-status-changed":return e.detail||"status changed";case"node-priority-changed":return"priority ".concat(e.detail||"changed");case"node-title-changed":return"title updated";case"node-owner-changed":return"owner ".concat(e.detail||"changed");case"link-added":return"dep added: ".concat((null===(n=e.meta)||void 0===n?void 0:n.target)||"");case"link-removed":return"dep removed: ".concat((null===(r=e.meta)||void 0===r?void 0:r.target)||"");case"comment-added":return e.detail||"commented";case"reply-added":return e.detail||"replied";case"task-claimed":return"claimed this task";case"task-unclaimed":return"unclaimed this task";case"like-added":return e.detail||"liked a comment"}}function K(e){let{event:t,onNodeClick:n}=e;return(0,r.jsxs)("div",{className:"flex items-center gap-2 py-2 px-3 group hover:bg-zinc-50/60 transition-colors",children:[(0,r.jsx)("div",{className:"w-1 h-1 rounded-full shrink-0 ".concat(X(t.type))}),(0,r.jsx)(q,{type:t.type,className:"w-3 h-3 shrink-0"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 text-[11px] text-zinc-600 truncate",children:[t.actor?(0,r.jsxs)(r.Fragment,{children:[t.actor.did?(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(t.actor.did),target:"_blank",rel:"noopener noreferrer",className:"font-medium text-zinc-800 hover:text-emerald-600 transition-colors",children:t.actor.handle.split(".")[0]}):(0,r.jsx)("span",{className:"font-medium text-zinc-800",children:t.actor.handle.split(".")[0]})," "]}):n?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{onClick:()=>n(t.nodeId),className:"font-medium text-zinc-700 hover:text-emerald-600 transition-colors",children:t.nodeId})," "]}):null,(0,r.jsx)("span",{className:"text-zinc-500",children:V(t)})]}),(0,r.jsx)("span",{className:"text-[10px] text-zinc-400 shrink-0 tabular-nums opacity-0 group-hover:opacity-100 transition-opacity",children:T(new Date(t.time).toISOString())})]})}function $(e){var t;let{event:n,onNodeClick:s}=e;return(0,r.jsxs)("div",{className:"flex gap-3 py-3 px-4 hover:bg-zinc-50/50 transition-colors group",children:[(0,r.jsx)("div",{className:"w-0.5 self-stretch rounded-full shrink-0 ".concat(X(n.type))}),(0,r.jsx)("div",{className:"mt-0.5 shrink-0",children:(null===(t=n.actor)||void 0===t?void 0:t.avatar)?(0,r.jsx)("img",{src:n.actor.avatar,alt:n.actor.handle,className:"w-7 h-7 rounded-full ring-1 ring-zinc-100"}):n.actor?(0,r.jsx)("div",{className:"w-7 h-7 rounded-full bg-zinc-100 flex items-center justify-center text-[11px] font-medium text-zinc-500",children:n.actor.handle.charAt(0).toUpperCase()}):(0,r.jsx)("div",{className:"w-7 h-7 rounded-full bg-zinc-50 flex items-center justify-center",children:(0,r.jsx)(q,{type:n.type,className:"w-3.5 h-3.5"})})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-1.5 text-[12px] leading-snug",children:[n.actor&&(n.actor.did?(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(n.actor.did),target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-zinc-800 hover:text-emerald-600 transition-colors truncate max-w-[140px]",children:n.actor.handle.split(".")[0]}):(0,r.jsx)("span",{className:"font-semibold text-zinc-800 truncate max-w-[140px]",children:n.actor.handle.split(".")[0]})),(0,r.jsx)("span",{className:"text-zinc-500",children:V(n)})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mt-1",children:[s&&(0,r.jsx)("button",{onClick:()=>s(n.nodeId),className:"inline-flex items-center px-1.5 py-0.5 text-[10px] font-mono font-medium text-emerald-700 bg-emerald-50 rounded-md hover:bg-emerald-100 transition-colors",children:n.nodeId}),n.nodeTitle&&(0,r.jsx)("span",{className:"text-[11px] text-zinc-400 truncate",children:n.nodeTitle})]})]}),(0,r.jsx)("span",{className:"text-[10px] text-zinc-400 shrink-0 tabular-nums mt-0.5",children:T(new Date(n.time).toISOString())})]})}function J(e){let{event:t,variant:n="compact",onNodeClick:s}=e;return"compact"===n?(0,r.jsx)(K,{event:t,onNodeClick:s}):(0,r.jsx)($,{event:t,onNodeClick:s})}function G(e){let{events:t,collapsed:n,onToggleCollapse:s,onExpandPanel:i,onNodeClick:a}=e,l=t.filter(e=>Date.now()-e.time<3e5).length;return n?(0,r.jsxs)("button",{onClick:s,className:"group flex items-center gap-2 px-3 py-2 bg-white/90 backdrop-blur-sm rounded-full border border-zinc-200/80 shadow-sm hover:bg-white hover:shadow-md transition-all",title:"Show activity feed",children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5 text-zinc-400 group-hover:text-emerald-500 transition-colors",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("polyline",{points:"8,4 8,8 11,10"})]}),(0,r.jsx)("span",{className:"text-xs text-zinc-500 group-hover:text-zinc-700 transition-colors",children:"Activity"}),l>0&&(0,r.jsx)("span",{className:"text-[10px] font-medium text-white bg-emerald-500 rounded-full px-1.5 py-0.5 min-w-[18px] text-center leading-tight",children:l})]}):(0,r.jsxs)("div",{className:"w-72 bg-white/95 backdrop-blur-sm rounded-xl border border-zinc-200/80 shadow-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3.5 py-2.5 border-b border-zinc-100/80",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),(0,r.jsx)("span",{className:"text-[11px] font-semibold text-zinc-600",children:"Live Activity"})]}),(0,r.jsx)("button",{onClick:s,className:"text-zinc-400 hover:text-zinc-600 transition-colors p-1 -mr-0.5 rounded-full hover:bg-zinc-100",title:"Collapse",children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"})})})]}),(0,r.jsx)("div",{className:"py-0.5 max-h-[260px] overflow-y-auto custom-scrollbar",children:0===t.length?(0,r.jsxs)("div",{className:"py-6 text-center",children:[(0,r.jsxs)("svg",{className:"w-5 h-5 text-zinc-200 mx-auto mb-1.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("polyline",{points:"8,4 8,8 11,10"})]}),(0,r.jsx)("p",{className:"text-[11px] text-zinc-400",children:"No activity yet"})]}):t.slice(0,6).map((e,t)=>(0,r.jsx)("div",{className:0===t?"bg-emerald-50/30":"",children:(0,r.jsx)(J,{event:e,variant:"compact",onNodeClick:a})},e.id))}),t.length>0&&(0,r.jsxs)("div",{className:"flex items-center justify-between px-3.5 py-2 border-t border-zinc-100/80 bg-zinc-50/30",children:[(0,r.jsxs)("span",{className:"text-[10px] text-zinc-400",children:[t.length," event",1!==t.length?"s":""]}),(0,r.jsxs)("button",{onClick:i,className:"text-[11px] text-emerald-600 hover:text-emerald-700 transition-colors font-medium flex items-center gap-1",children:["See all",(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]})]})]})}function Z(e,t){let n=new Set(e.map(e=>e.id)),r=[...e];for(let e of t)n.has(e.id)||(n.add(e.id),r.push(e));return r.sort((e,t)=>t.time-e.time),r.slice(0,200)}let Q=[{key:"issues",label:"Issues",icon:"circle"},{key:"deps",label:"Deps",icon:"link"},{key:"comments",label:"Comments",icon:"chat"},{key:"claims",label:"Claims",icon:"user"},{key:"likes",label:"Likes",icon:"heart"}];function ee(e){let{events:t,isOpen:n,onClose:i,onNodeClick:a}=e,[l,o]=(0,s.useState)(""),[c,d]=(0,s.useState)(new Set(Q.map(e=>e.key))),u=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.size>1&&n.delete(e):n.add(e),n})},x=(0,s.useMemo)(()=>{let e=t;if(e=e.filter(e=>c.has(function(e){switch(e){case"node-created":case"node-closed":case"node-status-changed":case"node-priority-changed":case"node-title-changed":case"node-owner-changed":return"issues";case"link-added":case"link-removed":return"deps";case"comment-added":case"reply-added":return"comments";case"task-claimed":case"task-unclaimed":return"claims";case"like-added":return"likes"}}(e.type))),l.trim()){let t=l.trim().toLowerCase();e=e.filter(e=>{var n;return e.nodeId.toLowerCase().includes(t)||e.nodeTitle&&e.nodeTitle.toLowerCase().includes(t)||(null===(n=e.actor)||void 0===n?void 0:n.handle)&&e.actor.handle.toLowerCase().includes(t)||e.detail&&e.detail.toLowerCase().includes(t)})}return e},[t,c,l]),h=(0,s.useMemo)(()=>(function(e){let t=new Map,n=[];for(let r of e){let e=function(e){let t=Date.now()-e,n=t/36e5,r=t/864e5;return n<1?"Just now":n<24?"Today":r<2?"Yesterday":r<7?"This week":r<30?"This month":"Older"}(r.time);t.has(e)||(t.set(e,[]),n.push(e)),t.get(e).push(r)}return n.map(e=>({label:e,events:t.get(e)}))})(x),[x]),m=c.size===Q.length;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("aside",{className:"hidden md:flex absolute top-0 right-0 h-full w-[360px] bg-white border-l border-zinc-200 flex-col shadow-xl z-30 transform transition-transform duration-300 ease-out ".concat(n?"translate-x-0":"translate-x-full"),children:[(0,r.jsxs)("div",{className:"shrink-0 px-5 py-3 border-b border-zinc-100 flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold text-zinc-400 uppercase tracking-wider",children:"Activity"}),t.length>0&&(0,r.jsx)("span",{className:"px-1.5 py-0.5 bg-emerald-50 text-emerald-600 rounded-full text-[10px] font-medium",children:t.length})]}),(0,r.jsx)("button",{onClick:i,className:"p-1 text-zinc-400 hover:text-zinc-600 transition-colors rounded-full hover:bg-zinc-100",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"px-4 pt-3 pb-2 shrink-0",children:(0,r.jsxs)("div",{className:"flex items-center bg-zinc-50/80 rounded-full border border-zinc-200/60 overflow-hidden",children:[(0,r.jsx)("div",{className:"pl-3 pr-1 text-zinc-400",children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),(0,r.jsx)("input",{type:"text",value:l,onChange:e=>o(e.target.value),placeholder:"Search activity...",className:"flex-1 px-2 py-2 text-xs text-zinc-800 bg-transparent outline-none placeholder:text-zinc-400"}),l&&(0,r.jsx)("button",{onClick:()=>o(""),className:"pr-3 text-zinc-400 hover:text-zinc-600",children:(0,r.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5 px-4 pb-3 shrink-0",children:Q.map(e=>{let t=c.has(e.key);return(0,r.jsx)("button",{onClick:()=>u(e.key),className:"px-2.5 py-1 text-[11px] font-medium rounded-full border transition-all ".concat(t?"bg-emerald-50 text-emerald-700 border-emerald-200 shadow-sm":"bg-white text-zinc-400 border-zinc-200 hover:text-zinc-600 hover:border-zinc-300"),children:e.label},e.key)})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar border-t border-zinc-100",children:0===x.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)("svg",{className:"w-8 h-8 text-zinc-200 mb-3",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})}),(0,r.jsx)("p",{className:"text-xs text-zinc-400",children:l.trim()?"No activity matching your search":"No activity yet"}),l.trim()&&(0,r.jsx)("button",{onClick:()=>o(""),className:"text-[11px] text-emerald-600 hover:text-emerald-700 mt-1.5",children:"Clear search"})]}):h.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"sticky top-0 z-[1] px-4 py-1.5 bg-zinc-50/95 backdrop-blur-sm border-b border-zinc-100/60",children:(0,r.jsx)("span",{className:"text-[10px] font-semibold text-zinc-400 uppercase tracking-wider",children:e.label})}),(0,r.jsx)("div",{className:"divide-y divide-zinc-50",children:e.events.map(e=>(0,r.jsx)(J,{event:e,variant:"full",onNodeClick:a},e.id))})]},e.label))}),(0,r.jsx)("div",{className:"shrink-0 px-5 py-2.5 border-t border-zinc-100 bg-zinc-50/50",children:(0,r.jsxs)("div",{className:"text-[10px] text-zinc-400",children:[x.length," event",1!==x.length?"s":"",!m&&" (filtered)",l.trim()&&' matching "'.concat(l.trim(),'"')]})})]}),(0,r.jsx)("div",{className:"md:hidden fixed inset-x-0 bottom-0 z-20 transition-transform duration-300 ease-out ".concat(n?"translate-y-0":"translate-y-full"),children:(0,r.jsxs)("div",{className:"bg-white rounded-t-2xl shadow-xl border-t border-zinc-200 max-h-[60vh] flex flex-col",children:[(0,r.jsx)("div",{className:"flex justify-center pt-3 pb-1",children:(0,r.jsx)("div",{className:"w-8 h-1 bg-zinc-300 rounded-full"})}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"text-sm font-semibold text-zinc-900",children:"Activity"}),t.length>0&&(0,r.jsx)("span",{className:"px-1.5 py-0.5 bg-emerald-50 text-emerald-600 rounded-full text-[10px] font-medium",children:t.length})]}),(0,r.jsx)("button",{onClick:i,className:"p-1 text-zinc-400 hover:text-zinc-600",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5 px-5 pb-3",children:Q.map(e=>(0,r.jsx)("button",{onClick:()=>u(e.key),className:"px-2.5 py-1 text-[11px] font-medium rounded-full border transition-colors ".concat(c.has(e.key)?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-white text-zinc-400 border-zinc-200"),children:e.label},e.key))}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:0===x.length?(0,r.jsx)("div",{className:"py-8 text-center text-xs text-zinc-400",children:"No activity matching filters"}):h.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"sticky top-0 z-[1] px-5 py-1.5 bg-zinc-50/95 backdrop-blur-sm border-b border-zinc-100/60",children:(0,r.jsx)("span",{className:"text-[10px] font-semibold text-zinc-400 uppercase tracking-wider",children:e.label})}),(0,r.jsx)("div",{className:"divide-y divide-zinc-50",children:e.events.map(e=>(0,r.jsx)(J,{event:e,variant:"full",onNodeClick:a},e.id))})]},e.label))})]})})]})}let et=new Map,en=new Map;async function er(e){let t=et.get(e);if(t)return t;let n=en.get(e);if(n)return n;let r=(async()=>{try{let t=await fetch("https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=".concat(encodeURIComponent(e)));if(!t.ok)throw Error("Profile fetch failed: ".concat(t.status));let n=await t.json(),r={did:e,handle:n.handle||e,displayName:n.displayName||void 0,avatar:n.avatar||void 0};return et.set(e,r),r}catch(n){let t={did:e,handle:e.slice(0,20)+"..."};return et.set(e,t),t}finally{en.delete(e)}})();return en.set(e,r),r}async function es(e){let t;let n=[],r=!0,s=0;for(;r&&s<5;){var i,a;let l=await fetch("https://hypergoat-app-production.up.railway.app/graphql",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"\n query FetchRecords($collection: String!, $first: Int, $after: String) {\n records(collection: $collection, first: $first, after: $after) {\n edges {\n node {\n cid\n collection\n did\n rkey\n uri\n value\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n",variables:{collection:e,first:100,after:t}})});if(!l.ok)throw Error("Indexer fetch failed: ".concat(l.status));let o=await l.json();if(null===(i=o.errors)||void 0===i?void 0:i.length)throw Error(o.errors[0].message);let c=null===(a=o.data)||void 0===a?void 0:a.records;if(!c)break;for(let e of c.edges)n.push(e.node);r=c.pageInfo.hasNextPage,t=c.pageInfo.endCursor,s++}return n}function ei(e){let{totalSteps:t,currentStep:n,currentTime:i,isPlaying:a,speed:l,onStepChange:o,onPlayPause:c,onSpeedChange:d}=e,u=(0,s.useCallback)(e=>{o(Number(e.target.value))},[o]),x=(0,s.useCallback)(()=>{d(1===l?2:2===l?4:1)},[l,d]),h=t>1;return(0,r.jsx)("div",{className:"bg-white/90 backdrop-blur-sm rounded-lg border border-zinc-200 shadow-sm px-3 py-2 min-w-[280px] max-w-[480px]",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{onClick:c,disabled:!h,className:"shrink-0 w-6 h-6 flex items-center justify-center rounded transition-colors ".concat(a?"text-emerald-500 hover:text-emerald-600":"text-zinc-500 hover:text-zinc-700"," disabled:opacity-40 disabled:cursor-not-allowed"),children:a?(0,r.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:[(0,r.jsx)("rect",{x:"3",y:"2",width:"3.5",height:"12",rx:"1"}),(0,r.jsx)("rect",{x:"9.5",y:"2",width:"3.5",height:"12",rx:"1"})]}):(0,r.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M4 2l10 6-10 6V2z"})})}),(0,r.jsx)("input",{type:"range",min:0,max:Math.max(t-1,0),value:n,onChange:u,disabled:!h,className:"timeline-slider flex-1 h-4 disabled:opacity-40"}),(0,r.jsxs)("span",{className:"shrink-0 text-xs text-zinc-500 font-medium text-right whitespace-nowrap",children:[(0,r.jsxs)("span",{className:"text-zinc-400",children:[n+1,"/",t]})," ",new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]}),(0,r.jsxs)("button",{onClick:x,className:"shrink-0 px-1.5 py-0.5 text-[10px] font-semibold rounded transition-colors ".concat(l>1?"bg-emerald-500 text-white":"text-zinc-500 border border-zinc-200 hover:text-zinc-700"),children:[l,"x"]})]})})}function ea(e,t,n){let r=Date.now(),s=new Map(e.graphData.nodes.map(e=>[e.id,e])),a=new Set(e.graphData.links.map(i)),l=t.graphData.nodes.map(e=>{let i=s.get(e.id);if(!i){let n=function(e,t,n){for(let r of t){let t="object"==typeof r.source?r.source.id:r.source,s="object"==typeof r.target?r.target.id:r.target;if(t===e&&n.has(s)){let e=n.get(s);if(null!=e.x&&null!=e.y)return{x:e.x,y:e.y}}if(s===e&&n.has(t)){let e=n.get(t);if(null!=e.x&&null!=e.y)return{x:e.x,y:e.y}}}return null}(e.id,t.graphData.links,s);return{...e,_spawnTime:r,x:n?n.x+(Math.random()-.5)*40:void 0,y:n?n.y+(Math.random()-.5)*40:void 0}}let a={...e,x:i.x,y:i.y,fx:i.fx,fy:i.fy};if(n.changedNodes.has(e.id)){let t=n.changedNodes.get(e.id).find(e=>"status"===e.field);t&&(a._changedAt=r,a._prevStatus=t.from)}return a});for(let e of n.removedNodeIds){let t=s.get(e);t&&l.push({...t,_removeTime:r})}let o=t.graphData.links.map(e=>{let t=i(e);return a.has(t)?e:{...e,_spawnTime:r}});for(let t of n.removedLinkKeys){let n=e.graphData.links.find(e=>i(e)===t);n&&o.push({source:"object"==typeof n.source?n.source.id:n.source,target:"object"==typeof n.target?n.target.id:n.target,type:n.type,_removeTime:r})}return{...t,graphData:{nodes:l,links:o}}}let el={open:"bg-emerald-500",in_progress:"bg-amber-500",blocked:"bg-red-500",deferred:"bg-violet-500",closed:"bg-zinc-400"};function eo(){var e,t,n;let[i,l]=(0,s.useState)(null),[o,c]=(0,s.useState)(!0),[d,u]=(0,s.useState)(null),[x,h]=(0,s.useState)(null),[m,p]=(0,s.useState)(null),[f,g]=(0,s.useState)("Beads"),[v,b]=(0,s.useState)(0),[y,j]=(0,s.useState)({}),{isAuthenticated:w,session:k}=(0,R.a)(),{commentsByNode:z,commentedNodeIds:C,allComments:M,refetch:S}=function(){let[e,t]=(0,s.useState)(new Map),[n,r]=(0,s.useState)(new Map),[i,a]=(0,s.useState)([]),[l,o]=(0,s.useState)(!0),[c,d]=(0,s.useState)(null),u=(0,s.useRef)(!1),x=(0,s.useCallback)(async()=>{try{o(!0),d(null);let[e,n]=await Promise.all([es("org.impactindexer.review.comment"),es("org.impactindexer.review.like")]),s=e.filter(e=>{let t=e.value.subject;return(null==t?void 0:t.uri)&&"string"==typeof t.uri&&t.uri.startsWith("beads:")}),i=new Map;for(let e of n){let t=e.value.subject;if((null==t?void 0:t.uri)&&"string"==typeof t.uri&&t.uri.startsWith("at://")){let n=i.get(t.uri)||[];n.push(e),i.set(t.uri,n)}}let l=new Set;for(let e of s)l.add(e.did);for(let e of n)l.add(e.did);let c=await Promise.all([...l].map(e=>er(e))),x=new Map(c.map(e=>[e.did,e])),h=[];for(let e of s){let t=e.value,n=t.subject.uri.replace(/^beads:/,""),r=t.text||"",s=t.createdAt||"",a=t.replyTo||void 0,l=x.get(e.did),o=(i.get(e.uri)||[]).map(e=>{let t=x.get(e.did),n=e.value;return{did:e.did,handle:(null==t?void 0:t.handle)||e.did.slice(0,20)+"...",displayName:null==t?void 0:t.displayName,avatar:null==t?void 0:t.avatar,createdAt:n.createdAt||"",uri:e.uri,rkey:e.rkey}}),c={did:e.did,handle:(null==l?void 0:l.handle)||e.did.slice(0,20)+"...",displayName:null==l?void 0:l.displayName,avatar:null==l?void 0:l.avatar,text:r,createdAt:s,uri:e.uri,rkey:e.rkey,nodeId:n,replyTo:a,likes:o,replies:[]};h.push(c)}let m=new Map;for(let e of h)m.set(e.uri,e);let p=[];for(let e of h){if(e.replyTo){let t=m.get(e.replyTo);if(t){t.replies.push(e);continue}}p.push(e)}p.sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()),function e(t){for(let n of t)n.replies.sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime()),e(n.replies)}(p);let f=new Map;for(let e of p){let t=f.get(e.nodeId)||[];t.push(e),f.set(e.nodeId,t)}let g=new Map;for(let e of h)g.set(e.nodeId,(g.get(e.nodeId)||0)+1);let v=[...h].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());u.current||(t(f),r(g),a(v))}catch(e){if(!u.current){let t=e instanceof Error?e.message:"Failed to fetch comments";console.error("Failed to fetch beads comments:",e),d(t)}}finally{u.current||o(!1)}},[]);return(0,s.useEffect)(()=>(u.current=!1,x(),()=>{u.current=!0}),[x]),{commentsByNode:e,commentedNodeIds:n,allComments:i,isLoading:l,error:c,refetch:x}}(),[L,I]=(0,s.useState)(new Map),[E,P]=(0,s.useState)(new Set),W=(0,s.useMemo)(()=>{let e=new Map;if(M)for(let t of M){if(e.has(t.nodeId)||E.has(t.nodeId))continue;let n=t.text.trim();n.startsWith("@")&&-1===n.indexOf(" ")&&e.set(t.nodeId,{avatar:t.avatar,handle:t.handle,claimedAt:t.createdAt,did:t.did,rkey:t.rkey})}for(let[t,n]of L)e.has(t)||E.has(t)||e.set(t,n);return e},[M,L,E]),[B,Y]=(0,s.useState)(!1),[q,X]=(0,s.useState)([]),[V,K]=(0,s.useState)(!1),[$,J]=(0,s.useState)(!1);(0,s.useEffect)(()=>{if(!i)return;let e=function(e,t,n){let r=[],s=new Set;function i(e){s.has(e.id)||(s.add(e.id),r.push(e))}for(let t of e){if(t.createdAt){let e=new Date(t.createdAt).getTime();isNaN(e)||i({id:"node-created:".concat(t.id,":").concat(e),type:"node-created",time:e,nodeId:t.id,nodeTitle:t.title,detail:t.issueType,meta:{issueType:t.issueType,prefix:t.prefix}})}if(t.closedAt){let e=new Date(t.closedAt).getTime();isNaN(e)||i({id:"node-closed:".concat(t.id,":").concat(e),type:"node-closed",time:e,nodeId:t.id,nodeTitle:t.title,detail:t.closeReason||"Closed",meta:{prefix:t.prefix}})}}for(let e of t)if(e.createdAt){let t=new Date(e.createdAt).getTime();if(!isNaN(t)){let n="object"==typeof e.source?e.source.id:e.source,r="object"==typeof e.target?e.target.id:e.target;i({id:"link-added:".concat(n,"->").concat(r,":").concat(t),type:"link-added",time:t,nodeId:n,detail:"".concat(e.type," ").concat(r),meta:{linkType:e.type,target:r}})}}if(n)for(let e of n){let t=new Date(e.createdAt).getTime();if(isNaN(t))continue;let n={handle:e.handle,avatar:e.avatar,did:e.did};for(let r of(i(e.text.startsWith("@")&&-1===e.text.trim().indexOf(" ")?{id:"task-claimed:".concat(e.nodeId,":").concat(t),type:"task-claimed",time:t,nodeId:e.nodeId,actor:n,detail:e.text}:e.replyTo?{id:"reply-added:".concat(e.nodeId,":").concat(e.rkey),type:"reply-added",time:t,nodeId:e.nodeId,actor:n,detail:e.text.length>80?e.text.slice(0,80)+"...":e.text}:{id:"comment-added:".concat(e.nodeId,":").concat(e.rkey),type:"comment-added",time:t,nodeId:e.nodeId,actor:n,detail:e.text.length>80?e.text.slice(0,80)+"...":e.text}),e.likes)){let t=new Date(r.createdAt).getTime();isNaN(t)||i({id:"like-added:".concat(e.nodeId,":").concat(r.rkey),type:"like-added",time:t,nodeId:e.nodeId,actor:{handle:r.handle,avatar:r.avatar,did:r.did},detail:"Liked comment by ".concat(e.handle)})}}return r.sort((e,t)=>t.time-e.time),r}(i.graphData.nodes,i.graphData.links,M);X(t=>Z(t,e))},[i,M]);let[Q,et]=(0,s.useState)(null),[en,eo]=(0,s.useState)(null),[ec,ed]=(0,s.useState)(null),[eu,ex]=(0,s.useState)(null),[eh,em]=(0,s.useState)(!1),[ep,ef]=(0,s.useState)(""),[eg,ev]=(0,s.useState)(0),[eb,ey]=(0,s.useState)(!1),[ej,ew]=(0,s.useState)(0),[ek,eN]=(0,s.useState)(!1),[ez,eC]=(0,s.useState)(1),[eM,eS]=(0,s.useState)(null),eD=(0,s.useRef)(null),eL=(0,s.useRef)(null),eT=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=null,t=null,n=null,r=!0;return function s(){(e=new EventSource("/api/beads/stream")).onmessage=e=>{if(r)try{let t=JSON.parse(e.data);if(t.error){u(t.error),c(!1);return}let n=eT.current,r=a(n,t);if(!n){eT.current=t,l(t),c(!1);return}if(!r.hasChanges)return;let s=function(e,t){let n=[],r=Date.now(),s=new Map(t.map(e=>[e.id,e]));for(let t of e.addedNodeIds){let e=s.get(t);n.push({id:"node-created:".concat(t,":").concat(r),type:"node-created",time:r,nodeId:t,nodeTitle:null==e?void 0:e.title,detail:(null==e?void 0:e.issueType)||"task",meta:e?{issueType:e.issueType,prefix:e.prefix}:void 0})}for(let t of e.removedNodeIds)n.push({id:"node-closed:".concat(t,":").concat(r),type:"node-closed",time:r,nodeId:t,detail:"Removed"});for(let[t,i]of e.changedNodes){let e=s.get(t);for(let s of i){let i;switch(s.field){case"status":default:i="node-status-changed";break;case"priority":i="node-priority-changed";break;case"title":i="node-title-changed";break;case"owner":i="node-owner-changed"}n.push({id:"".concat(i,":").concat(t,":").concat(r,":").concat(s.field),type:i,time:r,nodeId:t,nodeTitle:null==e?void 0:e.title,detail:"".concat(s.from," → ").concat(s.to),meta:{field:s.field,from:s.from,to:s.to}})}}for(let t of e.addedLinkKeys){let e=t.match(/^(.+)->(.+):(.+)$/);if(e){let[,s,i,a]=e;n.push({id:"link-added:".concat(t,":").concat(r),type:"link-added",time:r,nodeId:s,detail:"".concat(a," ").concat(i),meta:{linkType:a,target:i}})}}for(let t of e.removedLinkKeys){let e=t.match(/^(.+)->(.+):(.+)$/);if(e){let[,s,i,a]=e;n.push({id:"link-removed:".concat(t,":").concat(r),type:"link-removed",time:r,nodeId:s,detail:"".concat(a," ").concat(i),meta:{linkType:a,target:i}})}}return n}(r,t.graphData.nodes);s.length>0&&X(e=>Z(e,s));let i=ea(n,t,r);eT.current=i,l(i)}catch(e){console.error("Failed to parse SSE message:",e)}},e.onerror=()=>{(null==e?void 0:e.readyState)===EventSource.CLOSED&&(t=setTimeout(s,5e3))},n=setTimeout(()=>{r&&!eT.current&&fetch("/api/beads").then(e=>e.json()).then(e=>{r&&!eT.current&&(eT.current=e,l(e),c(!1))}).catch(()=>{})},5e3)}(),()=>{r=!1,null==e||e.close(),t&&clearTimeout(t),n&&clearTimeout(n)}},[]),(0,s.useEffect)(()=>{fetch("/api/config").then(e=>e.json()).then(e=>{e.name&&g(e.name),e.repoCount&&b(e.repoCount),e.repoUrls&&j(e.repoUrls)}).catch(()=>{})},[]),(0,s.useEffect)(()=>{if(!i)return;let e=setTimeout(()=>{let e=Date.now(),t=i.graphData.nodes.filter(t=>!t._removeTime||e-t._removeTime<600),n=i.graphData.links.filter(t=>!t._removeTime||e-t._removeTime<600);(t.length!==i.graphData.nodes.length||n.length!==i.graphData.links.length)&&l(e=>e?{...e,graphData:{nodes:t,links:n}}:e)},700);return()=>clearTimeout(e)},[i]);let eA=(0,s.useMemo)(()=>i?function(e,t){let n=[];for(let t of e){let e=new Date(t.createdAt).getTime();if(isNaN(e)||n.push({time:e,type:"node-created",id:t.id}),t.closedAt){let e=new Date(t.closedAt).getTime();isNaN(e)||n.push({time:e,type:"node-closed",id:t.id})}}n.sort((e,t)=>e.time-t.time);let r=n.length>0?n[0].time:Date.now(),s=n.length>0?n[n.length-1].time:Date.now();return{events:n,minTime:r,maxTime:s}}(i.graphData.nodes,i.graphData.links):null,[i]),eI=(0,s.useCallback)(()=>{ey(e=>{let t=!e;return t&&ew(-1),eN(!1),eS(null),t})},[]);(0,s.useEffect)(()=>{if(!ek||!eb||!eA)return;let e=setInterval(()=>{ew(e=>{let t=e+1;return t>=eA.events.length?(eN(!1),e):t})},2e3/ez);return()=>clearInterval(e)},[ek,eb,ez,eA]),(0,s.useEffect)(()=>{if(!eb||!i||!eA)return;if(-1===ej){eS(e=>{let t={...i,graphData:{nodes:[],links:[]}};if(!e)return t;let n=a(e,t);return n.hasChanges?ea(e,t,n):e});return}if(0===eA.events.length)return;let e=eA.events[ej];if(!e)return;let t=function(e,t,n){let r=new Set,s=[];for(let t of e){let e=new Date(t.createdAt).getTime();if(isNaN(e)||e>n)continue;r.add(t.id);let i=t.status;if(t.closedAt){let e=new Date(t.closedAt).getTime();!isNaN(e)&&e<=n?i="closed":"closed"===t.status&&(i="open")}i!==t.status?s.push({...t,status:i}):s.push(t)}let i=[];for(let e of t){let t="object"==typeof e.source?e.source.id:e.source,n="object"==typeof e.target?e.target.id:e.target;r.has(t)&&r.has(n)&&i.push({...e,source:t,target:n})}return{nodes:s,links:i}}(i.graphData.nodes,i.graphData.links,e.time),n={...i,graphData:{nodes:t.nodes,links:t.links}};eS(e=>{if(!e)return n;let t=a(e,n);return t.hasChanges?ea(e,n,t):e})},[eb,i,eA,ej]);let eE=(0,s.useCallback)(e=>{h(t=>(null==t?void 0:t.id)===e.id?null:e),Y(!1),K(!1)},[]),eP=(0,s.useCallback)(e=>{p(e)},[]),eW=(0,s.useCallback)(()=>{h(null),et(null),eo(null)},[]),eB=(0,s.useCallback)((e,t)=>{eo(null),e.description||w?et({node:e,x:t.clientX,y:t.clientY}):eo({node:e,x:t.clientX,y:t.clientY})},[w]),eR=(0,s.useCallback)(async(e,t)=>{let n=await fetch("/api/records",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({collection:"org.impactindexer.review.comment",record:{$type:"org.impactindexer.review.comment",subject:{uri:"beads:".concat(e),type:"record"},text:t,createdAt:new Date().toISOString()}})});if(!n.ok)throw Error((await n.json()).error||"Failed to post comment");await S()},[S]),eF=(0,s.useCallback)(async e=>{if(!(null==k?void 0:k.handle))return;let t=k.avatar;if(!t&&k.did)try{let e=await fetch("https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=".concat(encodeURIComponent(k.did)));e.ok&&(t=(await e.json()).avatar)}catch(e){}I(n=>{let r=new Map(n);return r.set(e,{avatar:t,claimedAt:new Date().toISOString(),handle:k.handle}),r}),await eR(e,"@".concat(k.handle)),setTimeout(()=>S(),3e3)},[null==k?void 0:k.handle,null==k?void 0:k.did,null==k?void 0:k.avatar,eR,S]),e_=(0,s.useCallback)(async e=>{let t=await fetch("/api/records?collection=".concat(encodeURIComponent("org.impactindexer.review.comment"),"&rkey=").concat(encodeURIComponent(e.rkey)),{method:"DELETE"});if(!t.ok)throw Error((await t.json()).error||"Failed to delete comment");await S()},[S]),eO=(0,s.useCallback)(async e=>{let t=W.get(e);t&&(P(t=>new Set(t).add(e)),I(t=>{let n=new Map(t);return n.delete(e),n}),t.rkey?(await e_({rkey:t.rkey}),P(t=>{let n=new Set(t);return n.delete(e),n})):setTimeout(async()=>{await S(),P(t=>{let n=new Set(t);return n.delete(e),n})},3e3))},[W,e_,S]),eU=(0,s.useCallback)(async e=>{let t=e.likes.find(e=>e.did===(null==k?void 0:k.did));if(t){let e=await fetch("/api/records?collection=".concat(encodeURIComponent("org.impactindexer.review.like"),"&rkey=").concat(encodeURIComponent(t.rkey)),{method:"DELETE"});if(!e.ok)throw Error((await e.json()).error||"Failed to unlike")}else{let t=await fetch("/api/records",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({collection:"org.impactindexer.review.like",record:{subject:{uri:e.uri,type:"record"},createdAt:new Date().toISOString()}})});if(!t.ok)throw Error((await t.json()).error||"Failed to like")}await S()},[null==k?void 0:k.did,S]),eH=(0,s.useCallback)(async(e,t)=>{let n=await fetch("/api/records",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({collection:"org.impactindexer.review.comment",record:{subject:{uri:"beads:".concat(e.nodeId),type:"record"},text:t,replyTo:e.uri,createdAt:new Date().toISOString()}})});if(!n.ok)throw Error((await n.json()).error||"Failed to post reply");await S()},[S]),eY=(0,s.useCallback)(e=>{if(!i)return;let t=i.graphData.nodes.find(t=>t.id===e);t&&h(t)},[i]),eq=(0,s.useMemo)(()=>{if(!i||!ep.trim())return[];let e=ep.toLowerCase();return i.graphData.nodes.filter(t=>"".concat(t.id," ").concat(t.title," ").concat(t.prefix).toLowerCase().includes(e)).slice(0,8)},[ep,i]);(0,s.useEffect)(()=>{ev(0)},[ep]);let eX=(0,s.useCallback)(e=>{var t;null===(t=eD.current)||void 0===t||t.focusNode(e),em(!1),ef(""),ev(0)},[]);(0,s.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&"f"===e.key&&(e.preventDefault(),em(!0),setTimeout(()=>{var e;return null===(e=eL.current)||void 0===e?void 0:e.focus()},50)),"Escape"===e.key&&eh&&(em(!1),ef(""),ev(0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eh]);let eV=(0,s.useCallback)(e=>{"ArrowDown"===e.key?(e.preventDefault(),ev(e=>Math.min(e+1,eq.length-1))):"ArrowUp"===e.key?(e.preventDefault(),ev(e=>Math.max(e-1,0))):"Enter"===e.key&&eq.length>0&&(e.preventDefault(),eX(eq[eg]))},[eq,eg,eX]);return o?(0,r.jsxs)("div",{className:"h-screen flex flex-col items-center justify-center bg-white",children:[(0,r.jsxs)("div",{className:"relative mb-6",children:[(0,r.jsx)("div",{className:"w-12 h-12 border-2 border-zinc-200 border-t-emerald-500 rounded-full animate-spin"}),(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,r.jsx)("div",{className:"w-2 h-2 rounded-full bg-emerald-500"})})]}),(0,r.jsx)("p",{className:"text-sm text-zinc-500 animate-pulse-soft",children:"Loading beads graph..."}),(0,r.jsx)("p",{className:"text-xs text-zinc-400 mt-1",children:"Parsing issues and dependencies"})]}):d?(0,r.jsx)("div",{className:"h-screen flex items-center justify-center bg-white",children:(0,r.jsxs)("div",{className:"max-w-sm text-center",children:[(0,r.jsx)("div",{className:"w-14 h-14 mx-auto mb-4 bg-red-50 rounded-full flex items-center justify-center",children:(0,r.jsx)("svg",{className:"w-7 h-7 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),(0,r.jsx)("h2",{className:"text-lg font-semibold text-zinc-900 mb-1",children:"Unable to load data"}),(0,r.jsx)("p",{className:"text-sm text-zinc-500 mb-4",children:d}),(0,r.jsxs)("button",{onClick:()=>window.location.reload(),className:"inline-flex items-center gap-2 px-4 py-2 bg-emerald-600 text-white text-sm rounded-lg hover:bg-emerald-700 transition-colors",children:[(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Try Again"]})]})}):i?(0,r.jsxs)("div",{className:"h-screen flex flex-col overflow-hidden bg-white",children:[(0,r.jsx)("header",{className:"sticky top-0 z-50 shrink-0 bg-white/95 backdrop-blur-sm border-b border-zinc-200/80",children:(0,r.jsxs)("div",{className:"px-6 h-14 flex items-center",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 shrink-0 group",children:[(0,r.jsx)(_,{className:"w-8 h-8 text-emerald-500 transition-transform group-hover:scale-105"}),(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsx)("h1",{className:"text-[15px] font-semibold text-zinc-900 tracking-tight",children:f}),(0,r.jsx)("span",{className:"font-normal text-zinc-400 text-[15px] hidden sm:inline",children:"heartbeads"}),v>1&&(0,r.jsxs)("span",{className:"text-[10px] text-zinc-400 bg-zinc-100 rounded-full px-1.5 py-0.5 font-medium hidden sm:inline",children:[v," repos"]})]})]}),(0,r.jsx)("div",{className:"flex-1 flex justify-center px-4",children:(0,r.jsx)("div",{className:"relative w-full max-w-md",children:eh?(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center bg-white rounded-full border border-zinc-200 shadow-sm overflow-hidden",children:[(0,r.jsx)("div",{className:"pl-3 pr-1 text-zinc-400",children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),(0,r.jsx)("input",{ref:eL,type:"text",value:ep,onChange:e=>ef(e.target.value),onKeyDown:eV,placeholder:"Search issues...",className:"flex-1 px-2 py-1.5 text-xs text-zinc-800 bg-transparent outline-none placeholder:text-zinc-400",autoFocus:!0}),(0,r.jsx)("button",{onClick:()=>{em(!1),ef(""),ev(0)},className:"px-2 py-1.5 text-zinc-400 hover:text-zinc-600",children:(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),ep.trim()&&(0,r.jsxs)("div",{className:"absolute top-full left-0 right-0 mt-2 bg-white rounded-xl border border-zinc-100 shadow-xl overflow-hidden max-h-72 overflow-y-auto z-50",children:[0===eq.length?(0,r.jsx)("div",{className:"px-3 py-3 text-xs text-zinc-400 text-center",children:"No matching issues"}):eq.map((e,t)=>(0,r.jsxs)("button",{onClick:()=>eX(e),onMouseEnter:()=>ev(t),className:"w-full text-left px-3 py-2 text-xs transition-colors flex items-start gap-2.5 ".concat(t===eg?"bg-emerald-50":"hover:bg-zinc-50"),children:[(0,r.jsx)("div",{className:"shrink-0 mt-1",children:(0,r.jsx)("div",{className:"w-2 h-2 rounded-full ".concat(el[e.status]||"bg-zinc-400")})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"font-medium text-zinc-600 shrink-0",children:e.id}),e.priority<=1&&(0,r.jsx)("span",{className:"text-[10px]",children:0===e.priority?"\uD83D\uDD25\uD83D\uDD25":"\uD83D\uDD25"})]}),(0,r.jsx)("div",{className:"text-zinc-400 truncate mt-0.5",children:e.title})]}),(0,r.jsx)("span",{className:"shrink-0 text-[10px] text-zinc-400 bg-zinc-100 rounded px-1 py-0.5 mt-0.5",children:e.prefix})]},e.id)),eq.length>0&&(0,r.jsxs)("div",{className:"px-3 py-1.5 text-[10px] text-zinc-400 border-t border-zinc-100 bg-zinc-50/50 flex items-center justify-between",children:[(0,r.jsxs)("span",{children:[eq.length," result",1!==eq.length?"s":""]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{className:"px-1 py-0.5 bg-white rounded border border-zinc-200 text-[9px] font-mono",children:"Enter"})," ","to focus"]})]})]})]}):(0,r.jsxs)("button",{onClick:()=>{em(!0),setTimeout(()=>{var e;return null===(e=eL.current)||void 0===e?void 0:e.focus()},50)},className:"w-full flex items-center gap-2 px-3.5 py-1.5 text-sm text-zinc-400 rounded-full bg-zinc-50/80 border border-zinc-200/60 hover:text-zinc-500 hover:border-zinc-300 hover:bg-zinc-100/50 transition-all",title:"Search issues (Ctrl+F)",children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5 shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,r.jsx)("span",{className:"flex-1 text-left",children:"Search issues..."}),(0,r.jsxs)("kbd",{className:"hidden sm:inline-block px-1 py-0.5 bg-zinc-100 rounded border border-zinc-200 text-[9px] font-mono text-zinc-400",children:["undefined"!=typeof navigator&&(null===(e=navigator.platform)||void 0===e?void 0:e.includes("Mac"))?"⌘":"Ctrl","F"]})]})})}),(0,r.jsxs)("div",{className:"hidden md:flex items-center gap-1 shrink-0",children:[(0,r.jsxs)("button",{onClick:eI,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-full transition-colors ".concat(eb?"text-emerald-700 bg-emerald-50":"text-zinc-500 hover:text-zinc-900 hover:bg-zinc-50"),children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("polyline",{points:"8,4 8,8 11,10"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Replay"})]}),(0,r.jsxs)("button",{onClick:()=>{Y(e=>!e),B||(h(null),K(!1))},className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-full transition-colors ".concat(B?"text-emerald-700 bg-emerald-50":"text-zinc-500 hover:text-zinc-900 hover:bg-zinc-50"),children:[(0,r.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12.76c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.076-4.076a1.526 1.526 0 011.037-.443 48.282 48.282 0 005.68-.494c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z"})}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Comments"})]}),(0,r.jsxs)("button",{onClick:()=>{K(e=>!e),V||(h(null),Y(!1))},className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-full transition-colors ".concat(V?"text-emerald-700 bg-emerald-50":"text-zinc-500 hover:text-zinc-900 hover:bg-zinc-50"),children:[(0,r.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,r.jsx)("polyline",{points:"8,4 8,8 11,10"})]}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Activity"})]}),(0,r.jsx)("div",{className:"w-px h-5 bg-zinc-200 mx-2"}),(0,r.jsx)(F,{})]})]})}),(0,r.jsxs)("div",{className:"flex-1 flex overflow-hidden relative",children:[(0,r.jsxs)("div",{className:"flex-1 relative bg-zinc-50/50",children:[(0,r.jsx)("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle, #000 1px, transparent 1px)",backgroundSize:"24px 24px"}}),(0,r.jsx)(N,{ref:eD,nodes:eb&&eM?eM.graphData.nodes:i.graphData.nodes,links:eb&&eM?eM.graphData.links:i.graphData.links,selectedNode:x,hoveredNode:m,onNodeClick:eE,onNodeHover:eP,onBackgroundClick:eW,onNodeRightClick:eB,commentedNodeIds:C,claimedNodeAvatars:W,onAvatarHover:ex,timelineActive:eb,stats:i.stats,sidebarOpen:!!x||B||V}),eb&&eA&&eA.events.length>0&&(0,r.jsx)("div",{className:"absolute bottom-4 z-10 transition-[right] duration-300 ease-out",style:{right:x||B||V?"calc(360px + 1rem)":"1rem"},children:(0,r.jsx)(ei,{totalSteps:eA.events.length,currentStep:Math.max(ej,0),currentTime:ej>=0&&null!==(n=null===(t=eA.events[ej])||void 0===t?void 0:t.time)&&void 0!==n?n:eA.minTime,isPlaying:ek,speed:ez,onStepChange:ew,onPlayPause:()=>eN(e=>!e),onSpeedChange:eC})}),!x&&!B&&!V&&!eb&&(0,r.jsx)("div",{className:"absolute top-3 right-3 sm:top-4 sm:right-4 z-10",children:(0,r.jsx)(G,{events:q,collapsed:$,onToggleCollapse:()=>J(e=>!e),onExpandPanel:()=>{K(!0),h(null),Y(!1)},onNodeClick:e=>{let t=null==i?void 0:i.graphData.nodes.find(t=>t.id===e);t&&eX(t)}})}),Q&&(0,r.jsx)(U,{node:Q.node,x:Q.x,y:Q.y,onShowDescription:()=>{ed(Q.node),et(null)},onAddComment:()=>{eo({node:Q.node,x:Q.x,y:Q.y}),et(null)},onClaimTask:w&&!W.has(Q.node.id)?()=>{eF(Q.node.id),et(null)}:void 0,onUnclaimTask:(()=>{if(!w)return;let e=W.get(Q.node.id);if(e&&(e.did===(null==k?void 0:k.did)||!e.did))return()=>{eO(Q.node.id),et(null)}})(),onClose:()=>et(null)}),en&&(0,r.jsx)(O,{node:en.node,x:en.x,y:en.y,onClose:()=>eo(null),onSubmit:async e=>{await eR(en.node.id,e),eo(null)},isAuthenticated:w,existingComments:z.get(en.node.id)}),ec&&(0,r.jsx)(D,{node:ec,onClose:()=>ed(null)}),eu&&(0,r.jsx)("div",{style:{position:"fixed",left:eu.x+12,top:eu.y-8,zIndex:90,pointerEvents:"none"},children:(0,r.jsxs)("div",{className:"flex items-center gap-2 bg-white border border-zinc-200 rounded-lg shadow-lg px-2.5 py-2",children:[eu.avatar?(0,r.jsx)("img",{src:eu.avatar,alt:"",className:"w-6 h-6 rounded-full shrink-0"}):(0,r.jsx)("div",{className:"w-6 h-6 rounded-full bg-zinc-200 flex items-center justify-center text-[10px] font-medium text-zinc-500 shrink-0",children:eu.handle.charAt(0).toUpperCase()}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsxs)("span",{className:"text-xs text-zinc-700 whitespace-nowrap",children:[eu.did?(0,r.jsx)("a",{href:"https://www.impactindexer.org/data?did=".concat(eu.did),target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-zinc-800 hover:text-emerald-600 transition-colors",style:{pointerEvents:"auto"},children:eu.handle}):(0,r.jsx)("span",{className:"font-semibold text-zinc-800",children:eu.handle})," claimed this task"]}),(0,r.jsx)("span",{className:"text-[10px] text-zinc-400",children:T(eu.claimedAt)})]})]})})]}),(0,r.jsxs)("aside",{className:"hidden md:flex absolute top-0 right-0 h-full w-[360px] bg-white border-l border-zinc-200 flex-col shadow-xl z-30 transform transition-transform duration-300 ease-out ".concat(x?"translate-x-0":"translate-x-full"),children:[(0,r.jsxs)("div",{className:"shrink-0 px-5 py-3 border-b border-zinc-100 flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-xs font-semibold text-zinc-400 uppercase tracking-wider",children:"Node Detail"}),(0,r.jsx)("button",{onClick:()=>{h(null)},className:"p-1 text-zinc-400 hover:text-zinc-600 transition-colors rounded-full hover:bg-zinc-100",children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar px-5 py-4 space-y-5",children:(0,r.jsx)(A,{node:x,allNodes:i.graphData.nodes,onNodeNavigate:eY,comments:x?z.get(x.id):void 0,onPostComment:x?e=>eR(x.id,e):void 0,onDeleteComment:e_,onLikeComment:eU,onReplyComment:eH,isAuthenticated:w,currentDid:null==k?void 0:k.did,repoUrls:y})})]}),(0,r.jsx)("div",{className:"md:hidden fixed inset-x-0 bottom-0 z-20 transform transition-transform duration-300 ease-out ".concat(x?"translate-y-0":"translate-y-full"),children:(0,r.jsxs)("div",{className:"bg-white rounded-t-2xl border-t border-zinc-200 shadow-lg max-h-[60vh] flex flex-col",children:[(0,r.jsxs)("div",{className:"shrink-0 flex items-center justify-between px-4 pt-3 pb-2",children:[(0,r.jsx)("div",{className:"w-8 h-1 bg-zinc-300 rounded-full mx-auto"}),(0,r.jsx)("button",{onClick:()=>h(null),className:"absolute right-3 top-3 p-1 text-zinc-400 hover:text-zinc-600",children:(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto custom-scrollbar px-4 pb-6 space-y-4",children:(0,r.jsx)(A,{node:x,allNodes:i.graphData.nodes,onNodeNavigate:eY,comments:x?z.get(x.id):void 0,onPostComment:x?e=>eR(x.id,e):void 0,onDeleteComment:e_,onLikeComment:eU,onReplyComment:eH,isAuthenticated:w,currentDid:null==k?void 0:k.did,repoUrls:y})})]})}),(0,r.jsx)(H,{isOpen:B,onClose:()=>Y(!1),allComments:M,onNodeNavigate:e=>{eY(e),Y(!1)},isAuthenticated:w,currentDid:null==k?void 0:k.did,onLikeComment:eU,onDeleteComment:e_}),(0,r.jsx)(ee,{events:q,isOpen:V,onClose:()=>K(!1),onNodeClick:e=>{let t=null==i?void 0:i.graphData.nodes.find(t=>t.id===e);t&&(eX(t),K(!1))}})]})]}):null}},7796:function(e,t,n){"use strict";n.d(t,{AuthProvider:function(){return a},a:function(){return l}});var r=n(3890),s=n(8496);let i=(0,s.createContext)(null);function a(e){let{children:t}=e,[n,a]=(0,s.useState)({status:"idle",session:null,error:null,isLoading:!0});(0,s.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch("/api/status");if(t.ok){let n=await t.json();if(n.did&&!e){a({status:"authenticated",session:{did:n.did,handle:n.handle||n.did,displayName:n.displayName,avatar:n.avatar},error:null,isLoading:!1});return}}}catch(e){console.error("Failed to check auth status:",e)}e||a(e=>({...e,isLoading:!1}))})(),()=>{e=!0}},[]);let l=(0,s.useCallback)(async e=>{a(e=>({...e,status:"authorizing",isLoading:!0,error:null}));try{let t=e.includes(".")?e:"".concat(e,".bsky.social"),n=await fetch("/api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({handle:t,returnTo:window.location.pathname+window.location.search})});if(!n.ok){let e=await n.json();throw Error(e.error||"Login failed")}let r=await n.json();window.location.href=r.redirectUrl}catch(t){let e=t instanceof Error?t:Error("Login failed");throw a({status:"error",session:null,error:e,isLoading:!1}),e}},[]),o=(0,s.useCallback)(async()=>{try{await fetch("/api/logout",{method:"POST"})}catch(e){console.error("Logout request failed:",e)}a({status:"idle",session:null,error:null,isLoading:!1})},[]);return(0,r.jsx)(i.Provider,{value:{state:n,login:l,logout:o},children:t})}function l(){let e=(0,s.useContext)(i);if(!e)throw Error("useAuth must be used within an AuthProvider");let{state:t,login:n,logout:r}=e;return{status:t.status,session:t.session,error:t.error,isLoading:t.isLoading,isAuthenticated:"authenticated"===t.status,login:n,logout:r}}}},function(e){e.O(0,[666,649,945,744],function(){return e(e.s=6284)}),_N_E=e.O()}]);