meshy-node 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dashboard/assets/{DashboardPage-DNbe_gkN.js → DashboardPage-D5cStRjL.js} +3 -3
- package/dashboard/assets/{DashboardShared-BguS5rZM.js → DashboardShared-Cl2J-iJd.js} +1 -1
- package/dashboard/assets/{DiffTab-BQegvnuJ.js → DiffTab-Bf9BAMpM.js} +1 -1
- package/dashboard/assets/{FilesTab-BoVqZxQh.js → FilesTab-CH1lwzT9.js} +1 -1
- package/dashboard/assets/{MarkdownPreviewFrame-Ch2MvGCr.js → MarkdownPreviewFrame-DEZT2HNE.js} +1 -1
- package/dashboard/assets/{PreviewTab-C06qRxmn.js → PreviewTab-T_Y0AhqI.js} +1 -1
- package/dashboard/assets/{SharedConversationPage-CzAKjW4S.js → SharedConversationPage-C2p4_D8K.js} +2 -2
- package/dashboard/assets/{file-tSdrAmCr.js → file-By_WHjZd.js} +1 -1
- package/dashboard/assets/index-B75j0Sjk.js +351 -0
- package/dashboard/assets/index-BRrkswqR.css +1 -0
- package/dashboard/index.html +2 -2
- package/main.cjs +1652 -1044
- package/package.json +1 -1
- package/runtime-metadata.json +4 -4
- package/dashboard/assets/index-DPc1_Q2V.css +0 -1
- package/dashboard/assets/index-DQFY3oGe.js +0 -346
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-
|
|
2
|
-
import{c as fe,r as o,a as Wn,f as No,m as ko,j as e,X as ut,Q as Xs,B as X,L as he,S as ts,u as So,P as mn,b as Et,d as Co,e as Gl,g as Wl,h as To,i as Ao,k as Ql,l as Yl,n as L,o as Jl,p as Zl,q as Xl,s as ec,I as dt,t as tc,C as En,v as nc,w as Eo,F as hn,x as nt,y as Oe,D as Mn,z as sc,A as rc,E as ce,G as $e,H as qe,J as Je,K as Ve,M as Mo,N as st,T as ac,O as oc,R as Un,U as ic,V as mt,W as ht,Y as vt,Z as Do,_ as _o,$ as In,a0 as lc,a1 as Dn,a2 as cc,a3 as er,a4 as dc,a5 as Po,a6 as Io,a7 as uc,a8 as Le,a9 as mc,aa as hc,ab as $t,ac as qt,ad as Vt,ae as Ht,af as Kt,ag as Gt,ah as Wt,ai as Qt,aj as gr,ak as fc,al as Mt,am as br,an as pc,ao as Gr,ap as tr,aq as gs,ar as Wr,as as xc,at as gc,au as bc,av as vc,aw as wc,ax as yc,ay as Ro,az as Dt,aA as Lo,aB as jc,aC as Nc,aD as jt,aE as Qr,aF as kc,aG as Nn,aH as Sc,aI as vr,aJ as wr,aK as Cc,aL as Tc,aM as ns,aN as Ac,aO as Rn,aP as Ec,aQ as yr,aR as Mc,aS as Dc,aT as jr,aU as _c,aV as Qn,aW as Pc,aX as Yr,aY as Nr,aZ as kr,a_ as Ic,a$ as Rc,b0 as Lc,b1 as Bc,b2 as Bo,b3 as _n,b4 as Oc,b5 as nr,b6 as Fc,b7 as zc,b8 as Uc,b9 as $c,ba as Jr,bb as qc,bc as Vc,bd as bs,be as Hc,bf as Zr,bg as Kc,bh as Gc,bi as Wc,bj as Xr,bk as Qc,bl as Yc,bm as sr,bn as Jc,bo as Zc,bp as Oo,bq as ea,br as Fo,bs as Xc,bt as ta,bu as ed,bv as td,bw as nd,bx as sd,by as rd,bz as ad,bA as na,bB as od,bC as id,bD as ld,bE as cd,bF as dd,bG as ud,bH as md,bI as hd,bJ as fd,bK as pd,bL as xd,bM as gd,bN as bd,bO as vd,bP as wd,bQ as yd,bR as jd,bS as Nd,bT as kd,bU as Sd,bV as Cd,bW as Td,bX as Ad,bY as Ed,bZ as Md,b_ as Dd,b$ as _d}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-CH1lwzT9.js","assets/index-B75j0Sjk.js","assets/index-BRrkswqR.css","assets/MarkdownPreviewFrame-DEZT2HNE.js","assets/DashboardShared-Cl2J-iJd.js","assets/file-By_WHjZd.js","assets/PreviewTab-T_Y0AhqI.js","assets/DiffTab-Bf9BAMpM.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as fe,r as o,a as Wn,f as No,m as ko,j as e,X as ut,Q as Xs,B as X,L as he,S as ts,u as So,P as mn,b as Et,d as Co,e as Gl,g as Wl,h as To,i as Ao,k as Ql,l as Yl,n as L,o as Jl,p as Zl,q as Xl,s as ec,I as dt,t as tc,C as En,v as nc,w as Eo,F as hn,x as nt,y as Oe,D as Mn,z as sc,A as rc,E as ce,G as $e,H as qe,J as Je,K as Ve,M as Mo,N as st,T as ac,O as oc,R as Un,U as ic,V as mt,W as ht,Y as vt,Z as Do,_ as _o,$ as In,a0 as lc,a1 as Dn,a2 as cc,a3 as er,a4 as dc,a5 as Po,a6 as Io,a7 as uc,a8 as Le,a9 as mc,aa as hc,ab as $t,ac as qt,ad as Vt,ae as Ht,af as Kt,ag as Gt,ah as Wt,ai as Qt,aj as gr,ak as fc,al as Mt,am as br,an as pc,ao as Gr,ap as tr,aq as gs,ar as Wr,as as xc,at as gc,au as bc,av as vc,aw as wc,ax as yc,ay as Ro,az as Dt,aA as Lo,aB as jc,aC as Nc,aD as jt,aE as Qr,aF as kc,aG as Nn,aH as Sc,aI as vr,aJ as wr,aK as Cc,aL as Tc,aM as ns,aN as Ac,aO as Rn,aP as Ec,aQ as yr,aR as Mc,aS as Dc,aT as jr,aU as _c,aV as Qn,aW as Pc,aX as Yr,aY as Nr,aZ as kr,a_ as Ic,a$ as Rc,b0 as Lc,b1 as Bc,b2 as Bo,b3 as _n,b4 as Oc,b5 as nr,b6 as Fc,b7 as zc,b8 as Uc,b9 as $c,ba as Jr,bb as qc,bc as Vc,bd as bs,be as Hc,bf as Zr,bg as Kc,bh as Gc,bi as Wc,bj as Xr,bk as Qc,bl as Yc,bm as sr,bn as Jc,bo as Zc,bp as Oo,bq as ea,br as Fo,bs as Xc,bt as ta,bu as ed,bv as td,bw as nd,bx as sd,by as rd,bz as ad,bA as na,bB as od,bC as id,bD as ld,bE as cd,bF as dd,bG as ud,bH as md,bI as hd,bJ as fd,bK as pd,bL as xd,bM as gd,bN as bd,bO as vd,bP as wd,bQ as yd,bR as jd,bS as Nd,bT as kd,bU as Sd,bV as Cd,bW as Td,bX as Ad,bY as Ed,bZ as Md,b_ as Dd,b$ as _d}from"./index-B75j0Sjk.js";import{r as sa,e as Pd,b as zo,g as Uo,a as kt,A as At,I as Sr,c as $o,T as qo,d as Id,i as Vo,f as Rd,p as Ho,h as Ld,j as ra,k as aa,l as Bd,m as Od,n as Fd,C as oa,o as vs,q as Cr,D as on,s as ct,M as rr,L as zd,t as Ud,u as $d,v as Ko,w as ar,x as qd,y as ws,z as Vd,B as Hd,E as Kd}from"./DashboardShared-Cl2J-iJd.js";import{E as Gd,M as Wd}from"./MarkdownPreviewFrame-DEZT2HNE.js";import{P as ss,D as $n,g as Qd,a as Yd,b as Jd}from"./PreviewTab-T_Y0AhqI.js";/**
|
|
3
3
|
* @license lucide-react v1.7.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -186,7 +186,7 @@ import{c as fe,r as o,a as Wn,f as No,m as ko,j as e,X as ut,Q as Xs,B as X,L as
|
|
|
186
186
|
* See the LICENSE file in the root directory of this source tree.
|
|
187
187
|
*/const Gu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Wu=fe("zoom-out",Gu),Qu=new Set(["assigned","running"]);function Yu(t,n){return t.reduce((s,r)=>r.assignedTo===n&&Qu.has(r.status)?s+1:s,0)}function fn(t){return t?.toLowerCase()==="devtunnel"}function Ju(t){return t?fn(t)?"DevTunnel":t.charAt(0).toUpperCase()+t.slice(1):"Direct"}function Er(t,n){return fn(n??t.transportType)||!!t.devtunnelEndpoint}function ri(t,n){return!fn(n??t.transportType)}function ai(t,n){const s=n??t.transportType;return fn(s)?"DevTunnel":t.devtunnelEndpoint?"Direct + DevTunnel":Ju(s)}function ca(t,n){return!t&&!n}function Zu({routeTaskId:t,creatingTask:n,internalSelectedTaskId:s,sortedTaskIds:r}){return t||(n?null:r[0]??s??null)}function Xu({activeTaskId:t,routeTaskId:n,creatingTask:s,tasksLoading:r,loadedTaskIds:a}){return!t||n||s||r?!1:!a.includes(t)}function em(t,n){return[n,...t.filter(s=>s.id!==n.id)]}function Mr(t,n){const s=t.findIndex(r=>r.id===n.id);return s===-1?[...t,n]:t.map((r,a)=>a===s?n:r)}const tm=new Set(["completed","failed","cancelled","archived"]);function nm(t,n){const s=new Set(n);return new Set(Array.from(t).filter(r=>s.has(r)))}function sm(t,n){const s=new Set(n);if(s.size===0)return!1;const r=t.filter(a=>s.has(a.id));return r.length===s.size&&r.every(a=>tm.has(a.status))}function rm(t,n){const s=new Set(n);return t.find(r=>!s.has(r.id))?.id??null}function oi(){const[t,n]=o.useState([]),[s,r]=o.useState(null),a=o.useRef(null),i=o.useCallback(()=>{a.current?.click()},[]),l=o.useCallback(async p=>{const u=Array.from(p.target.files??[]);if(u.length!==0)try{const h=await sa(u);n(f=>[...f,...h]),r(null)}catch(h){r(h instanceof Error?h.message:"Failed to attach image")}finally{p.target.value=""}},[]),c=o.useCallback(async p=>{const u=Pd(p.clipboardData);if(u.length!==0){p.preventDefault();try{const h=await sa(u);n(f=>[...f,...h]),r(null)}catch(h){r(h instanceof Error?h.message:"Failed to attach image")}}},[]),d=o.useCallback(p=>{n(u=>u.filter((h,f)=>f!==p))},[]),m=o.useCallback(()=>{n([]),r(null)},[]);return{images:t,error:s,fileInputRef:a,pickImages:i,handleFileChange:l,handlePaste:c,removeImage:d,clearImages:m}}function am({disabled:t=!1,running:n=!1,canStop:s=!1,hasContent:r=!1}){return n&&(!r||s&&t)?{primaryAction:"stop",primaryDisabled:!s}:{primaryAction:"send",primaryDisabled:t||!r}}function om({contentLength:t,disabled:n=!1}){return t>0&&!n}const im=/^[a-zA-Z0-9_-]+$/,ii=/[a-zA-Z0-9_-]/,lm=176;function cm(t){const n=t.map(a=>({...a,displayValue:dm(a)})),s=n.findIndex(a=>a.label.toLowerCase()==="working dir"),r=s>=0?s:0;return{primary:n[r],secondary:n.filter((a,i)=>i!==r)}}function dm(t){return t.label.toLowerCase()==="agent"?kt(t.value):t.value}function da(t){switch(t.toLowerCase()){case"branch":return Yn;case"node":return ts;default:return rs}}function um(t){return Array.from(new Set(t.map(n=>n.trim()).filter(Boolean)))}function li(t,n){return Number.isFinite(n)?Math.max(0,Math.min(t.length,Math.trunc(n))):t.length}function mm(t,n){const s=li(t,n),a=t.slice(0,s).match(/@([a-zA-Z0-9_-]*)$/);if(!a||a.index===void 0)return;const i=a.index+1,l=t.slice(s).match(/^[a-zA-Z0-9_-]*/),c=s+(l?.[0].length??0),d=t.slice(i,c);if(!(d.length>0&&!im.test(d)))return{query:d.toLowerCase(),range:{start:a.index,end:c}}}function hm(t,n){const s=new Map(n.map(i=>[i.toLowerCase(),i])),r=/@([a-zA-Z0-9_-]+)/g;let a;for(;(a=r.exec(t))!==null;){const i=(a[1]??"").toLowerCase(),l=s.get(i);if(!l)continue;const c=a.index+a[0].length;if(!(c<t.length&&ii.test(t[c]??"")))return{targetAgent:l,query:i,range:{start:a.index,end:c}}}}function ir(t,n){const s=t.slice(0,n.start);let r=t.slice(n.end);return s.length===0?r.trimStart():r.length===0?s.trimEnd():(/\s$/.test(s)&&/^\s/.test(r)?r=r.trimStart():!/\s$/.test(s)&&!/^\s/.test(r)&&(r=" "+r),s+r)}function ua(t,n,s){const r=um(n),a=typeof s=="number",i=mm(t,a?s:t.length);if(i){const c=r.filter(p=>p.toLowerCase().startsWith(i.query)),d=r.find(p=>p.toLowerCase()===i.query),m=!!d&&(i.range.end===t.length||!ii.test(t[i.range.end]??""));return{...m?{targetAgent:d}:{},query:i.query,strippedText:m?ir(t,i.range):t,matches:c,...a?{mentionRange:i.range}:{}}}const l=hm(t,r);return l?{targetAgent:l.targetAgent,query:l.query,strippedText:ir(t,l.range),matches:[l.targetAgent],...a?{mentionRange:l.range}:{}}:{strippedText:t,matches:[]}}function fm(t,n,s){if(t.length===0)return 0;const r=n?t.indexOf(n):-1;if(r>=0)return r;const a=s?t.indexOf(s):-1;return a>=0?a:0}function pm(t,n){return t.query!==void 0&&t.matches.length>0&&!t.targetAgent&&!n}function xm(t,n){if(!n)return{value:t.replace(/^@[a-zA-Z0-9_-]*\s*/,""),cursorPosition:0};const s=ir(t,n);return{value:s,cursorPosition:Math.min(n.start,s.length)}}function gm(t,n){const s=window.getComputedStyle(t);["boxSizing","width","fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","lineHeight","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth"].forEach(a=>{n.style[a]=s[a]})}function bm(t,n){if(typeof window>"u")return;const s=t.ownerDocument,r=s.createElement("div"),a=s.createElement("span"),i=li(t.value,n);gm(t,r),r.style.position="absolute",r.style.visibility="hidden",r.style.whiteSpace="pre-wrap",r.style.overflowWrap="break-word",r.style.overflow="hidden",r.style.top="0",r.style.left="-9999px",r.style.height="auto",r.textContent=t.value.slice(0,i),a.textContent="",r.appendChild(a),s.body.appendChild(r);const l={left:a.offsetLeft-t.scrollLeft,top:a.offsetTop-t.scrollTop};return r.remove(),l}function vm({cardClientWidth:t,cardRectWidth:n}){const s=n/t;return Number.isFinite(s)&&s>0?s:1}function wm({boundaryRectBottom:t,boundaryRectTop:n,cardRectTop:s,cardWidth:r,caretLeft:a,caretTop:i,cssZoom:l=1,lineHeight:c,matchCount:d,textareaOffsetLeft:m,textareaOffsetTop:p,viewportHeight:u}){const h=Number.isFinite(l)&&l>0?l:1,f=Math.min(Math.max(d,1)*28+4,220),j=f*h,g=m/h,w=p/h,b=n??0,k=t??u,y=Math.max(8,r-lm-8),x=Math.max(8,Math.min(g+a,y)),v=w+i+c+4,N=s+v*h,A=w+i-f-4,E=s+(w+i)*h,M=k-N-8,B=E-b-8,D=Math.max(8,(b-s+8)/h);if(M<j&&B>M)return{left:x,top:Math.max(D,A)};const _=Math.max(D,(k-s-j-8)/h);return{left:x,top:Math.max(D,Math.min(v,_))}}function ym(t,n,s){const r=t.closest('[data-chat-input-card="true"]'),a=bm(t,n);if(!r||!a)return;const i=t.getBoundingClientRect(),l=r.getBoundingClientRect(),c=r.closest(".dashboard-conversation-panel")?.getBoundingClientRect(),d=Number.parseFloat(window.getComputedStyle(t).lineHeight)||18;return wm({boundaryRectBottom:c?.bottom,boundaryRectTop:c?.top,cardRectTop:l.top,cardWidth:r.clientWidth,caretLeft:a.left,caretTop:a.top,cssZoom:vm({cardRectWidth:l.width,cardClientWidth:r.clientWidth}),lineHeight:d,matchCount:s,textareaOffsetLeft:i.left-l.left,textareaOffsetTop:i.top-l.top,viewportHeight:window.innerHeight})}function jm({onSend:t,disabled:n,disabledReason:s="Chat is waiting on the agent.",placeholder:r="Send a follow-up message...",contextItems:a=[],agent:i,currentAgent:l,taskId:c,model:d,availableAgents:m=[],selectedTargetAgent:p,onTargetAgentChange:u,running:h=!1,onStop:f,quickChats:j=[]}){const[g,w]=o.useState(""),[b,k]=o.useState(),[y,x]=o.useState(c),[v,N]=o.useState(),[A,E]=o.useState(),[M,B]=o.useState(!1),[D,_]=o.useState(0),[P,O]=o.useState(0),[W,J]=o.useState(0),Y=o.useRef(null),V=o.useRef(void 0),{images:ne,error:$,fileInputRef:ee,pickImages:S,handleFileChange:Q,handlePaste:T,removeImage:te,clearImages:R}=oi();c!==y&&(x(c),k(void 0));const H=o.useCallback((G=Y.current)=>{G&&_(G.selectionStart??G.value.length)},[]),F=o.useCallback((G=D,ge=1)=>{Y.current&&E(ym(Y.current,G,ge))},[D]),le=o.useCallback(()=>{Y.current&&(Y.current.style.height="auto")},[]),ie=o.useCallback(()=>{Y.current&&(Y.current.style.height="auto",Y.current.style.height=Math.min(Y.current.scrollHeight,220).toString()+"px",H(Y.current))},[H]);o.useEffect(()=>{O(0)},[g,j]);const ue=p??b,Z=o.useMemo(()=>ua(g,m,D),[m,D,g]),K=pm(Z,M),I=fm(Z.matches,v,l),se=Z.matches[I];o.useEffect(()=>{N(void 0),B(!1)},[l,Z.query,Z.matches.join("|")]),o.useEffect(()=>{if(!K){E(void 0);return}const G=Z.mentionRange?.end??D,ge=()=>F(G,Z.matches.length);if(typeof requestAnimationFrame!="function"){ge();return}const be=requestAnimationFrame(ge);return()=>cancelAnimationFrame(be)},[Z.matches.length,Z.mentionRange?.end,D,K,F]);const q=o.useCallback(G=>{u?u(G):k(G)},[u]),ae=o.useCallback(G=>{w(G.prompt);const ge=()=>{Y.current?.focus(),ie()};typeof requestAnimationFrame=="function"?requestAnimationFrame(ge):ge()},[ie]),ye=o.useCallback(()=>{const G=Wn(g,j,P);if(G){ae(G);return}const ge=ua(g,m,D),be=ge.targetAgent??ue,et=ge.targetAgent?ge.strippedText:g,_e=zo(et,ne);om({contentLength:_e.length,disabled:n})&&(J(rt=>rt+1),t(_e,be?{targetAgent:be}:void 0),w(""),q(void 0),R(),le())},[g,ne,m,D,ue,n,t,q,R,le,j,P,ae]),pe=o.useCallback((G,ge=Z.mentionRange)=>{q(G),w(et=>{const _e=xm(et,ge);return V.current=_e.cursorPosition,_(_e.cursorPosition),_e.value});const be=()=>{Y.current?.focus(),V.current!==void 0&&(Y.current?.setSelectionRange(V.current,V.current),V.current=void 0),ie()};typeof requestAnimationFrame=="function"?requestAnimationFrame(be):be()},[ie,Z.mentionRange,q]),Ze=o.useCallback(G=>{if(K&&G.key==="Escape"){G.preventDefault(),B(!0);return}if(K&&(G.key==="ArrowDown"||G.key==="ArrowUp")){G.preventDefault();const be=Z.matches.length;if(be===0)return;const et=G.key==="ArrowDown"?1:-1,_e=(I+et+be)%be;N(Z.matches[_e]);return}if(K&&G.key==="Enter"&&!G.shiftKey&&se){G.preventDefault(),pe(se,Z.mentionRange);return}const ge=No(g,j);if(ge.length>0&&(G.key==="ArrowDown"||G.key==="ArrowUp")){G.preventDefault(),O(be=>ko(be,ge.length,G.key==="ArrowDown"?1:-1));return}if(G.key==="Enter"&&!G.shiftKey){G.preventDefault();const be=Wn(g,j,P);be?ae(be):ye()}},[pe,ae,ye,Z.matches,Z.mentionRange,j,P,se,I,K,g]),Ae=g.trim().length>0||ne.length>0,Re=am({disabled:n,running:h,canStop:h&&!!f,hasContent:Ae}),De=cm(a),He=De.primary?da(De.primary.label):rs,Ke=i?Uo(i,d):null,je=l?kt(l):null,Be=n?s:h?Ae?"Enter queues this message for the next turn":f?"Task is running - type to queue, empty button stops task":"Task is running - type to queue a message":"Enter sends, Shift+Enter adds a line";return e.jsx("div",{"data-chat-input-shell":"true",className:"chat-input-shell animate-composer-settle w-full bg-background/35 px-2 pb-2 pt-0 sm:px-4 sm:pb-3",children:e.jsx("div",{"data-chat-input-column":"true",className:"mx-auto w-full max-w-[72rem]",children:e.jsxs("div",{"data-chat-input-card":"true",className:"chat-input-card relative overflow-visible rounded-xl border border-border/65 bg-card/88 transition-[border-color,box-shadow] duration-200 focus-within:border-primary/50 focus-within:ring-2 focus-within:ring-primary/15 sm:rounded-xl",children:[e.jsx("input",{ref:ee,type:"file",accept:"image/*",multiple:!0,onChange:Q,className:"hidden"}),l&&je&&e.jsxs("span",{"data-current-agent":l,title:`Active agent: ${je}`,className:"absolute right-2 top-1.5 z-10 inline-flex h-4 max-w-[8.5rem] items-center gap-1 rounded-sm bg-primary/12 px-1.5 text-[8px] font-medium leading-3 text-primary sm:right-4 sm:top-2",children:[e.jsx(At,{agent:l,className:"h-2.5 w-2.5 shrink-0 text-primary/75"}),e.jsx("span",{className:"truncate",children:je})]}),De.primary&&e.jsx("div",{"data-chat-input-primary-context":"true",className:`px-2.5 pt-1.5 sm:px-5 sm:pt-2 ${l?"pr-24 sm:pr-32":""}`,children:e.jsxs("div",{className:"-ml-1.5 inline-flex max-w-full items-center gap-1.5 rounded-sm bg-muted/45 px-1.5 py-0.5 shadow-[0_10px_28px_-18px_rgba(15,23,42,0.72)] sm:-ml-2 dark:shadow-[0_10px_28px_-18px_rgba(0,0,0,0.95)]",children:[e.jsx(He,{className:"h-2.5 w-2.5 shrink-0 text-primary/45","aria-hidden":"true"}),e.jsx("span",{className:"truncate font-mono text-[9px] leading-3 text-muted-foreground/72",title:De.primary.value,children:De.primary.displayValue})]})}),ne.length>0&&e.jsx("div",{className:"px-2 pt-2.5 sm:px-5 sm:pt-4",children:e.jsx("div",{className:"flex flex-wrap gap-3",children:ne.map((G,ge)=>e.jsxs("div",{className:"relative",children:[e.jsx(Sr,{image:G,alt:G.filename??`attachment ${ge+1}`,thumbnailClassName:"h-24 w-24 border border-border/70",imageClassName:"h-full w-full"}),e.jsx("button",{type:"button",onClick:()=>te(ge),className:"absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-sm border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${G.filename??`image ${ge+1}`}`,children:e.jsx(ut,{className:"h-3 w-3"})})]},`${G.filename??"image"}-${ge}`))})}),e.jsx("div",{className:"px-2 pb-0 pt-1 sm:px-5 sm:pt-1.5",children:e.jsx("textarea",{ref:Y,"data-chat-input-textarea":"true",value:g,onChange:G=>{w(G.target.value),H(G.currentTarget)},onKeyDown:Ze,onKeyUp:G=>H(G.currentTarget),onClick:G=>H(G.currentTarget),onSelect:G=>H(G.currentTarget),onScroll:()=>F(D,Z.matches.length),onPaste:T,onInput:ie,placeholder:r,disabled:n,rows:1,className:"min-h-[1.35rem] w-full resize-none overflow-x-hidden overflow-y-auto bg-transparent px-0 py-0 text-[11px] leading-[1.35rem] text-foreground placeholder:text-[10px] placeholder:text-muted-foreground/65 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"})}),e.jsx(Xs,{query:g,quickChats:j,selectedIndex:P,onActiveIndexChange:O,onSelect:ae}),K&&e.jsx("div",{"data-agent-mention-menu":"true",className:"absolute z-20 flex w-44 max-w-[calc(100%-1rem)] flex-col overflow-hidden rounded-sm border border-border/60 bg-popover/95 p-0.5 text-popover-foreground shadow-[0_16px_42px_-24px_rgba(0,0,0,0.85)]",style:A?{left:A.left,top:A.top}:{left:8,top:"50%"},children:Z.matches.map((G,ge)=>e.jsxs("button",{type:"button",onMouseDown:be=>be.preventDefault(),onMouseEnter:()=>N(G),onClick:()=>pe(G,Z.mentionRange),className:["flex h-7 w-full items-center gap-1.5 rounded-sm px-1.5 text-left text-[10px] transition-colors hover:bg-muted/55 hover:text-foreground",ge===I?"bg-primary/10 text-primary":"text-muted-foreground"].join(" "),children:[e.jsx(At,{agent:G,className:"h-3 w-3 shrink-0 text-primary/60"}),e.jsx("span",{className:"truncate",children:kt(G)})]},G))}),e.jsxs("div",{className:"flex items-end justify-between gap-2 px-2 pb-1.5 pt-0.5 sm:px-5 sm:pb-2.5",children:[ue||De.secondary.length>0?e.jsxs("div",{"data-chat-input-secondary-context":"true",className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 pb-0.5 text-[9px] leading-3 text-muted-foreground/72 sm:text-[9px]",children:[ue&&e.jsxs("span",{"data-chat-input-target-agent":ue,title:`Send to ${kt(ue)}`,className:"inline-flex h-6 max-w-[11rem] items-center gap-1.5 rounded-sm bg-primary/10 px-1.5 text-[10px] leading-3 text-primary",children:[e.jsx(Qo,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(At,{agent:ue,className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:kt(ue)}),e.jsx("button",{type:"button",onClick:()=>q(void 0),className:"-mr-0.5 inline-flex h-4 w-4 items-center justify-center rounded-sm text-primary/70 hover:bg-primary/15 hover:text-primary","aria-label":"Clear target agent",children:e.jsx(ut,{className:"h-2.5 w-2.5"})})]}),De.secondary.map(G=>{const ge=da(G.label),be=G.label.toLowerCase()==="agent";return e.jsxs("span",{title:`${G.label}: ${G.value}`,className:"inline-flex min-w-0 max-w-[12rem] items-center gap-1 truncate",children:[be?e.jsx(At,{agent:G.value,className:"h-2.5 w-2.5 shrink-0 text-primary/50"}):e.jsx(ge,{"data-chat-input-secondary-icon":"true",className:"h-2.5 w-2.5 shrink-0 text-primary/50","aria-hidden":"true"}),e.jsx("span",{className:`truncate ${G.mono?"font-mono":""}`,children:G.displayValue})]},`${G.label}:${G.value}`)})]}):e.jsx("div",{className:"min-w-0 flex-1"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[Ke&&e.jsxs("span",{"data-chat-input-model-display":"true","aria-label":`Model: ${Ke}`,title:`Model: ${Ke}`,className:"inline-flex h-7 max-w-[9rem] shrink-0 items-center gap-1.5 truncate rounded-sm px-2 text-[10px] text-muted-foreground",children:[e.jsx(Yo,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),Ke]}),e.jsxs(X,{type:"button",variant:"ghost",onClick:S,disabled:n,className:"h-7 shrink-0 gap-1.5 rounded-sm px-2 text-[10px] text-muted-foreground hover:text-foreground sm:px-2",title:"Attach images",children:[e.jsx(or,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Images"})]}),e.jsx("span",{title:Be,children:e.jsx(X,{onClick:Re.primaryAction==="stop"?f:ye,disabled:Re.primaryDisabled,size:"icon","data-chat-send-button":"true","aria-label":Re.primaryAction==="stop"?"Stop running task":h?"Queue message":"Send message",className:"chat-send-button h-7 w-9 shrink-0 rounded-sm bg-primary/90 text-primary-foreground shadow-[0_12px_30px_-18px_hsl(var(--primary)/0.95)] transition-transform duration-150 hover:bg-primary active:scale-95",children:Re.primaryAction==="stop"?e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(si,{className:`h-3.5 w-3.5 ${W>0?"animate-chat-send-flight":""}`},W)})})]})]}),$&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-2 py-2 text-[11px] text-destructive sm:px-6 sm:py-3",children:$})]})})})}var js="rovingFocusGroup.onEntryFocus",Nm={bubbles:!1,cancelable:!0},Bn="RovingFocusGroup",[lr,ci,km]=Gl(Bn),[Sm,di]=Co(Bn,[km]),[Cm,Tm]=Sm(Bn),ui=o.forwardRef((t,n)=>e.jsx(lr.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(lr.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Am,{...t,ref:n})})}));ui.displayName=Bn;var Am=o.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,orientation:r,loop:a=!1,dir:i,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:m,preventScrollOnEntryFocus:p=!1,...u}=t,h=o.useRef(null),f=Wl(n,h),j=To(i),[g,w]=Ao({prop:l,defaultProp:c??null,onChange:d,caller:Bn}),[b,k]=o.useState(!1),y=Ql(m),x=ci(s),v=o.useRef(!1),[N,A]=o.useState(0);return o.useEffect(()=>{const E=h.current;if(E)return E.addEventListener(js,y),()=>E.removeEventListener(js,y)},[y]),e.jsx(Cm,{scope:s,orientation:r,dir:j,loop:a,currentTabStopId:g,onItemFocus:o.useCallback(E=>w(E),[w]),onItemShiftTab:o.useCallback(()=>k(!0),[]),onFocusableItemAdd:o.useCallback(()=>A(E=>E+1),[]),onFocusableItemRemove:o.useCallback(()=>A(E=>E-1),[]),children:e.jsx(mn.div,{tabIndex:b||N===0?-1:0,"data-orientation":r,...u,ref:f,style:{outline:"none",...t.style},onMouseDown:Et(t.onMouseDown,()=>{v.current=!0}),onFocus:Et(t.onFocus,E=>{const M=!v.current;if(E.target===E.currentTarget&&M&&!b){const B=new CustomEvent(js,Nm);if(E.currentTarget.dispatchEvent(B),!B.defaultPrevented){const D=x().filter(J=>J.focusable),_=D.find(J=>J.active),P=D.find(J=>J.id===g),W=[_,P,...D].filter(Boolean).map(J=>J.ref.current);fi(W,p)}}v.current=!1}),onBlur:Et(t.onBlur,()=>k(!1))})})}),mi="RovingFocusGroupItem",hi=o.forwardRef((t,n)=>{const{__scopeRovingFocusGroup:s,focusable:r=!0,active:a=!1,tabStopId:i,children:l,...c}=t,d=So(),m=i||d,p=Tm(mi,s),u=p.currentTabStopId===m,h=ci(s),{onFocusableItemAdd:f,onFocusableItemRemove:j,currentTabStopId:g}=p;return o.useEffect(()=>{if(r)return f(),()=>j()},[r,f,j]),e.jsx(lr.ItemSlot,{scope:s,id:m,focusable:r,active:a,children:e.jsx(mn.span,{tabIndex:u?0:-1,"data-orientation":p.orientation,...c,ref:n,onMouseDown:Et(t.onMouseDown,w=>{r?p.onItemFocus(m):w.preventDefault()}),onFocus:Et(t.onFocus,()=>p.onItemFocus(m)),onKeyDown:Et(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const b=Dm(w,p.orientation,p.dir);if(b!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let y=h().filter(x=>x.focusable).map(x=>x.ref.current);if(b==="last")y.reverse();else if(b==="prev"||b==="next"){b==="prev"&&y.reverse();const x=y.indexOf(w.currentTarget);y=p.loop?_m(y,x+1):y.slice(x+1)}setTimeout(()=>fi(y))}}),children:typeof l=="function"?l({isCurrentTabStop:u,hasTabStop:g!=null}):l})})});hi.displayName=mi;var Em={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Mm(t,n){return n!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Dm(t,n,s){const r=Mm(t.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Em[r]}function fi(t,n=!1){const s=document.activeElement;for(const r of t)if(r===s||(r.focus({preventScroll:n}),document.activeElement!==s))return}function _m(t,n){return t.map((s,r)=>t[(n+r)%t.length])}var Pm=ui,Im=hi,as="Tabs",[Rm]=Co(as,[di]),pi=di(),[Lm,Dr]=Rm(as),xi=o.forwardRef((t,n)=>{const{__scopeTabs:s,value:r,onValueChange:a,defaultValue:i,orientation:l="horizontal",dir:c,activationMode:d="automatic",...m}=t,p=To(c),[u,h]=Ao({prop:r,onChange:a,defaultProp:i??"",caller:as});return e.jsx(Lm,{scope:s,baseId:So(),value:u,onValueChange:h,orientation:l,dir:p,activationMode:d,children:e.jsx(mn.div,{dir:p,"data-orientation":l,...m,ref:n})})});xi.displayName=as;var gi="TabsList",bi=o.forwardRef((t,n)=>{const{__scopeTabs:s,loop:r=!0,...a}=t,i=Dr(gi,s),l=pi(s);return e.jsx(Pm,{asChild:!0,...l,orientation:i.orientation,dir:i.dir,loop:r,children:e.jsx(mn.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:n})})});bi.displayName=gi;var vi="TabsTrigger",wi=o.forwardRef((t,n)=>{const{__scopeTabs:s,value:r,disabled:a=!1,...i}=t,l=Dr(vi,s),c=pi(s),d=Ni(l.baseId,r),m=ki(l.baseId,r),p=r===l.value;return e.jsx(Im,{asChild:!0,...c,focusable:!a,active:p,children:e.jsx(mn.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":m,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...i,ref:n,onMouseDown:Et(t.onMouseDown,u=>{!a&&u.button===0&&u.ctrlKey===!1?l.onValueChange(r):u.preventDefault()}),onKeyDown:Et(t.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&l.onValueChange(r)}),onFocus:Et(t.onFocus,()=>{const u=l.activationMode!=="manual";!p&&!a&&u&&l.onValueChange(r)})})})});wi.displayName=vi;var yi="TabsContent",ji=o.forwardRef((t,n)=>{const{__scopeTabs:s,value:r,forceMount:a,children:i,...l}=t,c=Dr(yi,s),d=Ni(c.baseId,r),m=ki(c.baseId,r),p=r===c.value,u=o.useRef(p);return o.useEffect(()=>{const h=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(h)},[]),e.jsx(Yl,{present:a||p,children:({present:h})=>e.jsx(mn.div,{"data-state":p?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!h,id:m,tabIndex:0,...l,ref:n,style:{...t.style,animationDuration:u.current?"0s":void 0},children:h&&i})})});ji.displayName=yi;function Ni(t,n){return`${t}-trigger-${n}`}function ki(t,n){return`${t}-content-${n}`}var Bm=xi,Si=bi,Ci=wi,Ti=ji;const _r=Bm,os=o.forwardRef(({className:t,...n},s)=>e.jsx(Si,{ref:s,className:L("inline-flex h-8 items-center justify-center rounded-sm bg-muted/72 p-0.5 text-muted-foreground shadow-inner shadow-background/40",t),...n}));os.displayName=Si.displayName;const Ot=o.forwardRef(({className:t,...n},s)=>e.jsx(Ci,{ref:s,className:L("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-2 py-0.5 text-[11px] font-semibold ring-offset-background transition-all duration-200 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary/12 data-[state=active]:text-primary data-[state=active]:shadow-[0_10px_28px_-18px_hsl(var(--primary)/0.85)]",t),...n}));Ot.displayName=Ci.displayName;const bt=o.forwardRef(({className:t,...n},s)=>e.jsx(Ti,{ref:s,className:L("mt-2 ring-offset-background data-[state=inactive]:hidden focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...n}));bt.displayName=Ti.displayName;var Om=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Fm=Om.reduce((t,n)=>{const s=Jl(`Primitive.${n}`),r=o.forwardRef((a,i)=>{const{asChild:l,...c}=a,d=l?s:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...c,ref:i})});return r.displayName=`Primitive.${n}`,{...t,[n]:r}},{}),zm="Label",Ai=o.forwardRef((t,n)=>e.jsx(Fm.label,{...t,ref:n,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(t.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));Ai.displayName=zm;var Ei=Ai;const Um=Zl("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),tt=o.forwardRef(({className:t,...n},s)=>e.jsx(Ei,{ref:s,className:L(Um(),t),...n}));tt.displayName=Ei.displayName;function ma({agent:t,query:n,onSelect:s}){const r=$o(t,n);return r?e.jsx("div",{"data-codex-goal-command":"true",className:"mx-2 mb-0.5 rounded-sm bg-background/70 p-0.5 shadow-none sm:mx-5",children:e.jsx("div",{role:"listbox","aria-label":"Codex commands",children:e.jsxs("button",{type:"button",role:"option","aria-selected":"true",onClick:s,className:"flex h-8 w-full min-w-0 items-center gap-2 rounded-sm px-2 text-left transition-colors hover:bg-muted/50 hover:text-foreground",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-primary",children:e.jsx(qo,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),e.jsx("span",{className:"shrink-0 text-[11px] font-medium text-foreground",children:r.label}),e.jsx("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:r.description})]})})}):null}function $m(t,n,s){return t!=="auto"?n.find(r=>r.id===t)??null:s.length===1?s[0]??null:null}function qm(t){return t.trim()||"."}function Vm(t){return new Promise(n=>window.setTimeout(n,t))}function Hm(t){return!!t&&typeof t=="object"&&typeof t.createdBranch=="string"&&typeof t.currentBranch<"u"}async function Km(t){let n=t;for(let s=0;s<60;s++){if(n.status==="succeeded"){if(Hm(n.result))return n.result;throw new Error("Branch creation completed without branch details")}if(n.status==="failed")throw new Error(n.error||"Branch creation failed");await Vm(1e3),n=await nc(n.id)}throw new Error("Timed out waiting for branch creation")}function ha({value:t,onChange:n,project:s,assignTo:r,nodes:a,assignableNodes:i,layout:l="default",chipClassName:c,chipActiveClassName:d,chipInactiveClassName:m,labelClassName:p,triggerClassName:u}){const[h,f]=o.useState(!1),[j,g]=o.useState(null),[w,b]=o.useState(""),[k,y]=o.useState(!1),[x,v]=o.useState(!1),[N,A]=o.useState(!1),[E,M]=o.useState(null),[B,D]=o.useState(""),[_,P]=o.useState(""),[O,W]=o.useState(""),[J,Y]=o.useState(!1),V=o.useRef(null),ne=o.useRef(0),$=o.useMemo(()=>$m(r,a,i),[r,a,i]),ee=$?.id,S=o.useMemo(()=>qm(s),[s]),Q=o.useMemo(()=>ee?`${ee}
|
|
188
188
|
${S}`:"",[ee,S]),T=o.useCallback(async(Z=0,K=!1)=>{const I=ne.current+1,se=Q;if(ne.current=I,!ee){g(null),b("");return}M(null),K||b(""),K?v(!0):y(!0);try{const q=await Xl(ee,{path:S,limit:20,offset:Z,allowAbsolute:!0});if(I!==ne.current)return;b(se),g(ae=>K&&ae?{...q,branches:[...ae.branches,...q.branches]}:q)}catch(q){if(I!==ne.current)return;M(q instanceof Error?q.message:"Failed to load branch info"),K||(g(null),b(""))}finally{I===ne.current&&(y(!1),v(!1))}},[ee,Q,S]);o.useEffect(()=>{if(!ee){ne.current+=1,g(null),b(""),M(null);return}T()},[ee,S,T]),o.useEffect(()=>{const Z=t.trim(),K=w===Q?j:null,I=K?.available&&K.currentBranch?K.currentBranch:"";Z!==I&&n(I)},[j,Q,w,n,t]),o.useEffect(()=>{if(!h)return;const Z=I=>{V.current&&(V.current.contains(I.target)||f(!1))},K=I=>{I.key==="Escape"&&f(!1)};return document.addEventListener("mousedown",Z),document.addEventListener("keydown",K),()=>{document.removeEventListener("mousedown",Z),document.removeEventListener("keydown",K)}},[h]),o.useEffect(()=>{h&&(P(""),W(""),Y(!1))},[h,ee,S]);const te=o.useCallback(async()=>{if(!ee)return;const Z=B.trim(),K=J?O.trim():_.trim();if(!(!Z||!K)){A(!0),M(null);try{const I=await ec(ee,{path:S,branchName:Z,startPoint:K,limit:20,offset:0,allowAbsolute:!0}),se=await Km(I);b(Q),g(se),n(se.currentBranch??se.createdBranch),D(""),P(""),W(""),Y(!1),f(!1)}catch(I){M(I instanceof Error?I.message:"Failed to create branch")}finally{A(!1)}}},[ee,Q,S,J,O,B,n,_]),R=w===Q?j:null,H=o.useCallback(()=>{R?.hasMore&&T(R.branches.length,!0)},[R,T]),F=t.trim()||R?.currentBranch||(R&&!R.available?"No git repo":"Branch"),le=J?O.trim():_.trim(),ie=!!(R?.available&&B.trim()&&le&&!N),ue=l==="composer"?e.jsxs(X,{type:"button",variant:"ghost",onClick:()=>f(Z=>!Z),title:F,"aria-label":`Branch: ${F}`,className:L(c,u,"min-w-0 max-w-full",t.trim()?d:m),children:[k&&!R?e.jsx(he,{className:"h-3.5 w-3.5 shrink-0 animate-spin"}):e.jsx(Yn,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:L("min-w-0 truncate",p),children:F})]}):e.jsxs(X,{type:"button",variant:"outline",onClick:()=>f(Z=>!Z),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:F,children:[e.jsx("span",{className:L("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:F}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:$?$.name:"Manual"})]});return e.jsxs("div",{className:L("relative inline-block",l==="composer"?"min-w-0 shrink-0":"w-full"),ref:V,children:[l==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[10px] font-medium",children:"Branch"}),ue]}):ue,h&&e.jsxs("div",{className:L("absolute z-50 mt-2 w-[240px] overflow-hidden rounded-sm border border-border/60 bg-background/95 shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",l==="composer"?"left-0":"left-0 right-0 w-auto min-w-[240px]"),children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsx(Yn,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-foreground",title:R?.repoRoot?`${R.currentBranch??F} · ${R.repoRoot}`:R?.currentBranch??F,children:R?.currentBranch??F}),k?e.jsx(he,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}):null]}),$?k&&!R?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(he,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):R&&!R.available?e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Not a git repository."}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-2 px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(dt,{value:B,onChange:Z=>D(Z.target.value),placeholder:"New branch name",className:"h-8 flex-1 rounded-sm border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx(X,{type:"button",size:"sm",onClick:()=>{te()},disabled:!ie,title:ie?"Create branch":"Enter a name and pick a base","aria-label":"Create branch",className:"h-8 w-8 shrink-0 rounded-sm p-0",children:N?e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(tc,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Base from"}),!J&&e.jsxs("button",{type:"button",onClick:()=>Y(!0),className:"flex items-center gap-1 rounded-sm px-1 py-0.5 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx(Jt,{className:"h-2.5 w-2.5"}),"Manual"]})]}),J?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dt,{value:O,onChange:Z=>W(Z.target.value),placeholder:"upstream/release/1.0",className:"h-8 flex-1 rounded-sm border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>{Y(!1),W("")},className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel manual input","aria-label":"Cancel manual input",children:e.jsx(ut,{className:"h-3.5 w-3.5"})})]}):R?.branches.length?e.jsxs("div",{className:"max-h-44 overflow-y-auto rounded-sm border border-border/40 bg-background/40",children:[R.branches.map(Z=>{const K=_===Z.ref,I=Z.branch==="main"||Z.branch==="master";return e.jsxs("button",{type:"button",onClick:()=>P(Z.ref),className:L("flex w-full items-center gap-2 border-b border-border/20 px-2.5 py-1.5 text-left text-[11px] last:border-b-0 hover:bg-background/60",K&&"bg-background/70"),title:Z.ref,children:[e.jsx("span",{className:L("shrink-0 text-[10px]",I?"text-amber-500 dark:text-amber-400":"text-muted-foreground/60"),"aria-hidden":!0,children:I?"★":"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:Z.ref}),K?e.jsx(En,{className:"h-3 w-3 shrink-0 text-primary"}):null]},Z.ref)}),R.hasMore&&e.jsxs("button",{type:"button",onClick:H,disabled:x,className:"flex w-full items-center justify-center gap-1 border-t border-border/20 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[x?e.jsx(he,{className:"h-3 w-3 animate-spin"}):e.jsx(Jn,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"rounded-sm border border-dashed border-border/40 px-2.5 py-2 text-[11px] text-muted-foreground",children:"No remote branches found."})]})]})}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a specific node first."}),E&&e.jsx("div",{className:"border-t border-destructive/20 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive",children:E})]})]})}function Gm({images:t,removeImage:n}){return e.jsx("div",{className:"flex flex-wrap gap-3",children:t.map((s,r)=>e.jsxs("div",{className:"relative",children:[e.jsx(Sr,{image:s,alt:s.filename??`attachment ${r+1}`,thumbnailClassName:"h-20 w-20 border border-border/70",imageClassName:"h-full w-full"}),e.jsx("button",{type:"button",onClick:()=>n(r),className:"absolute -top-2 -right-2 flex h-6 w-6 items-center justify-center rounded-sm border border-border/70 bg-background text-muted-foreground shadow-sm transition-all hover:-translate-y-px hover:text-foreground","aria-label":`Remove ${s.filename??`image ${r+1}`}`,children:e.jsx(ut,{className:"h-3.5 w-3.5"})})]},`${s.filename??"image"}-${r}`))})}const Wm=20,Qm=3,cr="meshy-working-dir-recents-by-node";function Ym(t){return t.startsWith("/")||t.startsWith("\\\\")||/^[A-Za-z]:[\\/]/.test(t)}function Jm(t){const n=t.trim();return n||"."}function dr(t){const n=[],s=new Set;for(const r of t){const a=r.trim();if(!(!a||s.has(a))&&(s.add(a),n.push(a),n.length===Qm))break}return n}function Zm(t,n){const s=n.trim();return dr(s?[s,...t]:t)}function Mi(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,r]of Object.entries(t)){if(!s||!Array.isArray(r))continue;const a=r.filter(l=>typeof l=="string"),i=dr(a);i.length>0&&(n[s]=i)}return n}function Xm(t,n,s){if(!n)return t;const r=t[n]??[],a=Zm(r,s);if(a.length===0){if(!(n in t))return t;const{[n]:i,...l}=t;return l}return{...t,[n]:a}}function eh(t,n){return n?t[n]?.[0]??"":""}function Di(t){if(!t||typeof window>"u")return"";try{const n=window.localStorage.getItem(cr);return n?eh(Mi(JSON.parse(n)),t):""}catch{return""}}function th(t,n,s){return t!=="auto"?n.find(r=>r.id===t)??null:s.length===1?s[0]??null:null}function nh(t,n){const s=n.trim();return s?Ym(s)||!t?s:`${t.replace(/[/\\]+$/,"")}/${s}`:""}function sh(t,n){return t?t.isAbsolute?t.currentPath:t.currentPath==="."||t.currentPath===""?t.rootPath||n?.workDir||"Node root":t.currentPath:n?.workDir??"Node root"}function Xn({value:t,onChange:n,assignTo:s,nodes:r,assignableNodes:a,layout:i="default",chipClassName:l,chipActiveClassName:c,chipInactiveClassName:d,labelClassName:m,triggerClassName:p,popoverPlacement:u="bottom",popoverAlign:h="start"}){const[f,j]=o.useState(!1),[g,w]=o.useState(null),[b,k]=o.useState(!1),[y,x]=o.useState(!1),[v,N]=o.useState(null),[A,E]=o.useState(""),[M,B]=o.useState(!1),[D,_]=o.useState({}),P=o.useRef(null),O=o.useMemo(()=>th(s,r,a),[s,r,a]),W=O?.id,J=o.useMemo(()=>W?D[W]??[]:[],[D,W]),Y=o.useMemo(()=>t.trim()?nh(O?.workDir,t):"Use node default",[t,O?.workDir]);o.useEffect(()=>{if(!(typeof window>"u"))try{const F=window.localStorage.getItem(cr);if(!F)return;const le=JSON.parse(F);_(Mi(le))}catch{}},[]);const V=o.useCallback(F=>{W&&_(le=>{const ie=Xm(le,W,F);if(ie===le)return le;if(typeof window<"u")try{window.localStorage.setItem(cr,JSON.stringify(ie))}catch{}return ie})},[W]),ne=o.useCallback((F,le=!0)=>{const ie=F.trim();n(ie),le&&ie&&V(ie),j(!1)},[n,V]),$=o.useCallback(async(F,le=0,ie=!1)=>{if(W){N(null),ie?x(!0):k(!0);try{const ue=await Eo(W,{path:F,limit:Wm,offset:le,directoriesOnly:!0,allowAbsolute:!0});w(Z=>ie&&Z?{...ue,entries:[...Z.entries,...ue.entries]}:ue)}catch(ue){N(ue instanceof Error?ue.message:"Failed to browse directories"),ie||w(null)}finally{k(!1),x(!1)}}},[W]),ee=o.useRef(t);ee.current=t;const S=o.useRef($);S.current=$,o.useEffect(()=>{if(!f)return;const F=ee.current;E(F),B(!1),w(null),N(null),W&&S.current(Jm(F))},[f,W]),o.useEffect(()=>{if(!f)return;const F=ie=>{P.current&&(P.current.contains(ie.target)||j(!1))},le=ie=>{ie.key==="Escape"&&j(!1)};return document.addEventListener("mousedown",F),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",le)}},[f]);const Q=o.useCallback(F=>{$(F)},[$]),T=o.useCallback(()=>{g&&$(g.currentPath,g.entries.length,!0)},[g,$]),te=i==="composer"?e.jsxs(X,{type:"button",variant:"ghost",onClick:()=>j(F=>!F),title:Y,"aria-label":`Working directory: ${Y}`,className:L(l,p,"min-w-0 max-w-full",t.trim()?c:d),children:[e.jsx(Jo,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:L("min-w-0 truncate",m),children:Y})]}):e.jsxs(X,{type:"button",variant:"outline",onClick:()=>j(F=>!F),className:"h-7 w-full justify-between rounded-sm border-border/70 bg-background/70 px-2.5 text-[11px] shadow-none",title:Y,children:[e.jsx("span",{className:L("truncate",t.trim()?"font-mono text-foreground":"text-muted-foreground"),children:Y}),e.jsx("span",{className:"ml-2 shrink-0 text-[10px] text-muted-foreground",children:O?O.name:"Manual"})]}),R=sh(g,O),H=!!g?.parentPath;return e.jsxs("div",{className:L("relative inline-block",i==="composer"?"min-w-0 max-w-[60%] shrink":"w-full"),"data-workdir-popover-placement":u,"data-workdir-popover-align":h,ref:P,children:[i==="default"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[10px] font-medium",children:"Working directory"}),te]}):te,f&&e.jsxs("div",{className:L("absolute z-50 flex max-h-[min(28rem,calc(100vh-5rem))] w-[240px] flex-col overflow-hidden rounded-sm border border-border/60 bg-background/95 shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",u==="top"?"bottom-full mb-2":"top-full mt-2",i==="composer"?h==="end"?"right-0":"left-0":h==="end"?"right-0 w-auto min-w-[240px]":"left-0 right-0 w-auto min-w-[240px]"),children:[J.length>0&&e.jsxs("div",{className:"border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx(Jn,{className:"h-2.5 w-2.5"}),"Recent"]}),e.jsx("div",{className:"flex flex-col",children:J.map(F=>e.jsx("button",{type:"button",onClick:()=>ne(F),className:"truncate rounded-sm px-1.5 py-0.5 text-left font-mono text-[11px] text-foreground hover:bg-background/60",title:F,children:F},F))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/60 px-2.5 py-1.5",children:[e.jsx("button",{type:"button",onClick:()=>g?.parentPath&&Q(g.parentPath),disabled:!H||b,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-sm border border-border/60 text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground disabled:opacity-40",title:"Parent directory",children:e.jsx(Wo,{className:"h-3 w-3"})}),e.jsx("div",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:R,children:R}),g&&e.jsx("button",{type:"button",onClick:()=>ne(g.isAbsolute?g.currentPath:g.currentPath==="."?"":g.currentPath),className:"shrink-0 rounded-sm px-1.5 py-0.5 text-[10px] font-medium text-foreground hover:bg-background/60",title:"Use this folder",children:"Use"})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:[O?b?e.jsxs("div",{className:"flex items-center justify-center px-3 py-4 text-[11px] text-muted-foreground",children:[e.jsx(he,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Loading..."]}):g&&g.entries.length>0?e.jsxs(e.Fragment,{children:[g.entries.map(F=>e.jsxs("div",{className:"group flex items-stretch border-b border-border/30 last:border-b-0",children:[e.jsxs("button",{type:"button",onClick:()=>ne(F.path),className:"flex min-w-0 flex-1 items-center gap-2 px-2.5 py-1.5 text-left hover:bg-background/55",title:`Use ${F.path}`,children:[e.jsx(hn,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[11px] text-foreground",children:F.name})]}),e.jsx("button",{type:"button",onClick:()=>Q(F.path),className:"flex w-9 shrink-0 items-center justify-center border-l border-border/30 text-muted-foreground hover:bg-background/70 hover:text-foreground",title:"Open subfolder","aria-label":`Open ${F.name}`,children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]},F.path)),g.hasMore&&e.jsxs("button",{type:"button",onClick:T,disabled:y,className:"flex w-full items-center justify-center gap-1 border-t border-border/40 py-1 text-[10px] text-muted-foreground hover:bg-background/60 hover:text-foreground disabled:opacity-50",children:[y?e.jsx(he,{className:"h-3 w-3 animate-spin"}):e.jsx(Jn,{className:"h-3 w-3"}),"Load more"]})]}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:v??"No subfolders."}):e.jsx("div",{className:"px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Select a node to browse."}),v&&g&&g.entries.length>0&&e.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[11px] text-destructive",children:v})]}),e.jsx("div",{className:"flex items-center gap-1 border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:M?e.jsxs(e.Fragment,{children:[e.jsx(dt,{value:A,onChange:F=>E(F.target.value),onKeyDown:F=>{F.key==="Enter"&&A.trim()?(F.preventDefault(),ne(A)):F.key==="Escape"&&(F.preventDefault(),B(!1),E(t))},autoFocus:!0,placeholder:"Path (relative or absolute)",className:"h-7 flex-1 rounded-sm border-border/60 bg-background/70 font-mono text-[11px]"}),e.jsx("button",{type:"button",onClick:()=>ne(A),disabled:!A.trim(),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-sm text-foreground hover:bg-background/60 disabled:opacity-40",title:"Apply","aria-label":"Apply manual path",children:e.jsx(En,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{B(!1),E(t)},className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Cancel","aria-label":"Cancel manual path",children:e.jsx(ut,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{E(t),B(!0)},className:"flex h-7 flex-1 items-center justify-between rounded-sm px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",title:"Enter a manual path",children:[e.jsx("span",{children:"Manual input"}),e.jsx(Jt,{className:"h-3 w-3"})]})})]})]})}function _i(t,n={}){const s=t.filter(r=>r.status==="online");return n.currentNodeRole!=="follower"||!n.leaderNodeId?s:s.filter(r=>r.id!==n.leaderNodeId)}function Pr({isCurrent:t}){return t?e.jsx(yu,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500 dark:text-emerald-400","aria-label":"current node"}):e.jsx(gu,{className:"h-3.5 w-3.5 shrink-0 text-sky-500 dark:text-sky-400","aria-label":"remote follower node"})}function ur(t,n){return t.map(s=>{const r=!!n&&s.id===n;return e.jsx(Oe,{value:s.id,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(Pr,{isCurrent:r}),e.jsx("span",{className:"truncate",children:s.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:r?"current":"remote"})]})},s.id)})}function rh(t){const n=t.sessionId.trim(),s=t.cwd.trim();return!n||!s||!t.assignTo?null:{title:t.title.trim()||t.defaultTitle?.trim()||void 0,agent:t.agent,sessionId:n,cwd:s,assignTo:t.assignTo,priority:t.priority,mode:t.mode??Mn}}function ah(){return ac.map(t=>e.jsx(Oe,{value:t.value,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{children:t.label}),t.description&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:t.description})]})},t.value))}function oh(t){if(!t)return"unknown time";const n=Date.parse(t);return Number.isNaN(n)?t:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(n)}function fa(t){if(!t.updatedAt)return 0;const n=Date.parse(t.updatedAt);return Number.isNaN(n)?0:n}function ih(t,n){return fa(n)-fa(t)||t.sessionId.localeCompare(n.sessionId)}function lh(t){const n=t.trim().replace(/[\\/]+$/,"");return n?n.split(/[\\/]+/).filter(Boolean).at(-1)??n:"Unknown project"}function ch(t){const n=new Map;for(const s of[...t].sort(ih)){const r=n.get(s.cwd);if(r){r.push(s);continue}n.set(s.cwd,[s])}return Array.from(n.entries()).map(([s,r])=>({folderName:lh(s),cwd:s,sessions:r}))}function dh(t,n){const s=new Set(t);return s.has(n)?s.delete(n):s.add(n),s}function uh({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,onCreated:a,onCancel:i,className:l,footerClassName:c,submitLabel:d="Load session",cancelLabel:m="Cancel",autoFocus:p=!1}){const u=o.useMemo(()=>_i(t,{currentNodeRole:n,leaderNodeId:r}),[t,n,r]),h=o.useMemo(()=>s&&u.some(I=>I.id===s)?s:u[0]?.id??"",[u,s]),[f,j]=o.useState(""),[g,w]=o.useState("codex"),[b,k]=o.useState(""),[y,x]=o.useState(""),[v,N]=o.useState(""),[A,E]=o.useState(h),[M,B]=o.useState(Mn),[D,_]=o.useState(!1),[P,O]=o.useState([]),[W,J]=o.useState(!1),[Y,V]=o.useState(null),ne=o.useMemo(()=>P.find(I=>I.sessionId===b)??null,[P,b]);o.useEffect(()=>{A&&u.some(I=>I.id===A)||E(h)},[A,u,h]),o.useEffect(()=>{k(""),x(""),N("")},[g,A]),o.useEffect(()=>{let I=!1;return A?(J(!0),V(null),sc(A,{agent:g,limit:50}).then(se=>{I||O(se.sessions)}).catch(se=>{I||(O([]),V(se instanceof Error?se.message:"Failed to load native sessions"))}).finally(()=>{I||J(!1)}),()=>{I=!0}):(O([]),V(null),J(!1),()=>{I=!0})},[g,A]),o.useEffect(()=>{ne&&(x(ne.sessionId),N(ne.cwd))},[ne]);const $=o.useCallback(async I=>{I.preventDefault();const se=rh({title:f,defaultTitle:ne?.summary,agent:g,sessionId:y,cwd:v,assignTo:A,priority:"normal",mode:M});if(se){_(!0);try{const q=await rc(se);a(q)}catch(q){ce.error(q instanceof Error?q.message:"Failed to load native session")}finally{_(!1)}}},[f,ne,g,y,v,A,M,a]),ee=!!(y.trim()&&v.trim()&&A),[S,Q]=o.useState(!1),[T,te]=o.useState(""),[R,H]=o.useState(()=>new Set),F=u.find(I=>I.id===A)??null,le=!!(s&&F?.id===s),ie=o.useMemo(()=>{const I=T.trim().toLowerCase();return I?P.filter(se=>se.summary.toLowerCase().includes(I)||se.sessionId.toLowerCase().includes(I)||se.cwd.toLowerCase().includes(I)):P},[P,T]),ue=o.useMemo(()=>ch(ie),[ie]),Z=o.useCallback(I=>{H(se=>dh(se,I))},[]),K="h-9 w-auto gap-1.5 rounded-sm border-border/60 bg-background/60 px-3 text-xs shadow-none transition-colors hover:bg-background/80";return e.jsxs("form",{onSubmit:$,className:L("space-y-4",l),children:[e.jsxs("div",{className:"rounded-sm border border-border/60 bg-background/54 shadow-none backdrop-blur-xl",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/50 px-3 py-2.5",children:[e.jsxs($e,{value:A,onValueChange:E,children:[e.jsx(qe,{className:L(K),"aria-label":"Node",children:F?e.jsxs(e.Fragment,{children:[e.jsx(Pr,{isCurrent:le}),e.jsx("span",{className:"max-w-[10rem] truncate",children:F.name})]}):e.jsx(Je,{placeholder:"Node"})}),e.jsx(Ve,{children:ur(u,s)})]}),e.jsxs($e,{value:g,onValueChange:I=>w(I),children:[e.jsxs(qe,{className:L(K),"aria-label":"Agent",children:[e.jsx(At,{agent:g}),e.jsx("span",{children:g})]}),e.jsx(Ve,{children:Id()})]}),e.jsxs("div",{className:"relative ml-auto min-w-0 flex-1 sm:max-w-56",children:[e.jsx(Mo,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(dt,{value:T,onChange:I=>te(I.target.value),placeholder:"Filter sessions",className:"h-9 rounded-sm border-border/60 bg-background/60 pl-9 text-xs shadow-none"})]})]}),e.jsxs("div",{className:"px-3 py-3",children:[e.jsx("div",{className:"flex items-center justify-between px-1 pb-2",children:e.jsx(tt,{className:"text-[10px] font-medium uppercase tracking-[0.2em] text-muted-foreground",children:W?"Loading...":`${ie.length} session${ie.length===1?"":"s"}`})}),e.jsxs("div",{className:"relative h-88 overflow-hidden rounded-sm",children:[W&&e.jsx("div",{className:"absolute inset-x-0 top-0 z-10 h-0.5 overflow-hidden bg-primary/10",children:e.jsx("div",{className:"h-full w-1/3 animate-indeterminate-bar bg-primary/70"})}),e.jsxs("div",{className:"h-full space-y-1.5 overflow-y-auto pr-1",children:[!A&&e.jsx("div",{className:"rounded-sm border border-dashed border-border/60 bg-background/35 px-3 py-4 text-center text-[11px] text-muted-foreground",children:"Pick a node to load its recent sessions."}),A&&!W&&ie.length===0&&e.jsx("div",{className:"rounded-sm border border-dashed border-border/60 bg-background/35 px-3 py-4 text-center text-[11px] text-muted-foreground",children:P.length===0?"No recent sessions on this node. Use Manual session ID under More options.":"No sessions match your filter."}),ue.map(I=>e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>Z(I.cwd),"aria-expanded":!R.has(I.cwd),className:"sticky top-0 z-[1] flex w-full items-center gap-2 border-b border-border/50 bg-background/95 px-1 py-1.5 text-left text-[10px] text-muted-foreground backdrop-blur transition-colors hover:bg-background",children:[e.jsx(st,{className:L("h-3.5 w-3.5 shrink-0 transition-transform",R.has(I.cwd)&&"-rotate-90")}),e.jsx(rs,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:I.folderName}),e.jsxs("span",{className:"shrink-0 uppercase tracking-[0.16em]",children:[I.sessions.length," session",I.sessions.length===1?"":"s"]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right font-mono",children:I.cwd})]}),!R.has(I.cwd)&&I.sessions.map(se=>{const q=se.sessionId===b;return e.jsxs("button",{type:"button",onClick:()=>k(se.sessionId),className:L("flex w-full flex-col gap-1 rounded-sm border px-2.5 py-2 text-left transition-colors duration-200",q?"border-primary/45 bg-primary/9 shadow-none":"border-border/55 bg-background/40 hover:border-border hover:bg-background/65"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:L("h-2 w-2 shrink-0 rounded-full",q?"bg-primary":"bg-border")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",children:se.summary}),e.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.16em] text-muted-foreground",children:oh(se.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-4 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"font-mono",children:se.sessionId.slice(0,12)}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),e.jsx("span",{className:"truncate font-mono",children:se.cwd})]})]},se.sessionId)})]},I.cwd))]})]}),Y&&e.jsx("p",{className:"px-1 pt-2 text-[11px] text-destructive",children:Y})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>Q(I=>!I),className:"inline-flex h-6 items-center gap-1.5 rounded-sm px-1.5 text-[10px] font-medium uppercase tracking-[0.16em] text-muted-foreground transition-colors hover:bg-muted/45 hover:text-foreground","aria-expanded":S,children:[e.jsx("span",{className:"shrink-0",children:S?"Less options":"More options"}),e.jsx(st,{className:L("h-3.5 w-3.5 shrink-0 transition-transform",S&&"rotate-180")})]}),S&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/30 p-2.5",children:[e.jsxs("div",{className:"grid gap-2.5 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(tt,{htmlFor:"native-session-id",className:"text-[10px] font-medium text-muted-foreground",children:"Session ID"}),e.jsx(dt,{id:"native-session-id",type:"text",value:y,onChange:I=>{k(""),x(I.target.value)},placeholder:"ses_..., thread_..., or UUID",autoFocus:p,className:"h-7 rounded-sm border-border/70 bg-background/70 font-mono text-[11px] shadow-none"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(tt,{htmlFor:"native-session-title",className:"text-[10px] font-medium text-muted-foreground",children:"Task title"}),e.jsx(dt,{id:"native-session-title",type:"text",value:f,onChange:I=>j(I.target.value),placeholder:"Optional",className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none"})]})]}),e.jsx(Xn,{value:v,onChange:I=>{k(""),N(I)},assignTo:A,nodes:t,assignableNodes:u}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(tt,{className:"text-[10px] font-medium text-muted-foreground",children:"Mode"}),e.jsxs($e,{value:M,onValueChange:I=>B(I),children:[e.jsx(qe,{className:"h-7 rounded-sm border-border/70 bg-background/70 text-[11px] shadow-none",children:e.jsx(Je,{placeholder:"Select mode"})}),e.jsx(Ve,{children:ah()})]})]})]})]}),e.jsxs("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",c),children:[i&&e.jsx(X,{type:"button",variant:"ghost",onClick:i,className:"rounded-sm",children:m}),e.jsx(X,{type:"submit",disabled:!ee||D,className:"rounded-sm px-5",children:D?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"h-4 w-4 animate-spin"})," Loading..."]}):d})]})]})}const Ns="__agent-default__";function Pi({agent:t,value:n,onChange:s,triggerClassName:r,contentClassName:a="max-h-80",chip:i=!1}){const l=Uo(t,n);return o.useEffect(()=>{n&&!Vo(t,n)&&s("")},[t,n,s]),e.jsxs($e,{value:n||Ns,onValueChange:c=>s(c===Ns?"":c),children:[e.jsx(qe,{"aria-label":`Model: ${l}`,title:`Model: ${l}`,className:r,children:i?e.jsxs(e.Fragment,{children:[e.jsx(Yo,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:l})]}):e.jsx(Je,{placeholder:"Agent default"})}),e.jsxs(Ve,{className:a,children:[e.jsx(Oe,{value:Ns,className:"py-1 text-[11px]",children:"Agent default"}),Rd(t)]})]})}function mh(t){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Model"}),e.jsx(Pi,{...t,triggerClassName:"h-8 rounded-sm border-border/70 bg-background/70"})]})}function Ii(t,n,s=!1){const r=t.trim();if(r)return r;const a=n.trim().split(`
|
|
189
|
-
`).map(i=>i.trim()).find(Boolean);return a?a.length>72?`${a.slice(0,69).trimEnd()}...`:a:s?"Image task":""}function hh(t){const n=t.title.trim(),s=Ho(t.agent,t.description),r=s.prompt,a=Ii(t.title,r,t.images.length>0),i=r.trim()||a,l=t.mode??Mn,c=t.model?.trim(),d=c&&Vo(t.agent,c)?c:"",m=s.isGoal?s.commandPrompt:r,p=zo(m,t.images);return!a||!i||!t.agent?null:{title:a,description:i,agent:t.agent,project:t.project.trim()||null,branch:t.branch?.trim()||null,payload:{initialMessage:p,mode:l,...d?{model:d}:{},...s.isGoal?{goal:!0}:{},titleSource:n?"manual":"derived"},priority:t.priority,assignTo:t.assignTo==="auto"?void 0:t.assignTo}}function fh({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,className:d,footerClassName:m,submitLabel:p="Create chat",cancelLabel:u="Cancel",autoFocus:h=!1,layout:f="default",defaultTaskAgent:j,quickChats:g=[]}){const[w,b]=o.useState(""),[k,y]=o.useState(""),[x,v]=o.useState(0),[N,A]=o.useState(()=>Un(j)),E=o.useRef(!1),[M,B]=o.useState(""),[D,_]=o.useState(Mn),[P,O]=o.useState(i?.trim()??""),W=o.useRef(i!==void 0),[J,Y]=o.useState(""),V=o.useMemo(()=>_i(t,{currentNodeRole:n,leaderNodeId:r}),[t,n,r]),ne=o.useMemo(()=>a&&V.some(re=>re.id===a)?a:s&&V.some(re=>re.id===s)?s:V[0]?.id??"",[V,s,a]),[$,ee]=o.useState(ne),[S,Q]=o.useState(!1),[T,te]=o.useState(!1),{images:R,error:H,fileInputRef:F,pickImages:le,handleFileChange:ie,handlePaste:ue,removeImage:Z}=oi(),K=o.useRef(null),I=o.useMemo(()=>V.find(re=>re.id===$)??null,[$,V]),se=!!(s&&I?.id===s),q=kt(N),ae=Ld(D),ye=o.useMemo(()=>Ho(N,k),[N,k]),pe=o.useMemo(()=>$o(N,k),[N,k]),Ze=ye.prompt,Ae=o.useMemo(()=>ye.isGoal||pe?[]:g,[ye.isGoal,pe,g]);o.useEffect(()=>{$&&V.some(re=>re.id===$)||ee(ne)},[$,V,ne]),o.useEffect(()=>{E.current||A(Un(j))},[j]);const ft=o.useCallback(re=>{E.current=!0,A(Un(re))},[]);o.useEffect(()=>{if(W.current){W.current=!1;return}O(Di($)),Y("")},[$]),o.useEffect(()=>{Y("")},[P]),o.useEffect(()=>{v(0)},[k,g,N]);const Re=o.useCallback(re=>{y(re.prompt)},[]),De=o.useCallback(()=>{y(pe?.value??"/goal "),v(0),!(typeof window>"u")&&window.setTimeout(()=>{const re=K.current;re?.focus();const Ne=re?.value.length??0;re?.setSelectionRange(Ne,Ne)},0)},[pe]),He=o.useCallback(async re=>{if(re.preventDefault(),pe){De();return}const Ne=Wn(k,Ae,x);if(Ne){Re(Ne);return}const Te=hh({title:w,description:k,agent:N,model:M,project:P,branch:J,priority:"normal",assignTo:$,mode:D,images:R});if(Te){Q(!0);try{const ve=await ic(Te);l(ve)}catch(ve){ce.error(ve instanceof Error?ve.message:"Failed to create task")}finally{Q(!1)}}},[w,k,N,M,P,J,$,D,R,l,Ae,x,Re,pe,De]),Ke=Ii(w,Ze,R.length>0),je=!pe&&!!(Ke&&N&&$&&(Ze.trim()||R.length>0)),Be=o.useCallback(re=>{if(re.nativeEvent.isComposing)return;if(pe&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault();return}const Ne=No(k,Ae);if(Ne.length>0&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault(),v(Te=>ko(Te,Ne.length,re.key==="ArrowDown"?1:-1));return}if(re.key==="Enter"){if(pe&&!re.shiftKey){re.preventDefault(),De();return}const Te=Wn(k,Ae,x);if(Te&&!re.shiftKey){re.preventDefault(),Re(Te);return}}re.key==="Enter"&&(re.ctrlKey||re.metaKey)&&je&&!S&&(re.preventDefault(),re.currentTarget.form?.requestSubmit())},[De,Re,Ae,je,k,pe,x,S]),G=R.length>0?e.jsx(Gm,{images:R,removeImage:Z}):null,ge=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Assign to"}),e.jsxs($e,{value:$,onValueChange:ee,children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select node"})}),e.jsx(Ve,{children:ur(V,s)})]})]}),be=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Agent"}),e.jsxs($e,{value:N,onValueChange:ft,children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select agent"})}),e.jsx(Ve,{children:ra()})]})]}),et=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Mode"}),e.jsxs($e,{value:D,onValueChange:re=>_(re),children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select mode"})}),e.jsx(Ve,{children:aa()})]})]}),_e=e.jsx(Xn,{value:P,onChange:O,assignTo:$,nodes:t,assignableNodes:V}),rt=e.jsx(ha,{value:J,onChange:Y,project:P,assignTo:$,nodes:t,assignableNodes:V});return f==="composer"?e.jsxs("form",{onSubmit:He,className:L("space-y-4",d),children:[e.jsx("input",{ref:F,type:"file",accept:"image/*",multiple:!0,onChange:ie,className:"hidden"}),(()=>{const re="chat-composer__chip h-9 min-w-0 w-auto gap-1.5 rounded-sm px-3.5 text-xs shadow-none transition-colors [&>span]:min-w-0",Ne="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",Te="border-border/70 bg-background/55 text-foreground",ve=N===Un(j),at=D===Mn;return e.jsxs("div",{className:"chat-composer space-y-2",children:[e.jsxs("div",{className:"chat-composer__card rounded-sm border border-border/60 bg-background/54 shadow-none backdrop-blur-xl",children:[e.jsxs("div",{className:"chat-composer__header flex min-w-0 items-center justify-between gap-3 px-4 pt-3",children:[e.jsxs($e,{value:$,onValueChange:ee,children:[e.jsx(qe,{className:L(re,Te,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${I?.name??"unassigned"}`,"aria-label":`Assigned node: ${I?.name??"unassigned"}`,children:I?e.jsxs(e.Fragment,{children:[e.jsx(Pr,{isCurrent:se}),e.jsx("span",{className:"min-w-0 truncate",children:I.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:se?"current":"remote"})]}):e.jsx(Je,{placeholder:"Select node"})}),e.jsx(Ve,{children:ur(V,s)})]}),T?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(dt,{id:"task-title-composer",type:"text",value:w,onChange:Pe=>b(Pe.target.value),onKeyDown:Pe=>{(Pe.key==="Enter"||Pe.key==="Escape")&&(Pe.preventDefault(),te(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-sm border-border/70 bg-background/55 px-3 text-xs shadow-none"}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>te(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(En,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>te(!0),className:"chat-composer__title-button flex min-w-0 items-center gap-1.5 rounded-sm px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",title:Ke||"Title","aria-label":Ke?`Edit title: ${Ke}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:Ke||"Title"}),e.jsx(Jt,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",ref:K,value:k,onChange:Pe=>y(Pe.target.value),onKeyDown:Be,onPaste:ue,placeholder:"Ask anything...",rows:4,autoFocus:h,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-sm bg-transparent px-5 pt-2 pb-2 text-xs leading-5 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsx(ma,{agent:N,query:k,onSelect:De}),e.jsx(Xs,{query:k,quickChats:Ae,selectedIndex:x,onActiveIndexChange:v,onSelect:Re}),e.jsxs("div",{className:"chat-composer__rail flex min-w-0 flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:le,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(or,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs($e,{value:N,onValueChange:ft,children:[e.jsxs(qe,{className:L(re,"chat-composer__icon-trigger",ve?Ne:Te),title:`Agent: ${q}`,"aria-label":`Agent: ${q}`,children:[e.jsx(At,{agent:N}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:q})]}),e.jsx(Ve,{children:ra()})]}),e.jsx(Pi,{agent:N,value:M,onChange:B,chip:!0,triggerClassName:L(re,"chat-composer__icon-trigger",M?Te:Ne),contentClassName:"max-h-80 shadow-none"}),e.jsxs($e,{value:D,onValueChange:Pe=>_(Pe),children:[e.jsxs(qe,{className:L(re,"chat-composer__icon-trigger",at?Ne:Te),title:`Mode: ${ae}`,"aria-label":`Mode: ${ae}`,children:[e.jsx(Fu,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:ae})]}),e.jsx(Ve,{children:aa()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[c&&e.jsxs(X,{type:"button",variant:"ghost",size:"sm",onClick:c,"aria-label":u,className:"chat-composer__cancel h-9 rounded-sm px-4 text-xs text-muted-foreground",children:[e.jsx(ut,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:u})]}),e.jsxs(X,{type:"submit",size:"icon",disabled:!je||S,className:"h-10 w-10 rounded-sm shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[S?e.jsx(he,{className:"h-4 w-4 animate-spin"}):e.jsx(si,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:S?"Creating chat":p})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const Pe="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(Xn,{value:P,onChange:O,assignTo:$,nodes:t,assignableNodes:V,layout:"composer",chipClassName:re,chipActiveClassName:Pe,chipInactiveClassName:Pe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(ha,{value:J,onChange:Y,project:P,assignTo:$,nodes:t,assignableNodes:V,layout:"composer",chipClassName:re,chipActiveClassName:Pe,chipInactiveClassName:Pe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(G||H)&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/45 p-2.5",children:[G,H&&e.jsx("div",{className:"text-[11px] text-destructive",children:H}),!H&&e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Paste screenshots directly into the prompt box or use the Images button."})]})]}):e.jsxs("form",{onSubmit:He,className:L("space-y-4",d),children:[e.jsx("input",{ref:F,type:"file",accept:"image/*",multiple:!0,onChange:ie,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{htmlFor:"task-description",className:"text-[11px] font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",ref:K,value:k,onChange:re=>y(re.target.value),onKeyDown:Be,onPaste:ue,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:h,className:"flex min-h-[128px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-sm border border-border/70 bg-background/70 px-3 py-2 text-xs leading-5 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),e.jsx(ma,{agent:N,query:k,onSelect:De}),e.jsx(Xs,{query:k,quickChats:Ae,selectedIndex:x,onActiveIndexChange:v,onSelect:Re}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(X,{type:"button",variant:"outline",onClick:le,className:"rounded-sm",children:[e.jsx(or,{className:"h-4 w-4"}),"Add images"]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Upload or paste screenshots and reference images with the opening prompt."})]}),G,H&&e.jsx("p",{className:"text-[11px] text-destructive",children:H})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_170px_190px_150px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{htmlFor:"task-title",className:"text-[11px] font-medium",children:"Chat title"}),e.jsx(dt,{id:"task-title",type:"text",value:w,onChange:re=>b(re.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-8 rounded-sm border-border/70 bg-background/70"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:Ke?`Will appear as: ${Ke}`:"A title will be generated from the first line of the prompt."})]}),be,e.jsx(mh,{agent:N,value:M,onChange:B}),et]}),_e,rt,ge,e.jsxs("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",m),children:[c&&e.jsx(X,{type:"button",variant:"ghost",onClick:c,className:"rounded-sm",children:u}),e.jsx(X,{type:"submit",disabled:!je||S,className:"rounded-sm px-5",children:S?"Creating...":p})]})]})}function ph({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,defaultMode:d="chat",mode:m,onModeChange:p,layout:u="default",className:h,footerClassName:f,autoFocus:j=!1,quickChats:g=[],defaultTaskAgent:w}){const[b,k]=o.useState(d),y=m!==void 0,x=y?m:b,v=N=>{y||k(N),p?.(N)};return e.jsxs("div",{className:L("space-y-4",h),children:[!y&&e.jsxs("div",{className:"flex h-8 items-center gap-0.5 rounded-sm border border-border/60 bg-background/45 p-0.5",children:[e.jsxs(X,{type:"button",variant:x==="chat"?"default":"ghost",onClick:()=>v("chat"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(oc,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(X,{type:"button",variant:x==="native"?"default":"ghost",onClick:()=>v("native"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(Ar,{className:"h-4 w-4"}),"Load session"]})]}),x==="chat"?e.jsx(fh,{nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,footerClassName:f,submitLabel:u==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:j,layout:u,defaultTaskAgent:w,quickChats:g},`${a??""}:${i??""}`):e.jsx(uh,{nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,onCreated:l,onCancel:c,footerClassName:f,autoFocus:j})]})}function xh({onClick:t,running:n}){return e.jsxs(X,{size:"icon",onClick:t,"aria-label":n?"Open composer - task running":"Open composer",title:n?"Task running - open composer":"Open composer",className:L("absolute bottom-4 right-4 z-10 h-12 w-12 overflow-visible rounded-lg shadow-lg",n&&"animate-soft-status-pulse bg-primary/90 text-primary-foreground hover:bg-primary"),children:[e.jsx(Jt,{className:"h-4 w-4"}),n&&e.jsx("span",{"aria-hidden":"true","data-running-indicator":"true",className:"pointer-events-none absolute right-1.5 top-1.5 h-2 w-2 rounded-full bg-primary-foreground shadow-[0_0_0_2px_hsl(var(--primary))]"})]})}function pa({children:t}){return e.jsxs("div",{className:"agent-progress-banner animate-message-receive flex items-center gap-1.5 rounded-lg bg-transparent px-1 py-1 text-[11px]",children:[e.jsx("span",{className:"agent-progress-terminal-spinner h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("div",{className:"agent-progress-sweep-text min-w-0 leading-5",children:t})]})}function gh({hasVisibleTranscriptEvents:t,hasTranscriptProgress:n,inputCollapsed:s}){return{collapsedButtonRunning:n&&t&&s,showDockedProgress:n&&t&&!s,showInlineProgress:n&&!t}}const cn="72f988bf-86f1-41af-91ab-2d7cd011db47",Ri=`${cn} (MSIT)`;function bh({open:t,onOpenChange:n,onShare:s,onStopShare:r,sharing:a,stopping:i=!1,shareResult:l}){return e.jsx(mt,{open:t,onOpenChange:n,children:e.jsxs(ht,{className:"max-w-md rounded-sm p-4",children:[e.jsx(vt,{className:"sr-only",children:"Share conversation"}),e.jsx(vh,{onOpenChange:n,onShare:s,onStopShare:r,sharing:a,stopping:i,shareResult:l})]})})}function vh({onOpenChange:t,onShare:n,onStopShare:s,sharing:r,stopping:a=!1,shareResult:i}){const[l,c]=o.useState(i?.tenant??cn),[d,m]=o.useState(i?.scope??"chat"),p=i?.url?Do(i.url):null,u=r||a;return o.useEffect(()=>{c(i?.tenant??cn),m(i?.scope??"chat")},[i?.shareId,i?.tenant,i?.scope]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-sm font-semibold leading-none tracking-tight",children:"Share conversation"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Create a tenant-gated link for this task."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(wh,{value:l,onChange:c,disabled:u}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Access"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(xa,{active:d==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>m("chat")}),e.jsx(xa,{active:d==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>m("filesPreview")})]})]}),p&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Shared link"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-border/70 bg-muted/30 px-3 py-2",children:[e.jsx("input",{readOnly:!0,value:p,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground",onClick:()=>{In(p,"Shared link copied")},"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(_o,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(X,{variant:"outline",onClick:()=>t(!1),disabled:u,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&s&&e.jsxs(X,{variant:"outline",onClick:()=>{s()},disabled:u,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[a&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(X,{onClick:()=>{n({tenant:l,scope:d})},disabled:u,className:"h-8 text-xs",children:[r&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function wh({value:t,onChange:n,disabled:s}){const[r,a]=o.useState(!1),[i,l]=o.useState(!1),[c,d]=o.useState(t),m=o.useRef(null);o.useEffect(()=>{d(t)},[t]),o.useEffect(()=>{if(!r)return;const u=f=>{const j=f.target;j instanceof Node&&(m.current?.contains(j)||(a(!1),l(!1)))},h=f=>{f.key==="Escape"&&(a(!1),l(!1))};return document.addEventListener("mousedown",u),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",h)}},[r]);const p=u=>{const h=u.trim();h&&(n(h),d(h),l(!1),a(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:m,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!s&&a(u=>!u),disabled:s,className:"flex h-9 w-full items-center justify-between gap-2 rounded-sm border border-border/70 bg-background/70 px-3 text-left text-xs text-foreground shadow-sm outline-none transition-colors hover:bg-background disabled:opacity-50",children:[e.jsx("span",{className:"min-w-0 truncate font-mono",children:yh(t)}),e.jsx(st,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),r&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-sm border border-border/60 bg-background/95 text-xs shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>p(cn),className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left hover:bg-background/60",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-[11px]",children:Ri}),t===cn&&e.jsx(En,{className:"h-3.5 w-3.5 shrink-0 text-primary"})]}),e.jsx("div",{className:"border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:i?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:c,onChange:u=>d(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),p(c))},autoFocus:!0,placeholder:"Tenant ID",className:"h-7 min-w-0 flex-1 rounded-sm border border-border/60 bg-background/70 px-2 font-mono text-[11px] outline-none focus:ring-2 focus:ring-ring"}),e.jsx("button",{type:"button",onClick:()=>p(c),className:"flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background/60",children:e.jsx(En,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{d(t),l(!1)},className:"flex h-7 w-7 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",children:e.jsx(ut,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>l(!0),className:"flex h-7 w-full items-center justify-between rounded-sm px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx("span",{children:"Manual tenant ID"}),e.jsx(Jt,{className:"h-3 w-3"})]})})]})]})]})}function yh(t){return t===cn?Ri:t}function xa({active:t,title:n,description:s,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,className:t?"rounded-sm border border-primary/45 bg-primary/10 px-3 py-2 text-left shadow-sm":"rounded-sm border border-border/70 bg-background px-3 py-2 text-left shadow-sm hover:bg-muted/50",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:n}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:s})]})}function jh(t){const n=t.map(s=>s.type==="text"?s.text:s.type==="image"?s.filename?`Image: ${s.filename}`:"Image attachment":s.isError?`Tool result error: ${s.content}`:`Tool result: ${s.content}`).join(" ").replace(/\s+/g," ").trim();return n?n.length>160?`${n.slice(0,157)}...`:n:"Queued follow-up"}function Nh({messages:t,onCancelMessage:n}){return t.length===0?null:e.jsx("div",{className:"border-t border-border/55 bg-card/30 px-3 py-2 sm:px-5",children:e.jsxs("div",{className:"mx-auto max-w-[72rem] rounded-sm border border-border/65 bg-background/58 px-3 py-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium text-foreground",children:[e.jsx(ku,{className:"h-3.5 w-3.5 text-primary"}),"Queued messages",e.jsx("span",{className:"ml-auto rounded-sm border border-border/60 bg-muted/60 px-1.5 py-0 text-[10px] text-muted-foreground",children:t.length})]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:t.map((s,r)=>{const a=s.content.filter(i=>i.type==="image");return e.jsxs("div",{className:"flex min-w-0 items-start gap-2 text-[11px] leading-5 text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-[10px] font-medium text-primary",children:r+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[s.targetAgent&&e.jsxs("div",{"data-queued-message-target-agent":s.targetAgent,className:"mb-0.5 inline-flex h-5 max-w-[11rem] items-center gap-1 rounded-sm bg-primary/10 px-1.5 text-[10px] leading-3 text-primary",title:`Send to ${kt(s.targetAgent)}`,children:[e.jsx(Qo,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(At,{agent:s.targetAgent,className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:kt(s.targetAgent)})]}),e.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:jh(s.content)}),a.length>0&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:a.map((i,l)=>e.jsx(Sr,{image:i,alt:i.filename??`queued attachment ${l+1}`,thumbnailClassName:"h-14 w-14 border border-border/65",imageClassName:"h-full w-full"},`${i.filename??"image"}-${l}`))})]}),n&&e.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 rounded-sm text-muted-foreground hover:text-destructive",title:"Cancel queued message","aria-label":"Cancel queued message",onClick:()=>n(s.id),children:e.jsx(ut,{className:"h-3 w-3"})})]},s.id)})})]})})}const kh="h-6 w-6 rounded-none border-b border-transparent !bg-transparent p-0 text-muted-foreground !shadow-none hover:text-foreground data-[state=active]:border-primary data-[state=active]:!bg-transparent data-[state=active]:text-primary data-[state=active]:!shadow-none",Sh=[{value:"transcript",label:"Transcript",icon:lc},{value:"files",label:"Files",icon:hn,activeIcon:rs},{value:"diff",label:"Diff",icon:Yn},{value:"preview",label:"Preview",icon:Gd}];function Ch({activeTab:t}){return e.jsx(os,{className:"h-auto max-w-full justify-start gap-2 overflow-x-auto rounded-sm !bg-muted/40 !p-0.5 !shadow-none",children:Sh.map(n=>{const s=n.value===t&&n.activeIcon?n.activeIcon:n.icon;return e.jsx(Ot,{value:n.value,title:n.label,"aria-label":n.label,className:kh,children:e.jsx(s,{className:"h-3.5 w-3.5","aria-hidden":"true"})},n.value)})})}const Li="pointer-events-auto h-5 w-5 shrink-0 rounded-sm bg-muted/65 text-muted-foreground hover:bg-muted hover:text-foreground",es="h-3.5 w-3.5";function mr({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,centerSlot:i}){return e.jsxs("div",{className:"relative flex w-full items-center justify-between gap-1.5",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:e.jsx(Bi,{desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:t,className:"lg:hidden"})}),i&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:e.jsx("div",{className:"pointer-events-auto",children:i})}),e.jsx(Oi,{operationsOpen:r,onToggleOperations:a,className:"xl:hidden"})]})}function Bi({className:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:r}){const a=globalThis.window?.matchMedia("(min-width: 1024px)")?.matches?n:s;return e.jsx(X,{variant:"ghost",size:"icon",onClick:r,title:a?"Hide tasks":"Show tasks","aria-label":a?"Hide tasks":"Show tasks",className:L(Li,t),children:a?e.jsx(Dn,{className:es}):e.jsx(nt,{className:es})})}function Oi({className:t,operationsOpen:n,onToggleOperations:s}){return e.jsx(X,{variant:"ghost",size:"icon",onClick:s,title:n?"Hide cluster":"Show cluster","aria-label":n?"Hide cluster":"Show cluster",className:L(Li,t),children:n?e.jsx(nt,{className:es}):e.jsx(Dn,{className:es})})}const ga="h-7 w-7 rounded-sm border-0 bg-primary/10 text-primary backdrop-blur hover:bg-primary/20 hover:text-primary";function Th({active:t,onScrollToBottom:n,onScrollToTop:s}){return e.jsxs("div",{className:L("pointer-events-none absolute right-3 top-1/2 z-10 flex -translate-y-1/2 flex-col gap-2 opacity-0 transition-opacity duration-200 group-hover:pointer-events-auto group-hover:opacity-100",t&&"pointer-events-auto opacity-100"),children:[e.jsx(X,{type:"button",variant:"ghost",size:"icon",className:ga,onClick:s,"aria-label":"Scroll to top",title:"Scroll to top",children:e.jsx(cc,{className:"h-4 w-4"})}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",className:ga,onClick:n,"aria-label":"Scroll to bottom",title:"Scroll to bottom",children:e.jsx(st,{className:"h-4 w-4"})})]})}function Ah(t){if(t.type!=="agent.handoff")return null;const n=typeof t.fromAgent=="string"&&t.fromAgent.trim()?t.fromAgent.trim():"agent",s=typeof t.toAgent=="string"&&t.toAgent.trim()?t.toAgent.trim():"";return s?{fromAgent:n,toAgent:s}:null}function Eh({fromAgent:t,toAgent:n}){return e.jsx("div",{className:"flex w-full justify-center py-0.5","data-agent-handoff":n,children:e.jsxs("div",{className:"inline-flex h-6 max-w-full items-center gap-1.5 rounded-sm border border-border/45 bg-muted/22 px-2 text-[10px] leading-3 text-muted-foreground/78",children:[e.jsx(At,{agent:t,className:"h-3 w-3 shrink-0 text-muted-foreground/65","aria-hidden":"true"}),e.jsxs("span",{className:"truncate",children:[kt(t)," to ",kt(n)]}),e.jsx(At,{agent:n,className:"h-3 w-3 shrink-0 text-primary/60","aria-hidden":"true"})]})})}const ba="h-[1.625rem] rounded-sm !border-0 !bg-transparent px-2 text-[10.5px] font-medium text-primary !shadow-none hover:!bg-transparent hover:text-primary/80 focus-visible:ring-1 focus-visible:ring-ring/50 focus-visible:ring-offset-0",Ut={content:"max-w-[20rem] gap-2.5 rounded-lg border-0 p-3.5 shadow-[0_18px_70px_-44px_rgba(0,0,0,0.72)] sm:max-w-[20rem]",header:"space-y-1 text-left",title:"text-[13px] leading-4",description:"text-[11px] leading-4",footer:"gap-1 pt-0 sm:space-x-1",cancel:`${ba} mt-0`,action:ba},Mh=30,Dh=1600;function _h({savedScrollTop:t,scrollHeight:n,clientHeight:s}){const r=Math.max(0,n-s);return Math.min(Math.max(0,t??r),r)}function ks(t){return t.scrollHeight-t.scrollTop-t.clientHeight<Mh}function va({explicitBottomStickUntil:t,now:n,wasAtBottom:s}){return s||t>n}function Ss(t,n){return!!(n&&(t===n||t.contains(n)))}function Cs(t){const n=t.ownerDocument.getSelection();if(!n||n.isCollapsed||n.rangeCount===0)return!1;if(Ss(t,n.anchorNode)||Ss(t,n.focusNode))return!0;for(let s=0;s<n.rangeCount;s+=1)if(Ss(t,n.getRangeAt(s).commonAncestorContainer))return!0;return!1}function Ph({atTop:t,inputCollapseDisabled:n,scrollingUp:s}){return!n&&(s||t)}function Ih({activeTab:t,activeTaskId:n,contentVersion:s,inputCollapseDisabled:r=!1,setActiveTab:a,setInputCollapsed:i}){const l=o.useRef(null),c=o.useRef(n),d=o.useRef(!1),m=o.useRef(0),p=o.useRef(new Map),u=o.useRef(0),h=o.useRef(!0),f=o.useCallback((x=c.current)=>{const v=l.current;!v||!x||(p.current.set(x,v.scrollTop),m.current=v.scrollTop,h.current=ks(v))},[]),j=o.useCallback((x=c.current)=>{const v=l.current;!v||!x||(v.scrollTop=_h({savedScrollTop:p.current.get(x),scrollHeight:v.scrollHeight,clientHeight:v.clientHeight}),m.current=v.scrollTop,h.current=ks(v))},[]),g=o.useCallback((x,v=c.current)=>{x.scrollTop=x.scrollHeight,m.current=x.scrollTop,h.current=!0,v&&p.current.set(v,x.scrollTop)},[]),w=o.useCallback((x=c.current)=>{const v=l.current;u.current=Date.now()+Dh,v&&(g(v,x),requestAnimationFrame(()=>{g(v,x),requestAnimationFrame(()=>g(v,x))}))},[g]),b=o.useCallback((x=c.current)=>{const v=l.current;u.current=0,v&&(v.scrollTop=0,m.current=0,h.current=!1,x&&p.current.set(x,0))},[]),k=o.useCallback(x=>{const v=x.currentTarget,N=m.current,A=v.scrollTop<N&&N-v.scrollTop>10,E=v.scrollTop<=0,M=Cs(v);if(f(),M){u.current=0;return}if(!d.current){if(ks(v)){i(!1),d.current=!0,setTimeout(()=>{d.current=!1},300);return}(A||E)&&(u.current=0,Ph({atTop:E,inputCollapseDisabled:r,scrollingUp:A})&&i(!0))}},[r,f,i]),y=o.useCallback(x=>{t==="transcript"&&f(),a(x),x==="transcript"&&requestAnimationFrame(()=>j())},[t,j,f,a]);return o.useLayoutEffect(()=>{r&&i(!1)},[r,i]),o.useLayoutEffect(()=>{const x=c.current;x&&x!==n&&f(x),c.current=n,t==="transcript"&&requestAnimationFrame(()=>j(n))},[n,t,j,f]),o.useLayoutEffect(()=>{const x=l.current;if(!x||t!=="transcript"||!n)return;const v=va({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:h.current});if(Cs(x)){u.current=0,f(n);return}v&&g(x,n),f(n)},[n,t,s,f,g]),o.useLayoutEffect(()=>{const x=l.current,v=x?.firstElementChild;if(!x||!v||t!=="transcript"||typeof ResizeObserver>"u")return;const N=new ResizeObserver(()=>{if(Cs(x)){u.current=0,f();return}va({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:h.current})?g(x):f()});return N.observe(x),N.observe(v),()=>N.disconnect()},[t,n,f,g]),{handleTranscriptScroll:k,handleTranscriptTabChange:y,scrollTranscriptToBottom:w,scrollTranscriptToTop:b,transcriptScrollRef:l}}function Fi(t=700){const[n,s]=o.useState(!1),r=o.useRef(null),a=o.useCallback(()=>{s(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>{s(!1),r.current=null},t)},[t]);return o.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),{markScrollbarActive:a,scrollbarActive:n}}const Rh="harness";function Lh(t){return typeof t=="object"&&t!==null}function Bh(t){return typeof t=="string"&&t.trim().length>0?t.trim():""}function Oh(t){return Lh(t.agentSessions)?Object.keys(t.agentSessions).map(n=>n.trim()).filter(Boolean):[]}function zi(t){return Bh(t.payload.activeAgent)||t.agent}function Ui(t){return new Set([t.agent,zi(t),...Oh(t.payload)].filter(Boolean)).size>1}function $i(t){return Ui(t)?Rh:t.agent}const Fh=o.lazy(async()=>({default:(await gr(()=>import("./FilesTab-BoVqZxQh.js"),__vite__mapDeps([0,1,2,3,4,5]))).FilesTab})),zh=o.lazy(async()=>({default:(await gr(()=>import("./PreviewTab-C06qRxmn.js").then(n=>n.c),__vite__mapDeps([6,1,2]))).PreviewTab})),Uh=o.lazy(async()=>({default:(await gr(()=>import("./DiffTab-BQegvnuJ.js"),__vite__mapDeps([7,1,2,5,4,3,6]))).DiffTab}));function $h({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,activeTab:l,setActiveTab:c,creatingTask:d,createMode:m,createDefaults:p,activeTask:u,assignedNode:h,taskLoading:f,transcriptLoading:j,taskError:g,displayEvents:w,initialPromptAlreadyInLogs:b,initialPrompt:k,supportsFollowUp:y,taskUnavailable:x,chatDisabled:v,chatDisabledReason:N,questionBypassEnabled:A,isRunning:E,isStarting:M,hasPendingFollowUp:B,canCancel:D,canRetry:_,onRetry:P,onCancel:O,onReloadNativeTranscript:W,onShareTask:J,onStopShareTask:Y,onStartCreateTask:V,onCancelCreateTask:ne,onCreateTask:$,onSendMessage:ee,onCancelQueuedMessage:S,onQuestionBypassChange:Q,onSubmitQuestionResponse:T,quickChats:te=[]}){const[R,H]=o.useState(!1),[F,le]=o.useState(!1),[ie,ue]=o.useState(!1),[Z,K]=o.useState(!1),[I,se]=o.useState(!1),[q,ae]=o.useState({}),[ye,pe]=o.useState(new Set),[Ze,Ae]=o.useState(new Set),[ft,Re]=o.useState(null),[De,He]=o.useState(null),Ke=u?.effectiveProjectPath??u?.project??"default workspace",je=u?h?.name??er(u.assignedTo,i?.nodes,u.assignedNodeName):"unassigned",Be=u?$i(u):"",G=u?zi(u):"",ge=u&&Ui(u)?G:void 0,be=u?.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-semibold",children:je}),"..."]}):"Connecting session to an available node...",et=u?[{label:"Working dir",value:Ke,mono:!0},...u.branch?[{label:"Branch",value:u.branch,mono:!0}]:[],{label:"Agent",value:Be,mono:!0},{label:"Node",value:je}]:[],_e=!!(k&&!b),rt=_e||w.length>0,re=E&&rt,Ne=(M||B||E)&&!re,Te=re?"The agent is still working on this conversation.":Ne?be:null,{collapsedButtonRunning:ve,showDockedProgress:at,showInlineProgress:Pe}=gh({hasTranscriptProgress:!!Te,hasVisibleTranscriptEvents:rt,inputCollapsed:R}),_t=u?.conversationKind==="nativeSession",pt=Bd(u),pn=j?"Loading transcript":_t?"No transcript imported":"Transcript is warming up",en=j?"Loading transcript...":_t?"Meshy could not find imported history for this native session yet.":"The opening prompt has been stored, but the agent has not emitted conversation output yet.",St=u?.queuedMessages??[],wt=o.useMemo(()=>Od(w),[w]),xn=o.useMemo(()=>{let me=u?.agent??"";return wt.map(ke=>{const Ge=Ah(ke.event);if(Ge)return me=Ge.toAgent,{...ke,agent:me,handoff:Ge};const Ue=typeof ke.event.agent=="string"&&ke.event.agent.trim()?ke.event.agent.trim():me;return{...ke,agent:Ue,handoff:null}})},[u?.agent,wt]),gn=o.useMemo(()=>{const me=u?.assignedTo?u.assignedTo===i?.self?.id?h?.supportedAgents??i.self.supportedAgents:h?.supportedAgents:i?.self?.supportedAgents;return dc({nodeSupportedAgents:me,taskAgent:u?.agent,activeAgent:typeof u?.payload.activeAgent=="string"?u.payload.activeAgent:void 0})},[h?.supportedAgents,i?.self?.id,i?.self?.supportedAgents,u?.assignedTo,u?.agent,u?.payload.activeAgent]),Pt=o.useMemo(()=>wt.findIndex(({event:me})=>qh(me)),[wt]),Ft=o.useMemo(()=>Fd("transcript",wt.map(me=>me.event)),[wt]),tn=u&&!ye.has(u.id)?q[u.id]??u.activeShare??null:null,Ct=u?.id??null,nn=`${Ct??"none"}:${w.length}:${St.length}:${_e?1:0}:${j?1:0}:${Pe?1:0}`,{handleTranscriptScroll:Fe,handleTranscriptTabChange:ot,scrollTranscriptToBottom:yt,scrollTranscriptToTop:Tt,transcriptScrollRef:U}=Ih({activeTab:l,activeTaskId:Ct,contentVersion:nn,inputCollapseDisabled:!!Te,setActiveTab:c,setInputCollapsed:H}),{markScrollbarActive:ze,scrollbarActive:Ie}=Fi(),We=o.useCallback(me=>{ze(),Fe(me)},[Fe,ze]),Qe=o.useCallback(me=>{Re(ke=>({path:me,requestId:(ke?.requestId??0)+1})),ot("files")},[ot]),sn=o.useCallback(me=>{He(ke=>({path:me,requestId:(ke?.requestId??0)+1})),ot("preview")},[ot]),xe=o.useCallback((me,ke)=>{yt(),ee(me,ke)},[ee,yt]);return o.useEffect(()=>{Re(null),He(null)},[Ct]),d?e.jsx(Vh,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:m,createDefaults:p,onCancel:ne,onCreated:$,quickChats:te}):!u&&f?e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(mr,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsxs("div",{className:"space-y-3 text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-sm border border-primary/20 bg-primary/10 text-primary shadow-none",children:e.jsx(he,{className:"h-5 w-5 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):u?e.jsxs(_r,{value:l,onValueChange:ot,className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsxs("div",{className:"dashboard-conversation-panel__header relative shrink-0 bg-card/28 px-3 pb-0.5 pt-1 sm:px-5 sm:pt-1.5",children:[e.jsxs("div",{className:"pointer-events-none absolute left-1 right-1 top-2 flex items-center justify-between sm:left-1.5 sm:right-1.5 sm:top-2.5",children:[e.jsx(Bi,{desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:t,className:"lg:hidden"}),e.jsx(Oi,{operationsOpen:r,onToggleOperations:a,className:"xl:hidden"})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 pl-5 sm:pl-6 lg:pl-0",children:[e.jsx("h2",{className:"min-w-0 truncate text-[13px] font-semibold leading-5 text-foreground sm:text-[15px]",title:u.title,children:u.title}),e.jsx(Io,{status:u.status,isNative:_t}),pt&&e.jsxs("span",{"data-task-goal-label":"true",title:"Codex goal",className:"inline-flex h-5 shrink-0 items-center gap-1 rounded-sm bg-primary/10 px-1.5 text-[9px] font-semibold uppercase tracking-[0.12em] text-primary",children:[e.jsx(qo,{className:"h-3 w-3","aria-hidden":"true"}),"Goal"]}),u.priority!=="normal"&&e.jsx(uc,{priority:u.priority})]}),g&&e.jsx("div",{className:"mt-2 w-fit rounded-sm border border-destructive/25 bg-destructive/10 px-2 py-1 text-[11px] text-destructive",children:g}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 pl-5 sm:pl-6 lg:pl-0",children:[e.jsx(Ch,{activeTab:l}),x&&e.jsx(Le,{variant:"outline",className:"hidden rounded-sm border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"hidden rounded-sm bg-muted/65 px-1.5 py-0.5 tabular-nums sm:inline-flex",children:mc(u.updatedAt)}),_&&e.jsxs(X,{variant:"ghost",size:"sm",onClick:P,"aria-label":"Retry task",title:"Retry task",className:"h-7 shrink-0 rounded-sm border-0 bg-primary/10 px-2 text-[10px] text-primary shadow-none hover:bg-primary/15 hover:text-primary",children:[e.jsx(hc,{className:"h-3.5 w-3.5"}),"Retry"]}),_t&&W&&e.jsx(X,{variant:"ghost",size:"icon",onClick:W,disabled:j,title:"Reload native session transcript","aria-label":"Reload native session transcript",className:"h-6 w-6 shrink-0 rounded-sm text-muted-foreground hover:bg-muted/55 hover:text-foreground",children:e.jsx(ni,{className:L("h-3.5 w-3.5",j&&"animate-spin")})}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",disabled:x,title:x?"Unavailable tasks cannot be shared.":"Share conversation","aria-label":x?"Unavailable tasks cannot be shared.":"Share conversation",className:"h-6 w-6 shrink-0 rounded-sm text-primary hover:bg-primary/10 hover:text-primary disabled:bg-transparent disabled:text-muted-foreground",onClick:()=>ue(!0),children:e.jsx(Zn,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsx(bt,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"group relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"relative min-h-0 flex-1",children:e.jsx("div",{ref:U,"data-transcript-scroll":"true",className:L("scrollbar-line h-full min-h-0 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-x-none bg-gradient-to-b from-background/15 via-transparent to-background/35 px-3 pb-4 pt-4 sm:px-5",Ie&&"scrollbar-line-active"),onScroll:We,children:e.jsxs("div",{"data-transcript-scroll-content":"true",className:"mx-auto flex max-w-[72rem] flex-col gap-4",children:[_e&&k&&e.jsx(oa,{event:k,agent:u.agent,sentAsGoal:pt,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Qe,questionBypassEnabled:A,onQuestionBypassChange:Q,onSubmitQuestionResponse:T,questionResponseDisabled:!y||v}),xn.map(({event:me,subItems:ke,agent:Ge,handoff:Ue},zt)=>Ue?e.jsx(Eh,{fromAgent:Ue.fromAgent,toAgent:Ue.toAgent},Ft[zt]):e.jsx(oa,{event:me,agent:Ge,subItems:ke,sentAsGoal:pt&&!_e&&zt===Pt,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Qe,questionBypassEnabled:A,onQuestionBypassChange:Q,onSubmitQuestionResponse:T,questionResponseDisabled:!y||v},Ft[zt])),!rt&&!Ne&&e.jsxs("div",{className:"rounded-sm border border-dashed border-border/70 bg-background/35 px-3 py-4 text-center",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:pn}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:en})]}),(!y&&u.result||u.error)&&e.jsxs("div",{className:"space-y-3",children:[!y&&u.result&&e.jsxs("div",{className:"rounded-sm border border-border/70 bg-card/80 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Stored result"}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5 text-muted-foreground",children:JSON.stringify(u.result,null,2)})]}),u.error&&!Ze.has(u.id)&&e.jsxs("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-3 text-destructive",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em]",children:"Stored error"}),e.jsx("button",{onClick:()=>Ae(me=>new Set(me).add(u.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(ut,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:u.error})]})]}),Pe&&Te&&e.jsx(pa,{children:Te})]})})}),e.jsx(Th,{active:Ie,onScrollToBottom:()=>yt(),onScrollToTop:()=>Tt()}),at&&Te&&e.jsx("div",{"data-docked-progress":"true",className:"shrink-0 bg-background/35 px-3 py-1 sm:px-5",children:e.jsx("div",{className:"mx-auto max-w-[72rem]",children:e.jsx(pa,{children:Te})})}),y?e.jsxs(e.Fragment,{children:[R&&e.jsx(xh,{running:ve,onClick:()=>{H(!1),yt(),requestAnimationFrame(()=>document.querySelector('[data-chat-input-textarea="true"]')?.focus())}}),e.jsxs("div",{className:`shrink-0 ${R?"hidden":""}`,children:[e.jsx(Nh,{messages:St,onCancelMessage:S}),e.jsx(jm,{onSend:xe,disabled:v,disabledReason:N,contextItems:et,agent:u.agent,currentAgent:ge,taskId:u.id,availableAgents:gn,model:typeof u.payload.model=="string"?u.payload.model:null,placeholder:v?N:E?"Queue a message for the next turn...":"Continue the conversation...",running:E||M||B,onStop:D?()=>le(!0):void 0,quickChats:te})]})]}):e.jsx("div",{className:"shrink-0 border-t border-border/60 px-3 py-3 text-[11px] text-muted-foreground sm:px-5",children:"This task does not expose follow-up chat messages. Use Files, Preview, or Diff to inspect the result."})]})}),e.jsx(bt,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(vs,{label:"Loading files..."}),children:e.jsx(Fh,{taskId:u.id,requestedFilePath:ft?.path??null,requestedFileRequestId:ft?.requestId??0,onPreviewFile:sn})})}),e.jsx(bt,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(vs,{label:"Loading preview..."}),children:e.jsx(zh,{taskId:u.id,requestedEntryPath:De?.path??null,requestedEntryRequestId:De?.requestId??0})})}),e.jsx(bt,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(vs,{label:"Loading diff..."}),children:e.jsx(Uh,{taskId:u.id})})}),e.jsx($t,{open:F,onOpenChange:le,children:e.jsxs(qt,{className:Ut.content,children:[e.jsxs(Vt,{className:Ut.header,children:[e.jsx(Ht,{className:Ut.title,children:"Stop this task?"}),e.jsx(Kt,{className:Ut.description,children:"The task will stop and move to a cancelled state."})]}),e.jsxs(Gt,{className:Ut.footer,children:[e.jsx(Wt,{className:Ut.cancel,children:"Keep running"}),e.jsx(Qt,{className:Ut.action,onClick:O,children:"Stop task"})]})]})}),e.jsx(bh,{open:ie,onOpenChange:ue,sharing:Z,stopping:I,shareResult:tn,onShare:async me=>{if(!u)return null;K(!0);try{const ke=await J(me);return ke?.url&&(ae(Ge=>({...Ge,[u.id]:ke})),pe(Ge=>{const Ue=new Set(Ge);return Ue.delete(u.id),Ue})),ke}finally{K(!1)}},onStopShare:async()=>{if(!u)return!1;se(!0);try{const me=await Y();return me!==!1&&(ae(ke=>{const Ge={...ke};return delete Ge[u.id],Ge}),pe(ke=>new Set(ke).add(u.id))),me}finally{se(!1)}}})]}):e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(mr,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsxs("div",{className:"w-full max-w-lg text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-sm border border-primary/20 bg-primary/10 text-primary shadow-none",children:e.jsx(Po,{className:"h-5 w-5"})}),e.jsx("h2",{className:"mt-3 text-sm font-semibold tracking-tight text-foreground sm:text-[15px]",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-2 max-w-md text-[11px] leading-5 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task or load a native session."}),e.jsxs(X,{onClick:()=>V(),className:"mt-4 h-8 rounded-sm px-3",children:[e.jsx(Ln,{className:"h-3.5 w-3.5"}),"Start or load chat"]}),g&&e.jsx("div",{className:"mx-auto mt-3 max-w-md rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:g})]})})]})}function qh(t){return t.type!=="user"||t.isMeta===!0||t.isSidechain===!0?!1:!!Cr(t)?.some(s=>s.type==="text"||s.type==="image")}function Vh({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:l,createDefaults:c,onCancel:d,onCreated:m,quickChats:p}){const[u,h]=o.useState(l??"chat");o.useEffect(()=>{l&&h(l)},[l]);const f=e.jsx("div",{className:"flex h-8 items-center gap-0.5 overflow-hidden rounded-sm border border-border/60 bg-background/65 p-0.5 text-[11px] font-medium shadow-none",children:[{value:"chat",label:"New chat",icon:Ln},{value:"native",label:"Load session",icon:Ar}].map(j=>{const g=j.icon,w=j.value===u;return e.jsxs("button",{type:"button",onClick:()=>h(j.value),"aria-pressed":w,className:L("flex h-7 min-w-28 items-center justify-center gap-1.5 rounded-sm border border-transparent px-2.5 transition-colors duration-150",w?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(g,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:j.label})]},j.value)})});return e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(mr,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,centerSlot:f})}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(ph,{nodes:i?.nodes??[],currentNodeRole:i?.self?.role,currentNodeId:i?.self?.id??null,leaderNodeId:i?.leader?.id??null,initialAssignTo:c?.assignTo,initialProject:c?.project,mode:u,onModeChange:h,onCreated:m,onCancel:d,autoFocus:!0,layout:"composer",defaultTaskAgent:i?.self.settingsSnapshot?.defaultTaskAgent,quickChats:p})})})]})}function Hh({onAdded:t}){const[n,s]=o.useState(""),[r,a]=o.useState(!1),[i,l]=o.useState(null),c=o.useCallback(async d=>{if(d.preventDefault(),!!n.trim()){a(!0),l(null);try{await fc({leaderEndpoint:n.trim(),transport:"devtunnel"}),t()}catch(m){l(m instanceof Error?m.message:"Failed to join node")}finally{a(!1)}}},[n,t]);return e.jsx(ht,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:e.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/60 bg-background/95 p-0 shadow-[0_28px_90px_-58px_rgba(0,0,0,0.88)] backdrop-blur-xl",children:[e.jsx("div",{className:"border-b border-border/60 px-3.5 py-2.5",children:e.jsxs(Mt,{className:"space-y-1 text-left",children:[e.jsx(vt,{className:"text-sm tracking-tight",children:"Join node"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Verify the remote leader's DevTunnel Node URL, sync this node's tasks to that leader, and join the cluster as a follower."})]})}),e.jsxs("form",{onSubmit:c,className:"space-y-3 px-3.5 py-3",children:[i&&e.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(tt,{htmlFor:"leader-endpoint",children:"Leader Node URL"}),e.jsx(Le,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(dt,{id:"leader-endpoint",type:"url",value:n,onChange:d=>s(d.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-8 rounded-sm border-border/70 bg-background/70"})]}),e.jsx("div",{className:"rounded-sm border border-border/60 bg-background/45 px-3 py-2 text-[11px] text-muted-foreground",children:"This does not switch the local node transport or auto-enable a local DevTunnel. Leaving later will detach this node from the remote leader and make it leader of its own cluster again."}),e.jsx(br,{className:"border-t border-border/60 pt-3",children:e.jsx(X,{type:"submit",disabled:!n.trim()||r,className:"rounded-sm",children:r?"Joining...":"Join node"})})]})]})})}function Kh({open:t,onOpenChange:n,onAdded:s}){return e.jsx(mt,{open:t,onOpenChange:n,children:e.jsx(Hh,{onAdded:()=>{n(!1),s()}})})}const Gh="absolute top-1/2 z-30 hidden h-10 w-4 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground opacity-0 outline-none transition-opacity duration-150 hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/55",Wh="flex h-7 w-3.5 items-center justify-center rounded-full bg-muted/85 shadow-[0_12px_24px_-20px_rgba(0,0,0,0.9)] backdrop-blur-sm transition-colors hover:bg-card hover:text-foreground",Qh="h-2.5 w-2.5";function qi({className:t,label:n,orientation:s,panel:r,panelResize:a}){return e.jsx("button",{type:"button","aria-label":n,"aria-orientation":s,"data-dashboard-resize-handle":r,onPointerDown:i=>a.onPointerDown(r,i),onWheel:i=>a.onWheel(r,i),className:L("group absolute z-20 hidden touch-none rounded-sm bg-transparent outline-none transition-colors hover:bg-primary/12 focus-visible:bg-primary/12 focus-visible:ring-2 focus-visible:ring-ring/70 lg:block",t),children:e.jsx("span",{className:"pointer-events-none absolute inset-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100"})})}function Yh({className:t,label:n,onToggle:s,side:r,visible:a}){const i=r==="left"?a?Dn:nt:a?nt:Dn;return e.jsx("button",{type:"button","aria-label":n,title:n,onClick:s,className:L(Gh,t),children:e.jsx("span",{className:Wh,"aria-hidden":"true",children:e.jsx(i,{className:Qh,strokeWidth:2.1})})})}function wa({className:t,label:n,onToggle:s,panel:r,panelResize:a,screen:i,side:l,visible:c}){const d=i==="lg"?"lg:block":"xl:block",m=i==="lg"?"lg:flex":"xl:flex";return e.jsxs("div",{className:L("group absolute top-0 z-30 hidden h-full w-4",d,t),children:[r&&e.jsx(qi,{panel:r,orientation:"vertical",label:`Resize ${r} panel`,panelResize:a,className:"left-1/2 top-0 h-full w-2 -translate-x-1/2 cursor-col-resize"}),e.jsx(Yh,{side:l,visible:c,label:n,onToggle:s,className:L(m,"left-1/2 -translate-x-1/2 group-hover:opacity-100")})]})}function Jh({conversationPanel:t,desktopTasksOpen:n,mobileTaskSidebar:s,mobileTasksPanelOpen:r,mobileTasksPanelRef:a,operationsOpen:i,operationsPanelRef:l,operationsSidecar:c,panelResize:d,taskSidebar:m,terminalPanel:p,onCloseOperations:u,onCloseTaskList:h,onToggleOperations:f,onToggleTasks:j}){const g={"--dashboard-tasks-width":d.sizes.tasks,"--dashboard-operations-width":d.sizes.operations,"--dashboard-terminal-height":d.sizes.terminal};return e.jsxs("div",{className:"dashboard-workspace flex h-full min-h-0 flex-col overflow-hidden",style:g,children:[e.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[e.jsx(wa,{screen:"lg",side:"left",visible:n,label:n?"Hide tasks":"Show tasks",onToggle:j,panel:n?"tasks":void 0,panelResize:d,className:n?"left-[var(--dashboard-tasks-width)] -translate-x-1/2":"left-0"}),e.jsx("div",{className:L("dashboard-workspace__tasks-panel relative hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",n?"lg:mr-2 lg:w-[var(--dashboard-tasks-width)]":"lg:w-0 lg:overflow-hidden"),children:n&&m}),e.jsxs("section",{className:"dashboard-workspace__primary flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[e.jsx("div",{className:"min-h-0 flex-1",children:t}),p&&e.jsxs("div",{className:"relative h-[var(--dashboard-terminal-height)] min-h-0 shrink-0",children:[e.jsx(qi,{panel:"terminal",orientation:"horizontal",label:"Resize terminal panel",panelResize:d,className:"-top-1 left-0 h-2 w-full cursor-row-resize"}),p]})]}),e.jsx(wa,{screen:"xl",side:"right",visible:i,label:i?"Hide cluster":"Show cluster",onToggle:f,panel:i?"operations":void 0,panelResize:d,className:i?"right-[var(--dashboard-operations-width)] translate-x-1/2":"right-0"}),e.jsx("div",{className:L("dashboard-workspace__operations-panel relative hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",i?"xl:ml-2 xl:w-[var(--dashboard-operations-width)]":"xl:w-0 xl:overflow-hidden"),children:i&&c})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:u,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:l,className:"fixed bottom-0 right-0 top-[var(--dashboard-mobile-overlay-top)] z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:c})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:h,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:a,className:"fixed bottom-0 left-0 top-[var(--dashboard-mobile-overlay-top)] z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:s})]})]})}const Zh=10,Yt="__all__";function lt(t){return"session"in t}function ya(t,n){return n&&t.some(s=>s.id===n)?n:t[0]?.id??""}function Ts(t){return t&&(Di(t.id)||t.workDir)||""}function qn(t,n,s){let r=!1;const a=t.map(i=>lt(i)&&i.session.id===s.id?(r=!0,{...i,nodeName:n,session:s}):i);return hr(r?a:[...a,{id:`session-${s.id}`,nodeName:n,session:s}])}function Vi(t,n){return t.filter(lt).filter(s=>s.session.nodeId===n).sort((s,r)=>r.session.startedAt-s.session.startedAt)}function Xh(t){const n=t.filter(lt).sort((s,r)=>r.session.startedAt-s.session.startedAt);return{active:n.filter(s=>s.session.status==="running"),completed:n.filter(s=>s.session.status!=="running")}}function ef(t,n){return!!(t&&n&&!t.contains(n))}function tf(t,n,s){if(s===Yt)return s;const r=Vi(t,n);return r.some(a=>a.session.id===s)?s:r[0]?.session.id??Yt}function nf(t,n,s){return s===Yt?t.filter(r=>!lt(r)||r.session.nodeId===n):t.filter(r=>lt(r)&&r.session.nodeId===n&&r.session.id===s)}function hr(t){const n=t.map((r,a)=>({entry:r,index:a})).filter(({entry:r})=>lt(r)&&r.session.status!=="running").sort((r,a)=>!lt(r.entry)||!lt(a.entry)?0:a.entry.session.startedAt-r.entry.session.startedAt||a.index-r.index),s=new Set(n.slice(0,Zh).map(({entry:r})=>lt(r)?r.session.id:""));return t.filter(r=>!lt(r)||r.session.status==="running"||s.has(r.session.id))}function fr(t){return t.status==="running"?t.pid?`running pid ${t.pid}`:"running":t.status==="exited"?`exit ${t.exitCode??0}`:t.status==="stopped"?"stopped":t.signal?`failed ${t.signal}`:`exit ${t.exitCode??"failed"}`}function sf(t){const n=t.session.command.length>48?`${t.session.command.slice(0,45)}...`:t.session.command;return`${t.nodeName} - ${fr(t.session)} - ${n}`}function Hi(t,n=48){return t.length>n?`${t.slice(0,n-3)}...`:t}function rf(t,n){return n===Yt?"All sessions":t?Hi(t.session.command,34):"Command session"}function ja(t){return t.status==="stopped"?"":t.stderr}function af({nodes:t,defaultNodeId:n,onClose:s,initialHistory:r=[]}){const[a,i]=o.useState(()=>ya(t,n)),l=o.useMemo(()=>t.find(T=>T.id===a)??t[0]??null,[t,a]),[c,d]=o.useState(()=>Ts(l)),[m,p]=o.useState(""),[u,h]=o.useState(()=>hr(r)),[f,j]=o.useState(Yt),[g,w]=o.useState(!1),[b,k]=o.useState(!1),[y,x]=o.useState(!1),[v,N]=o.useState(!1),[A,E]=o.useState(!1),M=o.useRef(null),B=o.useRef(null),D=o.useMemo(()=>t.find(T=>T.id===a)??t[0]??null,[t,a]),_=o.useMemo(()=>Vi(u,D?.id??""),[u,D]),P=o.useMemo(()=>Xh(_),[_]),O=o.useMemo(()=>_.find(T=>T.session.id===f),[f,_]),W=o.useMemo(()=>nf(u,D?.id??"",f),[u,D,f]),J=o.useRef(D?.id??"");o.useEffect(()=>{a&&t.some(T=>T.id===a)||i(ya(t,n))},[n,t,a]),o.useEffect(()=>{const T=D?.id??"";J.current!==T&&(J.current=T,d(Ts(D)))},[D]),o.useEffect(()=>{j(T=>tf(u,D?.id??"",g?T:""))},[u,D,g]),o.useEffect(()=>{M.current?.scrollTo({top:M.current.scrollHeight})},[u]),o.useEffect(()=>{let T=!1;async function te(){const R=await Promise.allSettled(t.map(async H=>({node:H,response:await xc(H.id)})));T||h(H=>R.reduce((F,le)=>le.status!=="fulfilled"?F:le.value.response.sessions.reduce((ie,ue)=>qn(ie,le.value.node.name,ue),F),H))}return t.length>0&&te(),()=>{T=!0}},[t]),o.useEffect(()=>{const T=u.filter(lt).filter(R=>R.session.status==="running");if(T.length===0)return;const te=window.setInterval(()=>{for(const R of T)pc(R.session.nodeId,R.session.id).then(H=>h(F=>qn(F,R.nodeName,H))).catch(()=>{})},1e3);return()=>window.clearInterval(te)},[u]);const Y=o.useRef(null);async function V(T){if(T.preventDefault(),!D||!m.trim()||A)return;const te=m.trim(),R=D.name;E(!0),p("");try{const H=await bc(D.id,{command:te,...c.trim()?{cwd:c.trim()}:{}});h(F=>qn(F,R,H)),j(H.id),w(!0)}catch(H){h(F=>[...F,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:R,command:te,error:H instanceof Error?H.message:"Command failed"}])}finally{E(!1)}}async function ne(T,te){T.stopPropagation();const R=await gc(te.session.nodeId,te.session.id);h(H=>qn(H,te.nodeName,R))}function $(T){j(T),w(!0),k(!1)}function ee(T){b&&ef(B.current,T.target)&&k(!1)}function S(T,te,R,H,F){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:H,"aria-label":`Toggle ${T} sessions`,"aria-expanded":!R,className:"node-terminal__small flex w-full items-center justify-between gap-2 px-2 pb-1 pt-0.5 text-left font-medium uppercase tracking-normal text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{children:T}),e.jsx(st,{className:L("h-3 w-3 transition-transform",R&&"-rotate-90")})]}),!R&&(te.length>0?te.map(Q):e.jsx("div",{className:"node-terminal__control px-2 py-1 text-muted-foreground",children:F}))]})}function Q(T){const te=f===T.session.id,R=T.session.status==="running";return e.jsxs("div",{className:L("node-terminal__control group flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65",te&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>$(T.session.id),className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:L("flex h-4 w-4 shrink-0 items-center justify-center",R?"text-primary":T.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:R?e.jsx(he,{className:"h-3 w-3 animate-spin"}):T.session.status==="exited"?e.jsx(tr,{className:"h-3 w-3"}):e.jsx(gs,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:Hi(T.session.command,44)}),e.jsxs("span",{className:"node-terminal__small block truncate text-muted-foreground",children:[T.nodeName," · ",fr(T.session)]})]})]}),R&&e.jsx("button",{type:"button",onClick:H=>{ne(H,T)},"aria-label":"Stop terminal session from selector",title:"Stop terminal session",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Wr,{className:"h-3 w-3"})})]},T.session.id)}return e.jsx("section",{className:"dashboard-panel node-terminal animate-composer-settle flex h-full min-h-0 shrink-0 overflow-visible rounded-xl","aria-label":"Node terminal",onClick:ee,children:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col overflow-visible rounded-[inherit] bg-card/72 text-card-foreground",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"node-terminal__header flex min-w-0 items-center gap-2 font-medium",children:[s?e.jsx("button",{type:"button",onClick:s,"aria-label":"Close terminal",title:"Close terminal",className:"flex h-6 w-6 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(ut,{className:"h-3.5 w-3.5"})}):e.jsx(Gr,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{children:"Terminal"})]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-2",children:[e.jsxs("div",{ref:B,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":b,title:O?sf(O):"All sessions",onClick:()=>k(T=>!T),className:"node-terminal__control flex h-7 max-w-[14rem] list-none items-center gap-1.5 rounded-sm border border-border/70 bg-background/70 px-2 text-foreground outline-none transition-colors hover:bg-muted/65 focus-visible:ring-2 focus-visible:ring-ring/70 [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{className:"min-w-0 truncate",children:rf(O,f)}),e.jsx(st,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform",b&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!b,className:L("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!b&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>$(Yt),className:L("node-terminal__control flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",f===Yt&&"bg-primary/10 text-primary"),children:[e.jsx(Gr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),S("Active",P.active,y,()=>x(T=>!T),"No active sessions"),S("Completed",P.completed,v,()=>N(T=>!T),"No completed sessions")]})})]}),e.jsx("select",{value:D?.id??"",onChange:T=>{i(T.target.value),w(!1),d(Ts(t.find(te=>te.id===T.target.value)??null))},disabled:A||t.length===0,"aria-label":"Terminal node",className:"node-terminal__control h-7 max-w-[11rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground outline-none transition-colors hover:bg-muted/65 disabled:opacity-50",children:t.map(T=>e.jsx("option",{value:T.id,className:"bg-background text-foreground",children:T.name},T.id))}),e.jsx(Xn,{value:c,onChange:d,assignTo:D?.id??"",nodes:t,assignableNodes:t,layout:"composer",chipClassName:"node-terminal__control h-7 max-w-[18rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground hover:bg-muted/65",chipActiveClassName:"font-mono",chipInactiveClassName:"text-muted-foreground",labelClassName:"node-terminal__workdir",triggerClassName:"terminal-workdir-trigger",popoverPlacement:"top",popoverAlign:"end"})]})]}),e.jsxs("div",{ref:M,className:"node-terminal__body min-h-0 flex-1 overflow-y-auto bg-muted/22 px-3 py-2 font-mono cursor-text",onClick:()=>Y.current?.focus(),children:[W.length===0?e.jsx("div",{className:"text-muted-foreground mb-2",children:"Commands run on the selected node and stay visible while running or after exit."}):e.jsx("div",{className:"space-y-3 mb-2",children:W.map(T=>lt(T)?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[T.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:T.session.command}),e.jsxs("span",{className:L("inline-flex items-center gap-1",T.session.status==="running"||T.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[T.session.status==="running"?e.jsx(he,{className:"h-3 w-3 animate-spin"}):T.session.status==="exited"?e.jsx(tr,{className:"h-3 w-3"}):e.jsx(gs,{className:"h-3 w-3"}),fr(T.session)]}),T.session.status==="running"&&e.jsx("button",{type:"button",onClick:te=>{ne(te,T)},"aria-label":"Stop terminal session",title:"Stop terminal session",className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted/65 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Wr,{className:"h-3 w-3"})})]}),T.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:T.session.stdout}),ja(T.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:ja(T.session)}),(T.session.stdoutTruncated||T.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},T.id):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[T.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:T.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(gs,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:T.error})]},T.id))}),e.jsxs("form",{onSubmit:V,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:D?`${D.name}$`:"$"}),e.jsx("input",{ref:Y,value:m,onChange:T=>p(T.target.value),disabled:!D||A,placeholder:D?"":"No online nodes available",className:"node-terminal__input flex-1 min-w-0 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground font-mono caret-primary disabled:opacity-50",autoComplete:"off",spellCheck:!1}),e.jsx("button",{type:"submit","aria-label":"Run",title:"Run",disabled:!D||!m.trim()||A,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 disabled:pointer-events-none disabled:text-muted-foreground disabled:opacity-50",children:A?e.jsx(he,{className:"h-3 w-3 animate-spin"}):e.jsx(ss,{className:"h-3 w-3"})})]})]})]})})}var ln={},As,Na;function of(){return Na||(Na=1,As=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),As}var Es={},Lt={},ka;function Zt(){if(ka)return Lt;ka=1;let t;const n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Lt.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},Lt.getSymbolTotalCodewords=function(r){return n[r]},Lt.getBCHDigit=function(s){let r=0;for(;s!==0;)r++,s>>>=1;return r},Lt.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},Lt.isKanjiModeEnabled=function(){return typeof t<"u"},Lt.toSJIS=function(r){return t(r)},Lt}var Ms={},Sa;function Ir(){return Sa||(Sa=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function n(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+s)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,a){if(t.isValid(r))return r;try{return n(r)}catch{return a}}})(Ms)),Ms}var Ds,Ca;function lf(){if(Ca)return Ds;Ca=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(n){const s=Math.floor(n/8);return(this.buffer[s]>>>7-n%8&1)===1},put:function(n,s){for(let r=0;r<s;r++)this.putBit((n>>>s-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(n){const s=Math.floor(this.length/8);this.buffer.length<=s&&this.buffer.push(0),n&&(this.buffer[s]|=128>>>this.length%8),this.length++}},Ds=t,Ds}var _s,Ta;function cf(){if(Ta)return _s;Ta=1;function t(n){if(!n||n<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=n,this.data=new Uint8Array(n*n),this.reservedBit=new Uint8Array(n*n)}return t.prototype.set=function(n,s,r,a){const i=n*this.size+s;this.data[i]=r,a&&(this.reservedBit[i]=!0)},t.prototype.get=function(n,s){return this.data[n*this.size+s]},t.prototype.xor=function(n,s,r){this.data[n*this.size+s]^=r},t.prototype.isReserved=function(n,s){return this.reservedBit[n*this.size+s]},_s=t,_s}var Ps={},Aa;function df(){return Aa||(Aa=1,(function(t){const n=Zt().getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const a=Math.floor(r/7)+2,i=n(r),l=i===145?26:Math.ceil((i-13)/(2*a-2))*2,c=[i-7];for(let d=1;d<a-1;d++)c[d]=c[d-1]-l;return c.push(6),c.reverse()},t.getPositions=function(r){const a=[],i=t.getRowColCoords(r),l=i.length;for(let c=0;c<l;c++)for(let d=0;d<l;d++)c===0&&d===0||c===0&&d===l-1||c===l-1&&d===0||a.push([i[c],i[d]]);return a}})(Ps)),Ps}var Is={},Ea;function uf(){if(Ea)return Is;Ea=1;const t=Zt().getSymbolSize,n=7;return Is.getPositions=function(r){const a=t(r);return[[0,0],[a-n,0],[0,a-n]]},Is}var Rs={},Ma;function mf(){return Ma||(Ma=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const n={N1:3,N2:3,N3:40,N4:10};t.isValid=function(a){return a!=null&&a!==""&&!isNaN(a)&&a>=0&&a<=7},t.from=function(a){return t.isValid(a)?parseInt(a,10):void 0},t.getPenaltyN1=function(a){const i=a.size;let l=0,c=0,d=0,m=null,p=null;for(let u=0;u<i;u++){c=d=0,m=p=null;for(let h=0;h<i;h++){let f=a.get(u,h);f===m?c++:(c>=5&&(l+=n.N1+(c-5)),m=f,c=1),f=a.get(h,u),f===p?d++:(d>=5&&(l+=n.N1+(d-5)),p=f,d=1)}c>=5&&(l+=n.N1+(c-5)),d>=5&&(l+=n.N1+(d-5))}return l},t.getPenaltyN2=function(a){const i=a.size;let l=0;for(let c=0;c<i-1;c++)for(let d=0;d<i-1;d++){const m=a.get(c,d)+a.get(c,d+1)+a.get(c+1,d)+a.get(c+1,d+1);(m===4||m===0)&&l++}return l*n.N2},t.getPenaltyN3=function(a){const i=a.size;let l=0,c=0,d=0;for(let m=0;m<i;m++){c=d=0;for(let p=0;p<i;p++)c=c<<1&2047|a.get(m,p),p>=10&&(c===1488||c===93)&&l++,d=d<<1&2047|a.get(p,m),p>=10&&(d===1488||d===93)&&l++}return l*n.N3},t.getPenaltyN4=function(a){let i=0;const l=a.data.length;for(let d=0;d<l;d++)i+=a.data[d];return Math.abs(Math.ceil(i*100/l/5)-10)*n.N4};function s(r,a,i){switch(r){case t.Patterns.PATTERN000:return(a+i)%2===0;case t.Patterns.PATTERN001:return a%2===0;case t.Patterns.PATTERN010:return i%3===0;case t.Patterns.PATTERN011:return(a+i)%3===0;case t.Patterns.PATTERN100:return(Math.floor(a/2)+Math.floor(i/3))%2===0;case t.Patterns.PATTERN101:return a*i%2+a*i%3===0;case t.Patterns.PATTERN110:return(a*i%2+a*i%3)%2===0;case t.Patterns.PATTERN111:return(a*i%3+(a+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(a,i){const l=i.size;for(let c=0;c<l;c++)for(let d=0;d<l;d++)i.isReserved(d,c)||i.xor(d,c,s(a,d,c))},t.getBestMask=function(a,i){const l=Object.keys(t.Patterns).length;let c=0,d=1/0;for(let m=0;m<l;m++){i(m),t.applyMask(m,a);const p=t.getPenaltyN1(a)+t.getPenaltyN2(a)+t.getPenaltyN3(a)+t.getPenaltyN4(a);t.applyMask(m,a),p<d&&(d=p,c=m)}return c}})(Rs)),Rs}var Vn={},Da;function Ki(){if(Da)return Vn;Da=1;const t=Ir(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],s=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Vn.getBlocksCount=function(a,i){switch(i){case t.L:return n[(a-1)*4+0];case t.M:return n[(a-1)*4+1];case t.Q:return n[(a-1)*4+2];case t.H:return n[(a-1)*4+3];default:return}},Vn.getTotalCodewordsCount=function(a,i){switch(i){case t.L:return s[(a-1)*4+0];case t.M:return s[(a-1)*4+1];case t.Q:return s[(a-1)*4+2];case t.H:return s[(a-1)*4+3];default:return}},Vn}var Ls={},kn={},_a;function hf(){if(_a)return kn;_a=1;const t=new Uint8Array(512),n=new Uint8Array(256);return(function(){let r=1;for(let a=0;a<255;a++)t[a]=r,n[r]=a,r<<=1,r&256&&(r^=285);for(let a=255;a<512;a++)t[a]=t[a-255]})(),kn.log=function(r){if(r<1)throw new Error("log("+r+")");return n[r]},kn.exp=function(r){return t[r]},kn.mul=function(r,a){return r===0||a===0?0:t[n[r]+n[a]]},kn}var Pa;function ff(){return Pa||(Pa=1,(function(t){const n=hf();t.mul=function(r,a){const i=new Uint8Array(r.length+a.length-1);for(let l=0;l<r.length;l++)for(let c=0;c<a.length;c++)i[l+c]^=n.mul(r[l],a[c]);return i},t.mod=function(r,a){let i=new Uint8Array(r);for(;i.length-a.length>=0;){const l=i[0];for(let d=0;d<a.length;d++)i[d]^=n.mul(a[d],l);let c=0;for(;c<i.length&&i[c]===0;)c++;i=i.slice(c)}return i},t.generateECPolynomial=function(r){let a=new Uint8Array([1]);for(let i=0;i<r;i++)a=t.mul(a,new Uint8Array([1,n.exp(i)]));return a}})(Ls)),Ls}var Bs,Ia;function pf(){if(Ia)return Bs;Ia=1;const t=ff();function n(s){this.genPoly=void 0,this.degree=s,this.degree&&this.initialize(this.degree)}return n.prototype.initialize=function(r){this.degree=r,this.genPoly=t.generateECPolynomial(this.degree)},n.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(r.length+this.degree);a.set(r);const i=t.mod(a,this.genPoly),l=this.degree-i.length;if(l>0){const c=new Uint8Array(this.degree);return c.set(i,l),c}return i},Bs=n,Bs}var Os={},Fs={},zs={},Ra;function Gi(){return Ra||(Ra=1,zs.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}),zs}var Nt={},La;function Wi(){if(La)return Nt;La=1;const t="[0-9]+",n="[A-Z $%*+\\-./:]+";let s="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";s=s.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+s+`)(?:.|[\r
|
|
189
|
+
`).map(i=>i.trim()).find(Boolean);return a?a.length>72?`${a.slice(0,69).trimEnd()}...`:a:s?"Image task":""}function hh(t){const n=t.title.trim(),s=Ho(t.agent,t.description),r=s.prompt,a=Ii(t.title,r,t.images.length>0),i=r.trim()||a,l=t.mode??Mn,c=t.model?.trim(),d=c&&Vo(t.agent,c)?c:"",m=s.isGoal?s.commandPrompt:r,p=zo(m,t.images);return!a||!i||!t.agent?null:{title:a,description:i,agent:t.agent,project:t.project.trim()||null,branch:t.branch?.trim()||null,payload:{initialMessage:p,mode:l,...d?{model:d}:{},...s.isGoal?{goal:!0}:{},titleSource:n?"manual":"derived"},priority:t.priority,assignTo:t.assignTo==="auto"?void 0:t.assignTo}}function fh({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,className:d,footerClassName:m,submitLabel:p="Create chat",cancelLabel:u="Cancel",autoFocus:h=!1,layout:f="default",defaultTaskAgent:j,quickChats:g=[]}){const[w,b]=o.useState(""),[k,y]=o.useState(""),[x,v]=o.useState(0),[N,A]=o.useState(()=>Un(j)),E=o.useRef(!1),[M,B]=o.useState(""),[D,_]=o.useState(Mn),[P,O]=o.useState(i?.trim()??""),W=o.useRef(i!==void 0),[J,Y]=o.useState(""),V=o.useMemo(()=>_i(t,{currentNodeRole:n,leaderNodeId:r}),[t,n,r]),ne=o.useMemo(()=>a&&V.some(re=>re.id===a)?a:s&&V.some(re=>re.id===s)?s:V[0]?.id??"",[V,s,a]),[$,ee]=o.useState(ne),[S,Q]=o.useState(!1),[T,te]=o.useState(!1),{images:R,error:H,fileInputRef:F,pickImages:le,handleFileChange:ie,handlePaste:ue,removeImage:Z}=oi(),K=o.useRef(null),I=o.useMemo(()=>V.find(re=>re.id===$)??null,[$,V]),se=!!(s&&I?.id===s),q=kt(N),ae=Ld(D),ye=o.useMemo(()=>Ho(N,k),[N,k]),pe=o.useMemo(()=>$o(N,k),[N,k]),Ze=ye.prompt,Ae=o.useMemo(()=>ye.isGoal||pe?[]:g,[ye.isGoal,pe,g]);o.useEffect(()=>{$&&V.some(re=>re.id===$)||ee(ne)},[$,V,ne]),o.useEffect(()=>{E.current||A(Un(j))},[j]);const ft=o.useCallback(re=>{E.current=!0,A(Un(re))},[]);o.useEffect(()=>{if(W.current){W.current=!1;return}O(Di($)),Y("")},[$]),o.useEffect(()=>{Y("")},[P]),o.useEffect(()=>{v(0)},[k,g,N]);const Re=o.useCallback(re=>{y(re.prompt)},[]),De=o.useCallback(()=>{y(pe?.value??"/goal "),v(0),!(typeof window>"u")&&window.setTimeout(()=>{const re=K.current;re?.focus();const Ne=re?.value.length??0;re?.setSelectionRange(Ne,Ne)},0)},[pe]),He=o.useCallback(async re=>{if(re.preventDefault(),pe){De();return}const Ne=Wn(k,Ae,x);if(Ne){Re(Ne);return}const Te=hh({title:w,description:k,agent:N,model:M,project:P,branch:J,priority:"normal",assignTo:$,mode:D,images:R});if(Te){Q(!0);try{const ve=await ic(Te);l(ve)}catch(ve){ce.error(ve instanceof Error?ve.message:"Failed to create task")}finally{Q(!1)}}},[w,k,N,M,P,J,$,D,R,l,Ae,x,Re,pe,De]),Ke=Ii(w,Ze,R.length>0),je=!pe&&!!(Ke&&N&&$&&(Ze.trim()||R.length>0)),Be=o.useCallback(re=>{if(re.nativeEvent.isComposing)return;if(pe&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault();return}const Ne=No(k,Ae);if(Ne.length>0&&(re.key==="ArrowDown"||re.key==="ArrowUp")){re.preventDefault(),v(Te=>ko(Te,Ne.length,re.key==="ArrowDown"?1:-1));return}if(re.key==="Enter"){if(pe&&!re.shiftKey){re.preventDefault(),De();return}const Te=Wn(k,Ae,x);if(Te&&!re.shiftKey){re.preventDefault(),Re(Te);return}}re.key==="Enter"&&(re.ctrlKey||re.metaKey)&&je&&!S&&(re.preventDefault(),re.currentTarget.form?.requestSubmit())},[De,Re,Ae,je,k,pe,x,S]),G=R.length>0?e.jsx(Gm,{images:R,removeImage:Z}):null,ge=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Assign to"}),e.jsxs($e,{value:$,onValueChange:ee,children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select node"})}),e.jsx(Ve,{children:ur(V,s)})]})]}),be=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Agent"}),e.jsxs($e,{value:N,onValueChange:ft,children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select agent"})}),e.jsx(Ve,{children:ra()})]})]}),et=e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{className:"text-[11px] font-medium",children:"Mode"}),e.jsxs($e,{value:D,onValueChange:re=>_(re),children:[e.jsx(qe,{className:"h-8 rounded-sm border-border/70 bg-background/70",children:e.jsx(Je,{placeholder:"Select mode"})}),e.jsx(Ve,{children:aa()})]})]}),_e=e.jsx(Xn,{value:P,onChange:O,assignTo:$,nodes:t,assignableNodes:V}),rt=e.jsx(ha,{value:J,onChange:Y,project:P,assignTo:$,nodes:t,assignableNodes:V});return f==="composer"?e.jsxs("form",{onSubmit:He,className:L("space-y-4",d),children:[e.jsx("input",{ref:F,type:"file",accept:"image/*",multiple:!0,onChange:ie,className:"hidden"}),(()=>{const re="chat-composer__chip h-9 min-w-0 w-auto gap-1.5 rounded-sm px-3.5 text-xs shadow-none transition-colors [&>span]:min-w-0",Ne="border-transparent bg-transparent text-muted-foreground hover:bg-background/40 hover:text-foreground",Te="border-border/70 bg-background/55 text-foreground",ve=N===Un(j),at=D===Mn;return e.jsxs("div",{className:"chat-composer space-y-2",children:[e.jsxs("div",{className:"chat-composer__card rounded-sm border border-border/60 bg-background/54 shadow-none backdrop-blur-xl",children:[e.jsxs("div",{className:"chat-composer__header flex min-w-0 items-center justify-between gap-3 px-4 pt-3",children:[e.jsxs($e,{value:$,onValueChange:ee,children:[e.jsx(qe,{className:L(re,Te,"chat-composer__node-trigger border-transparent bg-transparent hover:bg-background/40"),title:`Assigned node: ${I?.name??"unassigned"}`,"aria-label":`Assigned node: ${I?.name??"unassigned"}`,children:I?e.jsxs(e.Fragment,{children:[e.jsx(Pr,{isCurrent:se}),e.jsx("span",{className:"min-w-0 truncate",children:I.name}),e.jsx("span",{className:"chat-composer__header-meta shrink-0 text-[10px] uppercase tracking-[0.18em] text-muted-foreground",children:se?"current":"remote"})]}):e.jsx(Je,{placeholder:"Select node"})}),e.jsx(Ve,{children:ur(V,s)})]}),T?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(dt,{id:"task-title-composer",type:"text",value:w,onChange:Pe=>b(Pe.target.value),onKeyDown:Pe=>{(Pe.key==="Enter"||Pe.key==="Escape")&&(Pe.preventDefault(),te(!1))},autoFocus:!0,placeholder:"Chat title",className:"h-8 w-48 min-w-0 rounded-sm border-border/70 bg-background/55 px-3 text-xs shadow-none"}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>te(!1),"aria-label":"Save title",className:"h-8 w-8 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(En,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>te(!0),className:"chat-composer__title-button flex min-w-0 items-center gap-1.5 rounded-sm px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",title:Ke||"Title","aria-label":Ke?`Edit title: ${Ke}`:"Edit title",children:[e.jsx("span",{className:"chat-composer__title-text max-w-[220px] truncate",children:Ke||"Title"}),e.jsx(Jt,{className:"h-3 w-3 shrink-0"})]})]}),e.jsx("textarea",{id:"task-description",ref:K,value:k,onChange:Pe=>y(Pe.target.value),onKeyDown:Be,onPaste:ue,placeholder:"Ask anything...",rows:4,autoFocus:h,"aria-label":"Opening prompt",className:"min-h-[140px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-sm bg-transparent px-5 pt-2 pb-2 text-xs leading-5 text-foreground ring-offset-background placeholder:text-muted-foreground/70 focus-visible:outline-none"}),e.jsx(ma,{agent:N,query:k,onSelect:De}),e.jsx(Xs,{query:k,quickChats:Ae,selectedIndex:x,onActiveIndexChange:v,onSelect:Re}),e.jsxs("div",{className:"chat-composer__rail flex min-w-0 flex-nowrap items-center gap-2 px-3 pb-3",children:[e.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:le,"aria-label":"Add images",className:"h-9 w-9 shrink-0 rounded-sm text-muted-foreground hover:text-foreground",children:e.jsx(or,{className:"h-4 w-4"})}),e.jsx("span",{className:"mx-0.5 h-5 w-px bg-border/60","aria-hidden":!0}),e.jsxs($e,{value:N,onValueChange:ft,children:[e.jsxs(qe,{className:L(re,"chat-composer__icon-trigger",ve?Ne:Te),title:`Agent: ${q}`,"aria-label":`Agent: ${q}`,children:[e.jsx(At,{agent:N}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:q})]}),e.jsx(Ve,{children:ra()})]}),e.jsx(Pi,{agent:N,value:M,onChange:B,chip:!0,triggerClassName:L(re,"chat-composer__icon-trigger",M?Te:Ne),contentClassName:"max-h-80 shadow-none"}),e.jsxs($e,{value:D,onValueChange:Pe=>_(Pe),children:[e.jsxs(qe,{className:L(re,"chat-composer__icon-trigger",at?Ne:Te),title:`Mode: ${ae}`,"aria-label":`Mode: ${ae}`,children:[e.jsx(Fu,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label truncate",children:ae})]}),e.jsx(Ve,{children:aa()})]}),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:[c&&e.jsxs(X,{type:"button",variant:"ghost",size:"sm",onClick:c,"aria-label":u,className:"chat-composer__cancel h-9 rounded-sm px-4 text-xs text-muted-foreground",children:[e.jsx(ut,{className:"chat-composer__cancel-icon h-4 w-4 shrink-0"}),e.jsx("span",{className:"chat-composer__footer-label",children:u})]}),e.jsxs(X,{type:"submit",size:"icon",disabled:!je||S,className:"h-10 w-10 rounded-sm shadow-[0_8px_30px_-8px_hsl(var(--primary)/0.6)]",children:[S?e.jsx(he,{className:"h-4 w-4 animate-spin"}):e.jsx(si,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:S?"Creating chat":p})]})]})]})]}),e.jsx("div",{className:"chat-composer__location flex flex-wrap items-center gap-2 px-1",children:(()=>{const Pe="border-border/40 bg-muted/40 text-foreground/80 hover:bg-muted/60 hover:text-foreground";return e.jsxs(e.Fragment,{children:[e.jsx(Xn,{value:P,onChange:O,assignTo:$,nodes:t,assignableNodes:V,layout:"composer",chipClassName:re,chipActiveClassName:Pe,chipInactiveClassName:Pe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"}),e.jsx(ha,{value:J,onChange:Y,project:P,assignTo:$,nodes:t,assignableNodes:V,layout:"composer",chipClassName:re,chipActiveClassName:Pe,chipInactiveClassName:Pe,triggerClassName:"chat-composer__icon-trigger",labelClassName:"chat-composer__location-label"})]})})()})]})})(),(G||H)&&e.jsxs("div",{className:"space-y-2 rounded-sm border border-border/60 bg-background/45 p-2.5",children:[G,H&&e.jsx("div",{className:"text-[11px] text-destructive",children:H}),!H&&e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Paste screenshots directly into the prompt box or use the Images button."})]})]}):e.jsxs("form",{onSubmit:He,className:L("space-y-4",d),children:[e.jsx("input",{ref:F,type:"file",accept:"image/*",multiple:!0,onChange:ie,className:"hidden"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{htmlFor:"task-description",className:"text-[11px] font-medium",children:"Opening prompt"}),e.jsx("textarea",{id:"task-description",ref:K,value:k,onChange:re=>y(re.target.value),onKeyDown:Be,onPaste:ue,placeholder:"Describe what the agent should do. This becomes the first message in the chat.",rows:6,autoFocus:h,className:"flex min-h-[128px] w-full resize-none overflow-x-hidden overflow-y-auto rounded-sm border border-border/70 bg-background/70 px-3 py-2 text-xs leading-5 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),e.jsx(ma,{agent:N,query:k,onSelect:De}),e.jsx(Xs,{query:k,quickChats:Ae,selectedIndex:x,onActiveIndexChange:v,onSelect:Re}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(X,{type:"button",variant:"outline",onClick:le,className:"rounded-sm",children:[e.jsx(or,{className:"h-4 w-4"}),"Add images"]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Ctrl/Cmd+Enter starts the chat. Enter adds a new line. Upload or paste screenshots and reference images with the opening prompt."})]}),G,H&&e.jsx("p",{className:"text-[11px] text-destructive",children:H})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_170px_190px_150px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(tt,{htmlFor:"task-title",className:"text-[11px] font-medium",children:"Chat title"}),e.jsx(dt,{id:"task-title",type:"text",value:w,onChange:re=>b(re.target.value),placeholder:"Optional. Leave blank to derive it from the prompt.",className:"h-8 rounded-sm border-border/70 bg-background/70"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:Ke?`Will appear as: ${Ke}`:"A title will be generated from the first line of the prompt."})]}),be,e.jsx(mh,{agent:N,value:M,onChange:B}),et]}),_e,rt,ge,e.jsxs("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",m),children:[c&&e.jsx(X,{type:"button",variant:"ghost",onClick:c,className:"rounded-sm",children:u}),e.jsx(X,{type:"submit",disabled:!je||S,className:"rounded-sm px-5",children:S?"Creating...":p})]})]})}function ph({nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,defaultMode:d="chat",mode:m,onModeChange:p,layout:u="default",className:h,footerClassName:f,autoFocus:j=!1,quickChats:g=[],defaultTaskAgent:w}){const[b,k]=o.useState(d),y=m!==void 0,x=y?m:b,v=N=>{y||k(N),p?.(N)};return e.jsxs("div",{className:L("space-y-4",h),children:[!y&&e.jsxs("div",{className:"flex h-8 items-center gap-0.5 rounded-sm border border-border/60 bg-background/45 p-0.5",children:[e.jsxs(X,{type:"button",variant:x==="chat"?"default":"ghost",onClick:()=>v("chat"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(oc,{className:"h-4 w-4"}),"New chat"]}),e.jsxs(X,{type:"button",variant:x==="native"?"default":"ghost",onClick:()=>v("native"),className:"h-7 flex-1 rounded-sm shadow-none",children:[e.jsx(Ar,{className:"h-4 w-4"}),"Load session"]})]}),x==="chat"?e.jsx(fh,{nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,initialAssignTo:a,initialProject:i,onCreated:l,onCancel:c,footerClassName:f,submitLabel:u==="composer"?"Start chat":"Create chat",cancelLabel:"Cancel",autoFocus:j,layout:u,defaultTaskAgent:w,quickChats:g},`${a??""}:${i??""}`):e.jsx(uh,{nodes:t,currentNodeRole:n,currentNodeId:s,leaderNodeId:r,onCreated:l,onCancel:c,footerClassName:f,autoFocus:j})]})}function xh({onClick:t,running:n}){return e.jsxs(X,{size:"icon",onClick:t,"aria-label":n?"Open composer - task running":"Open composer",title:n?"Task running - open composer":"Open composer",className:L("absolute bottom-4 right-4 z-10 h-12 w-12 overflow-visible rounded-lg shadow-lg",n&&"animate-soft-status-pulse bg-primary/90 text-primary-foreground hover:bg-primary"),children:[e.jsx(Jt,{className:"h-4 w-4"}),n&&e.jsx("span",{"aria-hidden":"true","data-running-indicator":"true",className:"pointer-events-none absolute right-1.5 top-1.5 h-2 w-2 rounded-full bg-primary-foreground shadow-[0_0_0_2px_hsl(var(--primary))]"})]})}function pa({children:t}){return e.jsxs("div",{className:"agent-progress-banner animate-message-receive flex items-center gap-1.5 rounded-lg bg-transparent px-1 py-1 text-[11px]",children:[e.jsx("span",{className:"agent-progress-terminal-spinner h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsx("div",{className:"agent-progress-sweep-text min-w-0 leading-5",children:t})]})}function gh({hasVisibleTranscriptEvents:t,hasTranscriptProgress:n,inputCollapsed:s}){return{collapsedButtonRunning:n&&t&&s,showDockedProgress:n&&t&&!s,showInlineProgress:n&&!t}}const cn="72f988bf-86f1-41af-91ab-2d7cd011db47",Ri=`${cn} (MSIT)`;function bh({open:t,onOpenChange:n,onShare:s,onStopShare:r,sharing:a,stopping:i=!1,shareResult:l}){return e.jsx(mt,{open:t,onOpenChange:n,children:e.jsxs(ht,{className:"max-w-md rounded-sm p-4",children:[e.jsx(vt,{className:"sr-only",children:"Share conversation"}),e.jsx(vh,{onOpenChange:n,onShare:s,onStopShare:r,sharing:a,stopping:i,shareResult:l})]})})}function vh({onOpenChange:t,onShare:n,onStopShare:s,sharing:r,stopping:a=!1,shareResult:i}){const[l,c]=o.useState(i?.tenant??cn),[d,m]=o.useState(i?.scope??"chat"),p=i?.url?Do(i.url):null,u=r||a;return o.useEffect(()=>{c(i?.tenant??cn),m(i?.scope??"chat")},[i?.shareId,i?.tenant,i?.scope]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h2",{className:"text-sm font-semibold leading-none tracking-tight",children:"Share conversation"}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Create a tenant-gated link for this task."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(wh,{value:l,onChange:c,disabled:u}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Access"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(xa,{active:d==="chat",title:"Chat only",description:"Conversation transcript and opening prompt.",onClick:()=>m("chat")}),e.jsx(xa,{active:d==="filesPreview",title:"Chat, files and preview",description:"Transcript plus task output files and HTML preview.",onClick:()=>m("filesPreview")})]})]}),p&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Shared link"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-sm border border-border/70 bg-muted/30 px-3 py-2",children:[e.jsx("input",{readOnly:!0,value:p,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-foreground outline-none","aria-label":"Shared link"}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 rounded-sm text-muted-foreground",onClick:()=>{In(p,"Shared link copied")},"aria-label":"Copy shared link",title:"Copy shared link",children:e.jsx(_o,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(X,{variant:"outline",onClick:()=>t(!1),disabled:u,className:"h-8 text-xs",children:i?"Done":"Cancel"}),i&&s&&e.jsxs(X,{variant:"outline",onClick:()=>{s()},disabled:u,className:"h-8 border-destructive/30 text-xs text-destructive hover:bg-destructive/10 hover:text-destructive",children:[a&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Stop share"]}),e.jsxs(X,{onClick:()=>{n({tenant:l,scope:d})},disabled:u,className:"h-8 text-xs",children:[r&&e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),i?"Update link":"Share link"]})]})]})}function wh({value:t,onChange:n,disabled:s}){const[r,a]=o.useState(!1),[i,l]=o.useState(!1),[c,d]=o.useState(t),m=o.useRef(null);o.useEffect(()=>{d(t)},[t]),o.useEffect(()=>{if(!r)return;const u=f=>{const j=f.target;j instanceof Node&&(m.current?.contains(j)||(a(!1),l(!1)))},h=f=>{f.key==="Escape"&&(a(!1),l(!1))};return document.addEventListener("mousedown",u),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",h)}},[r]);const p=u=>{const h=u.trim();h&&(n(h),d(h),l(!1),a(!1))};return e.jsxs("div",{className:"space-y-2 text-xs",ref:m,children:[e.jsx("div",{className:"font-medium text-foreground",children:"Tenant"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>!s&&a(u=>!u),disabled:s,className:"flex h-9 w-full items-center justify-between gap-2 rounded-sm border border-border/70 bg-background/70 px-3 text-left text-xs text-foreground shadow-sm outline-none transition-colors hover:bg-background disabled:opacity-50",children:[e.jsx("span",{className:"min-w-0 truncate font-mono",children:yh(t)}),e.jsx(st,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),r&&e.jsxs("div",{className:"absolute left-0 right-0 z-50 mt-2 overflow-hidden rounded-sm border border-border/60 bg-background/95 text-xs shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur",children:[e.jsxs("button",{type:"button",onClick:()=>p(cn),className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left hover:bg-background/60",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-[11px]",children:Ri}),t===cn&&e.jsx(En,{className:"h-3.5 w-3.5 shrink-0 text-primary"})]}),e.jsx("div",{className:"border-t border-border/60 bg-background/40 px-2.5 py-1.5",children:i?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{value:c,onChange:u=>d(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),p(c))},autoFocus:!0,placeholder:"Tenant ID",className:"h-7 min-w-0 flex-1 rounded-sm border border-border/60 bg-background/70 px-2 font-mono text-[11px] outline-none focus:ring-2 focus:ring-ring"}),e.jsx("button",{type:"button",onClick:()=>p(c),className:"flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background/60",children:e.jsx(En,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>{d(t),l(!1)},className:"flex h-7 w-7 items-center justify-center rounded-sm text-muted-foreground hover:bg-background/60 hover:text-foreground",children:e.jsx(ut,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>l(!0),className:"flex h-7 w-full items-center justify-between rounded-sm px-1.5 text-[11px] text-muted-foreground hover:bg-background/60 hover:text-foreground",children:[e.jsx("span",{children:"Manual tenant ID"}),e.jsx(Jt,{className:"h-3 w-3"})]})})]})]})]})}function yh(t){return t===cn?Ri:t}function xa({active:t,title:n,description:s,onClick:r}){return e.jsxs("button",{type:"button",onClick:r,className:t?"rounded-sm border border-primary/45 bg-primary/10 px-3 py-2 text-left shadow-sm":"rounded-sm border border-border/70 bg-background px-3 py-2 text-left shadow-sm hover:bg-muted/50",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:n}),e.jsx("div",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:s})]})}function jh(t){const n=t.map(s=>s.type==="text"?s.text:s.type==="image"?s.filename?`Image: ${s.filename}`:"Image attachment":s.isError?`Tool result error: ${s.content}`:`Tool result: ${s.content}`).join(" ").replace(/\s+/g," ").trim();return n?n.length>160?`${n.slice(0,157)}...`:n:"Queued follow-up"}function Nh({messages:t,onCancelMessage:n}){return t.length===0?null:e.jsx("div",{className:"border-t border-border/55 bg-card/30 px-3 py-2 sm:px-5",children:e.jsxs("div",{className:"mx-auto max-w-[72rem] rounded-sm border border-border/65 bg-background/58 px-3 py-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium text-foreground",children:[e.jsx(ku,{className:"h-3.5 w-3.5 text-primary"}),"Queued messages",e.jsx("span",{className:"ml-auto rounded-sm border border-border/60 bg-muted/60 px-1.5 py-0 text-[10px] text-muted-foreground",children:t.length})]}),e.jsx("div",{className:"mt-2 space-y-1.5",children:t.map((s,r)=>{const a=s.content.filter(i=>i.type==="image");return e.jsxs("div",{className:"flex min-w-0 items-start gap-2 text-[11px] leading-5 text-muted-foreground",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm bg-primary/10 text-[10px] font-medium text-primary",children:r+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[s.targetAgent&&e.jsxs("div",{"data-queued-message-target-agent":s.targetAgent,className:"mb-0.5 inline-flex h-5 max-w-[11rem] items-center gap-1 rounded-sm bg-primary/10 px-1.5 text-[10px] leading-3 text-primary",title:`Send to ${kt(s.targetAgent)}`,children:[e.jsx(Qo,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx(At,{agent:s.targetAgent,className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:kt(s.targetAgent)})]}),e.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:jh(s.content)}),a.length>0&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:a.map((i,l)=>e.jsx(Sr,{image:i,alt:i.filename??`queued attachment ${l+1}`,thumbnailClassName:"h-14 w-14 border border-border/65",imageClassName:"h-full w-full"},`${i.filename??"image"}-${l}`))})]}),n&&e.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 rounded-sm text-muted-foreground hover:text-destructive",title:"Cancel queued message","aria-label":"Cancel queued message",onClick:()=>n(s.id),children:e.jsx(ut,{className:"h-3 w-3"})})]},s.id)})})]})})}const kh="h-6 w-6 rounded-none border-b border-transparent !bg-transparent p-0 text-muted-foreground !shadow-none hover:text-foreground data-[state=active]:border-primary data-[state=active]:!bg-transparent data-[state=active]:text-primary data-[state=active]:!shadow-none",Sh=[{value:"transcript",label:"Transcript",icon:lc},{value:"files",label:"Files",icon:hn,activeIcon:rs},{value:"diff",label:"Diff",icon:Yn},{value:"preview",label:"Preview",icon:Gd}];function Ch({activeTab:t}){return e.jsx(os,{className:"h-auto max-w-full justify-start gap-2 overflow-x-auto rounded-sm !bg-muted/40 !p-0.5 !shadow-none",children:Sh.map(n=>{const s=n.value===t&&n.activeIcon?n.activeIcon:n.icon;return e.jsx(Ot,{value:n.value,title:n.label,"aria-label":n.label,className:kh,children:e.jsx(s,{className:"h-3.5 w-3.5","aria-hidden":"true"})},n.value)})})}const Li="pointer-events-auto h-5 w-5 shrink-0 rounded-sm bg-muted/65 text-muted-foreground hover:bg-muted hover:text-foreground",es="h-3.5 w-3.5";function mr({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,centerSlot:i}){return e.jsxs("div",{className:"relative flex w-full items-center justify-between gap-1.5",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:e.jsx(Bi,{desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:t,className:"lg:hidden"})}),i&&e.jsx("div",{className:"pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:e.jsx("div",{className:"pointer-events-auto",children:i})}),e.jsx(Oi,{operationsOpen:r,onToggleOperations:a,className:"xl:hidden"})]})}function Bi({className:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:r}){const a=globalThis.window?.matchMedia("(min-width: 1024px)")?.matches?n:s;return e.jsx(X,{variant:"ghost",size:"icon",onClick:r,title:a?"Hide tasks":"Show tasks","aria-label":a?"Hide tasks":"Show tasks",className:L(Li,t),children:a?e.jsx(Dn,{className:es}):e.jsx(nt,{className:es})})}function Oi({className:t,operationsOpen:n,onToggleOperations:s}){return e.jsx(X,{variant:"ghost",size:"icon",onClick:s,title:n?"Hide cluster":"Show cluster","aria-label":n?"Hide cluster":"Show cluster",className:L(Li,t),children:n?e.jsx(nt,{className:es}):e.jsx(Dn,{className:es})})}const ga="h-7 w-7 rounded-sm border-0 bg-primary/10 text-primary backdrop-blur hover:bg-primary/20 hover:text-primary";function Th({active:t,onScrollToBottom:n,onScrollToTop:s}){return e.jsxs("div",{className:L("pointer-events-none absolute right-3 top-1/2 z-10 flex -translate-y-1/2 flex-col gap-2 opacity-0 transition-opacity duration-200 group-hover:pointer-events-auto group-hover:opacity-100",t&&"pointer-events-auto opacity-100"),children:[e.jsx(X,{type:"button",variant:"ghost",size:"icon",className:ga,onClick:s,"aria-label":"Scroll to top",title:"Scroll to top",children:e.jsx(cc,{className:"h-4 w-4"})}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",className:ga,onClick:n,"aria-label":"Scroll to bottom",title:"Scroll to bottom",children:e.jsx(st,{className:"h-4 w-4"})})]})}function Ah(t){if(t.type!=="agent.handoff")return null;const n=typeof t.fromAgent=="string"&&t.fromAgent.trim()?t.fromAgent.trim():"agent",s=typeof t.toAgent=="string"&&t.toAgent.trim()?t.toAgent.trim():"";return s?{fromAgent:n,toAgent:s}:null}function Eh({fromAgent:t,toAgent:n}){return e.jsx("div",{className:"flex w-full justify-center py-0.5","data-agent-handoff":n,children:e.jsxs("div",{className:"inline-flex h-6 max-w-full items-center gap-1.5 rounded-sm border border-border/45 bg-muted/22 px-2 text-[10px] leading-3 text-muted-foreground/78",children:[e.jsx(At,{agent:t,className:"h-3 w-3 shrink-0 text-muted-foreground/65","aria-hidden":"true"}),e.jsxs("span",{className:"truncate",children:[kt(t)," to ",kt(n)]}),e.jsx(At,{agent:n,className:"h-3 w-3 shrink-0 text-primary/60","aria-hidden":"true"})]})})}const ba="h-[1.625rem] rounded-sm !border-0 !bg-transparent px-2 text-[10.5px] font-medium text-primary !shadow-none hover:!bg-transparent hover:text-primary/80 focus-visible:ring-1 focus-visible:ring-ring/50 focus-visible:ring-offset-0",Ut={content:"max-w-[20rem] gap-2.5 rounded-lg border-0 p-3.5 shadow-[0_18px_70px_-44px_rgba(0,0,0,0.72)] sm:max-w-[20rem]",header:"space-y-1 text-left",title:"text-[13px] leading-4",description:"text-[11px] leading-4",footer:"gap-1 pt-0 sm:space-x-1",cancel:`${ba} mt-0`,action:ba},Mh=30,Dh=1600;function _h({savedScrollTop:t,scrollHeight:n,clientHeight:s}){const r=Math.max(0,n-s);return Math.min(Math.max(0,t??r),r)}function ks(t){return t.scrollHeight-t.scrollTop-t.clientHeight<Mh}function va({explicitBottomStickUntil:t,now:n,wasAtBottom:s}){return s||t>n}function Ss(t,n){return!!(n&&(t===n||t.contains(n)))}function Cs(t){const n=t.ownerDocument.getSelection();if(!n||n.isCollapsed||n.rangeCount===0)return!1;if(Ss(t,n.anchorNode)||Ss(t,n.focusNode))return!0;for(let s=0;s<n.rangeCount;s+=1)if(Ss(t,n.getRangeAt(s).commonAncestorContainer))return!0;return!1}function Ph({atTop:t,inputCollapseDisabled:n,scrollingUp:s}){return!n&&(s||t)}function Ih({activeTab:t,activeTaskId:n,contentVersion:s,inputCollapseDisabled:r=!1,setActiveTab:a,setInputCollapsed:i}){const l=o.useRef(null),c=o.useRef(n),d=o.useRef(!1),m=o.useRef(0),p=o.useRef(new Map),u=o.useRef(0),h=o.useRef(!0),f=o.useCallback((x=c.current)=>{const v=l.current;!v||!x||(p.current.set(x,v.scrollTop),m.current=v.scrollTop,h.current=ks(v))},[]),j=o.useCallback((x=c.current)=>{const v=l.current;!v||!x||(v.scrollTop=_h({savedScrollTop:p.current.get(x),scrollHeight:v.scrollHeight,clientHeight:v.clientHeight}),m.current=v.scrollTop,h.current=ks(v))},[]),g=o.useCallback((x,v=c.current)=>{x.scrollTop=x.scrollHeight,m.current=x.scrollTop,h.current=!0,v&&p.current.set(v,x.scrollTop)},[]),w=o.useCallback((x=c.current)=>{const v=l.current;u.current=Date.now()+Dh,v&&(g(v,x),requestAnimationFrame(()=>{g(v,x),requestAnimationFrame(()=>g(v,x))}))},[g]),b=o.useCallback((x=c.current)=>{const v=l.current;u.current=0,v&&(v.scrollTop=0,m.current=0,h.current=!1,x&&p.current.set(x,0))},[]),k=o.useCallback(x=>{const v=x.currentTarget,N=m.current,A=v.scrollTop<N&&N-v.scrollTop>10,E=v.scrollTop<=0,M=Cs(v);if(f(),M){u.current=0;return}if(!d.current){if(ks(v)){i(!1),d.current=!0,setTimeout(()=>{d.current=!1},300);return}(A||E)&&(u.current=0,Ph({atTop:E,inputCollapseDisabled:r,scrollingUp:A})&&i(!0))}},[r,f,i]),y=o.useCallback(x=>{t==="transcript"&&f(),a(x),x==="transcript"&&requestAnimationFrame(()=>j())},[t,j,f,a]);return o.useLayoutEffect(()=>{r&&i(!1)},[r,i]),o.useLayoutEffect(()=>{const x=c.current;x&&x!==n&&f(x),c.current=n,t==="transcript"&&requestAnimationFrame(()=>j(n))},[n,t,j,f]),o.useLayoutEffect(()=>{const x=l.current;if(!x||t!=="transcript"||!n)return;const v=va({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:h.current});if(Cs(x)){u.current=0,f(n);return}v&&g(x,n),f(n)},[n,t,s,f,g]),o.useLayoutEffect(()=>{const x=l.current,v=x?.firstElementChild;if(!x||!v||t!=="transcript"||typeof ResizeObserver>"u")return;const N=new ResizeObserver(()=>{if(Cs(x)){u.current=0,f();return}va({explicitBottomStickUntil:u.current,now:Date.now(),wasAtBottom:h.current})?g(x):f()});return N.observe(x),N.observe(v),()=>N.disconnect()},[t,n,f,g]),{handleTranscriptScroll:k,handleTranscriptTabChange:y,scrollTranscriptToBottom:w,scrollTranscriptToTop:b,transcriptScrollRef:l}}function Fi(t=700){const[n,s]=o.useState(!1),r=o.useRef(null),a=o.useCallback(()=>{s(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>{s(!1),r.current=null},t)},[t]);return o.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),{markScrollbarActive:a,scrollbarActive:n}}const Rh="harness";function Lh(t){return typeof t=="object"&&t!==null}function Bh(t){return typeof t=="string"&&t.trim().length>0?t.trim():""}function Oh(t){return Lh(t.agentSessions)?Object.keys(t.agentSessions).map(n=>n.trim()).filter(Boolean):[]}function zi(t){return Bh(t.payload.activeAgent)||t.agent}function Ui(t){return new Set([t.agent,zi(t),...Oh(t.payload)].filter(Boolean)).size>1}function $i(t){return Ui(t)?Rh:t.agent}const Fh=o.lazy(async()=>({default:(await gr(()=>import("./FilesTab-CH1lwzT9.js"),__vite__mapDeps([0,1,2,3,4,5]))).FilesTab})),zh=o.lazy(async()=>({default:(await gr(()=>import("./PreviewTab-T_Y0AhqI.js").then(n=>n.c),__vite__mapDeps([6,1,2]))).PreviewTab})),Uh=o.lazy(async()=>({default:(await gr(()=>import("./DiffTab-Bf9BAMpM.js"),__vite__mapDeps([7,1,2,5,4,3,6]))).DiffTab}));function $h({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,activeTab:l,setActiveTab:c,creatingTask:d,createMode:m,createDefaults:p,activeTask:u,assignedNode:h,taskLoading:f,transcriptLoading:j,taskError:g,displayEvents:w,initialPromptAlreadyInLogs:b,initialPrompt:k,supportsFollowUp:y,taskUnavailable:x,chatDisabled:v,chatDisabledReason:N,questionBypassEnabled:A,isRunning:E,isStarting:M,hasPendingFollowUp:B,canCancel:D,canRetry:_,onRetry:P,onCancel:O,onReloadNativeTranscript:W,onShareTask:J,onStopShareTask:Y,onStartCreateTask:V,onCancelCreateTask:ne,onCreateTask:$,onSendMessage:ee,onCancelQueuedMessage:S,onQuestionBypassChange:Q,onSubmitQuestionResponse:T,quickChats:te=[]}){const[R,H]=o.useState(!1),[F,le]=o.useState(!1),[ie,ue]=o.useState(!1),[Z,K]=o.useState(!1),[I,se]=o.useState(!1),[q,ae]=o.useState({}),[ye,pe]=o.useState(new Set),[Ze,Ae]=o.useState(new Set),[ft,Re]=o.useState(null),[De,He]=o.useState(null),Ke=u?.effectiveProjectPath??u?.project??"default workspace",je=u?h?.name??er(u.assignedTo,i?.nodes,u.assignedNodeName):"unassigned",Be=u?$i(u):"",G=u?zi(u):"",ge=u&&Ui(u)?G:void 0,be=u?.assignedTo?e.jsxs(e.Fragment,{children:["Connecting session on node ",e.jsx("span",{className:"font-semibold",children:je}),"..."]}):"Connecting session to an available node...",et=u?[{label:"Working dir",value:Ke,mono:!0},...u.branch?[{label:"Branch",value:u.branch,mono:!0}]:[],{label:"Agent",value:Be,mono:!0},{label:"Node",value:je}]:[],_e=!!(k&&!b),rt=_e||w.length>0,re=E&&rt,Ne=(M||B||E)&&!re,Te=re?"The agent is still working on this conversation.":Ne?be:null,{collapsedButtonRunning:ve,showDockedProgress:at,showInlineProgress:Pe}=gh({hasTranscriptProgress:!!Te,hasVisibleTranscriptEvents:rt,inputCollapsed:R}),_t=u?.conversationKind==="nativeSession",pt=Bd(u),pn=j?"Loading transcript":_t?"No transcript imported":"Transcript is warming up",en=j?"Loading transcript...":_t?"Meshy could not find imported history for this native session yet.":"The opening prompt has been stored, but the agent has not emitted conversation output yet.",St=u?.queuedMessages??[],wt=o.useMemo(()=>Od(w),[w]),xn=o.useMemo(()=>{let me=u?.agent??"";return wt.map(ke=>{const Ge=Ah(ke.event);if(Ge)return me=Ge.toAgent,{...ke,agent:me,handoff:Ge};const Ue=typeof ke.event.agent=="string"&&ke.event.agent.trim()?ke.event.agent.trim():me;return{...ke,agent:Ue,handoff:null}})},[u?.agent,wt]),gn=o.useMemo(()=>{const me=u?.assignedTo?u.assignedTo===i?.self?.id?h?.supportedAgents??i.self.supportedAgents:h?.supportedAgents:i?.self?.supportedAgents;return dc({nodeSupportedAgents:me,taskAgent:u?.agent,activeAgent:typeof u?.payload.activeAgent=="string"?u.payload.activeAgent:void 0})},[h?.supportedAgents,i?.self?.id,i?.self?.supportedAgents,u?.assignedTo,u?.agent,u?.payload.activeAgent]),Pt=o.useMemo(()=>wt.findIndex(({event:me})=>qh(me)),[wt]),Ft=o.useMemo(()=>Fd("transcript",wt.map(me=>me.event)),[wt]),tn=u&&!ye.has(u.id)?q[u.id]??u.activeShare??null:null,Ct=u?.id??null,nn=`${Ct??"none"}:${w.length}:${St.length}:${_e?1:0}:${j?1:0}:${Pe?1:0}`,{handleTranscriptScroll:Fe,handleTranscriptTabChange:ot,scrollTranscriptToBottom:yt,scrollTranscriptToTop:Tt,transcriptScrollRef:U}=Ih({activeTab:l,activeTaskId:Ct,contentVersion:nn,inputCollapseDisabled:!!Te,setActiveTab:c,setInputCollapsed:H}),{markScrollbarActive:ze,scrollbarActive:Ie}=Fi(),We=o.useCallback(me=>{ze(),Fe(me)},[Fe,ze]),Qe=o.useCallback(me=>{Re(ke=>({path:me,requestId:(ke?.requestId??0)+1})),ot("files")},[ot]),sn=o.useCallback(me=>{He(ke=>({path:me,requestId:(ke?.requestId??0)+1})),ot("preview")},[ot]),xe=o.useCallback((me,ke)=>{yt(),ee(me,ke)},[ee,yt]);return o.useEffect(()=>{Re(null),He(null)},[Ct]),d?e.jsx(Vh,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:m,createDefaults:p,onCancel:ne,onCreated:$,quickChats:te}):!u&&f?e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(mr,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsxs("div",{className:"space-y-3 text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-sm border border-primary/20 bg-primary/10 text-primary shadow-none",children:e.jsx(he,{className:"h-5 w-5 animate-spin"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Loading conversation"}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx(he,{className:"h-3.5 w-3.5 animate-spin"}),"Fetching the selected chat thread..."]})]})]})})]}):u?e.jsxs(_r,{value:l,onValueChange:ot,className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsxs("div",{className:"dashboard-conversation-panel__header relative shrink-0 bg-card/28 px-3 pb-0.5 pt-1 sm:px-5 sm:pt-1.5",children:[e.jsxs("div",{className:"pointer-events-none absolute left-1 right-1 top-2 flex items-center justify-between sm:left-1.5 sm:right-1.5 sm:top-2.5",children:[e.jsx(Bi,{desktopTasksOpen:n,mobileTasksPanelOpen:s,onToggleTasks:t,className:"lg:hidden"}),e.jsx(Oi,{operationsOpen:r,onToggleOperations:a,className:"xl:hidden"})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 pl-5 sm:pl-6 lg:pl-0",children:[e.jsx("h2",{className:"min-w-0 truncate text-[13px] font-semibold leading-5 text-foreground sm:text-[15px]",title:u.title,children:u.title}),e.jsx(Io,{status:u.status,isNative:_t}),pt&&e.jsxs("span",{"data-task-goal-label":"true",title:"Codex goal",className:"inline-flex h-5 shrink-0 items-center gap-1 rounded-sm bg-primary/10 px-1.5 text-[9px] font-semibold uppercase tracking-[0.12em] text-primary",children:[e.jsx(qo,{className:"h-3 w-3","aria-hidden":"true"}),"Goal"]}),u.priority!=="normal"&&e.jsx(uc,{priority:u.priority})]}),g&&e.jsx("div",{className:"mt-2 w-fit rounded-sm border border-destructive/25 bg-destructive/10 px-2 py-1 text-[11px] text-destructive",children:g}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 pl-5 sm:pl-6 lg:pl-0",children:[e.jsx(Ch,{activeTab:l}),x&&e.jsx(Le,{variant:"outline",className:"hidden rounded-sm border-destructive/25 bg-destructive/10 text-destructive sm:inline-flex",children:"Unavailable"}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:"hidden rounded-sm bg-muted/65 px-1.5 py-0.5 tabular-nums sm:inline-flex",children:mc(u.updatedAt)}),_&&e.jsxs(X,{variant:"ghost",size:"sm",onClick:P,"aria-label":"Retry task",title:"Retry task",className:"h-7 shrink-0 rounded-sm border-0 bg-primary/10 px-2 text-[10px] text-primary shadow-none hover:bg-primary/15 hover:text-primary",children:[e.jsx(hc,{className:"h-3.5 w-3.5"}),"Retry"]}),_t&&W&&e.jsx(X,{variant:"ghost",size:"icon",onClick:W,disabled:j,title:"Reload native session transcript","aria-label":"Reload native session transcript",className:"h-6 w-6 shrink-0 rounded-sm text-muted-foreground hover:bg-muted/55 hover:text-foreground",children:e.jsx(ni,{className:L("h-3.5 w-3.5",j&&"animate-spin")})}),e.jsx(X,{type:"button",variant:"ghost",size:"icon",disabled:x,title:x?"Unavailable tasks cannot be shared.":"Share conversation","aria-label":x?"Unavailable tasks cannot be shared.":"Share conversation",className:"h-6 w-6 shrink-0 rounded-sm text-primary hover:bg-primary/10 hover:text-primary disabled:bg-transparent disabled:text-muted-foreground",onClick:()=>ue(!0),children:e.jsx(Zn,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsx(bt,{value:"transcript",className:"mt-0 min-h-0 flex-1",children:e.jsxs("div",{className:"group relative flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"relative min-h-0 flex-1",children:e.jsx("div",{ref:U,"data-transcript-scroll":"true",className:L("scrollbar-line h-full min-h-0 touch-pan-y overflow-x-hidden overflow-y-auto overscroll-x-none bg-gradient-to-b from-background/15 via-transparent to-background/35 px-3 pb-4 pt-4 sm:px-5",Ie&&"scrollbar-line-active"),onScroll:We,children:e.jsxs("div",{"data-transcript-scroll-content":"true",className:"mx-auto flex max-w-[72rem] flex-col gap-4",children:[_e&&k&&e.jsx(oa,{event:k,agent:u.agent,sentAsGoal:pt,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Qe,questionBypassEnabled:A,onQuestionBypassChange:Q,onSubmitQuestionResponse:T,questionResponseDisabled:!y||v}),xn.map(({event:me,subItems:ke,agent:Ge,handoff:Ue},zt)=>Ue?e.jsx(Eh,{fromAgent:Ue.fromAgent,toAgent:Ue.toAgent},Ft[zt]):e.jsx(oa,{event:me,agent:Ge,subItems:ke,sentAsGoal:pt&&!_e&&zt===Pt,taskRootPath:u.effectiveProjectPath,onOpenFilePath:Qe,questionBypassEnabled:A,onQuestionBypassChange:Q,onSubmitQuestionResponse:T,questionResponseDisabled:!y||v},Ft[zt])),!rt&&!Ne&&e.jsxs("div",{className:"rounded-sm border border-dashed border-border/70 bg-background/35 px-3 py-4 text-center",children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground",children:pn}),e.jsx("div",{className:"mt-2 text-[11px] leading-6 text-muted-foreground",children:en})]}),(!y&&u.result||u.error)&&e.jsxs("div",{className:"space-y-3",children:[!y&&u.result&&e.jsxs("div",{className:"rounded-sm border border-border/70 bg-card/80 px-3 py-3",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Stored result"}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5 text-muted-foreground",children:JSON.stringify(u.result,null,2)})]}),u.error&&!Ze.has(u.id)&&e.jsxs("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-3 text-destructive",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.22em]",children:"Stored error"}),e.jsx("button",{onClick:()=>Ae(me=>new Set(me).add(u.id)),className:"rounded p-0.5 hover:bg-destructive/20","aria-label":"Dismiss error",children:e.jsx(ut,{className:"h-3.5 w-3.5"})})]}),e.jsx("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap text-[11px] leading-5",children:u.error})]})]}),Pe&&Te&&e.jsx(pa,{children:Te})]})})}),e.jsx(Th,{active:Ie,onScrollToBottom:()=>yt(),onScrollToTop:()=>Tt()}),at&&Te&&e.jsx("div",{"data-docked-progress":"true",className:"shrink-0 bg-background/35 px-3 py-1 sm:px-5",children:e.jsx("div",{className:"mx-auto max-w-[72rem]",children:e.jsx(pa,{children:Te})})}),y?e.jsxs(e.Fragment,{children:[R&&e.jsx(xh,{running:ve,onClick:()=>{H(!1),yt(),requestAnimationFrame(()=>document.querySelector('[data-chat-input-textarea="true"]')?.focus())}}),e.jsxs("div",{className:`shrink-0 ${R?"hidden":""}`,children:[e.jsx(Nh,{messages:St,onCancelMessage:S}),e.jsx(jm,{onSend:xe,disabled:v,disabledReason:N,contextItems:et,agent:u.agent,currentAgent:ge,taskId:u.id,availableAgents:gn,model:typeof u.payload.model=="string"?u.payload.model:null,placeholder:v?N:E?"Queue a message for the next turn...":"Continue the conversation...",running:E||M||B,onStop:D?()=>le(!0):void 0,quickChats:te})]})]}):e.jsx("div",{className:"shrink-0 border-t border-border/60 px-3 py-3 text-[11px] text-muted-foreground sm:px-5",children:"This task does not expose follow-up chat messages. Use Files, Preview, or Diff to inspect the result."})]})}),e.jsx(bt,{value:"files",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(vs,{label:"Loading files..."}),children:e.jsx(Fh,{taskId:u.id,requestedFilePath:ft?.path??null,requestedFileRequestId:ft?.requestId??0,onPreviewFile:sn})})}),e.jsx(bt,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(vs,{label:"Loading preview..."}),children:e.jsx(zh,{taskId:u.id,requestedEntryPath:De?.path??null,requestedEntryRequestId:De?.requestId??0})})}),e.jsx(bt,{value:"diff",className:"mt-0 min-h-0 flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(vs,{label:"Loading diff..."}),children:e.jsx(Uh,{taskId:u.id})})}),e.jsx($t,{open:F,onOpenChange:le,children:e.jsxs(qt,{className:Ut.content,children:[e.jsxs(Vt,{className:Ut.header,children:[e.jsx(Ht,{className:Ut.title,children:"Stop this task?"}),e.jsx(Kt,{className:Ut.description,children:"The task will stop and move to a cancelled state."})]}),e.jsxs(Gt,{className:Ut.footer,children:[e.jsx(Wt,{className:Ut.cancel,children:"Keep running"}),e.jsx(Qt,{className:Ut.action,onClick:O,children:"Stop task"})]})]})}),e.jsx(bh,{open:ie,onOpenChange:ue,sharing:Z,stopping:I,shareResult:tn,onShare:async me=>{if(!u)return null;K(!0);try{const ke=await J(me);return ke?.url&&(ae(Ge=>({...Ge,[u.id]:ke})),pe(Ge=>{const Ue=new Set(Ge);return Ue.delete(u.id),Ue})),ke}finally{K(!1)}},onStopShare:async()=>{if(!u)return!1;se(!0);try{const me=await Y();return me!==!1&&(ae(ke=>{const Ge={...ke};return delete Ge[u.id],Ge}),pe(ke=>new Set(ke).add(u.id))),me}finally{se(!1)}}})]}):e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(mr,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a})}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsxs("div",{className:"w-full max-w-lg text-center",children:[e.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-sm border border-primary/20 bg-primary/10 text-primary shadow-none",children:e.jsx(Po,{className:"h-5 w-5"})}),e.jsx("h2",{className:"mt-3 text-sm font-semibold tracking-tight text-foreground sm:text-[15px]",children:"No chat selected"}),e.jsx("p",{className:"mx-auto mt-2 max-w-md text-[11px] leading-5 text-muted-foreground",children:"Open a task from the left sidebar to continue the conversation, or start a new task or load a native session."}),e.jsxs(X,{onClick:()=>V(),className:"mt-4 h-8 rounded-sm px-3",children:[e.jsx(Ln,{className:"h-3.5 w-3.5"}),"Start or load chat"]}),g&&e.jsx("div",{className:"mx-auto mt-3 max-w-md rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:g})]})})]})}function qh(t){return t.type!=="user"||t.isMeta===!0||t.isSidechain===!0?!1:!!Cr(t)?.some(s=>s.type==="text"||s.type==="image")}function Vh({onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,cluster:i,defaultMode:l,createDefaults:c,onCancel:d,onCreated:m,quickChats:p}){const[u,h]=o.useState(l??"chat");o.useEffect(()=>{l&&h(l)},[l]);const f=e.jsx("div",{className:"flex h-8 items-center gap-0.5 overflow-hidden rounded-sm border border-border/60 bg-background/65 p-0.5 text-[11px] font-medium shadow-none",children:[{value:"chat",label:"New chat",icon:Ln},{value:"native",label:"Load session",icon:Ar}].map(j=>{const g=j.icon,w=j.value===u;return e.jsxs("button",{type:"button",onClick:()=>h(j.value),"aria-pressed":w,className:L("flex h-7 min-w-28 items-center justify-center gap-1.5 rounded-sm border border-transparent px-2.5 transition-colors duration-150",w?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-background/80 hover:text-foreground"),children:[e.jsx(g,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:j.label})]},j.value)})});return e.jsxs("div",{className:"dashboard-conversation-panel dashboard-panel animate-panel-settle flex h-full min-h-0 flex-col overflow-hidden rounded-xl",children:[e.jsx("div",{className:"dashboard-conversation-panel__header shrink-0 bg-card/28 px-3 py-3 sm:px-5",children:e.jsx(mr,{onToggleTasks:t,desktopTasksOpen:n,mobileTasksPanelOpen:s,operationsOpen:r,onToggleOperations:a,centerSlot:f})}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center overflow-y-auto px-4 py-6 sm:px-6",children:e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(ph,{nodes:i?.nodes??[],currentNodeRole:i?.self?.role,currentNodeId:i?.self?.id??null,leaderNodeId:i?.leader?.id??null,initialAssignTo:c?.assignTo,initialProject:c?.project,mode:u,onModeChange:h,onCreated:m,onCancel:d,autoFocus:!0,layout:"composer",defaultTaskAgent:i?.self.settingsSnapshot?.defaultTaskAgent,quickChats:p})})})]})}function Hh({onAdded:t}){const[n,s]=o.useState(""),[r,a]=o.useState(!1),[i,l]=o.useState(null),c=o.useCallback(async d=>{if(d.preventDefault(),!!n.trim()){a(!0),l(null);try{await fc({leaderEndpoint:n.trim(),transport:"devtunnel"}),t()}catch(m){l(m instanceof Error?m.message:"Failed to join node")}finally{a(!1)}}},[n,t]);return e.jsx(ht,{className:"overflow-hidden border-border/60 bg-transparent p-0 shadow-none sm:max-w-xl",children:e.jsxs("div",{className:"overflow-hidden rounded-sm border border-border/60 bg-background/95 p-0 shadow-[0_28px_90px_-58px_rgba(0,0,0,0.88)] backdrop-blur-xl",children:[e.jsx("div",{className:"border-b border-border/60 px-3.5 py-2.5",children:e.jsxs(Mt,{className:"space-y-1 text-left",children:[e.jsx(vt,{className:"text-sm tracking-tight",children:"Join node"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Verify the remote leader's DevTunnel Node URL, sync this node's tasks to that leader, and join the cluster as a follower."})]})}),e.jsxs("form",{onSubmit:c,className:"space-y-3 px-3.5 py-3",children:[i&&e.jsx("div",{className:"rounded-sm border border-destructive/20 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(tt,{htmlFor:"leader-endpoint",children:"Leader Node URL"}),e.jsx(Le,{variant:"outline",className:"rounded-sm border-border/70 bg-background/60 text-[10px] uppercase tracking-[0.16em]",children:"DevTunnel only"})]}),e.jsx(dt,{id:"leader-endpoint",type:"url",value:n,onChange:d=>s(d.target.value),placeholder:"https://your-leader.devtunnels.ms",className:"h-8 rounded-sm border-border/70 bg-background/70"})]}),e.jsx("div",{className:"rounded-sm border border-border/60 bg-background/45 px-3 py-2 text-[11px] text-muted-foreground",children:"This does not switch the local node transport or auto-enable a local DevTunnel. Leaving later will detach this node from the remote leader and make it leader of its own cluster again."}),e.jsx(br,{className:"border-t border-border/60 pt-3",children:e.jsx(X,{type:"submit",disabled:!n.trim()||r,className:"rounded-sm",children:r?"Joining...":"Join node"})})]})]})})}function Kh({open:t,onOpenChange:n,onAdded:s}){return e.jsx(mt,{open:t,onOpenChange:n,children:e.jsx(Hh,{onAdded:()=>{n(!1),s()}})})}const Gh="pointer-events-auto absolute top-1/2 z-30 hidden h-10 w-4 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground opacity-0 outline-none transition-opacity duration-150 hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring/55",Wh="flex h-7 w-3.5 items-center justify-center rounded-full bg-muted/85 shadow-[0_12px_24px_-20px_rgba(0,0,0,0.9)] backdrop-blur-sm transition-colors hover:bg-card hover:text-foreground",Qh="h-2.5 w-2.5";function qi({className:t,label:n,orientation:s,panel:r,panelResize:a}){return e.jsx("button",{type:"button","aria-label":n,"aria-orientation":s,"data-dashboard-resize-handle":r,onPointerDown:i=>a.onPointerDown(r,i),onWheel:i=>a.onWheel(r,i),className:L("pointer-events-auto group absolute z-20 hidden touch-none rounded-sm bg-transparent outline-none transition-colors hover:bg-primary/12 focus-visible:bg-primary/12 focus-visible:ring-2 focus-visible:ring-ring/70 lg:block",t),children:e.jsx("span",{className:"pointer-events-none absolute inset-0 opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100"})})}function Yh({className:t,label:n,onToggle:s,side:r,visible:a}){const i=r==="left"?a?Dn:nt:a?nt:Dn;return e.jsx("button",{type:"button","aria-label":n,title:n,onClick:s,className:L(Gh,t),children:e.jsx("span",{className:Wh,"aria-hidden":"true",children:e.jsx(i,{className:Qh,strokeWidth:2.1})})})}function wa({className:t,label:n,onToggle:s,panel:r,panelResize:a,screen:i,side:l,visible:c}){const d=i==="lg"?"lg:block":"xl:block",m=i==="lg"?"lg:flex":"xl:flex";return e.jsxs("div",{className:L("group pointer-events-none absolute top-0 z-30 hidden h-full w-4",d,t),children:[r&&e.jsx(qi,{panel:r,orientation:"vertical",label:`Resize ${r} panel`,panelResize:a,className:"left-1/2 top-0 h-full w-2 cursor-col-resize"}),e.jsx(Yh,{side:l,visible:c,label:n,onToggle:s,className:L(m,"left-1/2 -translate-x-1/2 group-hover:opacity-100")})]})}function Jh({conversationPanel:t,desktopTasksOpen:n,mobileTaskSidebar:s,mobileTasksPanelOpen:r,mobileTasksPanelRef:a,operationsOpen:i,operationsPanelRef:l,operationsSidecar:c,panelResize:d,taskSidebar:m,terminalPanel:p,onCloseOperations:u,onCloseTaskList:h,onToggleOperations:f,onToggleTasks:j}){const g={"--dashboard-tasks-width":d.sizes.tasks,"--dashboard-operations-width":d.sizes.operations,"--dashboard-terminal-height":d.sizes.terminal};return e.jsxs("div",{className:"dashboard-workspace flex h-full min-h-0 flex-col overflow-hidden",style:g,children:[e.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[e.jsx(wa,{screen:"lg",side:"left",visible:n,label:n?"Hide tasks":"Show tasks",onToggle:j,panel:n?"tasks":void 0,panelResize:d,className:n?"left-[var(--dashboard-tasks-width)] -translate-x-1/2":"left-0"}),e.jsx("div",{className:L("dashboard-workspace__tasks-panel relative hidden lg:block lg:shrink-0 lg:transition-all lg:duration-300",n?"lg:mr-2 lg:w-[var(--dashboard-tasks-width)]":"lg:w-0 lg:overflow-hidden"),children:n&&m}),e.jsxs("section",{className:"dashboard-workspace__primary flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[e.jsx("div",{className:"min-h-0 flex-1",children:t}),p&&e.jsxs("div",{className:"relative h-[var(--dashboard-terminal-height)] min-h-0 shrink-0",children:[e.jsx(qi,{panel:"terminal",orientation:"horizontal",label:"Resize terminal panel",panelResize:d,className:"-top-1 left-0 h-2 w-full cursor-row-resize"}),p]})]}),e.jsx(wa,{screen:"xl",side:"right",visible:i,label:i?"Hide cluster":"Show cluster",onToggle:f,panel:i?"operations":void 0,panelResize:d,className:i?"right-[var(--dashboard-operations-width)] translate-x-1/2":"right-0"}),e.jsx("div",{className:L("dashboard-workspace__operations-panel relative hidden xl:block xl:shrink-0 xl:transition-all xl:duration-300",i?"xl:ml-2 xl:w-[var(--dashboard-operations-width)]":"xl:w-0 xl:overflow-hidden"),children:i&&c})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close operations panel",onClick:u,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm xl:hidden"}),e.jsx("div",{ref:l,className:"fixed bottom-0 right-0 top-[var(--dashboard-mobile-overlay-top)] z-40 w-full p-2 sm:max-w-sm sm:p-3 xl:hidden",children:c})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","aria-label":"Close task list",onClick:h,className:"fixed inset-0 z-30 bg-black/45 backdrop-blur-sm lg:hidden"}),e.jsx("div",{ref:a,className:"fixed bottom-0 left-0 top-[var(--dashboard-mobile-overlay-top)] z-40 w-full p-2 sm:max-w-sm sm:p-3 lg:hidden",children:s})]})]})}const Zh=10,Yt="__all__";function lt(t){return"session"in t}function ya(t,n){return n&&t.some(s=>s.id===n)?n:t[0]?.id??""}function Ts(t){return t&&(Di(t.id)||t.workDir)||""}function qn(t,n,s){let r=!1;const a=t.map(i=>lt(i)&&i.session.id===s.id?(r=!0,{...i,nodeName:n,session:s}):i);return hr(r?a:[...a,{id:`session-${s.id}`,nodeName:n,session:s}])}function Vi(t,n){return t.filter(lt).filter(s=>s.session.nodeId===n).sort((s,r)=>r.session.startedAt-s.session.startedAt)}function Xh(t){const n=t.filter(lt).sort((s,r)=>r.session.startedAt-s.session.startedAt);return{active:n.filter(s=>s.session.status==="running"),completed:n.filter(s=>s.session.status!=="running")}}function ef(t,n){return!!(t&&n&&!t.contains(n))}function tf(t,n,s){if(s===Yt)return s;const r=Vi(t,n);return r.some(a=>a.session.id===s)?s:r[0]?.session.id??Yt}function nf(t,n,s){return s===Yt?t.filter(r=>!lt(r)||r.session.nodeId===n):t.filter(r=>lt(r)&&r.session.nodeId===n&&r.session.id===s)}function hr(t){const n=t.map((r,a)=>({entry:r,index:a})).filter(({entry:r})=>lt(r)&&r.session.status!=="running").sort((r,a)=>!lt(r.entry)||!lt(a.entry)?0:a.entry.session.startedAt-r.entry.session.startedAt||a.index-r.index),s=new Set(n.slice(0,Zh).map(({entry:r})=>lt(r)?r.session.id:""));return t.filter(r=>!lt(r)||r.session.status==="running"||s.has(r.session.id))}function fr(t){return t.status==="running"?t.pid?`running pid ${t.pid}`:"running":t.status==="exited"?`exit ${t.exitCode??0}`:t.status==="stopped"?"stopped":t.signal?`failed ${t.signal}`:`exit ${t.exitCode??"failed"}`}function sf(t){const n=t.session.command.length>48?`${t.session.command.slice(0,45)}...`:t.session.command;return`${t.nodeName} - ${fr(t.session)} - ${n}`}function Hi(t,n=48){return t.length>n?`${t.slice(0,n-3)}...`:t}function rf(t,n){return n===Yt?"All sessions":t?Hi(t.session.command,34):"Command session"}function ja(t){return t.status==="stopped"?"":t.stderr}function af({nodes:t,defaultNodeId:n,onClose:s,initialHistory:r=[]}){const[a,i]=o.useState(()=>ya(t,n)),l=o.useMemo(()=>t.find(T=>T.id===a)??t[0]??null,[t,a]),[c,d]=o.useState(()=>Ts(l)),[m,p]=o.useState(""),[u,h]=o.useState(()=>hr(r)),[f,j]=o.useState(Yt),[g,w]=o.useState(!1),[b,k]=o.useState(!1),[y,x]=o.useState(!1),[v,N]=o.useState(!1),[A,E]=o.useState(!1),M=o.useRef(null),B=o.useRef(null),D=o.useMemo(()=>t.find(T=>T.id===a)??t[0]??null,[t,a]),_=o.useMemo(()=>Vi(u,D?.id??""),[u,D]),P=o.useMemo(()=>Xh(_),[_]),O=o.useMemo(()=>_.find(T=>T.session.id===f),[f,_]),W=o.useMemo(()=>nf(u,D?.id??"",f),[u,D,f]),J=o.useRef(D?.id??"");o.useEffect(()=>{a&&t.some(T=>T.id===a)||i(ya(t,n))},[n,t,a]),o.useEffect(()=>{const T=D?.id??"";J.current!==T&&(J.current=T,d(Ts(D)))},[D]),o.useEffect(()=>{j(T=>tf(u,D?.id??"",g?T:""))},[u,D,g]),o.useEffect(()=>{M.current?.scrollTo({top:M.current.scrollHeight})},[u]),o.useEffect(()=>{let T=!1;async function te(){const R=await Promise.allSettled(t.map(async H=>({node:H,response:await xc(H.id)})));T||h(H=>R.reduce((F,le)=>le.status!=="fulfilled"?F:le.value.response.sessions.reduce((ie,ue)=>qn(ie,le.value.node.name,ue),F),H))}return t.length>0&&te(),()=>{T=!0}},[t]),o.useEffect(()=>{const T=u.filter(lt).filter(R=>R.session.status==="running");if(T.length===0)return;const te=window.setInterval(()=>{for(const R of T)pc(R.session.nodeId,R.session.id).then(H=>h(F=>qn(F,R.nodeName,H))).catch(()=>{})},1e3);return()=>window.clearInterval(te)},[u]);const Y=o.useRef(null);async function V(T){if(T.preventDefault(),!D||!m.trim()||A)return;const te=m.trim(),R=D.name;E(!0),p("");try{const H=await bc(D.id,{command:te,...c.trim()?{cwd:c.trim()}:{}});h(F=>qn(F,R,H)),j(H.id),w(!0)}catch(H){h(F=>[...F,{id:`${Date.now()}-${Math.random().toString(16).slice(2)}`,nodeName:R,command:te,error:H instanceof Error?H.message:"Command failed"}])}finally{E(!1)}}async function ne(T,te){T.stopPropagation();const R=await gc(te.session.nodeId,te.session.id);h(H=>qn(H,te.nodeName,R))}function $(T){j(T),w(!0),k(!1)}function ee(T){b&&ef(B.current,T.target)&&k(!1)}function S(T,te,R,H,F){return e.jsxs("div",{className:"border-t border-border/60 py-1",children:[e.jsxs("button",{type:"button",onClick:H,"aria-label":`Toggle ${T} sessions`,"aria-expanded":!R,className:"node-terminal__small flex w-full items-center justify-between gap-2 px-2 pb-1 pt-0.5 text-left font-medium uppercase tracking-normal text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{children:T}),e.jsx(st,{className:L("h-3 w-3 transition-transform",R&&"-rotate-90")})]}),!R&&(te.length>0?te.map(Q):e.jsx("div",{className:"node-terminal__control px-2 py-1 text-muted-foreground",children:F}))]})}function Q(T){const te=f===T.session.id,R=T.session.status==="running";return e.jsxs("div",{className:L("node-terminal__control group flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65",te&&"bg-primary/10 text-primary"),children:[e.jsxs("button",{type:"button",onClick:()=>$(T.session.id),className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:[e.jsx("span",{className:L("flex h-4 w-4 shrink-0 items-center justify-center",R?"text-primary":T.session.status==="exited"?"text-emerald-600 dark:text-emerald-300":"text-amber-600 dark:text-amber-300"),children:R?e.jsx(he,{className:"h-3 w-3 animate-spin"}):T.session.status==="exited"?e.jsx(tr,{className:"h-3 w-3"}):e.jsx(gs,{className:"h-3 w-3"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-foreground",children:Hi(T.session.command,44)}),e.jsxs("span",{className:"node-terminal__small block truncate text-muted-foreground",children:[T.nodeName," · ",fr(T.session)]})]})]}),R&&e.jsx("button",{type:"button",onClick:H=>{ne(H,T)},"aria-label":"Stop terminal session from selector",title:"Stop terminal session",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Wr,{className:"h-3 w-3"})})]},T.session.id)}return e.jsx("section",{className:"dashboard-panel node-terminal animate-composer-settle flex h-full min-h-0 shrink-0 overflow-visible rounded-xl","aria-label":"Node terminal",onClick:ee,children:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col overflow-visible rounded-[inherit] bg-card/72 text-card-foreground",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"node-terminal__header flex min-w-0 items-center gap-2 font-medium",children:[s?e.jsx("button",{type:"button",onClick:s,"aria-label":"Close terminal",title:"Close terminal",className:"flex h-6 w-6 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(ut,{className:"h-3.5 w-3.5"})}):e.jsx(Gr,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{children:"Terminal"})]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-2",children:[e.jsxs("div",{ref:B,className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-label":"Command session","aria-expanded":b,title:O?sf(O):"All sessions",onClick:()=>k(T=>!T),className:"node-terminal__control flex h-7 max-w-[14rem] list-none items-center gap-1.5 rounded-sm border border-border/70 bg-background/70 px-2 text-foreground outline-none transition-colors hover:bg-muted/65 focus-visible:ring-2 focus-visible:ring-ring/70 [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{className:"min-w-0 truncate",children:rf(O,f)}),e.jsx(st,{className:L("h-3 w-3 shrink-0 text-muted-foreground transition-transform",b&&"rotate-180")})]}),e.jsx("div",{"aria-hidden":!b,className:L("absolute right-0 bottom-9 z-30 w-[19rem] overflow-hidden rounded-xl border border-border/70 bg-popover text-popover-foreground shadow-xl",!b&&"hidden"),children:e.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[e.jsxs("button",{type:"button",onClick:()=>$(Yt),className:L("node-terminal__control flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",f===Yt&&"bg-primary/10 text-primary"),children:[e.jsx(Gr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:"All sessions"})]}),S("Active",P.active,y,()=>x(T=>!T),"No active sessions"),S("Completed",P.completed,v,()=>N(T=>!T),"No completed sessions")]})})]}),e.jsx("select",{value:D?.id??"",onChange:T=>{i(T.target.value),w(!1),d(Ts(t.find(te=>te.id===T.target.value)??null))},disabled:A||t.length===0,"aria-label":"Terminal node",className:"node-terminal__control h-7 max-w-[11rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground outline-none transition-colors hover:bg-muted/65 disabled:opacity-50",children:t.map(T=>e.jsx("option",{value:T.id,className:"bg-background text-foreground",children:T.name},T.id))}),e.jsx(Xn,{value:c,onChange:d,assignTo:D?.id??"",nodes:t,assignableNodes:t,layout:"composer",chipClassName:"node-terminal__control h-7 max-w-[18rem] rounded-sm border border-border/70 bg-background/70 px-2 text-foreground hover:bg-muted/65",chipActiveClassName:"font-mono",chipInactiveClassName:"text-muted-foreground",labelClassName:"node-terminal__workdir",triggerClassName:"terminal-workdir-trigger",popoverPlacement:"top",popoverAlign:"end"})]})]}),e.jsxs("div",{ref:M,className:"node-terminal__body min-h-0 flex-1 overflow-y-auto bg-muted/22 px-3 py-2 font-mono cursor-text",onClick:()=>Y.current?.focus(),children:[W.length===0?e.jsx("div",{className:"text-muted-foreground mb-2",children:"Commands run on the selected node and stay visible while running or after exit."}):e.jsx("div",{className:"space-y-3 mb-2",children:W.map(T=>lt(T)?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[T.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:T.session.command}),e.jsxs("span",{className:L("inline-flex items-center gap-1",T.session.status==="running"||T.session.status==="exited"?"text-primary":"text-amber-600 dark:text-amber-300"),children:[T.session.status==="running"?e.jsx(he,{className:"h-3 w-3 animate-spin"}):T.session.status==="exited"?e.jsx(tr,{className:"h-3 w-3"}):e.jsx(gs,{className:"h-3 w-3"}),fr(T.session)]}),T.session.status==="running"&&e.jsx("button",{type:"button",onClick:te=>{ne(te,T)},"aria-label":"Stop terminal session",title:"Stop terminal session",className:"inline-flex h-5 w-5 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted/65 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",children:e.jsx(Wr,{className:"h-3 w-3"})})]}),T.session.stdout&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-foreground",children:T.session.stdout}),ja(T.session)&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:ja(T.session)}),(T.session.stdoutTruncated||T.session.stderrTruncated)&&e.jsx("div",{className:"text-muted-foreground",children:"Output truncated to the latest output."})]},T.id):e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[e.jsxs("span",{className:"text-primary",children:[T.nodeName,"$"]}),e.jsx("span",{className:"break-all text-foreground",children:T.command}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(gs,{className:"h-3 w-3"}),"error"]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words text-destructive",children:T.error})]},T.id))}),e.jsxs("form",{onSubmit:V,className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"shrink-0 text-primary select-none",children:D?`${D.name}$`:"$"}),e.jsx("input",{ref:Y,value:m,onChange:T=>p(T.target.value),disabled:!D||A,placeholder:D?"":"No online nodes available",className:"node-terminal__input flex-1 min-w-0 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground font-mono caret-primary disabled:opacity-50",autoComplete:"off",spellCheck:!1}),e.jsx("button",{type:"submit","aria-label":"Run",title:"Run",disabled:!D||!m.trim()||A,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md text-primary transition-colors hover:bg-muted/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 disabled:pointer-events-none disabled:text-muted-foreground disabled:opacity-50",children:A?e.jsx(he,{className:"h-3 w-3 animate-spin"}):e.jsx(ss,{className:"h-3 w-3"})})]})]})]})})}var ln={},As,Na;function of(){return Na||(Na=1,As=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),As}var Es={},Lt={},ka;function Zt(){if(ka)return Lt;ka=1;let t;const n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Lt.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},Lt.getSymbolTotalCodewords=function(r){return n[r]},Lt.getBCHDigit=function(s){let r=0;for(;s!==0;)r++,s>>>=1;return r},Lt.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},Lt.isKanjiModeEnabled=function(){return typeof t<"u"},Lt.toSJIS=function(r){return t(r)},Lt}var Ms={},Sa;function Ir(){return Sa||(Sa=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function n(s){if(typeof s!="string")throw new Error("Param is not a string");switch(s.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+s)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,a){if(t.isValid(r))return r;try{return n(r)}catch{return a}}})(Ms)),Ms}var Ds,Ca;function lf(){if(Ca)return Ds;Ca=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(n){const s=Math.floor(n/8);return(this.buffer[s]>>>7-n%8&1)===1},put:function(n,s){for(let r=0;r<s;r++)this.putBit((n>>>s-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(n){const s=Math.floor(this.length/8);this.buffer.length<=s&&this.buffer.push(0),n&&(this.buffer[s]|=128>>>this.length%8),this.length++}},Ds=t,Ds}var _s,Ta;function cf(){if(Ta)return _s;Ta=1;function t(n){if(!n||n<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=n,this.data=new Uint8Array(n*n),this.reservedBit=new Uint8Array(n*n)}return t.prototype.set=function(n,s,r,a){const i=n*this.size+s;this.data[i]=r,a&&(this.reservedBit[i]=!0)},t.prototype.get=function(n,s){return this.data[n*this.size+s]},t.prototype.xor=function(n,s,r){this.data[n*this.size+s]^=r},t.prototype.isReserved=function(n,s){return this.reservedBit[n*this.size+s]},_s=t,_s}var Ps={},Aa;function df(){return Aa||(Aa=1,(function(t){const n=Zt().getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const a=Math.floor(r/7)+2,i=n(r),l=i===145?26:Math.ceil((i-13)/(2*a-2))*2,c=[i-7];for(let d=1;d<a-1;d++)c[d]=c[d-1]-l;return c.push(6),c.reverse()},t.getPositions=function(r){const a=[],i=t.getRowColCoords(r),l=i.length;for(let c=0;c<l;c++)for(let d=0;d<l;d++)c===0&&d===0||c===0&&d===l-1||c===l-1&&d===0||a.push([i[c],i[d]]);return a}})(Ps)),Ps}var Is={},Ea;function uf(){if(Ea)return Is;Ea=1;const t=Zt().getSymbolSize,n=7;return Is.getPositions=function(r){const a=t(r);return[[0,0],[a-n,0],[0,a-n]]},Is}var Rs={},Ma;function mf(){return Ma||(Ma=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const n={N1:3,N2:3,N3:40,N4:10};t.isValid=function(a){return a!=null&&a!==""&&!isNaN(a)&&a>=0&&a<=7},t.from=function(a){return t.isValid(a)?parseInt(a,10):void 0},t.getPenaltyN1=function(a){const i=a.size;let l=0,c=0,d=0,m=null,p=null;for(let u=0;u<i;u++){c=d=0,m=p=null;for(let h=0;h<i;h++){let f=a.get(u,h);f===m?c++:(c>=5&&(l+=n.N1+(c-5)),m=f,c=1),f=a.get(h,u),f===p?d++:(d>=5&&(l+=n.N1+(d-5)),p=f,d=1)}c>=5&&(l+=n.N1+(c-5)),d>=5&&(l+=n.N1+(d-5))}return l},t.getPenaltyN2=function(a){const i=a.size;let l=0;for(let c=0;c<i-1;c++)for(let d=0;d<i-1;d++){const m=a.get(c,d)+a.get(c,d+1)+a.get(c+1,d)+a.get(c+1,d+1);(m===4||m===0)&&l++}return l*n.N2},t.getPenaltyN3=function(a){const i=a.size;let l=0,c=0,d=0;for(let m=0;m<i;m++){c=d=0;for(let p=0;p<i;p++)c=c<<1&2047|a.get(m,p),p>=10&&(c===1488||c===93)&&l++,d=d<<1&2047|a.get(p,m),p>=10&&(d===1488||d===93)&&l++}return l*n.N3},t.getPenaltyN4=function(a){let i=0;const l=a.data.length;for(let d=0;d<l;d++)i+=a.data[d];return Math.abs(Math.ceil(i*100/l/5)-10)*n.N4};function s(r,a,i){switch(r){case t.Patterns.PATTERN000:return(a+i)%2===0;case t.Patterns.PATTERN001:return a%2===0;case t.Patterns.PATTERN010:return i%3===0;case t.Patterns.PATTERN011:return(a+i)%3===0;case t.Patterns.PATTERN100:return(Math.floor(a/2)+Math.floor(i/3))%2===0;case t.Patterns.PATTERN101:return a*i%2+a*i%3===0;case t.Patterns.PATTERN110:return(a*i%2+a*i%3)%2===0;case t.Patterns.PATTERN111:return(a*i%3+(a+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(a,i){const l=i.size;for(let c=0;c<l;c++)for(let d=0;d<l;d++)i.isReserved(d,c)||i.xor(d,c,s(a,d,c))},t.getBestMask=function(a,i){const l=Object.keys(t.Patterns).length;let c=0,d=1/0;for(let m=0;m<l;m++){i(m),t.applyMask(m,a);const p=t.getPenaltyN1(a)+t.getPenaltyN2(a)+t.getPenaltyN3(a)+t.getPenaltyN4(a);t.applyMask(m,a),p<d&&(d=p,c=m)}return c}})(Rs)),Rs}var Vn={},Da;function Ki(){if(Da)return Vn;Da=1;const t=Ir(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],s=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Vn.getBlocksCount=function(a,i){switch(i){case t.L:return n[(a-1)*4+0];case t.M:return n[(a-1)*4+1];case t.Q:return n[(a-1)*4+2];case t.H:return n[(a-1)*4+3];default:return}},Vn.getTotalCodewordsCount=function(a,i){switch(i){case t.L:return s[(a-1)*4+0];case t.M:return s[(a-1)*4+1];case t.Q:return s[(a-1)*4+2];case t.H:return s[(a-1)*4+3];default:return}},Vn}var Ls={},kn={},_a;function hf(){if(_a)return kn;_a=1;const t=new Uint8Array(512),n=new Uint8Array(256);return(function(){let r=1;for(let a=0;a<255;a++)t[a]=r,n[r]=a,r<<=1,r&256&&(r^=285);for(let a=255;a<512;a++)t[a]=t[a-255]})(),kn.log=function(r){if(r<1)throw new Error("log("+r+")");return n[r]},kn.exp=function(r){return t[r]},kn.mul=function(r,a){return r===0||a===0?0:t[n[r]+n[a]]},kn}var Pa;function ff(){return Pa||(Pa=1,(function(t){const n=hf();t.mul=function(r,a){const i=new Uint8Array(r.length+a.length-1);for(let l=0;l<r.length;l++)for(let c=0;c<a.length;c++)i[l+c]^=n.mul(r[l],a[c]);return i},t.mod=function(r,a){let i=new Uint8Array(r);for(;i.length-a.length>=0;){const l=i[0];for(let d=0;d<a.length;d++)i[d]^=n.mul(a[d],l);let c=0;for(;c<i.length&&i[c]===0;)c++;i=i.slice(c)}return i},t.generateECPolynomial=function(r){let a=new Uint8Array([1]);for(let i=0;i<r;i++)a=t.mul(a,new Uint8Array([1,n.exp(i)]));return a}})(Ls)),Ls}var Bs,Ia;function pf(){if(Ia)return Bs;Ia=1;const t=ff();function n(s){this.genPoly=void 0,this.degree=s,this.degree&&this.initialize(this.degree)}return n.prototype.initialize=function(r){this.degree=r,this.genPoly=t.generateECPolynomial(this.degree)},n.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(r.length+this.degree);a.set(r);const i=t.mod(a,this.genPoly),l=this.degree-i.length;if(l>0){const c=new Uint8Array(this.degree);return c.set(i,l),c}return i},Bs=n,Bs}var Os={},Fs={},zs={},Ra;function Gi(){return Ra||(Ra=1,zs.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}),zs}var Nt={},La;function Wi(){if(La)return Nt;La=1;const t="[0-9]+",n="[A-Z $%*+\\-./:]+";let s="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";s=s.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+s+`)(?:.|[\r
|
|
190
190
|
]))+`;Nt.KANJI=new RegExp(s,"g"),Nt.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Nt.BYTE=new RegExp(r,"g"),Nt.NUMERIC=new RegExp(t,"g"),Nt.ALPHANUMERIC=new RegExp(n,"g");const a=new RegExp("^"+s+"$"),i=new RegExp("^"+t+"$"),l=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Nt.testKanji=function(d){return a.test(d)},Nt.testNumeric=function(d){return i.test(d)},Nt.testAlphanumeric=function(d){return l.test(d)},Nt}var Ba;function Xt(){return Ba||(Ba=1,(function(t){const n=Gi(),s=Wi();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(i,l){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!n.isValid(l))throw new Error("Invalid version: "+l);return l>=1&&l<10?i.ccBits[0]:l<27?i.ccBits[1]:i.ccBits[2]},t.getBestModeForData=function(i){return s.testNumeric(i)?t.NUMERIC:s.testAlphanumeric(i)?t.ALPHANUMERIC:s.testKanji(i)?t.KANJI:t.BYTE},t.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},t.isValid=function(i){return i&&i.bit&&i.ccBits};function r(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+a)}}t.from=function(i,l){if(t.isValid(i))return i;try{return r(i)}catch{return l}}})(Fs)),Fs}var Oa;function xf(){return Oa||(Oa=1,(function(t){const n=Zt(),s=Ki(),r=Ir(),a=Xt(),i=Gi(),l=7973,c=n.getBCHDigit(l);function d(h,f,j){for(let g=1;g<=40;g++)if(f<=t.getCapacity(g,j,h))return g}function m(h,f){return a.getCharCountIndicator(h,f)+4}function p(h,f){let j=0;return h.forEach(function(g){const w=m(g.mode,f);j+=w+g.getBitsLength()}),j}function u(h,f){for(let j=1;j<=40;j++)if(p(h,j)<=t.getCapacity(j,f,a.MIXED))return j}t.from=function(f,j){return i.isValid(f)?parseInt(f,10):j},t.getCapacity=function(f,j,g){if(!i.isValid(f))throw new Error("Invalid QR Code version");typeof g>"u"&&(g=a.BYTE);const w=n.getSymbolTotalCodewords(f),b=s.getTotalCodewordsCount(f,j),k=(w-b)*8;if(g===a.MIXED)return k;const y=k-m(g,f);switch(g){case a.NUMERIC:return Math.floor(y/10*3);case a.ALPHANUMERIC:return Math.floor(y/11*2);case a.KANJI:return Math.floor(y/13);case a.BYTE:default:return Math.floor(y/8)}},t.getBestVersionForData=function(f,j){let g;const w=r.from(j,r.M);if(Array.isArray(f)){if(f.length>1)return u(f,w);if(f.length===0)return 1;g=f[0]}else g=f;return d(g.mode,g.getLength(),w)},t.getEncodedBits=function(f){if(!i.isValid(f)||f<7)throw new Error("Invalid QR Code version");let j=f<<12;for(;n.getBCHDigit(j)-c>=0;)j^=l<<n.getBCHDigit(j)-c;return f<<12|j}})(Os)),Os}var Us={},Fa;function gf(){if(Fa)return Us;Fa=1;const t=Zt(),n=1335,s=21522,r=t.getBCHDigit(n);return Us.getEncodedBits=function(i,l){const c=i.bit<<3|l;let d=c<<10;for(;t.getBCHDigit(d)-r>=0;)d^=n<<t.getBCHDigit(d)-r;return(c<<10|d)^s},Us}var $s={},qs,za;function bf(){if(za)return qs;za=1;const t=Xt();function n(s){this.mode=t.NUMERIC,this.data=s.toString()}return n.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(r){let a,i,l;for(a=0;a+3<=this.data.length;a+=3)i=this.data.substr(a,3),l=parseInt(i,10),r.put(l,10);const c=this.data.length-a;c>0&&(i=this.data.substr(a),l=parseInt(i,10),r.put(l,c*3+1))},qs=n,qs}var Vs,Ua;function vf(){if(Ua)return Vs;Ua=1;const t=Xt(),n=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function s(r){this.mode=t.ALPHANUMERIC,this.data=r}return s.getBitsLength=function(a){return 11*Math.floor(a/2)+6*(a%2)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(a){let i;for(i=0;i+2<=this.data.length;i+=2){let l=n.indexOf(this.data[i])*45;l+=n.indexOf(this.data[i+1]),a.put(l,11)}this.data.length%2&&a.put(n.indexOf(this.data[i]),6)},Vs=s,Vs}var Hs,$a;function wf(){if($a)return Hs;$a=1;const t=Xt();function n(s){this.mode=t.BYTE,typeof s=="string"?this.data=new TextEncoder().encode(s):this.data=new Uint8Array(s)}return n.getBitsLength=function(r){return r*8},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(s){for(let r=0,a=this.data.length;r<a;r++)s.put(this.data[r],8)},Hs=n,Hs}var Ks,qa;function yf(){if(qa)return Ks;qa=1;const t=Xt(),n=Zt();function s(r){this.mode=t.KANJI,this.data=r}return s.getBitsLength=function(a){return a*13},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(r){let a;for(a=0;a<this.data.length;a++){let i=n.toSJIS(this.data[a]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[a]+`
|
|
191
191
|
Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},Ks=s,Ks}var Gs={exports:{}},Va;function jf(){return Va||(Va=1,(function(t){var n={single_source_shortest_paths:function(s,r,a){var i={},l={};l[r]=0;var c=n.PriorityQueue.make();c.push(r,0);for(var d,m,p,u,h,f,j,g,w;!c.empty();){d=c.pop(),m=d.value,u=d.cost,h=s[m]||{};for(p in h)h.hasOwnProperty(p)&&(f=h[p],j=u+f,g=l[p],w=typeof l[p]>"u",(w||g>j)&&(l[p]=j,c.push(p,j),i[p]=m))}if(typeof a<"u"&&typeof l[a]>"u"){var b=["Could not find a path from ",r," to ",a,"."].join("");throw new Error(b)}return i},extract_shortest_path_from_predecessor_list:function(s,r){for(var a=[],i=r;i;)a.push(i),s[i],i=s[i];return a.reverse(),a},find_path:function(s,r,a){var i=n.single_source_shortest_paths(s,r,a);return n.extract_shortest_path_from_predecessor_list(i,a)},PriorityQueue:{make:function(s){var r=n.PriorityQueue,a={},i;s=s||{};for(i in r)r.hasOwnProperty(i)&&(a[i]=r[i]);return a.queue=[],a.sorter=s.sorter||r.default_sorter,a},default_sorter:function(s,r){return s.cost-r.cost},push:function(s,r){var a={value:s,cost:r};this.queue.push(a),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=n})(Gs)),Gs.exports}var Ha;function Nf(){return Ha||(Ha=1,(function(t){const n=Xt(),s=bf(),r=vf(),a=wf(),i=yf(),l=Wi(),c=Zt(),d=jf();function m(b){return unescape(encodeURIComponent(b)).length}function p(b,k,y){const x=[];let v;for(;(v=b.exec(y))!==null;)x.push({data:v[0],index:v.index,mode:k,length:v[0].length});return x}function u(b){const k=p(l.NUMERIC,n.NUMERIC,b),y=p(l.ALPHANUMERIC,n.ALPHANUMERIC,b);let x,v;return c.isKanjiModeEnabled()?(x=p(l.BYTE,n.BYTE,b),v=p(l.KANJI,n.KANJI,b)):(x=p(l.BYTE_KANJI,n.BYTE,b),v=[]),k.concat(y,x,v).sort(function(A,E){return A.index-E.index}).map(function(A){return{data:A.data,mode:A.mode,length:A.length}})}function h(b,k){switch(k){case n.NUMERIC:return s.getBitsLength(b);case n.ALPHANUMERIC:return r.getBitsLength(b);case n.KANJI:return i.getBitsLength(b);case n.BYTE:return a.getBitsLength(b)}}function f(b){return b.reduce(function(k,y){const x=k.length-1>=0?k[k.length-1]:null;return x&&x.mode===y.mode?(k[k.length-1].data+=y.data,k):(k.push(y),k)},[])}function j(b){const k=[];for(let y=0;y<b.length;y++){const x=b[y];switch(x.mode){case n.NUMERIC:k.push([x,{data:x.data,mode:n.ALPHANUMERIC,length:x.length},{data:x.data,mode:n.BYTE,length:x.length}]);break;case n.ALPHANUMERIC:k.push([x,{data:x.data,mode:n.BYTE,length:x.length}]);break;case n.KANJI:k.push([x,{data:x.data,mode:n.BYTE,length:m(x.data)}]);break;case n.BYTE:k.push([{data:x.data,mode:n.BYTE,length:m(x.data)}])}}return k}function g(b,k){const y={},x={start:{}};let v=["start"];for(let N=0;N<b.length;N++){const A=b[N],E=[];for(let M=0;M<A.length;M++){const B=A[M],D=""+N+M;E.push(D),y[D]={node:B,lastCount:0},x[D]={};for(let _=0;_<v.length;_++){const P=v[_];y[P]&&y[P].node.mode===B.mode?(x[P][D]=h(y[P].lastCount+B.length,B.mode)-h(y[P].lastCount,B.mode),y[P].lastCount+=B.length):(y[P]&&(y[P].lastCount=B.length),x[P][D]=h(B.length,B.mode)+4+n.getCharCountIndicator(B.mode,k))}}v=E}for(let N=0;N<v.length;N++)x[v[N]].end=0;return{map:x,table:y}}function w(b,k){let y;const x=n.getBestModeForData(b);if(y=n.from(k,x),y!==n.BYTE&&y.bit<x.bit)throw new Error('"'+b+'" cannot be encoded with mode '+n.toString(y)+`.
|
|
192
192
|
Suggested mode is: `+n.toString(x));switch(y===n.KANJI&&!c.isKanjiModeEnabled()&&(y=n.BYTE),y){case n.NUMERIC:return new s(b);case n.ALPHANUMERIC:return new r(b);case n.KANJI:return new i(b);case n.BYTE:return new a(b)}}t.fromArray=function(k){return k.reduce(function(y,x){return typeof x=="string"?y.push(w(x,null)):x.data&&y.push(w(x.data,x.mode)),y},[])},t.fromString=function(k,y){const x=u(k,c.isKanjiModeEnabled()),v=j(x),N=g(v,y),A=d.find_path(N.map,"start","end"),E=[];for(let M=1;M<A.length-1;M++)E.push(N.table[A[M]].node);return t.fromArray(f(E))},t.rawSplit=function(k){return t.fromArray(u(k,c.isKanjiModeEnabled()))}})($s)),$s}var Ka;function kf(){if(Ka)return Es;Ka=1;const t=Zt(),n=Ir(),s=lf(),r=cf(),a=df(),i=uf(),l=mf(),c=Ki(),d=pf(),m=xf(),p=gf(),u=Xt(),h=Nf();function f(N,A){const E=N.size,M=i.getPositions(A);for(let B=0;B<M.length;B++){const D=M[B][0],_=M[B][1];for(let P=-1;P<=7;P++)if(!(D+P<=-1||E<=D+P))for(let O=-1;O<=7;O++)_+O<=-1||E<=_+O||(P>=0&&P<=6&&(O===0||O===6)||O>=0&&O<=6&&(P===0||P===6)||P>=2&&P<=4&&O>=2&&O<=4?N.set(D+P,_+O,!0,!0):N.set(D+P,_+O,!1,!0))}}function j(N){const A=N.size;for(let E=8;E<A-8;E++){const M=E%2===0;N.set(E,6,M,!0),N.set(6,E,M,!0)}}function g(N,A){const E=a.getPositions(A);for(let M=0;M<E.length;M++){const B=E[M][0],D=E[M][1];for(let _=-2;_<=2;_++)for(let P=-2;P<=2;P++)_===-2||_===2||P===-2||P===2||_===0&&P===0?N.set(B+_,D+P,!0,!0):N.set(B+_,D+P,!1,!0)}}function w(N,A){const E=N.size,M=m.getEncodedBits(A);let B,D,_;for(let P=0;P<18;P++)B=Math.floor(P/3),D=P%3+E-8-3,_=(M>>P&1)===1,N.set(B,D,_,!0),N.set(D,B,_,!0)}function b(N,A,E){const M=N.size,B=p.getEncodedBits(A,E);let D,_;for(D=0;D<15;D++)_=(B>>D&1)===1,D<6?N.set(D,8,_,!0):D<8?N.set(D+1,8,_,!0):N.set(M-15+D,8,_,!0),D<8?N.set(8,M-D-1,_,!0):D<9?N.set(8,15-D-1+1,_,!0):N.set(8,15-D-1,_,!0);N.set(M-8,8,1,!0)}function k(N,A){const E=N.size;let M=-1,B=E-1,D=7,_=0;for(let P=E-1;P>0;P-=2)for(P===6&&P--;;){for(let O=0;O<2;O++)if(!N.isReserved(B,P-O)){let W=!1;_<A.length&&(W=(A[_]>>>D&1)===1),N.set(B,P-O,W),D--,D===-1&&(_++,D=7)}if(B+=M,B<0||E<=B){B-=M,M=-M;break}}}function y(N,A,E){const M=new s;E.forEach(function(O){M.put(O.mode.bit,4),M.put(O.getLength(),u.getCharCountIndicator(O.mode,N)),O.write(M)});const B=t.getSymbolTotalCodewords(N),D=c.getTotalCodewordsCount(N,A),_=(B-D)*8;for(M.getLengthInBits()+4<=_&&M.put(0,4);M.getLengthInBits()%8!==0;)M.putBit(0);const P=(_-M.getLengthInBits())/8;for(let O=0;O<P;O++)M.put(O%2?17:236,8);return x(M,N,A)}function x(N,A,E){const M=t.getSymbolTotalCodewords(A),B=c.getTotalCodewordsCount(A,E),D=M-B,_=c.getBlocksCount(A,E),P=M%_,O=_-P,W=Math.floor(M/_),J=Math.floor(D/_),Y=J+1,V=W-J,ne=new d(V);let $=0;const ee=new Array(_),S=new Array(_);let Q=0;const T=new Uint8Array(N.buffer);for(let le=0;le<_;le++){const ie=le<O?J:Y;ee[le]=T.slice($,$+ie),S[le]=ne.encode(ee[le]),$+=ie,Q=Math.max(Q,ie)}const te=new Uint8Array(M);let R=0,H,F;for(H=0;H<Q;H++)for(F=0;F<_;F++)H<ee[F].length&&(te[R++]=ee[F][H]);for(H=0;H<V;H++)for(F=0;F<_;F++)te[R++]=S[F][H];return te}function v(N,A,E,M){let B;if(Array.isArray(N))B=h.fromArray(N);else if(typeof N=="string"){let W=A;if(!W){const J=h.rawSplit(N);W=m.getBestVersionForData(J,E)}B=h.fromString(N,W||40)}else throw new Error("Invalid data");const D=m.getBestVersionForData(B,E);if(!D)throw new Error("The amount of data is too big to be stored in a QR Code");if(!A)A=D;else if(A<D)throw new Error(`
|