@tickernelz/paperclip-pro-server 2026.928.4 → 2026.928.5

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.
Files changed (69) hide show
  1. package/dist/build-info.json +1 -1
  2. package/dist/routes/issues.d.ts.map +1 -1
  3. package/dist/routes/issues.js +1 -0
  4. package/dist/routes/issues.js.map +1 -1
  5. package/node_modules/@agentclientprotocol/sdk/dist/acp.d.ts +4 -1
  6. package/node_modules/@agentclientprotocol/sdk/dist/acp.js +3 -2
  7. package/node_modules/@agentclientprotocol/sdk/dist/acp.js.map +1 -1
  8. package/node_modules/@agentclientprotocol/sdk/dist/connection.d.ts +199 -11
  9. package/node_modules/@agentclientprotocol/sdk/dist/connection.js +454 -46
  10. package/node_modules/@agentclientprotocol/sdk/dist/connection.js.map +1 -1
  11. package/node_modules/@agentclientprotocol/sdk/dist/connection.test.js +170 -11
  12. package/node_modules/@agentclientprotocol/sdk/dist/connection.test.js.map +1 -1
  13. package/node_modules/@agentclientprotocol/sdk/dist/examples/http-server.js +6 -1
  14. package/node_modules/@agentclientprotocol/sdk/dist/examples/http-server.js.map +1 -1
  15. package/node_modules/@agentclientprotocol/sdk/dist/http-stream.d.ts +2 -0
  16. package/node_modules/@agentclientprotocol/sdk/dist/http-stream.js +46 -8
  17. package/node_modules/@agentclientprotocol/sdk/dist/http-stream.js.map +1 -1
  18. package/node_modules/@agentclientprotocol/sdk/dist/line-buffer.d.ts +7 -5
  19. package/node_modules/@agentclientprotocol/sdk/dist/line-buffer.js +36 -29
  20. package/node_modules/@agentclientprotocol/sdk/dist/line-buffer.js.map +1 -1
  21. package/node_modules/@agentclientprotocol/sdk/dist/node-adapter.js +33 -2
  22. package/node_modules/@agentclientprotocol/sdk/dist/node-adapter.js.map +1 -1
  23. package/node_modules/@agentclientprotocol/sdk/dist/node-adapter.test.js +87 -0
  24. package/node_modules/@agentclientprotocol/sdk/dist/node-adapter.test.js.map +1 -1
  25. package/node_modules/@agentclientprotocol/sdk/dist/server-sse.d.ts +6 -1
  26. package/node_modules/@agentclientprotocol/sdk/dist/server-sse.js +78 -30
  27. package/node_modules/@agentclientprotocol/sdk/dist/server-sse.js.map +1 -1
  28. package/node_modules/@agentclientprotocol/sdk/dist/server-sse.test.js +59 -6
  29. package/node_modules/@agentclientprotocol/sdk/dist/server-sse.test.js.map +1 -1
  30. package/node_modules/@agentclientprotocol/sdk/dist/server-websocket-upgrade.test.js +320 -2
  31. package/node_modules/@agentclientprotocol/sdk/dist/server-websocket-upgrade.test.js.map +1 -1
  32. package/node_modules/@agentclientprotocol/sdk/dist/server.d.ts +4 -3
  33. package/node_modules/@agentclientprotocol/sdk/dist/server.js +49 -21
  34. package/node_modules/@agentclientprotocol/sdk/dist/server.js.map +1 -1
  35. package/node_modules/@agentclientprotocol/sdk/dist/server.test.js +530 -0
  36. package/node_modules/@agentclientprotocol/sdk/dist/server.test.js.map +1 -1
  37. package/node_modules/@agentclientprotocol/sdk/dist/sse.d.ts +3 -1
  38. package/node_modules/@agentclientprotocol/sdk/dist/sse.js +59 -36
  39. package/node_modules/@agentclientprotocol/sdk/dist/sse.js.map +1 -1
  40. package/node_modules/@agentclientprotocol/sdk/dist/stream-limits.d.ts +15 -0
  41. package/node_modules/@agentclientprotocol/sdk/dist/stream-limits.js +58 -0
  42. package/node_modules/@agentclientprotocol/sdk/dist/stream-limits.js.map +1 -0
  43. package/node_modules/@agentclientprotocol/sdk/dist/stream.d.ts +4 -1
  44. package/node_modules/@agentclientprotocol/sdk/dist/stream.js +6 -2
  45. package/node_modules/@agentclientprotocol/sdk/dist/stream.js.map +1 -1
  46. package/node_modules/@agentclientprotocol/sdk/dist/test-support/until.d.ts +5 -0
  47. package/node_modules/@agentclientprotocol/sdk/dist/test-support/until.js +14 -0
  48. package/node_modules/@agentclientprotocol/sdk/dist/test-support/until.js.map +1 -0
  49. package/node_modules/@agentclientprotocol/sdk/dist/v2/acp.d.ts +4 -1
  50. package/node_modules/@agentclientprotocol/sdk/dist/v2/acp.js +3 -2
  51. package/node_modules/@agentclientprotocol/sdk/dist/v2/acp.js.map +1 -1
  52. package/node_modules/@agentclientprotocol/sdk/dist/ws-server.js +143 -15
  53. package/node_modules/@agentclientprotocol/sdk/dist/ws-server.js.map +1 -1
  54. package/node_modules/@agentclientprotocol/sdk/dist/ws-utils.d.ts +6 -0
  55. package/node_modules/@agentclientprotocol/sdk/dist/ws-utils.js.map +1 -1
  56. package/node_modules/@agentclientprotocol/sdk/package.json +1 -1
  57. package/package.json +21 -21
  58. package/ui-dist/assets/{Agents.production-Cj5rZo69.js → Agents.production-Ou10IBgG.js} +2 -2
  59. package/ui-dist/assets/{CompanyActivity.production-BsesMNQp.js → CompanyActivity.production-dbz2o26S.js} +1 -1
  60. package/ui-dist/assets/{CompanyExport-CWmvCY4A.js → CompanyExport-VHEmaNC_.js} +1 -1
  61. package/ui-dist/assets/{CompanySkills.production-BGtfN-3A.js → CompanySkills.production-DuSUb8DQ.js} +1 -1
  62. package/ui-dist/assets/{Costs.production-84DycSrt.js → Costs.production-BRz8Rn3s.js} +1 -1
  63. package/ui-dist/assets/{OrgChart.production-D_VwOg1Z.js → OrgChart.production-Dgq5pMMa.js} +1 -1
  64. package/ui-dist/assets/{RoutineDetail.production-DJe0NpxJ.js → RoutineDetail.production-B2lkeY8y.js} +1 -1
  65. package/ui-dist/assets/{Routines.production-VhYuO012.js → Routines.production-CGNSsZDr.js} +1 -1
  66. package/ui-dist/assets/{definition-DurZnIaP.js → definition-D6jTm4Mv.js} +1 -1
  67. package/ui-dist/assets/{index-BqdSRbLj.js → index-DGStZYMS.js} +4 -4
  68. package/ui-dist/index.html +1 -1
  69. package/ui-dist/sw.js +1 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/runtime-IAg0vdY9.js","assets/model-DL5biheO.js","assets/definition-DurZnIaP.js","assets/character-CguPM7IG.js","assets/prod-COP_vZWu.js","assets/rolldown-runtime-ZpX3ckPj.js","assets/CompanyExport-CWmvCY4A.js","assets/createLucideIcon-r3v6fbGz.js","assets/router-Bb8nJWyv.js","assets/preload-helper-CceJXRIF.js","assets/zap-P-cXfK28.js","assets/agents-BlSzFh-1.js","assets/EmptyState-DPcc0zYh.js","assets/button-CAPbz11u.js","assets/mention-chips-DXumPrOR.js","assets/bot-DZDpMzjD.js","assets/StatusIcon-BuUYMqqU.js","assets/clipboard-CYJ5Q78m.js","assets/loader-circle-BD9wx-lw.js","assets/octagon-alert-rGMwyrWA.js","assets/MarkdownBody-DJQ35hak.js","assets/check-DDiXDm2i.js","assets/external-link-0lrOvZWO.js","assets/rotate-ccw-CRAQ3Xng.js","assets/PageSkeleton-DHjTwRT3.js","assets/skeleton-CKir8TUW.js","assets/Agents.production-Cj5rZo69.js","assets/AgentAvatar-PT82VwmU.js","assets/tabs-DWRZjksg.js","assets/dist-5v80Jc6A.js","assets/heartbeats-CK_aXmx5.js","assets/triangle-alert-CgJcxSQX.js","assets/SidebarContext-D01pu4wh.js","assets/environments-BVeNFanj.js","assets/Routines.production-VhYuO012.js","assets/RoutineRunVariablesDialog-Bt4KAWCh.js","assets/MarkdownEditor-DfrwLv1M.js","assets/dist-D1zgkcBw.js","assets/dist-DCJXgQu0.js","assets/sheet-CQJe5sfn.js","assets/checkbox-757DLJRS.js","assets/chevron-right-B9JUOr38.js","assets/label-BueB30Ch.js","assets/select-mS22eY6T.js","assets/chevron-down-F9aZv-V7.js","assets/useHiddenSettings-2JpxuJV7.js","assets/health-DeeeogeJ.js","assets/badge-Cf7ihb3q.js","assets/input-DpsS9it-.js","assets/company-members-BcZm1g8Q.js","assets/AgentIdentity-MCshmbhZ.js","assets/card-dmVcp3AX.js","assets/RoutineDetail.production-DJe0NpxJ.js","assets/save-DUnPDT6R.js","assets/CompanySkills.production-BGtfN-3A.js","assets/use-adapter-capabilities-BiWYK4zJ.js","assets/file-text-C9vgFckt.js","assets/CompanyActivity.production-BsesMNQp.js","assets/Costs.production-84DycSrt.js","assets/OrgChart.production-D_VwOg1Z.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/runtime-IAg0vdY9.js","assets/model-DL5biheO.js","assets/definition-D6jTm4Mv.js","assets/character-CguPM7IG.js","assets/prod-COP_vZWu.js","assets/rolldown-runtime-ZpX3ckPj.js","assets/CompanyExport-VHEmaNC_.js","assets/createLucideIcon-r3v6fbGz.js","assets/router-Bb8nJWyv.js","assets/preload-helper-CceJXRIF.js","assets/zap-P-cXfK28.js","assets/agents-BlSzFh-1.js","assets/EmptyState-DPcc0zYh.js","assets/button-CAPbz11u.js","assets/mention-chips-DXumPrOR.js","assets/bot-DZDpMzjD.js","assets/StatusIcon-BuUYMqqU.js","assets/clipboard-CYJ5Q78m.js","assets/loader-circle-BD9wx-lw.js","assets/octagon-alert-rGMwyrWA.js","assets/MarkdownBody-DJQ35hak.js","assets/check-DDiXDm2i.js","assets/external-link-0lrOvZWO.js","assets/rotate-ccw-CRAQ3Xng.js","assets/PageSkeleton-DHjTwRT3.js","assets/skeleton-CKir8TUW.js","assets/Agents.production-Ou10IBgG.js","assets/AgentAvatar-PT82VwmU.js","assets/tabs-DWRZjksg.js","assets/dist-5v80Jc6A.js","assets/heartbeats-CK_aXmx5.js","assets/triangle-alert-CgJcxSQX.js","assets/SidebarContext-D01pu4wh.js","assets/environments-BVeNFanj.js","assets/Routines.production-CGNSsZDr.js","assets/RoutineRunVariablesDialog-Bt4KAWCh.js","assets/MarkdownEditor-DfrwLv1M.js","assets/dist-D1zgkcBw.js","assets/dist-DCJXgQu0.js","assets/sheet-CQJe5sfn.js","assets/checkbox-757DLJRS.js","assets/chevron-right-B9JUOr38.js","assets/label-BueB30Ch.js","assets/select-mS22eY6T.js","assets/chevron-down-F9aZv-V7.js","assets/useHiddenSettings-2JpxuJV7.js","assets/health-DeeeogeJ.js","assets/badge-Cf7ihb3q.js","assets/input-DpsS9it-.js","assets/company-members-BcZm1g8Q.js","assets/AgentIdentity-MCshmbhZ.js","assets/card-dmVcp3AX.js","assets/RoutineDetail.production-B2lkeY8y.js","assets/save-DUnPDT6R.js","assets/CompanySkills.production-DuSUb8DQ.js","assets/use-adapter-capabilities-BiWYK4zJ.js","assets/file-text-C9vgFckt.js","assets/CompanyActivity.production-dbz2o26S.js","assets/Costs.production-BRz8Rn3s.js","assets/OrgChart.production-Dgq5pMMa.js"])))=>i.map(i=>d[i]);
2
2
  var A_e=Object.defineProperty;var r=(e,s)=>A_e(e,"name",{value:s,configurable:!0});import{i as G3,n as R_e,t as pv}from"./rolldown-runtime-ZpX3ckPj.js";import{$ as T_e,$n as WC,$t as Xoe,A as E_e,An as vR,At as P_e,B as Zoe,Bn as M_e,Bt as ele,C as D_e,Cn as L_e,Ct as tle,D as Ha,Dn as sle,Dt as $_e,E as pu,En as HC,Et as nle,F as FS,Fn as O_e,Fr as F_e,Ft as rle,G as B_e,Gn as H6,Gt as ale,H as q_e,Hn as z_e,Ht as ile,I as rS,In as U_e,Ir as ole,It as K_e,J as Q6,Jn as cl,Jt as Fp,K as V_e,Kn as TW,Kt as yR,L as Xu,Lr as G6,Lt as W_e,M as Ka,Mn as Y3,Mr as J3,Mt as e2,N as jR,Nn as H_e,Nr as Q_e,Nt as t2,O as EW,On as lle,Ot as G_e,P as n0,Pn as QC,Pr as Kt,Pt as PW,Q as Y_e,Qn as wR,Qt as cle,R as Y6,Rn as NR,Rt as V$,S as z,Sn as J_e,St as X_e,T as Wr,Tt as Z_e,U as xs,Un as eIe,Ut as tIe,Vn as dle,Vt as Lb,Wn as NM,Wt as sIe,X as Fa,Xn as Re,Xt as kR,Y as P,Yn as vn,Yt as ule,Z as mle,Zn as nIe,Zt as GC,_ as Qu,_n as hle,_t as rIe,an as ple,at as fle,b as MW,bn as aIe,bt as iIe,c as oIe,cn as lIe,ct as xle,d as cIe,dn as dIe,dt as uIe,en as J6,er as mIe,et as gle,fn as hIe,ft as s2,g as jc,gn as pIe,gr as fIe,gt as xIe,h as fv,hn as gIe,hr as bIe,ht as vIe,i as X3,in as Bp,it as DW,j as yh,jn as W$,jt as pj,k as Ui,kn as LW,kt as $W,l as YC,ln as ble,lt as X6,m as Iw,mn as yIe,mt as jIe,n as Z0,nn as wIe,nr as ee,nt as vle,o as NIe,on as OW,ot as kIe,pn as kM,pr as SIe,pt as Aw,q as Z3,qn as yle,qt as CIe,rn as jle,rr as _Ie,rt as BS,s as jb,sn as wle,st as IIe,t as Qt,tn as Z6,tr as ke,tt as AIe,un as FW,ut as RIe,v as TIe,vn as EIe,vt as PIe,w as Nle,wn as MIe,wt as DIe,x as ez,xn as LIe,xt as BW,y as qW,yn as e5,yt as kle,z as Ar,zn as zW,zt as tz}from"./createLucideIcon-r3v6fbGz.js";import{t as vc}from"./preload-helper-CceJXRIF.js";import{$ as kd,A as $Ie,B as Rt,C as OIe,D as FIe,E as UW,F as KW,G as VW,H as SR,I as Sle,J as WW,K as BIe,L as qIe,M as Cle,N as zIe,O as UIe,P as W_,Q as KIe,R as VIe,S as CR,T as _le,U as Rw,V as _R,W as ul,X as Ug,Y as $b,Z as po,_ as WIe,a as Tw,at as Ile,b as hl,ct as Ri,d as HIe,et as r0,f as Ob,g as QIe,h as GIe,i as YIe,it as ea,j as JIe,k as HW,l as XIe,m as Ale,n as a0,nt as ZIe,o as Hn,ot as t5,p as s5,q as SM,r as wn,rt as eAe,st as ka,t as Ge,tt as ot,u as sz,v as Hm,w as IR,x as AR,y as tAe,z as qy}from"./router-Bb8nJWyv.js";import{$ as nz,$n as rz,$t as qS,A as Gj,An as Gu,At as gg,B as sAe,Bn as Rle,Bt as fj,Cn as Tle,Ct as Kg,D as nAe,Dn as Ele,Dt as rAe,E as aAe,En as Ple,Et as iAe,F as oAe,Fn as Mle,Ft as Dle,G as lAe,Gn as cAe,Gt as Lle,H as dAe,Hn as uAe,Ht as $le,I as Ole,In as mAe,It as Yj,J as H$,Jn as JC,Jt as RR,K as hAe,Kn as Fle,Kt as Ble,L as pAe,Ln as QW,Lt as fAe,M as Ew,Mn as Lc,Mt as zl,N as xv,Nn as qle,Nt as Pw,O as Rx,On as Pm,Ot as xAe,P as gAe,Pn as zS,Pt as kc,Q as bAe,Qn as az,Qt as zle,R as vAe,Rn as yAe,Rt as jAe,Sn as TR,St as wAe,T as NAe,Tn as Ule,Tt as Kle,U as kAe,Un as Mw,Ut as Vle,V as SAe,Vn as CAe,Vt as _Ae,W as Wle,Wn as n5,Wt as IAe,X as GW,Xn as AAe,Xt as lx,Y as Hle,Yn as Dw,Yt as Qle,Z as Gle,Zn as Yle,Zt as xj,_ as Jle,_n as ER,_r as r5,_t as RAe,a as TAe,an as YW,ar as Lw,at as EAe,b as PAe,bn as MAe,br as Vg,bt as $w,c as CM,cn as Xle,cr as Wl,ct as Zle,d as PR,dn as ece,dr as DAe,dt as tce,en as gj,er as sce,et as nce,f as rce,fn as iz,fr as ace,ft as oz,g as JW,gn as MR,gr as sf,gt as LAe,h as $Ae,hn as ice,hr as oce,ht as OAe,i as FAe,in as XW,ir as Ow,it as XC,j as ZW,jn as Q$,jt as lce,k as cce,kn as dce,kt as bj,l as BAe,ln as qAe,lr as fu,lt as G$,m as DR,mn as LR,mr as zAe,mt as UAe,n as KAe,nn as $R,nr as VAe,nt as WAe,o as HAe,on as QAe,or as el,ot as GAe,p as uce,pn as mce,pr as YAe,pt as JAe,q as XAe,qn as Fw,qt as hce,r as bx,rn as OR,rr as nf,rt as Rh,s as eH,sn as pce,sr as tl,st as fce,t as lz,tn as xce,tr as ZC,tt as gv,u as gce,un as tH,ur as Tx,ut as Y$,v as _M,vn as ZAe,vr as FR,vt as Bl,w as bce,wn as sH,wt as e1,x as e2e,xn as vce,xr as t1,xt as s1,y as t2e,yn as s2e,yr as a5,yt as Bw,z as n2e,zn as r2e}from"./RoutineRunVariablesDialog-Bt4KAWCh.js";import{$ as yce,Q as ir,Z as a2e,a as i2e,ct as o2e,et as nH,o as l2e,rt as jce,s as c2e,tt as ud}from"./mention-chips-DXumPrOR.js";import{g as d2e}from"./dist-D1zgkcBw.js";import{i as u2e}from"./dist-5v80Jc6A.js";import{A as m2e,C as h2e,D as p2e,E as i5,M as Eg,N as Ul,O as Lm,S as sl,T as jl,_ as o5,a as vx,b as cz,c as l5,f as Pg,g as Md,h as wce,j as vj,k as f2e,l as ha,m as Mg,n as yx,o as Th,p as Eh,r as Fb,s as rf,t as rH,v as Rd,x as dz,y as H_}from"./zap-P-cXfK28.js";import{D as x2e,E as g2e,S as b2e,a as Nce,c as Vr,d as bc,f as kce,i as v2e,l as Ni,m as Wg,o as y2e,p as Ex,r as j2e,s as Sce,t as wc,u as Qm,w as w2e,x as N2e}from"./MarkdownEditor-DfrwLv1M.js";import{_ as uz,a as Cce,b as c5,c as _ce,d as Ph,f as Mh,g as Dh,h as Lh,i as US,l as $h,m as Oh,n as k2e,o as Fh,p as Bh,r as Qh,s as Gm,t as Gh,u as qh,v as Ki,y as Kl}from"./sheet-CQJe5sfn.js";import{a as Yi,c as S2e,i as n1,l as Vc,n as C2e,o as Ji,r as Fl,s as Ice,t as pr}from"./AgentAvatar-PT82VwmU.js";import{A as Ei,C as ui,D as Ace,E as Rce,O as pa,S as nx,T as Tce,_ as mz,a as Zs,b as qw,c as Sn,d as zw,f as qn,g as fa,h as zn,i as _2e,k as Ia,l as I2e,m as md,n as En,o as Mn,p as Un,r as Js,s as br,t as Fi,u as rn,v as xa,w as A2e,x as wb,y as ps}from"./checkbox-757DLJRS.js";import{_ as _o,a as R2e,c as d5,d as zu,f as r1,g as T2e,h as Zf,l as E2e,m as a1,n as bv,o as Ece,p as Eo,r as P2e,s as _i,t as Ws,u as i1,v as u5}from"./label-BueB30Ch.js";import{i as Ea,n as aa,r as Uc,t as ki}from"./tabs-DWRZjksg.js";import{a as Wn,c as dr,i as J$,n as Kc,o as M2e,r as nr,s as D2e,t as zt}from"./agents-BlSzFh-1.js";import{a as Pce,b as rc,d as Mce,f as BR,g as ia,l as Dce,m as Sd,n as L2e,o as Lce,p as $ce,t as Gi,u as $2e,v as O2e,x as du,y as fo}from"./StatusIcon-BuUYMqqU.js";import{a as ic,i as jx,n as Am,r as Ja,t as Uw}from"./use-adapter-capabilities-BiWYK4zJ.js";import{a as vv,c as Vu,i as o1,n as F2e,o as od,r as Ln,s as m5,t as Tn}from"./EmptyState-DPcc0zYh.js";import{t as Xi}from"./bot-DZDpMzjD.js";import{t as fs}from"./check-DDiXDm2i.js";import{t as en}from"./chevron-down-F9aZv-V7.js";import{t as fn}from"./chevron-right-B9JUOr38.js";import{a as B2e,c as Pa,i as Nn,l as l1,n as Ma,o as Oce,r as q2e,s as Da,t as La}from"./select-mS22eY6T.js";import{n as Td,r as Vi,t as Hp}from"./save-DUnPDT6R.js";import{A as wx,C as X$,D as z2e,_ as hz,b as Q_,c as U2e,h as K2e,i as V2e,j as oa,k as yn,l as Ng,n as W2e,o as H2e,p as Z$,r as pz,t as F,u as Q2e,y as G2e}from"./button-CAPbz11u.js";import{i as jr,n as yi,r as Io,t as Hr}from"./clipboard-CYJ5Q78m.js";import{t as xr}from"./external-link-0lrOvZWO.js";import{_ as Y2e,a as J2e,c as Fce,d as Bce,f as X2e,g as Z2e,h as Qp,i as eRe,l as tRe,m as sRe,n as qce,o as nRe,p as aH,r as zce,s as rRe,t as Pn,u as Uce,v as aRe,y as Xm}from"./MarkdownBody-DJQ35hak.js";import{t as mi}from"./file-text-C9vgFckt.js";import{a as h5,i as $o,n as iRe,o as Kce,r as c1,t as Zr}from"./heartbeats-CK_aXmx5.js";import{t as it}from"./loader-circle-BD9wx-lw.js";import{n as Kw,t as Zm}from"./useHiddenSettings-2JpxuJV7.js";import{t as Jj}from"./octagon-alert-rGMwyrWA.js";import{t as Ii}from"./rotate-ccw-CRAQ3Xng.js";import{t as Rs}from"./triangle-alert-CgJcxSQX.js";import{n as Wa,t as oRe}from"./SidebarContext-D01pu4wh.js";import{n as lRe,t as ct}from"./badge-Cf7ihb3q.js";import{n as Ir,t as Ci}from"./environments-BVeNFanj.js";import{t as _t}from"./input-DpsS9it-.js";import{a as af,i as d1,n as u1,o as ur,r as Px,t as Vw}from"./company-members-BcZm1g8Q.js";import{t as tm}from"./health-DeeeogeJ.js";import{t as bn}from"./skeleton-CKir8TUW.js";import{t as Dd}from"./AgentIdentity-MCshmbhZ.js";import{a as cRe,i as Nl,n as dRe,o as Zi,r as Qa,s as uo,t as Xs}from"./card-dmVcp3AX.js";import{t as Na}from"./PageSkeleton-DHjTwRT3.js";r((function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))a(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&a(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}r(n,"getFetchOpts");function a(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}r(a,"processPreload")}),"polyfill")();var uRe=class extends SIe{static{r(this,"InfiniteQueryObserver")}constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:n}=e,a=super.createResult(e,s),{isFetching:i,isRefetching:o,isError:l,isRefetchError:c}=a,d=n.fetchMeta?.fetchMore?.direction,m=l&&d==="forward",h=i&&d==="forward",p=l&&d==="backward",f=i&&d==="backward";return{...a,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:bIe(s,n.data),hasPreviousPage:fIe(s,n.data),isFetchNextPageError:m,isFetchingNextPage:h,isFetchPreviousPageError:p,isFetchingPreviousPage:f,isRefetchError:c&&!m&&!p,isRefetching:o&&!h&&!f}}};function yv(e,s){return _Ie(e,uRe,s)}r(yv,"useInfiniteQuery");var mRe="adapter_auth_missing",hRe="document",pRe=80,fRe={markdown:"md",html:"html",json:"json",text:"txt"};function xRe(e){return e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,pRe).replace(/-+$/g,"")||hRe}r(xRe,"documentExportSlug");function gRe(e){return fRe[(e??"").trim().toLowerCase()]??"md"}r(gRe,"documentExportExtension");function iH(e,s){const n=s.replace(/^\.+/,"").toLowerCase()||"md";return`${xRe(e)}.${n}`}r(iH,"documentExportFileName");function eO(e){const s=new Set([e.targetIssueId]);if(e.type==="create_issue"){e.draft.parentId&&s.add(e.draft.parentId);for(const n of e.draft.blockedByIssueIds??[])s.add(n)}if(e.type==="resolve_blocker")for(const n of e.removeBlockedByIssueIds)s.add(n);return[...s]}r(eO,"decisionEffectTargetIssueIds");var bRe=new Set(["terminated","pending_approval","paused"]),vRe=new Set(["active","idle","running","error"]);function yRe(e){return vRe.has(e)&&!bRe.has(e)}r(yRe,"isAgentStatusInvokable");function qN(e){return e==="done"||e==="cancelled"}r(qN,"isPipelineTerminalStageKind");function Vce(e){const s={};for(const n of e)(s[n.stageId]??=[]).push(n);return s}r(Vce,"groupWarningsByStage");function Wce(e){return e==="RESPONSIBLE_USER_UNAUTHORIZED"||e==="RESPONSIBLE_USER_UNAVAILABLE"}r(Wce,"isResponsibleUserDenialCode");function m1(e){const s=e?.trim();return s&&s.length>0?s:"the responsible user"}r(m1,"responsibleUserLabel");function tO(e,s={}){const n=m1(s.userName);return e==="RESPONSIBLE_USER_UNAVAILABLE"?{code:e,tone:"unavailable",title:"Responsible user unavailable",description:`This run acts on behalf of ${n}, but that account was removed or deactivated, so its permissions can no longer be evaluated. The agent's own permissions are not enough on their own — every action still requires an active responsible user.`,recommendedAction:"Mark the work blocked and reassign a responsible user (or reactivate the account) before the agent continues."}:{code:e,tone:"unauthorized",title:"Responsible user not authorized",description:`This action was denied because ${n} — the user this run acts on behalf of — does not have permission to perform it. The agent may be allowed, but a run can never exceed the permissions of the user it acts for, so the action is blocked.`,recommendedAction:`Grant ${n} the required permission, or have someone who is authorized take this action instead.`}}r(tO,"describeResponsibleUserDenial");var jRe=["issue_write_not_visible","issue_write_actor_class_excluded","issue_write_responsible_user_ceiling","issue_write_responsible_user_unavailable","issue_write_assignee_run_lock","cross_issue_influence_cap_exceeded","cross_issue_influence_run_context_required","issue_write_attribution_spoof_rejected"];function wRe(e){const s=e?.trim();return s&&s.length>0?s:"this task"}r(wRe,"issueLabel$2");function NRe(e){const s=e?.trim();return s&&s.length>0?s:"the current assignee"}r(NRe,"assigneeLabel");function kRe(e){const s=e?.trim();return s&&s.length>0?s:"this agent"}r(kRe,"actorLabel$1");var SRe="create a child issue with the request in its description (issue creation is a separate, open write path) and let its assignee act";function CRe(e,s={}){const n=wRe(s.issueIdentifier),a=kRe(s.actorLabel),i=NRe(s.assigneeLabel),o=m1(s.responsibleUserName);switch(e){case"issue_write_not_visible":return{code:e,status:403,tone:"boundary",boundary:"Issue visibility",title:"Task is outside this actor's visibility",description:`Issue writes are open by default, but only for tasks the actor can already read. ${n} is not visible to ${a}, so its comment, update, child, and assignment channels are all closed — the wall is visibility, not the write itself.`,whoCanAct:`${i}, and any agent or board member the task is visible to.`,sanctionedPath:`Ask the board to widen visibility for ${a}, or ${SRe}.`};case"issue_write_actor_class_excluded":return{code:e,status:403,tone:"boundary",boundary:"Actor-class boundary",title:"This actor class cannot write to tasks",description:`Default-open issue writes are a standard-trust privilege. Low-trust, skill-test, and task-bridge scopes keep their existing tight walls, so ${a} cannot write to ${n} no matter who it acts for.`,whoCanAct:"A standard-trust agent in this company, or a board member.",sanctionedPath:"Report the request upward and let a standard-trust agent make the write — actor-class scope cannot be widened per task."};case"issue_write_responsible_user_ceiling":{const l=tO("RESPONSIBLE_USER_UNAUTHORIZED",{userName:s.responsibleUserName});return{code:e,status:403,tone:"boundary",boundary:"Responsible-user ceiling",title:l.title,description:`${l.description} The write to ${n} was refused for that reason.`,whoCanAct:`${o} once authorized, or anyone already permitted to write to ${n}.`,sanctionedPath:l.recommendedAction}}case"issue_write_responsible_user_unavailable":{const l=tO("RESPONSIBLE_USER_UNAVAILABLE",{userName:s.responsibleUserName});return{code:e,status:403,tone:"boundary",boundary:"Responsible-user availability",title:l.title,description:`${l.description} The write to ${n} was refused for that reason.`,whoCanAct:`A board member, or ${a} once it has an active responsible user.`,sanctionedPath:l.recommendedAction}}case"issue_write_assignee_run_lock":return{code:e,status:409,tone:"lock",boundary:"Run checkout lock",title:"Another agent's run owns this task",description:`${i} has ${n} checked out and a run is live. Checkout and run ownership stay assignee-scoped even though writes are open, so field edits belong to the run that holds the lock until it finishes.`,whoCanAct:`${i}'s live run, or an agent holding the manage-active-checkouts permission.`,sanctionedPath:`Comment instead of patching — comments stay open and wake ${i} — or wait for the run to release the lock and retry.`};case"cross_issue_influence_cap_exceeded":{const l=s.cap??20,c=s.count??null;return{code:e,status:429,tone:"cap",boundary:`Per-run cross-issue cap of ${l} writes`,title:"This run has spent its cross-issue write budget",description:`A single heartbeat run may make at most ${l} cross-issue comments or task updates combined${c!==null?`; this was attempt ${c}`:""}. The cap bounds runaway comment sprays and loops — it is a rate backstop, not a permission decision, so ${a} is still allowed to write to ${n}.`,whoCanAct:`${a} on its next heartbeat run, or ${i} on ${n} directly.`,sanctionedPath:"Consolidate what is left into one comment on your own task, or end the run and continue on the next heartbeat — the budget resets per run."}}case"cross_issue_influence_run_context_required":return{code:e,status:403,tone:"boundary",boundary:"Heartbeat run context",title:"Cross-issue writes need a run to attribute them to",description:"Every agent comment and task update is attributed to a heartbeat run so the cross-issue cap can be counted and the audit trail can name who acted for whom. This request arrived without a valid run, so it could not be contained.",whoCanAct:`${a}, once the request carries its own run id.`,sanctionedPath:"Send the `X-Paperclip-Run-Id` header with your current run (`$PAPERCLIP_RUN_ID`) and retry."};case"issue_write_attribution_spoof_rejected":return{code:e,status:422,tone:"attribution",boundary:"Server-derived attribution",title:"Responsible user cannot be chosen by the caller",description:"`onBehalfOfUserId` is derived from the authenticated actor, never from the request body — an agent cannot pick the human whose authority it rides. The attempt was recorded in the audit log.",whoCanAct:`${a} itself: the write is allowed, only the chosen attribution is not.`,sanctionedPath:`Remove \`onBehalfOfUserId\` from the request and retry; the server fills in ${o} from your run.`}}}r(CRe,"describeIssueWriteDenial");function Hce(e){return(typeof e=="string"?e:e?.name??"").trim()}r(Hce,"rawNameOf");function Qce(e){const s=e.toLowerCase();return!!(s.includes("://")||s==="localhost"||s.startsWith("localhost:")||/^\d{1,3}(\.\d{1,3}){3}(:\d+)?$/.test(s)||/^[a-z0-9.-]+:\d+$/.test(s))}r(Qce,"looksLikeNetworkAddress");function sO(e){return e.split(/[\s._-]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()).join(" ")}r(sO,"titleCaseIdentifier");function _Re(e){const s=/^plugin:\s*(.+)$/i.exec(e);if(!s)return null;let n=s[1].trim();return n=n.slice(n.lastIndexOf(".")+1),n=n.replace(/^plugin[-_]/i,""),sO(n)||"Custom app"}r(_Re,"pluginPackageLabel");function of(e,s={}){const n=s.title?.trim();if(n)return n;const a=Hce(e);if(!a||Qce(a))return"Custom app";const i=_Re(a);if(i)return i;if(a.includes(":")&&!a.includes("://")){const o=a.slice(a.lastIndexOf(":")+1).trim();if(o)return sO(o)}return/\s/.test(a)||/[A-Z]/.test(a)?a:/[._-]/.test(a)?sO(a):a}r(of,"humanizeConnectionDisplayName");function oH(e){const s=Hce(e);return s&&Qce(s)?`hosted at ${s}`:null}r(oH,"connectionDisplaySecondaryHint");var lH=`I want to connect an MCP (Model Context Protocol) server to Paperclip, and I need a paste-ready config.
3
3
 
4
4
  Target server: <name the server, or ask me if I have not said>
@@ -284,7 +284,7 @@ self.onmessage = function (e) {
284
284
  }
285
285
 
286
286
  };
287
- `;function uHe(){const e=new Blob([dHe],{type:"application/javascript"}),s=URL.createObjectURL(e);try{return new Worker(s)}finally{URL.revokeObjectURL(s)}}r(uHe,"createSandboxedWorker");var wF=new Map,IT=new Map,w2=new Set,N2=new Map,Dfe=null;function mHe(e){Dfe=e}r(mHe,"setDynamicParserResultNotifier");function Lfe(e,s){e.worker.postMessage(s)}r(Lfe,"sendToWorker");function hHe(e){return e.nextId++}r(hHe,"nextRequestId");function pHe(e,s){return`${s}\0${e}`}r(pHe,"lineCacheKey");function fHe(){Dfe?.()}r(fHe,"notifyResultReady");function xHe(e,s,n){return new Promise(a=>{const i=hHe(e);e.pendingResolves.set(i,a),Lfe(e,{type:"parse",id:i,line:s,ts:n})})}r(xHe,"parseLineAsync");function Ek(e){for(const s of e.pendingResolves.values())s([]);e.pendingResolves.clear()}r(Ek,"drainPendingRequests");function gHe(e){return new Promise((s,n)=>{const a=uHe(),i={worker:a,ready:!1,nextId:1,pendingResolves:new Map},o=setTimeout(()=>{Ek(i),a.terminate(),n(new Error("Parser worker init timed out"))},5e3);a.onmessage=l=>{const c=l.data;if(c.type==="ready"){clearTimeout(o),i.ready=!0,a.onmessage=d=>{const m=d.data;if(m.type==="result"){const h=i.pendingResolves.get(m.id);h&&(i.pendingResolves.delete(m.id),h(m.entries))}else m.type==="error"&&Ek(i)},s(i);return}if(c.type==="error"){clearTimeout(o),Ek(i),a.terminate(),n(new Error(c.message));return}},a.onerror=l=>{clearTimeout(o),Ek(i),a.terminate(),n(new Error(`Worker error: ${l.message}`))},Lfe(i,{type:"init",source:e})})}r(gHe,"initSandboxedWorker");function bHe(e){const s=new Map,n=new Set;return{parseStdoutLine:r((i,o)=>{const l=pHe(i,o),c=s.get(l);return c?c.slice():(n.has(l)||(n.add(l),xHe(e,i,o).then(d=>{n.delete(l),s.set(l,d),fHe()})),[])},"parseStdoutLine")}}r(bHe,"buildParserModule");async function NF(e){const s=IT.get(e);if(s)return s;if(w2.has(e))return null;const n=N2.get(e);if(n)return n;const a=(async()=>{try{const i=await fetch(`/api/adapters/${encodeURIComponent(e)}/ui-parser.js`);if(!i.ok)return w2.add(e),null;const o=await gHe(await i.text());wF.set(e,o);const l=bHe(o);return IT.set(e,l),l}catch{return w2.add(e),null}finally{N2.delete(e)}})();return N2.set(e,a),a}r(NF,"loadDynamicParser");function kF(e){const s=IT.has(e);IT.delete(e),w2.delete(e),N2.delete(e);const n=wF.get(e);return n&&(Ek(n),n.worker.terminate(),wF.delete(e)),s}r(kF,"invalidateDynamicParser");var k2=[],X5=new Map,SF=new Set,$fe=new Map,S4=new Set,cI=new Map,CF=new Set;function Ofe(e){return CF.add(e),()=>CF.delete(e)}r(Ofe,"onAdapterChange");function Ffe(){for(const e of CF)e()}r(Ffe,"notifyAdapterChange");mHe(Ffe);function vHe(){for(const e of[n9e,g9e,L9e,z9e,uVe,kVe,LVe,VVe,sWe,mWe,LWe,AWe,tVe,XWe,_T,cHe])SF.add(e.type),$fe.set(e.type,e),sb(e)}r(vHe,"registerBuiltInUIAdapters");function sb(e){const s=k2.findIndex(n=>n.type===e.type);s>=0?k2.splice(s,1,e):k2.push(e),X5.set(e.type,e),Ffe()}r(sb,"registerUIAdapter");function Bfe(e){return X5.get(e)??null}r(Bfe,"findUIAdapter");vHe();function tN(e){const s=X5.get(e);if(!s){let n=!1;return{type:e,label:e,parseStdoutLine:r((a,i)=>(n||(n=!0,NF(e).then(o=>{o&&sb({type:e,label:e,parseStdoutLine:o.parseStdoutLine,createStdoutParser:o.createStdoutParser,ConfigFields:Gb,buildAdapterConfig:lw})})),_T.parseStdoutLine(a,i)),"parseStdoutLine"),ConfigFields:Gb,buildAdapterConfig:lw}}return s}r(tN,"getUIAdapter");function yHe(e){const s=new Set(e.filter(a=>!a.disabled&&!a.overrideDisabled).map(a=>a.type)),n=new Set(e.map(a=>a.type));for(const a of SF){const i=$fe.get(a);if(!i)continue;const o=n.has(a),l=s.has(a),c=S4.has(a);if(o&&l&&!c){S4.add(a);const d=(cI.get(a)??0)+1;cI.set(a,d);let m=!1;const h=i.parseStdoutLine,p=e.find(f=>f.type===a)?.label??a;sb({type:a,label:p,parseStdoutLine:r((f,g)=>(m||(m=!0,NF(a).then(v=>{v&&cI.get(a)===d&&sb({type:a,label:p,parseStdoutLine:v.parseStdoutLine,createStdoutParser:v.createStdoutParser,ConfigFields:i.ConfigFields,buildAdapterConfig:i.buildAdapterConfig})})),h(f,g)),"parseStdoutLine"),ConfigFields:i.ConfigFields,buildAdapterConfig:i.buildAdapterConfig})}else(!o||!l)&&c&&(S4.delete(a),cI.delete(a),kF(a),sb(i))}for(const{type:a,label:i}of e){if(SF.has(a))continue;const o=X5.get(a);if(o&&o!==_T)continue;let l=!1;const c=o?.parseStdoutLine??_T.parseStdoutLine;sb({type:a,label:i,parseStdoutLine:r((d,m)=>(l||(l=!0,NF(a).then(h=>{h&&sb({type:a,label:i,parseStdoutLine:h.parseStdoutLine,createStdoutParser:h.createStdoutParser,ConfigFields:o?.ConfigFields??Gb,buildAdapterConfig:o?.buildAdapterConfig??lw})})),c(d,m)),"parseStdoutLine"),ConfigFields:o?.ConfigFields??Gb,buildAdapterConfig:o?.buildAdapterConfig??lw})}}r(yHe,"syncExternalAdapters");function ZU(){return[...k2]}r(ZU,"listUIAdapters");function _F(e){if(typeof e=="function")return{parseLine:e,reset:null};if(e.createStdoutParser){const s=e.createStdoutParser();return{parseLine:s.parseLine,reset:s.reset}}return{parseLine:e.parseStdoutLine,reset:null}}r(_F,"resolveStdoutParser");function qfe(e,s){if((s.kind==="thinking"||s.kind==="assistant")&&s.delta){const n=e[e.length-1];if(n&&n.kind===s.kind&&n.delta&&n.channel===s.channel){n.text+=s.text,n.ts=s.ts;return}}e.push(s)}r(qfe,"appendTranscriptEntry");function jHe(e,s){for(const n of s)qfe(e,n)}r(jHe,"appendTranscriptEntries");function wHe(e,s=160){return e.length<=s?e:`${e.slice(0,s-3)}...`}r(wHe,"truncateTranscriptLine");function NHe(e){if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"&&e)return e;try{return JSON.stringify(e)}catch{return String(e)}}r(NHe,"formatTranscriptParserError");function kHe(e,s,n,a){const i=NHe(n)||"unknown parser error",o=wHe(e);return{kind:"result",ts:s,text:Uu(`Chat transcript error: ${i}. Falling back for line: ${o}`,a),inputTokens:0,outputTokens:0,cachedTokens:0,costUsd:0,subtype:"transcript_parse_error",isError:!0,errors:[]}}r(kHe,"createTranscriptParseErrorEntry");function eK(e){const{entries:s,line:n,ts:a,parseLine:i,reset:o,redactionOptions:l}=e;try{jHe(s,i(n,a).map(c=>QFe(c,l)))}catch(c){o?.(),qfe(s,kHe(n,a,c,l))}}r(eK,"appendParsedTranscriptLine");function zfe(e){const{entries:s,chunks:n,from:a,parseLine:i,reset:o,redactionOptions:l}=e;let c=e.stdoutBuffer;for(let d=a;d<n.length;d+=1){const m=n[d];if(m.stream==="stderr"){s.push({kind:"stderr",ts:m.ts,text:Uu(m.chunk,l)});continue}if(m.stream==="system"){s.push({kind:"system",ts:m.ts,text:Uu(m.chunk,l)});continue}const h=(c+m.chunk).split(/\r?\n/);c=h.pop()??"";for(const p of h){const f=p.trim();f&&eK({entries:s,line:f,ts:m.ts,parseLine:i,reset:o,redactionOptions:l})}}return c}r(zfe,"foldTranscriptChunks");function Ufe(e,s,n){const a=[],i={enabled:n?.censorUsernameInLogs??!1},{parseLine:o,reset:l}=_F(s),c=zfe({entries:a,chunks:e,from:0,stdoutBuffer:"",parseLine:o,reset:l,redactionOptions:i}).trim();return c&&eK({entries:a,line:c,ts:e.length>0?e[e.length-1].ts:new Date().toISOString(),parseLine:o,reset:l,redactionOptions:i}),l?.(),a}r(Ufe,"buildTranscript");var PY=[];function SHe(e,s){const n={enabled:s?.censorUsernameInLogs??!1},a=typeof e!="function"&&typeof e.createStdoutParser=="function";let i=_F(e),o=[],l="",c=PY,d=[];const m=r(()=>{i=_F(e),o=[],l="",c=PY},"restart"),h=r(f=>{if(f.length<c.length)return!1;for(let g=0;g<c.length;g+=1)if(f[g]!==c[g])return!1;return!0},"extendsFolded"),p=r(f=>{const g=l.trim();if(g&&a)return Ufe(f,e,s);const v=o.slice(),y=v.length-1;return y>=0&&(v[y]={...v[y]}),g&&eK({entries:v,line:g,ts:f.length>0?f[f.length-1].ts:new Date().toISOString(),parseLine:i.parseLine,reset:i.reset,redactionOptions:n}),v},"publish");return{update(f){return f===c||(h(f)||m(),l=zfe({entries:o,chunks:f,from:c.length,stdoutBuffer:l,parseLine:i.parseLine,reset:i.reset,redactionOptions:n}),c=f,d=p(f)),d}}}r(SHe,"createIncrementalTranscript");function CHe({agents:e,value:s,onChange:n,disabled:a=!1,excludeAgentIds:i=[],disabledEmptyLabel:o="Reports to: N/A (CEO)",chooseLabel:l="Reports to..."}){const[c,d]=(0,u.useState)(!1),m=new Set(i),h=e.filter(v=>v.status!=="terminated"&&!m.has(v.id)),p=s?e.find(v=>v.id===s):null,f=p?.status==="terminated",g=!!(s&&!p);return(0,t.jsxs)(nr,{open:c,onOpenChange:d,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsx)("button",{type:"button",className:z("inline-flex max-w-full min-w-0 items-center gap-1.5 overflow-hidden rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",f&&"border-amber-600/45 bg-amber-500/5",a&&"opacity-60 cursor-not-allowed"),disabled:a,children:g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(bc,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate text-muted-foreground",children:"Unknown manager (stale ID)"})]}):p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(pr,{agent:p,size:16,className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:z("min-w-0 truncate",f&&"text-amber-900 dark:text-amber-200"),children:`Reports to ${p.name}${f?" (terminated)":""}`})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(bc,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:a?o:l})]})})}),(0,t.jsxs)(Wn,{className:"w-48 p-1",align:"start",children:[(0,t.jsx)("button",{type:"button",className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",s===null&&"bg-accent"),onClick:r(()=>{n(null),d(!1)},"onClick"),children:"No manager"}),f&&(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden px-2 py-1.5 text-xs text-muted-foreground border-b border-border mb-0.5",children:[(0,t.jsx)(pr,{agent:p,size:16,className:"shrink-0 h-3 w-3"}),(0,t.jsxs)("span",{className:"min-w-0 truncate",children:["Current: ",p.name," (terminated)"]})]}),g&&(0,t.jsx)("div",{className:"px-2 py-1.5 text-xs text-muted-foreground border-b border-border mb-0.5",children:"Saved manager is missing from this organization. Choose a new manager or clear."}),h.map(v=>(0,t.jsxs)("button",{type:"button",className:z("flex items-center gap-2 w-full min-w-0 px-2 py-1.5 text-xs rounded hover:bg-accent/50 overflow-hidden",v.id===s&&"bg-accent"),onClick:r(()=>{n(v.id),d(!1)},"onClick"),children:[(0,t.jsx)(pr,{agent:v,size:16,className:"shrink-0 h-3 w-3 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:v.name}),(0,t.jsx)("span",{className:"text-muted-foreground ml-auto shrink-0",children:GU[v.role]??v.role})]},v.id))]})]})}r(CHe,"ReportsToPicker");var _He="__secret_folder__:";function IHe(e){return!e||e==="active"?null:(0,t.jsx)(ct,{variant:"outline",className:"ml-auto text-(length:--text-nano) font-normal text-muted-foreground",children:e})}r(IHe,"statusBadge");function Kfe(e){return e.split("/").filter(s=>s.length>0)}r(Kfe,"splitSecretPath$1");function S2(e){return e.join("/")}r(S2,"pathKey$1");function HN(e){return e.length>0?`/${e.join("/")}`:"/"}r(HN,"pathLabel");function AHe(e,s){return e.length<s.length?!1:s.every((n,a)=>e[a]===n)}r(AHe,"pathStartsWith");function MY(e){return`${_He}${S2(e)}`}r(MY,"folderValue");function RHe(e,s,n){const a=s.length,i=new Map,o=[];for(const c of e){const d=Kfe(c.name);if(AHe(d,s)){if(d.length>a+1){const m=d.slice(0,a+1),h=S2(m);if(!i.has(h)){const p=m[m.length-1]??"/",f=HN(m);i.set(h,{key:`folder-${h||"root"}`,value:MY(m),label:p,title:f,searchText:f,kind:"folder",folderPath:h,pathHint:f})}continue}if(d.length===a+1||a===0&&d.length===0){const m=d.at(-1)??c.name;o.push({key:`browse-${c.id}`,value:c.id,label:m,title:c.name,searchText:`${c.key} ${c.name}`,secret:c,status:c.status,kind:"secret",pathHint:c.name,disabled:c.status!=="active"&&c.id!==n})}}}const l=[];if(s.length>0){const c=s.slice(0,-1);l.push({key:`folder-up-${S2(s)}`,value:MY(c),label:"Up one folder",title:HN(c),searchText:HN(c),kind:"back",folderPath:S2(c),pathHint:HN(c)})}return l.push(...i.values(),...o),{id:"browse-secrets",label:s.length>0?HN(s):"Browse secrets",options:l}}r(RHe,"buildFolderGroup");function tK({secretId:e,secrets:s,recentlyUsedSecrets:n,disabled:a,onSelect:i,onCreateNew:o,triggerClassName:l,disablePortal:c}){const[d,m]=(0,u.useState)(""),h=(0,u.useMemo)(()=>s.find(w=>w.id===e)??null,[s,e]),p=!!e&&!h,f=(0,u.useMemo)(()=>d?d.split("/"):[],[d]),g=(0,u.useMemo)(()=>s.some(w=>Kfe(w.name).length>1),[s]),v=(0,u.useMemo)(()=>{const w=[];p&&w.push({id:"current-missing",label:"Current",options:[{key:`missing-${e}`,value:e,label:`Missing secret (${e.slice(0,8)}…)`,title:`Missing secret (${e})`,missing:!0,disabled:!0}]});const S=(n??[]).filter(j=>j.status==="active"&&j.id!==e);return S.length>0&&w.push({id:"recently-used",label:"Recently used",options:S.map(j=>({key:`recent-${j.id}`,value:j.id,label:j.name,title:j.name,searchText:`${j.key} ${j.name}`,secret:j,status:j.status,kind:"secret"}))}),w.push({id:"all-secrets",label:S.length>0?"All secrets":void 0,options:s.map(j=>({key:`all-${j.id}`,value:j.id,label:j.name,title:j.name,searchText:`${j.key} ${j.name}`,secret:j,status:j.status,kind:"secret",disabled:j.status!=="active"&&j.id!==e}))}),w},[p,n,e,s]),y=(0,u.useCallback)((w,S)=>{if(!g||P2e(w))return S;const j=RHe(s,f,e),N=S.filter(_=>_.id==="current-missing"||_.id==="recently-used");return j.options.length>0?[...N,j]:N},[f,g,e,s]);return(0,t.jsx)(bv,{value:e||"",groups:v,onValueChange:r((w,S)=>{if(S.folderPath!==void 0)return m(S.folderPath),!1;m(""),i(w)},"onValueChange"),deriveGroups:y,disabled:a,disablePortal:c,placeholder:"Select secret…",searchPlaceholder:"Search secrets…",emptyMessage:"No matching secrets",triggerClassName:z("h-(--sz-34px) min-h-(--sz-34px) font-mono text-sm",p&&"border-destructive text-destructive",h&&h.status!=="active"&&"border-amber-500/60",l),renderValue:r(w=>{if(!w)return(0,t.jsx)("span",{className:"text-muted-foreground",children:"Select secret…"});if(w.missing)return(0,t.jsxs)("span",{className:"flex w-full min-w-0 items-center gap-1.5 text-destructive",children:[(0,t.jsx)(yi,{className:"size-3.5 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:w.label})]});const S=w.status&&w.status!=="active";return(0,t.jsxs)("span",{className:"flex w-full min-w-0 items-center gap-1.5",title:w.title,children:[(0,t.jsx)(yi,{className:z("size-3.5 shrink-0",S?"text-amber-600":"text-muted-foreground")}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:w.label}),S?(0,t.jsxs)("span",{className:"text-amber-600",children:["(",w.status,")"]}):null]})},"renderValue"),renderOption:r((w,{selected:S})=>{if(w.kind==="folder"||w.kind==="back"){const j=w.kind==="back"?g3e:Kc;return(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",title:w.title??w.label,children:[(0,t.jsx)(j,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,t.jsx)("span",{className:z("truncate text-sm",S&&"font-medium"),children:w.label}),w.pathHint?(0,t.jsx)("span",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground",children:w.pathHint}):null]})]})}return(0,t.jsxs)("span",{className:z("flex min-w-0 flex-1 items-center gap-1.5",w.disabled&&"opacity-60"),title:w.title??w.label,children:[(0,t.jsx)(yi,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,t.jsx)("span",{className:z("min-w-0 truncate font-mono text-sm",S&&"font-medium"),children:w.label}),w.pathHint&&w.pathHint!==w.label?(0,t.jsx)("span",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground",children:w.pathHint}):null]}),IHe(w.status)]})},"renderOption"),createItem:o?{render:r(w=>(0,t.jsxs)("span",{className:"flex items-center gap-1.5 text-sm",children:[(0,t.jsx)(yn,{className:"size-3.5 shrink-0"}),w.trim()?(0,t.jsxs)("span",{children:["Create secret ",(0,t.jsxs)("span",{className:"font-mono",children:["“",w.trim(),"”"]}),"…"]}):(0,t.jsx)("span",{children:"Create new secret…"})]}),"render"),onSelect:r(w=>o(w),"onSelect")}:void 0})}r(tK,"SecretPicker");var THe=/^[a-z][a-z0-9_]*$/,DY="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40 focus-visible:ring-2 focus-visible:ring-ring/40";function Vfe({mode:e,initialName:s,initialValue:n,existingSecretNames:a,onCancel:i,onSubmit:o}){const[l,c]=(0,u.useState)(s),[d,m]=(0,u.useState)(n),[h,p]=(0,u.useState)(!1),[f,g]=(0,u.useState)(!1),[v,y]=(0,u.useState)(null),[w,S]=(0,u.useState)(!1),j=l.trim(),N=j?THe.test(j)?a?.some(T=>T.toLowerCase()===j)?"A secret with this name already exists":null:"Use lowercase letters, digits and _":w?"Name is required":null,_=d.length===0&&w?"Value is required":null,A=!f&&j.length>0&&d.length>0&&!N;async function C(){if(S(!0),!!A){g(!0),y(null);try{await o(j,d)}catch(T){y(T instanceof Error?T.message:"Failed to create secret"),g(!1)}}}r(C,"handleSubmit");const I=e==="create"?"Create & bind":"Store & bind";return(0,t.jsxs)("div",{className:"w-72 space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(D2e,{className:"text-sm font-medium",children:e==="create"?"Create secret":"Store value as secret"}),e==="store"?(0,t.jsxs)(M2e,{className:"text-(length:--text-micro) text-muted-foreground",children:["Moves the typed value into an encrypted organization secret and binds"," ",(0,t.jsx)("span",{className:"font-mono",children:s||"this variable"})," to it."]}):null]}),(0,t.jsxs)("label",{className:"block space-y-1",children:[(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium text-muted-foreground",children:"Name"}),(0,t.jsx)("input",{className:z(DY,N&&"border-destructive focus-visible:ring-destructive/40"),value:l,autoFocus:!0,spellCheck:!1,placeholder:"secret_name","aria-label":"Secret name","aria-invalid":N?!0:void 0,onChange:r(T=>c(T.target.value),"onChange"),onBlur:r(()=>S(!0),"onBlur"),onKeyDown:r(T=>{T.key==="Enter"&&(T.preventDefault(),C())},"onKeyDown")}),N?(0,t.jsx)("span",{className:"block text-(length:--text-micro) text-destructive",children:N}):null]}),(0,t.jsxs)("label",{className:"block space-y-1",children:[(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium text-muted-foreground",children:"Value"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{className:z(DY,"pr-8",_&&"border-destructive focus-visible:ring-destructive/40"),type:h?"text":"password",value:d,readOnly:e==="store",spellCheck:!1,placeholder:e==="create"?"value":void 0,"aria-label":"Secret value","aria-invalid":_?!0:void 0,onChange:e==="create"?T=>m(T.target.value):void 0}),(0,t.jsx)("button",{type:"button",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded p-1 text-muted-foreground hover:text-foreground","aria-label":h?"Hide value":"Show value",onClick:r(()=>p(T=>!T),"onClick"),children:h?(0,t.jsx)(Ym,{className:"h-3.5 w-3.5"}):(0,t.jsx)(ud,{className:"h-3.5 w-3.5"})})]}),_?(0,t.jsx)("span",{className:"block text-(length:--text-micro) text-destructive",children:_}):null]}),v?(0,t.jsx)("p",{className:"text-(length:--text-micro) text-destructive",children:v}):null,(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-0.5",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:f,children:"Cancel"}),(0,t.jsxs)(F,{type:"button",size:"sm",onClick:r(()=>{C()},"onClick"),disabled:!A,children:[f?(0,t.jsx)(it,{className:"h-3.5 w-3.5 animate-spin"}):null,I]})]})]})}r(Vfe,"SecretPopoverForm");function Wfe(e){return(0,t.jsx)(Vfe,{mode:"create",...e})}r(Wfe,"CreateSecretPopover");function EHe(e){return(0,t.jsx)(Vfe,{mode:"store",...e})}r(EHe,"ConvertToSecretPopover");var PHe=/(api[-_]?key|access[-_]?token|auth(?:_?token)?|authorization|bearer|secret|passwd|password|credential|jwt|private[-_]?key|cookie|connectionstring)/i,MHe=[/^sk-[A-Za-z0-9-_]{16,}$/,/^gh[pousr]_[A-Za-z0-9]{20,}$/,/^github_pat_[A-Za-z0-9_]{20,}$/,/^xox[baprs]-[A-Za-z0-9-]{10,}$/,/^AKIA[0-9A-Z]{16}$/,/^AIza[0-9A-Za-z\-_]{20,}$/,/-----BEGIN (?:[A-Z ]+ )?PRIVATE KEY-----/,/^eyJ[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$/];function DHe(e){return e.length<24||/\s/.test(e)||!/^[A-Za-z0-9+/=_\-.]+$/.test(e)?!1:[/[a-z]/.test(e),/[A-Z]/.test(e),/[0-9]/.test(e)].filter(Boolean).length>=2}r(DHe,"looksHighEntropy");function LHe(e,s){return s?PHe.test(e)||MHe.some(n=>n.test(s))?!0:DHe(s):!1}r(LHe,"isSensitiveEnv");var LY=0;function $He(){return LY+=1,`env-row-${LY}`}r($He,"nextRowId");function ax(e="text"){return{id:$He(),name:"",source:e,textValue:"",secretId:"",userSecretKey:"",required:!0,version:"latest"}}r(ax,"emptyRow");function OHe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="secret_ref"}r(OHe,"isSecretRef");function FHe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="plain"}r(FHe,"isPlainObj");function BHe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="user_secret_ref"}r(BHe,"isUserSecretRef");function C4(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([s,n])=>{if(typeof n=="string")return{...ax(),name:s,textValue:n};if(OHe(n)){const a=typeof n.version=="number"?n.version:"latest";return{...ax(),name:s,source:"secret",secretId:typeof n.secretId=="string"?n.secretId:"",version:a}}if(BHe(n)){const a=typeof n.version=="number"?n.version:"latest";return{...ax(),name:s,source:"user_secret",userSecretKey:typeof n.key=="string"?n.key:"",required:n.required!==!1,version:a}}return FHe(n)?{...ax(),name:s,source:"text",textValue:typeof n.value=="string"?n.value:""}:{...ax(),name:s}})}r(C4,"rowsFromValue");function C2(e){const s={};for(const n of e){const a=n.name.trim();if(a)if(n.source==="secret"){if(!n.secretId)continue;s[a]={type:"secret_ref",secretId:n.secretId,version:n.version}}else if(n.source==="user_secret"){const i=n.userSecretKey.trim();if(!i)continue;s[a]={type:"user_secret_ref",key:i,version:n.version,required:n.required}}else s[a]={type:"plain",value:n.textValue}}return Object.keys(s).length>0?s:void 0}r(C2,"valueFromRows");var $Y="CLAUDE_CODE_OAUTH_TOKEN";function aj(){return C2([{...ax("user_secret"),name:"CLAUDE_CODE_OAUTH_TOKEN",userSecretKey:"CLAUDE_CODE_OAUTH_TOKEN",required:!0,version:"latest"}])??{}}r(aj,"buildFixedClaudeOAuthBinding");var qHe=/^[A-Za-z_][A-Za-z0-9_]*$/;function zHe(e,s,n){const a=e.trim();if(!a)return null;if(!qHe.test(a))return{level:"error",message:"Invalid name — use letters, digits and _"};if(s.has(a))return{level:"error",message:"Duplicate name"};for(const i of n)if(i&&a.startsWith(i))return{level:"warn",message:"Reserved prefix — provided automatically and may be overridden"};return null}r(zHe,"validateName");function UHe(e){const s=new Map;for(const a of e){const i=a.name.trim();i&&s.set(i,(s.get(i)??0)+1)}const n=new Set;for(const[a,i]of s)i>1&&n.add(a);return n}r(UHe,"computeDuplicateNames");function KHe(e,s){return s===e.source?{kind:"noop"}:s==="secret"?e.textValue.trim()?{kind:"open-store",name:AT(e.name)||"secret",value:e.textValue}:{kind:"to-secret"}:{kind:"to-text",undoFrom:e.secretId?{...e}:null}}r(KHe,"planSourceSwitch");function Hfe(e,s){if(e.source!=="secret"||!e.secretId)return null;const n=s.find(a=>a.id===e.secretId);return n?n.status!=="active"?{level:"warn",kind:"disabled",message:"Runs will fail until re-enabled or rebound."}:null:{level:"error",kind:"missing",message:"This secret no longer exists — runs will fail until you rebind."}}r(Hfe,"computeRowHealth");function Qfe(e,s){if(e.source!=="user_secret"||!e.userSecretKey||!s?.length)return null;const n=s.find(a=>a.key===e.userSecretKey);return n?n.status!=="active"?{level:"warn",kind:"disabled",message:"Runs will fail until this user secret definition is re-enabled or rebound."}:null:{level:"error",kind:"missing",message:"This user secret definition no longer exists — runs will fail until you rebind."}}r(Qfe,"computeUserSecretRowHealth");function AT(e){return e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}r(AT,"secretNameFromKey");function bS(e){return e.trim().toUpperCase().replace(/[^A-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}r(bS,"envKeyFromSecretName");var VHe="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40 focus-visible:ring-2 focus-visible:ring-ring/40",OY="min-w-0 flex-1 bg-transparent px-2 py-1.5 text-sm font-mono outline-none placeholder:text-muted-foreground/40";function WHe({row:e,isLast:s,secrets:n,userSecretDefinitions:a,recentlyUsedSecrets:i,disabled:o,nameIssue:l,showNameIssue:c,dirtyFields:d,onPatch:m,onRemove:h,onNameBlur:p,onNamePaste:f,onEnterInValueLast:g,onCreateSecret:v,onToast:y,focusRequest:w,onFocusConsumed:S}){const j=(0,u.useRef)(null),N=(0,u.useRef)(null),_=(0,u.useRef)(null),[A,C]=(0,u.useState)(null),[I,T]=(0,u.useState)(!1),[R,L]=(0,u.useState)(null),O=Hfe(e,n)??Qfe(e,a),$=e.source==="secret"?n.find(te=>te.id===e.secretId)??null:null,E=(a?.length??0)>0,q=e.source==="text"&&!e.sensitiveDismissed&&LHe(e.name,e.textValue);(0,u.useEffect)(()=>{w&&(w==="name"?j.current?.focus():e.source==="text"?N.current?.focus():e.source==="secret"?_.current?.querySelector("[role=combobox]")?.focus():_.current?.querySelector("select,input")?.focus(),S())},[w,S,e.source]),(0,u.useEffect)(()=>{if(!R)return;const te=window.setTimeout(()=>L(null),5e3);return()=>window.clearTimeout(te)},[R]);function B(te){if(te==="user_secret"){if(e.source==="user_secret")return;m({source:"user_secret",secretId:"",version:"latest"}),window.setTimeout(()=>_.current?.querySelector("select,input")?.focus(),0);return}const re=KHe(e,te);switch(re.kind){case"noop":return;case"open-store":{const{name:de,value:Z}=re;window.setTimeout(()=>C({mode:"store",name:de,value:Z}),0);return}case"to-secret":m({source:"secret",userSecretKey:"",required:!0}),window.setTimeout(()=>{_.current?.querySelector("[role=combobox]")?.focus()},0);return;case"to-text":re.undoFrom&&L(re.undoFrom),m({source:"text",secretId:"",userSecretKey:"",required:!0,version:"latest"}),window.setTimeout(()=>N.current?.focus(),0);return}}r(B,"switchSource");async function K(te,re){const de=await v(te,re);m({source:"secret",secretId:de.id,userSecretKey:"",required:!0,version:"latest",textValue:""}),y(`Secret ${de.name} created`),C(null)}r(K,"submitSecretPopover");function U(){const te=AT(e.name)||"secret",{textValue:re}=e;window.setTimeout(()=>C({mode:"store",name:te,value:re}),0)}r(U,"openStoreAsSecret");const D=e.source==="text"?"Text value":e.source==="secret"?"Organization secret reference":"User secret reference",V=`${e.id}-name-error`,H=`${e.id}-health`,J=d.name||d.value,X=$?Math.max(0,$.latestVersion):0,le=e.version==="latest"?"latest":`v${e.version}`,ce=e.version!=="latest";return(0,t.jsxs)("div",{className:z("group/row grid grid-cols-(--gtc-13) items-start gap-x-1.5 gap-y-1 rounded-md px-1 py-1","@[40rem]/env:grid-cols-(--gtc-14) @[40rem]/env:items-center",J&&"bg-amber-500/[0.06] ring-1 ring-amber-500/20"),children:[(0,t.jsx)("div",{className:"col-start-1 row-start-1 min-w-0 @[40rem]/env:row-start-1 @[40rem]/env:self-start",children:(0,t.jsx)("input",{ref:j,className:z(VHe,d.name&&"border-amber-500/70 bg-amber-500/10 focus-visible:ring-amber-500/40",c&&l?.level==="error"&&"border-destructive focus-visible:ring-destructive/40",c&&l?.level==="warn"&&"border-amber-500 focus-visible:ring-amber-500/40"),placeholder:"KEY",value:e.name,spellCheck:!1,disabled:o,"aria-label":"Variable name","aria-invalid":c&&l?.level==="error"?!0:void 0,"aria-describedby":c&&l?V:void 0,onChange:r(te=>m({name:te.target.value}),"onChange"),onBlur:p,onPaste:r(te=>{e.name||f(te.clipboardData.getData("text"))&&te.preventDefault()},"onPaste"),onKeyDown:r(te=>{te.key==="Enter"&&(te.preventDefault(),e.source==="text"?N.current?.focus():_.current?.querySelector("[role=combobox],select,input")?.focus())},"onKeyDown")})}),(0,t.jsxs)("div",{className:"col-span-2 col-start-1 row-start-2 min-w-0 @[40rem]/env:col-span-1 @[40rem]/env:col-start-2 @[40rem]/env:row-start-1",children:[(0,t.jsxs)(nr,{open:A!==null,onOpenChange:r(te=>{te||C(null)},"onOpenChange"),children:[(0,t.jsx)(J$,{asChild:!0,children:(0,t.jsxs)("div",{ref:_,className:z("relative flex items-stretch overflow-hidden rounded-md border border-border bg-transparent focus-within:ring-2 focus-within:ring-ring/40",d.value&&"border-amber-500/70 bg-amber-500/10 focus-within:ring-amber-500/40",o&&"opacity-60"),children:[(0,t.jsxs)(fa,{children:[(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)(pa,{asChild:!0,disabled:o,children:(0,t.jsxs)("button",{type:"button","aria-label":"Value source",className:"flex shrink-0 items-center gap-0.5 border-r border-border px-2 text-muted-foreground hover:bg-accent/50 disabled:pointer-events-none",children:[e.source==="text"?(0,t.jsx)(sPe,{className:"size-3.5"}):e.source==="secret"?(0,t.jsx)(yi,{className:"size-3.5"}):(0,t.jsx)(vu,{className:"size-3.5"}),(0,t.jsx)(en,{className:"size-3 opacity-60"})]})})}),(0,t.jsx)(Un,{side:"top",children:D})]}),(0,t.jsxs)(xa,{align:"start",className:"w-56",children:[(0,t.jsxs)(ps,{className:"flex-col items-start gap-0.5",onSelect:r(()=>B("text"),"onSelect"),children:[(0,t.jsx)("span",{className:"text-sm",children:"Text value"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"Store the value inline as plain text."})]}),(0,t.jsxs)(ps,{className:"flex-col items-start gap-0.5",onSelect:r(()=>B("secret"),"onSelect"),children:[(0,t.jsx)("span",{className:"text-sm",children:"Organization secret"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"Resolve a stored organization secret at run start."})]}),(0,t.jsxs)(ps,{className:"flex-col items-start gap-0.5",onSelect:r(()=>B("user_secret"),"onSelect"),children:[(0,t.jsx)("span",{className:"text-sm",children:"User secret"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"Resolve the responsible user's own value at run start."})]})]})]}),e.source==="text"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:N,className:OY,placeholder:"value",value:e.textValue,type:q?"password":"text",spellCheck:!1,disabled:o,"aria-label":"Variable value",onChange:r(te=>m({textValue:te.target.value}),"onChange"),onKeyDown:r(te=>{te.key==="Enter"&&s&&(te.preventDefault(),g())},"onKeyDown")}),q?(0,t.jsxs)("div",{className:"flex shrink-0 items-stretch border-l border-border",children:[(0,t.jsxs)("button",{type:"button",onClick:U,disabled:o,className:"flex items-center gap-1 px-2 text-(length:--text-micro) text-amber-700 hover:bg-amber-500/10 dark:text-amber-400",title:"This value looks sensitive — store it as a secret",children:[(0,t.jsx)(kl,{className:"size-3.5"}),(0,t.jsx)("span",{className:"hidden @[30rem]/env:inline",children:"Store as secret"})]}),(0,t.jsx)("button",{type:"button",onClick:r(()=>m({sensitiveDismissed:!0}),"onClick"),disabled:o,"aria-label":"Dismiss sensitive-value suggestion",title:"Dismiss — keep this value as plain text",className:"flex items-center px-1.5 text-amber-700/60 hover:bg-amber-500/10 hover:text-amber-700 dark:text-amber-400/60 dark:hover:text-amber-400",children:(0,t.jsx)(ir,{className:"size-3"})})]}):null]}):e.source==="secret"?(0,t.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,t.jsx)(tK,{secretId:e.secretId,secrets:n,recentlyUsedSecrets:i,disabled:o,onSelect:r(te=>m({secretId:te,version:"latest"}),"onSelect"),onCreateNew:r(te=>C({mode:"create",name:AT(te)||te.trim(),value:""}),"onCreateNew"),triggerClassName:z("rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0",$&&$.status==="active"&&"pr-24 has-[>svg]:!pr-24")}),$&&$.status==="active"?(0,t.jsxs)(nr,{open:I,onOpenChange:T,children:[(0,t.jsx)(J$,{asChild:!0,children:(0,t.jsx)("button",{type:"button",disabled:o,onClick:r(te=>{te.preventDefault(),te.stopPropagation(),T(re=>!re)},"onClick"),"aria-label":"Version",className:z("absolute right-8 top-1/2 z-10 -translate-y-1/2 rounded px-1.5 py-0.5 text-(length:--text-nano) font-medium",ce?"bg-amber-500/15 text-amber-700 dark:text-amber-400":"text-muted-foreground hover:bg-accent"),children:le})}),(0,t.jsxs)(Wn,{align:"end",className:"w-44 p-1",role:"radiogroup","aria-label":"Secret version",children:[(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":e.version==="latest",onClick:r(()=>{m({version:"latest"}),T(!1)},"onClick"),className:z("flex w-full items-center justify-between rounded px-2 py-1.5 text-sm hover:bg-accent",e.version==="latest"&&"font-medium"),children:["latest ",(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"(recommended)"})]}),Array.from({length:X},(te,re)=>X-re).filter(te=>te>0).map(te=>(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":e.version===te,onClick:r(()=>{m({version:te}),T(!1)},"onClick"),className:z("flex w-full items-center rounded px-2 py-1.5 text-sm hover:bg-accent",e.version===te&&"font-medium text-amber-700 dark:text-amber-400"),children:["v",te]},te))]})]}):null]}):(0,t.jsxs)("div",{className:"grid min-w-0 flex-1 grid-cols-(--gtc-13)",children:[E?(0,t.jsxs)("select",{"aria-label":"User secret",value:e.userSecretKey,disabled:o,onChange:r(te=>{const re=te.target.value,de=a?.find(Z=>Z.key===re);m({userSecretKey:re,...de&&!e.name.trim()?{name:de.key.toUpperCase()}:{}})},"onChange"),className:"min-w-0 bg-transparent px-2 py-1.5 text-sm font-mono outline-none disabled:pointer-events-none",children:[(0,t.jsx)("option",{value:"",children:"Select user secret..."}),e.userSecretKey&&!a?.some(te=>te.key===e.userSecretKey)?(0,t.jsxs)("option",{value:e.userSecretKey,children:["Unknown (",e.userSecretKey,")"]}):null,(a??[]).map(te=>(0,t.jsxs)("option",{value:te.key,children:[te.name,te.status!=="active"?` (${te.status})`:""]},te.id))]}):(0,t.jsx)("input",{className:OY,placeholder:"user-secret key",value:e.userSecretKey,spellCheck:!1,disabled:o,"aria-label":"User secret key",onChange:r(te=>m({userSecretKey:te.target.value}),"onChange")}),(0,t.jsxs)("select",{"aria-label":"Requirement",value:e.required?"required":"optional",disabled:o,onChange:r(te=>m({required:te.target.value==="required"}),"onChange"),className:"border-l border-border bg-transparent px-2 py-1.5 text-xs font-medium text-muted-foreground outline-none disabled:pointer-events-none",children:[(0,t.jsx)("option",{value:"required",children:"Required"}),(0,t.jsx)("option",{value:"optional",children:"Optional"})]})]})]})}),(0,t.jsx)(Wn,{align:"start",className:"w-auto p-3",onInteractOutside:r(te=>{const re=te.detail.originalEvent.target;re&&_.current?.contains(re)&&te.preventDefault()},"onInteractOutside"),children:A?.mode==="store"?(0,t.jsx)(EHe,{initialName:A.name,initialValue:A.value,existingSecretNames:n.map(te=>te.name),onCancel:r(()=>C(null),"onCancel"),onSubmit:K}):A?.mode==="create"?(0,t.jsx)(Wfe,{initialName:A.name,initialValue:A.value,existingSecretNames:n.map(te=>te.name),onCancel:r(()=>C(null),"onCancel"),onSubmit:K}):null})]}),O?(0,t.jsx)("p",{id:H,role:"status",className:z("mt-0.5 text-(length:--text-micro)",O.level==="error"?"text-destructive":"text-amber-600 dark:text-amber-400"),children:O.message}):null,R?(0,t.jsxs)("p",{className:"mt-0.5 inline-flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:["Reverted to text —"," ",(0,t.jsx)("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2 hover:text-primary",onClick:r(()=>{m({source:"secret",secretId:R.secretId,version:R.version,textValue:""}),L(null)},"onClick"),children:"Undo"})]}):null]}),c&&l?(0,t.jsx)("p",{id:V,className:z("col-span-2 col-start-1 row-start-3 min-w-0 text-(length:--text-micro) @[40rem]/env:col-span-2 @[40rem]/env:row-start-2",l.level==="error"?"text-destructive":"text-amber-600 dark:text-amber-400"),children:l.message}):null,(0,t.jsxs)("div",{className:"col-start-2 row-start-1 flex items-center justify-end gap-0.5 self-start @[40rem]/env:col-start-3 @[40rem]/env:self-center",children:[e.source==="text"&&!q&&(e.name.trim()||e.textValue)?(0,t.jsxs)(fa,{children:[(0,t.jsx)(pa,{asChild:!0,disabled:o,children:(0,t.jsx)("button",{type:"button","aria-label":"More actions",className:"rounded p-1 text-muted-foreground opacity-100 hover:bg-accent hover:text-foreground @[40rem]/env:opacity-0 @[40rem]/env:group-hover/row:opacity-100 @[40rem]/env:group-focus-within/row:opacity-100",children:(0,t.jsx)(Ei,{className:"size-4"})})}),(0,t.jsx)(xa,{align:"end",children:(0,t.jsx)(ps,{onSelect:r(()=>{window.setTimeout(U,0)},"onSelect"),children:"Store as secret…"})})]}):null,(0,t.jsx)("button",{type:"button",onClick:h,disabled:o,"aria-label":`Remove ${e.name.trim()||"variable"}`,className:"rounded p-1 text-muted-foreground opacity-100 hover:bg-destructive/10 hover:text-destructive @[40rem]/env:opacity-0 @[40rem]/env:group-hover/row:opacity-100 @[40rem]/env:group-focus-within/row:opacity-100",children:(0,t.jsx)(ir,{className:"size-4"})})]})]})}r(WHe,"EnvironmentVariableRow");var HHe=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)$/;function QHe(e){const s=e.indexOf(" #");return s>=0?e.slice(0,s):e}r(QHe,"stripInlineComment");function GHe(e){const s=e.trim();if(s.length>=2){const n=s[0],a=s[s.length-1];if(n==='"'&&a==='"'||n==="'"&&a==="'")return s.slice(1,-1)}return QHe(s).trim()}r(GHe,"unquote");function YHe(e){const s=[];for(const n of e.split(/\r?\n/)){const a=n.trim();if(!a||a.startsWith("#"))continue;const i=HHe.exec(a);if(!i)continue;const o=i[1],l=GHe(i[2]);s.push({key:o,value:l})}return s}r(YHe,"parseDotenv");var JHe=["PAPERCLIP_"],XHe="Set the KEY to the env var name the process expects, for example GH_TOKEN. Choose a secret to resolve a stored value at run start. PAPERCLIP_* variables are injected automatically.";function IF(e){if(!e||typeof e!="object")return[];const s=new Map;for(const[n,a]of Object.entries(e)){const i=n.trim();if(i)if(typeof a=="string")s.set(i,{type:"plain",value:a});else if(a?.type==="secret_ref"){const o=typeof a.secretId=="string"?a.secretId:"";if(!o)continue;s.set(i,{type:"secret_ref",secretId:o,version:typeof a.version=="number"?a.version:"latest"})}else if(a?.type==="user_secret_ref"){const o=typeof a.key=="string"?a.key.trim():"";if(!o)continue;s.set(i,{type:"user_secret_ref",key:o,version:typeof a.version=="number"?a.version:"latest",required:a.required!==!1})}else a?.type==="plain"?s.set(i,{type:"plain",value:typeof a.value=="string"?a.value:""}):s.set(i,{type:"plain",value:""})}return[...s.entries()].sort(([n],[a])=>n.localeCompare(a))}r(IF,"normalizedEnvEntries");function QN(e){return JSON.stringify(IF(e))}r(QN,"normalizedEnvKey");var _4=3;function I4(e){const s=e.slice(0,_4).join(", ");return e.length>_4?`${s} +${e.length-_4} more`:s}r(I4,"formatChangedNames");function FY(e){return e.map(s=>({...s}))}r(FY,"cloneRows");function ZHe(e,s){return s?{name:e.name.trim()!==s.name.trim(),value:e.source!==s.source||e.textValue!==s.textValue||e.secretId!==s.secretId||e.userSecretKey!==s.userSecretKey||e.required!==s.required||e.version!==s.version}:{name:!!e.name.trim(),value:e.source!=="text"||!!e.textValue||!!e.secretId||e.version!=="latest"}}r(ZHe,"rowDirtyFields");var Yb=(0,u.forwardRef)(r(function({value:s,onChange:n,secrets:a,userSecretDefinitions:i,onCreateSecret:o,recentlyUsedSecrets:l,disabled:c,reservedPrefixes:d=JHe,footerHint:m,onDirtyChange:h,hideDraftActions:p=!1},f){const g=Sc(),v=(0,u.useRef)(null),[y,w]=(0,u.useState)(()=>C4(s)),S=(0,u.useRef)(y),[j,N]=(0,u.useState)(()=>FY(y)),_=(0,u.useMemo)(()=>QN(s),[]),A=(0,u.useRef)(_),C=(0,u.useRef)(_),I=(0,u.useRef)(null),[T,R]=(0,u.useState)(_),[L,O]=(0,u.useState)(()=>new Set(C4(s).map(oe=>oe.name.trim()).filter(Boolean))),[$,E]=(0,u.useState)(null);(0,u.useEffect)(()=>{S.current=y},[y]);function q(oe,je=S.current){A.current=oe,R(oe),N(FY(je))}r(q,"markCommitted");function B(oe){O(je=>{const _e=new Set(je);for(const xe of oe){const Ae=xe.name.trim();Ae&&_e.add(Ae)}return _e})}r(B,"touchCommittedNames");function K(oe){const je=C4(oe);return w(je),B(je),je}r(K,"adoptExternalValue"),(0,u.useEffect)(()=>{const oe=QN(s);if(oe===C.current)return;C.current=oe;const je=QN(C2(S.current)),_e=je!==A.current,xe=I.current===oe;if(xe&&(I.current=null),!_e){q(oe,K(s));return}(xe||je===oe)&&(B(S.current),q(oe))},[s]);const U=(0,u.useMemo)(()=>C2(y),[y]),D=(0,u.useMemo)(()=>QN(U),[U]),V=D!==T;(0,u.useEffect)(()=>{h?.(!c&&V)},[c,V,h]);const H=(0,u.useMemo)(()=>{const oe=new Map(IF(C2(j)).map(([Ae,Ye])=>[Ae,JSON.stringify(Ye)])),je=new Map(IF(U).map(([Ae,Ye])=>[Ae,JSON.stringify(Ye)])),_e=[],xe=[];for(const[Ae,Ye]of je)oe.has(Ae)?oe.get(Ae)!==Ye&&xe.push(Ae):_e.push(Ae);return{added:_e,changed:xe,removed:[...oe.keys()].filter(Ae=>!je.has(Ae))}},[j,U]),J=(0,u.useMemo)(()=>{const oe=[];return H.added.length>0&&oe.push(`New: ${I4(H.added)}`),H.changed.length>0&&oe.push(`Edited: ${I4(H.changed)}`),H.removed.length>0&&oe.push(`Removed: ${I4(H.removed)}`),oe.join(" · ")},[H]);(0,u.useEffect)(()=>{if(c||!V)return;function oe(je){je.preventDefault(),je.returnValue=""}return r(oe,"handleBeforeUnload"),window.addEventListener("beforeunload",oe),()=>window.removeEventListener("beforeunload",oe)},[c,V]);const X=(0,u.useCallback)(()=>c||!V?null:(I.current=D,(0,Yp.flushSync)(()=>{n(U)}),U??{}),[c,U,D,V,n]);(0,u.useImperativeHandle)(f,()=>({flushPendingDraft:X}),[X]),(0,u.useEffect)(()=>{const oe=v.current?.closest("form");if(!oe)return;function je(){X()}return r(je,"handleSubmit"),oe.addEventListener("submit",je,!0),()=>oe.removeEventListener("submit",je,!0)},[X]),(0,u.useEffect)(()=>{const oe=v.current;if(!oe)return;const je=oe;function _e(xe){const Ae=xe.target;if(!(Ae instanceof Element)||je.contains(Ae))return;const Ye=Ae.closest("button");if(!Ye||Ye.disabled)return;const Oe=`${Ye.getAttribute("aria-label")??""} ${Ye.textContent??""}`;(Ye.type==="submit"||/\b(save|create|update|test|import)\b/i.test(Oe))&&X()}return r(_e,"handleDocumentClick"),document.addEventListener("click",_e,!0),()=>document.removeEventListener("click",_e,!0)},[X]);function le(oe){w(oe)}r(le,"updateDraft");function ce(oe,je){le(y.map(_e=>_e.id===oe?{..._e,...je}:_e))}r(ce,"patchRow");function te(oe){le(y.filter(je=>je.id!==oe))}r(te,"removeRow");function re(){const oe=ax();w([...y,oe]),E({rowId:oe.id,field:"name"})}r(re,"addRow");function de(oe){const je=y.find(_e=>_e.id===oe)?.name.trim();je&&O(_e=>{if(_e.has(je))return _e;const xe=new Set(_e);return xe.add(je),xe})}r(de,"markTouched");function Z(oe,je){const _e=YHe(oe);if(_e.length===0)return!1;const xe=y.filter(Ae=>Ae.id!==je).map(Ae=>({...Ae}));for(const{key:Ae,value:Ye}of _e){const Oe=xe.find(Xe=>Xe.name.trim()===Ae);Oe?(Oe.name=Ae,Oe.source="text",Oe.textValue=Ye,Oe.secretId="",Oe.sensitiveDismissed=!1,Oe.userSecretKey="",Oe.required=!0):xe.push({...ax(),name:Ae,textValue:Ye})}return le(xe),g?.pushToast({title:`Imported ${_e.length} variable${_e.length===1?"":"s"}`,tone:"success"}),!0}r(Z,"bulkImport");function Y(oe){const je=y.map(Ae=>({...Ae})),_e=je[je.length-1];let xe;_e&&!_e.name&&!_e.textValue&&!_e.secretId&&!_e.userSecretKey?xe=_e:(xe=ax(),je.push(xe)),xe.source="secret",xe.secretId=oe.id,xe.version="latest",xe.name||(xe.name=bS(oe.name)),le(je)}r(Y,"bindRecentSecret");function G(){V&&(I.current=D,n(U))}r(G,"saveDraft");function fe(){I.current=null,C.current=QN(s);const oe=K(s);q(C.current,oe)}r(fe,"revertDraft");const se=(0,u.useMemo)(()=>UHe(y),[y]),ae=(0,u.useMemo)(()=>y.reduce((oe,je)=>Hfe(je,a)||Qfe(je,i)?oe+1:oe,0),[y,a,i]),ie=(0,u.useMemo)(()=>{const oe=new Set(y.filter(je=>je.source==="secret"&&je.secretId).map(je=>je.secretId));return(l??[]).filter(je=>je.status==="active"&&!oe.has(je.id)).slice(0,8)},[l,y]),ue=y.length>0,pe=m===void 0?XHe:m,be=(0,u.useMemo)(()=>new Map(j.map(oe=>[oe.id,oe])),[j]);return(0,t.jsx)(md,{children:(0,t.jsxs)("div",{ref:v,className:"@container/env space-y-2",children:[ae>1?(0,t.jsxs)("p",{className:"inline-flex items-center gap-1.5 text-(length:--text-micro) font-medium text-amber-700 dark:text-amber-400",children:[(0,t.jsx)(Vi,{className:"size-3.5"}),ae," bindings need attention"]}):null,ue?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"hidden gap-x-1.5 @[40rem]/env:grid @[40rem]/env:grid-cols-(--gtc-14)",children:[(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Name"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Value"}),(0,t.jsx)("span",{})]}),y.map((oe,je)=>{const _e=zHe(oe.name,se,d),xe=L.has(oe.name.trim());return(0,t.jsx)(WHe,{row:oe,isLast:je===y.length-1,secrets:a,userSecretDefinitions:i,recentlyUsedSecrets:l,disabled:c,nameIssue:_e,showNameIssue:xe,dirtyFields:ZHe(oe,be.get(oe.id)),onPatch:r(Ae=>ce(oe.id,Ae),"onPatch"),onRemove:r(()=>te(oe.id),"onRemove"),onNameBlur:r(()=>de(oe.id),"onNameBlur"),onNamePaste:r(Ae=>Z(Ae,oe.id),"onNamePaste"),onEnterInValueLast:re,onCreateSecret:o,onToast:r(Ae=>g?.pushToast({title:Ae,tone:"success"}),"onToast"),focusRequest:$?.rowId===oe.id?$.field:null,onFocusConsumed:r(()=>E(null),"onFocusConsumed")},oe.id)})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No environment variables"}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-1",children:[(0,t.jsxs)("button",{type:"button",onClick:re,disabled:c,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:[(0,t.jsx)(yn,{className:"size-3.5"}),"Add variable"]}),ie.length>0&&!c?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-(length:--text-micro) text-muted-foreground/70",children:[(0,t.jsx)(yi,{className:"size-3"}),"Recently used:"]}),ie.map(oe=>(0,t.jsxs)("button",{type:"button",onClick:r(()=>Y(oe),"onClick"),className:"inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 font-mono text-(length:--text-micro) text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",title:`Bind ${oe.name}`,children:["+ ",oe.name]},oe.id))]}):null]}),V&&!c&&!p?(0,t.jsxs)("div",{role:"status",className:"mt-3 flex w-full flex-col gap-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-3 text-amber-950 shadow-sm dark:bg-amber-500/15 dark:text-amber-100 @[34rem]/env:flex-row @[34rem]/env:items-center @[34rem]/env:justify-between",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)("span",{className:"size-2 rounded-full bg-amber-500 shadow-(--shadow-extract-13)"}),(0,t.jsx)("span",{children:"Unsaved changes"})]}),J?(0,t.jsx)("p",{className:"min-w-0 truncate pl-4 text-xs text-amber-950/80 dark:text-amber-100/80",title:J,children:J}):null]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:fe,className:"inline-flex h-9 items-center gap-1.5 rounded-md border border-amber-500/30 bg-background px-3 text-sm font-medium text-foreground transition-colors hover:bg-amber-500/10 dark:bg-background/80",children:[(0,t.jsx)(Ii,{className:"size-4"}),"Revert"]}),(0,t.jsxs)("button",{type:"button",onClick:G,className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90",children:[(0,t.jsx)(Hp,{className:"size-4"}),"Save"]})]})]}):null,pe?(0,t.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground/70",children:pe}):null,y.some(oe=>oe.source==="user_secret"&&oe.userSecretKey)?(0,t.jsxs)("p",{className:"inline-flex items-start gap-1 text-(length:--text-micro) text-muted-foreground/70",children:[(0,t.jsx)(vu,{className:"mt-0.5 size-3 shrink-0"}),(0,t.jsx)("span",{children:"User secrets resolve from the user responsible for the run. Required bindings fail until that user sets their value under Secrets → My secrets."})]}):null]})})},"EnvironmentVariablesEditor")),eQe="env.",P1="access.",AF=/^[A-Za-z_][A-Za-z0-9_]*$/;function Gfe(e){return e?e.startsWith("access.")?"api":e.startsWith("env.")?"env":"config":"config"}r(Gfe,"deliveryModeForConfigPath");function Yfe(e){switch(e){case"env":return"Env var";case"api":return"API access";default:return"Config"}}r(Yfe,"deliveryModeLabel");function tQe(e){switch(e){case"env":return"Injected as an environment variable at run start.";case"api":return"Fetched on demand via the run-bound agent API. Never written to the environment.";default:return"Provided through adapter configuration."}}r(tQe,"deliveryModeDescription");function Jfe(e){return e?e.startsWith("access.")?e.slice(7):e.startsWith("env.")?e.slice(4):e:""}r(Jfe,"aliasFromConfigPath");function sQe(e){switch(e){case"agent_api":return"Agent API";case"plugin_worker":return"Plugin worker";case"tool_connection":return"Tool connection";default:return e.charAt(0).toUpperCase()+e.slice(1)}}r(sQe,"consumerTypeLabel");var nQe={numeric:!0,sensitivity:"base"};function Pk(e){return e.kind==="company"?e.secret.name:e.definition.name}r(Pk,"getSecretPathRowName");function hw(e){return e.split("/").filter(s=>s.length>0)}r(hw,"splitSecretPath");function A4(e){return hw(e).join("/")}r(A4,"normalizeSecretPath");function BY(e,s){return s.every((n,a)=>e[a]===n)}r(BY,"startsWithSegments");function qY(e,s){return e.localeCompare(s,void 0,nQe)}r(qY,"compareNames");function rQe(e,s){const n=hw(s),a=e.map(c=>({row:c,name:Pk(c),segments:hw(Pk(c))})),i=new Set,o=[];for(const c of a){if(!BY(c.segments,n))continue;const d=c.segments.length-n.length;(d===0||d===1)&&o.push(c.row),d>=2&&i.add(c.segments[n.length])}const l=[...i].map(c=>{const d=[...n,c],m=new Set;let h=0;for(const p of a){if(!BY(p.segments,d))continue;const f=p.segments.length-d.length;if(!(f<1)){h+=1;for(let g=1;g<f;g+=1)m.add(p.segments.slice(d.length,d.length+g).join("/"))}}return{name:c,path:d.join("/"),secretCount:h,folderCount:m.size}});return l.sort((c,d)=>qY(c.name,d.name)),o.sort((c,d)=>qY(Pk(c),Pk(d))),{folders:l,secrets:o}}r(rQe,"buildSecretPathListing");function aQe(e){const s=hw(e);return s.map((n,a)=>({name:n,path:s.slice(0,a+1).join("/")}))}r(aQe,"buildSecretPathBreadcrumbs");function iQe(e){return e.trim()?e.includes("/")?"Folder name cannot contain slashes.":null:"Folder name is required."}r(iQe,"validateSecretFolderSegment");function cC({name:e,basePath:s="",className:n,leafClassName:a}){const i=hw(e),o=hw(s),l=o.length>0&&o.every((h,p)=>i[p]===h)&&i.length>o.length?i.slice(o.length):i,c=l.length>0?l:[e],d=c[c.length-1],m=c.slice(0,-1).join("/");return(0,t.jsxs)("span",{className:z("min-w-0 truncate",n),children:[m?(0,t.jsxs)("span",{className:"text-muted-foreground",children:[m,"/"]}):null,(0,t.jsx)("span",{className:z("font-medium text-foreground",a),children:d})]})}r(cC,"SecretPathName");function oQe(e,s){const n=e?`sha256:${e.slice(0,10)}…`:"no fingerprint",a=typeof s=="number"?`${s} ${s===1?"byte":"bytes"}`:null;return a?`${n} · ${a}`:n}r(oQe,"fingerprintLabel");function Xfe({fingerprint:e,length:s,className:n}){const{pushToast:a}=da(),i=oQe(e,s);if(!e)return(0,t.jsxs)("span",{className:z("inline-flex items-center gap-1 font-mono",n),children:[(0,t.jsx)(nH,{className:"size-3 shrink-0"}),i]});const o=`sha256:${e}`;return(0,t.jsxs)("button",{type:"button",onClick:r(()=>{Hr(o).then(()=>a({title:"Fingerprint copied",tone:"success"})).catch(()=>a({title:"Couldn’t copy fingerprint",tone:"error"}))},"onClick"),title:`Copy full digest — ${o}`,className:z("inline-flex items-center gap-1 font-mono hover:text-foreground",n),children:[(0,t.jsx)(nH,{className:"size-3 shrink-0"}),i,(0,t.jsx)(jr,{className:"size-3 shrink-0 opacity-60"})]})}r(Xfe,"FingerprintChip");function sK({justification:e,className:s}){return(0,t.jsxs)("div",{className:z("space-y-0.5",s),children:[(0,t.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:"Reason given by the agent"}),(0,t.jsxs)("p",{className:"whitespace-pre-wrap break-words text-xs text-foreground/80",children:["“",e,"”"]})]})}r(sK,"ProposalJustification");function dC({agent:e,className:s}){return(0,t.jsxs)("span",{className:z("inline-flex min-w-0 items-center gap-1",s),children:[(0,t.jsx)(pr,{agent:e,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:e.name})]})}r(dC,"AgentRefChip");function nK({configPath:e}){const s=Gfe(e),n=s==="env",a=s==="api";return(0,t.jsxs)(ct,{variant:"outline",className:z("h-5 gap-1 px-1.5 text-(length:--text-nano) font-normal",n&&"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",a&&"border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300",!n&&!a&&"border-border bg-muted/40 text-muted-foreground"),children:[n?(0,t.jsx)(Ode,{className:"size-3"}):a?(0,t.jsx)(v5,{className:"size-3"}):null,Yfe(s)]})}r(nK,"DeliveryBadge$1");function rK({className:e}){return(0,t.jsxs)(ct,{variant:"outline",className:z("h-5 gap-1 px-1.5 text-(length:--text-nano) font-medium","border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300",e),children:[(0,t.jsx)(kl,{className:"size-3"})," Proposed"]})}r(rK,"ProposedBadge");function Z5(e){return Jfe(e.configPath)}r(Z5,"bindingEnvKey");function aK(e){return e.secretProposalId?{name:e.secretProposalName??"proposed secret",pending:!0}:{name:e.secretName??"secret",pending:!1}}r(aK,"bindingSecretLabel");function zY(e){return e instanceof vn?e.message||`Request failed: ${e.status}`:e instanceof Error?e.message:"Something went wrong. Try again."}r(zY,"readableError");function Zfe(e,s=[]){const n=Kt(),{pushToast:a}=da(),[i,o]=(0,u.useState)(null),[l,c]=(0,u.useState)(null),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(null),f=(0,u.useCallback)(()=>{e&&(n.invalidateQueries({queryKey:["secret-proposals",e]}),n.invalidateQueries({queryKey:P.secrets.list(e)}))},[e,n]),g=ke({mutationFn:r(j=>{const{proposal:N}=j;if(N.kind==="secret"){const _=j.folder.trim()?`${j.folder.trim().replace(/\/+$/,"")}/${j.leaf.trim()}`:j.leaf.trim();return hr.approveProposal(e,N.id,{overrides:{name:_,description:j.description.trim()||null,providerConfigId:j.providerConfigId||null}})}return hr.approveProposal(e,N.id,{cascade:j.cascade||void 0})},"mutationFn"),onSuccess:r(j=>{a({title:j.kind==="secret"?"Secret approved":"Binding approved",body:j.kind==="secret"?j.proposedName??"Secret created":`${j.target?.name??"Agent"} · ${Z5(j)||"binding"}`,tone:"success"}),o(null),p(null),f()},"onSuccess"),onError:r(j=>p(zY(j)),"onError")}),v=ke({mutationFn:r(({proposal:j,reason:N})=>hr.rejectProposal(e,j.id,{reason:N.trim()}),"mutationFn"),onSuccess:r(j=>{a({title:"Proposal rejected",body:j.kind==="secret"?j.proposedName??void 0:void 0,tone:"info"}),c(null),m(""),p(null),f()},"onSuccess"),onError:r(j=>p(zY(j)),"onError")}),y=(0,u.useCallback)(j=>{p(null);const N=(j.proposedName??"").split("/"),_=N.pop()??"";o({proposal:j,folder:N.join("/"),leaf:_,description:j.proposedDescription??"",providerConfigId:s.find(A=>A.provider==="local_encrypted"&&A.isDefault)?.id??"",cascade:!!j.secretProposalId})},[s]),w=(0,u.useCallback)(j=>{p(null),m(""),c(j)},[]),S=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(lQe,{draft:i,error:h,pending:g.isPending,providerConfigs:s,onChange:o,onCancel:r(()=>{o(null),p(null)},"onCancel"),onConfirm:r(()=>i&&g.mutate(i),"onConfirm")}),(0,t.jsx)(dQe,{proposal:l,reason:d,error:h,pending:v.isPending,onReasonChange:m,onCancel:r(()=>{c(null),m(""),p(null)},"onCancel"),onConfirm:r(()=>l&&v.mutate({proposal:l,reason:d}),"onConfirm")})]});return{requestApprove:y,requestReject:w,isBusy:g.isPending||v.isPending,dialogs:S}}r(Zfe,"useProposalReview");function lQe({draft:e,error:s,pending:n,providerConfigs:a,onChange:i,onCancel:o,onConfirm:l}){const c=e?.proposal.kind==="secret",d=e?e.folder.trim()?`${e.folder.trim().replace(/\/+$/,"")}/${e.leaf.trim()}`:e.leaf.trim():"",m=a.filter(p=>p.provider==="local_encrypted"),h=c?!!(e&&e.leaf.trim()):!0;return(0,t.jsx)(Js,{open:!!e,onOpenChange:r(p=>!p&&o(),"onOpenChange"),children:(0,t.jsx)(Zs,{className:"sm:max-w-lg",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(Sn,{children:[(0,t.jsx)(rn,{children:c?"Approve & create secret":"Approve binding"}),(0,t.jsx)(Mn,{children:c?"The value is created as the proposing agent recorded it. Re-folder or rename it before it lands.":"Grant the target agent access to this secret. This runs with your permissions."})]}),(0,t.jsxs)("div",{className:"space-y-1.5 rounded-md border border-border bg-muted/30 p-2.5 text-xs",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,t.jsx)("span",{children:"Proposed by"}),(0,t.jsx)(dC,{agent:e.proposal.proposedBy,className:"font-medium text-foreground"})]}),(0,t.jsx)(sK,{justification:e.proposal.justification})]}),c?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Ws,{htmlFor:"approve-folder",children:"Folder"}),(0,t.jsx)(_t,{id:"approve-folder",value:e.folder,onChange:r(p=>i({...e,folder:p.target.value}),"onChange"),placeholder:"dev/github",className:"font-mono text-xs"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Ws,{htmlFor:"approve-name",children:"Name"}),(0,t.jsx)(_t,{id:"approve-name",value:e.leaf,onChange:r(p=>i({...e,leaf:p.target.value}),"onChange"),placeholder:"client-secret",autoFocus:!0,"aria-invalid":!e.leaf.trim(),className:"font-mono text-xs"})]})]}),(0,t.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:["Lands as"," ",d?(0,t.jsx)(cC,{name:d,className:"font-mono"}):(0,t.jsx)("span",{className:"italic",children:"enter a name"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Ws,{htmlFor:"approve-description",children:"Description"}),(0,t.jsx)(_t,{id:"approve-description",value:e.description,onChange:r(p=>i({...e,description:p.target.value}),"onChange"),placeholder:"Optional"})]}),m.length>0?(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Ws,{htmlFor:"approve-provider-config",children:"Provider vault"}),(0,t.jsxs)("select",{id:"approve-provider-config",value:e.providerConfigId,onChange:r(p=>i({...e,providerConfigId:p.target.value}),"onChange"),className:"h-9 w-full rounded-md border border-input bg-transparent px-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,t.jsx)("option",{value:"",children:"Deployment default"}),m.map(p=>(0,t.jsx)("option",{value:p.id,children:p.displayName},p.id))]})]}):null,(0,t.jsx)("div",{className:"rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-muted-foreground",children:(0,t.jsx)(Xfe,{fingerprint:e.proposal.valueFingerprintSha256,length:e.proposal.valueLength})})]}):(0,t.jsx)(cQe,{draft:e,onChange:i}),s?(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:s}):null,(0,t.jsxs)(br,{children:[(0,t.jsx)(F,{variant:"ghost",onClick:o,disabled:n,children:"Cancel"}),(0,t.jsx)(F,{onClick:l,disabled:n||!h,children:n?"Approving…":c?"Approve & create":e.cascade?"Approve secret & bind":"Approve binding"})]})]}):null})})}r(lQe,"ApproveDialog");function cQe({draft:e,onChange:s}){const{proposal:n}=e,a=aK(n),i=Z5(n);return(0,t.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,t.jsxs)("div",{className:"space-y-2 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Target agent"}),n.target?(0,t.jsx)(dC,{agent:n.target,className:"text-sm font-medium"}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"—"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Delivered as"}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(nK,{configPath:n.configPath}),(0,t.jsx)("code",{className:"font-mono text-xs",children:i||n.configPath})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Secret"}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(yi,{className:"size-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:a.name}),a.pending?(0,t.jsx)(rK,{}):null]})]})]}),n.secretProposalId?(0,t.jsxs)("label",{className:"flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-2.5 text-xs",children:[(0,t.jsx)(Fi,{checked:e.cascade,onCheckedChange:r(o=>s({...e,cascade:o===!0}),"onCheckedChange"),className:"mt-0.5","aria-label":"Also approve the proposed secret"}),(0,t.jsxs)("span",{className:"text-foreground/90",children:["Also approve the proposed secret"," ",(0,t.jsx)("span",{className:"font-medium",children:a.name})," and create it in the same step. The binding can’t land without it."]})]}):null]})}r(cQe,"BindingApproveBody");function dQe({proposal:e,reason:s,error:n,pending:a,onReasonChange:i,onCancel:o,onConfirm:l}){const c=s.trim().length>0;return(0,t.jsx)(Js,{open:!!e,onOpenChange:r(d=>!d&&o(),"onOpenChange"),children:(0,t.jsx)(Zs,{className:"sm:max-w-md",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(Sn,{children:[(0,t.jsx)(rn,{children:"Reject proposal"}),(0,t.jsxs)(Mn,{children:["The reason is sent back to"," ",(0,t.jsx)(dC,{agent:e.proposedBy,className:"text-foreground"}),". Dependent bindings are rejected too."]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Ws,{htmlFor:"reject-reason",children:"Reason"}),(0,t.jsx)(En,{id:"reject-reason",value:s,onChange:r(d=>i(d.target.value),"onChange"),rows:3,autoFocus:!0,placeholder:"Why is this being rejected?"})]}),n?(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:n}):null,(0,t.jsxs)(br,{children:[(0,t.jsx)(F,{variant:"ghost",onClick:o,disabled:a,children:"Cancel"}),(0,t.jsx)(F,{variant:"destructive",onClick:l,disabled:a||!c,children:a?"Rejecting…":"Reject"})]})]}):null})})}r(dQe,"RejectDialog");function exe({proposal:e,onApprove:s,onReject:n,disabled:a,size:i="sm"}){const o=!e.viewerCanApprove,l=i==="xs"?"h-7 px-2 text-xs":"",c=(0,t.jsx)(F,{size:"sm",className:l,disabled:a||o,onClick:r(()=>s(e),"onClick"),children:"Approve"});return(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[o?(0,t.jsx)(md,{children:(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)("span",{tabIndex:0,children:c})}),(0,t.jsx)(Un,{className:"max-w-72",children:e.approveBlockReason??"You don’t have permission to approve this."})]})}):c,(0,t.jsx)(F,{size:"sm",variant:"outline",className:l,disabled:a,onClick:r(()=>n(e),"onClick"),children:"Reject"})]})}r(exe,"ProposalActions");function txe(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}r(txe,"asRecord$15");function sxe(e){const s=txe(e);if(!s||s.type!=="secret_ref")return null;const n=typeof s.secretId=="string"?s.secretId:"";return n?{secretId:n,version:typeof s.version=="number"?s.version:"latest"}:null}r(sxe,"readSecretRef");function uQe(e){const s=txe(e?.env);if(!s)return[];const n=[];for(const[a,i]of Object.entries(s)){const o=sxe(i);o&&n.push({name:a,...o})}return n}r(uQe,"parseEnvSecretRefs");function mQe(e){if(!e)return[];const s=[];for(const[n,a]of Object.entries(e)){if(!n.startsWith("access."))continue;const i=sxe(a);i&&s.push({name:n.slice(P1.length),...i})}return s}r(mQe,"parseAccessGrants");function hQe(e,s){const n=new Map,a=r(i=>{let o=n.get(i);return o||(o={secretId:i,envKeys:[],apiAliases:[]},n.set(i,o)),o},"ensure");for(const i of e)a(i.secretId).envKeys.push(i.name);for(const i of s)a(i.secretId).apiAliases.push(i.name);return[...n.values()]}r(hQe,"summarizeAgentBindings");var UY=0;function nxe(){return UY+=1,`access-row-${UY}`}r(nxe,"nextAccessRowId");function R4(e){return e.map(s=>({id:nxe(),alias:s.name,secretId:s.secretId,version:s.version}))}r(R4,"entriesToRows");function KY(e){const s={};for(const n of e){const a=n.alias.trim();!a||!AF.test(a)||!n.secretId||(s[a]={type:"secret_ref",secretId:n.secretId,version:n.version})}return s}r(KY,"rowsToAccessMap");function VY(e){return JSON.stringify(Object.keys(e).sort().map(s=>{const n=e[s];return[s,n.secretId,n.version??"latest"]}))}r(VY,"normalizeAccessMapKey");function WY({mode:e}){return e==="env"?(0,t.jsxs)(ct,{variant:"outline",className:"h-5 gap-1 px-1.5 text-(length:--text-nano) font-normal border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",children:[(0,t.jsx)(Ode,{className:"size-3"})," Env var"]}):(0,t.jsxs)(ct,{variant:"outline",className:"h-5 gap-1 px-1.5 text-(length:--text-nano) font-normal border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300",children:[(0,t.jsx)(v5,{className:"size-3"})," API access"]})}r(WY,"DeliveryBadge");function pQe({config:e,secrets:s,onChange:n,onCreateSecret:a,disabled:i,proposals:o,onApproveProposal:l,onRejectProposal:c}){const d=(0,u.useMemo)(()=>(o??[]).filter($=>$.kind==="binding"),[o]),m=(0,u.useMemo)(()=>uQe(e),[e]),h=(0,u.useMemo)(()=>mQe(e),[e]),p=(0,u.useMemo)(()=>hQe(m,h),[m,h]),f=(0,u.useMemo)(()=>KY(R4(h)),[h]),g=(0,u.useMemo)(()=>VY(f),[f]),[v,y]=(0,u.useState)(()=>R4(h)),[w,S]=(0,u.useState)(null),j=(0,u.useRef)(new Map),N=(0,u.useRef)(g),_=(0,u.useRef)(g);(0,u.useEffect)(()=>{g!==_.current&&(_.current=g,g!==N.current&&y(R4(h)))},[g,h]);const A=r($=>s.find(E=>E.id===$)?.name??`${$.slice(0,8)}…`,"secretName");function C($){y($);const E=KY($);N.current=VY(E),n(E)}r(C,"emit");function I($,E){C(v.map(q=>q.id===$?{...q,...E}:q))}r(I,"patchRow");function T($){C(v.filter(E=>E.id!==$))}r(T,"removeRow");function R(){y($=>[...$,{id:nxe(),alias:"",secretId:"",version:"latest"}])}r(R,"addRow");const L=(0,u.useMemo)(()=>{const $=new Map;for(const E of v){const q=E.alias.trim();q&&$.set(q,($.get(q)??0)+1)}return $},[v]),O=p.length>0;return(0,t.jsxs)("div",{className:"space-y-3",children:[O?(0,t.jsx)("div",{className:"space-y-1.5",children:p.map($=>(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 rounded-md border border-border bg-muted/30 px-2.5 py-1.5 text-xs",children:[(0,t.jsx)(yi,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:A($.secretId)}),$.envKeys.length>0?(0,t.jsx)(WY,{mode:"env"}):null,$.apiAliases.length>0?(0,t.jsx)(WY,{mode:"api"}):null,(0,t.jsx)("span",{className:"min-w-0 truncate font-mono text-(length:--text-micro) text-muted-foreground",children:[...$.envKeys.map(E=>`${eQe}${E}`),...$.apiAliases.map(E=>`${P1}${E}`)].join(" · ")})]},$.secretId))}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No secrets are bound to this agent yet."}),d.length>0&&l&&c?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Proposed access"}),d.map($=>{const E=aK($),q=Z5($);return(0,t.jsxs)("div",{className:"flex flex-col gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-2.5 py-2 text-xs sm:flex-row sm:items-center",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,t.jsx)(nK,{configPath:$.configPath}),(0,t.jsx)("code",{className:"font-mono",children:q||$.configPath}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"→"}),(0,t.jsx)(yi,{className:"size-3 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:E.name}),E.pending?(0,t.jsx)(rK,{}):null]}),(0,t.jsxs)("p",{className:"flex flex-wrap items-center gap-1 text-muted-foreground",children:[(0,t.jsxs)("span",{children:["proposed by ",$.proposedBy.name]}),(0,t.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,t.jsxs)("span",{className:"truncate italic",children:["“",$.justification,"”"]})]})]}),(0,t.jsx)(exe,{proposal:$,onApprove:l,onReject:c,disabled:i,size:"xs"})]},$.id)})]}):null,(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"API access (no env var)"}),v.length>0?(0,t.jsx)("div",{className:"space-y-2",children:v.map($=>{const E=$.alias.trim(),q=!!E&&!AF.test(E),B=!!E&&(L.get(E)??0)>1,K=s.find(U=>U.id===$.secretId)??null;return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"grid grid-cols-(--gtc-65) items-start gap-1.5",children:[(0,t.jsx)("div",{children:(0,t.jsx)(_t,{value:$.alias,onChange:r(U=>I($.id,{alias:U.target.value}),"onChange"),onBlur:r(U=>{const D=U.target.value.trim();if(D&&!AF.test(D)){const V=bS(D);V&&V!==D&&I($.id,{alias:V})}},"onBlur"),placeholder:"ALIAS","aria-label":"Access alias",disabled:i,className:z("h-9 font-mono text-sm",(q||B)&&"border-destructive text-destructive")})}),(0,t.jsxs)("div",{className:"flex min-w-0 items-start gap-1.5",children:[(0,t.jsxs)(nr,{open:w?.rowId===$.id,onOpenChange:r(U=>{!U&&w?.rowId===$.id&&S(null)},"onOpenChange"),children:[(0,t.jsx)(J$,{asChild:!0,children:(0,t.jsx)("div",{ref:r(U=>{U?j.current.set($.id,U):j.current.delete($.id)},"ref"),className:"min-w-0 flex-1",children:(0,t.jsx)(tK,{secretId:$.secretId,secrets:s,onSelect:r(U=>I($.id,{secretId:U,version:"latest",alias:!$.alias.trim()&&U?bS(A(U)):$.alias}),"onSelect"),onCreateNew:a?U=>{window.setTimeout(()=>{S({rowId:$.id,name:AT(U)||U.trim()})},0)}:void 0,disabled:i,triggerClassName:"h-9 min-h-9"})})}),(0,t.jsx)(Wn,{align:"start",className:"w-auto p-3",onInteractOutside:r(U=>{const D=U.detail.originalEvent.target;D&&j.current.get($.id)?.contains(D)&&U.preventDefault()},"onInteractOutside"),children:w?.rowId===$.id&&a?(0,t.jsx)(Wfe,{initialName:w.name,initialValue:"",existingSecretNames:s.map(U=>U.name),onCancel:r(()=>S(null),"onCancel"),onSubmit:r(async(U,D)=>{const V=await a(U,D);I($.id,{secretId:V.id,version:"latest",alias:$.alias.trim()||bS(V.name)}),S(null)},"onSubmit")}):null})]}),(0,t.jsxs)("select",{className:"h-9 shrink-0 rounded-md border border-border bg-background px-2 text-xs outline-none disabled:cursor-not-allowed disabled:opacity-60",value:$.version===void 0?"latest":String($.version),onChange:r(U=>{const D=U.target.value;I($.id,{version:D==="latest"?"latest":Number.parseInt(D,10)})},"onChange"),disabled:i||!K,"aria-label":"Version",children:[(0,t.jsx)("option",{value:"latest",children:"latest"}),K?Array.from({length:Math.max(0,K.latestVersion)},(U,D)=>{const V=K.latestVersion-D;return V<=0?null:(0,t.jsxs)("option",{value:V,children:["v",V]},V)}):null]})]}),(0,t.jsx)("button",{type:"button",onClick:r(()=>T($.id),"onClick"),disabled:i,"aria-label":"Remove API access",className:"mt-1 inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:(0,t.jsx)(Ia,{className:"size-3.5"})})]}),q?(0,t.jsx)("p",{className:"pl-0.5 text-(length:--text-micro) text-destructive",children:"Invalid alias — use letters, digits and _"}):B?(0,t.jsx)("p",{className:"pl-0.5 text-(length:--text-micro) text-destructive",children:"Duplicate alias"}):null]},$.id)})}):null,(0,t.jsxs)("button",{type:"button",onClick:R,disabled:i,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:[(0,t.jsx)(yn,{className:"size-3.5"}),"Add API access"]})]}),(0,t.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground/70",children:[tQe("api")," The agent reads them by alias through ",(0,t.jsx)("code",{children:"GET /agents/me/secrets"}),"."]})]})}r(pQe,"AgentSecretAccessEditor");function fQe(e){if(typeof e!="string")return null;const s=e.trim();return s.length>0?s:null}r(fQe,"asNonEmptyString$3");function xQe(e){return fQe(e)!==null}r(xQe,"hasLegacyWorkingDirectory");function gQe(e){return e.isCreate?!1:xQe(e.adapterConfig?.cwd)}r(gQe,"shouldShowLegacyWorkingDirectoryField");var rxe=new Set;function bQe(e){return rxe.has(e)}r(bQe,"isAdapterTypeHidden");function vQe(e){rxe=new Set(e)}r(vQe,"setDisabledAdapterTypes");function yQe(e){return!zm(e).hideFromVisualSelection}r(yQe,"isVisualAdapterChoice");function axe(e,s=ZU()){const n=e??df;return s.map(a=>({value:a.type,label:n(a.type),comingSoon:!!zm(a.type).comingSoon,hidden:bQe(a.type),experimental:!!zm(a.type).experimental}))}r(axe,"listAdapterOptions");function ixe(e={}){const s=e.enabled??!0,{data:n}=ee({queryKey:P.adapters.all,queryFn:r(()=>Am.list(),"queryFn"),enabled:s,staleTime:3e5});return n&&yHe(n.filter(a=>a.source==="external").map(a=>({type:a.type,label:a.label,disabled:a.disabled,overrideDisabled:a.overridePaused}))),(0,u.useEffect)(()=>{n&&vQe(n.filter(a=>a.disabled).map(a=>a.type))},[n]),(0,u.useMemo)(()=>new Set(n?.filter(a=>a.disabled).map(a=>a.type)??[]),[n])}r(ixe,"useDisabledAdaptersSync");function jQe(e={}){const s=e.enabled??!0,{data:n}=ee({queryKey:P.adapters.all,queryFn:r(()=>Am.list(),"queryFn"),enabled:s,staleTime:3e5});return n!==void 0}r(jQe,"useAdapterRegistryLoaded");function RT(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))}r(RT,"omitUndefinedEntries");function dI(e,s){const n={};if(Object.keys(s.identity).length>0&&Object.assign(n,s.identity),s.adapterType!==void 0&&(n.adapterType=s.adapterType),s.adapterType!==void 0||Object.keys(s.adapterConfig).length>0){const a=e.adapterConfig??{};n.adapterConfig=RT(s.adapterType!==void 0?{...Object.fromEntries(L_e.filter(i=>a[i]!==void 0).map(i=>[i,a[i]])),...s.adapterConfig}:{...a,...s.adapterConfig}),n.replaceAdapterConfig=!0}if(Object.keys(s.heartbeat).length>0||Object.keys(s.debug).length>0){const a=e.runtimeConfig??{},i=n.runtimeConfig??{...a};if(Object.keys(s.heartbeat).length>0&&(i.heartbeat={...a.heartbeat??{},...s.heartbeat}),Object.keys(s.debug).length>0){const o=RT({...a.debug??{},...s.debug});Object.keys(o).length===0?delete i.debug:i.debug=o}n.runtimeConfig=i}return Object.keys(s.runtime).length>0&&Object.assign(n,s.runtime),n}r(dI,"buildAgentUpdatePatch");var wQe="kubernetes";function NQe(e){return e.driver!=="sandbox"?!1:e.config?.provider===wQe}r(NQe,"isKubernetesSandboxEnvironment");function iK(e,s){return e!=="kubernetes"?{forced:!1,kubernetesEnvironment:null}:{forced:!0,kubernetesEnvironment:s.find(n=>NQe(n))??null}}r(iK,"resolveForcedKubernetesEnvironment");var T4={identity:{},adapterConfig:{},heartbeat:{},debug:{},runtime:{}},GN={};function kQe(e){return e==="claude_local"||e==="codex_local"||e==="paperclip_runner"||e==="opencode_local"}r(kQe,"supportsAdapterModelRefresh");function SQe(e,s){return Fme(e,s).model}r(SQe,"resolvePaperclipRunnerTransitionModel");function HY(e){return Object.keys(e.identity).length>0||e.adapterType!==void 0||Object.keys(e.adapterConfig).length>0||Object.keys(e.heartbeat).length>0||Object.keys(e.debug).length>0||Object.keys(e.runtime).length>0}r(HY,"isOverlayDirty");function RF(e,s){if(Object.is(e,s))return!0;if(Array.isArray(e)&&Array.isArray(s))return e.length===s.length&&e.every((n,a)=>RF(n,s[a]));if(typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof s=="object"&&s!==null&&!Array.isArray(s)){const n=Object.entries(e),a=s;return n.length===Object.keys(a).length&&n.every(([i,o])=>i in a&&RF(o,a[i]))}return!1}r(RF,"overlayValuesEqual");function CQe(e,s){const n=r((a,i)=>Object.fromEntries(Object.entries(a).filter(([o,l])=>!(o in i)||!RF(l,i[o]))),"subtractGroup");return{identity:n(e.identity,s.identity),...e.adapterType!==void 0&&e.adapterType!==s.adapterType?{adapterType:e.adapterType}:{},adapterConfig:n(e.adapterConfig,s.adapterConfig),heartbeat:n(e.heartbeat,s.heartbeat),debug:n(e.debug,s.debug),runtime:n(e.runtime,s.runtime)}}r(CQe,"subtractPersistedOverlay");var bm="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40";function _Qe(e){return e.split(",").map(s=>s.trim()).filter(Boolean)}r(_Qe,"parseCommaArgs");function IQe(e){return Array.isArray(e)?e.filter(s=>typeof s=="string").join(", "):typeof e=="string"?e:""}r(IQe,"formatArgList");var AQe=[{id:"",label:"Auto"},{id:"minimal",label:"Minimal"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"X-High"},{id:"max",label:"Max"}],RQe=[{id:"",label:"Auto"},{id:"plan",label:"Plan"},{id:"ask",label:"Ask"}],TQe=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"}],EQe=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"high",label:"High"},{id:"max",label:"Max"}],PQe=2,QY=10,MQe=1,oxe=300;function _2(e,s,n){return Math.max(s,Math.min(n,Math.floor(e)))}r(_2,"clampInteger");function DQe(e){return _2(e,0,oxe)*1e3}r(DQe,"clampDelayMsFromSeconds");function LQe({order:e,className:s,children:n}){if(!e)return(0,t.jsx)("div",{className:s,children:n});const a=r(o=>{const l=(0,u.isValidElement)(o)?o.props["data-config-section"]:void 0,c=l?e.indexOf(l):-1;return c<0?e.length:c},"rank"),i=u.Children.toArray(n).sort((o,l)=>a(o)-a(l));return(0,t.jsx)("div",{className:s,children:i})}r(LQe,"ConfigSections");function lxe(e){const{mode:s,adapterModels:n}=e,a=s==="create",i=e.sectionLayout==="cards",o=e.showAdapterTypeField??!0,l=e.showAdapterTestEnvironmentButton??!0,c=l&&!e.onTestActionChange&&!e.compactTestFeedback,d=!e.onTestFeedbackChange,m=e.showCreateRunPolicySection??!0,h=e.hideInstructionsFile??!1,p=e.canConfigureProviderTrace===!0,{selectedCompanyId:f}=xs(),g=Kt(),v=(0,u.useRef)(null),y=ixe(),{data:w=[]}=ee({queryKey:f?P.secrets.list(f):["secrets","none"],queryFn:r(()=>hr.list(f),"queryFn"),enabled:!!f}),{data:S=[]}=ee({queryKey:f?P.secrets.userDefinitions(f):["user-secret-definitions","none"],queryFn:r(()=>hr.listUserSecretDefinitions(f),"queryFn"),enabled:!!f,retry:!1}),j=a?null:e.agent.id,{data:N=[]}=ee({queryKey:f?P.secrets.proposals(f,"pending"):["secret-proposals","none"],queryFn:r(()=>hr.listProposals(f,"pending"),"queryFn"),enabled:!!f&&!a,retry:!1}),_=(0,u.useMemo)(()=>N.filter(Qe=>Qe.kind==="binding"&&Qe.target?.id===j),[N,j]),A=Zfe(f,[]),{data:C}=ee({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn"),retry:!1}),I=(0,u.useMemo)(()=>{const Qe=new Set(y);return C?.enableNativeRunner!==!0&&Qe.add("paperclip_runner"),Qe},[y,C?.enableNativeRunner]),T=C?.enableEnvironments===!0,R=C?.enableManagedSandboxOnly===!0,L=C===void 0||R,{data:O}=ee({queryKey:P.instance.generalSettings,queryFn:r(()=>Ir.getGeneral(),"queryFn"),retry:!1}),{data:$}=ee({queryKey:P.instance.settings,queryFn:r(()=>Ir.get(),"queryFn"),retry:!1}),{data:E=[]}=ee({queryKey:f?P.environments.list(f):["environments","none"],queryFn:r(()=>Ci.list(f),"queryFn"),enabled:!!f&&(T||O?.executionMode==="kubernetes")}),{forced:q,kubernetesEnvironment:B}=(0,u.useMemo)(()=>iK(O?.executionMode,E),[O?.executionMode,E]),K=ke({mutationFn:r(Qe=>{if(!f)throw new Error("Select an organization to create secrets");return hr.create(f,Qe)},"mutationFn"),onSuccess:r(()=>{f&&g.invalidateQueries({queryKey:P.secrets.list(f)})},"onSuccess")}),U=ke({mutationFn:r(async({file:Qe,namespace:Yt})=>{if(!f)throw new Error("Select an organization to upload images");return d0.uploadImage(f,Qe,Yt)},"mutationFn")}),[D,V]=(0,u.useState)(T4),[H,J]=(0,u.useState)(!1),[X,le]=(0,u.useState)(0),ce=(0,u.useRef)(null),te=(0,u.useRef)(null),re=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(!a){if(ce.current!==null&&e.agent!==ce.current&&!re.current){const Qe=te.current;te.current=null,V(Yt=>Qe?CQe(Yt,Qe):{...T4})}ce.current=e.agent}},[a,a?void 0:e.agent]);const de=!a&&(HY(D)||H);function Z(Qe,Yt,an){const Fs=D[Qe];return Yt in Fs?Fs[Yt]:an}r(Z,"eff");function Y(Qe,Yt,an){V(Fs=>({...Fs,[Qe]:{...Fs[Qe],[Yt]:an}}))}r(Y,"mark");function G(){return v.current?.flushPendingDraft()??null}r(G,"flushEnvironmentDraft");const fe=(0,u.useCallback)(Qe=>{a||V(Yt=>{const an={...e.agent.adapterConfig??{},...Yt.adapterConfig},Fs={...Yt.adapterConfig};for(const[Kn,Nr]of Object.entries(Qe))Fs[`${P1}${Kn}`]=Nr;for(const Kn of Object.keys(an))Kn.startsWith("access.")&&(Kn.slice(7)in Qe||(Fs[Kn]=void 0));return{...Yt,adapterConfig:Fs}})},[a,a?void 0:e.agent]),se=(0,u.useCallback)(()=>{V({...T4}),J(!1),le(Qe=>Qe+1)},[]),ae=(0,u.useCallback)(async()=>{if(a)return;const Qe=G(),Yt=Qe?{...D,adapterConfig:{...D.adapterConfig,env:Qe}}:D;HY(Yt)&&await e.onSave(dI(e.agent,Yt))},[a,de,D,e]);(0,u.useEffect)(()=>{a||(e.onDirtyChange?.(de),e.onSaveActionChange?.(ae),e.onCancelActionChange?.(se))},[a,de,e.onDirtyChange,e.onSaveActionChange,e.onCancelActionChange,ae,se]),(0,u.useEffect)(()=>{if(!a)return()=>{e.onSaveActionChange?.(null),e.onCancelActionChange?.(null),e.onDirtyChange?.(!1)}},[a,e.onDirtyChange,e.onSaveActionChange,e.onCancelActionChange]);const ie=a?{}:e.agent.adapterConfig??{},ue=a?{}:e.agent.runtimeConfig??{},pe=a?{}:ue.heartbeat??{},be=a?{}:ue.debug??{},oe=a?e.values.adapterType:D.adapterType??e.agent.adapterType,je=Uw(),_e=je(oe),xe=_e.supportsInstructionsBundle||_e.supportsSkills||_e.supportsLocalAgentJwt,Ae=xe&&!L&&gQe({isCreate:a,adapterConfig:ie}),Ye=(0,u.useMemo)(()=>tN(oe),[oe]),Oe=(0,u.useMemo)(()=>new Set(nTe(oe)),[oe]),Xe=a?e.values:null,me=a?Qe=>e.onChange(Qe):null;a&&Xe.claudeStoredSessionId;const Le=r(()=>{f&&g.invalidateQueries({queryKey:P.secrets.userDefinitions(f)})},"invalidateUserSecretDefinitions"),mt=r(Qe=>{if(!a||!me)return;const Yt=Xe.envBindings??{};me({envBindings:{...Yt,...aj()},claudeStoredSessionId:Qe}),Le()},"handleClaudeLoginStored"),We=r(async()=>{if(a)return;const Qe={...G()??Z("adapterConfig","env",ie.env??GN),...aj()},Yt={...D,adapterConfig:{...D.adapterConfig,env:Qe}};V(Yt),await e.onSave({...dI(e.agent,Yt),applyStoredClaudeLogin:!0}),Le()},"handleClaudeLoginStoredEdit"),ze=r(async Qe=>{if(a||!Qe.companyIdentityDiffers)return;const Yt={...G()??Z("adapterConfig","env",ie.env??GN),CODEX_HOME:{type:"secret_ref",secretId:Qe.secretId,version:"latest"}},an={...D,adapterConfig:{...D.adapterConfig,env:Yt}};V(an),te.current=an,re.current=!0;try{await e.onSave(dI(e.agent,an))}catch(Fs){throw te.current=null,Fs}finally{re.current=!1}Le()},"handleCodexAccountBindingEdit"),st=r(()=>{if(!a||!me)return;const Qe=Xe.envBindings??{};me({envBindings:{...Qe,...aj()},claudeApplyStoredLogin:!0}),Le()},"handleApplyStoredClaudeLogin"),pt=r(async()=>{if(a)return;const Qe={...G()??Z("adapterConfig","env",ie.env??GN),...aj()},Yt={...D,adapterConfig:{...D.adapterConfig,env:Qe}};V(Yt),await e.onSave({...dI(e.agent,Yt),applyStoredClaudeLogin:!0}),Le()},"handleApplyStoredClaudeLoginEdit"),Pt=a?Xe.defaultEnvironmentId??"":Z("identity","defaultEnvironmentId",e.agent.defaultEnvironmentId??""),tt=(0,u.useMemo)(()=>Pt?(E.find(Qe=>Qe.id===Pt)??null)?.driver==="local"?"":Pt:"",[E,Pt]),ht=(0,u.useMemo)(()=>E.find(Qe=>Qe.id===tt)??null,[tt,E]),et=(0,u.useMemo)(()=>{const Qe=$?.defaultEnvironmentId??null;return Qe?(E.find(Yt=>Yt.id===Qe)??null)?.driver==="local"?"":Qe:""},[E,$?.defaultEnvironmentId]),Ie=(0,u.useMemo)(()=>E.find(Qe=>Qe.id===et)??null,[E,et]),Ne=(0,u.useMemo)(()=>{try{return cw({agentDefaultEnvironmentId:Pt||null,instanceDefaultEnvironmentId:$?.defaultEnvironmentId??null,localDefaultEnvironmentId:uw(E),managedSandboxOnly:C?.enableManagedSandboxOnly===!0,managedSandboxEnvironmentId:dw(E),visibleEnvironmentIds:E.map(Qe=>Qe.id)})}catch{return null}},[Pt,$?.defaultEnvironmentId,E,C?.enableManagedSandboxOnly]),Je=(0,u.useMemo)(()=>E.find(Qe=>Qe.id===Ne)??null,[E,Ne]),{data:ft}=ee({queryKey:f?P.environments.capabilities(f):["environment-capabilities","none"],queryFn:r(()=>Ci.capabilities(f),"queryFn"),enabled:!!f&&_e.login!=null});(0,u.useEffect)(()=>{!a||!me||!q||!B||tt!==B.id&&me({defaultEnvironmentId:B.id})},[a,me,q,B,tt]);const Ot=(0,u.useMemo)(()=>E.filter(Qe=>{if(!Oe.has(Qe.driver)||Qe.driver==="local")return!1;if(Qe.driver!=="sandbox")return!0;const Yt=typeof Qe.config?.provider=="string"?Qe.config.provider:null;return Yt!==null&&Yt!=="fake"}),[E,Oe]),es=(0,u.useMemo)(()=>!ht||Ot.some(Qe=>Qe.id===ht.id)?Ot:[...Ot,ht],[ht,Ot]),bs=T&&(q||tt.length>0||Ot.length>=1),Ke=Ie?mw(Ie):R?"Paperclip Computer":"Local",Ve=oe==="paperclip_runner"?String(a?e.values.adapterSchemaValues?.provider??"codex":Z("adapterConfig","provider",ie.provider==="acpx"&&ie.acpxAgent==="codex"?"codex":ie.provider??"codex")):void 0,dt=oe==="opencode_local"&&t2.safeParse(D.runtime.runtimeConfig?.aiConnection??ue.aiConnection).data?.provider==="openrouter"?"openrouter":Ve,Be=f?P.agents.adapterModels(f,oe,tt||null,dt):["agents","none","adapter-models",oe],{data:as,error:Fe}=ee({queryKey:Be,queryFn:r(()=>zt.adapterModels(f,oe,{environmentId:tt||null,provider:dt}),"queryFn"),enabled:!!f}),[Ut,At]=(0,u.useState)(null),[Ls,qe]=(0,u.useState)(!1),ut=as??n??[],Dt="command",{data:is,refetch:Ts}=ee({queryKey:f?P.agents.detectModel(f,oe):["agents","none","detect-model",oe],queryFn:r(()=>{if(!f)throw new Error("Select an organization to detect the model");return zt.detectModel(f,oe)},"queryFn"),enabled:!!(f&&xe&&oe!=="opencode_local"&&oe!=="paperclip_runner")}),jt=is?.model??null;is?.candidates;const{data:we=[]}=ee({queryKey:f?P.agents.list(f):["agents","none","list"],queryFn:r(()=>zt.list(f),"queryFn"),enabled:!!(!a&&f)}),Pe={mode:s,isCreate:a,adapterType:oe,values:a?e.values:null,set:a?Qe=>e.onChange(Qe):null,config:ie,eff:Z,mark:Y,models:ut,hideInstructionsFile:h||L,managedSandboxOnly:L},[at,Mt]=(0,u.useState)(!1),[kt,hs]=(0,u.useState)(!1),bt=mfe(oe),Vt=r(Qe=>(0,t.jsxs)(t.Fragment,{children:[oe==="claude_local"&&(0,t.jsx)(s9e,{...Pe,section:Qe}),(0,t.jsx)(Ye.ConfigFields,{...Pe,section:Qe,hideModel:xe})]}),"renderAdapterFields"),[Wt,Me]=(0,u.useState)(!1),[Ee,He]=(0,u.useState)(!1);function Ue(Qe){if(a){const an=Ye.buildAdapterConfig(Xe);return Qe&&Object.assign(an,Qe),RT(an)}const Yt={...ie,...D.adapterConfig};return Qe&&Object.assign(Yt,Qe),RT(Yt)}r(Ue,"buildAdapterConfigForTest");const Gt=ke({mutationFn:r(async()=>{if(!f)throw new Error("Select an organization to test adapter environment");const Qe=G(),Yt=Qe?{env:Qe}:void 0;let an=$,Fs=E,Kn=C?.enableManagedSandboxOnly===!0;if(!Pt)try{const[ns,on,Hs]=await Promise.all([g.ensureQueryData({queryKey:P.instance.settings,queryFn:r(()=>Ir.get(),"queryFn")}),g.ensureQueryData({queryKey:P.environments.list(f),queryFn:r(()=>Ci.list(f),"queryFn")}),g.ensureQueryData({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn")})]);an=ns,Fs=on,Kn=Hs?.enableManagedSandboxOnly===!0}catch{throw new Error("Could not load environment settings to determine which environment to test in. Retry the test.")}const Nr=cw({agentDefaultEnvironmentId:Pt||null,instanceDefaultEnvironmentId:an?.defaultEnvironmentId??null,localDefaultEnvironmentId:uw(Fs),managedSandboxOnly:Kn,managedSandboxEnvironmentId:dw(Fs),visibleEnvironmentIds:Fs.map(ns=>ns.id)}),ga=Ue(Yt),Vn=a?void 0:e.agent.id,Qn=a?void 0:t2.safeParse(D.runtime.runtimeConfig?.aiConnection??e.agent.runtimeConfig.aiConnection).data;if(e.compactTestFeedback){const ns=oe==="paperclip_runner"?ga.provider==="codex"?"codex_local":ga.provider==="acpx"&&ga.acpxAgent==="claude"?"claude_local":oe:oe;return rfe({companyId:f,adapterType:oe,providerAdapter:ns,adapterConfig:ga,agentId:Vn,aiConnection:Qn,environmentId:Nr})}return zt.testEnvironment(f,oe,{adapterConfig:ga,agentId:Vn,aiConnection:Qn,environmentId:Nr})},"mutationFn")}),[Nt,ts]=(0,u.useState)(!1),[ls,Tt]=(0,u.useState)(null),ys="Test",ds=!a&&!!e.isSaving,Ys=Nt||ds||!f,dn=(0,u.useRef)(Gt.reset);dn.current=Gt.reset;const $n=(0,u.useRef)(()=>{});$n.current=()=>{if(!a||!me)return;const Qe=Xe.envBindings??{},Yt=Xe.claudeStoredSessionId!=null||Xe.claudeApplyStoredLogin===!0,an=$Y in Qe;if(!Yt&&!an)return;const Fs={...Qe};delete Fs[$Y],me({envBindings:Fs,claudeStoredSessionId:null,claudeApplyStoredLogin:!1})},(0,u.useEffect)(()=>{dn.current(),Tt(null),$n.current()},[oe,Ne]);const kn=_e.login!=null,Bs=Gt.data,ks=Bs!=null&&je(Bs.adapterType).login!=null,or=Bs&&ks?Bs.checks.find(Qe=>Qe.code==="adapter_auth_missing")??null:null,Is=typeof Je?.config?.provider=="string"?Je.config.provider:null,Lr=Is!=null&&ft?.sandboxProviders?.[Is]?.supportsLoginPty===!0,jn=_e.login!=null,Yn=(a||!(D.runtime.runtimeConfig?.aiConnection??ue.aiConnection))&&kn&&Je?.driver==="sandbox"&&!!Ne&&!!f&&!!or&&(!jn||Lr),lr=(0,u.useCallback)(async()=>{if(!f)throw new Error("Select an organization to test adapter environment");ts(!0),Tt(null),Gt.reset();try{return await Gt.mutateAsync()}catch(Qe){throw Tt(Qe instanceof Error?Qe.message:"Environment test failed"),Qe}finally{ts(!1)}},[f,Gt]),Cn=(0,u.useRef)(()=>{});(0,u.useEffect)(()=>{Cn.current=()=>{Ys||lr().catch(()=>{})}},[lr,Ys]);const vr=(0,u.useCallback)(()=>{Cn.current()},[]);(0,u.useEffect)(()=>{if(!(!l||!e.onTestActionChange))return e.onTestActionChange(vr),()=>{e.onTestActionChange?.(null)}},[l,e.onTestActionChange,vr]),(0,u.useEffect)(()=>{if(!(!l||!e.onTestActionStateChange))return e.onTestActionStateChange({disabled:Ys,pending:Nt}),()=>{e.onTestActionStateChange?.({disabled:!0,pending:!1})}},[l,e.onTestActionStateChange,Ys,Nt]),(0,u.useEffect)(()=>{if(e.onTestFeedbackChange)return e.onTestFeedbackChange({errorMessage:ls??(Gt.error instanceof Error?Gt.error.message:Gt.error?"Environment test failed":null),result:Gt.data??null,login:Yn&&f&&Ne?{companyId:f,adapterType:oe,environmentId:Ne}:null}),()=>{e.onTestFeedbackChange?.({errorMessage:null,result:null,login:null})}},[e.onTestFeedbackChange,ls,Gt.data,Gt.error,Yn,f,oe,Ne]);const zr=a?Xe.model??"":Z("adapterConfig","model",String(ie.model??"")),Qr=typeof zr=="string"?zr:"";async function rr(){if(f){qe(!0),At(null);try{const Qe=await zt.adapterModels(f,oe,{refresh:!0,environmentId:tt||null,provider:dt});g.setQueryData(Be,Qe)}catch(Qe){At(Qe instanceof Error?Qe.message:"Failed to refresh adapter models.")}finally{qe(!1)}}}r(rr,"handleRefreshModels");const gr=oe==="codex_local"?"modelReasoningEffort":oe==="cursor"?"mode":oe==="opencode_local"?"variant":oe==="grok_local"?"reasoningEffort":oe==="pi_local"?"thinking":"effort",cr=oe==="codex_local"?tC(Qr,"Auto").map(Qe=>({id:Qe.value,label:Qe.label})):oe==="cursor"?RQe:oe==="opencode_local"?AQe:oe==="kimi_local"?EQe:oe==="pi_local"?[{id:"",label:"Auto"},...["off","minimal","low","medium","high","xhigh"].map(Qe=>({id:Qe,label:Qe}))]:oe==="claude_local"||oe==="grok_local"?[{id:"",label:"Auto"},...kT(oe,Qr).map(Qe=>({id:Qe,label:Qe==="xhigh"?"X-High":Qe[0].toUpperCase()+Qe.slice(1)}))]:TQe,Gr=a?Xe.thinkingEffort:oe==="codex_local"?Z("adapterConfig","modelReasoningEffort",String(ie.modelReasoningEffort??ie.reasoningEffort??"")):oe==="cursor"?Z("adapterConfig","mode",String(ie.mode??"")):oe==="opencode_local"?Z("adapterConfig","variant",String(ie.variant??"")):Z("adapterConfig",gr,String(ie[gr]??"")),Dn=oe!=="gemini_local"&&oe!=="cursor_cloud"&&oe!=="paperclip_runner",Rr=oe==="codex_local"?a?!!Xe.search:Z("adapterConfig","search",!!ie.search):!1,la=(0,u.useMemo)(()=>{if(a)return{heartbeat:{enabled:Xe.heartbeatEnabled,intervalSec:Xe.intervalSec}};const Qe={...ue.heartbeat&&typeof ue.heartbeat=="object"?ue.heartbeat:{},...D.heartbeat};return{...ue,heartbeat:Qe}},[a,D.heartbeat,ue,Xe]),_n=MW(la.heartbeat),_s=MW(_n.maxTurnContinuation),ta=TIe(_s.enabled,!0),Xn=_2(qW(_s.maxAttempts,PQe),0,QY),gt=_2(qW(_s.delayMs,MQe*1e3)/1e3,0,oxe);function $s(Qe){Y("heartbeat","maxTurnContinuation",{..._s,...Qe})}r($s,"updateMaxTurnContinuation");const qs=(0,t.jsx)(Yb,{ref:v,onDirtyChange:J,hideDraftActions:!a&&e.hideInlineSave,value:a?Xe.envBindings??GN:Z("adapterConfig","env",ie.env??GN),secrets:w,userSecretDefinitions:S,onCreateSecret:r(async(Qe,Yt)=>await K.mutateAsync({name:Qe,value:Yt}),"onCreateSecret"),onChange:r(Qe=>a?me({envBindings:Qe??{},envVars:""}):Y("adapterConfig","env",Qe),"onChange")},X);return!a&&e.content==="secrets"?(0,t.jsxs)("div",{className:z("relative",i&&"space-y-6"),children:[de&&!e.hideInlineSave&&(0,t.jsx)("div",{className:"sticky top-0 z-10 flex items-center justify-end border-b border-primary/20 bg-background/90 px-4 py-2 backdrop-blur-sm",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}),(0,t.jsx)(F,{size:"sm",onClick:ae,disabled:e.isSaving,children:e.isSaving?"Saving...":"Save"})]})}),e.environmentVariablesPlacement==="secrets"&&(0,t.jsxs)("div",{"data-config-section":"environment-variables",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"mb-3 text-sm font-medium",children:"Environment variables"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment variables"}),(0,t.jsx)("div",{className:z(i?"rounded-lg border border-border p-4":"px-4 pb-3"),children:qs})]}),(0,t.jsxs)("div",{"data-config-section":"secrets",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"mb-3 text-sm font-medium",children:"Secret access"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Secret access"}),(0,t.jsxs)("div",{className:z(i?"space-y-3 rounded-lg border border-border p-4":"space-y-3 px-4 pb-3"),children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:bi.secretAccess}),(0,t.jsx)(pQe,{config:{...ie,...D.adapterConfig},secrets:w,onChange:fe,onCreateSecret:r((Qe,Yt)=>K.mutateAsync({name:Qe,value:Yt}),"onCreateSecret"),proposals:_,onApproveProposal:A.requestApprove,onRejectProposal:A.requestReject}),A.dialogs]})]})]}):(0,t.jsxs)(LQe,{order:e.sectionOrder,className:z("relative",i&&"space-y-6"),children:[de&&!e.hideInlineSave&&(0,t.jsx)("div",{className:"sticky top-0 z-10 flex items-center justify-end px-4 py-2 bg-background/90 backdrop-blur-sm border-b border-primary/20",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}),(0,t.jsx)(F,{size:"sm",onClick:ae,disabled:!a&&e.isSaving,children:!a&&e.isSaving?"Saving...":"Save"})]})}),!a&&(0,t.jsxs)("div",{"data-config-section":"identity",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:e.sectionTitles?.identity??"Identity"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Identity"}),(0,t.jsxs)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[(0,t.jsx)(ws,{label:"Name",hint:bi.name,children:(0,t.jsx)(Oa,{value:Z("identity","name",e.agent.name),onCommit:r(Qe=>Y("identity","name",Qe),"onCommit"),immediate:!0,className:bm,placeholder:"Agent name"})}),(0,t.jsx)(ws,{label:"Title",hint:bi.title,children:(0,t.jsx)(Oa,{value:Z("identity","title",e.agent.title??""),onCommit:r(Qe=>Y("identity","title",Qe||null),"onCommit"),immediate:!0,className:bm,placeholder:"e.g. VP of Engineering"})}),(0,t.jsx)(ws,{label:"Reports to",hint:bi.reportsTo,children:(0,t.jsx)(CHe,{agents:we,value:Z("identity","reportsTo",e.agent.reportsTo??null),onChange:r(Qe=>Y("identity","reportsTo",Qe),"onChange"),excludeAgentIds:[e.agent.id],chooseLabel:"Choose manager…"})}),xe&&!e.hidePromptTemplate&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ws,{label:"Prompt Template",hint:bi.promptTemplate,children:(0,t.jsx)(wc,{value:Z("adapterConfig","promptTemplate",String(ie.promptTemplate??"")),onChange:r(Qe=>Y("adapterConfig","promptTemplate",Qe??""),"onChange"),placeholder:"You are agent {{ agent.name }}. Your role is {{ agent.role }}...",contentClassName:"min-h-(--sz-88px) text-sm font-mono",imageUploadHandler:r(async Qe=>{const Yt=`agents/${e.agent.id}/prompt-template`;return(await U.mutateAsync({file:Qe,namespace:Yt})).contentPath},"imageUploadHandler")})}),(0,t.jsx)("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-900 dark:text-amber-100",children:"Prompt template is replayed on every heartbeat. Keep it compact and dynamic to avoid recurring token cost and cache churn."})]})]})]}),q?(0,t.jsxs)("div",{"data-config-section":"environment",className:z(!i&&(a?"border-t border-border":"border-b border-border")),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Environment"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment"}),(0,t.jsx)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(ws,{label:"Default environment",hint:"This instance runs all agents in the Kubernetes sandbox. Local execution is disabled.",children:B?(0,t.jsxs)("div",{className:z(bm,"flex items-center text-muted-foreground"),children:[B.name," · Kubernetes sandbox"]}):(0,t.jsx)("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200",children:"This instance requires the Kubernetes sandbox, but no managed Kubernetes environment is available for this organization yet. Configure one before creating agents; execution will not fall back to local."})})})]}):bs?(0,t.jsxs)("div",{"data-config-section":"environment",className:z(!i&&(a?"border-t border-border":"border-b border-border")),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Environment"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment"}),(0,t.jsx)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(ws,{label:"Environment override",children:(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsxs)("select",{className:bm,value:tt,onChange:r(Qe=>{const Yt=Qe.target.value;if(a){me({defaultEnvironmentId:Yt});return}Y("identity","defaultEnvironmentId",Yt||null)},"onChange"),children:[(0,t.jsxs)("option",{value:"",children:["Default: ",Ke]}),es.map(Qe=>(0,t.jsx)("option",{value:Qe.id,children:mw(Qe)},Qe.id))]})})})})]}):null,(0,t.jsxs)("div",{"data-config-section":"adapter",className:z(!i&&(a?"border-t border-border":"border-b border-border")),children:[(0,t.jsxs)("div",{className:z(i?"flex items-center justify-between mb-3":"px-4 py-2 flex items-center justify-between gap-2"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium",children:e.sectionTitles?.adapter??"Adapter"}):(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Adapter"}),c&&(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:vr,disabled:Ys,children:Nt?`${ys}...`:ys})]}),(0,t.jsxs)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[o&&(0,t.jsx)(ws,{label:"Adapter type",hint:bi.adapterType,children:(0,t.jsx)(dxe,{value:oe,disabledTypes:I,onChange:r(Qe=>{if(a){const{adapterType:Yt,...an}=Zg,Fs={...an,adapterType:Qe};Qe==="codex_local"?Fs.dangerouslyBypassSandbox=!0:Qe==="gemini_local"?Fs.model="auto":Qe==="kimi_local"?Fs.model="kimi-code/kimi-for-coding":Qe==="cursor"?Fs.model="auto":Qe==="opencode_local"?Fs.model="openai/gpt-5.2-codex":Qe==="paperclip_runner"&&(Fs.model=rw),me(Fs)}else V(Yt=>({...Yt,adapterType:Qe,adapterConfig:{model:Qe==="gemini_local"?"auto":Qe==="kimi_local"?"kimi-code/kimi-for-coding":Qe==="opencode_local"?"openai/gpt-5.2-codex":Qe==="cursor"?"auto":Qe==="paperclip_runner"?SQe(oe,ie.model):"",effort:"",modelReasoningEffort:"",variant:"",mode:"",...Qe==="codex_local"?{dangerouslyBypassApprovalsAndSandbox:!0}:Qe==="paperclip_runner"?{...Fme(oe,Z("adapterConfig","model",ie.model))}:{}}}))},"onChange")})}),!a&&f&&(0,t.jsx)(nfe,{companyId:f,agentId:e.agent.id,agentName:e.agent.name,adapterType:oe==="paperclip_runner"?Z("adapterConfig","provider",ie.provider)==="codex"?"codex_local":Z("adapterConfig","provider",ie.provider)==="opencode"?"opencode_local":Z("adapterConfig","provider",ie.provider)==="acpx"&&Z("adapterConfig","acpxAgent",ie.acpxAgent)==="claude"?"claude_local":oe:oe,value:t2.safeParse(D.runtime.runtimeConfig?.aiConnection??ue.aiConnection).data,model:String(Z("adapterConfig","model",ie.model)??""),environmentId:tt||void 0,legacy:!0,onChange:r(Qe=>Y("runtime","runtimeConfig",{...ue,aiConnection:Qe}),"onChange")}),d&&!e.compactTestFeedback&&(ls||Gt.error)&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:ls??(Gt.error instanceof Error?Gt.error.message:"Environment test failed")}),d&&!e.compactTestFeedback&&Gt.data&&(0,t.jsx)(UQe,{result:Gt.data}),d&&Yn&&(0,t.jsx)(oK,{companyId:f,adapterType:oe,environmentId:Ne,onStored:a?mt:We,onApplyStored:a?st:pt,onAccountBinding:a?void 0:ze},`${oe}:${Ne}`),Ae&&(0,t.jsx)(ws,{label:"Working directory (deprecated)",hint:bi.cwd,children:(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border px-2.5 py-1.5",children:[(0,t.jsx)(Io,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)(Oa,{value:a?Xe.cwd:Z("adapterConfig","cwd",String(ie.cwd??"")),onCommit:r(Qe=>a?me({cwd:Qe}):Y("adapterConfig","cwd",Qe||void 0),"onCommit"),immediate:!0,className:"w-full bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40",placeholder:"/path/to/project"}),(0,t.jsx)(hd,{})]})}),Vt("adapter"),xe&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(lK,{models:ut,value:Qr,onChange:r(Qe=>{const Yt=kT(oe,Qe),an=["codex_local","claude_local","grok_local"].includes(oe)&&!!Gr&&!Yt.includes(String(Gr));if(a){me({model:Qe,...an?{thinkingEffort:""}:{}});return}Y("adapterConfig","model",Qe||void 0),an&&(Y("adapterConfig",gr,void 0),Y("adapterConfig","reasoningEffort",void 0))},"onChange"),open:Wt,onOpenChange:Me,defaultLabel:oe==="claude_local"?"Default (claude-opus-5)":void 0,allowDefault:oe!=="opencode_local"&&oe!=="pi_local"&&oe!=="paperclip_runner",required:oe==="opencode_local"||oe==="pi_local",groupByProvider:oe==="opencode_local"||oe==="pi_local",creatable:!0,detectedModel:jt,detectedModelCandidates:[],onDetectModel:oe==="opencode_local"||oe==="paperclip_runner"?void 0:async()=>(await Ts()).data?.model??null,onRefreshModels:kQe(oe)?rr:void 0,refreshingModels:Ls,detectModelLabel:"Detect model",emptyDetectHint:"No model detected. Select or enter one manually."}),(Ut||Fe)&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:Ut??(Fe instanceof Error?Fe.message:"Failed to load adapter models.")}),oe==="opencode_local"&&ht&&ht.driver!=="local"&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Live OpenCode model discovery only runs for Local environments. Using the curated list and manual entry for ",ht.name,"."]}),Dn&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(KQe,{value:Gr,options:cr,onChange:r(Qe=>a?me({thinkingEffort:Qe}):Y("adapterConfig",gr,Qe||void 0),"onChange"),open:Ee,onOpenChange:He}),oe==="codex_local"&&Rr&&Gr==="minimal"&&(0,t.jsx)("p",{className:"text-xs text-amber-400",children:"Codex may reject `minimal` thinking when search is enabled."})]})]})]})]}),(0,t.jsxs)("div",{"data-config-section":"configuration",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Configuration"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Configuration"}),(0,t.jsxs)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[!a&&typeof ie.bootstrapPromptTemplate=="string"&&ie.bootstrapPromptTemplate&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ws,{label:"Bootstrap prompt (legacy)",hint:bi.bootstrapPrompt,children:(0,t.jsx)(wc,{value:Z("adapterConfig","bootstrapPromptTemplate",String(ie.bootstrapPromptTemplate??"")),onChange:r(Qe=>Y("adapterConfig","bootstrapPromptTemplate",Qe||void 0),"onChange"),placeholder:"Optional initial setup prompt for the first run",contentClassName:"min-h-(--sz-44px) text-sm font-mono",imageUploadHandler:r(async Qe=>{const Yt=`agents/${e.agent.id}/bootstrap-prompt`;return(await U.mutateAsync({file:Qe,namespace:Yt})).contentPath},"imageUploadHandler")})}),(0,t.jsx)("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200",children:"Bootstrap prompt is legacy and will be removed in a future release. Consider moving this content into the agent's prompt template or instructions file instead."})]}),Vt("configuration"),(xe||oe==="process"||bt?.fields.some(Qe=>pF(Qe.key)==="advanced"))&&(0,t.jsx)(y2,{title:"Advanced",open:kt,onToggle:r(()=>hs(!kt),"onToggle"),children:(0,t.jsxs)("div",{className:"space-y-3",children:[xe&&(0,t.jsxs)(t.Fragment,{children:[" ",!L&&(0,t.jsx)(ws,{label:"Command",hint:bi.localCommand,children:(0,t.jsx)(Oa,{value:a?Xe.command:Z("adapterConfig",Dt,String(ie.command??"")),onCommit:r(Qe=>a?me({command:Qe}):Y("adapterConfig",Dt,Qe||null),"onCommit"),immediate:!0,className:bm,placeholder:{claude_local:"claude",codex_local:"codex",gemini_local:"gemini",kimi_local:"kimi",pi_local:"pi",cursor:"agent",opencode_local:"opencode"}[oe]??oe.replace(/_local$/,"")})}),(0,t.jsx)(ws,{label:"Extra args (comma-separated)",hint:bi.extraArgs,children:(0,t.jsx)(Oa,{value:a?Xe.extraArgs:Z("adapterConfig","extraArgs",IQe(ie.extraArgs)),onCommit:r(Qe=>a?me({extraArgs:Qe}):Y("adapterConfig","extraArgs",Qe?.trim()?_Qe(Qe):null),"onCommit"),className:bm,placeholder:"e.g. --verbose, --foo=bar"})})]}),Vt("advanced")]})})]})]}),e.environmentVariablesPlacement!=="secrets"&&(xe||bt?.fields.some(Qe=>pF(Qe.key)==="environment"))&&(0,t.jsxs)("div",{"data-config-section":"environment-variables",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Environment variables"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment variables"}),(0,t.jsx)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:xe?qs:Vt("environment")})]}),a&&m?(0,t.jsxs)("div",{"data-config-section":"run-policy",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsxs)("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[(0,t.jsx)(H_,{className:"h-3 w-3"})," Run Policy"]}):(0,t.jsxs)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)(H_,{className:"h-3 w-3"})," Run Policy"]}),(0,t.jsxs)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[(0,t.jsx)(dY,{label:"Heartbeat on interval",hint:bi.heartbeatInterval,checked:Xe.heartbeatEnabled,onCheckedChange:r(Qe=>me({heartbeatEnabled:Qe}),"onCheckedChange"),number:Xe.intervalSec,onNumberChange:r(Qe=>me({intervalSec:Qe}),"onNumberChange"),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:bi.intervalSec,showNumber:Xe.heartbeatEnabled}),(0,t.jsx)(y2,{title:"Advanced Run Policy",open:at,onToggle:r(()=>Mt(!at),"onToggle"),children:(0,t.jsx)("div",{className:"space-y-3",children:Vt("runPolicy")})})]})]}):a?null:(0,t.jsxs)("div",{"data-config-section":"run-policy",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsxs)("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[(0,t.jsx)(H_,{className:"h-3 w-3"})," Run Policy"]}):(0,t.jsxs)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)(H_,{className:"h-3 w-3"})," Run Policy"]}),(0,t.jsxs)("div",{className:z(i?"border border-border rounded-lg overflow-hidden":""),children:[(0,t.jsx)("div",{className:z(i?"p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(dY,{label:"Heartbeat on interval",hint:bi.heartbeatInterval,checked:Z("heartbeat","enabled",pe.enabled===!0),onCheckedChange:r(Qe=>Y("heartbeat","enabled",Qe),"onCheckedChange"),number:Z("heartbeat","intervalSec",Number(pe.intervalSec??300)),onNumberChange:r(Qe=>Y("heartbeat","intervalSec",Qe),"onNumberChange"),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:bi.intervalSec,showNumber:Z("heartbeat","enabled",pe.enabled===!0)})}),(0,t.jsx)(y2,{title:"Advanced Run Policy",bordered:i,open:at,onToggle:r(()=>Mt(!at),"onToggle"),children:(0,t.jsxs)("div",{className:"space-y-3",children:[Vt("runPolicy"),xe&&(0,t.jsx)(t.Fragment,{children:!a&&(0,t.jsxs)(t.Fragment,{children:[!bt?.fields.some(Qe=>Qe.key==="timeoutSec")&&(0,t.jsx)(ws,{label:"Timeout (sec)",hint:bi.timeoutSec,children:(0,t.jsx)(nc,{value:Z("adapterConfig","timeoutSec",Number(ie.timeoutSec??0)),onCommit:r(Qe=>Y("adapterConfig","timeoutSec",Qe),"onCommit"),immediate:!0,className:bm})}),!bt?.fields.some(Qe=>Qe.key==="graceSec")&&(0,t.jsx)(ws,{label:"Interrupt grace period (sec)",hint:bi.graceSec,children:(0,t.jsx)(nc,{value:Z("adapterConfig","graceSec",Number(ie.graceSec??15)),onCommit:r(Qe=>Y("adapterConfig","graceSec",Qe),"onCommit"),immediate:!0,className:bm})})]})}),(0,t.jsx)(id,{label:"Wake on demand",hint:bi.wakeOnDemand,checked:Z("heartbeat","wakeOnDemand",pe.wakeOnDemand!==!1),onChange:r(Qe=>Y("heartbeat","wakeOnDemand",Qe),"onChange")}),(0,t.jsx)(ws,{label:"Cooldown (sec)",hint:bi.cooldownSec,children:(0,t.jsx)(nc,{value:Z("heartbeat","cooldownSec",Number(pe.cooldownSec??10)),onCommit:r(Qe=>Y("heartbeat","cooldownSec",Qe),"onCommit"),immediate:!0,className:bm})}),(0,t.jsx)(ws,{label:"Max concurrent runs",hint:bi.maxConcurrentRuns,children:(0,t.jsx)(nc,{value:Z("heartbeat","maxConcurrentRuns",Number(pe.maxConcurrentRuns??20)),onCommit:r(Qe=>Y("heartbeat","maxConcurrentRuns",Qe),"onCommit"),immediate:!0,className:bm})}),(0,t.jsxs)("div",{className:"rounded-md border border-border/70 px-3 py-2",children:[(0,t.jsx)(id,{label:"Continue after max-turn stop",hint:bi.maxTurnContinuationEnabled,checked:ta,onChange:r(Qe=>$s({enabled:Qe}),"onChange")}),ta?(0,t.jsxs)("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[(0,t.jsx)(ws,{label:"Continuation attempts",hint:bi.maxTurnContinuationMaxAttempts,children:(0,t.jsx)(nc,{value:Xn,onCommit:r(Qe=>$s({maxAttempts:_2(Qe,0,QY)}),"onCommit"),immediate:!0,className:bm})}),(0,t.jsx)(ws,{label:"Continuation delay (sec)",hint:bi.maxTurnContinuationDelaySec,children:(0,t.jsx)(nc,{value:gt,onCommit:r(Qe=>$s({delayMs:DQe(Qe)}),"onCommit"),immediate:!0,className:bm})})]}):null]})]})})]})]}),!a&&p?(0,t.jsxs)("div",{className:z(!i&&"border-b border-border"),children:[i?(0,t.jsxs)("h3",{className:"mb-3 flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)(vj,{className:"h-3 w-3"})," Debugging"]}):(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 text-xs font-medium text-muted-foreground",children:[(0,t.jsx)(vj,{className:"h-3 w-3"})," Debugging"]}),(0,t.jsxs)("div",{className:z("border-border bg-accent/30",i?"rounded-lg border p-4":"mx-4 mb-4 rounded-md border px-3 py-3"),children:[(0,t.jsx)(id,{label:"Capture raw provider traces",hint:"Stores exact provider traffic for every future run until disabled. Traces may contain sensitive prompts and tool arguments, are administrator-only, and expire after 24 hours.",checked:Z("debug","providerTrace",be.providerTrace)==="raw",onChange:r(Qe=>Y("debug","providerTrace",Qe?"raw":void 0),"onChange")}),Z("debug","providerTrace",be.providerTrace)==="raw"?(0,t.jsxs)("div",{className:"mt-3 flex items-start gap-2 rounded-md border border-border bg-background/60 px-3 py-2 text-xs text-foreground",children:[(0,t.jsx)(vj,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{children:"Raw tracing is on for future runs. Paperclip keeps at most 64 MiB per run and automatically deletes it after 24 hours."})]}):null]})]}):null,e.compactTestFeedback&&d&&l&&(0,t.jsx)(ofe,{state:Nt?"running":ls||Gt.error?"fail":Bs?.status??"idle",result:Bs??null,error:ls??(Gt.error instanceof Error?Gt.error.message:null),onTest:vr,disabled:Ys})]})}r(lxe,"AgentConfigForm");var TF=new Set(["authenticated","failed","timed_out","cancelled"]),EF=2e3;function PF({value:e,label:s}){const[n,a]=(0,u.useState)(!1),i=(0,u.useRef)(null);return(0,u.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]),(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,className:"text-muted-foreground hover:text-foreground",onClick:r(async()=>{try{await Hr(e),a(!0)}catch{a(!1)}i.current&&clearTimeout(i.current),i.current=setTimeout(()=>a(!1),1500)},"onClick"),children:n?(0,t.jsx)(fs,{className:"size-3"}):(0,t.jsx)(jr,{className:"size-3"})})}r(PF,"AdapterLoginCopyButton");function $Qe({status:e,message:s}){return e==="authenticated"?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(fs,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Authenticated. The environment has credentials now."})]}):(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(Rs,{className:"size-3 shrink-0"}),(0,t.jsxs)("span",{children:[e==="timed_out"?"Login timed out":e==="cancelled"?"Login cancelled":"Login failed",s?`: ${s}`:"."]})]})}r($Qe,"AdapterLoginTerminalState");var OQe={claude_local:"Anthropic",codex_local:"OpenAI"};function cxe(e){const s=OQe[e];return s?`Sign in to ${s}`:"Sign in to the environment"}r(cxe,"adapterLoginTitle");function oK(e){return Uw()(e.adapterType).login?.panelMode==="submitted_browser_code"?(0,t.jsx)(zQe,{...e}):(0,t.jsx)(FQe,{...e})}r(oK,"AdapterLoginPanel");function FQe({companyId:e,adapterType:s,environmentId:n,autoStart:a,onConnected:i,onAccountBinding:o,chrome:l="panel",aiConnection:c,onPromptReady:d}){const[m,h]=(0,u.useState)(null),[p,f]=(0,u.useState)(null),[g,v]=(0,u.useState)(null),[y,w]=(0,u.useState)("idle"),S=(0,u.useRef)(!1),j=ke({mutationFn:r(()=>zt.startAdapterAuthLogin(e,s,{environmentId:n,aiConnection:c}),"mutationFn"),onSuccess:r(te=>{S.current=!1,f(null),v(null),w("idle"),h(te.sessionId)},"onSuccess"),onError:r(te=>{f(te instanceof Error?te.message:"Could not start the login.")},"onError")}),N=(0,u.useCallback)(()=>{S.current=!1,h(null),v(null),f(null)},[]),_=ke({mutationFn:r(()=>zt.cancelAdapterAuthLogin(e,s,m),"mutationFn"),onSuccess:N,onError:r(te=>{f(te instanceof Error?te.message:"Could not cancel the login.")},"onError")}),A=ee({queryKey:["adapter-login-active-session",e,s],queryFn:r(async()=>{try{const te=await zt.getActiveAdapterAuthLoginSession(e,s);if(!te)return null;if(c&&te.environmentId!==n||!!te.aiConnection!=!!c||c&&(te.aiConnection?.provider!==c.provider||te.aiConnection?.method!==c.method||te.aiConnection?.connectionId!==c.connectionId||te.aiConnection?.ownership!==c.ownership||te.aiConnection?.allAgents!==c.allAgents||JSON.stringify(te.aiConnection?.agentIds)!==JSON.stringify(c.agentIds)))throw new Error("Another sign-in attempt is active. Finish or cancel it in its original account setup before starting this one.");return te}catch(te){if(te instanceof vn&&te.status===404)return null;throw te}},"queryFn"),retry:!1,gcTime:0,staleTime:0}),[C,I]=(0,u.useState)(!1),T=ee({queryKey:["adapter-login-status",e,s,m],queryFn:r(()=>zt.getAdapterAuthLoginStatus(e,s,m),"queryFn"),enabled:!!m&&!C,retry:r((te,re)=>re instanceof vn&&re.status===404?!1:te<3,"retry"),refetchInterval:r(te=>{const re=te.state.data?.status;return re&&TF.has(re)?!1:EF},"refetchInterval")});(0,u.useEffect)(()=>{const te=T.data?.prompt??null;te&&v(te)},[T.data]);const R=T.data??j.data??null,L=R?.status??null,O=g,$=L?TF.has(L):!1,E=!!m&&!$,q=j.isPending||E||y==="saving",B=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(B.current||!A.isFetched)return;B.current=!0;const te=A.data;te&&(S.current=!0,f(null),v(te.prompt??null),h(te.sessionId))},[A.isFetched,A.data]),(0,u.useEffect)(()=>{const te=T.error;if(!(te instanceof vn&&te.status===404)||!S.current||C)return;I(!0);const re=m;(async()=>(re&&await zt.cancelAdapterAuthLogin(e,s,re).catch(()=>{}),I(!1),N()))()},[T.error,C,m,e,s,N]);const K=(0,u.useRef)(!1),U=(0,u.useRef)(j.mutate);U.current=j.mutate,(0,u.useEffect)(()=>{if(!(!a||K.current)){if(A.isError){K.current=!0,f(A.error instanceof Error?A.error.message:"Could not check for an active login.");return}A.isSuccess&&(K.current=!0,!A.data&&U.current())}},[a,A.isSuccess,A.isError,A.data,A.error]);const D=(0,u.useRef)(!1),V=(0,u.useRef)(i);V.current=i,(0,u.useEffect)(()=>{L!=="authenticated"||D.current||(D.current=!0,V.current?.(m??void 0))},[L]);const H=(0,u.useRef)(null),J=(0,u.useRef)(o);J.current=o;const X=T.data?.codexAccountBinding??null,le=(0,u.useCallback)(async te=>{const re=J.current;if(re){w("saving");try{await re(te),w("bound")}catch{w("failed")}}},[]);(0,u.useEffect)(()=>{L!=="authenticated"||!m||H.current!==m&&(!X||!X.companyIdentityDiffers||!J.current||(H.current=m,le(X)))},[L,m,X,le]);const ce=(0,u.useRef)(d);if(ce.current=d,(0,u.useEffect)(()=>{ce.current?.(O?.url??null)},[O]),l==="onboarding"){const te=$&&L&&L!=="authenticated";return(0,t.jsx)(bfe,{loading:!O&&!p&&!te,providerName:xfe(s),authorizationUrl:O?.url,mode:"displayed_code",children:p?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:p}):te?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:L==="timed_out"?"The login timed out. Start it again.":L==="cancelled"?"The login was cancelled.":"The login did not finish. Start it again."}):(0,t.jsx)($7e,{code:O?.code??"",autoCopy:!0})})}return(0,t.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:cxe(s)}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[E&&(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground hover:text-foreground",disabled:_.isPending,onClick:r(()=>_.mutate(),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",disabled:q,onClick:r(()=>j.mutate(),"onClick"),children:"Sign in"})]})]}),p&&(0,t.jsx)("div",{role:"alert",className:"text-(length:--text-micro) text-destructive",children:p}),(0,t.jsxs)("div",{role:"status","aria-live":"polite",className:"space-y-2 empty:hidden",children:[E&&!O&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(it,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Preparing..."})]}),E&&O&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:"Copy the code, then open the authentication page."}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"1. Code"}),(0,t.jsx)("span",{className:"font-mono text-xs text-foreground break-all",children:O.code})]}),(0,t.jsx)(PF,{value:O.code,label:"Copy code"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"2. Authentication URL"}),(0,t.jsx)("span",{className:"font-mono text-xs text-foreground break-all",children:O.url})]}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(PF,{value:O.url,label:"Copy URL"}),(0,t.jsx)(F,{asChild:!0,type:"button",variant:"ghost",size:"icon-xs","aria-label":"Open the authentication page",title:"Open the authentication page",className:"text-muted-foreground hover:text-foreground",children:(0,t.jsx)("a",{href:O.url,target:"_blank",rel:"noreferrer noopener",children:(0,t.jsx)(xr,{className:"size-3"})})})]})]})]}),$&&L&&(0,t.jsx)($Qe,{status:L,message:R?.failure?.message??null}),L==="authenticated"&&y==="saving"&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(it,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Binding this agent to the signed-in account..."})]}),L==="authenticated"&&y==="bound"&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(fs,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Agent bound to the signed-in account."})]}),L==="authenticated"&&y==="failed"&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro)",children:[(0,t.jsx)(Rs,{className:"size-3 shrink-0 text-destructive"}),(0,t.jsx)("span",{className:"text-destructive",children:"Could not bind this agent to the signed-in account."}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-6 px-2 text-xs",onClick:r(()=>{X&&le(X)},"onClick"),children:"Retry"})]})]})]})}r(FQe,"DisplayedCodeLoginPanel");var BQe=new Set(["failed","timed_out","cancelled"]),GY="The login did not finish. Start the login again.",qQe=9e5,YY="The login timed out. Start the login again.";function zQe({companyId:e,adapterType:s,environmentId:n,onStored:a,onApplyStored:i,autoStart:o,onConnected:l,onCodeSubmitted:c,onSubmitFailed:d,chrome:m="panel",aiConnection:h,onPromptReady:p}){const[f,g]=(0,u.useState)(null),[v,y]=(0,u.useState)(null),[w,S]=(0,u.useState)(null),[j,N]=(0,u.useState)(!1),[_,A]=(0,u.useState)(""),[C,I]=(0,u.useState)(null),[T,R]=(0,u.useState)(!1),[L,O]=(0,u.useState)(!1),[$,E]=(0,u.useState)(!1),[q,B]=(0,u.useState)(!1),K=(0,u.useRef)(!1),[U,D]=(0,u.useState)(!1),V=(0,u.useRef)(!1),H=r(()=>{y(null),S(null),N(!1),A(""),I(null),R(!1),O(!1),B(!1),E(!1),K.current=!1},"resetLocalState"),J=ee({queryKey:["claude-oauth-token-status",e],queryFn:r(async()=>{try{return await zt.getClaudeOAuthTokenStatus(e)}catch(et){if(et instanceof vn&&et.status===404)return null;throw et}},"queryFn"),retry:r((et,Ie)=>Ie instanceof vn&&Ie.status===404?!1:et<2,"retry")}).data??null,X=ke({mutationFn:r(()=>zt.startClaudeSetupTokenLogin(e,{environmentId:n,aiConnection:h,...J&&!h?{overwrite:{expectedSecretId:J.secretId,expectedLatestVersion:J.latestVersion}}:{}}),"mutationFn"),onSuccess:r(et=>{V.current=!1,H(),g(et.sessionId)},"onSuccess"),onError:r(et=>{y(et instanceof Error?et.message:"Could not start the login.")},"onError")}),le=r(()=>{V.current=!1,g(null),H()},"clearActiveSession"),ce=ke({mutationFn:r(()=>zt.cancelClaudeSetupTokenLogin(e,f),"mutationFn"),onSuccess:r(()=>{le()},"onSuccess"),onError:r(et=>{if(et instanceof vn&&et.status===404){le();return}y(et instanceof Error?et.message:"Could not cancel the login.")},"onError")}),te=(0,u.useCallback)(et=>{zt.cancelClaudeSetupTokenLogin(e,et).catch(()=>{})},[e]),re=ee({queryKey:["claude-setup-token-active-session",e],queryFn:r(async()=>{try{const et=await zt.getActiveClaudeSetupTokenLoginSession(e);if(!et)return null;if(h&&et.environmentId!==n||!!et.aiConnection!=!!h||h&&(et.aiConnection?.provider!==h.provider||et.aiConnection?.method!==h.method||et.aiConnection?.connectionId!==h.connectionId||et.aiConnection?.ownership!==h.ownership||et.aiConnection?.allAgents!==h.allAgents||JSON.stringify(et.aiConnection?.agentIds)!==JSON.stringify(h.agentIds)))throw new Error("Another sign-in attempt is active. Finish or cancel it in its original account setup before starting this one.");return et}catch(et){if(et instanceof vn&&et.status===404)return null;throw et}},"queryFn"),retry:!1,gcTime:0,staleTime:0}),[de,Z]=(0,u.useState)(!1),Y=!!f&&!L&&!q&&!de,G=ee({queryKey:["claude-setup-token-status",e,f],queryFn:r(()=>zt.getClaudeSetupTokenLoginStatus(e,f),"queryFn"),enabled:Y,retry:r((et,Ie)=>Ie instanceof vn&&Ie.status===404?!1:et<3,"retry"),refetchInterval:r(et=>{if(L||q)return!1;const Ie=et.state.data?.status;return Ie&&TF.has(Ie)?!1:EF},"refetchInterval")});(0,u.useEffect)(()=>{const et=G.error;if(et instanceof vn&&et.status===404){if(V.current){if(de)return;Z(!0);const Ie=f;(async()=>(Ie&&await zt.cancelClaudeSetupTokenLogin(e,Ie).catch(()=>{}),Z(!1),le()))();return}B(!0)}},[G.error,de,f,e]);const fe=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(fe.current||!re.isFetched)return;fe.current=!0;const et=re.data;et&&(V.current=!0,H(),g(et.sessionId),et.prompt&&(S(et.prompt.authorizationUrl),et.prompt.transportAdvisory&&N(!0)))},[re.isFetched,re.data]);const se=ee({queryKey:["claude-setup-token-prompt",e,f],enabled:Y&&!w,queryFn:r(async()=>{try{return await zt.getClaudeSetupTokenLoginPrompt(e,f)}catch(et){if(et instanceof vn&&et.status===404)return null;throw et}},"queryFn"),refetchInterval:r(et=>L||et.state.data?.authorizationUrl?!1:EF,"refetchInterval")});(0,u.useEffect)(()=>{const et=se.data?.authorizationUrl??null;et&&S(et),se.data?.transportAdvisory&&N(!0)},[se.data]);const ae=ke({mutationFn:r(et=>zt.submitClaudeSetupTokenBrowserCode(e,f,et),"mutationFn"),onError:r(et=>{y(et instanceof Error?et.message:"Could not submit the browser code.")},"onError")}),ie=ke({mutationFn:r(()=>zt.completeClaudeSetupTokenLogin(e,f),"mutationFn"),onSuccess:r(et=>{I(et.storedSessionId),a?.(et.storedSessionId)},"onSuccess"),onError:r(()=>{R(!0)},"onError")}),ue=G.data?.status??X.data?.status??null,pe=G.data?.expiresAt??X.data?.expiresAt??null,be=(0,u.useRef)(ie.mutate);be.current=ie.mutate,(0,u.useEffect)(()=>{ue==="authenticated"&&!K.current&&(K.current=!0,be.current())},[ue]);const oe=C!==null,je=T||q||!!(ue&&BQe.has(ue)),_e=ue==="authenticated"&&!oe&&!T,xe=!!f&&!oe&&!je&&!L,Ae=X.isPending||xe;(0,u.useEffect)(()=>{if(!xe)return;const et=pe!==null?new Date(pe).getTime():NaN,Ie=Number.isFinite(et)?Math.max(0,et-Date.now()):qQe,Ne=setTimeout(()=>{f&&te(f),O(!0)},Ie);return()=>clearTimeout(Ne)},[xe,pe,f,te]);const Ye=_.trim(),Oe=xe&&!!w&&!_e&&jIe(Ye)&&!ae.isPending&&!$,Xe=(0,u.useRef)(c);Xe.current=c;const me=(0,u.useRef)(d);me.current=d;const Le=r(()=>{Oe&&(y(null),ae.mutate(Ye),E(!0),Xe.current?.(),m!=="onboarding"&&A(""))},"handleSubmit"),mt=(0,u.useRef)(!1),We=(0,u.useRef)(X.mutate);We.current=X.mutate,(0,u.useEffect)(()=>{if(!(!o||mt.current)){if(re.isError){mt.current=!0,y(re.error instanceof Error?re.error.message:"Could not check for an active login.");return}re.isSuccess&&(mt.current=!0,!re.data&&We.current())}},[o,re.isSuccess,re.isError,re.data,re.error]);const ze=(0,u.useRef)(Le);ze.current=Le;const st=m==="onboarding",pt=(0,u.useRef)(!1);(0,u.useEffect)(()=>{!st||!pt.current||(pt.current=!1,Oe&&ze.current())},[st,Oe,_]);const Pt=(0,u.useRef)(!1),tt=(0,u.useRef)(l);tt.current=l,(0,u.useEffect)(()=>{!oe||Pt.current||(Pt.current=!0,tt.current?.(f??void 0))},[oe]),(0,u.useEffect)(()=>{$&&(!v&&!je&&!L||(E(!1),me.current?.()))},[$,v,je,L]);const ht=(0,u.useRef)(p);if(ht.current=p,(0,u.useEffect)(()=>{ht.current?.(w)},[w]),m==="onboarding"){const et=je||L;return(0,t.jsxs)(bfe,{loading:!w&&!v&&!et,providerName:xfe(s),authorizationUrl:w??void 0,mode:"submitted_code",children:[j&&(0,t.jsxs)("p",{className:"flex items-start gap-2 pl-2 text-xs text-amber-700 dark:text-amber-200",children:[(0,t.jsx)(Rs,{className:"mt-0.5 size-3 shrink-0"}),"This connection is not encrypted. The login code travels in clear text on this network. Continue only on a network you trust."]}),v?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:v}):et?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:L&&!je?YY:GY}):(0,t.jsx)(G5,{value:_,onChange:A,onSubmit:Le,onPaste:r(()=>{pt.current=!0},"onPaste"),masked:!0,disabled:ae.isPending||_e||$})]})}return(0,t.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:cxe(s)}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[xe&&(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground hover:text-foreground",disabled:ce.isPending,onClick:r(()=>ce.mutate(),"onClick"),children:"Cancel"}),i&&J&&!xe&&!oe&&!U&&(0,t.jsx)(F,{type:"button",variant:"default",size:"sm",className:"h-7 px-2.5 text-xs",onClick:r(()=>{i(),D(!0)},"onClick"),children:"Use saved login"}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",disabled:Ae,onClick:r(()=>X.mutate(),"onClick"),children:J&&!xe&&!oe?"Sign in to replace":"Sign in"})]})]}),J&&!xe&&!oe&&!U&&(0,t.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:"You have a saved Claude login. Use it to bind this agent, or log in again to replace the stored token."}),U&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(fs,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"The saved Claude login is bound to this agent now."})]}),v&&(0,t.jsx)("div",{role:"alert",className:"text-(length:--text-micro) text-destructive",children:v}),(0,t.jsxs)("div",{role:"status","aria-live":"polite",className:"space-y-2 empty:hidden",children:[xe&&!w&&!_e&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(it,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Preparing..."})]}),xe&&w&&!_e&&(0,t.jsxs)("div",{className:"space-y-2",children:[j&&(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-300 bg-amber-50 px-2 py-1.5 text-(length:--text-micro) text-amber-800 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-200",children:[(0,t.jsx)(Rs,{className:"size-3 shrink-0 mt-0.5"}),(0,t.jsx)("span",{children:"This connection is not encrypted. The login code travels in clear text on this network. Continue only on a network you trust."})]}),(0,t.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:"Open the authorization page, then enter the browser code it shows."}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"1. Authorization URL"}),(0,t.jsx)("span",{className:"font-mono text-xs text-foreground break-all",children:w})]}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(PF,{value:w,label:"Copy URL"}),(0,t.jsx)(F,{asChild:!0,type:"button",variant:"ghost",size:"icon-xs","aria-label":"Open the authorization page",title:"Open the authorization page",className:"text-muted-foreground hover:text-foreground",children:(0,t.jsx)("a",{href:w,target:"_blank",rel:"noreferrer noopener",children:(0,t.jsx)(xr,{className:"size-3"})})})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"2. Browser code"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{"aria-label":"Browser code",type:"text",autoComplete:"off",spellCheck:!1,value:_,onChange:r(et=>A(et.target.value),"onChange"),onKeyDown:r(et=>{et.key==="Enter"&&(et.preventDefault(),Le())},"onKeyDown"),className:"flex-1 min-w-0 rounded-md border border-border bg-background px-2 py-1 font-mono text-xs text-foreground"}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",disabled:!Oe,onClick:Le,children:"Submit"})]})]})]}),_e&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(it,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Completing the login…"})]}),oe&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(fs,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Authenticated. The environment has credentials now."})]}),je&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(Rs,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:GY})]}),L&&!je&&!oe&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(Rs,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:YY})]})]})]})}r(zQe,"SubmittedBrowserCodeLoginPanel");function UQe({result:e}){const s=e.status==="pass"?"Passed":e.status==="warn"?"Warnings":"Failed",n=e.status==="pass"?"text-green-700 dark:text-green-300 border-green-300 dark:border-green-500/40 bg-green-50 dark:bg-green-500/10":e.status==="warn"?"text-amber-700 dark:text-amber-300 border-amber-300 dark:border-amber-500/40 bg-amber-50 dark:bg-amber-500/10":"text-red-700 dark:text-red-300 border-red-300 dark:border-red-500/40 bg-red-50 dark:bg-red-500/10";return(0,t.jsxs)("div",{className:`rounded-md border px-3 py-2 text-xs ${n}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"font-medium",children:s}),(0,t.jsx)("span",{className:"text-(length:--text-micro) opacity-80",children:new Date(e.testedAt).toLocaleTimeString()})]}),(0,t.jsx)("div",{className:"mt-2 space-y-1.5",children:e.checks.map((a,i)=>(0,t.jsxs)("div",{className:"text-(length:--text-micro) leading-relaxed break-words",children:[(0,t.jsx)("span",{className:"font-medium uppercase tracking-wide opacity-80",children:a.level}),(0,t.jsx)("span",{className:"mx-1 opacity-60",children:"·"}),(0,t.jsx)("span",{children:a.message}),a.detail&&(0,t.jsxs)("span",{className:"block opacity-75 break-all",children:["(",a.detail,")"]}),a.hint&&(0,t.jsxs)("span",{className:"block opacity-90 break-words",children:["Hint: ",a.hint]})]},`${a.code}-${i}`))})]})}r(UQe,"AdapterEnvironmentResult$1");function dxe({value:e,onChange:s,disabledTypes:n}){const[a,i]=(0,u.useState)(!1),o=zm(e),l=(0,u.useMemo)(()=>axe(c=>ow[c]??df(c)).filter(c=>!n.has(c.value)),[n]);return(0,t.jsxs)(nr,{open:a,onOpenChange:i,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e==="opencode_local"?(0,t.jsx)(fF,{className:"h-3.5 w-3.5"}):null,(0,t.jsx)("span",{className:"truncate",children:ow[e]??df(e)}),o.experimental&&(0,t.jsx)(JY,{})]}),(0,t.jsx)(en,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsx)(Wn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:l.map(c=>(0,t.jsxs)("button",{disabled:c.comingSoon,className:z("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded",c.comingSoon?"opacity-40 cursor-not-allowed":"hover:bg-accent/50",c.value===e&&!c.comingSoon&&"bg-accent"),onClick:r(()=>{c.comingSoon||(s(c.value),i(!1))},"onClick"),children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[c.value==="opencode_local"?(0,t.jsx)(fF,{className:"h-3.5 w-3.5"}):null,(0,t.jsx)("span",{children:c.label}),c.experimental&&(0,t.jsx)(JY,{})]}),c.comingSoon&&(0,t.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground",children:"Coming soon"})]},c.value))})]})}r(dxe,"AdapterTypeDropdown");function JY(){return(0,t.jsx)("span",{className:"shrink-0 rounded border border-amber-500/30 bg-amber-500/10 px-1.5 py-0.5 text-(length:--text-nano) font-medium leading-none text-amber-700 dark:text-amber-200",children:"Experimental"})}r(JY,"ExperimentalBadge$1");function lK({models:e,value:s,onChange:n,open:a,onOpenChange:i,allowDefault:o,required:l,groupByProvider:c,creatable:d,detectedModel:m,detectedModelCandidates:h,onDetectModel:p,onRefreshModels:f,refreshingModels:g,detectModelLabel:v,emptyDetectHint:y,defaultLabel:w}){const[S,j]=(0,u.useState)(""),[N,_]=(0,u.useState)(!1),A=e.find($=>$.id===s),C=S.trim(),I=!!(d&&C&&!e.some($=>$.id.toLowerCase()===C.toLowerCase())),T=(0,u.useMemo)(()=>{const $=new Set;m&&$.add(m);for(const E of h??[])E&&$.add(E);return $},[m,h]),R=(0,u.useMemo)(()=>e.filter($=>{if(T.has($.id))return!1;if(!S.trim())return!0;const E=S.toLowerCase(),q=$O($.id)??"";return $.id.toLowerCase().includes(E)||$.label.toLowerCase().includes(E)||q.toLowerCase().includes(E)}),[e,S,T]),L=(0,u.useMemo)(()=>{if(!c)return[{provider:"models",entries:[...R].sort((E,q)=>E.id.localeCompare(q.id))}];const $=new Map;for(const E of R){const q=$O(E.id)??"other",B=$.get(q)??[];B.push(E),$.set(q,B)}return Array.from($.entries()).sort(([E],[q])=>E.localeCompare(q)).map(([E,q])=>({provider:E,entries:[...q].sort((B,K)=>B.id.localeCompare(K.id))}))},[R,c]);async function O(){if(p){_(!0);try{const $=await p();$&&(n($),i(!1),j(""))}finally{_(!1)}}}return r(O,"handleDetectModel"),(0,t.jsx)(ws,{label:"Model",hint:bi.model,children:(0,t.jsxs)(nr,{open:a,onOpenChange:r($=>{i($),$||j("")},"onOpenChange"),children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[(0,t.jsx)("span",{className:z(!s&&"text-muted-foreground"),children:A?A.label:s||(o?w??"Default":l?"Select model (required)":"Select model")}),(0,t.jsx)(en,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsxs)(Wn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:[(0,t.jsxs)("div",{className:"relative mb-1",children:[(0,t.jsx)("input",{className:"w-full px-2 py-1.5 pr-6 text-xs bg-transparent outline-none border-b border-border placeholder:text-muted-foreground/50",placeholder:d?"Search models... (type to create)":"Search models...",value:S,onChange:r($=>j($.target.value),"onChange"),autoFocus:!0}),S&&(0,t.jsx)("button",{type:"button",className:"absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:r(()=>j(""),"onClick"),children:(0,t.jsxs)("svg",{"aria-hidden":"true",focusable:"false",className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,t.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p&&!S.trim()&&(0,t.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-muted-foreground",onClick:r(()=>{O()},"onClick"),disabled:N,children:[(0,t.jsxs)("svg",{"aria-hidden":"true",focusable:"false",className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,t.jsx)("path",{d:"M3 3v5h5"})]}),N?"Detecting...":m?v?.replace(/^Detect\b/,"Re-detect")??"Re-detect from config":v??"Detect from config"]}),f&&!S.trim()&&(0,t.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-muted-foreground",onClick:r(()=>{f()},"onClick"),disabled:g,children:[(0,t.jsxs)("svg",{"aria-hidden":"true",focusable:"false",className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M3 12a9 9 0 0 1 15.28-6.36L21 8"}),(0,t.jsx)("path",{d:"M21 3v5h-5"}),(0,t.jsx)("path",{d:"M21 12a9 9 0 0 1-15.28 6.36L3 16"}),(0,t.jsx)("path",{d:"M8 16H3v5"})]}),g?"Refreshing...":"Refresh models"]}),s&&(!e.some($=>$.id===s)||T.has(s))&&(0,t.jsxs)("button",{type:"button",className:z("flex items-center w-full px-2 py-1.5 text-sm rounded bg-accent/50"),onClick:r(()=>{i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:s,children:e.find($=>$.id===s)?.label??s}),(0,t.jsx)(ct,{variant:"outline",className:"ml-auto text-(length:--text-nano) px-1.5 bg-green-500/15 text-green-400 border-green-500/20",children:"current"})]}),m&&m!==s&&(0,t.jsxs)("button",{type:"button",className:z("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50"),onClick:r(()=>{n(m),i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:m,children:e.find($=>$.id===m)?.label??m}),(0,t.jsx)(ct,{variant:"outline",className:"ml-auto text-(length:--text-nano) px-1.5 bg-blue-500/15 text-blue-400 border-blue-500/20",children:"detected"})]}),h?.filter($=>$&&$!==m&&$!==s).map($=>{const E=e.find(q=>q.id===$);return(0,t.jsxs)("button",{type:"button",className:z("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50"),onClick:r(()=>{n($),i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:$,children:E?.label??$}),(0,t.jsx)(ct,{variant:"outline",className:"ml-auto text-(length:--text-nano) px-1.5 bg-sky-500/15 text-sky-400 border-sky-500/20",children:"config"})]},`detected-${$}`)}),(0,t.jsxs)("div",{className:"max-h-(--sz-240px) overflow-y-auto",children:[o&&(0,t.jsx)("button",{type:"button",className:z("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",!s&&"bg-accent"),onClick:r(()=>{n(""),i(!1)},"onClick"),children:"Default"}),I&&(0,t.jsxs)("button",{type:"button",className:"flex items-center justify-between gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",onClick:r(()=>{n(C),i(!1),j("")},"onClick"),children:[(0,t.jsx)("span",{children:"Use manual model"}),(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:C})]}),L.map($=>(0,t.jsxs)("div",{className:"mb-1 last:mb-0",children:[c&&(0,t.jsxs)("div",{className:"px-2 py-1 text-(length:--text-nano) uppercase tracking-wide text-muted-foreground",children:[$.provider," (",$.entries.length,")"]}),$.entries.map(E=>(0,t.jsx)("button",{type:"button",className:z("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",E.id===s&&"bg-accent"),onClick:r(()=>{n(E.id),i(!1)},"onClick"),children:(0,t.jsx)("span",{className:"block w-full text-left truncate",title:E.id,children:c?_Be(E.id):E.label})},E.id))]},$.provider)),R.length===0&&!I&&T.size===0&&(0,t.jsx)("div",{className:"px-2 py-2 space-y-2",children:(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:p?y??"No model detected yet. Enter a provider/model manually.":"No models found."})})]})]})]})})}r(lK,"ModelDropdown");function KQe({value:e,options:s,onChange:n,open:a,onOpenChange:i}){const o=s.find(l=>l.id===e)??s[0];return(0,t.jsx)(ws,{label:"Thinking effort",hint:bi.thinkingEffort,children:(0,t.jsxs)(nr,{open:a,onOpenChange:i,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[(0,t.jsx)("span",{className:z(!e&&"text-muted-foreground"),children:o?.label??"Auto"}),(0,t.jsx)(en,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsx)(Wn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:s.map(l=>(0,t.jsxs)("button",{className:z("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",l.id===e&&"bg-accent"),onClick:r(()=>{n(l.id),i(!1)},"onClick"),children:[(0,t.jsx)("span",{children:l.label}),l.id?(0,t.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:l.id}):null]},l.id||"auto"))})]})})}r(KQe,"ThinkingEffortDropdown");function uxe(e){const s=`paperclip.agent-appearance.${e}`;function n(){try{const l=xle.safeParse(JSON.parse(sessionStorage.getItem(s)??"null"));if(l.success)return l.data}catch{}const o=s2();try{sessionStorage.setItem(s,JSON.stringify(o))}catch{}return o}r(n,"readDraft");const[a,i]=(0,u.useState)(()=>({key:s,appearance:n()}));return a.key!==s&&i({key:s,appearance:n()}),{appearance:a.appearance,clear(){try{sessionStorage.removeItem(s)}catch{}}}}r(uxe,"useAgentAppearanceDraft");var YN=null,uI=new Set,JN={subscribe(e){return uI.add(e),()=>{uI.delete(e)}},getSnapshot(){return YN},acquire(e){if(YN)return!1;YN=e;for(const s of uI)s();return!0},release(e){if(YN===e){YN=null;for(const s of uI)s()}}};function uC({agent:e,appearance:s,size:n=256,state:a="idle",muted:i=!1,motion:o="auto",trackingRegion:l,trackingScope:c="region",followCursor:d=!0,followRotation:m=!0,className:h,label:p,name:f}){const g=(0,u.useMemo)(()=>Aw(s??e?.appearance,e?.id),[s,e?.appearance,e?.id]),v=(0,u.useRef)(null),y=(0,u.useRef)(null),w=(0,u.useRef)(null),S=(0,u.useRef)(Symbol("agent-character")),j=(0,u.useSyncExternalStore)(JN.subscribe,JN.getSnapshot,()=>null),[N,_]=(0,u.useState)(!1),[A,C]=(0,u.useState)(!0),[I,T]=(0,u.useState)(!1),[R,L]=(0,u.useState)(!1),O=N&&!A&&!I&&o==="auto"&&a!=="rest";return(0,u.useEffect)(()=>{if(typeof matchMedia!="function"||typeof IntersectionObserver!="function")return;const $=matchMedia("(prefers-reduced-motion: reduce)"),E=r(()=>C($.matches),"change");E(),$.addEventListener("change",E);const q=new IntersectionObserver(B=>_(B[0]?.isIntersecting??!1));return v.current&&q.observe(v.current),()=>{q.disconnect(),$.removeEventListener("change",E)}},[]),(0,u.useEffect)(()=>{O&&j===null&&JN.acquire(S.current),O||JN.release(S.current)},[O,j]),(0,u.useEffect)(()=>()=>JN.release(S.current),[]),(0,u.useEffect)(()=>{if(!O||j!==S.current)return;let $=!1;return L(!1),Promise.all([vc(()=>import("./runtime-IAg0vdY9.js"),__vite__mapDeps([0,1])),vc(()=>import("./definition-DurZnIaP.js"),__vite__mapDeps([2,3,1]))]).then(([E,q])=>{$||!y.current||(w.current=E.createCharacter(y.current,q.characterDefinition(g,i),{animation:q.animationId(a),trackingRegion:l?.current??v.current??void 0,followCursor:d,followRotation:m,trackingScope:c,displaySize:n,onError:r(()=>T(!0),"onError")}),L(!0))}).catch(()=>{$||T(!0)}),()=>{$=!0,w.current?.destroy(),w.current=null,L(!1)}},[O,j,l,c,n,d,m]),(0,u.useEffect)(()=>{w.current&&vc(()=>import("./definition-DurZnIaP.js").then($=>{w.current?.setDefinition($.characterDefinition(g,i)),w.current?.setAnimation($.animationId(a))}),__vite__mapDeps([2,3,1]))},[g,i,a,R]),(0,t.jsxs)("span",{ref:v,role:p?"img":void 0,"aria-label":p,"aria-hidden":p?void 0:!0,className:z("relative inline-block shrink-0",C2e[n],h),children:[(0,t.jsx)(pr,{agent:e,appearance:g,size:n<256?256:n,name:f,pose:a,muted:i,className:z("size-full",R&&"invisible")}),(0,t.jsx)("span",{ref:y,className:"absolute inset-0"})]})}r(uC,"AgentCharacter");var VQe=new Set(["claude_local","codex_local","opencode_local","grok_local"]);function mxe(e,{cloud:s,nativeRunnerEnabled:n}){return s?VQe.has(e):e!=="paperclip_runner"||n}r(mxe,"isNewAgentAdapterAllowed");var WQe={claude_local:{src:"/brands/claude-color.svg"},codex_local:{src:"/brands/codex-color.svg"},gemini_local:{src:"/brands/adapters/gemini-color.svg"},kimi_local:{src:"/brands/adapters/kimi-color-light.svg",dark:"/brands/adapters/kimi-color.svg"},...Object.fromEntries([["cursor","cursor"],["cursor_cloud","cursor"],["grok_local","grok"],["hermes_local","hermesagent"],["hermes_gateway","hermesagent"],["pi_local","pi"]].map(([e,s])=>[e,{src:`/brands/adapters/${s}.svg`,dark:`/brands/adapters/${s}-dark.svg`}]))};function cK({type:e,className:s="size-6"}){const n=zm(e).icon,a=WQe[e];return a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("img",{src:a.src,className:z("shrink-0 object-contain",a.dark&&"dark:hidden",s),alt:""}),a.dark&&(0,t.jsx)("img",{src:a.dark,className:z("hidden shrink-0 object-contain dark:block",s),alt:""})]}):(0,t.jsx)(n,{className:s})}r(cK,"AdapterMark");function HQe(){const{selectedCompanyId:e}=xs(),{appearance:s}=uxe(`${e}:new-agent`);return(0,t.jsx)(uC,{appearance:s,state:"sleepy",muted:!0,size:256,className:"size-48",trackingScope:"page"})}r(HQe,"AgentBasicsCharacter");function hxe({open:e,onClose:s,onContinue:n,initialAdapter:a="",onInvite:i}){const o=(0,u.useId)(),l=!!Qc(),c=ee({queryKey:P.instance.experimentalSettings,queryFn:Ir.getExperimental,enabled:e,retry:!1}),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(a),[f,g]=(0,u.useState)("codex"),[v,y]=(0,u.useState)("name"),{data:w,isPending:S,error:j}=ee({queryKey:P.adapters.all,queryFn:Am.list,enabled:e}),N=(w??[]).filter(A=>A.loaded&&!A.disabled&&mxe(A.type,{cloud:l,nativeRunnerEnabled:c.data?.enableNativeRunner===!0})&&!["process","http"].includes(A.type)&&!zm(A.type).comingSoon),_=N.some(A=>A.type===h);return(0,t.jsx)(Js,{open:e,onOpenChange:r(A=>{A||s()},"onOpenChange"),children:(0,t.jsxs)(Zs,{className:z("flex max-h-(--sz-calc-18) flex-col gap-0 overflow-hidden p-0 sm:max-w-(--sz-640px)",v==="name"&&"sm:max-w-(--sz-560px)"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-6 py-5 text-xs text-muted-foreground","aria-label":"New agent progress",children:[(0,t.jsx)("span",{className:z(v==="name"&&"font-medium text-foreground"),children:"1. Name"}),(0,t.jsx)(fn,{className:"size-3"}),(0,t.jsx)("span",{className:z(v==="adapter"&&"font-medium text-foreground"),children:"2. Adapter"})]}),(0,t.jsxs)("form",{className:"flex min-h-0 flex-col",onSubmit:r(A=>{A.preventDefault(),d.trim()&&(v==="name"?y("adapter"):_&&n({name:d.trim(),adapterType:h,runnerProvider:f}))},"onSubmit"),children:[(0,t.jsxs)("div",{className:"flex min-h-0 flex-col gap-7 overflow-y-auto px-6 pb-8 sm:px-10",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center",children:[e&&(0,t.jsx)(HQe,{}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(rn,{className:"text-3xl font-semibold tracking-tight",children:v==="name"?"Meet your next agent":"Choose an adapter"}),(0,t.jsx)(Mn,{className:"text-base",children:v==="name"?"Start with a name. Make them your own.":`How should ${d.trim()} work?`})]})]}),v==="name"?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{htmlFor:o,className:"text-sm font-medium",children:"Agent name"}),(0,t.jsx)(_t,{id:o,autoFocus:!0,maxLength:100,placeholder:"e.g. Darnold",value:d,onChange:r(A=>m(A.target.value),"onChange"),className:"h-12 text-base"}),i&&(0,t.jsx)(F,{type:"button",variant:"link",className:"px-0 text-muted-foreground",onClick:i,children:"Invite an external agent"})]}):(0,t.jsxs)("fieldset",{className:"space-y-4",children:[(0,t.jsx)("legend",{className:"sr-only",children:"Adapter"}),S&&(0,t.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading adapters…"}),j&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:j.message}),(0,t.jsx)("div",{className:z("grid grid-cols-2 gap-3",N.length!==4&&"sm:grid-cols-3"),children:N.map(A=>{const C=zm(A.type);return(0,t.jsxs)("label",{className:"relative cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",name:"new-agent-adapter",value:A.type,checked:h===A.type,onChange:r(()=>p(A.type),"onChange"),className:"peer sr-only"}),(0,t.jsxs)("span",{className:z("flex h-full flex-col items-center gap-2 rounded-lg border px-3 py-4 text-center peer-focus-visible:ring-2 peer-focus-visible:ring-ring hover:bg-accent/40",h===A.type?"border-foreground/40 bg-accent":"border-border bg-card"),children:[(0,t.jsx)(cK,{type:A.type}),(0,t.jsx)("span",{className:"text-sm font-medium",children:C.label}),h===A.type&&(0,t.jsx)(fs,{className:"absolute right-2 top-2 size-3.5"})]})]},A.type)})}),_&&h==="paperclip_runner"&&(0,t.jsxs)("label",{className:"flex flex-col gap-2 text-sm font-medium",children:["Runner",(0,t.jsxs)("select",{className:"rounded-md border border-border bg-background px-3 py-2",value:f,onChange:r(A=>g(A.target.value),"onChange"),children:[(0,t.jsx)("option",{value:"codex",children:"Codex (app server)"}),(0,t.jsx)("option",{value:"claude",children:"Claude (ACPX)"}),(0,t.jsx)("option",{value:"opencode",children:"OpenCode"})]})]})]})]}),(0,t.jsxs)("div",{className:"flex justify-between gap-4 border-t border-border px-6 py-4",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:r(()=>v==="name"?s():y("name"),"onClick"),children:v==="name"?"Cancel":(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ic,{className:"size-4"}),"Back"]})}),(0,t.jsxs)(F,{type:"submit",disabled:!d.trim()||v==="adapter"&&!_,children:[v==="name"?"Choose adapter":"Configure agent",(0,t.jsx)(Zo,{className:"size-4"})]})]})]})]})})}r(hxe,"AgentBasicsDialog");var QQe={subscription:"Subscription",api:"API"};function GQe({mode:e}){return(0,t.jsx)("span",{className:"relative flex h-4 w-full items-center justify-center overflow-hidden text-(length:--text-micro) text-muted-foreground",children:(0,t.jsx)(eN,{initial:!1,mode:"sync",children:(0,t.jsx)(Yo.span,{className:"absolute inset-0 flex items-center justify-center whitespace-nowrap",initial:{opacity:0,y:hY},animate:{opacity:1,y:0,transition:y7e},exit:{opacity:0,y:hY,transition:j7e},children:QQe[e]},e)})})}r(GQe,"CredentialTag");function YQe({source:e,mode:s,selected:n,onSelect:a,buttonRef:i,settling:o}){return(0,t.jsxs)("button",{ref:i,type:"button",role:"radio","aria-checked":n,onClick:a,className:z("flex min-w-0 flex-1 cursor-pointer flex-col items-center gap-1.5 self-stretch rounded-md border p-3","transition-(--tp-border-color-background-color) ease-(--motion-ease-standard)",o?"duration-(--motion-duration-slow)":"duration-(--motion-duration-fast)","outline-none focus-visible:ring-ring/50 focus-visible:ring-(length:--rad-3)",n?"border-foreground/40 bg-accent":"border-border bg-card hover:bg-accent/40"),children:[(0,t.jsx)("span",{className:"flex size-(--sz-30px) shrink-0 items-center justify-center",children:e.icon}),(0,t.jsx)("span",{className:"text-(length:--text-compact) font-medium text-foreground",children:e.label}),(0,t.jsx)(GQe,{mode:s})]})}r(YQe,"ModelSourceTile");function pxe({sources:e,mode:s,selectedId:n,onSelect:a,label:i,collapsed:o=!1,settling:l=!1}){const c=(0,u.useRef)(new Map),d=r(h=>{if(e.length===0)return;const p=e.findIndex(g=>g.id===n),f=e[((p===-1?h>0?-1:0:p)+h+e.length)%e.length];a(f.id),c.current.get(f.id)?.focus()},"moveSelection"),m=o?e.filter(h=>h.id===n):e;return(0,t.jsx)("div",{role:"radiogroup","aria-label":i,className:z("flex items-start gap-3",o&&"justify-center"),onKeyDown:r(h=>{o||(h.key==="ArrowRight"||h.key==="ArrowDown"?(h.preventDefault(),d(1)):(h.key==="ArrowLeft"||h.key==="ArrowUp")&&(h.preventDefault(),d(-1)))},"onKeyDown"),children:(0,t.jsx)(eN,{initial:!1,mode:"popLayout",children:m.map(h=>(0,t.jsx)(Yo.div,{layout:!0,transition:ffe,exit:{opacity:0,transition:T7e},className:z("flex min-w-0",o?"w-(--sz-source-tile-two-up)":"flex-1"),children:(0,t.jsx)(YQe,{source:h,mode:s,selected:h.id===n,onSelect:r(()=>a(h.id),"onSelect"),settling:l,buttonRef:r(p=>{p?c.current.set(h.id,p):c.current.delete(h.id)},"buttonRef")})},h.id))})})}r(pxe,"ModelSourceTiles");var E4={subscription:"Use API key instead",api:"Use subscription instead"},JQe={subscription:"api",api:"subscription"};function fxe({mode:e,onChange:s}){return(0,t.jsxs)("button",{type:"button",onClick:r(()=>s(JQe[e]),"onClick"),className:z("group grid cursor-pointer px-3 py-2 text-left text-sm font-medium","rounded-md outline-none focus-visible:ring-ring/50 focus-visible:ring-(length:--rad-3)"),children:[Object.keys(E4).map(n=>(0,t.jsx)("span",{"aria-hidden":!0,className:"invisible col-start-1 row-start-1 whitespace-nowrap",children:E4[n]},n)),(0,t.jsx)(eN,{initial:!1,mode:"sync",children:(0,t.jsx)(Yo.span,{className:z("col-start-1 row-start-1 justify-self-start whitespace-nowrap","underline decoration-muted-foreground/40 underline-offset-4","text-muted-foreground transition-colors","group-hover:text-foreground group-hover:decoration-foreground/40"),initial:{opacity:0},animate:{opacity:1,transition:JU},exit:{opacity:0,transition:w7e},children:E4[e]},e)})]})}r(fxe,"CredentialModeLink");function xxe({onBack:e,primaryLabel:s,primaryDisabled:n,loading:a,loadingLabel:i,primaryIcon:o,onPrimary:l}){const c=a&&i?i:s,d=o??(a?"spinner":"arrow");return(0,t.jsxs)("div",{className:"flex items-center justify-between pt-9",children:[e?(0,t.jsxs)(F,{variant:"ghost",size:"lg",className:"rounded-full has-[>svg]:pl-4 has-[>svg]:pr-5",onClick:e,disabled:a,children:[(0,t.jsx)(ic,{className:"mr-1 size-3.5"}),"Back"]}):(0,t.jsx)("span",{}),(0,t.jsx)(Yo.div,{layout:!0,transition:S7e,className:"min-w-0",children:(0,t.jsx)(F,{size:"lg",className:"w-full rounded-full px-6",onClick:l,disabled:n||a,children:(0,t.jsxs)(Yo.span,{className:"flex items-center whitespace-nowrap",initial:{opacity:0},animate:{opacity:1},transition:C7e,children:[d==="spinner"?(0,t.jsx)(it,{className:"mr-1 size-4 animate-spin"}):null,c,d==="arrow"?(0,t.jsx)(Zo,{className:"ml-1 size-3.5"}):null]},`${c}:${d}`)})})]})}r(xxe,"FooterNav");function gxe({companyId:e,adapterType:s,environmentId:n,canLogin:a,localEnvironment:i=!1,onConnected:o,onBack:l,testConnection:c,testError:d,managedAccount:m}){const h=ee({queryKey:P.health,queryFn:tm.get,enabled:i}),p=i&&(h.data?.localAiLoginSupported??h.data?.deploymentMode==="local_trusted"),f=(0,u.useRef)(0);(0,u.useEffect)(()=>()=>{f.current++},[]);const g=r(()=>{f.current++,L(!1),S(!1),N(null),A("preparing")},"cancel"),[v,y]=(0,u.useState)(m?.initialMethod==="api_key"?"api":m?"subscription":null),[w,S]=(0,u.useState)(!1),[j,N]=(0,u.useState)(null),[_,A]=(0,u.useState)("preparing"),C=(0,u.useRef)("ready"),[I,T]=(0,u.useState)(""),[R,L]=(0,u.useState)(!1),[O,$]=(0,u.useState)(null),[E,q]=(0,u.useState)(null),B=s==="claude_local"?"Claude":s==="grok_local"?"Grok":"OpenAI",K=s==="claude_local"?"ANTHROPIC_API_KEY":s==="grok_local"?"XAI_API_KEY":"OPENAI_API_KEY",U=s==="claude_local"?"anthropic":s==="grok_local"?"xai":"openai",D=efe(e,K),V=m?{...D,options:[],subscriptions:[],loading:!1}:D,[H,J]=(0,u.useState)(null),X=V.subscriptions.length?V.subscriptions.find(ae=>ae.id===(H??V.subscriptions[0]?.id)):void 0,[le,ce]=(0,u.useState)(null),te=V.options.find(ae=>ae.id===(le??V.options[0]?.id)),re=m?{...V.storedLogin,data:void 0,isPending:!1,isError:!1}:V.storedLogin,de=(0,u.useRef)(null),Z=v??(V.subscriptions.length>0||s==="claude_local"&&!X&&re.data?"subscription":V.options.length?"api":"subscription"),Y=bhe(e,m?.intent??{provider:U,method:"subscription",name:`My ${B} subscription`,ownership:"personal",agentIds:[],allAgents:!0},p&&Z==="subscription"&&!X&&!re.data,{allowHostClaude:h.data?.deploymentMode==="local_trusted"}),G=ee({queryKey:P.agents.authSignal(e,s,n),queryFn:r(()=>zt.getAdapterAuthSignal(e,s,n??void 0),"queryFn"),retry:!1,enabled:!m});async function fe(){if(R||m?.disabled)return;const ae=++f.current;L(!0),$(null);try{if(m){if(Z==="subscription"&&!p)return;const pe=de.current??await(Z==="api"?mu.create(e,{...m.intent,method:"api_key",apiKey:I.trim()}):Y.connect(m.intent));de.current=pe,T(""),ae===f.current&&m.onComplete({...pe,method:Z==="api"?"api_key":"subscription"});return}let ie=Z==="api"?te?te.aiConnection?{env:{},aiConnection:te.aiConnection}:{env:{[K]:te.binding}}:E??{env:{},credentials:{[K]:I.trim()}}:{...X?.aiConnection?{aiConnection:X.aiConnection}:{},env:X?.binding?{CODEX_HOME:X.binding}:{},...s==="claude_local"&&!X&&re.data?{env:aj(),applyStoredClaudeLogin:!0}:{}};if(Z==="subscription"&&p&&!X&&!re.data&&(de.current??=await Y.connect(),ie={env:{},aiConnection:{provider:U,method:"subscription",mode:"responsible_user"}}),ie.credentials&&(await mu.create(e,{provider:U,method:"api_key",name:`My ${B} API`,ownership:"personal",apiKey:ie.credentials[K],agentIds:[],allAgents:!0}),ie={env:{},aiConnection:{provider:U,method:"api_key",mode:"responsible_user"}}),ae!==f.current)return;Z==="api"&&(T(""),te||q(ie));const ue=await c(ie);if(ae!==f.current)return;ue?o(ie):$("The provider did not respond. Check the connection and try again.")}catch(ie){if(ae!==f.current)return;m&&T(""),$(ie instanceof Error?ie.message:"Could not connect to the provider.")}finally{ae===f.current&&L(!1)}}r(fe,"connect");const se=Z==="subscription"&&a&&n&&!X&&!V.loading&&!re.data&&(!!m||G.data?.status!=="present"||H==="");return(0,t.jsxs)("div",{className:"min-w-0 max-w-full",children:[(0,t.jsx)(pxe,{label:"Connect your model provider",sources:[{id:s,label:B,icon:(0,t.jsx)(cK,{type:s})}],mode:Z,selectedId:w?s:null,collapsed:w,onSelect:r(()=>{m?.disabled||S(!0)},"onSelect")}),!w&&!m?.fixedMethod&&(0,t.jsx)("div",{className:"-ml-3 mt-1",children:(0,t.jsx)(fxe,{mode:Z,onChange:r(ae=>{de.current=null,y(ae),$(null)},"onChange")})}),!w&&V.options.length>0&&(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:[V.options.length," saved API"," ",V.options.length===1?"key available":"keys available","."]}),Z==="subscription"&&V.subscriptions.length>0&&(0,t.jsx)(Cj,{options:V.subscriptions,value:X?.id??"",onChange:J,loading:!1,error:!1,kind:"subscription",disabled:R}),(0,t.jsx)(Yo.div,{initial:!1,animate:{height:w?"auto":0,opacity:w?1:0},transition:{height:ld,opacity:H5},className:"overflow-hidden",children:w&&(0,t.jsx)("div",{className:"pt-5",children:Z==="api"?(0,t.jsxs)(Q5,{instruction:V.options.length?"Choose a saved API key or enter a new one":`Provide your ${B} API key to connect`,children:[(0,t.jsx)(Cj,{...V,value:te?.id??"",disabled:R,onChange:r(ae=>{ce(ae),T(""),q(null),$(null)},"onChange")}),!te&&(0,t.jsx)(G5,{label:"API key",masked:!0,autoFocus:!0,value:I,placeholder:E?"Key entered. Retry the connection.":"Enter API key here",onChange:r(ae=>{ce(""),T(ae),q(null)},"onChange"),onSubmit:r(()=>{fe()},"onSubmit"),disabled:R})]}):se?(0,t.jsx)(oK,{companyId:e,adapterType:s,environmentId:n,chrome:"onboarding",aiConnection:m?.intent??{provider:U,method:"subscription",name:`My ${B} subscription`,ownership:"personal",agentIds:[],allAgents:!0},autoStart:!0,onStored:r(()=>{},"onStored"),onPromptReady:r(ae=>{N(ae),A(ie=>ae?ie==="preparing"?"ready":ie:"preparing")},"onPromptReady"),onCodeSubmitted:r(()=>{C.current=_==="waiting"?"waiting":"ready",A("connecting")},"onCodeSubmitted"),onSubmitFailed:r(()=>{A(ae=>ae==="connecting"?C.current:ae)},"onSubmitFailed"),onConnected:r(ae=>{if(m){if(!ae){$("The login did not return a saved connection. Try again.");return}const ue=f.current;A("connecting"),mu.loginResult(e,ae).then(pe=>{ue===f.current&&m.onComplete({...pe,method:"subscription"})}).catch(()=>{ue===f.current&&(A("ready"),$("Could not retrieve the saved connection. Go back and retry."))});return}const ie={env:{},aiConnection:{provider:U,method:"subscription",mode:"responsible_user"}};q(ie),o(ie)},"onConnected")}):X?null:p&&!re.data?(0,t.jsx)(XU,{adapterType:s,login:{...Y,retry:r(()=>{$(null),Y.retry()},"retry")}}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:re.data?"Use your saved Claude subscription for this agent.":a?"Use the existing provider connection for this environment.":"This environment does not support browser sign-in. Choose a sign-in environment or connect with an API key."})})}),Z==="subscription"&&re.isError&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:"Could not check your saved Claude subscription. Try again."}),O&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:d??O}),i&&h.isError&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:"Could not prepare sign-in. Reload this page to try again."}),(0,t.jsx)(xxe,{onBack:r(()=>{w?g():l()},"onBack"),primaryLabel:w&&se?_==="waiting"?"Waiting for code":_==="connecting"?"Connecting":`Sign in to ${B}`:R?"Connecting":Z==="subscription"&&(re.data||X)?"Use saved subscription":Z==="api"&&te?"Use saved API key":"Connect",primaryDisabled:m?.disabled||!!m&&Z==="subscription"&&!a&&!p||i&&h.isPending||Y.preparing||!!Y.error||!m&&G.isPending||V.loading||s==="claude_local"&&re.isPending||!w||!!se&&(!j||_!=="ready")||Z==="api"&&!I.trim()&&!E&&!te,loading:R,primaryIcon:w&&se?_==="ready"?"none":"spinner":void 0,onPrimary:r(()=>{if(se){if(!j||_!=="ready")return;window.open(j,"_blank","noreferrer,noopener"),A("waiting")}else fe()},"onPrimary")})]})}r(gxe,"AgentProviderConnection");function TT(e){return e.provider==="openrouter"?(0,t.jsx)(ZQe,{...e}):(0,t.jsx)(XQe,{...e})}r(TT,"AiConnectionCredentialStep");function XQe({companyId:e,provider:s,initialMethod:n,fixedMethod:a,connectionId:i,name:o,ownership:l,agentIds:c,allAgents:d,environmentId:m,onComplete:h,onCancel:p}){const[f,g]=(0,u.useState)(o),[v,y]=(0,u.useState)(),w=Kt(),S=ee({queryKey:P.environments.list(e),queryFn:r(()=>Ci.list(e),"queryFn")}),j=ee({queryKey:P.environments.capabilities(e),queryFn:r(()=>Ci.capabilities(e),"queryFn")}),N=ee({queryKey:P.instance.settings,queryFn:Ir.get}),_=ee({queryKey:P.instance.experimentalSettings,queryFn:Ir.getExperimental}),A=ee({queryKey:P.instance.generalSettings,queryFn:Ir.getGeneral}),C=iK(A.data?.executionMode,S.data??[]);let I=null,T;try{I=C.forced?C.kubernetesEnvironment?.id??null:cw({agentDefaultEnvironmentId:m??v,instanceDefaultEnvironmentId:N.data?.defaultEnvironmentId,localDefaultEnvironmentId:uw(S.data),managedSandboxOnly:_.data?.enableManagedSandboxOnly,managedSandboxEnvironmentId:dw(S.data),visibleEnvironmentIds:S.data?.map(K=>K.id)})}catch(K){T=K instanceof Error?K.message:"Could not resolve the sign-in environment."}const R=(S.data??[]).filter(K=>K.status==="active"&&(K.driver==="local"||K.driver==="sandbox"&&typeof K.config.provider=="string"&&j.data?.sandboxProviders?.[K.config.provider]?.supportsLoginPty===!0));!C.forced&&!m&&!v&&!R.some(K=>K.id===I)&&(I=R[0]?.id??null);const L=S.data?.find(K=>K.id===I),O=typeof L?.config.provider=="string"?L.config.provider:"",$=L?.driver==="sandbox"&&j.data?.sandboxProviders?.[O]?.supportsLoginPty===!0,E=[S,j,N,_,A].some(K=>K.isPending),q=T??[S,j,N,_,A].find(K=>K.error)?.error?.message,B={provider:s,method:"subscription",name:f,ownership:l,agentIds:c,allAgents:d,connectionId:i};return(0,t.jsxs)("div",{className:"mx-auto w-full min-w-0 max-w-xl space-y-6",children:[(0,t.jsxs)("label",{className:"block space-y-2 text-sm",children:["Connection name",(0,t.jsx)(_t,{value:f,onChange:r(K=>g(K.target.value),"onChange"),disabled:!!i})]}),!m&&!C.forced&&R.length>1&&(0,t.jsxs)(La,{value:I??"",onValueChange:y,children:[(0,t.jsx)(Da,{"aria-label":"Sign-in environment",children:(0,t.jsx)(Pa,{placeholder:"Sign-in environment"})}),(0,t.jsx)(Ma,{children:R.map(K=>(0,t.jsx)(Nn,{value:K.id,children:K.name},K.id))})]}),q&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:q}),E?(0,t.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Preparing sign-in…"}):(0,t.jsx)(gxe,{companyId:e,adapterType:s==="anthropic"?"claude_local":s==="xai"?"grok_local":"codex_local",environmentId:I,canLogin:$,localEnvironment:L?.driver==="local",onBack:p,onConnected:r(()=>{},"onConnected"),testConnection:r(async()=>!1,"testConnection"),managedAccount:{intent:B,initialMethod:n,fixedMethod:a||!!i,disabled:E||!!q||!f.trim(),onComplete:r(K=>{w.invalidateQueries({queryKey:["ai-connections",e]}),h(K)},"onComplete")}},I??"local")]})}r(XQe,"SubscriptionConnectionStep");function ZQe({companyId:e,provider:s,connectionId:n,name:a,ownership:i,agentIds:o,allAgents:l,onComplete:c,onCancel:d}){const[m,h]=(0,u.useState)(a),[p,f]=(0,u.useState)(""),g=Kt(),v=ke({mutationFn:r(()=>mu.create(e,{provider:s,method:"api_key",name:m,ownership:i,agentIds:o,allAgents:l,connectionId:n,apiKey:p}),"mutationFn"),onSuccess:r(y=>{g.invalidateQueries({queryKey:["ai-connections",e]}),c({...y,method:"api_key"})},"onSuccess"),onSettled:r(()=>f(""),"onSettled")});return(0,t.jsxs)("div",{className:"mx-auto w-full min-w-0 max-w-xl space-y-4",children:[(0,t.jsxs)("label",{className:"block space-y-2 text-sm",children:["Connection name",(0,t.jsx)(_t,{value:m,onChange:r(y=>h(y.target.value),"onChange"),disabled:!!n})]}),v.error&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:v.error.message}),(0,t.jsx)(vfe,{providerName:"OpenRouter",value:p,onChange:f,onSubmit:r(()=>v.mutate(),"onSubmit"),disabled:v.isPending,placeholder:"Enter API key here",autoFocus:!0}),(0,t.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,t.jsx)(F,{variant:"ghost",onClick:d,children:"Cancel"}),(0,t.jsx)(F,{disabled:!m.trim()||!p.trim()||v.isPending,onClick:r(()=>v.mutate(),"onClick"),children:v.isPending?"Connecting…":"Connect"})]})]})}r(ZQe,"ApiKeyConnectionStep");var eGe=new RegExp(`\\b(${["mcp","server","profile","policy","gateway","transport","stdio","endpoint"].join("|")})s?\\b`,"gi");function bxe(e){return e.replace(eGe,"").replace(/\s{2,}/g," ").replace(/\s+([.,])/g,"$1").trim()}r(bxe,"sanitizeProsumerCopy");var tGe={zapier:{tagline:"Reach 9,000+ apps your team already uses.",short:"Reach 9,000+ apps from your agents."},github:{tagline:"Read code and pull requests, comment on issues.",short:"Read code and pull requests, comment on issues."},slack:{tagline:"Send and read messages in your team's channels.",short:"Send and read messages in your channels."},notion:{tagline:"Read and update pages in your workspace.",short:"Read and update pages in your workspace."},railway:{tagline:"Inspect services, read logs, and manage deployments.",short:"Connect Railway for deployments, logs, and container access."},posthog:{tagline:"Explore product usage, errors, flags, and experiments.",short:"Sign in with PostHog. Project pinning and access controls are optional."},linear:{tagline:"Create, update and read tickets.",short:"Create, update and read tickets."},"google-sheets":{tagline:"Read and update selected spreadsheets.",short:"Read spreadsheets or update the files you choose."},gmail:{tagline:"Read mail and create drafts for your review.",short:"Read mail and create drafts for your review."},"google-drive":{tagline:"Find, read, and create files in Drive.",short:"Find, read, and create files in Drive."},"google-docs":{tagline:"Read and update documents.",short:"Read and update documents."},"google-slides":{tagline:"Read and update presentations.",short:"Read and update presentations."},"google-calendar":{tagline:"Review calendars and manage events.",short:"Review calendars and manage events."},"google-chat":{tagline:"Read conversations and send messages.",short:"Read conversations and send messages."},"google-people":{tagline:"Look up contacts and people in your directory.",short:"Look up contacts and people in your directory."},"google-workspace-search":{tagline:"Search across your Google workspace.",short:"Search across your Google workspace."},hubspot:{tagline:"Look up contacts and update deal stages.",short:"Look up contacts and update deal stages."},intercom:{tagline:"Read and reply to customer conversations.",short:"Read and reply to customer conversations."},figma:{tagline:"Read files and post comments on frames.",short:"Read files and post comments on frames."},stripe:{tagline:"Read customers, invoices, and payouts.",short:"Read customers, invoices, and payouts."},context7:{tagline:"Look up up-to-date docs for your libraries.",short:"Look up up-to-date docs for your libraries."}},sGe={tagline:"Give your agents access to this app.",short:"Give your agents access to this app."};function vxe(e,s){const n=tGe[e];if(n)return n;if(s){const a=bxe(s);if(a)return{tagline:a,short:a}}return sGe}r(vxe,"appCopyFor");function XY(e,s,n){return n<=1?`Your ${e} key`:bxe(s)||`Your ${e} key`}r(XY,"credentialFieldLabel");var nGe=1500;function uf(e=nGe){const[s,n]=(0,u.useState)("idle"),a=(0,u.useRef)(null),i=(0,u.useRef)(0);(0,u.useEffect)(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const o=(0,u.useCallback)(async l=>{const c=++i.current;let d="copied";try{await Hr(l)}catch{d="failed"}return i.current!==c||(n(d),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{i.current===c&&(n("idle"),a.current=null)},e)),d},[e]);return{status:s,copied:s==="copied",failed:s==="failed",copy:o}}r(uf,"useCopyAction");function dK(){const e=Sc()?.pushToast;return(0,u.useCallback)(async(s,n="Copied")=>{try{return await Hr(s),e?.({title:n,tone:"success",dedupeKey:`copy:${n}`}),!0}catch{return e?.({title:"Couldn’t copy to clipboard",body:"Select and copy the value manually.",tone:"error",dedupeKey:"copy-failed"}),!1}},[e])}r(dK,"useCopyToast");var rGe="/cloud/connections/handoff",aGe="/cloud/connections/reauth",ET="paperclip.cloud-oauth-handoff.v1",fx=class extends Error{static{r(this,"OAuthHandoffError")}code;constructor(e,s){super(e),this.code=s,this.name="OAuthHandoffError"}};function uK(e){if(e===void 0)return null;if(!e||typeof e!="object"||Array.isArray(e))throw new fx("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");const s=e;if(s.kind!=="paperclip_cloud"||typeof s.session!="string"||s.session.length<16||s.session.length>512||!/^[A-Za-z0-9_-]+$/.test(s.session))throw new fx("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");return{kind:"paperclip_cloud",session:s.session}}r(uK,"parseHandoff");function iGe(e,s){return e===404||s==="SESSION_NOT_AVAILABLE"?new fx("This sign-in expired. Start the connection again.","expired"):e===401||e===403?new fx("Paperclip Cloud could not authorize this connection for your account.","forbidden"):new fx("Paperclip Cloud couldn’t prepare secure sign-in. Try again.","unavailable")}r(iGe,"handoffFailure");async function oGe(e,s){const n=s.request??fetch;let a,i;for(let o=0;o<2;o+=1)try{if(a=await n(rGe,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},credentials:"include",body:JSON.stringify({session:e}),signal:s.signal}),a.status<500||o===1)return a}catch(l){if(s.signal?.aborted||l instanceof DOMException&&l.name==="AbortError")throw l;if(i=l,o===1)break}if(a)return a;throw new fx(i instanceof Error?i.message:"Paperclip Cloud couldn’t prepare secure sign-in. Try again.","unavailable")}r(oGe,"postCloudHandoff");function lGe(e,s){if(typeof e!="string"||typeof window>"u")return null;try{const n=new URL(e,window.location.origin);return n.origin!==window.location.origin||n.pathname!==aGe||n.username||n.password||n.hash||n.searchParams.size!==1||n.searchParams.get("session")!==s?null:{kind:"reauthentication",url:n.toString(),host:n.host}}catch{return null}}r(lGe,"exactReauthenticationTarget");async function pw(e,s={}){const n=uK(e.handoff);if(!n){const l=cT(e.authorizationUrl);if(!l.ok)throw new fx(l.message,"invalid_handoff");return{kind:"authorization",url:l.url,host:l.host}}const a=await oGe(n.session,s),i=await a.json().catch(()=>null);if(!a.ok){if(i?.error==="RECENT_LOGIN_REQUIRED"){const l=lGe(i.reauthenticationUrl,n.session);if(l)return l}throw iGe(a.status,i?.error)}const o=cT(typeof i?.authorizationUrl=="string"?i.authorizationUrl:void 0);if(!o.ok)throw new fx("Paperclip Cloud returned an invalid provider sign-in address.","invalid_handoff");return{kind:"authorization",url:o.url,host:o.host}}r(pw,"prepareOAuthNavigation");function mC(e,s=window.sessionStorage){const n=uK({kind:"paperclip_cloud",session:e});if(!n)throw new fx("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");const a={version:1,session:n.session,savedAt:Date.now()};s.setItem(ET,JSON.stringify(a))}r(mC,"savePendingCloudHandoff");function cGe(e=window.sessionStorage){const s=e.getItem(ET);if(!s)return null;try{const n=JSON.parse(s);if(n.version!==1||typeof n.savedAt!="number"||Date.now()-n.savedAt>9e5)throw new Error("expired");return uK({kind:"paperclip_cloud",session:n.session})}catch{return e.removeItem(ET),null}}r(cGe,"readPendingCloudHandoff");function ZY(e=window.sessionStorage){e.removeItem(ET)}r(ZY,"clearPendingCloudHandoff");function eE({host:e,className:s}){return(0,t.jsxs)("div",{className:z("flex flex-wrap items-center gap-2 text-xs",s),children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 font-medium text-amber-700 dark:text-amber-400",children:[(0,t.jsx)(kl,{className:"h-3 w-3"}),"Unverified server"]}),e?(0,t.jsx)("span",{className:"font-mono text-muted-foreground",children:e}):null]})}r(eE,"UnverifiedServerBadge");function tE(e){return!!(e&&ale({...e,methods:e.methods.filter(s=>(s.purpose??"tool")!=="channel"&&s.transport!=="chat_sdk")}))}r(tE,"appSupportsToolCatalogSetup");var dGe=sIe.filter(e=>Xoe(e).some(s=>Fp(s))).map(e=>e.slug);function uGe(e){return dGe.some(s=>s===e)}r(uGe,"isMcpDirectOAuthConnectSlug");function MF(e,s){const n=new URLSearchParams({source:e});return s&&n.set("intent",s),`/apps/connect?${n.toString()}`}r(MF,"appSourceConnectHref");function mGe(e,s){return`/apps/connect?${new URLSearchParams({source:e,resume:s}).toString()}`}r(mGe,"appSourceResumeHref");function P4(e){return e?`/apps/vercel-connect?${new URLSearchParams({source:e}).toString()}`:"/apps/vercel-connect"}r(P4,"vercelConnectSourceHref");function hGe(e){return e.serviceSlug??e.appKey??e.sourceSlug??void 0}r(hGe,"resolveAppsConnectRouteKey");function pGe(e,{chatConnectorsEnabled:s=!1}={}){if(e.get("byo")==="1")return!!(e.get("reconnect")?.trim()&&e.get("applicationId")?.trim()&&e.get("link")?.trim());const n=e.get("source")??"",a=GC(n);return!s&&a?.methods.some(i=>i.transport==="chat_sdk")&&!a.methods.some(i=>(i.purpose??"tool")!=="channel"&&i.transport!=="chat_sdk")?!1:J6(n)&&e.get("reconnect")?.trim()?!0:s?ale(a):tE(a)}r(pGe,"canEnterAppsConnect");var M4=" for the organization",fGe=" for the company";function eJ(e,s){const n=e.trim();if(s!=="organization")return n;const a=n.toLocaleLowerCase();return a.endsWith(M4)?n:a.endsWith(fGe)?`${n.slice(0,n.length-16).trimEnd()}${M4}`:`${n}${M4}`}r(eJ,"connectionNameForGrantKind");function xGe(e){switch(e){case"active":return"Connected";case"needs_reauthorization":return"Needs attention";case"expired":return"Expired";case"revoked":return"Revoked";default:return"Not connected"}}r(xGe,"grantStatusLabel");function gGe(e){switch(e){case"active":return"connected";case"needs_reauthorization":case"expired":return"attention";case"revoked":return"inactive";default:return"missing"}}r(gGe,"grantStatusTone");function bGe(e,s={}){const n=e?.providerTenant?.name?.trim();return n||(e?.kind==="user"?s.subjectLabel?.trim()||"Connected account":e?.kind==="agent"?s.subjectLabel?.trim()||"Dedicated account":"Shared credential")}r(bGe,"grantAccountLabel");function vGe(e){return new Set((e?.members??[]).filter(s=>s.subjectType==="user").map(s=>s.subjectId))}r(vGe,"audienceUserIds");function yGe(e){return e.find(s=>s.kind==="organization"&&s.isDefault)??e.find(s=>s.kind==="organization")??null}r(yGe,"organizationGrant");function jGe(e,s){return s?e.find(n=>n.kind==="user"&&n.subjectUserId===s)??null:null}r(jGe,"personalGrantFor");function wGe(e,s){if(!s)return null;const n=e.find(a=>a.userId===s);return n&&(n.name?.trim()||n.email?.trim())||null}r(wGe,"memberLabel");var tJ=0;function DF(){return tJ+=1,{id:`header-${tJ}`,name:"",value:""}}r(DF,"newCustomHeaderRow");function vS(e){try{return new URL(e).host||null}catch{return null}}r(vS,"endpointHost");function NGe(e=window.location.origin){const s=new URL("/api/tools/oauth/callback",e),n=s.hostname.toLowerCase().replace(/^\[|\]$/g,"");return s.protocol==="http:"&&(n==="127.0.0.1"||n==="::1")&&(s.hostname="localhost"),s.toString()}r(NGe,"oauthCallbackUrlForBrowser");function D4(e){try{const s=new URL(e);return`${s.host.replace(/^www\./,"")}${s.pathname==="/"?"":s.pathname.replace(/\/+$/,"")}`.slice(0,160)||null}catch{return null}}r(D4,"defaultGenericMcpName");function sJ(e,s){const n=s?.trim()||"Paperclip couldn't connect to that address. Check it and try again.";switch(e){case"mcp_remote_url_missing":case"mcp_remote_url_invalid":return{title:"That doesn't look like a server address",body:"Paste the full address, starting with https:// — for example https://mcp.example.com/mcp.",focus:"url"};case"remote_http_private_endpoint":return{title:"That address is inside a private network",body:"This Paperclip is reachable from the internet, so it won't call addresses on your local network. Use the server's public address instead.",focus:"url"};case"remote_http_dns_failed":return{title:"We couldn't find that host",body:"The address didn't resolve. Check the spelling, or confirm the server is published on the internet.",focus:"url"};case"mcp_header_rejected":return{title:"Paperclip can't send that header",body:n,focus:"credentials"};case"tool_access_name_conflict":return{title:"Paperclip couldn’t name this connection",body:"Try connecting again.",focus:"none"};case"oauth_challenge":return{title:"This server wants a credential",body:"It asked us to authenticate but didn't offer a sign-in Paperclip can complete on its own. Add the key or headers its docs list under Advanced authentication.",focus:"credentials"};case"oauth_manual_client_required":case"oauth_manual_client_rebinding_required":return{title:"This server needs sign-in details you create yourself",body:"Register Paperclip in the provider's settings, then add the client ID and secret it gives you under Advanced authentication.",focus:"credentials"};case"oauth_redirect_origin_unsupported":case"oauth_redirect_uri_invalid":return{title:"This Paperclip needs a public HTTPS address first",body:"Sign-in sends the operator back to Paperclip, so this instance has to be reachable over HTTPS. Ask your Paperclip admin to configure it.",focus:"deployment"};case"runtime_error":return{title:"We couldn't reach that server",body:"Nothing answered at that address. Confirm the server is running and the address is right, then try again.",focus:"url"};default:return{title:"Paperclip couldn't connect",body:n,focus:"none"}}}r(sJ,"genericConnectGuidance");function yxe(e){const s=new Set;for(const n of e){const a=n.name.trim();if(!a&&!n.value.trim())continue;const i=$_e(a);if(!i.ok)return $W(a,i.reason);const o=G_e(n.value);if(!o.ok)return $W(a,o.reason);if(!n.value.trim())return`Add a value for "${a}", or remove the row.`;const l=a.toLowerCase();if(s.has(l))return`"${a}" is listed twice.`;s.add(l)}return null}r(yxe,"customHeaderError");function kGe(e){const s={},n=e.keyValue.trim();if((e.authMode==="bearer"||e.authMode==="auto"&&e.needsKey)&&n&&(s["credentials.authorization"]=n),e.authMode==="custom_headers")for(const l of e.headers){const c=l.name.trim();!c||!l.value.trim()||(s[`headers.${c}`]=l.value)}const a=e.name.trim(),i=e.oauthClientId.trim(),o=e.oauthClientSecret.trim();return{link:e.link,...a?{name:a}:{},...e.authMode==="auto"?{}:{authMode:e.authMode},...Object.keys(s).length>0?{credentialValues:s}:{},...e.authMode==="oauth"&&i?{oauthClient:{clientId:i,...o?{clientSecret:o}:{}}}:{}}}r(kGe,"genericConnectPayload");function SGe(e){return e.link.trim()?e.authMode==="auto"?!e.needsKey||e.keyValue.trim().length>0:e.authMode==="bearer"?e.keyValue.trim().length>0:e.authMode==="custom_headers"?e.headers.filter(s=>s.name.trim()&&s.value.trim()).length>0&&yxe(e.headers)===null:!0:!1}r(SGe,"canSubmitGenericConnect");function fw(e){const s=new Set;let n=!1;for(const a of e??[])a.targetType==="company"?n=!0:a.targetType==="agent"&&s.add(a.targetId);return{onAll:n,agentIds:s}}r(fw,"installStateFrom");function jxe(e,s){return e.onAll||e.agentIds.has(s)}r(jxe,"isAgentInstalled");function wxe(e,s){return s.onAll?[{targetType:"company",targetId:e}]:[...s.agentIds].map(n=>({targetType:"agent",targetId:n}))}r(wxe,"installPayload");var CGe="Has access — tick to load its tools into this agent's context.";function Nxe(e){return`paperclip.connector-enrollment-access:${e}`}r(Nxe,"enrollmentAccessStorageKey");function _Ge(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const s=e;if(typeof s.companyId!="string"||!s.companyId.trim()||!(s.grantKind==="user"||s.grantKind==="agent"||s.grantKind==="organization")||s.installChoice!=="specific"&&s.installChoice!=="all"||!Array.isArray(s.agentIds)||s.agentIds.some(a=>typeof a!="string"||!a.trim()))return!1;const n=new Set(s.agentIds);return n.size!==s.agentIds.length?!1:s.grantKind==="agent"?s.installChoice==="specific"&&n.size===1:s.installChoice==="all"?n.size===0:n.size>0}r(_Ge,"validEnrollmentAccessState");function IGe(e,s,n){try{window.sessionStorage.setItem(Nxe(s),JSON.stringify({...n,companyId:e}))}catch{}}r(IGe,"saveEnrollmentAccessState");function AGe(e){const s=Nxe(e);try{const n=window.sessionStorage.getItem(s);if(window.sessionStorage.removeItem(s),!n)return null;const a=JSON.parse(n);return _Ge(a)?a:null}catch{return null}}r(AGe,"consumeEnrollmentAccessState");function nJ(e){if(!e)return null;try{const s=new URL(e);return s.protocol==="https:"&&s.hostname.toLowerCase()==="github.com"?s.toString():null}catch{return null}}r(nJ,"githubRecoveryUrl");function rJ(e,s){return e==="denied"?"Authorization was cancelled or declined. Your saved connection was not changed.":s==="github_installation_required"?"GitHub access is required. Install Paperclip and grant at least one repository, then try again.":"Authorization did not complete. Your saved connection is still here, so you can try again."}r(rJ,"oauthCallbackErrorMessage");var RGe={access:"access",key:"setup",success:"complete"};function aJ(e){return e.requestedAppKey?e.resumeConnectionId||e.routeStage==="setup"?"key":"access":e.hasPrefilledLink||e.zapierSource?"access":"gallery"}r(aJ,"requestedConnectionInitialStep");function TGe(e){const s=e.galleryApps.find(a=>a.slug===e.requestedAppKey);if(s)return s;if(!e.reconnectConnection)return null;const n=e.applications.find(a=>a.id===e.reconnectConnection?.applicationId);return Sx(n)!==e.requestedAppKey?null:J6(e.requestedAppKey)}r(TGe,"requestedConnectionEntry");function EGe(e){return!e.reconnectConnection||!e.reconnectApplication||e.reconnectConnection.applicationId!==e.reconnectApplication.id?!1:e.requestedAppKey?Sx(e.reconnectApplication)===e.requestedAppKey:e.byo&&e.applicationId===e.reconnectApplication.id}r(EGe,"retainedReconnectMatches");function PGe(e){return e.credentialSource==="vercel_connect"&&!e.available&&!e.retainedReconnectMatches}r(PGe,"isVercelConnectUnavailable");function MGe(e){return e.available===!1&&!(e.reconnectConnectionId&&e.reconnectSourceMatches)}r(MGe,"isConnectionDefinitionUnavailable");function DGe(e){return!e.hasRequestedEntry||e.supportedMethodCount===0||e.unsupportedOAuth||e.vercelUnavailable||e.definitionUnavailable?e.reconnectConnectionId?"reconnect_unavailable":"fallback":"ready"}r(DGe,"requestedConnectionSetupResolution");function iJ(e,s,n,a){const i=RGe[s]??"setup",o=new URLSearchParams({source:e,stage:i});return a?.resumeConnectionId&&o.set("resume",a.resumeConnectionId),a?.reconnectConnectionId&&o.set("reconnect",a.reconnectConnectionId),a?.interactionId&&o.set("intent",a.interactionId),a?.connectionMethodKey&&o.set("method",a.connectionMethodKey),`${n==="vercel_connect"?"/apps/vercel-connect":"/apps/connect"}?${o.toString()}`}r(iJ,"appConnectHref");function mI(e,s){if(!s)return e;const[n,a=""]=e.split("?",2),i=new URLSearchParams(a);return i.set("intent",s),`${n}?${i.toString()}`}r(mI,"withConnectionIntent");var oJ=["Pick app","Access","Add your key"],lJ={gallery:0,access:1,key:2},LGe={access:0,key:1},$Ge=["Access","Add MCP URL"],OGe=["Access","Sign in"];function L4(e,s=!1){return s&&e?.auth!=="none"&&(!e?.grantKinds||e.grantKinds.includes("user"))?"user":e?.grantKinds?.length===1||e?.grantKinds&&!e.grantKinds.includes("organization")?e.grantKinds[0]:"organization"}r(L4,"defaultGrantKindFor");function FGe(e){const s=e.config?.oauth;if(!s||typeof s!="object"||Array.isArray(s))return;const n=s.connectorSubjectAgentId;return typeof n=="string"?n:void 0}r(FGe,"configuredAgentIdentity");function Mk(e,s){const n=typeof s=="string"?s:s?.key;return e?.slug==="google-sheets"&&n==="local"}r(Mk,"isGoogleSheetsRobotMethod");function XN(e){return e?Object.fromEntries([...e.tenantFields??[],...e.extensionFields??[]].filter(s=>s.defaultValue!==void 0).map(s=>[s.key,s.defaultValue])):{}}r(XN,"defaultMethodConfig");function Ky(e,s){if(!e)return[];const n=M1(e);return s==="vercel_connect"?n.filter(a=>!!a.credentialSources?.vercelConnect):n}r(Ky,"connectionMethodsForCredentialSource");function M1(e){return Xoe(e).filter(s=>(s.purpose??"tool")!=="channel")}r(M1,"availableToolConnectionMethods");function hI(e,s){const n=M1(e);return s?n.find(a=>a.key===s)??null:Z6(n)}r(hI,"availableToolConnectionMethod");function Ij(e){const s=Z6(e);return e.length===1||s?.capabilityProfile||s?.grantKinds?.includes("agent")?s:null}r(Ij,"recommendedSetupConnectionMethod");function cJ(e){return Ij(e?e.methods.filter(s=>(s.purpose??"tool")==="tool"&&(s.oauthStrategy==="paperclip_cloud_connector"||s.oauthStrategy==="paperclip_id_connector")):[])}r(cJ,"recommendedManagedConnectorMethod");function dJ(e){if(!e)return!1;const s=M1(e),n=s.length===1?s[0]:null;return!!(n&&Fp(n)&&!CIe(n))}r(dJ,"canUseAutomaticOAuthFastPath");function uJ(e){if(!e)return null;const s=M1(e),n=s.length===1?s[0]:null;return n&&Fp(n)?n:null}r(uJ,"automaticOAuthMethod");function BGe(e){const s=e.metadata;if(!s)return null;const n=s.sourceTemplateKey??s.galleryKey;return typeof n=="string"?n:null}r(BGe,"appSourceSlug");function qGe(e){const s=e.config?.sourceTemplateKey??e.transportConfig.sourceTemplateKey;return typeof s=="string"?s:null}r(qGe,"connectionSourceSlug");function mJ(e,s,n,a={}){if(!e)return null;const i=new Set(s.filter(o=>o.status!=="archived"&&BGe(o)===e&&(!a.applicationId||o.id===a.applicationId)).map(o=>o.id));return n.find(o=>{const l=a.applicationId?o.applicationId===a.applicationId:i.has(o.applicationId)||qGe(o)===e;return o.status!=="archived"&&(!a.draftOnly||o.status==="draft")&&o.authKind==="oauth"&&l})??null}r(mJ,"reusableOAuthConnection");function kxe(e,s,n){if(e.origin!==s||!e.data||typeof e.data!="object")return null;const a=e.data;return a.type!=="paperclip.connection-intent.oauth"||a.interactionId!==n?null:a.outcome==="connected"||a.outcome==="declined"||a.outcome==="failed"?a.outcome:null}r(kxe,"readConnectionIntentOAuthOutcome");function sE(e={}){const[s]=Ri(),n=ka(),{selectedCompanyId:a}=xs(),i=ghe(),o=e.interactionId||s.get("intent")||void 0,l=e.serviceSlug||s.get("source")||n.appKey||s.get("appKey"),c=(0,u.useMemo)(()=>{if(o&&pj(l))try{return sessionStorage.getItem(`paperclip:mcp-intent-draft:${a}:${o}`)}catch{}return null},[o,a,l]),d=e.configuredConnection?.id||s.get("resume")||s.get("reconnect")||c,m=!!(d&&(!l||pj(l))),h=ee({queryKey:["tools","connection",d],queryFn:r(()=>ms.getConnection(d),"queryFn"),enabled:m}),p=l||h.data?.config?.sourceTemplateKey,f=s.get("method")||h.data?.config?.connectionMethodKey;return m&&h.isPending?(0,t.jsx)("p",{className:"p-6 text-sm text-muted-foreground",children:"Loading connection…"}):m&&h.isError?(0,t.jsxs)("div",{role:"alert",className:"space-y-3 p-6",children:[(0,t.jsx)("p",{children:"Could not load this connection. Your saved access and credentials have not changed."}),(0,t.jsx)(F,{variant:"outline",onClick:r(()=>{h.refetch()},"onClick"),children:"Try again"})]}):!e.byoOnly&&(e.credentialSource??"paperclip_vault")==="paperclip_vault"&&pj(p)&&(!f||e2(p,f))?i.loaded?i.enabled?(0,t.jsx)(Wqe,{...e,interactionId:o,providerId:p,connection:h.data},`${o||"page"}:${p}`):(0,t.jsx)("p",{role:"status",className:"p-6 text-sm text-muted-foreground",children:"Enable MCP aggregators in Settings → Experimental to set up this connection."}):(0,t.jsx)("p",{className:"p-6 text-sm text-muted-foreground",children:"Loading connection settings…"}):(0,t.jsx)(zGe,{...e})}r(sE,"ConnectionSetupFlow");function zGe({byoOnly:e=!1,credentialSource:s="paperclip_vault",host:n="page",serviceSlug:a,requestedAgentId:i,interactionId:o,forceNewConnection:l=!1,existingConnections:c=[],configuredConnection:d,onUseExisting:m,onComplete:h,onOAuthDeclined:p,aiConnection:f,onPhaseChange:g,onCancel:v,renderCredentialStep:y}={}){const w=Hn(),S=(0,u.useCallback)(($e,Ft)=>{n==="page"&&(Ft?w($e,Ft):w($e))},[n,w]),j=ka(),{selectedCompany:N,selectedCompanyId:_}=xs(),{enabled:A}=Lx(),{setBreadcrumbs:C}=Ln(),{pushToast:I}=Pi(),[T]=Ri(),R=o?.trim()||T.get("intent")?.trim()||null,L=j.appKey??T.get("appKey")??void 0,O=T.get("source")?.trim()||null,$=l||T.get("new")==="1",E=T.get("stage")?.trim()||null,q=T.get("method")?.trim()||null,B=T.get("resume")?.trim()||null,K=T.get("oauth"),U=T.get("code"),D=nJ(T.get("installation_url")),V=nJ(T.get("management_url")),H=d?.id??(T.get("reconnect")?.trim()||null),J=T.get("identity")==="user"?"user":T.get("identity")==="organization"?"organization":null,X=s==="vercel_connect",le=a??O,ce=s==="paperclip_vault"&&uGe(le)?le:null,te=hGe({serviceSlug:a,appKey:L,sourceSlug:O}),re=(a??O??L)==="zapier",de=re?void 0:te,Z=!!d||n==="page"&&(e||T.get("byo")==="1"),[Y]=(0,u.useState)(()=>n==="page"&&T.get("cloud_connector")==="enrolled"&&de?AGe(de):null),[G]=(0,u.useState)(()=>{const $e=T.get("link")?.trim()??"";return{link:/^https?:\/\//i.test($e)?$e:"",name:d?.name??T.get("name")?.trim()??"",applicationId:d?.applicationId??(T.get("applicationId")?.trim()||void 0)}}),[fe,se]=(0,u.useState)(()=>aJ({requestedAppKey:de,routeStage:E,resumeConnectionId:B,hasPrefilledLink:!!G.link,zapierSource:re})),[ae,ie]=(0,u.useState)(null),[ue,pe]=(0,u.useState)(""),[be,oe]=(0,u.useState)(G.link),[je,_e]=(0,u.useState)(G.name||(re?"Zapier":"")),[xe,Ae]=(0,u.useState)(!1),[Ye,Oe]=(0,u.useState)(""),[Xe,me]=(0,u.useState)("auto"),[Le,mt]=(0,u.useState)(()=>[DF()]),[We,ze]=(0,u.useState)(""),[st,pt]=(0,u.useState)(""),[Pt,tt]=(0,u.useState)(!1),[ht,et]=(0,u.useState)(null),[Ie,Ne]=(0,u.useState)(!1),[Je,ft]=(0,u.useState)({}),[Ot,es]=(0,u.useState)(""),[bs,Ke]=(0,u.useState)(""),[Ve,dt]=(0,u.useState)(""),[Be,as]=(0,u.useState)(f&&f.mode!=="responsible_user"?`ai-${f.method}`:""),[Fe,Ut]=(0,u.useState)({}),[At,Ls]=(0,u.useState)(""),[qe,ut]=(0,u.useState)(null),[Dt,is]=(0,u.useState)(null),[Ts,jt]=(0,u.useState)({}),[we,Pe]=(0,u.useState)("all"),[at,Mt]=(0,u.useState)(new Set),[kt,hs]=(0,u.useState)(()=>new Set(Y?.agentIds??(i?[i]:[]))),[bt,Vt]=(0,u.useState)(Y?.grantKind??J??(i?"user":"organization")),[Wt,Me]=(0,u.useState)(Y?.installChoice??(i?"specific":"all")),Ee=!!(B&&(K==="failed"||K==="denied")),[He,Ue]=(0,u.useState)(Ee?"error":"entry"),[Gt,Nt]=(0,u.useState)(()=>Ee?rJ(K,U):null),[ts,ls]=(0,u.useState)(null),Tt=(0,u.useRef)(!1),ys=(0,u.useRef)(!1),ds=(0,u.useRef)(null),[Ys,dn]=(0,u.useState)(null),$n=(0,u.useRef)(null),[kn,Bs]=(0,u.useState)(null),[ks,or]=(0,u.useState)(null),Is=(0,u.useRef)(null),[Lr,jn]=(0,u.useState)(c.length>0&&!!m),[Yn,lr]=(0,u.useState)(null),[Cn,vr]=(0,u.useState)(null),[zr,Qr]=(0,u.useState)(null),rr=(0,u.useCallback)(()=>{n!=="dialog"||$n.current?.closed===!1||($n.current=window.open("about:blank","paperclip-connection-oauth","popup,width=720,height=760,resizable=yes,scrollbars=yes"))},[n]),gr=(0,u.useCallback)($e=>{if(n!=="dialog"){Nc($e);return}or($e);const Ft=$n.current;if(!Ft||Ft.closed){Ue("error"),Nt("Paperclip couldn’t open the sign-in window. Open sign-in in a new tab to continue."),g?.("needs_retry");return}Ft.location.assign($e),Ft.focus()},[n,g]),cr=(0,u.useCallback)(()=>{$n.current=null,Nt(null),Ue("redirecting"),g?.("authorizing")},[g]);(0,u.useEffect)(()=>{if(n!=="dialog"||He!=="redirecting")return;const $e=window.setInterval(()=>{$n.current?.closed&&(Ue("error"),Nt("The sign-in window closed. If authorization did not finish, try again."),or(null),g?.("needs_retry"))},1e3);return()=>window.clearInterval($e)},[n,He,g]);const Gr=(0,u.useCallback)(async $e=>{Is.current?.abort();const Ft=new AbortController;Is.current=Ft;try{const Ms=await pw($e,{signal:Ft.signal});if(Ms.kind==="reauthentication"){const mn=n==="dialog"?$n.current:window;if(!mn||mn.closed||!$e.handoff)throw new Error("Paperclip couldn’t preserve this sign-in while refreshing your account.");mC($e.handoff.session,mn.sessionStorage),Ue("starting")}else ls(Ms.host),Ue("redirecting");gr(Ms.url)}catch(Ms){if(Ft.signal.aborted)return;Ue("error"),Nt(Ms instanceof Error?Ms.message:"Paperclip couldn’t start secure sign-in. Try again."),g?.("needs_retry")}finally{Is.current===Ft&&(Is.current=null)}},[n,g,gr]);(0,u.useEffect)(()=>()=>Is.current?.abort(),[]),(0,u.useEffect)(()=>{if(n!=="dialog"||!R)return;const $e=r(Ft=>{const Ms=kxe(Ft,window.location.origin,R);if(Ms==="connected"){Ue("entry"),or(null),h?.({resolvedByCallback:!0});return}if(Ms==="declined"){Ue("error"),Nt("Authorization was cancelled. You can try again."),g?.("needs_retry");return}Ms==="failed"&&(Ue("error"),Nt("Authorization did not complete. Try again when you’re ready."))},"receiveOAuthOutcome");return window.addEventListener("message",$e),()=>window.removeEventListener("message",$e)},[R,n,h,p]),(0,u.useEffect)(()=>{if(n!=="dialog"||R||!kn)return;let $e=!1,Ft=!1;const Ms=window.setInterval(async()=>{if(Ft||$e)return;const mn=$n.current;if(!mn||mn.closed){Bs(null),Ue("error"),Nt("The sign-in window closed. Try again to finish connecting GitHub.");return}let Br;try{Br=new URL(mn.location.href)}catch{return}if(!(Br.origin!==window.location.origin||!Br.pathname.includes(kn))){if(Br.searchParams.has("oauth")){Bs(null),Ue("error"),Nt("Authorization did not complete. Finish setup in the sign-in window or try again.");return}if(Br.searchParams.get("success")==="1"){Ft=!0;try{const za=await ms.getConnection(kn);!$e&&za.status==="active"&&(Bs(null),mn.close(),h?.({connectionId:za.id}))}catch{$e||(Bs(null),Ue("error"),Nt("Could not confirm the connection. Try again."))}finally{Ft=!1}}}},1e3);return()=>{$e=!0,window.clearInterval(Ms)}},[R,kn,n,h]);const Dn=r(()=>{me("auto"),mt([DF()]),ze(""),pt(""),tt(!1),et(null),Ne(!1)},"resetGenericAuthState"),Rr=r($e=>{if(n==="page"&&!R&&s==="paperclip_vault"&&pj($e.slug)){S(`/apps/connect?source=${$e.slug}`);return}if($e.slug==="zapier"){ie(null),pe(""),oe(""),_e("Zapier"),Ae(!1),Oe(""),Dn(),ft({}),is(null),se("access"),S(mI("/apps/connect?source=zapier",R));return}if(s==="paperclip_vault"&&dJ($e)){S(MF($e.slug,R));return}ie($e),pe($e.name),oe(""),_e(""),Ae(!1),Oe(""),Dn(),ft({}),es(""),Ke(""),dt("");const Ft=Ij(Ky($e,s));as(Ft?.key??""),Ut(XN(Ft)),Ls(""),ut(null),is(null),hs(new Set(i?[i]:[])),Me(i?"specific":"all"),Vt(er??L4(Ft,!!i)),se("access"),S(s==="vercel_connect"?mI(P4($e.slug),R):MF($e.slug,R))},"useMatchedGalleryEntry"),la=r(()=>{se("gallery"),S(mI(s==="vercel_connect"?P4():e?"/apps/byo":"/apps",R))},"backToGallery");(0,u.useEffect)(()=>{if(n==="page")return C([{label:"Connectors",href:"/apps"},{label:X?"Vercel Connect":e?"Connect your own tool":"Connect an app"}]),()=>C([])},[e,n,C,X]);const _n=ee({queryKey:P.apps.gallery(_??"__none__"),queryFn:r(()=>ms.listGallery(_),"queryFn"),select:(0,u.useCallback)($e=>R?{...$e,apps:$e.apps.map(Ft=>({...Ft,methods:Ft.methods.filter(Ms=>f?Ms.ai?.provider===f.provider&&(f.mode==="responsible_user"||Ms.ai.method===f.method):Ms.transport!=="runtime_auth")})).filter(Ft=>Ft.methods.length>0)}:$e,[R,f?.provider,f?.method,f?.mode]),enabled:!!_}),_s=(0,u.useMemo)(()=>(_n.data?.apps??[]).filter($e=>A||!$e.methods.some(Ft=>Ft.transport==="chat_sdk")||tE($e)),[_n.data,A]),ta=de?J6(de):null,Xn=!!ta?.methods.some($e=>$e.oauthStrategy==="paperclip_cloud_connector"||$e.oauthStrategy==="paperclip_id_connector"),gt=!!ae?.methods.some($e=>$e.oauthStrategy==="paperclip_cloud_connector"||$e.oauthStrategy==="paperclip_id_connector"),$s=ae&&Xn&&!gt?cJ(ta):null,[qs,Qe]=(0,u.useState)(null),Yt=ee({queryKey:["cloud-connector","enrollment"],queryFn:r(()=>ms.getCloudConnectorEnrollment(),"queryFn"),refetchInterval:qs?2e3:!1,enabled:!!(_&&Xn&&!gt)}),[an,Fs]=(0,u.useState)(null),Kn=(0,u.useCallback)(()=>{$n.current?.close(),$n.current=null,Qe(null)},[]),Nr=(0,u.useCallback)(()=>{!_||!de||IGe(_,de,{grantKind:bt,installChoice:Wt,agentIds:Wt==="specific"?[...kt]:[]})},[bt,kt,Wt,de,_]),ga=(0,u.useCallback)($e=>{const Ft=cT($e);if(!Ft.ok){Kn(),Fs(Ft.message);return}if(n==="dialog"){Qe(Ft.url);const Ms=$n.current;Ms&&!Ms.closed?(Ms.location.assign(Ft.url),Ms.focus()):Fs("Open authorization in a new tab to continue.");return}Nc(Ft.url)},[n,Kn]);(0,u.useEffect)(()=>{!qs||Yt.data?.status!=="active"||(Kn(),Fs(null),_n.refetch())},[qs,Yt.data?.status,_n.refetch,Kn]);const Vn=ke({mutationFn:r(()=>ms.startCloudConnectorEnrollment(_,N?.name,de?iJ(de,"key",s,{resumeConnectionId:B,reconnectConnectionId:H,interactionId:R})+(n==="dialog"?"&enrollment_host=dialog":""):void 0),"mutationFn"),onSuccess:r($e=>{if(!$e.verificationUrl){Kn(),Fs("Paperclip Cloud did not return an enrollment link. Try again.");return}ga($e.verificationUrl)},"onSuccess"),onError:r($e=>{Kn(),Fs($e instanceof Error?$e.message:"Paperclip couldn’t reach Paperclip Cloud. Try again.")},"onError")}),Qn=ee({queryKey:P.tools.applications(_??"__none__"),queryFn:r(()=>ms.listApplications(_),"queryFn"),enabled:!!_&&(!!ce||!!B||!!H),refetchOnMount:"always"}),ns=ee({queryKey:P.tools.connections(_??"__none__"),queryFn:r(()=>ms.listConnections(_),"queryFn"),enabled:!!_&&(!!ce||!!B||!!H),refetchOnMount:"always"}),on=(0,u.useMemo)(()=>l?null:mJ(ce,Qn.data?.applications??[],ns.data?.connections??[],$?{applicationId:G.applicationId,draftOnly:!0}:{}),[Qn.data,ns.data,$,ce,G.applicationId,l]),Hs=(0,u.useMemo)(()=>H?(ns.data?.connections??[]).find($e=>$e.id===H)??null:null,[ns.data,H]),Jt=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(!d||!ns.isFetchedAfterMount||!Hs||Jt.current===Hs.id)return;const $e=Hs.config?.url??Hs.transportConfig?.url??Hs.transportConfig?.serverUrl??Hs.config?.serverUrl;typeof $e!="string"||!/^https?:\/\//i.test($e)||(Jt.current=Hs.id,oe(Ft=>Ft||$e))},[d,ns.isFetchedAfterMount,Hs]);const As=(0,u.useMemo)(()=>Hs?(Qn.data?.applications??[]).find($e=>$e.id===Hs.applicationId)??null:null,[Qn.data,Hs]),Fn=EGe({requestedAppKey:de,byo:Z,applicationId:G.applicationId,reconnectConnection:Hs,reconnectApplication:As}),In=(0,u.useMemo)(()=>B?(ns.data?.connections??[]).find($e=>$e.id===B)??null:null,[ns.data,B]),Zn=In??Hs,er=Zn?Zn.credentialPolicy==="per_user"?"user":Zn.credentialPolicy==="per_agent"?"agent":"organization":J,na=In?.authKind==="oauth"?In:on,us=on?on.credentialPolicy==="per_user"?"user":on.credentialPolicy==="per_agent"?"agent":"organization":null,Os=er??us;(0,u.useEffect)(()=>{Os&&Vt(Os)},[Os]);const tn=(0,u.useMemo)(()=>be&&!ae?kR(be,_s):null,[ae,_s,be]),Bn=ae?hI(ae,Be||null):null,mr=Bn&&Fp(Bn)?Bn:uJ(ae),Ur=s==="paperclip_vault"&&mr?ae:null,Jn=s==="paperclip_vault"&&dJ(ae)?ae:null,ei=!!ce&&(!Qn.isFetchedAfterMount||!ns.isFetchedAfterMount),ye=r($e=>{se($e),ae&&S(iJ(ae.slug,$e,s,{connectionMethodKey:ae.methods.find(Ft=>Ft.key===Be)?.ai?Be:void 0,resumeConnectionId:B,reconnectConnectionId:H,interactionId:R}))},"setAppStep"),qt=ke({mutationFn:r($e=>ms.startOAuth($e.id,{asCurrentUser:$e.credentialPolicy==="per_user",...$e.credentialPolicy==="per_agent"?{asAgentId:FGe($e)??[...kt][0]}:{},...R?{interactionId:R}:{}}),"mutationFn"),onSuccess:r($e=>{Gr($e)},"onSuccess"),onError:r($e=>{const Ft=$e instanceof vn&&$e.body&&typeof $e.body=="object"?$e.body.details:null;Ue("error"),g?.("needs_retry"),Nt(Ft?.code==="invalid_grant"?"Your authorization expired or was revoked. Reconnect to continue.":$e instanceof Error?$e.message:"Paperclip couldn’t start secure sign-in. Try again.")},"onError")}),un=qt.mutate,Gn=(0,u.useCallback)($e=>{g?.("authorizing"),rr(),n==="dialog"&&!R&&Bs($e.id),un($e)},[un,g,rr,n,R]),An=r(async $e=>{if(i)return;const Ft=wxe(_,(Os??bt)!=="agent"&&Wt==="all"?{onAll:!0,agentIds:new Set}:{onAll:!1,agentIds:kt});await ms.putConnectionInstalls($e,Ft)},"applyAccessInstalls"),ba=Os??bt,Ba=ke({mutationFn:r(async $e=>{const Ft=$e??ae;let Ms;if(Ft){const mn=Os??bt,Br=hI(Ft,Be||null),za=Mk(Ft,Br)?qO(At).ids:[],qr=ue.trim(),So=eJ(qr||Ft.name,mn);Ms=await ms.connectApp(_,{galleryKey:Ft.slug,...Be?{connectionMethodKey:Be}:{},name:So,credentialSource:s,...s==="paperclip_vault"?{credentialValues:Je}:{},...s==="vercel_connect"?{vercelConnect:{connector:Ve.trim()}}:{},...Ot.trim()?{oauthClient:{clientId:Ot.trim(),...bs?{clientSecret:bs}:{}}}:{},configValues:Mk(Ft,Br)?{allowedSpreadsheetIds:za}:Object.keys(Fe).length>0?Fe:void 0,applicationId:G.applicationId,...B?{resumeConnectionId:B}:H?{reconnectConnectionId:H}:{},...mn!=="organization"?{grantKind:mn}:{},...mn==="agent"?{subjectAgentId:[...kt][0]}:{}})}else{const mn=kGe({link:be,name:je,authMode:Xe,needsKey:xe,keyValue:Ye,headers:Le,oauthClientId:We,oauthClientSecret:st}),Br=eJ(mn.name??D4(be)??"Custom app",ba);Ms=await ms.connectApp(_,{...mn,...H?{reconnectConnectionId:H}:{},...re||tn?.slug==="zapier"?{galleryKey:"zapier",connectionMethodKey:"generated-url"}:{},name:Br,applicationId:G.applicationId,...ba!=="organization"?{grantKind:ba}:{},...ba==="agent"?{subjectAgentId:[...kt][0]}:{}})}return Ms.auth?.kind==="oauth"&&!B&&!H&&await An(Ms.connectionId),Ms},"mutationFn"),onSuccess:r($e=>{if($e.auth?.kind==="oauth"){if(is($e),$e.auth.manualClientRequired){et(sJ("oauth_manual_client_required",null)),me("oauth"),tt(!0),Ne(!1);return}if(n==="dialog"||R){Ue("starting"),Ne(!ae),Gn($e.connection);return}const Ms=$e.auth.startUrl?.trim();if(!Ms){Ue("starting"),Ne(!0),Gn($e.connection);return}Ne(!0),Gr({authorizationUrl:Ms,handoff:$e.auth.handoff});return}et(null),is($e);const Ft={};for(const Ms of $e.actions.readOnly)Ft[Ms.catalogEntryId]=!0;for(const Ms of $e.actions.canMakeChanges)Ft[Ms.catalogEntryId]=!0;jt(Ft),It.mutate({result:$e,enabled:Ft})},"onSuccess"),onError:r($e=>{const Ft=$e instanceof vn&&$e.body&&typeof $e.body=="object"?$e.body.details:null;if(Ur){Ue("error"),g?.("needs_retry"),Nt(Ft?.code==="invalid_grant"?"Your authorization expired or was revoked. Reconnect to continue.":$e instanceof Error?$e.message:"Paperclip couldn’t start secure sign-in. Try again.");return}if(!ae&&be){const Ms=typeof Ft?.code=="string"?Ft.code:null,mn=sJ(Ms,$e instanceof Error?$e.message:null);et(mn),Ne(!1),mn.focus==="credentials"&&tt(!0);return}I({title:"Couldn’t connect",body:$e instanceof Error?$e.message:"Please check your key and try again.",tone:"error"})},"onError")}),ne=Ba.mutate,rt=(0,u.useCallback)($e=>{const Ft=$e??ae;(Ft?hI(Ft,Be||null):null)?.auth==="oauth"&&rr(),ne($e)},[Be,ae,ne,rr]);(0,u.useEffect)(()=>{if(!de||_n.isLoading||!_n.data||H&&(!ns.isFetchedAfterMount||!Qn.isFetchedAfterMount))return;const $e=TGe({requestedAppKey:de,galleryApps:_n.data.apps,reconnectConnection:Hs,applications:Qn.data?.applications??[]}),Ft=!!$e?.methods.some(Bi=>Bi.oauthStrategy==="paperclip_cloud_connector"||Bi.oauthStrategy==="paperclip_id_connector");if(Xn&&!Ft&&Yt.isLoading)return;const Ms=Ky($e,s),mn=f??(Hs?.connectionPurpose==="ai"?PW.safeParse(Hs.config?.ai).data:void 0),Br=Ms.find(Bi=>mn?Bi.ai?.provider===mn.provider&&(!("mode"in mn)||mn.mode!=="responsible_user")&&Bi.ai.method===mn.method:Bi.key===q)??(Xn&&!Ft?cJ(ta):null)??Ij(Ms),za=Ms.length===1?Ms[0]:null,qr=s==="paperclip_vault"&&!!uJ($e),So=PGe({credentialSource:s,available:_n.data.credentialSources?.vercelConnect.available===!0,retainedReconnectMatches:!!(H&&Fn)}),kr=Ms.length===1&&za?.auth==="oauth"&&!Fp(za)&&!yR(za),xo=MGe({available:$e?.availability?.available,reconnectConnectionId:H,reconnectSourceMatches:Fn}),Mi=DGe({reconnectConnectionId:H,hasRequestedEntry:!!$e,supportedMethodCount:Ms.length,unsupportedOAuth:kr,vercelUnavailable:So,definitionUnavailable:xo});if(Mi!=="ready"){if(ie(null),se("gallery"),Mi==="reconnect_unavailable"&&H){Qr(H);return}S(mI(s==="vercel_connect"?P4():"/apps/connect",R),{replace:!0});return}if(Qr(null),!!$e){if(ae?.slug!==$e.slug){ie($e),pe($e.name),oe(""),_e(""),Ae(!1),Oe(""),ft({}),es(""),Ke(""),dt(""),as(Br?.key??""),Ut(XN(Br)),Ls(""),ut(null),is(null);const Bi=Y?.companyId===_?Y:null;Vt(er??Bi?.grantKind??L4(Br,!!i)),hs(new Set(Bi?.agentIds??(i?[i]:[]))),Me(Bi?.installChoice??(i?"specific":"all")),se(aJ({requestedAppKey:de,routeStage:E,resumeConnectionId:B,hasPrefilledLink:!!G.link,zapierSource:re}))}else gt!==Ft&&(ie($e),as(Br?.key??""),Ut(XN(Br)));if(!(qr&&(!Qn.isFetchedAfterMount||!ns.isFetchedAfterMount))&&!(qr&&ys.current)&&qr&&(Qn.isError||ns.isError)){Ue("error"),Nt("Paperclip couldn’t check for an existing connection. Try again."),se("key");return}}},[f,q,Qn.isError,Qn.isFetchedAfterMount,Qn.data,ns.isError,ns.isFetchedAfterMount,Yt.data?.configured,Yt.isLoading,Be,s,ae?.slug,gt,_n.data,_n.isLoading,S,er,Hs,H,Fn,B,ta,de,i,Y,E,re]),(0,u.useEffect)(()=>{Hs?.connectionPurpose==="ai"&&fe==="access"&&se("key")},[Hs?.connectionPurpose,fe]),(0,u.useEffect)(()=>{ds.current=null,dn(null)},[B]),(0,u.useEffect)(()=>{if(!In||!ae||In.status!=="draft"||ds.current===In.id)return;const $e=In.config&&typeof In.config=="object"?In.config:{},Ft=typeof $e.sourceTemplateKey=="string"?$e.sourceTemplateKey:null;if(Ft&&Ft!==ae.slug)return;const Ms=typeof $e.connectionMethodKey=="string"?$e.connectionMethodKey:null,mn=Ms?Ky(ae,s).find(za=>za.key===Ms)??null:null;if(pe(In.name||ae.name),mn){as(mn.key);const za=$e.methodConfig&&typeof $e.methodConfig=="object"?$e.methodConfig:{};Ut({...XN(mn),...Object.fromEntries(Object.entries(za).filter(qr=>typeof qr[1]=="string"||typeof qr[1]=="boolean"))})}const Br=$e.oauth&&typeof $e.oauth=="object"?$e.oauth:null;Br?.clientRegistrationSource==="manual"&&typeof Br.clientId=="string"&&es(Br.clientId),K==="failed"||K==="denied"?(Ue("error"),Nt(rJ(K,U))):(Ue("entry"),Nt(null)),se("key"),ds.current=In.id,dn(In.id)},[s,ae,U,K,In]);const It=ke({mutationFn:r(async $e=>{const{result:Ft,enabled:Ms}=$e,mn=Object.entries(Ms).filter(([,kr])=>kr).map(([kr])=>kr),Br=new Set(Array.isArray(Ft.suggestedDefaults.askFirstRiskLevels)?Ft.suggestedDefaults.askFirstRiskLevels.filter(kr=>typeof kr=="string"):[]),za=Ft.actions.canMakeChanges.filter(kr=>Ms[kr.catalogEntryId]&&Br.has(kr.riskLevel)).map(kr=>kr.catalogEntryId),qr=Wt==="all"?"all_agents":{agentIds:Array.from(kt)},So=await ms.finishApp(_,Ft.connectionId,{enabledCatalogEntryIds:mn,askFirstCatalogEntryIds:za,access:qr,...i?{preserveExistingAccess:!0}:{}});return await An(Ft.connectionId),So},"mutationFn"),onSuccess:r(($e,Ft)=>{ye("success"),h?.({connectionId:Ft.result.connectionId})},"onSuccess"),onError:r($e=>{ye("access"),I({title:"Couldn’t finish setup",body:$e instanceof Error?$e.message:"Please try again.",tone:"error"})},"onError")});if(!_)return(0,t.jsx)("div",{className:"p-6 text-sm text-muted-foreground",children:"Select an organization to connect apps."});if((B||H)&&(ns.isError||Qn.isError))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Couldn’t load connection setup"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Paperclip couldn’t check the retained connection. The retained connection was not changed."}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",onClick:r(async()=>{const[$e,Ft]=await Promise.all([ns.refetch(),Qn.refetch()]);!$e.isError&&!Ft.isError&&(Nt(null),Ue("entry"))},"onClick"),children:"Try again"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]})]});if(B&&ns.isFetchedAfterMount&&!In)return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"This setup can’t be resumed"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"The saved connection no longer exists or is not available to this organization."}),(0,t.jsx)(F,{type:"button",variant:"outline",className:"mt-5",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]});if(H&&ns.isFetchedAfterMount&&Qn.isFetchedAfterMount&&(!Hs||!Fn))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"This connection can’t be reconnected"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:Hs?"This reconnect link does not match the retained connection's provider.":"The retained connection no longer exists or is not available to this organization."}),(0,t.jsx)(F,{type:"button",variant:"outline",className:"mt-5",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]});if((B||H)&&_n.isError)return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Couldn’t load connection setup"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Paperclip couldn’t load the provider details needed to restore this connection. The retained connection was not changed."}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",onClick:r(()=>{_n.refetch()},"onClick"),children:"Try again"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]})]});if(H&&zr===H)return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"This connection can’t be reconnected"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Paperclip no longer has a supported setup method for this retained connection. The retained connection was not changed."}),(0,t.jsx)(F,{type:"button",variant:"outline",className:"mt-5",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]});if(B&&(!ns.isFetchedAfterMount||_n.isLoading||!ae||Ys!==In?.id))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl space-y-4","aria-label":"Loading saved connection setup",children:[(0,t.jsx)(bn,{className:"h-8 w-48"}),(0,t.jsx)(bn,{className:"h-40 w-full rounded-xl"})]});if(H&&(!ns.isFetchedAfterMount||!Qn.isFetchedAfterMount||_n.isLoading||de&&!ae))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl space-y-4","aria-label":"Loading retained connection setup",children:[(0,t.jsx)(bn,{className:"h-8 w-48"}),(0,t.jsx)(bn,{className:"h-40 w-full rounded-xl"})]});if(Lr&&m)return(0,t.jsxs)("div",{className:"max-w-5xl","data-testid":"connection-existing-choice",children:[(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsxs)("h1",{className:"text-2xl font-bold tracking-tight",children:["Use an existing ",de?"connection":"app connection"]}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Reuse a connection without changing who already has access, or connect a new one."})]}),(0,t.jsx)(pU,{choices:c.map($e=>({id:$e.id,name:$e.name,description:$e.status==="active"&&$e.enabled?"Ready to use":"Setup needs attention"})),pendingId:Yn,onSelect:r(async $e=>{lr($e),vr(null);try{await m($e)}catch(Ft){vr(Ft instanceof Error?Ft.message:"Couldn’t use this connection."),lr(null)}},"onSelect")}),Cn?(0,t.jsx)(Ja,{tone:"danger",className:"mt-4",children:Cn}):null,(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>jn(!1),"onClick"),children:d?"Review connection setup":"Connect new"}),v?(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:v,children:"Cancel"}):null]})]});const Ns=!!(Ur&&fe==="key"&&(Jn||He!=="entry")),Qs=!!(fe==="key"&&ae&&Xn&&!gt&&Yt.data?.configured===!0),sn=!!(fe==="key"&&ae&&Xn&&!gt&&(Yt.isLoading||Yt.isError||Yt.data?.configured!==!0));if(Ns&&Ur)return(0,t.jsx)(LF,{entry:Ur,resuming:!!B,phase:He,error:Gt,recoveryActions:U==="github_installation_required"?{installationUrl:D,managementUrl:V}:void 0,authorizationHost:ts,authorizationUrl:ks,onOpenAuthorization:cr,onRetry:r(async()=>{Nt(null),Ue("starting");const $e=Dt?.connection??na;if($e){Gn($e);return}ys.current=!0;try{const[Ft,Ms]=await Promise.all([Qn.refetch(),ns.refetch()]);if(Ft.isError||Ms.isError){Ue("error"),Nt("Paperclip couldn’t check for an existing connection. Try again.");return}const mn=(B?(Ms.data?.connections??[]).find(Br=>Br.id===B&&Br.authKind==="oauth")??null:null)??mJ(ce,Ft.data?.applications??[],Ms.data?.connections??[],$?{applicationId:G.applicationId,draftOnly:!0}:{});if(!Tt.current&&!B){mn&&Vt(mn.credentialPolicy==="per_user"?"user":mn.credentialPolicy==="per_agent"?"agent":"organization"),Ue("entry"),Nt(null),se("access");return}mn?Gn(mn):Ba.mutate(Ur)}finally{ys.current=!1}},"onRetry"),onBack:r(()=>{Is.current?.abort(),Ue("entry"),Nt(null),ye("access")},"onBack"),onCancel:r(()=>{Is.current?.abort(),(v??(()=>S("/apps")))()},"onCancel")});if(Ie&&!ae&&be&&fe==="key")return(0,t.jsx)(LF,{identity:{name:je.trim()||vS(be)||"this server",unverifiedHost:vS(be)},steps:{labels:oJ,activeIndex:lJ.key},phase:He,error:Gt,authorizationHost:ts,authorizationUrl:ks,onOpenAuthorization:cr,onRetry:r(()=>{Nt(null);const $e=Dt?.connection;if($e){Ue("starting"),Gn($e);return}Ne(!1),Ue("entry")},"onRetry"),onBack:r(()=>{Is.current?.abort(),Ne(!1),Ue("entry"),Nt(null)},"onBack"),onCancel:r(()=>{Is.current?.abort(),(v??(()=>S("/apps")))()},"onCancel")});const ca=Dt?.application.name??ae?.name??(je.trim()||D4(be)||"this app"),$t=Ky(ae,s),rs=$s?[$s]:$t,ln=X?_s.filter($e=>Ky($e,s).length>0):_s,Yr=re?_n.data?.apps.find($e=>$e.slug==="zapier")??null:null,On=(Hs?.connectionPurpose==="ai"?PW.safeParse(Hs.config?.ai).data:void 0)??ae?.methods.find($e=>$e.key===Be)?.ai??(!Be&&ae?.methods.every($e=>$e.ai)?ae.methods[0]?.ai:void 0),qa=ae?y?.({app:ae,name:ue||ae.name,grantKind:ba,agentIds:[...kt],allAgents:Wt==="all",onBack:r(()=>ye("access"),"onBack")})??(On&&_?(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(TT,{companyId:_,provider:On.provider,fixedMethod:!!(f&&f.mode!=="responsible_user"),initialMethod:Hs?.connectionPurpose==="ai"?(Hs.config?.ai).method:On.method,connectionId:Hs?.connectionPurpose==="ai"?Hs.id:void 0,name:Hs?.connectionPurpose==="ai"?Hs.name:ue||`My ${ae.name} ${On.method==="subscription"?"subscription":"API"}`,ownership:(Hs?.connectionPurpose==="ai"?Hs.credentialPolicy==="shared":ba==="organization")?"shared":"personal",agentIds:[...kt],allAgents:Wt==="all",onCancel:r(()=>v?v():S("/apps"),"onCancel"),onComplete:r($e=>{h?.({connectionId:$e.connectionId}),h||S(`/apps/${$e.connectionId}/permissions`)},"onComplete")})}):void 0):void 0,ri=Hs?.connectionPurpose==="ai"?["Reconnect account"]:qa!==void 0?["Access","Connect account"]:re?$Ge:ae&&rs.length>1?["Access","Choose connection"]:ae&&rs[0]?.auth==="oauth"?["Access","Sign in"]:Mk(ae,Be)?["Access","Share sheet"]:ae?["Access","Add your key"]:oJ,pi=ae?Be?rs.find($e=>$e.key===Be)??null:rs[0]??null:null,Si=ae?pi?.auth??"none":Xe==="none"?"none":Xe==="oauth"?"oauth":"api_key",to=!!Jn,ai=to?`Continue to ${ae?.name??"sign-in"}`:Si==="oauth"?"Continue":"Save and continue",Te=Hs?.connectionPurpose==="ai"?0:(re||ae)&&fe!=="gallery"&&fe!=="success"?LGe[fe]:fe==="success"?ri.length:lJ[fe];return(0,t.jsxs)("div",{className:"max-w-5xl",children:[fe!=="success"&&!(e&&fe==="gallery")&&(0,t.jsx)(mK,{subtitle:fe==="gallery"?X?"Choose a reviewed app to connect through Vercel.":"Pick the app you want your agents to use.":`Step ${Te+1} of ${ri.length}`,step:fe,activeIndex:Te,labels:ri,appIdentity:re?{name:"Zapier",logoUrl:Yr?.branding.logoUrl??null,darkLogoUrl:Yr?.branding.darkLogoUrl??null}:ae&&fe!=="gallery"?{name:ae.name,logoUrl:ae.branding.logoUrl,darkLogoUrl:ae.branding.darkLogoUrl??null}:void 0,unverifiedHost:!ae&&!re&&fe!=="gallery"?vS(be):null,onCancel:v??(()=>S("/apps"))}),fe==="gallery"&&(0,t.jsx)(KGe,{loading:_n.isLoading,initialLink:be,apps:ln,vercelConnect:X,vercelConnectAvailability:_n.data?.credentialSources?.vercelConnect??null,byo:Z,byoOnly:e,source:T.get("source"),onPick:Rr,onUseLink:r($e=>{const Ft=kR($e,_s);ie(null),pe(""),oe($e),_e(Ft?.name??D4($e)??""),Ae(!1),Oe(""),ft({}),Ls(""),ut(null),hs(new Set(i?[i]:[])),Me(i?"specific":"all"),Vt(er??(i?"user":"organization")),se("access")},"onUseLink")}),Qs&&ae?(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsxs)("h2",{className:"text-lg font-semibold text-foreground",children:[ae.name," sign-in is unavailable"]}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["This instance is connected to Paperclip, but ",ae.name," sign-in is not currently available. Try again shortly or contact your instance administrator."]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between gap-3",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:r(()=>ye("access"),"onClick"),children:"Back"}),(0,t.jsxs)(F,{type:"button",disabled:_n.isFetching,onClick:r(()=>{_n.refetch()},"onClick"),children:[_n.isFetching?(0,t.jsx)(it,{className:"h-4 w-4 animate-spin"}):null,"Try again"]})]})]}):fe==="key"&&ae&&sn?(0,t.jsx)("div",{className:"mx-auto max-w-xl",children:(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-card p-6",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"rounded-lg bg-muted p-2 text-muted-foreground",children:(0,t.jsx)(Hg,{className:"h-5 w-5"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Connect with Paperclip"}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["You must connect this instance to Paperclip to connect to ",ae.name," (you only need to do this once)."]})]})]}),Yt.isError||an?(0,t.jsx)(Ja,{tone:"danger",className:"mt-4",children:an??"Paperclip couldn’t check Cloud registration. Try again."}):null,qs?(0,t.jsxs)("p",{className:"mt-4 text-sm text-muted-foreground",children:["Finish authorization in the opened window."," ",(0,t.jsx)("a",{className:"underline",href:qs,target:"_blank",rel:"noopener noreferrer",children:"Open authorization in a new tab"})]}):null,(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between gap-3",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:r(()=>ye("access"),"onClick"),children:"Back"}),(0,t.jsxs)(F,{type:"button",disabled:Yt.isLoading||Vn.isPending,onClick:r(()=>{Fs(null),rr(),Nr(),Vn.mutate()},"onClick"),children:[Vn.isPending?(0,t.jsx)(it,{className:"h-4 w-4 animate-spin"}):null,Yt.data?.status==="pending"?"Continue":"Connect with Paperclip"]})]})]})}):fe==="key"&&ae&&qa!==void 0?qa:fe==="key"&&ae?(0,t.jsx)(WGe,{entry:ae,error:Ba.isError?Ba.error instanceof Error?Ba.error.message:"Please check your key and try again.":null,values:Je,onChange:ft,oauthClientId:Ot,onOAuthClientIdChange:es,oauthClientSecret:bs,onOAuthClientSecretChange:Ke,credentialSource:s,vercelConnector:Ve,onVercelConnectorChange:dt,vercelConnectAvailability:_n.data?.credentialSources?.vercelConnect??null,methodKey:Be,onMethodChange:r($e=>{as($e?.key??""),!er&&$e?.grantKinds&&!$e.grantKinds.includes(bt)&&Vt(L4($e,!!i)),ft({}),es(""),Ke(""),dt(""),Ut(XN($e))},"onMethodChange"),configValues:Fe,onConfigChange:Ut,googleSheetsLinks:At,googleSheetsError:qe,onGoogleSheetsLinksChange:r($e=>{Ls($e),ut(null)},"onGoogleSheetsLinksChange"),submitting:Ba.isPending,onBack:r(()=>ye("access"),"onBack"),onConnect:r(()=>{if(Mk(ae,Be)){const Ms=qO(At);if(Ms.invalidCount>0){ut("That doesn't look like a Google Sheets link.");return}if(Ms.ids.length===0){ut("Paste at least one Google Sheets link.");return}}const $e=hI(ae,Be||null),Ft=!!($e?.credentialFields?.length||$e?.tenantFields?.some(Ms=>!Ms.hidden)||$e?.extensionFields?.some(Ms=>!Ms.hidden));if($e&&Fp($e)&&na&&!Ft&&!Ot.trim()){Tt.current=!0,Nt(null),Ue("starting"),Gn(na);return}$e&&Fp($e)&&(Tt.current=!0,Nt(null),Ue("starting")),rt()},"onConnect")}):null,fe==="key"&&!ae&&be&&!re&&(0,t.jsx)(VGe,{link:be,name:je,needsKey:xe,onNeedsKeyChange:r($e=>{Ae($e),$e||Oe("")},"onNeedsKeyChange"),keyValue:Ye,onKeyChange:Oe,authMode:Xe,onAuthModeChange:r($e=>{me($e),et(null),$e!=="auto"&&Ae(!1),$e!=="bearer"&&$e!=="auto"&&Oe("")},"onAuthModeChange"),headers:Le,onHeadersChange:r($e=>{mt($e),et(null)},"onHeadersChange"),oauthClientId:We,onOAuthClientIdChange:ze,oauthClientSecret:st,onOAuthClientSecretChange:pt,advancedOpen:Pt,onAdvancedOpenChange:tt,guidance:ht,matchedEntry:tn,onUseMatchedEntry:tn?()=>Rr(tn):void 0,submitting:Ba.isPending||Ie,onBack:r(()=>se("access"),"onBack"),onConnect:r(()=>{et(null),Ba.mutate(void 0)},"onConnect")}),fe==="key"&&!ae&&re&&(0,t.jsx)(UGe,{link:be,onLinkChange:oe,submitting:Ba.isPending,onBack:r(()=>se("access"),"onBack"),onConnect:r(()=>Ba.mutate(void 0),"onConnect")}),fe==="access"&&(0,t.jsxs)(t.Fragment,{children:[ae?.slug==="railway"&&(0,t.jsxs)("div",{className:"mb-6 space-y-3 text-sm text-muted-foreground",children:[(0,t.jsx)("p",{children:pi?.guidanceMd}),(0,t.jsx)("ul",{className:"list-disc space-y-2 pl-5",children:pi?.warnings?.map($e=>(0,t.jsx)("li",{children:$e},$e))})]}),(0,t.jsx)(Cxe,{companyId:_,authKind:Si,grantKinds:Os?[Os]:pi?.grantKinds,grantKind:ba,setGrantKind:Vt,installChoice:Wt,setInstallChoice:Me,installAgentIds:kt,setInstallAgentIds:hs,lockedAgentId:i,capabilities:_n.data?.capabilities,githubIdentity:ae?.slug==="github",submitLabel:ai,continuesToProvider:to,identityLoading:!!Ur&&ei,preserveAgentAccess:!!(Ur&&(na||Hs)),pending:Ba.isPending||qt.isPending||!!(de&&!ae),onBack:la,onContinue:r(()=>{if(Jn){Tt.current=!0,Nt(null),Ue("starting"),ye("key"),na?Gn(na):rt(Jn);return}ae?ye("key"):se("key")},"onContinue")})]}),fe==="success"&&(0,t.jsx)(GGe,{appName:ca,logoUrl:ae?.branding.logoUrl,darkLogoUrl:ae?.branding.darkLogoUrl,summary:QGe({grantKind:ba,authKind:Si,installChoice:Wt,installCount:kt.size,enabledCount:Object.values(Ts).filter(Boolean).length}),onDone:v??(()=>S("/apps"))})]})}r(zGe,"StandardConnectionSetupFlow");function mK({title:e,headingRef:s,subtitle:n,step:a,activeIndex:i,labels:o,appIdentity:l,unverifiedHost:c,onCancel:d}){return(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[l?(0,t.jsx)(yc,{name:l.name,logoUrl:l.logoUrl,darkLogoUrl:l.darkLogoUrl,size:44}):null,(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{ref:s,tabIndex:s?-1:void 0,className:"text-2xl font-bold tracking-tight outline-none",children:e??(l?`Connect ${l.name}`:"Connect your own MCP server")}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:n}),c?(0,t.jsx)(eE,{host:c,className:"mt-2"}):null]})]}),d&&(0,t.jsx)(F,{variant:"ghost",size:"sm",onClick:d,children:"Cancel"})]}),a!=="gallery"&&(0,t.jsxs)("nav",{className:"mt-4","aria-label":"Setup progress","data-testid":"wizard-stepper",children:[(0,t.jsx)("ol",{className:"flex gap-2","aria-hidden":"true",children:o.map((m,h)=>(0,t.jsx)("li",{"data-testid":"wizard-step-dot","data-step-active":h===i?"true":void 0,className:z("h-1 w-20 rounded-full",h<=i?"bg-foreground":"bg-border")},m))}),(0,t.jsx)("div",{className:"mt-2 text-xs text-muted-foreground","data-testid":"wizard-step-labels",children:o.join(" · ")})]})]})}r(mK,"StepHeader");function LF({entry:e,identity:s,resuming:n=!1,phase:a,error:i,recoveryActions:o,authorizationHost:l,authorizationUrl:c,steps:d={labels:OGe,activeIndex:1},onRetry:m,onOpenAuthorization:h,onBack:p,onCancel:f}){const g=e?.name??s?.name??"this server",v=e?null:s?.unverifiedHost??null,y=a==="entry"?{title:n?`Finish connecting ${g}`:`Connect ${g} to Paperclip`,body:n?`Your connection is saved. Continue in ${g} to approve access; its identity and agent access will stay the same.`:`Paperclip will open ${g} so you can choose a workspace and approve access.`}:a==="starting"?{title:"Preparing secure sign-in",body:`Paperclip is creating a secure ${g} connection.`}:a==="redirecting"?{title:`Opening ${g}`,body:l?`Continue at ${l} to choose a workspace and approve access. Only approve access if you recognize that address.`:`Continue in ${g} to choose a workspace and approve access.`}:{title:`${g} couldn’t connect`,body:i??"Paperclip couldn’t start secure sign-in. Try again."};return(0,t.jsxs)("div",{className:"max-w-5xl",children:[(0,t.jsx)(mK,{subtitle:"Secure MCP sign-in",step:"key",activeIndex:d.activeIndex,labels:d.labels,appIdentity:e?{name:e.name,logoUrl:e.branding.logoUrl,darkLogoUrl:e.branding.darkLogoUrl}:void 0,unverifiedHost:v,onCancel:f}),(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"mt-1 inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-lg border border-border bg-background",children:a==="error"?(0,t.jsx)(oc,{className:"h-5 w-5 text-destructive"}):a==="entry"?(0,t.jsx)(Md,{className:"h-5 w-5 text-muted-foreground"}):(0,t.jsx)(it,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h2",{className:"text-xl font-bold tracking-tight",children:y.title}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:y.body}),v?(0,t.jsx)(eE,{host:v,className:"mt-2"}):null]})]}),a==="error"&&o&&(o.installationUrl||o.managementUrl)?(0,t.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[o.installationUrl?(0,t.jsx)(F,{type:"button",variant:"outline",asChild:!0,children:(0,t.jsxs)("a",{href:o.installationUrl,target:"_blank",rel:"noreferrer",children:["Install Paperclip on GitHub",(0,t.jsx)(eo,{className:"ml-1.5 h-3.5 w-3.5"})]})}):null,o.managementUrl?(0,t.jsx)(F,{type:"button",variant:"ghost",asChild:!0,children:(0,t.jsx)("a",{href:o.managementUrl,target:"_blank",rel:"noreferrer",children:"Manage repositories on GitHub"})}):null]}):null,(0,t.jsxs)("div",{className:"mt-6 flex items-center gap-2",children:[a==="error"||a==="entry"?(0,t.jsx)(F,{type:"button",onClick:m,children:a==="entry"?n?`Finish with ${g}`:`Continue to ${g}`:"Try again"}):(0,t.jsx)(F,{type:"button",disabled:!0,children:a==="redirecting"?`Opening ${g}…`:"Preparing…"}),c?(0,t.jsx)(F,{variant:"outline",asChild:!0,children:(0,t.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",onClick:h,children:"Open sign-in in a new tab"})}):null,(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:p,children:"Back"})]})]})]})}r(LF,"OAuthConnectStateScreen");function UGe({link:e,onLinkChange:s,submitting:n,onBack:a,onConnect:i}){const o=$F(e),l=o?new URL(o).hostname:"",c=l==="zapier.com"||l.endsWith(".zapier.com");return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Zapier MCP URL"}),(0,t.jsx)(_t,{type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r(d=>s(d.target.value),"onChange"),onKeyDown:r(d=>{d.key==="Enter"&&c&&!n&&i()},"onKeyDown"),placeholder:"https://mcp.zapier.com/api/v1/connect?token=…",className:"mt-2 h-11",autoFocus:!0}),e.trim()&&!c&&(0,t.jsx)("p",{className:"mt-2 text-xs text-destructive",children:"Paste a valid Zapier URL to continue."})]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:a,disabled:n,children:"Back"}),(0,t.jsxs)(F,{onClick:i,disabled:n||!c,children:[n&&(0,t.jsx)(it,{className:"mr-2 h-4 w-4 animate-spin"}),n?"Checking…":"Check link"]})]})]})}r(UGe,"ZapierConnectStep");function KGe({loading:e,initialLink:s="",apps:n,byo:a=!1,byoOnly:i=!1,vercelConnect:o=!1,vercelConnectAvailability:l=null,source:c=null,onPick:d,onUseLink:m}){const[h,p]=(0,u.useState)(""),[f,g]=(0,u.useState)(s),v=(0,u.useRef)(!1);(0,u.useEffect)(()=>{v.current||g(s)},[s]);const[y,w]=(0,u.useState)(null),S=(0,u.useRef)(null),j=(0,u.useRef)(null),N=(0,u.useRef)(!1);(0,u.useEffect)(()=>{!a||e&&!i||N.current||(i||S.current?.scrollIntoView?.({block:"center"}),j.current?.focus(),j.current?.select(),N.current=!0)},[a,i,e]);const _=(0,u.useMemo)(()=>{const R=h.trim().toLowerCase();return n.filter(L=>!R||L.name.toLowerCase().includes(R))},[n,h]),A=$F(f),C=A?kR(A,n):null,I=c==="zapier",T=r(()=>{const R=$F(f);if(!R){w("Paste a full http or https link.");return}w(null),m(R)},"continueWithLink");return e&&!i?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((R,L)=>(0,t.jsx)(bn,{className:"h-32 w-full rounded-xl"},L))}):(0,t.jsxs)("div",{className:"space-y-6",children:[o?(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-bold tracking-tight",children:"Connect through Vercel"}),(0,t.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-muted-foreground",children:"Create and manage the provider connector in Vercel. Paperclip stores its reference and applies agent access, policy, approval, and audit controls here."})]}),l?(0,t.jsx)(F,{asChild:!0,variant:"outline",size:"sm",className:"shrink-0",children:(0,t.jsxs)("a",{href:l.manageUrl,target:"_blank",rel:"noreferrer",children:["Open Vercel Connect",(0,t.jsx)(eo,{className:"ml-2 h-3.5 w-3.5"})]})}):null]}),l?.available===!1?(0,t.jsx)(Ja,{tone:"danger",compact:!0,className:"mt-4",children:l.reason??"Vercel Connect is unavailable on this instance."}):null]}):null,!i&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(ha,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(_t,{value:h,onChange:r(R=>p(R.target.value),"onChange"),placeholder:"Search apps…",className:"h-11 pl-9"})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4",children:_.map(R=>{const L=vxe(R.slug,R.description),O=M1(R),$=O.length===0||O.every(q=>q.auth==="oauth"&&!Fp(q)&&!yR(q)),E=R.availability?.available===!1||o&&l?.available!==!0;return(0,t.jsxs)("button",{type:"button",disabled:$||E,title:E?R.availability?.reason??l?.reason??void 0:void 0,onClick:r(()=>d(R),"onClick"),className:z("flex flex-col rounded-xl border border-border bg-card p-4 text-left transition-colors",$||E?"cursor-not-allowed opacity-60":"hover:border-foreground/30 hover:bg-accent/40"),children:[(0,t.jsx)(yc,{name:R.name,logoUrl:R.branding.logoUrl,darkLogoUrl:R.branding.darkLogoUrl,size:36}),(0,t.jsx)("div",{className:"mt-3 text-sm font-bold text-foreground",children:R.name}),(0,t.jsx)("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:L.tagline}),(0,t.jsx)("div",{className:"mt-3 text-xs font-semibold text-foreground",children:E?(0,t.jsx)("span",{className:"text-muted-foreground",children:R.availability?.reason??l?.reason??"Unavailable on this instance."}):$?(0,t.jsx)("span",{className:"text-muted-foreground",children:"Unavailable"}):(0,t.jsx)("span",{children:"Connect →"})})]},R.slug)})}),_.length===0&&(0,t.jsxs)("div",{className:"py-10 text-center text-sm text-muted-foreground",children:["No apps match “",h,"”."]})]}),o?null:(0,t.jsxs)("div",{ref:S,className:z("grid gap-4 border-t border-border pt-5 md:grid-cols-(--gtc-13)",a&&"-mx-3 rounded-xl border border-primary/40 bg-primary/[0.04] px-3 pb-4 md:mx-0"),children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[(0,t.jsx)(oc,{className:"h-4 w-4 text-muted-foreground"}),I?"Connect Zapier":a?"Connect your own MCP server":"Connect with a link"]}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:I?"Paste the complete MCP URL Zapier gives you, including its token.":a?"Paste your MCP server’s URL and every discovered tool will be available immediately.":"Paste a setup link from an app that is not listed here."}),!I&&(0,t.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["Any remote tool URL works here — including a local MCP server like"," ",(0,t.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"http://127.0.0.1:8848/mcp"}),"."]}),C&&(0,t.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-3 rounded-lg border border-border bg-muted/40 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(yc,{name:C.name,logoUrl:C.branding.logoUrl,darkLogoUrl:C.branding.darkLogoUrl,size:24}),(0,t.jsxs)("span",{className:"truncate",children:["This looks like ",C.name,"."]})]}),(0,t.jsx)(F,{type:"button",size:"sm",variant:"outline",disabled:C.availability?.available===!1,onClick:r(()=>{if(w(null),C.slug==="zapier"){T();return}d(C)},"onClick"),children:C.availability?.available===!1?"Not available":C.slug==="zapier"?"Continue":`Use ${C.name}`})]})]}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-2 sm:min-w-(--sz-360px)",children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(_t,{ref:j,type:I||C?.slug==="zapier"?"password":"url",autoComplete:"off",spellCheck:!1,"aria-label":"MCP server URL",value:f,onChange:r(R=>{v.current=!0,g(R.target.value),w(null)},"onChange"),onKeyDown:r(R=>{R.key==="Enter"&&T()},"onKeyDown"),placeholder:I?"https://mcp.zapier.com/api/v1/connect?token=…":"https://example.com/actions",className:"h-10"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:T,children:"Continue"})]}),y&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:y})]})]})]})}r(KGe,"GalleryStep");function $F(e){try{const s=new URL(e.trim());return s.protocol!=="http:"&&s.protocol!=="https:"?null:s.toString()}catch{return null}}r($F,"normalizeAppLink");function VGe({link:e,name:s,needsKey:n,onNeedsKeyChange:a,keyValue:i,onKeyChange:o,authMode:l,onAuthModeChange:c,headers:d,onHeadersChange:m,oauthClientId:h,onOAuthClientIdChange:p,oauthClientSecret:f,onOAuthClientSecretChange:g,advancedOpen:v,onAdvancedOpenChange:y,guidance:w,matchedEntry:S,onUseMatchedEntry:j,submitting:N,onBack:_,onConnect:A}){const C=vS(e),I=l==="custom_headers"?yxe(d):null,T=SGe({link:e,name:s,authMode:l,needsKey:n,keyValue:i,headers:d,oauthClientId:h,oauthClientSecret:f}),R=l==="auto",L=S?.slug==="zapier"?mle(e):e,O=r(($,E)=>{m(d.map(q=>q.id===$?{...q,...E}:q))},"updateHeader");return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("p",{className:"min-w-0 truncate font-mono text-sm text-muted-foreground",title:L,children:L}),(0,t.jsx)(eE,{host:C})]}),S&&j?(0,t.jsxs)("div",{className:"mt-6 flex flex-wrap items-center justify-between gap-3 rounded-lg border border-border bg-muted/40 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(yc,{name:S.name,logoUrl:S.branding.logoUrl,darkLogoUrl:S.branding.darkLogoUrl,size:24}),(0,t.jsxs)("span",{className:"truncate",children:["Paperclip has a guided setup for ",S.name,"."]})]}),(0,t.jsxs)(F,{type:"button",size:"sm",variant:"outline",onClick:j,children:["Use ",S.name]})]}):null,w?(0,t.jsx)("div",{className:"mt-6",children:(0,t.jsx)(Ja,{tone:"warning",title:w.title,children:w.body})}):null,(0,t.jsxs)("div",{className:"mt-6 space-y-6",children:[R&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mr-2 text-sm font-medium text-foreground",children:"Does it need a key?"}),(0,t.jsxs)("div",{className:"mt-2 inline-flex rounded-lg border border-border bg-muted/50 p-1",children:[(0,t.jsx)($4,{label:"No",selected:!n,onClick:r(()=>a(!1),"onClick")}),(0,t.jsx)($4,{label:"Yes",selected:n,onClick:r(()=>a(!0),"onClick")})]}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:n?"Paste the key this app gave you.":"Most servers just work from the address — pick Yes only if the server gave you a key, or if it asks you to sign in."})]}),R&&n||l==="bearer"?(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"generic-mcp-key",children:"App key"}),(0,t.jsx)(_t,{id:"generic-mcp-key",type:"password",autoComplete:"off",value:i,onChange:r($=>o($.target.value),"onChange"),placeholder:"••••••••••••••••",className:"mt-2 h-11 font-mono"})]})}):null,(0,t.jsxs)(el,{open:v,onOpenChange:y,children:[(0,t.jsxs)(Wl,{className:"flex w-full items-center justify-between rounded-lg border border-border bg-background px-3 py-2 text-left text-sm font-medium text-foreground hover:bg-accent/40",children:["Advanced authentication",(0,t.jsx)(en,{className:z("h-4 w-4 text-muted-foreground transition-transform",v&&"rotate-180")})]}),(0,t.jsxs)(tl,{className:"space-y-5 pt-4",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Only needed when the server's docs are specific about how to authenticate."}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:hJ.map($=>(0,t.jsx)($4,{label:$.label,selected:l===$.mode,onClick:r(()=>c($.mode),"onClick")},$.mode))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:hJ.find($=>$.mode===l)?.hint}),l==="custom_headers"?(0,t.jsxs)("div",{className:"space-y-3",children:[d.map($=>(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(_t,{value:$.name,onChange:r(E=>O($.id,{name:E.target.value}),"onChange"),placeholder:"Header name","aria-label":"Header name",className:"h-10 font-mono"}),(0,t.jsx)(_t,{type:"password",autoComplete:"off",value:$.value,onChange:r(E=>O($.id,{value:E.target.value}),"onChange"),placeholder:"Value","aria-label":$.name.trim()?`Value for ${$.name.trim()}`:"Header value",className:"h-10 font-mono"}),(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",className:"h-10 shrink-0",onClick:r(()=>m(d.filter(E=>E.id!==$.id)),"onClick"),disabled:d.length===1,children:"Remove"})]},$.id)),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",onClick:r(()=>m([...d,DF()]),"onClick"),children:"Add another header"}),I?(0,t.jsx)("p",{className:"text-xs text-destructive",children:I}):null]}):null,l==="oauth"?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Paperclip sets sign-in up on its own whenever the server allows it. Only fill these in when the server's docs tell you to register Paperclip yourself first."}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"generic-mcp-client-id",children:"Client ID"}),(0,t.jsx)(_t,{id:"generic-mcp-client-id",value:h,onChange:r($=>p($.target.value),"onChange"),autoComplete:"off",placeholder:"Optional",className:"mt-2 h-11 font-mono"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"generic-mcp-client-secret",children:"Client secret"}),(0,t.jsx)(_t,{id:"generic-mcp-client-secret",type:"password",autoComplete:"off",value:f,onChange:r($=>g($.target.value),"onChange"),placeholder:"Optional",className:"mt-2 h-11 font-mono"})]})]}):null]})]})]}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:_,disabled:N,children:"Back"}),(0,t.jsxs)(F,{onClick:A,disabled:N||!T||!!I,children:[N&&(0,t.jsx)(it,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":"Check link"]})]})]})}r(VGe,"LinkConnectStep");var hJ=[{mode:"auto",label:"Let Paperclip check",hint:"Paperclip asks the server what it needs and walks you through it. Start here."},{mode:"none",label:"No sign-in needed",hint:"The server is open to anyone with the address."},{mode:"bearer",label:"Key or token",hint:"Paperclip sends your key as an Authorization header."},{mode:"custom_headers",label:"Custom headers",hint:"For servers that name their own headers. Values are stored as Paperclip secrets and can’t be read back."},{mode:"oauth",label:"Browser sign-in",hint:"You’ll sign in at the provider. Add a client ID and secret only if the provider requires you to register Paperclip first."}];function $4({label:e,selected:s,onClick:n}){return(0,t.jsx)("button",{type:"button",onClick:n,"aria-pressed":s,className:z("min-w-(--sz-64px) rounded-md px-4 py-1.5 text-sm font-medium transition-colors",s?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:e})}r($4,"SegmentedOption");function WGe({entry:e,error:s,values:n,onChange:a,oauthClientId:i,onOAuthClientIdChange:o,oauthClientSecret:l,onOAuthClientSecretChange:c,credentialSource:d,vercelConnector:m,onVercelConnectorChange:h,vercelConnectAvailability:p,methodKey:f,onMethodChange:g,configValues:v,onConfigChange:y,googleSheetsLinks:w,googleSheetsError:S,onGoogleSheetsLinksChange:j,submitting:N,onBack:_,onConnect:A}){const C=(0,u.useMemo)(()=>Ky(e,d),[d,e]),I=f?C.find(Oe=>Oe.key===f)??null:Ij(C),T=(0,u.useMemo)(()=>C.some(Oe=>Oe.capabilityProfile)?Array.from(C.reduce((Oe,Xe)=>{const me=Xe.capabilityProfile.key,Le=Oe.get(me);return Le?Le.methods.push(Xe):Oe.set(me,{key:me,label:Xe.capabilityProfile?.label??Xe.label??Xe.key,description:Xe.capabilityProfile?.description??Xe.whenToUse,methods:[Xe]}),Oe},new Map)).map(([,Oe])=>Oe):[],[C]),R=I?.capabilityProfile?.key??I?.key??"",L=T.map(Oe=>Oe.key).join("|"),[O,$]=(0,u.useState)(R||Ij(C)?.capabilityProfile?.key||(T.length===1?T[0].key:""));(0,u.useEffect)(()=>{if(R){$(R);return}$(Oe=>T.some(Xe=>Xe.key===Oe)?Oe:Ij(C)?.capabilityProfile?.key||(T.length===1?T[0].key:""))},[L,T,C,R]);const E=T.length>1?T.find(Oe=>Oe.key===O)?.methods??[]:C,q=(I?.credentialFields??[]).map(Oe=>({...Oe,configPath:ule(Oe),helpUrl:I?.consoleLinks?.keys??I?.consoleLinks?.docs??""})),B=I?.credentialSources?.vercelConnect??null,K=d==="vercel_connect",U=K||q.every(Oe=>Oe.required===!1||(n[Oe.configPath]?.trim().length??0)>0),D=yR(I),V=D&&!Fp(I),H=K||!V||i.trim().length>0,J=!K||m.trim().length>0,X=I?.auth==="oauth"&&D?NGe():null,le=[...I?.tenantFields??[],...I?.extensionFields??[]],ce=le.filter(Oe=>!Oe.hidden),te=ce.filter(Oe=>Oe.advanced!==!0),re=ce.filter(Oe=>Oe.advanced===!0),[de,Z]=(0,u.useState)(!1),Y=le.every(Oe=>{if(!Oe.required)return!0;const Xe=v[Oe.key];return typeof Xe=="boolean"||typeof Xe=="string"&&Xe.trim().length>0}),G=I?.configRequirements?.atLeastOneOf??[],fe=G.length===0||G.some(Oe=>{const Xe=v[Oe];return typeof Xe=="string"&&Xe.trim().length>0}),se=(T.length<=1||!!O)&&(E.length<=1?!!I:!!f),ae=e.availability?.robotEmail??null,ie=e.availability?.available===!1,ue=!K&&D&&!V,pe=re.length>0||ue,be=T.length>1?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"What should Paperclip be able to do?"}),(0,t.jsx)(uu,{ariaLabel:`Access level for ${e.name}`,className:"mt-2",value:O,onValueChange:r(Oe=>{const Xe=T.find(me=>me.key===Oe);Xe&&($(Oe),g(Z6(Xe.methods)))},"onValueChange"),options:T.map(Oe=>({value:Oe.key,title:Oe.label,description:Oe.description}))}),!O&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Choose an access level to continue."})]}):null,oe=E.find(Oe=>Oe.oauthStrategy==="paperclip_cloud_connector"&&tIe(Oe.connectorProfile??"")),je=oe&&E.find(Oe=>yR(Oe)&&!Fp(Oe)),_e=I?.key===je?.key,xe=(0,u.useId)(),Ae=oe&&je&&E.length===2?(0,t.jsx)(F,{type:"button",variant:"link",className:"h-auto p-0 text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground","aria-expanded":_e,"aria-controls":xe,disabled:N,onClick:r(()=>g(_e?oe:je),"onClick"),children:_e?"Use Paperclip instead":"Use your own Google OAuth app"}):E.length>1?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"How do you want to connect?"}),(0,t.jsx)(uu,{ariaLabel:`How to connect ${e.name}`,className:"mt-2",value:f,onValueChange:r(Oe=>{const Xe=E.find(me=>me.key===Oe);Xe&&g(Xe)},"onValueChange"),options:E.map(Oe=>({value:Oe.key,title:Oe.label??(Oe.auth==="oauth"?`Sign in with ${e.name}`:"Use an API key")}))}),!I&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Choose a connection method to continue."})]}):null;if(Mk(e,I)){const Oe=qO(w),Xe=!ie&&!!ae&&w.trim().length>0;return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{className:"space-y-6",children:[be,ae?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Share each sheet with this email"}),(0,t.jsxs)("div",{className:"mt-2 flex min-w-0 flex-col gap-2 sm:flex-row",children:[(0,t.jsx)("div",{title:ae,className:"min-h-11 min-w-0 flex-1 rounded-md border border-input bg-muted/40 px-3 py-2.5 font-mono text-xs leading-tight text-foreground break-all",children:ae}),(0,t.jsx)(Sxe,{value:ae,ariaLabel:"Copy sharing email"})]}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"In Google Sheets, click Share and add this email as an Editor. Then paste the sheet links below."})]}):(0,t.jsx)("div",{className:"rounded-lg bg-muted/50 p-4 text-sm text-muted-foreground",children:"Google Sheets is not available on this instance yet."}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Paste links to the sheets you shared"}),(0,t.jsx)(En,{value:w,onChange:r(me=>j(me.target.value),"onChange"),placeholder:"https://docs.google.com/spreadsheets/d/...",className:"mt-2 min-h-28"}),(0,t.jsx)("div",{className:"mt-2 text-xs text-muted-foreground",children:Oe.ids.length>0?`${Oe.ids.length} ${Oe.ids.length===1?"sheet":"sheets"} ready to connect.`:"Paste one link per line. Both .../edit and .../edit#gid=... links work."}),S&&(0,t.jsx)("div",{className:"mt-2 text-xs text-destructive",children:S})]})]}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:_,disabled:N,children:"Back"}),(0,t.jsxs)(F,{onClick:A,disabled:N||!Xe,children:[N&&(0,t.jsx)(it,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":"Connect"]})]})]})}const Ye=I?.consoleLinks?.docs??e.docsUrl;return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[Ye?(0,t.jsx)("div",{className:"mb-4 flex justify-end",children:(0,t.jsxs)("a",{href:Ye,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground underline underline-offset-2 hover:text-foreground",children:["Review requirements",(0,t.jsx)(eo,{className:"h-3 w-3"})]})}):null,(0,t.jsxs)("div",{className:"space-y-6",children:[be,Ae,K&&B&&p?(0,t.jsxs)("div",{className:"space-y-4 rounded-lg border border-border p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Create or attach the connector in Vercel"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Paperclip does not copy Vercel’s setup forms. Finish connector setup there, then paste its UID below."}),(0,t.jsxs)("a",{href:p.manageUrl,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2",children:["Open Vercel Connect",(0,t.jsx)(eo,{className:"h-3 w-3"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"vercel-connect-connector",children:"Connector UID or ID"}),(0,t.jsx)(_t,{id:"vercel-connect-connector",value:m,onChange:r(Oe=>h(Oe.target.value),"onChange"),autoComplete:"off",placeholder:"service/my-connector or scl_…",className:"mt-2 h-11 font-mono"}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Paperclip validates the connector and stores only its reference and redacted verification metadata."})]})]}):null,s?(0,t.jsx)("div",{role:"alert",children:(0,t.jsx)(Ja,{tone:"danger",children:s})}):null,te.map(Oe=>(0,t.jsx)(fJ,{field:Oe,value:v[Oe.key],onChange:r(Xe=>y({...v,[Oe.key]:Xe}),"onChange")},Oe.key)),pe&&(0,t.jsxs)(el,{open:de,onOpenChange:Z,children:[(0,t.jsxs)(Wl,{className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[(0,t.jsx)(en,{className:z("h-4 w-4 transition-transform",de&&"rotate-180")}),"Advanced"]}),(0,t.jsx)(tl,{className:"pt-4",children:(0,t.jsxs)("div",{className:"space-y-6",children:[re.map(Oe=>(0,t.jsx)(fJ,{field:Oe,value:v[Oe.key],onChange:r(Xe=>y({...v,[Oe.key]:Xe}),"onChange")},Oe.key)),ue?(0,t.jsx)(pJ,{entry:e,method:I,callbackUrl:X,clientId:i,onClientIdChange:o,clientSecret:l,onClientSecretChange:c,required:!1}):null]})})]}),!K&&I?.auth==="oauth"&&V?(0,t.jsx)("div",{id:xe,role:"region","aria-label":"Your OAuth app",children:(0,t.jsx)(pJ,{entry:e,method:I,callbackUrl:X,clientId:i,onClientIdChange:o,clientSecret:l,onClientSecretChange:c,required:!0})}):null,K||!I||q.length===0?null:q.map(Oe=>(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:XY(e.name,Oe.label,q.length)}),(0,t.jsx)(_t,{type:"password","aria-label":XY(e.name,Oe.label,q.length),autoComplete:"off",value:n[Oe.configPath]??"",onChange:r(Xe=>a({...n,[Oe.configPath]:Xe.target.value}),"onChange"),placeholder:"••••••••••••••••",className:"mt-2 h-11 font-mono"}),Oe.helpUrl&&(0,t.jsxs)("a",{href:Oe.helpUrl,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2",children:["Where do I find this?",(0,t.jsx)(eo,{className:"h-3 w-3"})]})]},Oe.configPath))]}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:_,disabled:N,children:"Back"}),(0,t.jsxs)(F,{onClick:A,disabled:N||!se||!U||!H||!J||!Y||!fe,children:[N&&(0,t.jsx)(it,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":K?I?.auth==="oauth"?"Validate and continue":"Validate and connect":I?.auth==="oauth"?e.slug==="github"?"Continue to GitHub":"Continue to sign in":"Connect"]})]})]})}r(WGe,"KeyStep");function Sxe({value:e,ariaLabel:s}){const{copied:n,failed:a,copy:i}=uf();return(0,t.jsxs)(F,{type:"button",variant:"outline",className:"shrink-0","aria-label":s,onClick:r(()=>{i(e)},"onClick"),children:[n?(0,t.jsx)(fs,{className:"mr-2 h-4 w-4"}):(0,t.jsx)(jr,{className:"mr-2 h-4 w-4"}),n?"Copied":a?"Copy failed":"Copy"]})}r(Sxe,"CopyValueButton");function pJ({entry:e,method:s,callbackUrl:n,clientId:a,onClientIdChange:i,clientSecret:o,onClientSecretChange:l,required:c}){return(0,t.jsxs)("div",{className:"space-y-4 rounded-lg border border-border p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:c?"Your OAuth app":"Use your own OAuth app"}),(0,t.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["Register Paperclip's callback URI in ",e.name,", then enter the customer-owned client details."]}),s.consoleLinks?.register?(0,t.jsxs)("a",{href:s.consoleLinks.register,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2",children:["Open ",e.name," app settings",(0,t.jsx)(eo,{className:"h-3 w-3"})]}):null]}),n?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Paperclip callback URL"}),(0,t.jsxs)("div",{className:"mt-2 flex min-w-0 flex-col gap-2 sm:flex-row",children:[(0,t.jsx)("div",{title:n,className:"min-h-11 min-w-0 flex-1 rounded-md border border-input bg-muted/40 px-3 py-2.5 font-mono text-xs leading-tight text-foreground break-all",children:n}),(0,t.jsx)(Sxe,{value:n,ariaLabel:"Copy callback URL"})]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Add this exact URL to ",e.name," before continuing. It must match the authorization request."]})]}):null,(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"curated-oauth-client-id",children:"Client ID"}),(0,t.jsx)(_t,{id:"curated-oauth-client-id",value:a,onChange:r(d=>i(d.target.value),"onChange"),autoComplete:"off",placeholder:c?"Required":"Optional",className:"mt-2 h-11 font-mono"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"curated-oauth-client-secret",children:"Client secret"}),(0,t.jsx)(_t,{id:"curated-oauth-client-secret",type:"password",value:o,onChange:r(d=>l(d.target.value),"onChange"),autoComplete:"off",placeholder:"Optional for public clients",className:"mt-2 h-11 font-mono"})]})]})}r(pJ,"OAuthClientFields");function fJ({field:e,value:s,onChange:n}){return e.type==="checkbox"?(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4 rounded-lg border border-border p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:e.label}),e.helperMd&&(0,t.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:e.helperMd})]}),(0,t.jsx)(_i,{checked:s===!0,onCheckedChange:n})]}):(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:e.label}),e.type==="textarea"?(0,t.jsx)(En,{value:typeof s=="string"?s:"",onChange:r(a=>n(a.target.value),"onChange"),placeholder:e.placeholder,className:"mt-2 min-h-24"}):e.type==="select"?(0,t.jsxs)("select",{value:typeof s=="string"?s:"",onChange:r(a=>n(a.target.value),"onChange"),className:"mt-2 h-11 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30",children:[(0,t.jsx)("option",{value:"",disabled:!0,children:"Select an option"}),(e.options??[]).map(a=>(0,t.jsx)("option",{value:a.value,children:a.label},a.value))]}):(0,t.jsx)(_t,{value:typeof s=="string"?s:"",onChange:r(a=>n(a.target.value),"onChange"),placeholder:e.placeholder,className:"mt-2 h-11"}),e.helperMd&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:e.helperMd})]})}r(fJ,"MethodConfigField");function Cxe({companyId:e,...s}){const n=ee({queryKey:P.agents.list(e),queryFn:r(()=>zt.list(e),"queryFn")});return(0,t.jsx)(_xe,{...s,agents:(n.data??[]).filter(a=>a.status!=="terminated"),agentsLoading:n.isLoading})}r(Cxe,"AccessStep");function _xe({agents:e,agentsLoading:s=!1,authKind:n,grantKinds:a,grantKind:i,setGrantKind:o,installChoice:l,setInstallChoice:c,installAgentIds:d,setInstallAgentIds:m,lockedAgentId:h,capabilities:p,githubIdentity:f=!1,submitLabel:g,continuesToProvider:v=!1,identityLoading:y=!1,preserveAgentAccess:w=!1,pending:S=!1,onBack:j,onContinue:N}){const _=p?.editableAgentIds,A=_?e.filter(B=>_.includes(B.id)):e,C=p?.canSetCompanyInstall??!0,I=p?.canCreateOrganizationGrant??!0,T=n!=="none",R=a??["user","organization"],L=(!T||i==="user"||i==="agent"||I)&&(w?!0:h?d.has(h):i==="agent"?l==="specific"&&d.size===1:l==="all"?C:d.size>0),O=h?e.find(B=>B.id===h)?.name??"the requesting agent":null,$=f?"Connect GitHub as":"Which humans can use this credential?",E=i==="agent"?"Which agent owns this GitHub account?":f&&i==="user"?"Which agents may use your GitHub when you’re responsible?":f?"Which agents may use the shared GitHub account?":"Which agents can use this connection?",q=f?E:"Which agents can use this connection?";return(0,t.jsxs)("div",{className:"mx-auto max-w-2xl",children:[(0,t.jsx)("div",{className:"overflow-hidden rounded-xl border border-border",children:(0,t.jsxs)("div",{className:"divide-y divide-border",children:[(0,t.jsxs)("section",{className:"p-6",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:$}),f&&i==="agent"?(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This agent uses this GitHub account for everyone’s work, instead of the person giving instructions."}):null,y?(0,t.jsxs)("div",{className:"mt-4 grid gap-2 sm:grid-cols-2","aria-label":"Loading connection identity",children:[(0,t.jsx)(bn,{className:"h-20 w-full rounded-md"}),(0,t.jsx)(bn,{className:"h-20 w-full rounded-md"})]}):T&&R.length===1?(0,t.jsxs)("div",{className:"mt-4 flex items-center gap-3 rounded-md border border-border p-4",children:[R[0]==="user"?(0,t.jsx)(vu,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):R[0]==="agent"?(0,t.jsx)(Xi,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):(0,t.jsx)(yj,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:R[0]==="user"?f?"My GitHub account":"Just me":R[0]==="agent"?"A dedicated account for an agent":f?"Shared organization GitHub account (advanced)":"Any human in the organization"}),f?(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:R[0]==="user"?"Agents use it only for runs where you are the responsible person.":R[0]==="agent"?"That agent always uses this account, regardless of who starts the run.":"Eligible agents use one shared credential, regardless of who starts the run."}):null]})]}):T?(0,t.jsx)(uu,{ariaLabel:f?$:"Which humans can use this credential?",className:"mt-4 sm:grid-cols-2",value:i,onValueChange:r(B=>{const K=B;o(K),K==="agent"&&(c("specific"),d.size>1&&m(new Set([[...d][0]])))},"onValueChange"),options:[{value:"user",title:f?"My GitHub account":"Just me",description:f?"Agents use it only for runs where you are the responsible person.":void 0,icon:(0,t.jsx)(vu,{className:"h-4 w-4","aria-hidden":"true"})},{value:"agent",title:"A dedicated account for an agent",description:f?"That agent always uses this account, regardless of who starts the run.":void 0,icon:(0,t.jsx)(Xi,{className:"h-4 w-4","aria-hidden":"true"})},{value:"organization",title:f?"Shared organization GitHub account (advanced)":"Any human in the organization",description:f?"Eligible agents use one shared credential, regardless of who starts the run.":void 0,icon:(0,t.jsx)(yj,{className:"h-4 w-4","aria-hidden":"true"}),accessibleLabel:I?f?"Shared organization GitHub account (advanced)":"Any human in the organization":`${f?"Shared organization GitHub account (advanced)":"Any human in the organization"}. Unavailable: ${p?.organizationGrantReason??"Only a connection manager can share this credential with the organization."}`,tooltip:I?void 0:p?.organizationGrantReason??"Only a connection manager can share this credential with the organization.",disabled:!I}].filter(B=>R.includes(B.value))}):(0,t.jsx)("p",{className:"mt-4 text-sm text-muted-foreground",children:"No identity required"})]}),(0,t.jsxs)("section",{className:"p-6",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:E}),w?(0,t.jsxs)("div",{className:"mt-4 flex items-start gap-3 rounded-md border border-border bg-muted/40 p-4",children:[(0,t.jsx)(yj,{className:"mt-0.5 h-4 w-4 shrink-0 text-primary","aria-hidden":"true"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Existing agent access stays the same"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Reconnecting replaces the credential without changing which agents can use it."})]})]}):h?(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["This task grants access only to ",(0,t.jsx)("span",{className:"font-medium text-foreground",children:O}),". Existing connection access is left unchanged."]}):i==="agent"?(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Choose exactly one agent. This identity cannot be shared with other agents."}):(0,t.jsx)(uu,{ariaLabel:q,className:"mt-4 sm:grid-cols-2",value:l,onValueChange:r(B=>c(B),"onValueChange"),options:[{value:"specific",title:f?"Only agents I choose":"Just agents I pick",description:f?i==="user"?"Only selected agents may use your GitHub when you’re responsible.":"Only selected agents may use the shared account.":void 0,icon:(0,t.jsx)(Xi,{className:"h-4 w-4","aria-hidden":"true"})},{value:"all",title:"Any agent",description:f?i==="user"?"Every agent may use your GitHub when you’re responsible.":"Every agent may use the shared account.":void 0,icon:(0,t.jsx)(HGe,{}),accessibleLabel:C?"Any agent":`Any agent. Unavailable: ${p?.companyInstallReason??"Only someone who can configure this connection can choose this."}`,tooltip:C?void 0:p?.companyInstallReason??"Only someone who can configure this connection can choose this.",disabled:!C}]}),!w&&!h&&l==="specific"?(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)(kv,{agents:A,selectedAgentIds:d,onChange:r(B=>m(i==="agent"&&B.size>1?new Set([[...B].at(-1)]):B),"onChange"),loading:s,emptyMessage:"You cannot edit any agents yet.",showSelectionPreview:!1})}):null]})]})}),(0,t.jsxs)("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsx)(F,{variant:"ghost",className:"w-full sm:w-auto",onClick:j,disabled:S,children:"Back"}),(0,t.jsxs)(F,{className:"w-full sm:w-auto",onClick:N,disabled:!L||y||S,children:[S?(0,t.jsx)(it,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):null,g,!S&&v?(0,t.jsx)(eo,{className:"h-4 w-4","aria-hidden":"true"}):null]})]})]})}r(_xe,"AccessStepContent");function HGe(){return(0,t.jsxs)("span",{className:"relative block h-4 w-5","aria-hidden":"true",children:[(0,t.jsx)(Xi,{className:"absolute left-0 top-0 h-3.5 w-3.5"}),(0,t.jsx)(Xi,{className:"absolute bottom-0 right-0 h-3.5 w-3.5"})]})}r(HGe,"BotGroupIcon");function QGe(e){const s=e.authKind==="none"?"No identity required":e.grantKind==="user"?"Your identity":e.grantKind==="agent"?"Dedicated agent identity":"Organization identity",n=e.installChoice==="all"?"Any agent":`${e.installCount} selected ${e.installCount===1?"agent":"agents"}`;return[{label:"Identity",value:s},{label:"Available to",value:n},{label:"Actions",value:`${e.enabledCount} ${e.enabledCount===1?"action":"actions"} on`}]}r(QGe,"accessSummaryLines");function GGe({appName:e,logoUrl:s,darkLogoUrl:n,summary:a,onDone:i}){return(0,t.jsxs)("div",{className:"mx-auto max-w-md py-10 text-center",children:[(0,t.jsx)("div",{className:"mx-auto flex h-20 w-20 items-center justify-center rounded-full border-2 border-emerald-500 bg-emerald-500/10",children:(0,t.jsx)(fs,{className:"h-9 w-9 text-emerald-600 dark:text-emerald-400"})}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-center gap-2",children:[(0,t.jsx)(yc,{name:e,logoUrl:s,darkLogoUrl:n,size:28}),(0,t.jsxs)("h2",{className:"text-2xl font-bold tracking-tight",children:[e," is ready."]})]}),(0,t.jsx)("dl",{className:"mx-auto mt-6 max-w-xs space-y-1 text-left",children:a.map(o=>(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-4",children:[(0,t.jsx)("dt",{className:"text-xs font-medium text-muted-foreground",children:o.label}),(0,t.jsx)("dd",{className:"text-sm text-foreground",children:o.value})]},o.label))}),(0,t.jsx)("div",{className:"mt-8",children:(0,t.jsx)(F,{size:"lg",className:"px-10",onClick:i,children:"View connection"})})]})}r(GGe,"ConnectionSetupCompletionScreen");function Ixe(){const{newProjectOpen:e,closeNewProject:s}=c1(),{selectedCompanyId:n}=xs();return n&&e?(0,t.jsx)(YGe,{companyId:n,onClose:s},n):null}r(Ixe,"NewProjectDialog");function YGe({companyId:e,onClose:s}){const n=Kt(),[a,i]=(0,u.useState)(""),[o,l]=(0,u.useState)([]),[c,d]=(0,u.useState)(!1),m=(0,u.useRef)(null),h=ke({mutationFn:r(()=>ia.create(e,{name:a.trim(),status:"planned",repositoryIds:o.map(p=>p.id)}),"mutationFn"),onSuccess:r(()=>{n.invalidateQueries({queryKey:P.projects.all(e)}),s()},"onSuccess")});return(0,t.jsx)(Js,{open:!0,onOpenChange:r(p=>{!p&&!h.isPending&&s()},"onOpenChange"),children:(0,t.jsx)(Zs,{showCloseButton:!1,"aria-describedby":void 0,className:"flex max-h-(--sz-calc-18) flex-col gap-0 overflow-hidden p-0 shadow-sm sm:max-w-lg",onOpenAutoFocus:r(p=>{p.preventDefault(),m.current?.focus()},"onOpenAutoFocus"),children:c?(0,t.jsxs)("div",{className:"min-h-0 overflow-y-auto p-5",children:[(0,t.jsx)(rn,{className:"sr-only",children:"Connect GitHub"}),(0,t.jsx)(sE,{host:"dialog",serviceSlug:"github",forceNewConnection:!0,onCancel:r(()=>d(!1),"onCancel"),onComplete:r(()=>{n.invalidateQueries({queryKey:hU(e)}),d(!1)},"onComplete")})]}):(0,t.jsxs)("form",{className:"flex min-h-0 flex-col overflow-hidden",onSubmit:r(p=>{p.preventDefault(),a.trim()&&!h.isPending&&h.mutate()},"onSubmit"),children:[(0,t.jsxs)("div",{className:"flex shrink-0 flex-col gap-4 px-5 pb-4 pt-5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)(rn,{className:"text-lg font-semibold",children:"Create project"}),(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-sm",disabled:h.isPending,"aria-label":"Close new project",onClick:s,children:(0,t.jsx)(ir,{className:"size-4"})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-input px-3 focus-within:border-ring focus-within:ring-1 focus-within:ring-ring",children:[(0,t.jsx)(Kc,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,t.jsx)("input",{ref:m,"aria-label":"Project name",value:a,disabled:h.isPending,onChange:r(p=>i(p.target.value),"onChange"),placeholder:"Project name",required:!0,className:"h-10 w-full min-w-0 border-0 bg-transparent text-base outline-none placeholder:text-muted-foreground md:text-sm"})]})]}),(0,t.jsx)("div",{role:"region","aria-label":"Source repositories",tabIndex:0,className:"min-h-0 overflow-y-auto overscroll-contain px-5 pb-1 outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",children:(0,t.jsx)(Qme,{companyId:e,selected:o,onChange:l,onConnect:r(()=>d(!0),"onConnect"),disabled:h.isPending})}),h.isError&&(0,t.jsx)("p",{role:"alert",className:"px-5 pt-3 text-sm text-destructive",children:h.error.message}),(0,t.jsxs)("div",{className:"flex shrink-0 justify-end gap-2 px-5 py-5",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",disabled:h.isPending,onClick:s,children:"Cancel"}),(0,t.jsx)(F,{type:"submit",disabled:!a.trim()||h.isPending,children:h.isPending?"Creating…":"Create project"})]})]})})})}r(YGe,"NewProjectForm");var xx={list:r(e=>Re.get(`/companies/${e}/goals`),"list"),get:r(e=>Re.get(`/goals/${e}`),"get"),create:r((e,s)=>Re.post(`/companies/${e}/goals`,s),"create"),update:r((e,s)=>Re.patch(`/goals/${e}`,s),"update"),remove:r(e=>Re.delete(`/goals/${e}`),"remove")};function Axe(e){return{"--sc":`var(${e})`}}r(Axe,"scStyle");function JGe(e){const s=e.replace(/_/g," ");return s.charAt(0).toUpperCase()+s.slice(1)}r(JGe,"sentenceCaseStatus");function ni({status:e,label:s}){return(0,t.jsx)("span",{className:z("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap shrink-0",X$[e]??"bg-muted text-muted-foreground"),children:s??e.replace(/[_-]/g," ")})}r(ni,"StatusBadge$5");function Rxe({status:e}){const s=H2e[e]??"--status-agent-idle",n=e==="active"?"idle":e;return(0,t.jsx)("span",{className:"status-chip inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium leading-none whitespace-nowrap shrink-0",style:Axe(s),children:n.replace(/_/g," ")})}r(Rxe,"AgentStatusBadge");function Tp({status:e,externalConversationState:s}){const n=e==="in_review"&&s==="waiting"?"idle":e,a=z2e[n]??"--status-task-backlog";return(0,t.jsxs)("span",{className:z("status-chip inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-normal leading-none whitespace-nowrap shrink-0",n==="cancelled"&&"line-through"),style:Axe(a),children:[(0,t.jsx)(o1,{status:n,size:"sm"}),JGe(n)]})}r(Tp,"IssueStatusBadge");var xJ={company:"Organization",team:"Team",agent:"Agent",task:"Task"};function Txe(){const{newGoalOpen:e,newGoalDefaults:s,closeNewGoal:n}=c1(),{selectedCompanyId:a,selectedCompany:i}=xs(),o=Kt(),[l,c]=(0,u.useState)(""),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)("planned"),[f,g]=(0,u.useState)("task"),[v,y]=(0,u.useState)(""),[w,S]=(0,u.useState)(!1),[j,N]=(0,u.useState)(!1),[_,A]=(0,u.useState)(!1),[C,I]=(0,u.useState)(!1),T=(0,u.useRef)(null),R=v||s.parentId||"",{data:L}=ee({queryKey:P.goals.list(a),queryFn:r(()=>xx.list(a),"queryFn"),enabled:!!a&&e}),O=ke({mutationFn:r(U=>xx.create(a,U),"mutationFn"),onSuccess:r(()=>{o.invalidateQueries({queryKey:P.goals.list(a)}),E(),n()},"onSuccess")}),$=ke({mutationFn:r(async U=>{if(!a)throw new Error("No organization selected");return d0.uploadImage(a,U,"goals/drafts")},"mutationFn")});function E(){c(""),m(""),p("planned"),g("task"),y(""),S(!1)}r(E,"reset");function q(){!a||!l.trim()||O.mutate({title:l.trim(),description:d.trim()||void 0,status:h,level:f,...R?{parentId:R}:{}})}r(q,"handleSubmit");function B(U){U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&(U.preventDefault(),q())}r(B,"handleKeyDown");const K=(L??[]).find(U=>U.id===R);return(0,t.jsx)(Js,{open:e,onOpenChange:r(U=>{U||(E(),n())},"onOpenChange"),children:(0,t.jsxs)(Zs,{showCloseButton:!1,className:z("p-0 gap-0",w?"sm:max-w-2xl":"sm:max-w-lg"),onKeyDown:B,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i&&(0,t.jsx)("span",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-medium",children:i.issuePrefix}),(0,t.jsx)("span",{className:"text-muted-foreground/60",children:"›"}),(0,t.jsx)("span",{children:s.parentId?"New sub-goal":"New goal"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:r(()=>S(!w),"onClick"),children:w?(0,t.jsx)(Sz,{className:"h-3.5 w-3.5"}):(0,t.jsx)(i0,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:r(()=>{E(),n()},"onClick"),children:(0,t.jsx)("span",{className:"text-lg leading-none",children:"×"})})]})]}),(0,t.jsx)("div",{className:"px-4 pt-4 pb-2 shrink-0",children:(0,t.jsx)("input",{className:"w-full text-lg font-semibold bg-transparent outline-none placeholder:text-muted-foreground/50",placeholder:"Goal title",value:l,onChange:r(U=>c(U.target.value),"onChange"),onKeyDown:r(U=>{U.key==="Tab"&&!U.shiftKey&&(U.preventDefault(),T.current?.focus())},"onKeyDown"),autoFocus:!0})}),(0,t.jsx)("div",{className:"px-4 pb-2 overflow-y-auto max-h-(--sz-50vh)",children:(0,t.jsx)(wc,{ref:T,value:d,onChange:m,placeholder:"Add description...",bordered:!1,contentClassName:z("text-sm text-muted-foreground",w?"min-h-(--sz-220px)":"min-h-(--sz-120px)"),imageUploadHandler:r(async U=>(await $.mutateAsync(U)).contentPath,"imageUploadHandler")})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-4 py-2 border-t border-border flex-wrap",children:[(0,t.jsxs)(nr,{open:j,onOpenChange:N,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsx)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:(0,t.jsx)(ni,{status:h})})}),(0,t.jsx)(Wn,{className:"w-40 p-1",align:"start",children:lle.map(U=>(0,t.jsx)("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 capitalize",U===h&&"bg-accent"),onClick:r(()=>{p(U),N(!1)},"onClick"),children:U},U))})]}),(0,t.jsxs)(nr,{open:_,onOpenChange:A,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:[(0,t.jsx)(hl,{className:"h-3 w-3 text-muted-foreground"}),xJ[f]??f]})}),(0,t.jsx)(Wn,{className:"w-40 p-1",align:"start",children:sle.map(U=>(0,t.jsx)("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",U===f&&"bg-accent"),onClick:r(()=>{g(U),A(!1)},"onClick"),children:xJ[U]??U},U))})]}),(0,t.jsxs)(nr,{open:C,onOpenChange:I,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:[(0,t.jsx)(vx,{className:"h-3 w-3 text-muted-foreground"}),K?K.title:"Parent goal"]})}),(0,t.jsxs)(Wn,{className:"w-48 p-1",align:"start",children:[(0,t.jsx)("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",!R&&"bg-accent"),onClick:r(()=>{y(""),I(!1)},"onClick"),children:"No parent"}),(L??[]).map(U=>(0,t.jsx)("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 truncate",U.id===R&&"bg-accent"),onClick:r(()=>{y(U.id),I(!1)},"onClick"),children:U.title},U.id))]})]})]}),(0,t.jsx)("div",{className:"flex items-center justify-end px-4 py-2.5 border-t border-border",children:(0,t.jsx)(F,{size:"sm",disabled:!l.trim()||O.isPending,onClick:q,children:O.isPending?"Creating…":s.parentId?"Create sub-goal":"Create goal"})})]})})}r(Txe,"NewGoalDialog");function XGe(e){const s=ZGe(e),n=eYe(e);return`You're invited to join a Paperclip company as an agent.
287
+ `;function uHe(){const e=new Blob([dHe],{type:"application/javascript"}),s=URL.createObjectURL(e);try{return new Worker(s)}finally{URL.revokeObjectURL(s)}}r(uHe,"createSandboxedWorker");var wF=new Map,IT=new Map,w2=new Set,N2=new Map,Dfe=null;function mHe(e){Dfe=e}r(mHe,"setDynamicParserResultNotifier");function Lfe(e,s){e.worker.postMessage(s)}r(Lfe,"sendToWorker");function hHe(e){return e.nextId++}r(hHe,"nextRequestId");function pHe(e,s){return`${s}\0${e}`}r(pHe,"lineCacheKey");function fHe(){Dfe?.()}r(fHe,"notifyResultReady");function xHe(e,s,n){return new Promise(a=>{const i=hHe(e);e.pendingResolves.set(i,a),Lfe(e,{type:"parse",id:i,line:s,ts:n})})}r(xHe,"parseLineAsync");function Ek(e){for(const s of e.pendingResolves.values())s([]);e.pendingResolves.clear()}r(Ek,"drainPendingRequests");function gHe(e){return new Promise((s,n)=>{const a=uHe(),i={worker:a,ready:!1,nextId:1,pendingResolves:new Map},o=setTimeout(()=>{Ek(i),a.terminate(),n(new Error("Parser worker init timed out"))},5e3);a.onmessage=l=>{const c=l.data;if(c.type==="ready"){clearTimeout(o),i.ready=!0,a.onmessage=d=>{const m=d.data;if(m.type==="result"){const h=i.pendingResolves.get(m.id);h&&(i.pendingResolves.delete(m.id),h(m.entries))}else m.type==="error"&&Ek(i)},s(i);return}if(c.type==="error"){clearTimeout(o),Ek(i),a.terminate(),n(new Error(c.message));return}},a.onerror=l=>{clearTimeout(o),Ek(i),a.terminate(),n(new Error(`Worker error: ${l.message}`))},Lfe(i,{type:"init",source:e})})}r(gHe,"initSandboxedWorker");function bHe(e){const s=new Map,n=new Set;return{parseStdoutLine:r((i,o)=>{const l=pHe(i,o),c=s.get(l);return c?c.slice():(n.has(l)||(n.add(l),xHe(e,i,o).then(d=>{n.delete(l),s.set(l,d),fHe()})),[])},"parseStdoutLine")}}r(bHe,"buildParserModule");async function NF(e){const s=IT.get(e);if(s)return s;if(w2.has(e))return null;const n=N2.get(e);if(n)return n;const a=(async()=>{try{const i=await fetch(`/api/adapters/${encodeURIComponent(e)}/ui-parser.js`);if(!i.ok)return w2.add(e),null;const o=await gHe(await i.text());wF.set(e,o);const l=bHe(o);return IT.set(e,l),l}catch{return w2.add(e),null}finally{N2.delete(e)}})();return N2.set(e,a),a}r(NF,"loadDynamicParser");function kF(e){const s=IT.has(e);IT.delete(e),w2.delete(e),N2.delete(e);const n=wF.get(e);return n&&(Ek(n),n.worker.terminate(),wF.delete(e)),s}r(kF,"invalidateDynamicParser");var k2=[],X5=new Map,SF=new Set,$fe=new Map,S4=new Set,cI=new Map,CF=new Set;function Ofe(e){return CF.add(e),()=>CF.delete(e)}r(Ofe,"onAdapterChange");function Ffe(){for(const e of CF)e()}r(Ffe,"notifyAdapterChange");mHe(Ffe);function vHe(){for(const e of[n9e,g9e,L9e,z9e,uVe,kVe,LVe,VVe,sWe,mWe,LWe,AWe,tVe,XWe,_T,cHe])SF.add(e.type),$fe.set(e.type,e),sb(e)}r(vHe,"registerBuiltInUIAdapters");function sb(e){const s=k2.findIndex(n=>n.type===e.type);s>=0?k2.splice(s,1,e):k2.push(e),X5.set(e.type,e),Ffe()}r(sb,"registerUIAdapter");function Bfe(e){return X5.get(e)??null}r(Bfe,"findUIAdapter");vHe();function tN(e){const s=X5.get(e);if(!s){let n=!1;return{type:e,label:e,parseStdoutLine:r((a,i)=>(n||(n=!0,NF(e).then(o=>{o&&sb({type:e,label:e,parseStdoutLine:o.parseStdoutLine,createStdoutParser:o.createStdoutParser,ConfigFields:Gb,buildAdapterConfig:lw})})),_T.parseStdoutLine(a,i)),"parseStdoutLine"),ConfigFields:Gb,buildAdapterConfig:lw}}return s}r(tN,"getUIAdapter");function yHe(e){const s=new Set(e.filter(a=>!a.disabled&&!a.overrideDisabled).map(a=>a.type)),n=new Set(e.map(a=>a.type));for(const a of SF){const i=$fe.get(a);if(!i)continue;const o=n.has(a),l=s.has(a),c=S4.has(a);if(o&&l&&!c){S4.add(a);const d=(cI.get(a)??0)+1;cI.set(a,d);let m=!1;const h=i.parseStdoutLine,p=e.find(f=>f.type===a)?.label??a;sb({type:a,label:p,parseStdoutLine:r((f,g)=>(m||(m=!0,NF(a).then(v=>{v&&cI.get(a)===d&&sb({type:a,label:p,parseStdoutLine:v.parseStdoutLine,createStdoutParser:v.createStdoutParser,ConfigFields:i.ConfigFields,buildAdapterConfig:i.buildAdapterConfig})})),h(f,g)),"parseStdoutLine"),ConfigFields:i.ConfigFields,buildAdapterConfig:i.buildAdapterConfig})}else(!o||!l)&&c&&(S4.delete(a),cI.delete(a),kF(a),sb(i))}for(const{type:a,label:i}of e){if(SF.has(a))continue;const o=X5.get(a);if(o&&o!==_T)continue;let l=!1;const c=o?.parseStdoutLine??_T.parseStdoutLine;sb({type:a,label:i,parseStdoutLine:r((d,m)=>(l||(l=!0,NF(a).then(h=>{h&&sb({type:a,label:i,parseStdoutLine:h.parseStdoutLine,createStdoutParser:h.createStdoutParser,ConfigFields:o?.ConfigFields??Gb,buildAdapterConfig:o?.buildAdapterConfig??lw})})),c(d,m)),"parseStdoutLine"),ConfigFields:o?.ConfigFields??Gb,buildAdapterConfig:o?.buildAdapterConfig??lw})}}r(yHe,"syncExternalAdapters");function ZU(){return[...k2]}r(ZU,"listUIAdapters");function _F(e){if(typeof e=="function")return{parseLine:e,reset:null};if(e.createStdoutParser){const s=e.createStdoutParser();return{parseLine:s.parseLine,reset:s.reset}}return{parseLine:e.parseStdoutLine,reset:null}}r(_F,"resolveStdoutParser");function qfe(e,s){if((s.kind==="thinking"||s.kind==="assistant")&&s.delta){const n=e[e.length-1];if(n&&n.kind===s.kind&&n.delta&&n.channel===s.channel){n.text+=s.text,n.ts=s.ts;return}}e.push(s)}r(qfe,"appendTranscriptEntry");function jHe(e,s){for(const n of s)qfe(e,n)}r(jHe,"appendTranscriptEntries");function wHe(e,s=160){return e.length<=s?e:`${e.slice(0,s-3)}...`}r(wHe,"truncateTranscriptLine");function NHe(e){if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"&&e)return e;try{return JSON.stringify(e)}catch{return String(e)}}r(NHe,"formatTranscriptParserError");function kHe(e,s,n,a){const i=NHe(n)||"unknown parser error",o=wHe(e);return{kind:"result",ts:s,text:Uu(`Chat transcript error: ${i}. Falling back for line: ${o}`,a),inputTokens:0,outputTokens:0,cachedTokens:0,costUsd:0,subtype:"transcript_parse_error",isError:!0,errors:[]}}r(kHe,"createTranscriptParseErrorEntry");function eK(e){const{entries:s,line:n,ts:a,parseLine:i,reset:o,redactionOptions:l}=e;try{jHe(s,i(n,a).map(c=>QFe(c,l)))}catch(c){o?.(),qfe(s,kHe(n,a,c,l))}}r(eK,"appendParsedTranscriptLine");function zfe(e){const{entries:s,chunks:n,from:a,parseLine:i,reset:o,redactionOptions:l}=e;let c=e.stdoutBuffer;for(let d=a;d<n.length;d+=1){const m=n[d];if(m.stream==="stderr"){s.push({kind:"stderr",ts:m.ts,text:Uu(m.chunk,l)});continue}if(m.stream==="system"){s.push({kind:"system",ts:m.ts,text:Uu(m.chunk,l)});continue}const h=(c+m.chunk).split(/\r?\n/);c=h.pop()??"";for(const p of h){const f=p.trim();f&&eK({entries:s,line:f,ts:m.ts,parseLine:i,reset:o,redactionOptions:l})}}return c}r(zfe,"foldTranscriptChunks");function Ufe(e,s,n){const a=[],i={enabled:n?.censorUsernameInLogs??!1},{parseLine:o,reset:l}=_F(s),c=zfe({entries:a,chunks:e,from:0,stdoutBuffer:"",parseLine:o,reset:l,redactionOptions:i}).trim();return c&&eK({entries:a,line:c,ts:e.length>0?e[e.length-1].ts:new Date().toISOString(),parseLine:o,reset:l,redactionOptions:i}),l?.(),a}r(Ufe,"buildTranscript");var PY=[];function SHe(e,s){const n={enabled:s?.censorUsernameInLogs??!1},a=typeof e!="function"&&typeof e.createStdoutParser=="function";let i=_F(e),o=[],l="",c=PY,d=[];const m=r(()=>{i=_F(e),o=[],l="",c=PY},"restart"),h=r(f=>{if(f.length<c.length)return!1;for(let g=0;g<c.length;g+=1)if(f[g]!==c[g])return!1;return!0},"extendsFolded"),p=r(f=>{const g=l.trim();if(g&&a)return Ufe(f,e,s);const v=o.slice(),y=v.length-1;return y>=0&&(v[y]={...v[y]}),g&&eK({entries:v,line:g,ts:f.length>0?f[f.length-1].ts:new Date().toISOString(),parseLine:i.parseLine,reset:i.reset,redactionOptions:n}),v},"publish");return{update(f){return f===c||(h(f)||m(),l=zfe({entries:o,chunks:f,from:c.length,stdoutBuffer:l,parseLine:i.parseLine,reset:i.reset,redactionOptions:n}),c=f,d=p(f)),d}}}r(SHe,"createIncrementalTranscript");function CHe({agents:e,value:s,onChange:n,disabled:a=!1,excludeAgentIds:i=[],disabledEmptyLabel:o="Reports to: N/A (CEO)",chooseLabel:l="Reports to..."}){const[c,d]=(0,u.useState)(!1),m=new Set(i),h=e.filter(v=>v.status!=="terminated"&&!m.has(v.id)),p=s?e.find(v=>v.id===s):null,f=p?.status==="terminated",g=!!(s&&!p);return(0,t.jsxs)(nr,{open:c,onOpenChange:d,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsx)("button",{type:"button",className:z("inline-flex max-w-full min-w-0 items-center gap-1.5 overflow-hidden rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",f&&"border-amber-600/45 bg-amber-500/5",a&&"opacity-60 cursor-not-allowed"),disabled:a,children:g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(bc,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate text-muted-foreground",children:"Unknown manager (stale ID)"})]}):p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(pr,{agent:p,size:16,className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:z("min-w-0 truncate",f&&"text-amber-900 dark:text-amber-200"),children:`Reports to ${p.name}${f?" (terminated)":""}`})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(bc,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:a?o:l})]})})}),(0,t.jsxs)(Wn,{className:"w-48 p-1",align:"start",children:[(0,t.jsx)("button",{type:"button",className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",s===null&&"bg-accent"),onClick:r(()=>{n(null),d(!1)},"onClick"),children:"No manager"}),f&&(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden px-2 py-1.5 text-xs text-muted-foreground border-b border-border mb-0.5",children:[(0,t.jsx)(pr,{agent:p,size:16,className:"shrink-0 h-3 w-3"}),(0,t.jsxs)("span",{className:"min-w-0 truncate",children:["Current: ",p.name," (terminated)"]})]}),g&&(0,t.jsx)("div",{className:"px-2 py-1.5 text-xs text-muted-foreground border-b border-border mb-0.5",children:"Saved manager is missing from this organization. Choose a new manager or clear."}),h.map(v=>(0,t.jsxs)("button",{type:"button",className:z("flex items-center gap-2 w-full min-w-0 px-2 py-1.5 text-xs rounded hover:bg-accent/50 overflow-hidden",v.id===s&&"bg-accent"),onClick:r(()=>{n(v.id),d(!1)},"onClick"),children:[(0,t.jsx)(pr,{agent:v,size:16,className:"shrink-0 h-3 w-3 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:v.name}),(0,t.jsx)("span",{className:"text-muted-foreground ml-auto shrink-0",children:GU[v.role]??v.role})]},v.id))]})]})}r(CHe,"ReportsToPicker");var _He="__secret_folder__:";function IHe(e){return!e||e==="active"?null:(0,t.jsx)(ct,{variant:"outline",className:"ml-auto text-(length:--text-nano) font-normal text-muted-foreground",children:e})}r(IHe,"statusBadge");function Kfe(e){return e.split("/").filter(s=>s.length>0)}r(Kfe,"splitSecretPath$1");function S2(e){return e.join("/")}r(S2,"pathKey$1");function HN(e){return e.length>0?`/${e.join("/")}`:"/"}r(HN,"pathLabel");function AHe(e,s){return e.length<s.length?!1:s.every((n,a)=>e[a]===n)}r(AHe,"pathStartsWith");function MY(e){return`${_He}${S2(e)}`}r(MY,"folderValue");function RHe(e,s,n){const a=s.length,i=new Map,o=[];for(const c of e){const d=Kfe(c.name);if(AHe(d,s)){if(d.length>a+1){const m=d.slice(0,a+1),h=S2(m);if(!i.has(h)){const p=m[m.length-1]??"/",f=HN(m);i.set(h,{key:`folder-${h||"root"}`,value:MY(m),label:p,title:f,searchText:f,kind:"folder",folderPath:h,pathHint:f})}continue}if(d.length===a+1||a===0&&d.length===0){const m=d.at(-1)??c.name;o.push({key:`browse-${c.id}`,value:c.id,label:m,title:c.name,searchText:`${c.key} ${c.name}`,secret:c,status:c.status,kind:"secret",pathHint:c.name,disabled:c.status!=="active"&&c.id!==n})}}}const l=[];if(s.length>0){const c=s.slice(0,-1);l.push({key:`folder-up-${S2(s)}`,value:MY(c),label:"Up one folder",title:HN(c),searchText:HN(c),kind:"back",folderPath:S2(c),pathHint:HN(c)})}return l.push(...i.values(),...o),{id:"browse-secrets",label:s.length>0?HN(s):"Browse secrets",options:l}}r(RHe,"buildFolderGroup");function tK({secretId:e,secrets:s,recentlyUsedSecrets:n,disabled:a,onSelect:i,onCreateNew:o,triggerClassName:l,disablePortal:c}){const[d,m]=(0,u.useState)(""),h=(0,u.useMemo)(()=>s.find(w=>w.id===e)??null,[s,e]),p=!!e&&!h,f=(0,u.useMemo)(()=>d?d.split("/"):[],[d]),g=(0,u.useMemo)(()=>s.some(w=>Kfe(w.name).length>1),[s]),v=(0,u.useMemo)(()=>{const w=[];p&&w.push({id:"current-missing",label:"Current",options:[{key:`missing-${e}`,value:e,label:`Missing secret (${e.slice(0,8)}…)`,title:`Missing secret (${e})`,missing:!0,disabled:!0}]});const S=(n??[]).filter(j=>j.status==="active"&&j.id!==e);return S.length>0&&w.push({id:"recently-used",label:"Recently used",options:S.map(j=>({key:`recent-${j.id}`,value:j.id,label:j.name,title:j.name,searchText:`${j.key} ${j.name}`,secret:j,status:j.status,kind:"secret"}))}),w.push({id:"all-secrets",label:S.length>0?"All secrets":void 0,options:s.map(j=>({key:`all-${j.id}`,value:j.id,label:j.name,title:j.name,searchText:`${j.key} ${j.name}`,secret:j,status:j.status,kind:"secret",disabled:j.status!=="active"&&j.id!==e}))}),w},[p,n,e,s]),y=(0,u.useCallback)((w,S)=>{if(!g||P2e(w))return S;const j=RHe(s,f,e),N=S.filter(_=>_.id==="current-missing"||_.id==="recently-used");return j.options.length>0?[...N,j]:N},[f,g,e,s]);return(0,t.jsx)(bv,{value:e||"",groups:v,onValueChange:r((w,S)=>{if(S.folderPath!==void 0)return m(S.folderPath),!1;m(""),i(w)},"onValueChange"),deriveGroups:y,disabled:a,disablePortal:c,placeholder:"Select secret…",searchPlaceholder:"Search secrets…",emptyMessage:"No matching secrets",triggerClassName:z("h-(--sz-34px) min-h-(--sz-34px) font-mono text-sm",p&&"border-destructive text-destructive",h&&h.status!=="active"&&"border-amber-500/60",l),renderValue:r(w=>{if(!w)return(0,t.jsx)("span",{className:"text-muted-foreground",children:"Select secret…"});if(w.missing)return(0,t.jsxs)("span",{className:"flex w-full min-w-0 items-center gap-1.5 text-destructive",children:[(0,t.jsx)(yi,{className:"size-3.5 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:w.label})]});const S=w.status&&w.status!=="active";return(0,t.jsxs)("span",{className:"flex w-full min-w-0 items-center gap-1.5",title:w.title,children:[(0,t.jsx)(yi,{className:z("size-3.5 shrink-0",S?"text-amber-600":"text-muted-foreground")}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:w.label}),S?(0,t.jsxs)("span",{className:"text-amber-600",children:["(",w.status,")"]}):null]})},"renderValue"),renderOption:r((w,{selected:S})=>{if(w.kind==="folder"||w.kind==="back"){const j=w.kind==="back"?g3e:Kc;return(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",title:w.title??w.label,children:[(0,t.jsx)(j,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,t.jsx)("span",{className:z("truncate text-sm",S&&"font-medium"),children:w.label}),w.pathHint?(0,t.jsx)("span",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground",children:w.pathHint}):null]})]})}return(0,t.jsxs)("span",{className:z("flex min-w-0 flex-1 items-center gap-1.5",w.disabled&&"opacity-60"),title:w.title??w.label,children:[(0,t.jsx)(yi,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-col",children:[(0,t.jsx)("span",{className:z("min-w-0 truncate font-mono text-sm",S&&"font-medium"),children:w.label}),w.pathHint&&w.pathHint!==w.label?(0,t.jsx)("span",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground",children:w.pathHint}):null]}),IHe(w.status)]})},"renderOption"),createItem:o?{render:r(w=>(0,t.jsxs)("span",{className:"flex items-center gap-1.5 text-sm",children:[(0,t.jsx)(yn,{className:"size-3.5 shrink-0"}),w.trim()?(0,t.jsxs)("span",{children:["Create secret ",(0,t.jsxs)("span",{className:"font-mono",children:["“",w.trim(),"”"]}),"…"]}):(0,t.jsx)("span",{children:"Create new secret…"})]}),"render"),onSelect:r(w=>o(w),"onSelect")}:void 0})}r(tK,"SecretPicker");var THe=/^[a-z][a-z0-9_]*$/,DY="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40 focus-visible:ring-2 focus-visible:ring-ring/40";function Vfe({mode:e,initialName:s,initialValue:n,existingSecretNames:a,onCancel:i,onSubmit:o}){const[l,c]=(0,u.useState)(s),[d,m]=(0,u.useState)(n),[h,p]=(0,u.useState)(!1),[f,g]=(0,u.useState)(!1),[v,y]=(0,u.useState)(null),[w,S]=(0,u.useState)(!1),j=l.trim(),N=j?THe.test(j)?a?.some(T=>T.toLowerCase()===j)?"A secret with this name already exists":null:"Use lowercase letters, digits and _":w?"Name is required":null,_=d.length===0&&w?"Value is required":null,A=!f&&j.length>0&&d.length>0&&!N;async function C(){if(S(!0),!!A){g(!0),y(null);try{await o(j,d)}catch(T){y(T instanceof Error?T.message:"Failed to create secret"),g(!1)}}}r(C,"handleSubmit");const I=e==="create"?"Create & bind":"Store & bind";return(0,t.jsxs)("div",{className:"w-72 space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(D2e,{className:"text-sm font-medium",children:e==="create"?"Create secret":"Store value as secret"}),e==="store"?(0,t.jsxs)(M2e,{className:"text-(length:--text-micro) text-muted-foreground",children:["Moves the typed value into an encrypted organization secret and binds"," ",(0,t.jsx)("span",{className:"font-mono",children:s||"this variable"})," to it."]}):null]}),(0,t.jsxs)("label",{className:"block space-y-1",children:[(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium text-muted-foreground",children:"Name"}),(0,t.jsx)("input",{className:z(DY,N&&"border-destructive focus-visible:ring-destructive/40"),value:l,autoFocus:!0,spellCheck:!1,placeholder:"secret_name","aria-label":"Secret name","aria-invalid":N?!0:void 0,onChange:r(T=>c(T.target.value),"onChange"),onBlur:r(()=>S(!0),"onBlur"),onKeyDown:r(T=>{T.key==="Enter"&&(T.preventDefault(),C())},"onKeyDown")}),N?(0,t.jsx)("span",{className:"block text-(length:--text-micro) text-destructive",children:N}):null]}),(0,t.jsxs)("label",{className:"block space-y-1",children:[(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium text-muted-foreground",children:"Value"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{className:z(DY,"pr-8",_&&"border-destructive focus-visible:ring-destructive/40"),type:h?"text":"password",value:d,readOnly:e==="store",spellCheck:!1,placeholder:e==="create"?"value":void 0,"aria-label":"Secret value","aria-invalid":_?!0:void 0,onChange:e==="create"?T=>m(T.target.value):void 0}),(0,t.jsx)("button",{type:"button",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded p-1 text-muted-foreground hover:text-foreground","aria-label":h?"Hide value":"Show value",onClick:r(()=>p(T=>!T),"onClick"),children:h?(0,t.jsx)(Ym,{className:"h-3.5 w-3.5"}):(0,t.jsx)(ud,{className:"h-3.5 w-3.5"})})]}),_?(0,t.jsx)("span",{className:"block text-(length:--text-micro) text-destructive",children:_}):null]}),v?(0,t.jsx)("p",{className:"text-(length:--text-micro) text-destructive",children:v}):null,(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-0.5",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",onClick:i,disabled:f,children:"Cancel"}),(0,t.jsxs)(F,{type:"button",size:"sm",onClick:r(()=>{C()},"onClick"),disabled:!A,children:[f?(0,t.jsx)(it,{className:"h-3.5 w-3.5 animate-spin"}):null,I]})]})]})}r(Vfe,"SecretPopoverForm");function Wfe(e){return(0,t.jsx)(Vfe,{mode:"create",...e})}r(Wfe,"CreateSecretPopover");function EHe(e){return(0,t.jsx)(Vfe,{mode:"store",...e})}r(EHe,"ConvertToSecretPopover");var PHe=/(api[-_]?key|access[-_]?token|auth(?:_?token)?|authorization|bearer|secret|passwd|password|credential|jwt|private[-_]?key|cookie|connectionstring)/i,MHe=[/^sk-[A-Za-z0-9-_]{16,}$/,/^gh[pousr]_[A-Za-z0-9]{20,}$/,/^github_pat_[A-Za-z0-9_]{20,}$/,/^xox[baprs]-[A-Za-z0-9-]{10,}$/,/^AKIA[0-9A-Z]{16}$/,/^AIza[0-9A-Za-z\-_]{20,}$/,/-----BEGIN (?:[A-Z ]+ )?PRIVATE KEY-----/,/^eyJ[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$/];function DHe(e){return e.length<24||/\s/.test(e)||!/^[A-Za-z0-9+/=_\-.]+$/.test(e)?!1:[/[a-z]/.test(e),/[A-Z]/.test(e),/[0-9]/.test(e)].filter(Boolean).length>=2}r(DHe,"looksHighEntropy");function LHe(e,s){return s?PHe.test(e)||MHe.some(n=>n.test(s))?!0:DHe(s):!1}r(LHe,"isSensitiveEnv");var LY=0;function $He(){return LY+=1,`env-row-${LY}`}r($He,"nextRowId");function ax(e="text"){return{id:$He(),name:"",source:e,textValue:"",secretId:"",userSecretKey:"",required:!0,version:"latest"}}r(ax,"emptyRow");function OHe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="secret_ref"}r(OHe,"isSecretRef");function FHe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="plain"}r(FHe,"isPlainObj");function BHe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="user_secret_ref"}r(BHe,"isUserSecretRef");function C4(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([s,n])=>{if(typeof n=="string")return{...ax(),name:s,textValue:n};if(OHe(n)){const a=typeof n.version=="number"?n.version:"latest";return{...ax(),name:s,source:"secret",secretId:typeof n.secretId=="string"?n.secretId:"",version:a}}if(BHe(n)){const a=typeof n.version=="number"?n.version:"latest";return{...ax(),name:s,source:"user_secret",userSecretKey:typeof n.key=="string"?n.key:"",required:n.required!==!1,version:a}}return FHe(n)?{...ax(),name:s,source:"text",textValue:typeof n.value=="string"?n.value:""}:{...ax(),name:s}})}r(C4,"rowsFromValue");function C2(e){const s={};for(const n of e){const a=n.name.trim();if(a)if(n.source==="secret"){if(!n.secretId)continue;s[a]={type:"secret_ref",secretId:n.secretId,version:n.version}}else if(n.source==="user_secret"){const i=n.userSecretKey.trim();if(!i)continue;s[a]={type:"user_secret_ref",key:i,version:n.version,required:n.required}}else s[a]={type:"plain",value:n.textValue}}return Object.keys(s).length>0?s:void 0}r(C2,"valueFromRows");var $Y="CLAUDE_CODE_OAUTH_TOKEN";function aj(){return C2([{...ax("user_secret"),name:"CLAUDE_CODE_OAUTH_TOKEN",userSecretKey:"CLAUDE_CODE_OAUTH_TOKEN",required:!0,version:"latest"}])??{}}r(aj,"buildFixedClaudeOAuthBinding");var qHe=/^[A-Za-z_][A-Za-z0-9_]*$/;function zHe(e,s,n){const a=e.trim();if(!a)return null;if(!qHe.test(a))return{level:"error",message:"Invalid name — use letters, digits and _"};if(s.has(a))return{level:"error",message:"Duplicate name"};for(const i of n)if(i&&a.startsWith(i))return{level:"warn",message:"Reserved prefix — provided automatically and may be overridden"};return null}r(zHe,"validateName");function UHe(e){const s=new Map;for(const a of e){const i=a.name.trim();i&&s.set(i,(s.get(i)??0)+1)}const n=new Set;for(const[a,i]of s)i>1&&n.add(a);return n}r(UHe,"computeDuplicateNames");function KHe(e,s){return s===e.source?{kind:"noop"}:s==="secret"?e.textValue.trim()?{kind:"open-store",name:AT(e.name)||"secret",value:e.textValue}:{kind:"to-secret"}:{kind:"to-text",undoFrom:e.secretId?{...e}:null}}r(KHe,"planSourceSwitch");function Hfe(e,s){if(e.source!=="secret"||!e.secretId)return null;const n=s.find(a=>a.id===e.secretId);return n?n.status!=="active"?{level:"warn",kind:"disabled",message:"Runs will fail until re-enabled or rebound."}:null:{level:"error",kind:"missing",message:"This secret no longer exists — runs will fail until you rebind."}}r(Hfe,"computeRowHealth");function Qfe(e,s){if(e.source!=="user_secret"||!e.userSecretKey||!s?.length)return null;const n=s.find(a=>a.key===e.userSecretKey);return n?n.status!=="active"?{level:"warn",kind:"disabled",message:"Runs will fail until this user secret definition is re-enabled or rebound."}:null:{level:"error",kind:"missing",message:"This user secret definition no longer exists — runs will fail until you rebind."}}r(Qfe,"computeUserSecretRowHealth");function AT(e){return e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}r(AT,"secretNameFromKey");function bS(e){return e.trim().toUpperCase().replace(/[^A-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}r(bS,"envKeyFromSecretName");var VHe="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40 focus-visible:ring-2 focus-visible:ring-ring/40",OY="min-w-0 flex-1 bg-transparent px-2 py-1.5 text-sm font-mono outline-none placeholder:text-muted-foreground/40";function WHe({row:e,isLast:s,secrets:n,userSecretDefinitions:a,recentlyUsedSecrets:i,disabled:o,nameIssue:l,showNameIssue:c,dirtyFields:d,onPatch:m,onRemove:h,onNameBlur:p,onNamePaste:f,onEnterInValueLast:g,onCreateSecret:v,onToast:y,focusRequest:w,onFocusConsumed:S}){const j=(0,u.useRef)(null),N=(0,u.useRef)(null),_=(0,u.useRef)(null),[A,C]=(0,u.useState)(null),[I,T]=(0,u.useState)(!1),[R,L]=(0,u.useState)(null),O=Hfe(e,n)??Qfe(e,a),$=e.source==="secret"?n.find(te=>te.id===e.secretId)??null:null,E=(a?.length??0)>0,q=e.source==="text"&&!e.sensitiveDismissed&&LHe(e.name,e.textValue);(0,u.useEffect)(()=>{w&&(w==="name"?j.current?.focus():e.source==="text"?N.current?.focus():e.source==="secret"?_.current?.querySelector("[role=combobox]")?.focus():_.current?.querySelector("select,input")?.focus(),S())},[w,S,e.source]),(0,u.useEffect)(()=>{if(!R)return;const te=window.setTimeout(()=>L(null),5e3);return()=>window.clearTimeout(te)},[R]);function B(te){if(te==="user_secret"){if(e.source==="user_secret")return;m({source:"user_secret",secretId:"",version:"latest"}),window.setTimeout(()=>_.current?.querySelector("select,input")?.focus(),0);return}const re=KHe(e,te);switch(re.kind){case"noop":return;case"open-store":{const{name:de,value:Z}=re;window.setTimeout(()=>C({mode:"store",name:de,value:Z}),0);return}case"to-secret":m({source:"secret",userSecretKey:"",required:!0}),window.setTimeout(()=>{_.current?.querySelector("[role=combobox]")?.focus()},0);return;case"to-text":re.undoFrom&&L(re.undoFrom),m({source:"text",secretId:"",userSecretKey:"",required:!0,version:"latest"}),window.setTimeout(()=>N.current?.focus(),0);return}}r(B,"switchSource");async function K(te,re){const de=await v(te,re);m({source:"secret",secretId:de.id,userSecretKey:"",required:!0,version:"latest",textValue:""}),y(`Secret ${de.name} created`),C(null)}r(K,"submitSecretPopover");function U(){const te=AT(e.name)||"secret",{textValue:re}=e;window.setTimeout(()=>C({mode:"store",name:te,value:re}),0)}r(U,"openStoreAsSecret");const D=e.source==="text"?"Text value":e.source==="secret"?"Organization secret reference":"User secret reference",V=`${e.id}-name-error`,H=`${e.id}-health`,J=d.name||d.value,X=$?Math.max(0,$.latestVersion):0,le=e.version==="latest"?"latest":`v${e.version}`,ce=e.version!=="latest";return(0,t.jsxs)("div",{className:z("group/row grid grid-cols-(--gtc-13) items-start gap-x-1.5 gap-y-1 rounded-md px-1 py-1","@[40rem]/env:grid-cols-(--gtc-14) @[40rem]/env:items-center",J&&"bg-amber-500/[0.06] ring-1 ring-amber-500/20"),children:[(0,t.jsx)("div",{className:"col-start-1 row-start-1 min-w-0 @[40rem]/env:row-start-1 @[40rem]/env:self-start",children:(0,t.jsx)("input",{ref:j,className:z(VHe,d.name&&"border-amber-500/70 bg-amber-500/10 focus-visible:ring-amber-500/40",c&&l?.level==="error"&&"border-destructive focus-visible:ring-destructive/40",c&&l?.level==="warn"&&"border-amber-500 focus-visible:ring-amber-500/40"),placeholder:"KEY",value:e.name,spellCheck:!1,disabled:o,"aria-label":"Variable name","aria-invalid":c&&l?.level==="error"?!0:void 0,"aria-describedby":c&&l?V:void 0,onChange:r(te=>m({name:te.target.value}),"onChange"),onBlur:p,onPaste:r(te=>{e.name||f(te.clipboardData.getData("text"))&&te.preventDefault()},"onPaste"),onKeyDown:r(te=>{te.key==="Enter"&&(te.preventDefault(),e.source==="text"?N.current?.focus():_.current?.querySelector("[role=combobox],select,input")?.focus())},"onKeyDown")})}),(0,t.jsxs)("div",{className:"col-span-2 col-start-1 row-start-2 min-w-0 @[40rem]/env:col-span-1 @[40rem]/env:col-start-2 @[40rem]/env:row-start-1",children:[(0,t.jsxs)(nr,{open:A!==null,onOpenChange:r(te=>{te||C(null)},"onOpenChange"),children:[(0,t.jsx)(J$,{asChild:!0,children:(0,t.jsxs)("div",{ref:_,className:z("relative flex items-stretch overflow-hidden rounded-md border border-border bg-transparent focus-within:ring-2 focus-within:ring-ring/40",d.value&&"border-amber-500/70 bg-amber-500/10 focus-within:ring-amber-500/40",o&&"opacity-60"),children:[(0,t.jsxs)(fa,{children:[(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)(pa,{asChild:!0,disabled:o,children:(0,t.jsxs)("button",{type:"button","aria-label":"Value source",className:"flex shrink-0 items-center gap-0.5 border-r border-border px-2 text-muted-foreground hover:bg-accent/50 disabled:pointer-events-none",children:[e.source==="text"?(0,t.jsx)(sPe,{className:"size-3.5"}):e.source==="secret"?(0,t.jsx)(yi,{className:"size-3.5"}):(0,t.jsx)(vu,{className:"size-3.5"}),(0,t.jsx)(en,{className:"size-3 opacity-60"})]})})}),(0,t.jsx)(Un,{side:"top",children:D})]}),(0,t.jsxs)(xa,{align:"start",className:"w-56",children:[(0,t.jsxs)(ps,{className:"flex-col items-start gap-0.5",onSelect:r(()=>B("text"),"onSelect"),children:[(0,t.jsx)("span",{className:"text-sm",children:"Text value"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"Store the value inline as plain text."})]}),(0,t.jsxs)(ps,{className:"flex-col items-start gap-0.5",onSelect:r(()=>B("secret"),"onSelect"),children:[(0,t.jsx)("span",{className:"text-sm",children:"Organization secret"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"Resolve a stored organization secret at run start."})]}),(0,t.jsxs)(ps,{className:"flex-col items-start gap-0.5",onSelect:r(()=>B("user_secret"),"onSelect"),children:[(0,t.jsx)("span",{className:"text-sm",children:"User secret"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"Resolve the responsible user's own value at run start."})]})]})]}),e.source==="text"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("input",{ref:N,className:OY,placeholder:"value",value:e.textValue,type:q?"password":"text",spellCheck:!1,disabled:o,"aria-label":"Variable value",onChange:r(te=>m({textValue:te.target.value}),"onChange"),onKeyDown:r(te=>{te.key==="Enter"&&s&&(te.preventDefault(),g())},"onKeyDown")}),q?(0,t.jsxs)("div",{className:"flex shrink-0 items-stretch border-l border-border",children:[(0,t.jsxs)("button",{type:"button",onClick:U,disabled:o,className:"flex items-center gap-1 px-2 text-(length:--text-micro) text-amber-700 hover:bg-amber-500/10 dark:text-amber-400",title:"This value looks sensitive — store it as a secret",children:[(0,t.jsx)(kl,{className:"size-3.5"}),(0,t.jsx)("span",{className:"hidden @[30rem]/env:inline",children:"Store as secret"})]}),(0,t.jsx)("button",{type:"button",onClick:r(()=>m({sensitiveDismissed:!0}),"onClick"),disabled:o,"aria-label":"Dismiss sensitive-value suggestion",title:"Dismiss — keep this value as plain text",className:"flex items-center px-1.5 text-amber-700/60 hover:bg-amber-500/10 hover:text-amber-700 dark:text-amber-400/60 dark:hover:text-amber-400",children:(0,t.jsx)(ir,{className:"size-3"})})]}):null]}):e.source==="secret"?(0,t.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,t.jsx)(tK,{secretId:e.secretId,secrets:n,recentlyUsedSecrets:i,disabled:o,onSelect:r(te=>m({secretId:te,version:"latest"}),"onSelect"),onCreateNew:r(te=>C({mode:"create",name:AT(te)||te.trim(),value:""}),"onCreateNew"),triggerClassName:z("rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0",$&&$.status==="active"&&"pr-24 has-[>svg]:!pr-24")}),$&&$.status==="active"?(0,t.jsxs)(nr,{open:I,onOpenChange:T,children:[(0,t.jsx)(J$,{asChild:!0,children:(0,t.jsx)("button",{type:"button",disabled:o,onClick:r(te=>{te.preventDefault(),te.stopPropagation(),T(re=>!re)},"onClick"),"aria-label":"Version",className:z("absolute right-8 top-1/2 z-10 -translate-y-1/2 rounded px-1.5 py-0.5 text-(length:--text-nano) font-medium",ce?"bg-amber-500/15 text-amber-700 dark:text-amber-400":"text-muted-foreground hover:bg-accent"),children:le})}),(0,t.jsxs)(Wn,{align:"end",className:"w-44 p-1",role:"radiogroup","aria-label":"Secret version",children:[(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":e.version==="latest",onClick:r(()=>{m({version:"latest"}),T(!1)},"onClick"),className:z("flex w-full items-center justify-between rounded px-2 py-1.5 text-sm hover:bg-accent",e.version==="latest"&&"font-medium"),children:["latest ",(0,t.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:"(recommended)"})]}),Array.from({length:X},(te,re)=>X-re).filter(te=>te>0).map(te=>(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":e.version===te,onClick:r(()=>{m({version:te}),T(!1)},"onClick"),className:z("flex w-full items-center rounded px-2 py-1.5 text-sm hover:bg-accent",e.version===te&&"font-medium text-amber-700 dark:text-amber-400"),children:["v",te]},te))]})]}):null]}):(0,t.jsxs)("div",{className:"grid min-w-0 flex-1 grid-cols-(--gtc-13)",children:[E?(0,t.jsxs)("select",{"aria-label":"User secret",value:e.userSecretKey,disabled:o,onChange:r(te=>{const re=te.target.value,de=a?.find(Z=>Z.key===re);m({userSecretKey:re,...de&&!e.name.trim()?{name:de.key.toUpperCase()}:{}})},"onChange"),className:"min-w-0 bg-transparent px-2 py-1.5 text-sm font-mono outline-none disabled:pointer-events-none",children:[(0,t.jsx)("option",{value:"",children:"Select user secret..."}),e.userSecretKey&&!a?.some(te=>te.key===e.userSecretKey)?(0,t.jsxs)("option",{value:e.userSecretKey,children:["Unknown (",e.userSecretKey,")"]}):null,(a??[]).map(te=>(0,t.jsxs)("option",{value:te.key,children:[te.name,te.status!=="active"?` (${te.status})`:""]},te.id))]}):(0,t.jsx)("input",{className:OY,placeholder:"user-secret key",value:e.userSecretKey,spellCheck:!1,disabled:o,"aria-label":"User secret key",onChange:r(te=>m({userSecretKey:te.target.value}),"onChange")}),(0,t.jsxs)("select",{"aria-label":"Requirement",value:e.required?"required":"optional",disabled:o,onChange:r(te=>m({required:te.target.value==="required"}),"onChange"),className:"border-l border-border bg-transparent px-2 py-1.5 text-xs font-medium text-muted-foreground outline-none disabled:pointer-events-none",children:[(0,t.jsx)("option",{value:"required",children:"Required"}),(0,t.jsx)("option",{value:"optional",children:"Optional"})]})]})]})}),(0,t.jsx)(Wn,{align:"start",className:"w-auto p-3",onInteractOutside:r(te=>{const re=te.detail.originalEvent.target;re&&_.current?.contains(re)&&te.preventDefault()},"onInteractOutside"),children:A?.mode==="store"?(0,t.jsx)(EHe,{initialName:A.name,initialValue:A.value,existingSecretNames:n.map(te=>te.name),onCancel:r(()=>C(null),"onCancel"),onSubmit:K}):A?.mode==="create"?(0,t.jsx)(Wfe,{initialName:A.name,initialValue:A.value,existingSecretNames:n.map(te=>te.name),onCancel:r(()=>C(null),"onCancel"),onSubmit:K}):null})]}),O?(0,t.jsx)("p",{id:H,role:"status",className:z("mt-0.5 text-(length:--text-micro)",O.level==="error"?"text-destructive":"text-amber-600 dark:text-amber-400"),children:O.message}):null,R?(0,t.jsxs)("p",{className:"mt-0.5 inline-flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:["Reverted to text —"," ",(0,t.jsx)("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2 hover:text-primary",onClick:r(()=>{m({source:"secret",secretId:R.secretId,version:R.version,textValue:""}),L(null)},"onClick"),children:"Undo"})]}):null]}),c&&l?(0,t.jsx)("p",{id:V,className:z("col-span-2 col-start-1 row-start-3 min-w-0 text-(length:--text-micro) @[40rem]/env:col-span-2 @[40rem]/env:row-start-2",l.level==="error"?"text-destructive":"text-amber-600 dark:text-amber-400"),children:l.message}):null,(0,t.jsxs)("div",{className:"col-start-2 row-start-1 flex items-center justify-end gap-0.5 self-start @[40rem]/env:col-start-3 @[40rem]/env:self-center",children:[e.source==="text"&&!q&&(e.name.trim()||e.textValue)?(0,t.jsxs)(fa,{children:[(0,t.jsx)(pa,{asChild:!0,disabled:o,children:(0,t.jsx)("button",{type:"button","aria-label":"More actions",className:"rounded p-1 text-muted-foreground opacity-100 hover:bg-accent hover:text-foreground @[40rem]/env:opacity-0 @[40rem]/env:group-hover/row:opacity-100 @[40rem]/env:group-focus-within/row:opacity-100",children:(0,t.jsx)(Ei,{className:"size-4"})})}),(0,t.jsx)(xa,{align:"end",children:(0,t.jsx)(ps,{onSelect:r(()=>{window.setTimeout(U,0)},"onSelect"),children:"Store as secret…"})})]}):null,(0,t.jsx)("button",{type:"button",onClick:h,disabled:o,"aria-label":`Remove ${e.name.trim()||"variable"}`,className:"rounded p-1 text-muted-foreground opacity-100 hover:bg-destructive/10 hover:text-destructive @[40rem]/env:opacity-0 @[40rem]/env:group-hover/row:opacity-100 @[40rem]/env:group-focus-within/row:opacity-100",children:(0,t.jsx)(ir,{className:"size-4"})})]})]})}r(WHe,"EnvironmentVariableRow");var HHe=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)$/;function QHe(e){const s=e.indexOf(" #");return s>=0?e.slice(0,s):e}r(QHe,"stripInlineComment");function GHe(e){const s=e.trim();if(s.length>=2){const n=s[0],a=s[s.length-1];if(n==='"'&&a==='"'||n==="'"&&a==="'")return s.slice(1,-1)}return QHe(s).trim()}r(GHe,"unquote");function YHe(e){const s=[];for(const n of e.split(/\r?\n/)){const a=n.trim();if(!a||a.startsWith("#"))continue;const i=HHe.exec(a);if(!i)continue;const o=i[1],l=GHe(i[2]);s.push({key:o,value:l})}return s}r(YHe,"parseDotenv");var JHe=["PAPERCLIP_"],XHe="Set the KEY to the env var name the process expects, for example GH_TOKEN. Choose a secret to resolve a stored value at run start. PAPERCLIP_* variables are injected automatically.";function IF(e){if(!e||typeof e!="object")return[];const s=new Map;for(const[n,a]of Object.entries(e)){const i=n.trim();if(i)if(typeof a=="string")s.set(i,{type:"plain",value:a});else if(a?.type==="secret_ref"){const o=typeof a.secretId=="string"?a.secretId:"";if(!o)continue;s.set(i,{type:"secret_ref",secretId:o,version:typeof a.version=="number"?a.version:"latest"})}else if(a?.type==="user_secret_ref"){const o=typeof a.key=="string"?a.key.trim():"";if(!o)continue;s.set(i,{type:"user_secret_ref",key:o,version:typeof a.version=="number"?a.version:"latest",required:a.required!==!1})}else a?.type==="plain"?s.set(i,{type:"plain",value:typeof a.value=="string"?a.value:""}):s.set(i,{type:"plain",value:""})}return[...s.entries()].sort(([n],[a])=>n.localeCompare(a))}r(IF,"normalizedEnvEntries");function QN(e){return JSON.stringify(IF(e))}r(QN,"normalizedEnvKey");var _4=3;function I4(e){const s=e.slice(0,_4).join(", ");return e.length>_4?`${s} +${e.length-_4} more`:s}r(I4,"formatChangedNames");function FY(e){return e.map(s=>({...s}))}r(FY,"cloneRows");function ZHe(e,s){return s?{name:e.name.trim()!==s.name.trim(),value:e.source!==s.source||e.textValue!==s.textValue||e.secretId!==s.secretId||e.userSecretKey!==s.userSecretKey||e.required!==s.required||e.version!==s.version}:{name:!!e.name.trim(),value:e.source!=="text"||!!e.textValue||!!e.secretId||e.version!=="latest"}}r(ZHe,"rowDirtyFields");var Yb=(0,u.forwardRef)(r(function({value:s,onChange:n,secrets:a,userSecretDefinitions:i,onCreateSecret:o,recentlyUsedSecrets:l,disabled:c,reservedPrefixes:d=JHe,footerHint:m,onDirtyChange:h,hideDraftActions:p=!1},f){const g=Sc(),v=(0,u.useRef)(null),[y,w]=(0,u.useState)(()=>C4(s)),S=(0,u.useRef)(y),[j,N]=(0,u.useState)(()=>FY(y)),_=(0,u.useMemo)(()=>QN(s),[]),A=(0,u.useRef)(_),C=(0,u.useRef)(_),I=(0,u.useRef)(null),[T,R]=(0,u.useState)(_),[L,O]=(0,u.useState)(()=>new Set(C4(s).map(oe=>oe.name.trim()).filter(Boolean))),[$,E]=(0,u.useState)(null);(0,u.useEffect)(()=>{S.current=y},[y]);function q(oe,je=S.current){A.current=oe,R(oe),N(FY(je))}r(q,"markCommitted");function B(oe){O(je=>{const _e=new Set(je);for(const xe of oe){const Ae=xe.name.trim();Ae&&_e.add(Ae)}return _e})}r(B,"touchCommittedNames");function K(oe){const je=C4(oe);return w(je),B(je),je}r(K,"adoptExternalValue"),(0,u.useEffect)(()=>{const oe=QN(s);if(oe===C.current)return;C.current=oe;const je=QN(C2(S.current)),_e=je!==A.current,xe=I.current===oe;if(xe&&(I.current=null),!_e){q(oe,K(s));return}(xe||je===oe)&&(B(S.current),q(oe))},[s]);const U=(0,u.useMemo)(()=>C2(y),[y]),D=(0,u.useMemo)(()=>QN(U),[U]),V=D!==T;(0,u.useEffect)(()=>{h?.(!c&&V)},[c,V,h]);const H=(0,u.useMemo)(()=>{const oe=new Map(IF(C2(j)).map(([Ae,Ye])=>[Ae,JSON.stringify(Ye)])),je=new Map(IF(U).map(([Ae,Ye])=>[Ae,JSON.stringify(Ye)])),_e=[],xe=[];for(const[Ae,Ye]of je)oe.has(Ae)?oe.get(Ae)!==Ye&&xe.push(Ae):_e.push(Ae);return{added:_e,changed:xe,removed:[...oe.keys()].filter(Ae=>!je.has(Ae))}},[j,U]),J=(0,u.useMemo)(()=>{const oe=[];return H.added.length>0&&oe.push(`New: ${I4(H.added)}`),H.changed.length>0&&oe.push(`Edited: ${I4(H.changed)}`),H.removed.length>0&&oe.push(`Removed: ${I4(H.removed)}`),oe.join(" · ")},[H]);(0,u.useEffect)(()=>{if(c||!V)return;function oe(je){je.preventDefault(),je.returnValue=""}return r(oe,"handleBeforeUnload"),window.addEventListener("beforeunload",oe),()=>window.removeEventListener("beforeunload",oe)},[c,V]);const X=(0,u.useCallback)(()=>c||!V?null:(I.current=D,(0,Yp.flushSync)(()=>{n(U)}),U??{}),[c,U,D,V,n]);(0,u.useImperativeHandle)(f,()=>({flushPendingDraft:X}),[X]),(0,u.useEffect)(()=>{const oe=v.current?.closest("form");if(!oe)return;function je(){X()}return r(je,"handleSubmit"),oe.addEventListener("submit",je,!0),()=>oe.removeEventListener("submit",je,!0)},[X]),(0,u.useEffect)(()=>{const oe=v.current;if(!oe)return;const je=oe;function _e(xe){const Ae=xe.target;if(!(Ae instanceof Element)||je.contains(Ae))return;const Ye=Ae.closest("button");if(!Ye||Ye.disabled)return;const Oe=`${Ye.getAttribute("aria-label")??""} ${Ye.textContent??""}`;(Ye.type==="submit"||/\b(save|create|update|test|import)\b/i.test(Oe))&&X()}return r(_e,"handleDocumentClick"),document.addEventListener("click",_e,!0),()=>document.removeEventListener("click",_e,!0)},[X]);function le(oe){w(oe)}r(le,"updateDraft");function ce(oe,je){le(y.map(_e=>_e.id===oe?{..._e,...je}:_e))}r(ce,"patchRow");function te(oe){le(y.filter(je=>je.id!==oe))}r(te,"removeRow");function re(){const oe=ax();w([...y,oe]),E({rowId:oe.id,field:"name"})}r(re,"addRow");function de(oe){const je=y.find(_e=>_e.id===oe)?.name.trim();je&&O(_e=>{if(_e.has(je))return _e;const xe=new Set(_e);return xe.add(je),xe})}r(de,"markTouched");function Z(oe,je){const _e=YHe(oe);if(_e.length===0)return!1;const xe=y.filter(Ae=>Ae.id!==je).map(Ae=>({...Ae}));for(const{key:Ae,value:Ye}of _e){const Oe=xe.find(Xe=>Xe.name.trim()===Ae);Oe?(Oe.name=Ae,Oe.source="text",Oe.textValue=Ye,Oe.secretId="",Oe.sensitiveDismissed=!1,Oe.userSecretKey="",Oe.required=!0):xe.push({...ax(),name:Ae,textValue:Ye})}return le(xe),g?.pushToast({title:`Imported ${_e.length} variable${_e.length===1?"":"s"}`,tone:"success"}),!0}r(Z,"bulkImport");function Y(oe){const je=y.map(Ae=>({...Ae})),_e=je[je.length-1];let xe;_e&&!_e.name&&!_e.textValue&&!_e.secretId&&!_e.userSecretKey?xe=_e:(xe=ax(),je.push(xe)),xe.source="secret",xe.secretId=oe.id,xe.version="latest",xe.name||(xe.name=bS(oe.name)),le(je)}r(Y,"bindRecentSecret");function G(){V&&(I.current=D,n(U))}r(G,"saveDraft");function fe(){I.current=null,C.current=QN(s);const oe=K(s);q(C.current,oe)}r(fe,"revertDraft");const se=(0,u.useMemo)(()=>UHe(y),[y]),ae=(0,u.useMemo)(()=>y.reduce((oe,je)=>Hfe(je,a)||Qfe(je,i)?oe+1:oe,0),[y,a,i]),ie=(0,u.useMemo)(()=>{const oe=new Set(y.filter(je=>je.source==="secret"&&je.secretId).map(je=>je.secretId));return(l??[]).filter(je=>je.status==="active"&&!oe.has(je.id)).slice(0,8)},[l,y]),ue=y.length>0,pe=m===void 0?XHe:m,be=(0,u.useMemo)(()=>new Map(j.map(oe=>[oe.id,oe])),[j]);return(0,t.jsx)(md,{children:(0,t.jsxs)("div",{ref:v,className:"@container/env space-y-2",children:[ae>1?(0,t.jsxs)("p",{className:"inline-flex items-center gap-1.5 text-(length:--text-micro) font-medium text-amber-700 dark:text-amber-400",children:[(0,t.jsx)(Vi,{className:"size-3.5"}),ae," bindings need attention"]}):null,ue?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"hidden gap-x-1.5 @[40rem]/env:grid @[40rem]/env:grid-cols-(--gtc-14)",children:[(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Name"}),(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Value"}),(0,t.jsx)("span",{})]}),y.map((oe,je)=>{const _e=zHe(oe.name,se,d),xe=L.has(oe.name.trim());return(0,t.jsx)(WHe,{row:oe,isLast:je===y.length-1,secrets:a,userSecretDefinitions:i,recentlyUsedSecrets:l,disabled:c,nameIssue:_e,showNameIssue:xe,dirtyFields:ZHe(oe,be.get(oe.id)),onPatch:r(Ae=>ce(oe.id,Ae),"onPatch"),onRemove:r(()=>te(oe.id),"onRemove"),onNameBlur:r(()=>de(oe.id),"onNameBlur"),onNamePaste:r(Ae=>Z(Ae,oe.id),"onNamePaste"),onEnterInValueLast:re,onCreateSecret:o,onToast:r(Ae=>g?.pushToast({title:Ae,tone:"success"}),"onToast"),focusRequest:$?.rowId===oe.id?$.field:null,onFocusConsumed:r(()=>E(null),"onFocusConsumed")},oe.id)})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No environment variables"}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-1",children:[(0,t.jsxs)("button",{type:"button",onClick:re,disabled:c,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:[(0,t.jsx)(yn,{className:"size-3.5"}),"Add variable"]}),ie.length>0&&!c?(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-(length:--text-micro) text-muted-foreground/70",children:[(0,t.jsx)(yi,{className:"size-3"}),"Recently used:"]}),ie.map(oe=>(0,t.jsxs)("button",{type:"button",onClick:r(()=>Y(oe),"onClick"),className:"inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 font-mono text-(length:--text-micro) text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",title:`Bind ${oe.name}`,children:["+ ",oe.name]},oe.id))]}):null]}),V&&!c&&!p?(0,t.jsxs)("div",{role:"status",className:"mt-3 flex w-full flex-col gap-3 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-3 text-amber-950 shadow-sm dark:bg-amber-500/15 dark:text-amber-100 @[34rem]/env:flex-row @[34rem]/env:items-center @[34rem]/env:justify-between",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)("span",{className:"size-2 rounded-full bg-amber-500 shadow-(--shadow-extract-13)"}),(0,t.jsx)("span",{children:"Unsaved changes"})]}),J?(0,t.jsx)("p",{className:"min-w-0 truncate pl-4 text-xs text-amber-950/80 dark:text-amber-100/80",title:J,children:J}):null]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:fe,className:"inline-flex h-9 items-center gap-1.5 rounded-md border border-amber-500/30 bg-background px-3 text-sm font-medium text-foreground transition-colors hover:bg-amber-500/10 dark:bg-background/80",children:[(0,t.jsx)(Ii,{className:"size-4"}),"Revert"]}),(0,t.jsxs)("button",{type:"button",onClick:G,className:"inline-flex h-9 items-center gap-1.5 rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90",children:[(0,t.jsx)(Hp,{className:"size-4"}),"Save"]})]})]}):null,pe?(0,t.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground/70",children:pe}):null,y.some(oe=>oe.source==="user_secret"&&oe.userSecretKey)?(0,t.jsxs)("p",{className:"inline-flex items-start gap-1 text-(length:--text-micro) text-muted-foreground/70",children:[(0,t.jsx)(vu,{className:"mt-0.5 size-3 shrink-0"}),(0,t.jsx)("span",{children:"User secrets resolve from the user responsible for the run. Required bindings fail until that user sets their value under Secrets → My secrets."})]}):null]})})},"EnvironmentVariablesEditor")),eQe="env.",P1="access.",AF=/^[A-Za-z_][A-Za-z0-9_]*$/;function Gfe(e){return e?e.startsWith("access.")?"api":e.startsWith("env.")?"env":"config":"config"}r(Gfe,"deliveryModeForConfigPath");function Yfe(e){switch(e){case"env":return"Env var";case"api":return"API access";default:return"Config"}}r(Yfe,"deliveryModeLabel");function tQe(e){switch(e){case"env":return"Injected as an environment variable at run start.";case"api":return"Fetched on demand via the run-bound agent API. Never written to the environment.";default:return"Provided through adapter configuration."}}r(tQe,"deliveryModeDescription");function Jfe(e){return e?e.startsWith("access.")?e.slice(7):e.startsWith("env.")?e.slice(4):e:""}r(Jfe,"aliasFromConfigPath");function sQe(e){switch(e){case"agent_api":return"Agent API";case"plugin_worker":return"Plugin worker";case"tool_connection":return"Tool connection";default:return e.charAt(0).toUpperCase()+e.slice(1)}}r(sQe,"consumerTypeLabel");var nQe={numeric:!0,sensitivity:"base"};function Pk(e){return e.kind==="company"?e.secret.name:e.definition.name}r(Pk,"getSecretPathRowName");function hw(e){return e.split("/").filter(s=>s.length>0)}r(hw,"splitSecretPath");function A4(e){return hw(e).join("/")}r(A4,"normalizeSecretPath");function BY(e,s){return s.every((n,a)=>e[a]===n)}r(BY,"startsWithSegments");function qY(e,s){return e.localeCompare(s,void 0,nQe)}r(qY,"compareNames");function rQe(e,s){const n=hw(s),a=e.map(c=>({row:c,name:Pk(c),segments:hw(Pk(c))})),i=new Set,o=[];for(const c of a){if(!BY(c.segments,n))continue;const d=c.segments.length-n.length;(d===0||d===1)&&o.push(c.row),d>=2&&i.add(c.segments[n.length])}const l=[...i].map(c=>{const d=[...n,c],m=new Set;let h=0;for(const p of a){if(!BY(p.segments,d))continue;const f=p.segments.length-d.length;if(!(f<1)){h+=1;for(let g=1;g<f;g+=1)m.add(p.segments.slice(d.length,d.length+g).join("/"))}}return{name:c,path:d.join("/"),secretCount:h,folderCount:m.size}});return l.sort((c,d)=>qY(c.name,d.name)),o.sort((c,d)=>qY(Pk(c),Pk(d))),{folders:l,secrets:o}}r(rQe,"buildSecretPathListing");function aQe(e){const s=hw(e);return s.map((n,a)=>({name:n,path:s.slice(0,a+1).join("/")}))}r(aQe,"buildSecretPathBreadcrumbs");function iQe(e){return e.trim()?e.includes("/")?"Folder name cannot contain slashes.":null:"Folder name is required."}r(iQe,"validateSecretFolderSegment");function cC({name:e,basePath:s="",className:n,leafClassName:a}){const i=hw(e),o=hw(s),l=o.length>0&&o.every((h,p)=>i[p]===h)&&i.length>o.length?i.slice(o.length):i,c=l.length>0?l:[e],d=c[c.length-1],m=c.slice(0,-1).join("/");return(0,t.jsxs)("span",{className:z("min-w-0 truncate",n),children:[m?(0,t.jsxs)("span",{className:"text-muted-foreground",children:[m,"/"]}):null,(0,t.jsx)("span",{className:z("font-medium text-foreground",a),children:d})]})}r(cC,"SecretPathName");function oQe(e,s){const n=e?`sha256:${e.slice(0,10)}…`:"no fingerprint",a=typeof s=="number"?`${s} ${s===1?"byte":"bytes"}`:null;return a?`${n} · ${a}`:n}r(oQe,"fingerprintLabel");function Xfe({fingerprint:e,length:s,className:n}){const{pushToast:a}=da(),i=oQe(e,s);if(!e)return(0,t.jsxs)("span",{className:z("inline-flex items-center gap-1 font-mono",n),children:[(0,t.jsx)(nH,{className:"size-3 shrink-0"}),i]});const o=`sha256:${e}`;return(0,t.jsxs)("button",{type:"button",onClick:r(()=>{Hr(o).then(()=>a({title:"Fingerprint copied",tone:"success"})).catch(()=>a({title:"Couldn’t copy fingerprint",tone:"error"}))},"onClick"),title:`Copy full digest — ${o}`,className:z("inline-flex items-center gap-1 font-mono hover:text-foreground",n),children:[(0,t.jsx)(nH,{className:"size-3 shrink-0"}),i,(0,t.jsx)(jr,{className:"size-3 shrink-0 opacity-60"})]})}r(Xfe,"FingerprintChip");function sK({justification:e,className:s}){return(0,t.jsxs)("div",{className:z("space-y-0.5",s),children:[(0,t.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:"Reason given by the agent"}),(0,t.jsxs)("p",{className:"whitespace-pre-wrap break-words text-xs text-foreground/80",children:["“",e,"”"]})]})}r(sK,"ProposalJustification");function dC({agent:e,className:s}){return(0,t.jsxs)("span",{className:z("inline-flex min-w-0 items-center gap-1",s),children:[(0,t.jsx)(pr,{agent:e,size:16,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:e.name})]})}r(dC,"AgentRefChip");function nK({configPath:e}){const s=Gfe(e),n=s==="env",a=s==="api";return(0,t.jsxs)(ct,{variant:"outline",className:z("h-5 gap-1 px-1.5 text-(length:--text-nano) font-normal",n&&"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",a&&"border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300",!n&&!a&&"border-border bg-muted/40 text-muted-foreground"),children:[n?(0,t.jsx)(Ode,{className:"size-3"}):a?(0,t.jsx)(v5,{className:"size-3"}):null,Yfe(s)]})}r(nK,"DeliveryBadge$1");function rK({className:e}){return(0,t.jsxs)(ct,{variant:"outline",className:z("h-5 gap-1 px-1.5 text-(length:--text-nano) font-medium","border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300",e),children:[(0,t.jsx)(kl,{className:"size-3"})," Proposed"]})}r(rK,"ProposedBadge");function Z5(e){return Jfe(e.configPath)}r(Z5,"bindingEnvKey");function aK(e){return e.secretProposalId?{name:e.secretProposalName??"proposed secret",pending:!0}:{name:e.secretName??"secret",pending:!1}}r(aK,"bindingSecretLabel");function zY(e){return e instanceof vn?e.message||`Request failed: ${e.status}`:e instanceof Error?e.message:"Something went wrong. Try again."}r(zY,"readableError");function Zfe(e,s=[]){const n=Kt(),{pushToast:a}=da(),[i,o]=(0,u.useState)(null),[l,c]=(0,u.useState)(null),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(null),f=(0,u.useCallback)(()=>{e&&(n.invalidateQueries({queryKey:["secret-proposals",e]}),n.invalidateQueries({queryKey:P.secrets.list(e)}))},[e,n]),g=ke({mutationFn:r(j=>{const{proposal:N}=j;if(N.kind==="secret"){const _=j.folder.trim()?`${j.folder.trim().replace(/\/+$/,"")}/${j.leaf.trim()}`:j.leaf.trim();return hr.approveProposal(e,N.id,{overrides:{name:_,description:j.description.trim()||null,providerConfigId:j.providerConfigId||null}})}return hr.approveProposal(e,N.id,{cascade:j.cascade||void 0})},"mutationFn"),onSuccess:r(j=>{a({title:j.kind==="secret"?"Secret approved":"Binding approved",body:j.kind==="secret"?j.proposedName??"Secret created":`${j.target?.name??"Agent"} · ${Z5(j)||"binding"}`,tone:"success"}),o(null),p(null),f()},"onSuccess"),onError:r(j=>p(zY(j)),"onError")}),v=ke({mutationFn:r(({proposal:j,reason:N})=>hr.rejectProposal(e,j.id,{reason:N.trim()}),"mutationFn"),onSuccess:r(j=>{a({title:"Proposal rejected",body:j.kind==="secret"?j.proposedName??void 0:void 0,tone:"info"}),c(null),m(""),p(null),f()},"onSuccess"),onError:r(j=>p(zY(j)),"onError")}),y=(0,u.useCallback)(j=>{p(null);const N=(j.proposedName??"").split("/"),_=N.pop()??"";o({proposal:j,folder:N.join("/"),leaf:_,description:j.proposedDescription??"",providerConfigId:s.find(A=>A.provider==="local_encrypted"&&A.isDefault)?.id??"",cascade:!!j.secretProposalId})},[s]),w=(0,u.useCallback)(j=>{p(null),m(""),c(j)},[]),S=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(lQe,{draft:i,error:h,pending:g.isPending,providerConfigs:s,onChange:o,onCancel:r(()=>{o(null),p(null)},"onCancel"),onConfirm:r(()=>i&&g.mutate(i),"onConfirm")}),(0,t.jsx)(dQe,{proposal:l,reason:d,error:h,pending:v.isPending,onReasonChange:m,onCancel:r(()=>{c(null),m(""),p(null)},"onCancel"),onConfirm:r(()=>l&&v.mutate({proposal:l,reason:d}),"onConfirm")})]});return{requestApprove:y,requestReject:w,isBusy:g.isPending||v.isPending,dialogs:S}}r(Zfe,"useProposalReview");function lQe({draft:e,error:s,pending:n,providerConfigs:a,onChange:i,onCancel:o,onConfirm:l}){const c=e?.proposal.kind==="secret",d=e?e.folder.trim()?`${e.folder.trim().replace(/\/+$/,"")}/${e.leaf.trim()}`:e.leaf.trim():"",m=a.filter(p=>p.provider==="local_encrypted"),h=c?!!(e&&e.leaf.trim()):!0;return(0,t.jsx)(Js,{open:!!e,onOpenChange:r(p=>!p&&o(),"onOpenChange"),children:(0,t.jsx)(Zs,{className:"sm:max-w-lg",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(Sn,{children:[(0,t.jsx)(rn,{children:c?"Approve & create secret":"Approve binding"}),(0,t.jsx)(Mn,{children:c?"The value is created as the proposing agent recorded it. Re-folder or rename it before it lands.":"Grant the target agent access to this secret. This runs with your permissions."})]}),(0,t.jsxs)("div",{className:"space-y-1.5 rounded-md border border-border bg-muted/30 p-2.5 text-xs",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,t.jsx)("span",{children:"Proposed by"}),(0,t.jsx)(dC,{agent:e.proposal.proposedBy,className:"font-medium text-foreground"})]}),(0,t.jsx)(sK,{justification:e.proposal.justification})]}),c?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Ws,{htmlFor:"approve-folder",children:"Folder"}),(0,t.jsx)(_t,{id:"approve-folder",value:e.folder,onChange:r(p=>i({...e,folder:p.target.value}),"onChange"),placeholder:"dev/github",className:"font-mono text-xs"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Ws,{htmlFor:"approve-name",children:"Name"}),(0,t.jsx)(_t,{id:"approve-name",value:e.leaf,onChange:r(p=>i({...e,leaf:p.target.value}),"onChange"),placeholder:"client-secret",autoFocus:!0,"aria-invalid":!e.leaf.trim(),className:"font-mono text-xs"})]})]}),(0,t.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:["Lands as"," ",d?(0,t.jsx)(cC,{name:d,className:"font-mono"}):(0,t.jsx)("span",{className:"italic",children:"enter a name"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Ws,{htmlFor:"approve-description",children:"Description"}),(0,t.jsx)(_t,{id:"approve-description",value:e.description,onChange:r(p=>i({...e,description:p.target.value}),"onChange"),placeholder:"Optional"})]}),m.length>0?(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Ws,{htmlFor:"approve-provider-config",children:"Provider vault"}),(0,t.jsxs)("select",{id:"approve-provider-config",value:e.providerConfigId,onChange:r(p=>i({...e,providerConfigId:p.target.value}),"onChange"),className:"h-9 w-full rounded-md border border-input bg-transparent px-2 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",children:[(0,t.jsx)("option",{value:"",children:"Deployment default"}),m.map(p=>(0,t.jsx)("option",{value:p.id,children:p.displayName},p.id))]})]}):null,(0,t.jsx)("div",{className:"rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-muted-foreground",children:(0,t.jsx)(Xfe,{fingerprint:e.proposal.valueFingerprintSha256,length:e.proposal.valueLength})})]}):(0,t.jsx)(cQe,{draft:e,onChange:i}),s?(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:s}):null,(0,t.jsxs)(br,{children:[(0,t.jsx)(F,{variant:"ghost",onClick:o,disabled:n,children:"Cancel"}),(0,t.jsx)(F,{onClick:l,disabled:n||!h,children:n?"Approving…":c?"Approve & create":e.cascade?"Approve secret & bind":"Approve binding"})]})]}):null})})}r(lQe,"ApproveDialog");function cQe({draft:e,onChange:s}){const{proposal:n}=e,a=aK(n),i=Z5(n);return(0,t.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,t.jsxs)("div",{className:"space-y-2 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Target agent"}),n.target?(0,t.jsx)(dC,{agent:n.target,className:"text-sm font-medium"}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"—"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Delivered as"}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(nK,{configPath:n.configPath}),(0,t.jsx)("code",{className:"font-mono text-xs",children:i||n.configPath})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Secret"}),(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(yi,{className:"size-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:a.name}),a.pending?(0,t.jsx)(rK,{}):null]})]})]}),n.secretProposalId?(0,t.jsxs)("label",{className:"flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-2.5 text-xs",children:[(0,t.jsx)(Fi,{checked:e.cascade,onCheckedChange:r(o=>s({...e,cascade:o===!0}),"onCheckedChange"),className:"mt-0.5","aria-label":"Also approve the proposed secret"}),(0,t.jsxs)("span",{className:"text-foreground/90",children:["Also approve the proposed secret"," ",(0,t.jsx)("span",{className:"font-medium",children:a.name})," and create it in the same step. The binding can’t land without it."]})]}):null]})}r(cQe,"BindingApproveBody");function dQe({proposal:e,reason:s,error:n,pending:a,onReasonChange:i,onCancel:o,onConfirm:l}){const c=s.trim().length>0;return(0,t.jsx)(Js,{open:!!e,onOpenChange:r(d=>!d&&o(),"onOpenChange"),children:(0,t.jsx)(Zs,{className:"sm:max-w-md",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(Sn,{children:[(0,t.jsx)(rn,{children:"Reject proposal"}),(0,t.jsxs)(Mn,{children:["The reason is sent back to"," ",(0,t.jsx)(dC,{agent:e.proposedBy,className:"text-foreground"}),". Dependent bindings are rejected too."]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Ws,{htmlFor:"reject-reason",children:"Reason"}),(0,t.jsx)(En,{id:"reject-reason",value:s,onChange:r(d=>i(d.target.value),"onChange"),rows:3,autoFocus:!0,placeholder:"Why is this being rejected?"})]}),n?(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:n}):null,(0,t.jsxs)(br,{children:[(0,t.jsx)(F,{variant:"ghost",onClick:o,disabled:a,children:"Cancel"}),(0,t.jsx)(F,{variant:"destructive",onClick:l,disabled:a||!c,children:a?"Rejecting…":"Reject"})]})]}):null})})}r(dQe,"RejectDialog");function exe({proposal:e,onApprove:s,onReject:n,disabled:a,size:i="sm"}){const o=!e.viewerCanApprove,l=i==="xs"?"h-7 px-2 text-xs":"",c=(0,t.jsx)(F,{size:"sm",className:l,disabled:a||o,onClick:r(()=>s(e),"onClick"),children:"Approve"});return(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[o?(0,t.jsx)(md,{children:(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)("span",{tabIndex:0,children:c})}),(0,t.jsx)(Un,{className:"max-w-72",children:e.approveBlockReason??"You don’t have permission to approve this."})]})}):c,(0,t.jsx)(F,{size:"sm",variant:"outline",className:l,disabled:a,onClick:r(()=>n(e),"onClick"),children:"Reject"})]})}r(exe,"ProposalActions");function txe(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}r(txe,"asRecord$15");function sxe(e){const s=txe(e);if(!s||s.type!=="secret_ref")return null;const n=typeof s.secretId=="string"?s.secretId:"";return n?{secretId:n,version:typeof s.version=="number"?s.version:"latest"}:null}r(sxe,"readSecretRef");function uQe(e){const s=txe(e?.env);if(!s)return[];const n=[];for(const[a,i]of Object.entries(s)){const o=sxe(i);o&&n.push({name:a,...o})}return n}r(uQe,"parseEnvSecretRefs");function mQe(e){if(!e)return[];const s=[];for(const[n,a]of Object.entries(e)){if(!n.startsWith("access."))continue;const i=sxe(a);i&&s.push({name:n.slice(P1.length),...i})}return s}r(mQe,"parseAccessGrants");function hQe(e,s){const n=new Map,a=r(i=>{let o=n.get(i);return o||(o={secretId:i,envKeys:[],apiAliases:[]},n.set(i,o)),o},"ensure");for(const i of e)a(i.secretId).envKeys.push(i.name);for(const i of s)a(i.secretId).apiAliases.push(i.name);return[...n.values()]}r(hQe,"summarizeAgentBindings");var UY=0;function nxe(){return UY+=1,`access-row-${UY}`}r(nxe,"nextAccessRowId");function R4(e){return e.map(s=>({id:nxe(),alias:s.name,secretId:s.secretId,version:s.version}))}r(R4,"entriesToRows");function KY(e){const s={};for(const n of e){const a=n.alias.trim();!a||!AF.test(a)||!n.secretId||(s[a]={type:"secret_ref",secretId:n.secretId,version:n.version})}return s}r(KY,"rowsToAccessMap");function VY(e){return JSON.stringify(Object.keys(e).sort().map(s=>{const n=e[s];return[s,n.secretId,n.version??"latest"]}))}r(VY,"normalizeAccessMapKey");function WY({mode:e}){return e==="env"?(0,t.jsxs)(ct,{variant:"outline",className:"h-5 gap-1 px-1.5 text-(length:--text-nano) font-normal border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",children:[(0,t.jsx)(Ode,{className:"size-3"})," Env var"]}):(0,t.jsxs)(ct,{variant:"outline",className:"h-5 gap-1 px-1.5 text-(length:--text-nano) font-normal border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300",children:[(0,t.jsx)(v5,{className:"size-3"})," API access"]})}r(WY,"DeliveryBadge");function pQe({config:e,secrets:s,onChange:n,onCreateSecret:a,disabled:i,proposals:o,onApproveProposal:l,onRejectProposal:c}){const d=(0,u.useMemo)(()=>(o??[]).filter($=>$.kind==="binding"),[o]),m=(0,u.useMemo)(()=>uQe(e),[e]),h=(0,u.useMemo)(()=>mQe(e),[e]),p=(0,u.useMemo)(()=>hQe(m,h),[m,h]),f=(0,u.useMemo)(()=>KY(R4(h)),[h]),g=(0,u.useMemo)(()=>VY(f),[f]),[v,y]=(0,u.useState)(()=>R4(h)),[w,S]=(0,u.useState)(null),j=(0,u.useRef)(new Map),N=(0,u.useRef)(g),_=(0,u.useRef)(g);(0,u.useEffect)(()=>{g!==_.current&&(_.current=g,g!==N.current&&y(R4(h)))},[g,h]);const A=r($=>s.find(E=>E.id===$)?.name??`${$.slice(0,8)}…`,"secretName");function C($){y($);const E=KY($);N.current=VY(E),n(E)}r(C,"emit");function I($,E){C(v.map(q=>q.id===$?{...q,...E}:q))}r(I,"patchRow");function T($){C(v.filter(E=>E.id!==$))}r(T,"removeRow");function R(){y($=>[...$,{id:nxe(),alias:"",secretId:"",version:"latest"}])}r(R,"addRow");const L=(0,u.useMemo)(()=>{const $=new Map;for(const E of v){const q=E.alias.trim();q&&$.set(q,($.get(q)??0)+1)}return $},[v]),O=p.length>0;return(0,t.jsxs)("div",{className:"space-y-3",children:[O?(0,t.jsx)("div",{className:"space-y-1.5",children:p.map($=>(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 rounded-md border border-border bg-muted/30 px-2.5 py-1.5 text-xs",children:[(0,t.jsx)(yi,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:A($.secretId)}),$.envKeys.length>0?(0,t.jsx)(WY,{mode:"env"}):null,$.apiAliases.length>0?(0,t.jsx)(WY,{mode:"api"}):null,(0,t.jsx)("span",{className:"min-w-0 truncate font-mono text-(length:--text-micro) text-muted-foreground",children:[...$.envKeys.map(E=>`${eQe}${E}`),...$.apiAliases.map(E=>`${P1}${E}`)].join(" · ")})]},$.secretId))}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No secrets are bound to this agent yet."}),d.length>0&&l&&c?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Proposed access"}),d.map($=>{const E=aK($),q=Z5($);return(0,t.jsxs)("div",{className:"flex flex-col gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-2.5 py-2 text-xs sm:flex-row sm:items-center",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,t.jsx)(nK,{configPath:$.configPath}),(0,t.jsx)("code",{className:"font-mono",children:q||$.configPath}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"→"}),(0,t.jsx)(yi,{className:"size-3 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:E.name}),E.pending?(0,t.jsx)(rK,{}):null]}),(0,t.jsxs)("p",{className:"flex flex-wrap items-center gap-1 text-muted-foreground",children:[(0,t.jsxs)("span",{children:["proposed by ",$.proposedBy.name]}),(0,t.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,t.jsxs)("span",{className:"truncate italic",children:["“",$.justification,"”"]})]})]}),(0,t.jsx)(exe,{proposal:$,onApprove:l,onReject:c,disabled:i,size:"xs"})]},$.id)})]}):null,(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"API access (no env var)"}),v.length>0?(0,t.jsx)("div",{className:"space-y-2",children:v.map($=>{const E=$.alias.trim(),q=!!E&&!AF.test(E),B=!!E&&(L.get(E)??0)>1,K=s.find(U=>U.id===$.secretId)??null;return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"grid grid-cols-(--gtc-65) items-start gap-1.5",children:[(0,t.jsx)("div",{children:(0,t.jsx)(_t,{value:$.alias,onChange:r(U=>I($.id,{alias:U.target.value}),"onChange"),onBlur:r(U=>{const D=U.target.value.trim();if(D&&!AF.test(D)){const V=bS(D);V&&V!==D&&I($.id,{alias:V})}},"onBlur"),placeholder:"ALIAS","aria-label":"Access alias",disabled:i,className:z("h-9 font-mono text-sm",(q||B)&&"border-destructive text-destructive")})}),(0,t.jsxs)("div",{className:"flex min-w-0 items-start gap-1.5",children:[(0,t.jsxs)(nr,{open:w?.rowId===$.id,onOpenChange:r(U=>{!U&&w?.rowId===$.id&&S(null)},"onOpenChange"),children:[(0,t.jsx)(J$,{asChild:!0,children:(0,t.jsx)("div",{ref:r(U=>{U?j.current.set($.id,U):j.current.delete($.id)},"ref"),className:"min-w-0 flex-1",children:(0,t.jsx)(tK,{secretId:$.secretId,secrets:s,onSelect:r(U=>I($.id,{secretId:U,version:"latest",alias:!$.alias.trim()&&U?bS(A(U)):$.alias}),"onSelect"),onCreateNew:a?U=>{window.setTimeout(()=>{S({rowId:$.id,name:AT(U)||U.trim()})},0)}:void 0,disabled:i,triggerClassName:"h-9 min-h-9"})})}),(0,t.jsx)(Wn,{align:"start",className:"w-auto p-3",onInteractOutside:r(U=>{const D=U.detail.originalEvent.target;D&&j.current.get($.id)?.contains(D)&&U.preventDefault()},"onInteractOutside"),children:w?.rowId===$.id&&a?(0,t.jsx)(Wfe,{initialName:w.name,initialValue:"",existingSecretNames:s.map(U=>U.name),onCancel:r(()=>S(null),"onCancel"),onSubmit:r(async(U,D)=>{const V=await a(U,D);I($.id,{secretId:V.id,version:"latest",alias:$.alias.trim()||bS(V.name)}),S(null)},"onSubmit")}):null})]}),(0,t.jsxs)("select",{className:"h-9 shrink-0 rounded-md border border-border bg-background px-2 text-xs outline-none disabled:cursor-not-allowed disabled:opacity-60",value:$.version===void 0?"latest":String($.version),onChange:r(U=>{const D=U.target.value;I($.id,{version:D==="latest"?"latest":Number.parseInt(D,10)})},"onChange"),disabled:i||!K,"aria-label":"Version",children:[(0,t.jsx)("option",{value:"latest",children:"latest"}),K?Array.from({length:Math.max(0,K.latestVersion)},(U,D)=>{const V=K.latestVersion-D;return V<=0?null:(0,t.jsxs)("option",{value:V,children:["v",V]},V)}):null]})]}),(0,t.jsx)("button",{type:"button",onClick:r(()=>T($.id),"onClick"),disabled:i,"aria-label":"Remove API access",className:"mt-1 inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:(0,t.jsx)(Ia,{className:"size-3.5"})})]}),q?(0,t.jsx)("p",{className:"pl-0.5 text-(length:--text-micro) text-destructive",children:"Invalid alias — use letters, digits and _"}):B?(0,t.jsx)("p",{className:"pl-0.5 text-(length:--text-micro) text-destructive",children:"Duplicate alias"}):null]},$.id)})}):null,(0,t.jsxs)("button",{type:"button",onClick:R,disabled:i,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50",children:[(0,t.jsx)(yn,{className:"size-3.5"}),"Add API access"]})]}),(0,t.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground/70",children:[tQe("api")," The agent reads them by alias through ",(0,t.jsx)("code",{children:"GET /agents/me/secrets"}),"."]})]})}r(pQe,"AgentSecretAccessEditor");function fQe(e){if(typeof e!="string")return null;const s=e.trim();return s.length>0?s:null}r(fQe,"asNonEmptyString$3");function xQe(e){return fQe(e)!==null}r(xQe,"hasLegacyWorkingDirectory");function gQe(e){return e.isCreate?!1:xQe(e.adapterConfig?.cwd)}r(gQe,"shouldShowLegacyWorkingDirectoryField");var rxe=new Set;function bQe(e){return rxe.has(e)}r(bQe,"isAdapterTypeHidden");function vQe(e){rxe=new Set(e)}r(vQe,"setDisabledAdapterTypes");function yQe(e){return!zm(e).hideFromVisualSelection}r(yQe,"isVisualAdapterChoice");function axe(e,s=ZU()){const n=e??df;return s.map(a=>({value:a.type,label:n(a.type),comingSoon:!!zm(a.type).comingSoon,hidden:bQe(a.type),experimental:!!zm(a.type).experimental}))}r(axe,"listAdapterOptions");function ixe(e={}){const s=e.enabled??!0,{data:n}=ee({queryKey:P.adapters.all,queryFn:r(()=>Am.list(),"queryFn"),enabled:s,staleTime:3e5});return n&&yHe(n.filter(a=>a.source==="external").map(a=>({type:a.type,label:a.label,disabled:a.disabled,overrideDisabled:a.overridePaused}))),(0,u.useEffect)(()=>{n&&vQe(n.filter(a=>a.disabled).map(a=>a.type))},[n]),(0,u.useMemo)(()=>new Set(n?.filter(a=>a.disabled).map(a=>a.type)??[]),[n])}r(ixe,"useDisabledAdaptersSync");function jQe(e={}){const s=e.enabled??!0,{data:n}=ee({queryKey:P.adapters.all,queryFn:r(()=>Am.list(),"queryFn"),enabled:s,staleTime:3e5});return n!==void 0}r(jQe,"useAdapterRegistryLoaded");function RT(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))}r(RT,"omitUndefinedEntries");function dI(e,s){const n={};if(Object.keys(s.identity).length>0&&Object.assign(n,s.identity),s.adapterType!==void 0&&(n.adapterType=s.adapterType),s.adapterType!==void 0||Object.keys(s.adapterConfig).length>0){const a=e.adapterConfig??{};n.adapterConfig=RT(s.adapterType!==void 0?{...Object.fromEntries(L_e.filter(i=>a[i]!==void 0).map(i=>[i,a[i]])),...s.adapterConfig}:{...a,...s.adapterConfig}),n.replaceAdapterConfig=!0}if(Object.keys(s.heartbeat).length>0||Object.keys(s.debug).length>0){const a=e.runtimeConfig??{},i=n.runtimeConfig??{...a};if(Object.keys(s.heartbeat).length>0&&(i.heartbeat={...a.heartbeat??{},...s.heartbeat}),Object.keys(s.debug).length>0){const o=RT({...a.debug??{},...s.debug});Object.keys(o).length===0?delete i.debug:i.debug=o}n.runtimeConfig=i}return Object.keys(s.runtime).length>0&&Object.assign(n,s.runtime),n}r(dI,"buildAgentUpdatePatch");var wQe="kubernetes";function NQe(e){return e.driver!=="sandbox"?!1:e.config?.provider===wQe}r(NQe,"isKubernetesSandboxEnvironment");function iK(e,s){return e!=="kubernetes"?{forced:!1,kubernetesEnvironment:null}:{forced:!0,kubernetesEnvironment:s.find(n=>NQe(n))??null}}r(iK,"resolveForcedKubernetesEnvironment");var T4={identity:{},adapterConfig:{},heartbeat:{},debug:{},runtime:{}},GN={};function kQe(e){return e==="claude_local"||e==="codex_local"||e==="paperclip_runner"||e==="opencode_local"}r(kQe,"supportsAdapterModelRefresh");function SQe(e,s){return Fme(e,s).model}r(SQe,"resolvePaperclipRunnerTransitionModel");function HY(e){return Object.keys(e.identity).length>0||e.adapterType!==void 0||Object.keys(e.adapterConfig).length>0||Object.keys(e.heartbeat).length>0||Object.keys(e.debug).length>0||Object.keys(e.runtime).length>0}r(HY,"isOverlayDirty");function RF(e,s){if(Object.is(e,s))return!0;if(Array.isArray(e)&&Array.isArray(s))return e.length===s.length&&e.every((n,a)=>RF(n,s[a]));if(typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof s=="object"&&s!==null&&!Array.isArray(s)){const n=Object.entries(e),a=s;return n.length===Object.keys(a).length&&n.every(([i,o])=>i in a&&RF(o,a[i]))}return!1}r(RF,"overlayValuesEqual");function CQe(e,s){const n=r((a,i)=>Object.fromEntries(Object.entries(a).filter(([o,l])=>!(o in i)||!RF(l,i[o]))),"subtractGroup");return{identity:n(e.identity,s.identity),...e.adapterType!==void 0&&e.adapterType!==s.adapterType?{adapterType:e.adapterType}:{},adapterConfig:n(e.adapterConfig,s.adapterConfig),heartbeat:n(e.heartbeat,s.heartbeat),debug:n(e.debug,s.debug),runtime:n(e.runtime,s.runtime)}}r(CQe,"subtractPersistedOverlay");var bm="w-full rounded-md border border-border px-2.5 py-1.5 bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40";function _Qe(e){return e.split(",").map(s=>s.trim()).filter(Boolean)}r(_Qe,"parseCommaArgs");function IQe(e){return Array.isArray(e)?e.filter(s=>typeof s=="string").join(", "):typeof e=="string"?e:""}r(IQe,"formatArgList");var AQe=[{id:"",label:"Auto"},{id:"minimal",label:"Minimal"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"},{id:"xhigh",label:"X-High"},{id:"max",label:"Max"}],RQe=[{id:"",label:"Auto"},{id:"plan",label:"Plan"},{id:"ask",label:"Ask"}],TQe=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"}],EQe=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"high",label:"High"},{id:"max",label:"Max"}],PQe=2,QY=10,MQe=1,oxe=300;function _2(e,s,n){return Math.max(s,Math.min(n,Math.floor(e)))}r(_2,"clampInteger");function DQe(e){return _2(e,0,oxe)*1e3}r(DQe,"clampDelayMsFromSeconds");function LQe({order:e,className:s,children:n}){if(!e)return(0,t.jsx)("div",{className:s,children:n});const a=r(o=>{const l=(0,u.isValidElement)(o)?o.props["data-config-section"]:void 0,c=l?e.indexOf(l):-1;return c<0?e.length:c},"rank"),i=u.Children.toArray(n).sort((o,l)=>a(o)-a(l));return(0,t.jsx)("div",{className:s,children:i})}r(LQe,"ConfigSections");function lxe(e){const{mode:s,adapterModels:n}=e,a=s==="create",i=e.sectionLayout==="cards",o=e.showAdapterTypeField??!0,l=e.showAdapterTestEnvironmentButton??!0,c=l&&!e.onTestActionChange&&!e.compactTestFeedback,d=!e.onTestFeedbackChange,m=e.showCreateRunPolicySection??!0,h=e.hideInstructionsFile??!1,p=e.canConfigureProviderTrace===!0,{selectedCompanyId:f}=xs(),g=Kt(),v=(0,u.useRef)(null),y=ixe(),{data:w=[]}=ee({queryKey:f?P.secrets.list(f):["secrets","none"],queryFn:r(()=>hr.list(f),"queryFn"),enabled:!!f}),{data:S=[]}=ee({queryKey:f?P.secrets.userDefinitions(f):["user-secret-definitions","none"],queryFn:r(()=>hr.listUserSecretDefinitions(f),"queryFn"),enabled:!!f,retry:!1}),j=a?null:e.agent.id,{data:N=[]}=ee({queryKey:f?P.secrets.proposals(f,"pending"):["secret-proposals","none"],queryFn:r(()=>hr.listProposals(f,"pending"),"queryFn"),enabled:!!f&&!a,retry:!1}),_=(0,u.useMemo)(()=>N.filter(Qe=>Qe.kind==="binding"&&Qe.target?.id===j),[N,j]),A=Zfe(f,[]),{data:C}=ee({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn"),retry:!1}),I=(0,u.useMemo)(()=>{const Qe=new Set(y);return C?.enableNativeRunner!==!0&&Qe.add("paperclip_runner"),Qe},[y,C?.enableNativeRunner]),T=C?.enableEnvironments===!0,R=C?.enableManagedSandboxOnly===!0,L=C===void 0||R,{data:O}=ee({queryKey:P.instance.generalSettings,queryFn:r(()=>Ir.getGeneral(),"queryFn"),retry:!1}),{data:$}=ee({queryKey:P.instance.settings,queryFn:r(()=>Ir.get(),"queryFn"),retry:!1}),{data:E=[]}=ee({queryKey:f?P.environments.list(f):["environments","none"],queryFn:r(()=>Ci.list(f),"queryFn"),enabled:!!f&&(T||O?.executionMode==="kubernetes")}),{forced:q,kubernetesEnvironment:B}=(0,u.useMemo)(()=>iK(O?.executionMode,E),[O?.executionMode,E]),K=ke({mutationFn:r(Qe=>{if(!f)throw new Error("Select an organization to create secrets");return hr.create(f,Qe)},"mutationFn"),onSuccess:r(()=>{f&&g.invalidateQueries({queryKey:P.secrets.list(f)})},"onSuccess")}),U=ke({mutationFn:r(async({file:Qe,namespace:Yt})=>{if(!f)throw new Error("Select an organization to upload images");return d0.uploadImage(f,Qe,Yt)},"mutationFn")}),[D,V]=(0,u.useState)(T4),[H,J]=(0,u.useState)(!1),[X,le]=(0,u.useState)(0),ce=(0,u.useRef)(null),te=(0,u.useRef)(null),re=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(!a){if(ce.current!==null&&e.agent!==ce.current&&!re.current){const Qe=te.current;te.current=null,V(Yt=>Qe?CQe(Yt,Qe):{...T4})}ce.current=e.agent}},[a,a?void 0:e.agent]);const de=!a&&(HY(D)||H);function Z(Qe,Yt,an){const Fs=D[Qe];return Yt in Fs?Fs[Yt]:an}r(Z,"eff");function Y(Qe,Yt,an){V(Fs=>({...Fs,[Qe]:{...Fs[Qe],[Yt]:an}}))}r(Y,"mark");function G(){return v.current?.flushPendingDraft()??null}r(G,"flushEnvironmentDraft");const fe=(0,u.useCallback)(Qe=>{a||V(Yt=>{const an={...e.agent.adapterConfig??{},...Yt.adapterConfig},Fs={...Yt.adapterConfig};for(const[Kn,Nr]of Object.entries(Qe))Fs[`${P1}${Kn}`]=Nr;for(const Kn of Object.keys(an))Kn.startsWith("access.")&&(Kn.slice(7)in Qe||(Fs[Kn]=void 0));return{...Yt,adapterConfig:Fs}})},[a,a?void 0:e.agent]),se=(0,u.useCallback)(()=>{V({...T4}),J(!1),le(Qe=>Qe+1)},[]),ae=(0,u.useCallback)(async()=>{if(a)return;const Qe=G(),Yt=Qe?{...D,adapterConfig:{...D.adapterConfig,env:Qe}}:D;HY(Yt)&&await e.onSave(dI(e.agent,Yt))},[a,de,D,e]);(0,u.useEffect)(()=>{a||(e.onDirtyChange?.(de),e.onSaveActionChange?.(ae),e.onCancelActionChange?.(se))},[a,de,e.onDirtyChange,e.onSaveActionChange,e.onCancelActionChange,ae,se]),(0,u.useEffect)(()=>{if(!a)return()=>{e.onSaveActionChange?.(null),e.onCancelActionChange?.(null),e.onDirtyChange?.(!1)}},[a,e.onDirtyChange,e.onSaveActionChange,e.onCancelActionChange]);const ie=a?{}:e.agent.adapterConfig??{},ue=a?{}:e.agent.runtimeConfig??{},pe=a?{}:ue.heartbeat??{},be=a?{}:ue.debug??{},oe=a?e.values.adapterType:D.adapterType??e.agent.adapterType,je=Uw(),_e=je(oe),xe=_e.supportsInstructionsBundle||_e.supportsSkills||_e.supportsLocalAgentJwt,Ae=xe&&!L&&gQe({isCreate:a,adapterConfig:ie}),Ye=(0,u.useMemo)(()=>tN(oe),[oe]),Oe=(0,u.useMemo)(()=>new Set(nTe(oe)),[oe]),Xe=a?e.values:null,me=a?Qe=>e.onChange(Qe):null;a&&Xe.claudeStoredSessionId;const Le=r(()=>{f&&g.invalidateQueries({queryKey:P.secrets.userDefinitions(f)})},"invalidateUserSecretDefinitions"),mt=r(Qe=>{if(!a||!me)return;const Yt=Xe.envBindings??{};me({envBindings:{...Yt,...aj()},claudeStoredSessionId:Qe}),Le()},"handleClaudeLoginStored"),We=r(async()=>{if(a)return;const Qe={...G()??Z("adapterConfig","env",ie.env??GN),...aj()},Yt={...D,adapterConfig:{...D.adapterConfig,env:Qe}};V(Yt),await e.onSave({...dI(e.agent,Yt),applyStoredClaudeLogin:!0}),Le()},"handleClaudeLoginStoredEdit"),ze=r(async Qe=>{if(a||!Qe.companyIdentityDiffers)return;const Yt={...G()??Z("adapterConfig","env",ie.env??GN),CODEX_HOME:{type:"secret_ref",secretId:Qe.secretId,version:"latest"}},an={...D,adapterConfig:{...D.adapterConfig,env:Yt}};V(an),te.current=an,re.current=!0;try{await e.onSave(dI(e.agent,an))}catch(Fs){throw te.current=null,Fs}finally{re.current=!1}Le()},"handleCodexAccountBindingEdit"),st=r(()=>{if(!a||!me)return;const Qe=Xe.envBindings??{};me({envBindings:{...Qe,...aj()},claudeApplyStoredLogin:!0}),Le()},"handleApplyStoredClaudeLogin"),pt=r(async()=>{if(a)return;const Qe={...G()??Z("adapterConfig","env",ie.env??GN),...aj()},Yt={...D,adapterConfig:{...D.adapterConfig,env:Qe}};V(Yt),await e.onSave({...dI(e.agent,Yt),applyStoredClaudeLogin:!0}),Le()},"handleApplyStoredClaudeLoginEdit"),Pt=a?Xe.defaultEnvironmentId??"":Z("identity","defaultEnvironmentId",e.agent.defaultEnvironmentId??""),tt=(0,u.useMemo)(()=>Pt?(E.find(Qe=>Qe.id===Pt)??null)?.driver==="local"?"":Pt:"",[E,Pt]),ht=(0,u.useMemo)(()=>E.find(Qe=>Qe.id===tt)??null,[tt,E]),et=(0,u.useMemo)(()=>{const Qe=$?.defaultEnvironmentId??null;return Qe?(E.find(Yt=>Yt.id===Qe)??null)?.driver==="local"?"":Qe:""},[E,$?.defaultEnvironmentId]),Ie=(0,u.useMemo)(()=>E.find(Qe=>Qe.id===et)??null,[E,et]),Ne=(0,u.useMemo)(()=>{try{return cw({agentDefaultEnvironmentId:Pt||null,instanceDefaultEnvironmentId:$?.defaultEnvironmentId??null,localDefaultEnvironmentId:uw(E),managedSandboxOnly:C?.enableManagedSandboxOnly===!0,managedSandboxEnvironmentId:dw(E),visibleEnvironmentIds:E.map(Qe=>Qe.id)})}catch{return null}},[Pt,$?.defaultEnvironmentId,E,C?.enableManagedSandboxOnly]),Je=(0,u.useMemo)(()=>E.find(Qe=>Qe.id===Ne)??null,[E,Ne]),{data:ft}=ee({queryKey:f?P.environments.capabilities(f):["environment-capabilities","none"],queryFn:r(()=>Ci.capabilities(f),"queryFn"),enabled:!!f&&_e.login!=null});(0,u.useEffect)(()=>{!a||!me||!q||!B||tt!==B.id&&me({defaultEnvironmentId:B.id})},[a,me,q,B,tt]);const Ot=(0,u.useMemo)(()=>E.filter(Qe=>{if(!Oe.has(Qe.driver)||Qe.driver==="local")return!1;if(Qe.driver!=="sandbox")return!0;const Yt=typeof Qe.config?.provider=="string"?Qe.config.provider:null;return Yt!==null&&Yt!=="fake"}),[E,Oe]),es=(0,u.useMemo)(()=>!ht||Ot.some(Qe=>Qe.id===ht.id)?Ot:[...Ot,ht],[ht,Ot]),bs=T&&(q||tt.length>0||Ot.length>=1),Ke=Ie?mw(Ie):R?"Paperclip Computer":"Local",Ve=oe==="paperclip_runner"?String(a?e.values.adapterSchemaValues?.provider??"codex":Z("adapterConfig","provider",ie.provider==="acpx"&&ie.acpxAgent==="codex"?"codex":ie.provider??"codex")):void 0,dt=oe==="opencode_local"&&t2.safeParse(D.runtime.runtimeConfig?.aiConnection??ue.aiConnection).data?.provider==="openrouter"?"openrouter":Ve,Be=f?P.agents.adapterModels(f,oe,tt||null,dt):["agents","none","adapter-models",oe],{data:as,error:Fe}=ee({queryKey:Be,queryFn:r(()=>zt.adapterModels(f,oe,{environmentId:tt||null,provider:dt}),"queryFn"),enabled:!!f}),[Ut,At]=(0,u.useState)(null),[Ls,qe]=(0,u.useState)(!1),ut=as??n??[],Dt="command",{data:is,refetch:Ts}=ee({queryKey:f?P.agents.detectModel(f,oe):["agents","none","detect-model",oe],queryFn:r(()=>{if(!f)throw new Error("Select an organization to detect the model");return zt.detectModel(f,oe)},"queryFn"),enabled:!!(f&&xe&&oe!=="opencode_local"&&oe!=="paperclip_runner")}),jt=is?.model??null;is?.candidates;const{data:we=[]}=ee({queryKey:f?P.agents.list(f):["agents","none","list"],queryFn:r(()=>zt.list(f),"queryFn"),enabled:!!(!a&&f)}),Pe={mode:s,isCreate:a,adapterType:oe,values:a?e.values:null,set:a?Qe=>e.onChange(Qe):null,config:ie,eff:Z,mark:Y,models:ut,hideInstructionsFile:h||L,managedSandboxOnly:L},[at,Mt]=(0,u.useState)(!1),[kt,hs]=(0,u.useState)(!1),bt=mfe(oe),Vt=r(Qe=>(0,t.jsxs)(t.Fragment,{children:[oe==="claude_local"&&(0,t.jsx)(s9e,{...Pe,section:Qe}),(0,t.jsx)(Ye.ConfigFields,{...Pe,section:Qe,hideModel:xe})]}),"renderAdapterFields"),[Wt,Me]=(0,u.useState)(!1),[Ee,He]=(0,u.useState)(!1);function Ue(Qe){if(a){const an=Ye.buildAdapterConfig(Xe);return Qe&&Object.assign(an,Qe),RT(an)}const Yt={...ie,...D.adapterConfig};return Qe&&Object.assign(Yt,Qe),RT(Yt)}r(Ue,"buildAdapterConfigForTest");const Gt=ke({mutationFn:r(async()=>{if(!f)throw new Error("Select an organization to test adapter environment");const Qe=G(),Yt=Qe?{env:Qe}:void 0;let an=$,Fs=E,Kn=C?.enableManagedSandboxOnly===!0;if(!Pt)try{const[ns,on,Hs]=await Promise.all([g.ensureQueryData({queryKey:P.instance.settings,queryFn:r(()=>Ir.get(),"queryFn")}),g.ensureQueryData({queryKey:P.environments.list(f),queryFn:r(()=>Ci.list(f),"queryFn")}),g.ensureQueryData({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn")})]);an=ns,Fs=on,Kn=Hs?.enableManagedSandboxOnly===!0}catch{throw new Error("Could not load environment settings to determine which environment to test in. Retry the test.")}const Nr=cw({agentDefaultEnvironmentId:Pt||null,instanceDefaultEnvironmentId:an?.defaultEnvironmentId??null,localDefaultEnvironmentId:uw(Fs),managedSandboxOnly:Kn,managedSandboxEnvironmentId:dw(Fs),visibleEnvironmentIds:Fs.map(ns=>ns.id)}),ga=Ue(Yt),Vn=a?void 0:e.agent.id,Qn=a?void 0:t2.safeParse(D.runtime.runtimeConfig?.aiConnection??e.agent.runtimeConfig.aiConnection).data;if(e.compactTestFeedback){const ns=oe==="paperclip_runner"?ga.provider==="codex"?"codex_local":ga.provider==="acpx"&&ga.acpxAgent==="claude"?"claude_local":oe:oe;return rfe({companyId:f,adapterType:oe,providerAdapter:ns,adapterConfig:ga,agentId:Vn,aiConnection:Qn,environmentId:Nr})}return zt.testEnvironment(f,oe,{adapterConfig:ga,agentId:Vn,aiConnection:Qn,environmentId:Nr})},"mutationFn")}),[Nt,ts]=(0,u.useState)(!1),[ls,Tt]=(0,u.useState)(null),ys="Test",ds=!a&&!!e.isSaving,Ys=Nt||ds||!f,dn=(0,u.useRef)(Gt.reset);dn.current=Gt.reset;const $n=(0,u.useRef)(()=>{});$n.current=()=>{if(!a||!me)return;const Qe=Xe.envBindings??{},Yt=Xe.claudeStoredSessionId!=null||Xe.claudeApplyStoredLogin===!0,an=$Y in Qe;if(!Yt&&!an)return;const Fs={...Qe};delete Fs[$Y],me({envBindings:Fs,claudeStoredSessionId:null,claudeApplyStoredLogin:!1})},(0,u.useEffect)(()=>{dn.current(),Tt(null),$n.current()},[oe,Ne]);const kn=_e.login!=null,Bs=Gt.data,ks=Bs!=null&&je(Bs.adapterType).login!=null,or=Bs&&ks?Bs.checks.find(Qe=>Qe.code==="adapter_auth_missing")??null:null,Is=typeof Je?.config?.provider=="string"?Je.config.provider:null,Lr=Is!=null&&ft?.sandboxProviders?.[Is]?.supportsLoginPty===!0,jn=_e.login!=null,Yn=(a||!(D.runtime.runtimeConfig?.aiConnection??ue.aiConnection))&&kn&&Je?.driver==="sandbox"&&!!Ne&&!!f&&!!or&&(!jn||Lr),lr=(0,u.useCallback)(async()=>{if(!f)throw new Error("Select an organization to test adapter environment");ts(!0),Tt(null),Gt.reset();try{return await Gt.mutateAsync()}catch(Qe){throw Tt(Qe instanceof Error?Qe.message:"Environment test failed"),Qe}finally{ts(!1)}},[f,Gt]),Cn=(0,u.useRef)(()=>{});(0,u.useEffect)(()=>{Cn.current=()=>{Ys||lr().catch(()=>{})}},[lr,Ys]);const vr=(0,u.useCallback)(()=>{Cn.current()},[]);(0,u.useEffect)(()=>{if(!(!l||!e.onTestActionChange))return e.onTestActionChange(vr),()=>{e.onTestActionChange?.(null)}},[l,e.onTestActionChange,vr]),(0,u.useEffect)(()=>{if(!(!l||!e.onTestActionStateChange))return e.onTestActionStateChange({disabled:Ys,pending:Nt}),()=>{e.onTestActionStateChange?.({disabled:!0,pending:!1})}},[l,e.onTestActionStateChange,Ys,Nt]),(0,u.useEffect)(()=>{if(e.onTestFeedbackChange)return e.onTestFeedbackChange({errorMessage:ls??(Gt.error instanceof Error?Gt.error.message:Gt.error?"Environment test failed":null),result:Gt.data??null,login:Yn&&f&&Ne?{companyId:f,adapterType:oe,environmentId:Ne}:null}),()=>{e.onTestFeedbackChange?.({errorMessage:null,result:null,login:null})}},[e.onTestFeedbackChange,ls,Gt.data,Gt.error,Yn,f,oe,Ne]);const zr=a?Xe.model??"":Z("adapterConfig","model",String(ie.model??"")),Qr=typeof zr=="string"?zr:"";async function rr(){if(f){qe(!0),At(null);try{const Qe=await zt.adapterModels(f,oe,{refresh:!0,environmentId:tt||null,provider:dt});g.setQueryData(Be,Qe)}catch(Qe){At(Qe instanceof Error?Qe.message:"Failed to refresh adapter models.")}finally{qe(!1)}}}r(rr,"handleRefreshModels");const gr=oe==="codex_local"?"modelReasoningEffort":oe==="cursor"?"mode":oe==="opencode_local"?"variant":oe==="grok_local"?"reasoningEffort":oe==="pi_local"?"thinking":"effort",cr=oe==="codex_local"?tC(Qr,"Auto").map(Qe=>({id:Qe.value,label:Qe.label})):oe==="cursor"?RQe:oe==="opencode_local"?AQe:oe==="kimi_local"?EQe:oe==="pi_local"?[{id:"",label:"Auto"},...["off","minimal","low","medium","high","xhigh"].map(Qe=>({id:Qe,label:Qe}))]:oe==="claude_local"||oe==="grok_local"?[{id:"",label:"Auto"},...kT(oe,Qr).map(Qe=>({id:Qe,label:Qe==="xhigh"?"X-High":Qe[0].toUpperCase()+Qe.slice(1)}))]:TQe,Gr=a?Xe.thinkingEffort:oe==="codex_local"?Z("adapterConfig","modelReasoningEffort",String(ie.modelReasoningEffort??ie.reasoningEffort??"")):oe==="cursor"?Z("adapterConfig","mode",String(ie.mode??"")):oe==="opencode_local"?Z("adapterConfig","variant",String(ie.variant??"")):Z("adapterConfig",gr,String(ie[gr]??"")),Dn=oe!=="gemini_local"&&oe!=="cursor_cloud"&&oe!=="paperclip_runner",Rr=oe==="codex_local"?a?!!Xe.search:Z("adapterConfig","search",!!ie.search):!1,la=(0,u.useMemo)(()=>{if(a)return{heartbeat:{enabled:Xe.heartbeatEnabled,intervalSec:Xe.intervalSec}};const Qe={...ue.heartbeat&&typeof ue.heartbeat=="object"?ue.heartbeat:{},...D.heartbeat};return{...ue,heartbeat:Qe}},[a,D.heartbeat,ue,Xe]),_n=MW(la.heartbeat),_s=MW(_n.maxTurnContinuation),ta=TIe(_s.enabled,!0),Xn=_2(qW(_s.maxAttempts,PQe),0,QY),gt=_2(qW(_s.delayMs,MQe*1e3)/1e3,0,oxe);function $s(Qe){Y("heartbeat","maxTurnContinuation",{..._s,...Qe})}r($s,"updateMaxTurnContinuation");const qs=(0,t.jsx)(Yb,{ref:v,onDirtyChange:J,hideDraftActions:!a&&e.hideInlineSave,value:a?Xe.envBindings??GN:Z("adapterConfig","env",ie.env??GN),secrets:w,userSecretDefinitions:S,onCreateSecret:r(async(Qe,Yt)=>await K.mutateAsync({name:Qe,value:Yt}),"onCreateSecret"),onChange:r(Qe=>a?me({envBindings:Qe??{},envVars:""}):Y("adapterConfig","env",Qe),"onChange")},X);return!a&&e.content==="secrets"?(0,t.jsxs)("div",{className:z("relative",i&&"space-y-6"),children:[de&&!e.hideInlineSave&&(0,t.jsx)("div",{className:"sticky top-0 z-10 flex items-center justify-end border-b border-primary/20 bg-background/90 px-4 py-2 backdrop-blur-sm",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}),(0,t.jsx)(F,{size:"sm",onClick:ae,disabled:e.isSaving,children:e.isSaving?"Saving...":"Save"})]})}),e.environmentVariablesPlacement==="secrets"&&(0,t.jsxs)("div",{"data-config-section":"environment-variables",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"mb-3 text-sm font-medium",children:"Environment variables"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment variables"}),(0,t.jsx)("div",{className:z(i?"rounded-lg border border-border p-4":"px-4 pb-3"),children:qs})]}),(0,t.jsxs)("div",{"data-config-section":"secrets",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"mb-3 text-sm font-medium",children:"Secret access"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Secret access"}),(0,t.jsxs)("div",{className:z(i?"space-y-3 rounded-lg border border-border p-4":"space-y-3 px-4 pb-3"),children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:bi.secretAccess}),(0,t.jsx)(pQe,{config:{...ie,...D.adapterConfig},secrets:w,onChange:fe,onCreateSecret:r((Qe,Yt)=>K.mutateAsync({name:Qe,value:Yt}),"onCreateSecret"),proposals:_,onApproveProposal:A.requestApprove,onRejectProposal:A.requestReject}),A.dialogs]})]})]}):(0,t.jsxs)(LQe,{order:e.sectionOrder,className:z("relative",i&&"space-y-6"),children:[de&&!e.hideInlineSave&&(0,t.jsx)("div",{className:"sticky top-0 z-10 flex items-center justify-end px-4 py-2 bg-background/90 backdrop-blur-sm border-b border-primary/20",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Unsaved changes"}),(0,t.jsx)(F,{size:"sm",onClick:ae,disabled:!a&&e.isSaving,children:!a&&e.isSaving?"Saving...":"Save"})]})}),!a&&(0,t.jsxs)("div",{"data-config-section":"identity",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:e.sectionTitles?.identity??"Identity"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Identity"}),(0,t.jsxs)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[(0,t.jsx)(ws,{label:"Name",hint:bi.name,children:(0,t.jsx)(Oa,{value:Z("identity","name",e.agent.name),onCommit:r(Qe=>Y("identity","name",Qe),"onCommit"),immediate:!0,className:bm,placeholder:"Agent name"})}),(0,t.jsx)(ws,{label:"Title",hint:bi.title,children:(0,t.jsx)(Oa,{value:Z("identity","title",e.agent.title??""),onCommit:r(Qe=>Y("identity","title",Qe||null),"onCommit"),immediate:!0,className:bm,placeholder:"e.g. VP of Engineering"})}),(0,t.jsx)(ws,{label:"Reports to",hint:bi.reportsTo,children:(0,t.jsx)(CHe,{agents:we,value:Z("identity","reportsTo",e.agent.reportsTo??null),onChange:r(Qe=>Y("identity","reportsTo",Qe),"onChange"),excludeAgentIds:[e.agent.id],chooseLabel:"Choose manager…"})}),xe&&!e.hidePromptTemplate&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ws,{label:"Prompt Template",hint:bi.promptTemplate,children:(0,t.jsx)(wc,{value:Z("adapterConfig","promptTemplate",String(ie.promptTemplate??"")),onChange:r(Qe=>Y("adapterConfig","promptTemplate",Qe??""),"onChange"),placeholder:"You are agent {{ agent.name }}. Your role is {{ agent.role }}...",contentClassName:"min-h-(--sz-88px) text-sm font-mono",imageUploadHandler:r(async Qe=>{const Yt=`agents/${e.agent.id}/prompt-template`;return(await U.mutateAsync({file:Qe,namespace:Yt})).contentPath},"imageUploadHandler")})}),(0,t.jsx)("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-900 dark:text-amber-100",children:"Prompt template is replayed on every heartbeat. Keep it compact and dynamic to avoid recurring token cost and cache churn."})]})]})]}),q?(0,t.jsxs)("div",{"data-config-section":"environment",className:z(!i&&(a?"border-t border-border":"border-b border-border")),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Environment"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment"}),(0,t.jsx)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(ws,{label:"Default environment",hint:"This instance runs all agents in the Kubernetes sandbox. Local execution is disabled.",children:B?(0,t.jsxs)("div",{className:z(bm,"flex items-center text-muted-foreground"),children:[B.name," · Kubernetes sandbox"]}):(0,t.jsx)("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200",children:"This instance requires the Kubernetes sandbox, but no managed Kubernetes environment is available for this organization yet. Configure one before creating agents; execution will not fall back to local."})})})]}):bs?(0,t.jsxs)("div",{"data-config-section":"environment",className:z(!i&&(a?"border-t border-border":"border-b border-border")),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Environment"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment"}),(0,t.jsx)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(ws,{label:"Environment override",children:(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsxs)("select",{className:bm,value:tt,onChange:r(Qe=>{const Yt=Qe.target.value;if(a){me({defaultEnvironmentId:Yt});return}Y("identity","defaultEnvironmentId",Yt||null)},"onChange"),children:[(0,t.jsxs)("option",{value:"",children:["Default: ",Ke]}),es.map(Qe=>(0,t.jsx)("option",{value:Qe.id,children:mw(Qe)},Qe.id))]})})})})]}):null,(0,t.jsxs)("div",{"data-config-section":"adapter",className:z(!i&&(a?"border-t border-border":"border-b border-border")),children:[(0,t.jsxs)("div",{className:z(i?"flex items-center justify-between mb-3":"px-4 py-2 flex items-center justify-between gap-2"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium",children:e.sectionTitles?.adapter??"Adapter"}):(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Adapter"}),c&&(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:vr,disabled:Ys,children:Nt?`${ys}...`:ys})]}),(0,t.jsxs)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[o&&(0,t.jsx)(ws,{label:"Adapter type",hint:bi.adapterType,children:(0,t.jsx)(dxe,{value:oe,disabledTypes:I,onChange:r(Qe=>{if(a){const{adapterType:Yt,...an}=Zg,Fs={...an,adapterType:Qe};Qe==="codex_local"?Fs.dangerouslyBypassSandbox=!0:Qe==="gemini_local"?Fs.model="auto":Qe==="kimi_local"?Fs.model="kimi-code/kimi-for-coding":Qe==="cursor"?Fs.model="auto":Qe==="opencode_local"?Fs.model="openai/gpt-5.2-codex":Qe==="paperclip_runner"&&(Fs.model=rw),me(Fs)}else V(Yt=>({...Yt,adapterType:Qe,adapterConfig:{model:Qe==="gemini_local"?"auto":Qe==="kimi_local"?"kimi-code/kimi-for-coding":Qe==="opencode_local"?"openai/gpt-5.2-codex":Qe==="cursor"?"auto":Qe==="paperclip_runner"?SQe(oe,ie.model):"",effort:"",modelReasoningEffort:"",variant:"",mode:"",...Qe==="codex_local"?{dangerouslyBypassApprovalsAndSandbox:!0}:Qe==="paperclip_runner"?{...Fme(oe,Z("adapterConfig","model",ie.model))}:{}}}))},"onChange")})}),!a&&f&&(0,t.jsx)(nfe,{companyId:f,agentId:e.agent.id,agentName:e.agent.name,adapterType:oe==="paperclip_runner"?Z("adapterConfig","provider",ie.provider)==="codex"?"codex_local":Z("adapterConfig","provider",ie.provider)==="opencode"?"opencode_local":Z("adapterConfig","provider",ie.provider)==="acpx"&&Z("adapterConfig","acpxAgent",ie.acpxAgent)==="claude"?"claude_local":oe:oe,value:t2.safeParse(D.runtime.runtimeConfig?.aiConnection??ue.aiConnection).data,model:String(Z("adapterConfig","model",ie.model)??""),environmentId:tt||void 0,legacy:!0,onChange:r(Qe=>Y("runtime","runtimeConfig",{...ue,aiConnection:Qe}),"onChange")}),d&&!e.compactTestFeedback&&(ls||Gt.error)&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:ls??(Gt.error instanceof Error?Gt.error.message:"Environment test failed")}),d&&!e.compactTestFeedback&&Gt.data&&(0,t.jsx)(UQe,{result:Gt.data}),d&&Yn&&(0,t.jsx)(oK,{companyId:f,adapterType:oe,environmentId:Ne,onStored:a?mt:We,onApplyStored:a?st:pt,onAccountBinding:a?void 0:ze},`${oe}:${Ne}`),Ae&&(0,t.jsx)(ws,{label:"Working directory (deprecated)",hint:bi.cwd,children:(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border px-2.5 py-1.5",children:[(0,t.jsx)(Io,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)(Oa,{value:a?Xe.cwd:Z("adapterConfig","cwd",String(ie.cwd??"")),onCommit:r(Qe=>a?me({cwd:Qe}):Y("adapterConfig","cwd",Qe||void 0),"onCommit"),immediate:!0,className:"w-full bg-transparent outline-none text-sm font-mono placeholder:text-muted-foreground/40",placeholder:"/path/to/project"}),(0,t.jsx)(hd,{})]})}),Vt("adapter"),xe&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(lK,{models:ut,value:Qr,onChange:r(Qe=>{const Yt=kT(oe,Qe),an=["codex_local","claude_local","grok_local"].includes(oe)&&!!Gr&&!Yt.includes(String(Gr));if(a){me({model:Qe,...an?{thinkingEffort:""}:{}});return}Y("adapterConfig","model",Qe||void 0),an&&(Y("adapterConfig",gr,void 0),Y("adapterConfig","reasoningEffort",void 0))},"onChange"),open:Wt,onOpenChange:Me,defaultLabel:oe==="claude_local"?"Default (claude-opus-5)":void 0,allowDefault:oe!=="opencode_local"&&oe!=="pi_local"&&oe!=="paperclip_runner",required:oe==="opencode_local"||oe==="pi_local",groupByProvider:oe==="opencode_local"||oe==="pi_local",creatable:!0,detectedModel:jt,detectedModelCandidates:[],onDetectModel:oe==="opencode_local"||oe==="paperclip_runner"?void 0:async()=>(await Ts()).data?.model??null,onRefreshModels:kQe(oe)?rr:void 0,refreshingModels:Ls,detectModelLabel:"Detect model",emptyDetectHint:"No model detected. Select or enter one manually."}),(Ut||Fe)&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:Ut??(Fe instanceof Error?Fe.message:"Failed to load adapter models.")}),oe==="opencode_local"&&ht&&ht.driver!=="local"&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Live OpenCode model discovery only runs for Local environments. Using the curated list and manual entry for ",ht.name,"."]}),Dn&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(KQe,{value:Gr,options:cr,onChange:r(Qe=>a?me({thinkingEffort:Qe}):Y("adapterConfig",gr,Qe||void 0),"onChange"),open:Ee,onOpenChange:He}),oe==="codex_local"&&Rr&&Gr==="minimal"&&(0,t.jsx)("p",{className:"text-xs text-amber-400",children:"Codex may reject `minimal` thinking when search is enabled."})]})]})]})]}),(0,t.jsxs)("div",{"data-config-section":"configuration",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Configuration"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Configuration"}),(0,t.jsxs)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[!a&&typeof ie.bootstrapPromptTemplate=="string"&&ie.bootstrapPromptTemplate&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ws,{label:"Bootstrap prompt (legacy)",hint:bi.bootstrapPrompt,children:(0,t.jsx)(wc,{value:Z("adapterConfig","bootstrapPromptTemplate",String(ie.bootstrapPromptTemplate??"")),onChange:r(Qe=>Y("adapterConfig","bootstrapPromptTemplate",Qe||void 0),"onChange"),placeholder:"Optional initial setup prompt for the first run",contentClassName:"min-h-(--sz-44px) text-sm font-mono",imageUploadHandler:r(async Qe=>{const Yt=`agents/${e.agent.id}/bootstrap-prompt`;return(await U.mutateAsync({file:Qe,namespace:Yt})).contentPath},"imageUploadHandler")})}),(0,t.jsx)("div",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200",children:"Bootstrap prompt is legacy and will be removed in a future release. Consider moving this content into the agent's prompt template or instructions file instead."})]}),Vt("configuration"),(xe||oe==="process"||bt?.fields.some(Qe=>pF(Qe.key)==="advanced"))&&(0,t.jsx)(y2,{title:"Advanced",open:kt,onToggle:r(()=>hs(!kt),"onToggle"),children:(0,t.jsxs)("div",{className:"space-y-3",children:[xe&&(0,t.jsxs)(t.Fragment,{children:[" ",!L&&(0,t.jsx)(ws,{label:"Command",hint:bi.localCommand,children:(0,t.jsx)(Oa,{value:a?Xe.command:Z("adapterConfig",Dt,String(ie.command??"")),onCommit:r(Qe=>a?me({command:Qe}):Y("adapterConfig",Dt,Qe||null),"onCommit"),immediate:!0,className:bm,placeholder:{claude_local:"claude",codex_local:"codex",gemini_local:"gemini",kimi_local:"kimi",pi_local:"pi",cursor:"agent",opencode_local:"opencode"}[oe]??oe.replace(/_local$/,"")})}),(0,t.jsx)(ws,{label:"Extra args (comma-separated)",hint:bi.extraArgs,children:(0,t.jsx)(Oa,{value:a?Xe.extraArgs:Z("adapterConfig","extraArgs",IQe(ie.extraArgs)),onCommit:r(Qe=>a?me({extraArgs:Qe}):Y("adapterConfig","extraArgs",Qe?.trim()?_Qe(Qe):null),"onCommit"),className:bm,placeholder:"e.g. --verbose, --foo=bar"})})]}),Vt("advanced")]})})]})]}),e.environmentVariablesPlacement!=="secrets"&&(xe||bt?.fields.some(Qe=>pF(Qe.key)==="environment"))&&(0,t.jsxs)("div",{"data-config-section":"environment-variables",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Environment variables"}):(0,t.jsx)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground",children:"Environment variables"}),(0,t.jsx)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:xe?qs:Vt("environment")})]}),a&&m?(0,t.jsxs)("div",{"data-config-section":"run-policy",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsxs)("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[(0,t.jsx)(H_,{className:"h-3 w-3"})," Run Policy"]}):(0,t.jsxs)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)(H_,{className:"h-3 w-3"})," Run Policy"]}),(0,t.jsxs)("div",{className:z(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[(0,t.jsx)(dY,{label:"Heartbeat on interval",hint:bi.heartbeatInterval,checked:Xe.heartbeatEnabled,onCheckedChange:r(Qe=>me({heartbeatEnabled:Qe}),"onCheckedChange"),number:Xe.intervalSec,onNumberChange:r(Qe=>me({intervalSec:Qe}),"onNumberChange"),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:bi.intervalSec,showNumber:Xe.heartbeatEnabled}),(0,t.jsx)(y2,{title:"Advanced Run Policy",open:at,onToggle:r(()=>Mt(!at),"onToggle"),children:(0,t.jsx)("div",{className:"space-y-3",children:Vt("runPolicy")})})]})]}):a?null:(0,t.jsxs)("div",{"data-config-section":"run-policy",className:z(!i&&"border-b border-border"),children:[i?(0,t.jsxs)("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[(0,t.jsx)(H_,{className:"h-3 w-3"})," Run Policy"]}):(0,t.jsxs)("div",{className:"px-4 py-2 text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)(H_,{className:"h-3 w-3"})," Run Policy"]}),(0,t.jsxs)("div",{className:z(i?"border border-border rounded-lg overflow-hidden":""),children:[(0,t.jsx)("div",{className:z(i?"p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(dY,{label:"Heartbeat on interval",hint:bi.heartbeatInterval,checked:Z("heartbeat","enabled",pe.enabled===!0),onCheckedChange:r(Qe=>Y("heartbeat","enabled",Qe),"onCheckedChange"),number:Z("heartbeat","intervalSec",Number(pe.intervalSec??300)),onNumberChange:r(Qe=>Y("heartbeat","intervalSec",Qe),"onNumberChange"),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:bi.intervalSec,showNumber:Z("heartbeat","enabled",pe.enabled===!0)})}),(0,t.jsx)(y2,{title:"Advanced Run Policy",bordered:i,open:at,onToggle:r(()=>Mt(!at),"onToggle"),children:(0,t.jsxs)("div",{className:"space-y-3",children:[Vt("runPolicy"),xe&&(0,t.jsx)(t.Fragment,{children:!a&&(0,t.jsxs)(t.Fragment,{children:[!bt?.fields.some(Qe=>Qe.key==="timeoutSec")&&(0,t.jsx)(ws,{label:"Timeout (sec)",hint:bi.timeoutSec,children:(0,t.jsx)(nc,{value:Z("adapterConfig","timeoutSec",Number(ie.timeoutSec??0)),onCommit:r(Qe=>Y("adapterConfig","timeoutSec",Qe),"onCommit"),immediate:!0,className:bm})}),!bt?.fields.some(Qe=>Qe.key==="graceSec")&&(0,t.jsx)(ws,{label:"Interrupt grace period (sec)",hint:bi.graceSec,children:(0,t.jsx)(nc,{value:Z("adapterConfig","graceSec",Number(ie.graceSec??15)),onCommit:r(Qe=>Y("adapterConfig","graceSec",Qe),"onCommit"),immediate:!0,className:bm})})]})}),(0,t.jsx)(id,{label:"Wake on demand",hint:bi.wakeOnDemand,checked:Z("heartbeat","wakeOnDemand",pe.wakeOnDemand!==!1),onChange:r(Qe=>Y("heartbeat","wakeOnDemand",Qe),"onChange")}),(0,t.jsx)(ws,{label:"Cooldown (sec)",hint:bi.cooldownSec,children:(0,t.jsx)(nc,{value:Z("heartbeat","cooldownSec",Number(pe.cooldownSec??10)),onCommit:r(Qe=>Y("heartbeat","cooldownSec",Qe),"onCommit"),immediate:!0,className:bm})}),(0,t.jsx)(ws,{label:"Max concurrent runs",hint:bi.maxConcurrentRuns,children:(0,t.jsx)(nc,{value:Z("heartbeat","maxConcurrentRuns",Number(pe.maxConcurrentRuns??20)),onCommit:r(Qe=>Y("heartbeat","maxConcurrentRuns",Qe),"onCommit"),immediate:!0,className:bm})}),(0,t.jsxs)("div",{className:"rounded-md border border-border/70 px-3 py-2",children:[(0,t.jsx)(id,{label:"Continue after max-turn stop",hint:bi.maxTurnContinuationEnabled,checked:ta,onChange:r(Qe=>$s({enabled:Qe}),"onChange")}),ta?(0,t.jsxs)("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[(0,t.jsx)(ws,{label:"Continuation attempts",hint:bi.maxTurnContinuationMaxAttempts,children:(0,t.jsx)(nc,{value:Xn,onCommit:r(Qe=>$s({maxAttempts:_2(Qe,0,QY)}),"onCommit"),immediate:!0,className:bm})}),(0,t.jsx)(ws,{label:"Continuation delay (sec)",hint:bi.maxTurnContinuationDelaySec,children:(0,t.jsx)(nc,{value:gt,onCommit:r(Qe=>$s({delayMs:DQe(Qe)}),"onCommit"),immediate:!0,className:bm})})]}):null]})]})})]})]}),!a&&p?(0,t.jsxs)("div",{className:z(!i&&"border-b border-border"),children:[i?(0,t.jsxs)("h3",{className:"mb-3 flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)(vj,{className:"h-3 w-3"})," Debugging"]}):(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 text-xs font-medium text-muted-foreground",children:[(0,t.jsx)(vj,{className:"h-3 w-3"})," Debugging"]}),(0,t.jsxs)("div",{className:z("border-border bg-accent/30",i?"rounded-lg border p-4":"mx-4 mb-4 rounded-md border px-3 py-3"),children:[(0,t.jsx)(id,{label:"Capture raw provider traces",hint:"Stores exact provider traffic for every future run until disabled. Traces may contain sensitive prompts and tool arguments, are administrator-only, and expire after 24 hours.",checked:Z("debug","providerTrace",be.providerTrace)==="raw",onChange:r(Qe=>Y("debug","providerTrace",Qe?"raw":void 0),"onChange")}),Z("debug","providerTrace",be.providerTrace)==="raw"?(0,t.jsxs)("div",{className:"mt-3 flex items-start gap-2 rounded-md border border-border bg-background/60 px-3 py-2 text-xs text-foreground",children:[(0,t.jsx)(vj,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{children:"Raw tracing is on for future runs. Paperclip keeps at most 64 MiB per run and automatically deletes it after 24 hours."})]}):null]})]}):null,e.compactTestFeedback&&d&&l&&(0,t.jsx)(ofe,{state:Nt?"running":ls||Gt.error?"fail":Bs?.status??"idle",result:Bs??null,error:ls??(Gt.error instanceof Error?Gt.error.message:null),onTest:vr,disabled:Ys})]})}r(lxe,"AgentConfigForm");var TF=new Set(["authenticated","failed","timed_out","cancelled"]),EF=2e3;function PF({value:e,label:s}){const[n,a]=(0,u.useState)(!1),i=(0,u.useRef)(null);return(0,u.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]),(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,className:"text-muted-foreground hover:text-foreground",onClick:r(async()=>{try{await Hr(e),a(!0)}catch{a(!1)}i.current&&clearTimeout(i.current),i.current=setTimeout(()=>a(!1),1500)},"onClick"),children:n?(0,t.jsx)(fs,{className:"size-3"}):(0,t.jsx)(jr,{className:"size-3"})})}r(PF,"AdapterLoginCopyButton");function $Qe({status:e,message:s}){return e==="authenticated"?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(fs,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Authenticated. The environment has credentials now."})]}):(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(Rs,{className:"size-3 shrink-0"}),(0,t.jsxs)("span",{children:[e==="timed_out"?"Login timed out":e==="cancelled"?"Login cancelled":"Login failed",s?`: ${s}`:"."]})]})}r($Qe,"AdapterLoginTerminalState");var OQe={claude_local:"Anthropic",codex_local:"OpenAI"};function cxe(e){const s=OQe[e];return s?`Sign in to ${s}`:"Sign in to the environment"}r(cxe,"adapterLoginTitle");function oK(e){return Uw()(e.adapterType).login?.panelMode==="submitted_browser_code"?(0,t.jsx)(zQe,{...e}):(0,t.jsx)(FQe,{...e})}r(oK,"AdapterLoginPanel");function FQe({companyId:e,adapterType:s,environmentId:n,autoStart:a,onConnected:i,onAccountBinding:o,chrome:l="panel",aiConnection:c,onPromptReady:d}){const[m,h]=(0,u.useState)(null),[p,f]=(0,u.useState)(null),[g,v]=(0,u.useState)(null),[y,w]=(0,u.useState)("idle"),S=(0,u.useRef)(!1),j=ke({mutationFn:r(()=>zt.startAdapterAuthLogin(e,s,{environmentId:n,aiConnection:c}),"mutationFn"),onSuccess:r(te=>{S.current=!1,f(null),v(null),w("idle"),h(te.sessionId)},"onSuccess"),onError:r(te=>{f(te instanceof Error?te.message:"Could not start the login.")},"onError")}),N=(0,u.useCallback)(()=>{S.current=!1,h(null),v(null),f(null)},[]),_=ke({mutationFn:r(()=>zt.cancelAdapterAuthLogin(e,s,m),"mutationFn"),onSuccess:N,onError:r(te=>{f(te instanceof Error?te.message:"Could not cancel the login.")},"onError")}),A=ee({queryKey:["adapter-login-active-session",e,s],queryFn:r(async()=>{try{const te=await zt.getActiveAdapterAuthLoginSession(e,s);if(!te)return null;if(c&&te.environmentId!==n||!!te.aiConnection!=!!c||c&&(te.aiConnection?.provider!==c.provider||te.aiConnection?.method!==c.method||te.aiConnection?.connectionId!==c.connectionId||te.aiConnection?.ownership!==c.ownership||te.aiConnection?.allAgents!==c.allAgents||JSON.stringify(te.aiConnection?.agentIds)!==JSON.stringify(c.agentIds)))throw new Error("Another sign-in attempt is active. Finish or cancel it in its original account setup before starting this one.");return te}catch(te){if(te instanceof vn&&te.status===404)return null;throw te}},"queryFn"),retry:!1,gcTime:0,staleTime:0}),[C,I]=(0,u.useState)(!1),T=ee({queryKey:["adapter-login-status",e,s,m],queryFn:r(()=>zt.getAdapterAuthLoginStatus(e,s,m),"queryFn"),enabled:!!m&&!C,retry:r((te,re)=>re instanceof vn&&re.status===404?!1:te<3,"retry"),refetchInterval:r(te=>{const re=te.state.data?.status;return re&&TF.has(re)?!1:EF},"refetchInterval")});(0,u.useEffect)(()=>{const te=T.data?.prompt??null;te&&v(te)},[T.data]);const R=T.data??j.data??null,L=R?.status??null,O=g,$=L?TF.has(L):!1,E=!!m&&!$,q=j.isPending||E||y==="saving",B=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(B.current||!A.isFetched)return;B.current=!0;const te=A.data;te&&(S.current=!0,f(null),v(te.prompt??null),h(te.sessionId))},[A.isFetched,A.data]),(0,u.useEffect)(()=>{const te=T.error;if(!(te instanceof vn&&te.status===404)||!S.current||C)return;I(!0);const re=m;(async()=>(re&&await zt.cancelAdapterAuthLogin(e,s,re).catch(()=>{}),I(!1),N()))()},[T.error,C,m,e,s,N]);const K=(0,u.useRef)(!1),U=(0,u.useRef)(j.mutate);U.current=j.mutate,(0,u.useEffect)(()=>{if(!(!a||K.current)){if(A.isError){K.current=!0,f(A.error instanceof Error?A.error.message:"Could not check for an active login.");return}A.isSuccess&&(K.current=!0,!A.data&&U.current())}},[a,A.isSuccess,A.isError,A.data,A.error]);const D=(0,u.useRef)(!1),V=(0,u.useRef)(i);V.current=i,(0,u.useEffect)(()=>{L!=="authenticated"||D.current||(D.current=!0,V.current?.(m??void 0))},[L]);const H=(0,u.useRef)(null),J=(0,u.useRef)(o);J.current=o;const X=T.data?.codexAccountBinding??null,le=(0,u.useCallback)(async te=>{const re=J.current;if(re){w("saving");try{await re(te),w("bound")}catch{w("failed")}}},[]);(0,u.useEffect)(()=>{L!=="authenticated"||!m||H.current!==m&&(!X||!X.companyIdentityDiffers||!J.current||(H.current=m,le(X)))},[L,m,X,le]);const ce=(0,u.useRef)(d);if(ce.current=d,(0,u.useEffect)(()=>{ce.current?.(O?.url??null)},[O]),l==="onboarding"){const te=$&&L&&L!=="authenticated";return(0,t.jsx)(bfe,{loading:!O&&!p&&!te,providerName:xfe(s),authorizationUrl:O?.url,mode:"displayed_code",children:p?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:p}):te?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:L==="timed_out"?"The login timed out. Start it again.":L==="cancelled"?"The login was cancelled.":"The login did not finish. Start it again."}):(0,t.jsx)($7e,{code:O?.code??"",autoCopy:!0})})}return(0,t.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:cxe(s)}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[E&&(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground hover:text-foreground",disabled:_.isPending,onClick:r(()=>_.mutate(),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",disabled:q,onClick:r(()=>j.mutate(),"onClick"),children:"Sign in"})]})]}),p&&(0,t.jsx)("div",{role:"alert",className:"text-(length:--text-micro) text-destructive",children:p}),(0,t.jsxs)("div",{role:"status","aria-live":"polite",className:"space-y-2 empty:hidden",children:[E&&!O&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(it,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Preparing..."})]}),E&&O&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:"Copy the code, then open the authentication page."}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"1. Code"}),(0,t.jsx)("span",{className:"font-mono text-xs text-foreground break-all",children:O.code})]}),(0,t.jsx)(PF,{value:O.code,label:"Copy code"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"2. Authentication URL"}),(0,t.jsx)("span",{className:"font-mono text-xs text-foreground break-all",children:O.url})]}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(PF,{value:O.url,label:"Copy URL"}),(0,t.jsx)(F,{asChild:!0,type:"button",variant:"ghost",size:"icon-xs","aria-label":"Open the authentication page",title:"Open the authentication page",className:"text-muted-foreground hover:text-foreground",children:(0,t.jsx)("a",{href:O.url,target:"_blank",rel:"noreferrer noopener",children:(0,t.jsx)(xr,{className:"size-3"})})})]})]})]}),$&&L&&(0,t.jsx)($Qe,{status:L,message:R?.failure?.message??null}),L==="authenticated"&&y==="saving"&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(it,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Binding this agent to the signed-in account..."})]}),L==="authenticated"&&y==="bound"&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(fs,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Agent bound to the signed-in account."})]}),L==="authenticated"&&y==="failed"&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro)",children:[(0,t.jsx)(Rs,{className:"size-3 shrink-0 text-destructive"}),(0,t.jsx)("span",{className:"text-destructive",children:"Could not bind this agent to the signed-in account."}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-6 px-2 text-xs",onClick:r(()=>{X&&le(X)},"onClick"),children:"Retry"})]})]})]})}r(FQe,"DisplayedCodeLoginPanel");var BQe=new Set(["failed","timed_out","cancelled"]),GY="The login did not finish. Start the login again.",qQe=9e5,YY="The login timed out. Start the login again.";function zQe({companyId:e,adapterType:s,environmentId:n,onStored:a,onApplyStored:i,autoStart:o,onConnected:l,onCodeSubmitted:c,onSubmitFailed:d,chrome:m="panel",aiConnection:h,onPromptReady:p}){const[f,g]=(0,u.useState)(null),[v,y]=(0,u.useState)(null),[w,S]=(0,u.useState)(null),[j,N]=(0,u.useState)(!1),[_,A]=(0,u.useState)(""),[C,I]=(0,u.useState)(null),[T,R]=(0,u.useState)(!1),[L,O]=(0,u.useState)(!1),[$,E]=(0,u.useState)(!1),[q,B]=(0,u.useState)(!1),K=(0,u.useRef)(!1),[U,D]=(0,u.useState)(!1),V=(0,u.useRef)(!1),H=r(()=>{y(null),S(null),N(!1),A(""),I(null),R(!1),O(!1),B(!1),E(!1),K.current=!1},"resetLocalState"),J=ee({queryKey:["claude-oauth-token-status",e],queryFn:r(async()=>{try{return await zt.getClaudeOAuthTokenStatus(e)}catch(et){if(et instanceof vn&&et.status===404)return null;throw et}},"queryFn"),retry:r((et,Ie)=>Ie instanceof vn&&Ie.status===404?!1:et<2,"retry")}).data??null,X=ke({mutationFn:r(()=>zt.startClaudeSetupTokenLogin(e,{environmentId:n,aiConnection:h,...J&&!h?{overwrite:{expectedSecretId:J.secretId,expectedLatestVersion:J.latestVersion}}:{}}),"mutationFn"),onSuccess:r(et=>{V.current=!1,H(),g(et.sessionId)},"onSuccess"),onError:r(et=>{y(et instanceof Error?et.message:"Could not start the login.")},"onError")}),le=r(()=>{V.current=!1,g(null),H()},"clearActiveSession"),ce=ke({mutationFn:r(()=>zt.cancelClaudeSetupTokenLogin(e,f),"mutationFn"),onSuccess:r(()=>{le()},"onSuccess"),onError:r(et=>{if(et instanceof vn&&et.status===404){le();return}y(et instanceof Error?et.message:"Could not cancel the login.")},"onError")}),te=(0,u.useCallback)(et=>{zt.cancelClaudeSetupTokenLogin(e,et).catch(()=>{})},[e]),re=ee({queryKey:["claude-setup-token-active-session",e],queryFn:r(async()=>{try{const et=await zt.getActiveClaudeSetupTokenLoginSession(e);if(!et)return null;if(h&&et.environmentId!==n||!!et.aiConnection!=!!h||h&&(et.aiConnection?.provider!==h.provider||et.aiConnection?.method!==h.method||et.aiConnection?.connectionId!==h.connectionId||et.aiConnection?.ownership!==h.ownership||et.aiConnection?.allAgents!==h.allAgents||JSON.stringify(et.aiConnection?.agentIds)!==JSON.stringify(h.agentIds)))throw new Error("Another sign-in attempt is active. Finish or cancel it in its original account setup before starting this one.");return et}catch(et){if(et instanceof vn&&et.status===404)return null;throw et}},"queryFn"),retry:!1,gcTime:0,staleTime:0}),[de,Z]=(0,u.useState)(!1),Y=!!f&&!L&&!q&&!de,G=ee({queryKey:["claude-setup-token-status",e,f],queryFn:r(()=>zt.getClaudeSetupTokenLoginStatus(e,f),"queryFn"),enabled:Y,retry:r((et,Ie)=>Ie instanceof vn&&Ie.status===404?!1:et<3,"retry"),refetchInterval:r(et=>{if(L||q)return!1;const Ie=et.state.data?.status;return Ie&&TF.has(Ie)?!1:EF},"refetchInterval")});(0,u.useEffect)(()=>{const et=G.error;if(et instanceof vn&&et.status===404){if(V.current){if(de)return;Z(!0);const Ie=f;(async()=>(Ie&&await zt.cancelClaudeSetupTokenLogin(e,Ie).catch(()=>{}),Z(!1),le()))();return}B(!0)}},[G.error,de,f,e]);const fe=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(fe.current||!re.isFetched)return;fe.current=!0;const et=re.data;et&&(V.current=!0,H(),g(et.sessionId),et.prompt&&(S(et.prompt.authorizationUrl),et.prompt.transportAdvisory&&N(!0)))},[re.isFetched,re.data]);const se=ee({queryKey:["claude-setup-token-prompt",e,f],enabled:Y&&!w,queryFn:r(async()=>{try{return await zt.getClaudeSetupTokenLoginPrompt(e,f)}catch(et){if(et instanceof vn&&et.status===404)return null;throw et}},"queryFn"),refetchInterval:r(et=>L||et.state.data?.authorizationUrl?!1:EF,"refetchInterval")});(0,u.useEffect)(()=>{const et=se.data?.authorizationUrl??null;et&&S(et),se.data?.transportAdvisory&&N(!0)},[se.data]);const ae=ke({mutationFn:r(et=>zt.submitClaudeSetupTokenBrowserCode(e,f,et),"mutationFn"),onError:r(et=>{y(et instanceof Error?et.message:"Could not submit the browser code.")},"onError")}),ie=ke({mutationFn:r(()=>zt.completeClaudeSetupTokenLogin(e,f),"mutationFn"),onSuccess:r(et=>{I(et.storedSessionId),a?.(et.storedSessionId)},"onSuccess"),onError:r(()=>{R(!0)},"onError")}),ue=G.data?.status??X.data?.status??null,pe=G.data?.expiresAt??X.data?.expiresAt??null,be=(0,u.useRef)(ie.mutate);be.current=ie.mutate,(0,u.useEffect)(()=>{ue==="authenticated"&&!K.current&&(K.current=!0,be.current())},[ue]);const oe=C!==null,je=T||q||!!(ue&&BQe.has(ue)),_e=ue==="authenticated"&&!oe&&!T,xe=!!f&&!oe&&!je&&!L,Ae=X.isPending||xe;(0,u.useEffect)(()=>{if(!xe)return;const et=pe!==null?new Date(pe).getTime():NaN,Ie=Number.isFinite(et)?Math.max(0,et-Date.now()):qQe,Ne=setTimeout(()=>{f&&te(f),O(!0)},Ie);return()=>clearTimeout(Ne)},[xe,pe,f,te]);const Ye=_.trim(),Oe=xe&&!!w&&!_e&&jIe(Ye)&&!ae.isPending&&!$,Xe=(0,u.useRef)(c);Xe.current=c;const me=(0,u.useRef)(d);me.current=d;const Le=r(()=>{Oe&&(y(null),ae.mutate(Ye),E(!0),Xe.current?.(),m!=="onboarding"&&A(""))},"handleSubmit"),mt=(0,u.useRef)(!1),We=(0,u.useRef)(X.mutate);We.current=X.mutate,(0,u.useEffect)(()=>{if(!(!o||mt.current)){if(re.isError){mt.current=!0,y(re.error instanceof Error?re.error.message:"Could not check for an active login.");return}re.isSuccess&&(mt.current=!0,!re.data&&We.current())}},[o,re.isSuccess,re.isError,re.data,re.error]);const ze=(0,u.useRef)(Le);ze.current=Le;const st=m==="onboarding",pt=(0,u.useRef)(!1);(0,u.useEffect)(()=>{!st||!pt.current||(pt.current=!1,Oe&&ze.current())},[st,Oe,_]);const Pt=(0,u.useRef)(!1),tt=(0,u.useRef)(l);tt.current=l,(0,u.useEffect)(()=>{!oe||Pt.current||(Pt.current=!0,tt.current?.(f??void 0))},[oe]),(0,u.useEffect)(()=>{$&&(!v&&!je&&!L||(E(!1),me.current?.()))},[$,v,je,L]);const ht=(0,u.useRef)(p);if(ht.current=p,(0,u.useEffect)(()=>{ht.current?.(w)},[w]),m==="onboarding"){const et=je||L;return(0,t.jsxs)(bfe,{loading:!w&&!v&&!et,providerName:xfe(s),authorizationUrl:w??void 0,mode:"submitted_code",children:[j&&(0,t.jsxs)("p",{className:"flex items-start gap-2 pl-2 text-xs text-amber-700 dark:text-amber-200",children:[(0,t.jsx)(Rs,{className:"mt-0.5 size-3 shrink-0"}),"This connection is not encrypted. The login code travels in clear text on this network. Continue only on a network you trust."]}),v?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:v}):et?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:L&&!je?YY:GY}):(0,t.jsx)(G5,{value:_,onChange:A,onSubmit:Le,onPaste:r(()=>{pt.current=!0},"onPaste"),masked:!0,disabled:ae.isPending||_e||$})]})}return(0,t.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-foreground",children:cxe(s)}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[xe&&(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground hover:text-foreground",disabled:ce.isPending,onClick:r(()=>ce.mutate(),"onClick"),children:"Cancel"}),i&&J&&!xe&&!oe&&!U&&(0,t.jsx)(F,{type:"button",variant:"default",size:"sm",className:"h-7 px-2.5 text-xs",onClick:r(()=>{i(),D(!0)},"onClick"),children:"Use saved login"}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",disabled:Ae,onClick:r(()=>X.mutate(),"onClick"),children:J&&!xe&&!oe?"Sign in to replace":"Sign in"})]})]}),J&&!xe&&!oe&&!U&&(0,t.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:"You have a saved Claude login. Use it to bind this agent, or log in again to replace the stored token."}),U&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(fs,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"The saved Claude login is bound to this agent now."})]}),v&&(0,t.jsx)("div",{role:"alert",className:"text-(length:--text-micro) text-destructive",children:v}),(0,t.jsxs)("div",{role:"status","aria-live":"polite",className:"space-y-2 empty:hidden",children:[xe&&!w&&!_e&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(it,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Preparing..."})]}),xe&&w&&!_e&&(0,t.jsxs)("div",{className:"space-y-2",children:[j&&(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-300 bg-amber-50 px-2 py-1.5 text-(length:--text-micro) text-amber-800 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-200",children:[(0,t.jsx)(Rs,{className:"size-3 shrink-0 mt-0.5"}),(0,t.jsx)("span",{children:"This connection is not encrypted. The login code travels in clear text on this network. Continue only on a network you trust."})]}),(0,t.jsx)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:"Open the authorization page, then enter the browser code it shows."}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"1. Authorization URL"}),(0,t.jsx)("span",{className:"font-mono text-xs text-foreground break-all",children:w})]}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(PF,{value:w,label:"Copy URL"}),(0,t.jsx)(F,{asChild:!0,type:"button",variant:"ghost",size:"icon-xs","aria-label":"Open the authorization page",title:"Open the authorization page",className:"text-muted-foreground hover:text-foreground",children:(0,t.jsx)("a",{href:w,target:"_blank",rel:"noreferrer noopener",children:(0,t.jsx)(xr,{className:"size-3"})})})]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("div",{className:"text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:"2. Browser code"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{"aria-label":"Browser code",type:"text",autoComplete:"off",spellCheck:!1,value:_,onChange:r(et=>A(et.target.value),"onChange"),onKeyDown:r(et=>{et.key==="Enter"&&(et.preventDefault(),Le())},"onKeyDown"),className:"flex-1 min-w-0 rounded-md border border-border bg-background px-2 py-1 font-mono text-xs text-foreground"}),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs",disabled:!Oe,onClick:Le,children:"Submit"})]})]})]}),_e&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(it,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Completing the login…"})]}),oe&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(fs,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Authenticated. The environment has credentials now."})]}),je&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(Rs,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:GY})]}),L&&!je&&!oe&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(Rs,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:YY})]})]})]})}r(zQe,"SubmittedBrowserCodeLoginPanel");function UQe({result:e}){const s=e.status==="pass"?"Passed":e.status==="warn"?"Warnings":"Failed",n=e.status==="pass"?"text-green-700 dark:text-green-300 border-green-300 dark:border-green-500/40 bg-green-50 dark:bg-green-500/10":e.status==="warn"?"text-amber-700 dark:text-amber-300 border-amber-300 dark:border-amber-500/40 bg-amber-50 dark:bg-amber-500/10":"text-red-700 dark:text-red-300 border-red-300 dark:border-red-500/40 bg-red-50 dark:bg-red-500/10";return(0,t.jsxs)("div",{className:`rounded-md border px-3 py-2 text-xs ${n}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"font-medium",children:s}),(0,t.jsx)("span",{className:"text-(length:--text-micro) opacity-80",children:new Date(e.testedAt).toLocaleTimeString()})]}),(0,t.jsx)("div",{className:"mt-2 space-y-1.5",children:e.checks.map((a,i)=>(0,t.jsxs)("div",{className:"text-(length:--text-micro) leading-relaxed break-words",children:[(0,t.jsx)("span",{className:"font-medium uppercase tracking-wide opacity-80",children:a.level}),(0,t.jsx)("span",{className:"mx-1 opacity-60",children:"·"}),(0,t.jsx)("span",{children:a.message}),a.detail&&(0,t.jsxs)("span",{className:"block opacity-75 break-all",children:["(",a.detail,")"]}),a.hint&&(0,t.jsxs)("span",{className:"block opacity-90 break-words",children:["Hint: ",a.hint]})]},`${a.code}-${i}`))})]})}r(UQe,"AdapterEnvironmentResult$1");function dxe({value:e,onChange:s,disabledTypes:n}){const[a,i]=(0,u.useState)(!1),o=zm(e),l=(0,u.useMemo)(()=>axe(c=>ow[c]??df(c)).filter(c=>!n.has(c.value)),[n]);return(0,t.jsxs)(nr,{open:a,onOpenChange:i,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[(0,t.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e==="opencode_local"?(0,t.jsx)(fF,{className:"h-3.5 w-3.5"}):null,(0,t.jsx)("span",{className:"truncate",children:ow[e]??df(e)}),o.experimental&&(0,t.jsx)(JY,{})]}),(0,t.jsx)(en,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsx)(Wn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:l.map(c=>(0,t.jsxs)("button",{disabled:c.comingSoon,className:z("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded",c.comingSoon?"opacity-40 cursor-not-allowed":"hover:bg-accent/50",c.value===e&&!c.comingSoon&&"bg-accent"),onClick:r(()=>{c.comingSoon||(s(c.value),i(!1))},"onClick"),children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[c.value==="opencode_local"?(0,t.jsx)(fF,{className:"h-3.5 w-3.5"}):null,(0,t.jsx)("span",{children:c.label}),c.experimental&&(0,t.jsx)(JY,{})]}),c.comingSoon&&(0,t.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground",children:"Coming soon"})]},c.value))})]})}r(dxe,"AdapterTypeDropdown");function JY(){return(0,t.jsx)("span",{className:"shrink-0 rounded border border-amber-500/30 bg-amber-500/10 px-1.5 py-0.5 text-(length:--text-nano) font-medium leading-none text-amber-700 dark:text-amber-200",children:"Experimental"})}r(JY,"ExperimentalBadge$1");function lK({models:e,value:s,onChange:n,open:a,onOpenChange:i,allowDefault:o,required:l,groupByProvider:c,creatable:d,detectedModel:m,detectedModelCandidates:h,onDetectModel:p,onRefreshModels:f,refreshingModels:g,detectModelLabel:v,emptyDetectHint:y,defaultLabel:w}){const[S,j]=(0,u.useState)(""),[N,_]=(0,u.useState)(!1),A=e.find($=>$.id===s),C=S.trim(),I=!!(d&&C&&!e.some($=>$.id.toLowerCase()===C.toLowerCase())),T=(0,u.useMemo)(()=>{const $=new Set;m&&$.add(m);for(const E of h??[])E&&$.add(E);return $},[m,h]),R=(0,u.useMemo)(()=>e.filter($=>{if(T.has($.id))return!1;if(!S.trim())return!0;const E=S.toLowerCase(),q=$O($.id)??"";return $.id.toLowerCase().includes(E)||$.label.toLowerCase().includes(E)||q.toLowerCase().includes(E)}),[e,S,T]),L=(0,u.useMemo)(()=>{if(!c)return[{provider:"models",entries:[...R].sort((E,q)=>E.id.localeCompare(q.id))}];const $=new Map;for(const E of R){const q=$O(E.id)??"other",B=$.get(q)??[];B.push(E),$.set(q,B)}return Array.from($.entries()).sort(([E],[q])=>E.localeCompare(q)).map(([E,q])=>({provider:E,entries:[...q].sort((B,K)=>B.id.localeCompare(K.id))}))},[R,c]);async function O(){if(p){_(!0);try{const $=await p();$&&(n($),i(!1),j(""))}finally{_(!1)}}}return r(O,"handleDetectModel"),(0,t.jsx)(ws,{label:"Model",hint:bi.model,children:(0,t.jsxs)(nr,{open:a,onOpenChange:r($=>{i($),$||j("")},"onOpenChange"),children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[(0,t.jsx)("span",{className:z(!s&&"text-muted-foreground"),children:A?A.label:s||(o?w??"Default":l?"Select model (required)":"Select model")}),(0,t.jsx)(en,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsxs)(Wn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:[(0,t.jsxs)("div",{className:"relative mb-1",children:[(0,t.jsx)("input",{className:"w-full px-2 py-1.5 pr-6 text-xs bg-transparent outline-none border-b border-border placeholder:text-muted-foreground/50",placeholder:d?"Search models... (type to create)":"Search models...",value:S,onChange:r($=>j($.target.value),"onChange"),autoFocus:!0}),S&&(0,t.jsx)("button",{type:"button",className:"absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:r(()=>j(""),"onClick"),children:(0,t.jsxs)("svg",{"aria-hidden":"true",focusable:"false",className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,t.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p&&!S.trim()&&(0,t.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-muted-foreground",onClick:r(()=>{O()},"onClick"),disabled:N,children:[(0,t.jsxs)("svg",{"aria-hidden":"true",focusable:"false",className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),(0,t.jsx)("path",{d:"M3 3v5h5"})]}),N?"Detecting...":m?v?.replace(/^Detect\b/,"Re-detect")??"Re-detect from config":v??"Detect from config"]}),f&&!S.trim()&&(0,t.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 text-muted-foreground",onClick:r(()=>{f()},"onClick"),disabled:g,children:[(0,t.jsxs)("svg",{"aria-hidden":"true",focusable:"false",className:"h-3 w-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M3 12a9 9 0 0 1 15.28-6.36L21 8"}),(0,t.jsx)("path",{d:"M21 3v5h-5"}),(0,t.jsx)("path",{d:"M21 12a9 9 0 0 1-15.28 6.36L3 16"}),(0,t.jsx)("path",{d:"M8 16H3v5"})]}),g?"Refreshing...":"Refresh models"]}),s&&(!e.some($=>$.id===s)||T.has(s))&&(0,t.jsxs)("button",{type:"button",className:z("flex items-center w-full px-2 py-1.5 text-sm rounded bg-accent/50"),onClick:r(()=>{i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:s,children:e.find($=>$.id===s)?.label??s}),(0,t.jsx)(ct,{variant:"outline",className:"ml-auto text-(length:--text-nano) px-1.5 bg-green-500/15 text-green-400 border-green-500/20",children:"current"})]}),m&&m!==s&&(0,t.jsxs)("button",{type:"button",className:z("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50"),onClick:r(()=>{n(m),i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:m,children:e.find($=>$.id===m)?.label??m}),(0,t.jsx)(ct,{variant:"outline",className:"ml-auto text-(length:--text-nano) px-1.5 bg-blue-500/15 text-blue-400 border-blue-500/20",children:"detected"})]}),h?.filter($=>$&&$!==m&&$!==s).map($=>{const E=e.find(q=>q.id===$);return(0,t.jsxs)("button",{type:"button",className:z("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50"),onClick:r(()=>{n($),i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:$,children:E?.label??$}),(0,t.jsx)(ct,{variant:"outline",className:"ml-auto text-(length:--text-nano) px-1.5 bg-sky-500/15 text-sky-400 border-sky-500/20",children:"config"})]},`detected-${$}`)}),(0,t.jsxs)("div",{className:"max-h-(--sz-240px) overflow-y-auto",children:[o&&(0,t.jsx)("button",{type:"button",className:z("flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",!s&&"bg-accent"),onClick:r(()=>{n(""),i(!1)},"onClick"),children:"Default"}),I&&(0,t.jsxs)("button",{type:"button",className:"flex items-center justify-between gap-2 w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",onClick:r(()=>{n(C),i(!1),j("")},"onClick"),children:[(0,t.jsx)("span",{children:"Use manual model"}),(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:C})]}),L.map($=>(0,t.jsxs)("div",{className:"mb-1 last:mb-0",children:[c&&(0,t.jsxs)("div",{className:"px-2 py-1 text-(length:--text-nano) uppercase tracking-wide text-muted-foreground",children:[$.provider," (",$.entries.length,")"]}),$.entries.map(E=>(0,t.jsx)("button",{type:"button",className:z("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",E.id===s&&"bg-accent"),onClick:r(()=>{n(E.id),i(!1)},"onClick"),children:(0,t.jsx)("span",{className:"block w-full text-left truncate",title:E.id,children:c?_Be(E.id):E.label})},E.id))]},$.provider)),R.length===0&&!I&&T.size===0&&(0,t.jsx)("div",{className:"px-2 py-2 space-y-2",children:(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:p?y??"No model detected yet. Enter a provider/model manually.":"No models found."})})]})]})]})})}r(lK,"ModelDropdown");function KQe({value:e,options:s,onChange:n,open:a,onOpenChange:i}){const o=s.find(l=>l.id===e)??s[0];return(0,t.jsx)(ws,{label:"Thinking effort",hint:bi.thinkingEffort,children:(0,t.jsxs)(nr,{open:a,onOpenChange:i,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-sm hover:bg-accent/50 transition-colors w-full justify-between",children:[(0,t.jsx)("span",{className:z(!e&&"text-muted-foreground"),children:o?.label??"Auto"}),(0,t.jsx)(en,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsx)(Wn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:s.map(l=>(0,t.jsxs)("button",{className:z("flex items-center justify-between w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50",l.id===e&&"bg-accent"),onClick:r(()=>{n(l.id),i(!1)},"onClick"),children:[(0,t.jsx)("span",{children:l.label}),l.id?(0,t.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:l.id}):null]},l.id||"auto"))})]})})}r(KQe,"ThinkingEffortDropdown");function uxe(e){const s=`paperclip.agent-appearance.${e}`;function n(){try{const l=xle.safeParse(JSON.parse(sessionStorage.getItem(s)??"null"));if(l.success)return l.data}catch{}const o=s2();try{sessionStorage.setItem(s,JSON.stringify(o))}catch{}return o}r(n,"readDraft");const[a,i]=(0,u.useState)(()=>({key:s,appearance:n()}));return a.key!==s&&i({key:s,appearance:n()}),{appearance:a.appearance,clear(){try{sessionStorage.removeItem(s)}catch{}}}}r(uxe,"useAgentAppearanceDraft");var YN=null,uI=new Set,JN={subscribe(e){return uI.add(e),()=>{uI.delete(e)}},getSnapshot(){return YN},acquire(e){if(YN)return!1;YN=e;for(const s of uI)s();return!0},release(e){if(YN===e){YN=null;for(const s of uI)s()}}};function uC({agent:e,appearance:s,size:n=256,state:a="idle",muted:i=!1,motion:o="auto",trackingRegion:l,trackingScope:c="region",followCursor:d=!0,followRotation:m=!0,className:h,label:p,name:f}){const g=(0,u.useMemo)(()=>Aw(s??e?.appearance,e?.id),[s,e?.appearance,e?.id]),v=(0,u.useRef)(null),y=(0,u.useRef)(null),w=(0,u.useRef)(null),S=(0,u.useRef)(Symbol("agent-character")),j=(0,u.useSyncExternalStore)(JN.subscribe,JN.getSnapshot,()=>null),[N,_]=(0,u.useState)(!1),[A,C]=(0,u.useState)(!0),[I,T]=(0,u.useState)(!1),[R,L]=(0,u.useState)(!1),O=N&&!A&&!I&&o==="auto"&&a!=="rest";return(0,u.useEffect)(()=>{if(typeof matchMedia!="function"||typeof IntersectionObserver!="function")return;const $=matchMedia("(prefers-reduced-motion: reduce)"),E=r(()=>C($.matches),"change");E(),$.addEventListener("change",E);const q=new IntersectionObserver(B=>_(B[0]?.isIntersecting??!1));return v.current&&q.observe(v.current),()=>{q.disconnect(),$.removeEventListener("change",E)}},[]),(0,u.useEffect)(()=>{O&&j===null&&JN.acquire(S.current),O||JN.release(S.current)},[O,j]),(0,u.useEffect)(()=>()=>JN.release(S.current),[]),(0,u.useEffect)(()=>{if(!O||j!==S.current)return;let $=!1;return L(!1),Promise.all([vc(()=>import("./runtime-IAg0vdY9.js"),__vite__mapDeps([0,1])),vc(()=>import("./definition-D6jTm4Mv.js"),__vite__mapDeps([2,3,1]))]).then(([E,q])=>{$||!y.current||(w.current=E.createCharacter(y.current,q.characterDefinition(g,i),{animation:q.animationId(a),trackingRegion:l?.current??v.current??void 0,followCursor:d,followRotation:m,trackingScope:c,displaySize:n,onError:r(()=>T(!0),"onError")}),L(!0))}).catch(()=>{$||T(!0)}),()=>{$=!0,w.current?.destroy(),w.current=null,L(!1)}},[O,j,l,c,n,d,m]),(0,u.useEffect)(()=>{w.current&&vc(()=>import("./definition-D6jTm4Mv.js").then($=>{w.current?.setDefinition($.characterDefinition(g,i)),w.current?.setAnimation($.animationId(a))}),__vite__mapDeps([2,3,1]))},[g,i,a,R]),(0,t.jsxs)("span",{ref:v,role:p?"img":void 0,"aria-label":p,"aria-hidden":p?void 0:!0,className:z("relative inline-block shrink-0",C2e[n],h),children:[(0,t.jsx)(pr,{agent:e,appearance:g,size:n<256?256:n,name:f,pose:a,muted:i,className:z("size-full",R&&"invisible")}),(0,t.jsx)("span",{ref:y,className:"absolute inset-0"})]})}r(uC,"AgentCharacter");var VQe=new Set(["claude_local","codex_local","opencode_local","grok_local"]);function mxe(e,{cloud:s,nativeRunnerEnabled:n}){return s?VQe.has(e):e!=="paperclip_runner"||n}r(mxe,"isNewAgentAdapterAllowed");var WQe={claude_local:{src:"/brands/claude-color.svg"},codex_local:{src:"/brands/codex-color.svg"},gemini_local:{src:"/brands/adapters/gemini-color.svg"},kimi_local:{src:"/brands/adapters/kimi-color-light.svg",dark:"/brands/adapters/kimi-color.svg"},...Object.fromEntries([["cursor","cursor"],["cursor_cloud","cursor"],["grok_local","grok"],["hermes_local","hermesagent"],["hermes_gateway","hermesagent"],["pi_local","pi"]].map(([e,s])=>[e,{src:`/brands/adapters/${s}.svg`,dark:`/brands/adapters/${s}-dark.svg`}]))};function cK({type:e,className:s="size-6"}){const n=zm(e).icon,a=WQe[e];return a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("img",{src:a.src,className:z("shrink-0 object-contain",a.dark&&"dark:hidden",s),alt:""}),a.dark&&(0,t.jsx)("img",{src:a.dark,className:z("hidden shrink-0 object-contain dark:block",s),alt:""})]}):(0,t.jsx)(n,{className:s})}r(cK,"AdapterMark");function HQe(){const{selectedCompanyId:e}=xs(),{appearance:s}=uxe(`${e}:new-agent`);return(0,t.jsx)(uC,{appearance:s,state:"sleepy",muted:!0,size:256,className:"size-48",trackingScope:"page"})}r(HQe,"AgentBasicsCharacter");function hxe({open:e,onClose:s,onContinue:n,initialAdapter:a="",onInvite:i}){const o=(0,u.useId)(),l=!!Qc(),c=ee({queryKey:P.instance.experimentalSettings,queryFn:Ir.getExperimental,enabled:e,retry:!1}),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(a),[f,g]=(0,u.useState)("codex"),[v,y]=(0,u.useState)("name"),{data:w,isPending:S,error:j}=ee({queryKey:P.adapters.all,queryFn:Am.list,enabled:e}),N=(w??[]).filter(A=>A.loaded&&!A.disabled&&mxe(A.type,{cloud:l,nativeRunnerEnabled:c.data?.enableNativeRunner===!0})&&!["process","http"].includes(A.type)&&!zm(A.type).comingSoon),_=N.some(A=>A.type===h);return(0,t.jsx)(Js,{open:e,onOpenChange:r(A=>{A||s()},"onOpenChange"),children:(0,t.jsxs)(Zs,{className:z("flex max-h-(--sz-calc-18) flex-col gap-0 overflow-hidden p-0 sm:max-w-(--sz-640px)",v==="name"&&"sm:max-w-(--sz-560px)"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-6 py-5 text-xs text-muted-foreground","aria-label":"New agent progress",children:[(0,t.jsx)("span",{className:z(v==="name"&&"font-medium text-foreground"),children:"1. Name"}),(0,t.jsx)(fn,{className:"size-3"}),(0,t.jsx)("span",{className:z(v==="adapter"&&"font-medium text-foreground"),children:"2. Adapter"})]}),(0,t.jsxs)("form",{className:"flex min-h-0 flex-col",onSubmit:r(A=>{A.preventDefault(),d.trim()&&(v==="name"?y("adapter"):_&&n({name:d.trim(),adapterType:h,runnerProvider:f}))},"onSubmit"),children:[(0,t.jsxs)("div",{className:"flex min-h-0 flex-col gap-7 overflow-y-auto px-6 pb-8 sm:px-10",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center",children:[e&&(0,t.jsx)(HQe,{}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(rn,{className:"text-3xl font-semibold tracking-tight",children:v==="name"?"Meet your next agent":"Choose an adapter"}),(0,t.jsx)(Mn,{className:"text-base",children:v==="name"?"Start with a name. Make them your own.":`How should ${d.trim()} work?`})]})]}),v==="name"?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{htmlFor:o,className:"text-sm font-medium",children:"Agent name"}),(0,t.jsx)(_t,{id:o,autoFocus:!0,maxLength:100,placeholder:"e.g. Darnold",value:d,onChange:r(A=>m(A.target.value),"onChange"),className:"h-12 text-base"}),i&&(0,t.jsx)(F,{type:"button",variant:"link",className:"px-0 text-muted-foreground",onClick:i,children:"Invite an external agent"})]}):(0,t.jsxs)("fieldset",{className:"space-y-4",children:[(0,t.jsx)("legend",{className:"sr-only",children:"Adapter"}),S&&(0,t.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading adapters…"}),j&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:j.message}),(0,t.jsx)("div",{className:z("grid grid-cols-2 gap-3",N.length!==4&&"sm:grid-cols-3"),children:N.map(A=>{const C=zm(A.type);return(0,t.jsxs)("label",{className:"relative cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",name:"new-agent-adapter",value:A.type,checked:h===A.type,onChange:r(()=>p(A.type),"onChange"),className:"peer sr-only"}),(0,t.jsxs)("span",{className:z("flex h-full flex-col items-center gap-2 rounded-lg border px-3 py-4 text-center peer-focus-visible:ring-2 peer-focus-visible:ring-ring hover:bg-accent/40",h===A.type?"border-foreground/40 bg-accent":"border-border bg-card"),children:[(0,t.jsx)(cK,{type:A.type}),(0,t.jsx)("span",{className:"text-sm font-medium",children:C.label}),h===A.type&&(0,t.jsx)(fs,{className:"absolute right-2 top-2 size-3.5"})]})]},A.type)})}),_&&h==="paperclip_runner"&&(0,t.jsxs)("label",{className:"flex flex-col gap-2 text-sm font-medium",children:["Runner",(0,t.jsxs)("select",{className:"rounded-md border border-border bg-background px-3 py-2",value:f,onChange:r(A=>g(A.target.value),"onChange"),children:[(0,t.jsx)("option",{value:"codex",children:"Codex (app server)"}),(0,t.jsx)("option",{value:"claude",children:"Claude (ACPX)"}),(0,t.jsx)("option",{value:"opencode",children:"OpenCode"})]})]})]})]}),(0,t.jsxs)("div",{className:"flex justify-between gap-4 border-t border-border px-6 py-4",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:r(()=>v==="name"?s():y("name"),"onClick"),children:v==="name"?"Cancel":(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ic,{className:"size-4"}),"Back"]})}),(0,t.jsxs)(F,{type:"submit",disabled:!d.trim()||v==="adapter"&&!_,children:[v==="name"?"Choose adapter":"Configure agent",(0,t.jsx)(Zo,{className:"size-4"})]})]})]})]})})}r(hxe,"AgentBasicsDialog");var QQe={subscription:"Subscription",api:"API"};function GQe({mode:e}){return(0,t.jsx)("span",{className:"relative flex h-4 w-full items-center justify-center overflow-hidden text-(length:--text-micro) text-muted-foreground",children:(0,t.jsx)(eN,{initial:!1,mode:"sync",children:(0,t.jsx)(Yo.span,{className:"absolute inset-0 flex items-center justify-center whitespace-nowrap",initial:{opacity:0,y:hY},animate:{opacity:1,y:0,transition:y7e},exit:{opacity:0,y:hY,transition:j7e},children:QQe[e]},e)})})}r(GQe,"CredentialTag");function YQe({source:e,mode:s,selected:n,onSelect:a,buttonRef:i,settling:o}){return(0,t.jsxs)("button",{ref:i,type:"button",role:"radio","aria-checked":n,onClick:a,className:z("flex min-w-0 flex-1 cursor-pointer flex-col items-center gap-1.5 self-stretch rounded-md border p-3","transition-(--tp-border-color-background-color) ease-(--motion-ease-standard)",o?"duration-(--motion-duration-slow)":"duration-(--motion-duration-fast)","outline-none focus-visible:ring-ring/50 focus-visible:ring-(length:--rad-3)",n?"border-foreground/40 bg-accent":"border-border bg-card hover:bg-accent/40"),children:[(0,t.jsx)("span",{className:"flex size-(--sz-30px) shrink-0 items-center justify-center",children:e.icon}),(0,t.jsx)("span",{className:"text-(length:--text-compact) font-medium text-foreground",children:e.label}),(0,t.jsx)(GQe,{mode:s})]})}r(YQe,"ModelSourceTile");function pxe({sources:e,mode:s,selectedId:n,onSelect:a,label:i,collapsed:o=!1,settling:l=!1}){const c=(0,u.useRef)(new Map),d=r(h=>{if(e.length===0)return;const p=e.findIndex(g=>g.id===n),f=e[((p===-1?h>0?-1:0:p)+h+e.length)%e.length];a(f.id),c.current.get(f.id)?.focus()},"moveSelection"),m=o?e.filter(h=>h.id===n):e;return(0,t.jsx)("div",{role:"radiogroup","aria-label":i,className:z("flex items-start gap-3",o&&"justify-center"),onKeyDown:r(h=>{o||(h.key==="ArrowRight"||h.key==="ArrowDown"?(h.preventDefault(),d(1)):(h.key==="ArrowLeft"||h.key==="ArrowUp")&&(h.preventDefault(),d(-1)))},"onKeyDown"),children:(0,t.jsx)(eN,{initial:!1,mode:"popLayout",children:m.map(h=>(0,t.jsx)(Yo.div,{layout:!0,transition:ffe,exit:{opacity:0,transition:T7e},className:z("flex min-w-0",o?"w-(--sz-source-tile-two-up)":"flex-1"),children:(0,t.jsx)(YQe,{source:h,mode:s,selected:h.id===n,onSelect:r(()=>a(h.id),"onSelect"),settling:l,buttonRef:r(p=>{p?c.current.set(h.id,p):c.current.delete(h.id)},"buttonRef")})},h.id))})})}r(pxe,"ModelSourceTiles");var E4={subscription:"Use API key instead",api:"Use subscription instead"},JQe={subscription:"api",api:"subscription"};function fxe({mode:e,onChange:s}){return(0,t.jsxs)("button",{type:"button",onClick:r(()=>s(JQe[e]),"onClick"),className:z("group grid cursor-pointer px-3 py-2 text-left text-sm font-medium","rounded-md outline-none focus-visible:ring-ring/50 focus-visible:ring-(length:--rad-3)"),children:[Object.keys(E4).map(n=>(0,t.jsx)("span",{"aria-hidden":!0,className:"invisible col-start-1 row-start-1 whitespace-nowrap",children:E4[n]},n)),(0,t.jsx)(eN,{initial:!1,mode:"sync",children:(0,t.jsx)(Yo.span,{className:z("col-start-1 row-start-1 justify-self-start whitespace-nowrap","underline decoration-muted-foreground/40 underline-offset-4","text-muted-foreground transition-colors","group-hover:text-foreground group-hover:decoration-foreground/40"),initial:{opacity:0},animate:{opacity:1,transition:JU},exit:{opacity:0,transition:w7e},children:E4[e]},e)})]})}r(fxe,"CredentialModeLink");function xxe({onBack:e,primaryLabel:s,primaryDisabled:n,loading:a,loadingLabel:i,primaryIcon:o,onPrimary:l}){const c=a&&i?i:s,d=o??(a?"spinner":"arrow");return(0,t.jsxs)("div",{className:"flex items-center justify-between pt-9",children:[e?(0,t.jsxs)(F,{variant:"ghost",size:"lg",className:"rounded-full has-[>svg]:pl-4 has-[>svg]:pr-5",onClick:e,disabled:a,children:[(0,t.jsx)(ic,{className:"mr-1 size-3.5"}),"Back"]}):(0,t.jsx)("span",{}),(0,t.jsx)(Yo.div,{layout:!0,transition:S7e,className:"min-w-0",children:(0,t.jsx)(F,{size:"lg",className:"w-full rounded-full px-6",onClick:l,disabled:n||a,children:(0,t.jsxs)(Yo.span,{className:"flex items-center whitespace-nowrap",initial:{opacity:0},animate:{opacity:1},transition:C7e,children:[d==="spinner"?(0,t.jsx)(it,{className:"mr-1 size-4 animate-spin"}):null,c,d==="arrow"?(0,t.jsx)(Zo,{className:"ml-1 size-3.5"}):null]},`${c}:${d}`)})})]})}r(xxe,"FooterNav");function gxe({companyId:e,adapterType:s,environmentId:n,canLogin:a,localEnvironment:i=!1,onConnected:o,onBack:l,testConnection:c,testError:d,managedAccount:m}){const h=ee({queryKey:P.health,queryFn:tm.get,enabled:i}),p=i&&(h.data?.localAiLoginSupported??h.data?.deploymentMode==="local_trusted"),f=(0,u.useRef)(0);(0,u.useEffect)(()=>()=>{f.current++},[]);const g=r(()=>{f.current++,L(!1),S(!1),N(null),A("preparing")},"cancel"),[v,y]=(0,u.useState)(m?.initialMethod==="api_key"?"api":m?"subscription":null),[w,S]=(0,u.useState)(!1),[j,N]=(0,u.useState)(null),[_,A]=(0,u.useState)("preparing"),C=(0,u.useRef)("ready"),[I,T]=(0,u.useState)(""),[R,L]=(0,u.useState)(!1),[O,$]=(0,u.useState)(null),[E,q]=(0,u.useState)(null),B=s==="claude_local"?"Claude":s==="grok_local"?"Grok":"OpenAI",K=s==="claude_local"?"ANTHROPIC_API_KEY":s==="grok_local"?"XAI_API_KEY":"OPENAI_API_KEY",U=s==="claude_local"?"anthropic":s==="grok_local"?"xai":"openai",D=efe(e,K),V=m?{...D,options:[],subscriptions:[],loading:!1}:D,[H,J]=(0,u.useState)(null),X=V.subscriptions.length?V.subscriptions.find(ae=>ae.id===(H??V.subscriptions[0]?.id)):void 0,[le,ce]=(0,u.useState)(null),te=V.options.find(ae=>ae.id===(le??V.options[0]?.id)),re=m?{...V.storedLogin,data:void 0,isPending:!1,isError:!1}:V.storedLogin,de=(0,u.useRef)(null),Z=v??(V.subscriptions.length>0||s==="claude_local"&&!X&&re.data?"subscription":V.options.length?"api":"subscription"),Y=bhe(e,m?.intent??{provider:U,method:"subscription",name:`My ${B} subscription`,ownership:"personal",agentIds:[],allAgents:!0},p&&Z==="subscription"&&!X&&!re.data,{allowHostClaude:h.data?.deploymentMode==="local_trusted"}),G=ee({queryKey:P.agents.authSignal(e,s,n),queryFn:r(()=>zt.getAdapterAuthSignal(e,s,n??void 0),"queryFn"),retry:!1,enabled:!m});async function fe(){if(R||m?.disabled)return;const ae=++f.current;L(!0),$(null);try{if(m){if(Z==="subscription"&&!p)return;const pe=de.current??await(Z==="api"?mu.create(e,{...m.intent,method:"api_key",apiKey:I.trim()}):Y.connect(m.intent));de.current=pe,T(""),ae===f.current&&m.onComplete({...pe,method:Z==="api"?"api_key":"subscription"});return}let ie=Z==="api"?te?te.aiConnection?{env:{},aiConnection:te.aiConnection}:{env:{[K]:te.binding}}:E??{env:{},credentials:{[K]:I.trim()}}:{...X?.aiConnection?{aiConnection:X.aiConnection}:{},env:X?.binding?{CODEX_HOME:X.binding}:{},...s==="claude_local"&&!X&&re.data?{env:aj(),applyStoredClaudeLogin:!0}:{}};if(Z==="subscription"&&p&&!X&&!re.data&&(de.current??=await Y.connect(),ie={env:{},aiConnection:{provider:U,method:"subscription",mode:"responsible_user"}}),ie.credentials&&(await mu.create(e,{provider:U,method:"api_key",name:`My ${B} API`,ownership:"personal",apiKey:ie.credentials[K],agentIds:[],allAgents:!0}),ie={env:{},aiConnection:{provider:U,method:"api_key",mode:"responsible_user"}}),ae!==f.current)return;Z==="api"&&(T(""),te||q(ie));const ue=await c(ie);if(ae!==f.current)return;ue?o(ie):$("The provider did not respond. Check the connection and try again.")}catch(ie){if(ae!==f.current)return;m&&T(""),$(ie instanceof Error?ie.message:"Could not connect to the provider.")}finally{ae===f.current&&L(!1)}}r(fe,"connect");const se=Z==="subscription"&&a&&n&&!X&&!V.loading&&!re.data&&(!!m||G.data?.status!=="present"||H==="");return(0,t.jsxs)("div",{className:"min-w-0 max-w-full",children:[(0,t.jsx)(pxe,{label:"Connect your model provider",sources:[{id:s,label:B,icon:(0,t.jsx)(cK,{type:s})}],mode:Z,selectedId:w?s:null,collapsed:w,onSelect:r(()=>{m?.disabled||S(!0)},"onSelect")}),!w&&!m?.fixedMethod&&(0,t.jsx)("div",{className:"-ml-3 mt-1",children:(0,t.jsx)(fxe,{mode:Z,onChange:r(ae=>{de.current=null,y(ae),$(null)},"onChange")})}),!w&&V.options.length>0&&(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:[V.options.length," saved API"," ",V.options.length===1?"key available":"keys available","."]}),Z==="subscription"&&V.subscriptions.length>0&&(0,t.jsx)(Cj,{options:V.subscriptions,value:X?.id??"",onChange:J,loading:!1,error:!1,kind:"subscription",disabled:R}),(0,t.jsx)(Yo.div,{initial:!1,animate:{height:w?"auto":0,opacity:w?1:0},transition:{height:ld,opacity:H5},className:"overflow-hidden",children:w&&(0,t.jsx)("div",{className:"pt-5",children:Z==="api"?(0,t.jsxs)(Q5,{instruction:V.options.length?"Choose a saved API key or enter a new one":`Provide your ${B} API key to connect`,children:[(0,t.jsx)(Cj,{...V,value:te?.id??"",disabled:R,onChange:r(ae=>{ce(ae),T(""),q(null),$(null)},"onChange")}),!te&&(0,t.jsx)(G5,{label:"API key",masked:!0,autoFocus:!0,value:I,placeholder:E?"Key entered. Retry the connection.":"Enter API key here",onChange:r(ae=>{ce(""),T(ae),q(null)},"onChange"),onSubmit:r(()=>{fe()},"onSubmit"),disabled:R})]}):se?(0,t.jsx)(oK,{companyId:e,adapterType:s,environmentId:n,chrome:"onboarding",aiConnection:m?.intent??{provider:U,method:"subscription",name:`My ${B} subscription`,ownership:"personal",agentIds:[],allAgents:!0},autoStart:!0,onStored:r(()=>{},"onStored"),onPromptReady:r(ae=>{N(ae),A(ie=>ae?ie==="preparing"?"ready":ie:"preparing")},"onPromptReady"),onCodeSubmitted:r(()=>{C.current=_==="waiting"?"waiting":"ready",A("connecting")},"onCodeSubmitted"),onSubmitFailed:r(()=>{A(ae=>ae==="connecting"?C.current:ae)},"onSubmitFailed"),onConnected:r(ae=>{if(m){if(!ae){$("The login did not return a saved connection. Try again.");return}const ue=f.current;A("connecting"),mu.loginResult(e,ae).then(pe=>{ue===f.current&&m.onComplete({...pe,method:"subscription"})}).catch(()=>{ue===f.current&&(A("ready"),$("Could not retrieve the saved connection. Go back and retry."))});return}const ie={env:{},aiConnection:{provider:U,method:"subscription",mode:"responsible_user"}};q(ie),o(ie)},"onConnected")}):X?null:p&&!re.data?(0,t.jsx)(XU,{adapterType:s,login:{...Y,retry:r(()=>{$(null),Y.retry()},"retry")}}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:re.data?"Use your saved Claude subscription for this agent.":a?"Use the existing provider connection for this environment.":"This environment does not support browser sign-in. Choose a sign-in environment or connect with an API key."})})}),Z==="subscription"&&re.isError&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:"Could not check your saved Claude subscription. Try again."}),O&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:d??O}),i&&h.isError&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:"Could not prepare sign-in. Reload this page to try again."}),(0,t.jsx)(xxe,{onBack:r(()=>{w?g():l()},"onBack"),primaryLabel:w&&se?_==="waiting"?"Waiting for code":_==="connecting"?"Connecting":`Sign in to ${B}`:R?"Connecting":Z==="subscription"&&(re.data||X)?"Use saved subscription":Z==="api"&&te?"Use saved API key":"Connect",primaryDisabled:m?.disabled||!!m&&Z==="subscription"&&!a&&!p||i&&h.isPending||Y.preparing||!!Y.error||!m&&G.isPending||V.loading||s==="claude_local"&&re.isPending||!w||!!se&&(!j||_!=="ready")||Z==="api"&&!I.trim()&&!E&&!te,loading:R,primaryIcon:w&&se?_==="ready"?"none":"spinner":void 0,onPrimary:r(()=>{if(se){if(!j||_!=="ready")return;window.open(j,"_blank","noreferrer,noopener"),A("waiting")}else fe()},"onPrimary")})]})}r(gxe,"AgentProviderConnection");function TT(e){return e.provider==="openrouter"?(0,t.jsx)(ZQe,{...e}):(0,t.jsx)(XQe,{...e})}r(TT,"AiConnectionCredentialStep");function XQe({companyId:e,provider:s,initialMethod:n,fixedMethod:a,connectionId:i,name:o,ownership:l,agentIds:c,allAgents:d,environmentId:m,onComplete:h,onCancel:p}){const[f,g]=(0,u.useState)(o),[v,y]=(0,u.useState)(),w=Kt(),S=ee({queryKey:P.environments.list(e),queryFn:r(()=>Ci.list(e),"queryFn")}),j=ee({queryKey:P.environments.capabilities(e),queryFn:r(()=>Ci.capabilities(e),"queryFn")}),N=ee({queryKey:P.instance.settings,queryFn:Ir.get}),_=ee({queryKey:P.instance.experimentalSettings,queryFn:Ir.getExperimental}),A=ee({queryKey:P.instance.generalSettings,queryFn:Ir.getGeneral}),C=iK(A.data?.executionMode,S.data??[]);let I=null,T;try{I=C.forced?C.kubernetesEnvironment?.id??null:cw({agentDefaultEnvironmentId:m??v,instanceDefaultEnvironmentId:N.data?.defaultEnvironmentId,localDefaultEnvironmentId:uw(S.data),managedSandboxOnly:_.data?.enableManagedSandboxOnly,managedSandboxEnvironmentId:dw(S.data),visibleEnvironmentIds:S.data?.map(K=>K.id)})}catch(K){T=K instanceof Error?K.message:"Could not resolve the sign-in environment."}const R=(S.data??[]).filter(K=>K.status==="active"&&(K.driver==="local"||K.driver==="sandbox"&&typeof K.config.provider=="string"&&j.data?.sandboxProviders?.[K.config.provider]?.supportsLoginPty===!0));!C.forced&&!m&&!v&&!R.some(K=>K.id===I)&&(I=R[0]?.id??null);const L=S.data?.find(K=>K.id===I),O=typeof L?.config.provider=="string"?L.config.provider:"",$=L?.driver==="sandbox"&&j.data?.sandboxProviders?.[O]?.supportsLoginPty===!0,E=[S,j,N,_,A].some(K=>K.isPending),q=T??[S,j,N,_,A].find(K=>K.error)?.error?.message,B={provider:s,method:"subscription",name:f,ownership:l,agentIds:c,allAgents:d,connectionId:i};return(0,t.jsxs)("div",{className:"mx-auto w-full min-w-0 max-w-xl space-y-6",children:[(0,t.jsxs)("label",{className:"block space-y-2 text-sm",children:["Connection name",(0,t.jsx)(_t,{value:f,onChange:r(K=>g(K.target.value),"onChange"),disabled:!!i})]}),!m&&!C.forced&&R.length>1&&(0,t.jsxs)(La,{value:I??"",onValueChange:y,children:[(0,t.jsx)(Da,{"aria-label":"Sign-in environment",children:(0,t.jsx)(Pa,{placeholder:"Sign-in environment"})}),(0,t.jsx)(Ma,{children:R.map(K=>(0,t.jsx)(Nn,{value:K.id,children:K.name},K.id))})]}),q&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:q}),E?(0,t.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"Preparing sign-in…"}):(0,t.jsx)(gxe,{companyId:e,adapterType:s==="anthropic"?"claude_local":s==="xai"?"grok_local":"codex_local",environmentId:I,canLogin:$,localEnvironment:L?.driver==="local",onBack:p,onConnected:r(()=>{},"onConnected"),testConnection:r(async()=>!1,"testConnection"),managedAccount:{intent:B,initialMethod:n,fixedMethod:a||!!i,disabled:E||!!q||!f.trim(),onComplete:r(K=>{w.invalidateQueries({queryKey:["ai-connections",e]}),h(K)},"onComplete")}},I??"local")]})}r(XQe,"SubscriptionConnectionStep");function ZQe({companyId:e,provider:s,connectionId:n,name:a,ownership:i,agentIds:o,allAgents:l,onComplete:c,onCancel:d}){const[m,h]=(0,u.useState)(a),[p,f]=(0,u.useState)(""),g=Kt(),v=ke({mutationFn:r(()=>mu.create(e,{provider:s,method:"api_key",name:m,ownership:i,agentIds:o,allAgents:l,connectionId:n,apiKey:p}),"mutationFn"),onSuccess:r(y=>{g.invalidateQueries({queryKey:["ai-connections",e]}),c({...y,method:"api_key"})},"onSuccess"),onSettled:r(()=>f(""),"onSettled")});return(0,t.jsxs)("div",{className:"mx-auto w-full min-w-0 max-w-xl space-y-4",children:[(0,t.jsxs)("label",{className:"block space-y-2 text-sm",children:["Connection name",(0,t.jsx)(_t,{value:m,onChange:r(y=>h(y.target.value),"onChange"),disabled:!!n})]}),v.error&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:v.error.message}),(0,t.jsx)(vfe,{providerName:"OpenRouter",value:p,onChange:f,onSubmit:r(()=>v.mutate(),"onSubmit"),disabled:v.isPending,placeholder:"Enter API key here",autoFocus:!0}),(0,t.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,t.jsx)(F,{variant:"ghost",onClick:d,children:"Cancel"}),(0,t.jsx)(F,{disabled:!m.trim()||!p.trim()||v.isPending,onClick:r(()=>v.mutate(),"onClick"),children:v.isPending?"Connecting…":"Connect"})]})]})}r(ZQe,"ApiKeyConnectionStep");var eGe=new RegExp(`\\b(${["mcp","server","profile","policy","gateway","transport","stdio","endpoint"].join("|")})s?\\b`,"gi");function bxe(e){return e.replace(eGe,"").replace(/\s{2,}/g," ").replace(/\s+([.,])/g,"$1").trim()}r(bxe,"sanitizeProsumerCopy");var tGe={zapier:{tagline:"Reach 9,000+ apps your team already uses.",short:"Reach 9,000+ apps from your agents."},github:{tagline:"Read code and pull requests, comment on issues.",short:"Read code and pull requests, comment on issues."},slack:{tagline:"Send and read messages in your team's channels.",short:"Send and read messages in your channels."},notion:{tagline:"Read and update pages in your workspace.",short:"Read and update pages in your workspace."},railway:{tagline:"Inspect services, read logs, and manage deployments.",short:"Connect Railway for deployments, logs, and container access."},posthog:{tagline:"Explore product usage, errors, flags, and experiments.",short:"Sign in with PostHog. Project pinning and access controls are optional."},linear:{tagline:"Create, update and read tickets.",short:"Create, update and read tickets."},"google-sheets":{tagline:"Read and update selected spreadsheets.",short:"Read spreadsheets or update the files you choose."},gmail:{tagline:"Read mail and create drafts for your review.",short:"Read mail and create drafts for your review."},"google-drive":{tagline:"Find, read, and create files in Drive.",short:"Find, read, and create files in Drive."},"google-docs":{tagline:"Read and update documents.",short:"Read and update documents."},"google-slides":{tagline:"Read and update presentations.",short:"Read and update presentations."},"google-calendar":{tagline:"Review calendars and manage events.",short:"Review calendars and manage events."},"google-chat":{tagline:"Read conversations and send messages.",short:"Read conversations and send messages."},"google-people":{tagline:"Look up contacts and people in your directory.",short:"Look up contacts and people in your directory."},"google-workspace-search":{tagline:"Search across your Google workspace.",short:"Search across your Google workspace."},hubspot:{tagline:"Look up contacts and update deal stages.",short:"Look up contacts and update deal stages."},intercom:{tagline:"Read and reply to customer conversations.",short:"Read and reply to customer conversations."},figma:{tagline:"Read files and post comments on frames.",short:"Read files and post comments on frames."},stripe:{tagline:"Read customers, invoices, and payouts.",short:"Read customers, invoices, and payouts."},context7:{tagline:"Look up up-to-date docs for your libraries.",short:"Look up up-to-date docs for your libraries."}},sGe={tagline:"Give your agents access to this app.",short:"Give your agents access to this app."};function vxe(e,s){const n=tGe[e];if(n)return n;if(s){const a=bxe(s);if(a)return{tagline:a,short:a}}return sGe}r(vxe,"appCopyFor");function XY(e,s,n){return n<=1?`Your ${e} key`:bxe(s)||`Your ${e} key`}r(XY,"credentialFieldLabel");var nGe=1500;function uf(e=nGe){const[s,n]=(0,u.useState)("idle"),a=(0,u.useRef)(null),i=(0,u.useRef)(0);(0,u.useEffect)(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const o=(0,u.useCallback)(async l=>{const c=++i.current;let d="copied";try{await Hr(l)}catch{d="failed"}return i.current!==c||(n(d),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{i.current===c&&(n("idle"),a.current=null)},e)),d},[e]);return{status:s,copied:s==="copied",failed:s==="failed",copy:o}}r(uf,"useCopyAction");function dK(){const e=Sc()?.pushToast;return(0,u.useCallback)(async(s,n="Copied")=>{try{return await Hr(s),e?.({title:n,tone:"success",dedupeKey:`copy:${n}`}),!0}catch{return e?.({title:"Couldn’t copy to clipboard",body:"Select and copy the value manually.",tone:"error",dedupeKey:"copy-failed"}),!1}},[e])}r(dK,"useCopyToast");var rGe="/cloud/connections/handoff",aGe="/cloud/connections/reauth",ET="paperclip.cloud-oauth-handoff.v1",fx=class extends Error{static{r(this,"OAuthHandoffError")}code;constructor(e,s){super(e),this.code=s,this.name="OAuthHandoffError"}};function uK(e){if(e===void 0)return null;if(!e||typeof e!="object"||Array.isArray(e))throw new fx("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");const s=e;if(s.kind!=="paperclip_cloud"||typeof s.session!="string"||s.session.length<16||s.session.length>512||!/^[A-Za-z0-9_-]+$/.test(s.session))throw new fx("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");return{kind:"paperclip_cloud",session:s.session}}r(uK,"parseHandoff");function iGe(e,s){return e===404||s==="SESSION_NOT_AVAILABLE"?new fx("This sign-in expired. Start the connection again.","expired"):e===401||e===403?new fx("Paperclip Cloud could not authorize this connection for your account.","forbidden"):new fx("Paperclip Cloud couldn’t prepare secure sign-in. Try again.","unavailable")}r(iGe,"handoffFailure");async function oGe(e,s){const n=s.request??fetch;let a,i;for(let o=0;o<2;o+=1)try{if(a=await n(rGe,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},credentials:"include",body:JSON.stringify({session:e}),signal:s.signal}),a.status<500||o===1)return a}catch(l){if(s.signal?.aborted||l instanceof DOMException&&l.name==="AbortError")throw l;if(i=l,o===1)break}if(a)return a;throw new fx(i instanceof Error?i.message:"Paperclip Cloud couldn’t prepare secure sign-in. Try again.","unavailable")}r(oGe,"postCloudHandoff");function lGe(e,s){if(typeof e!="string"||typeof window>"u")return null;try{const n=new URL(e,window.location.origin);return n.origin!==window.location.origin||n.pathname!==aGe||n.username||n.password||n.hash||n.searchParams.size!==1||n.searchParams.get("session")!==s?null:{kind:"reauthentication",url:n.toString(),host:n.host}}catch{return null}}r(lGe,"exactReauthenticationTarget");async function pw(e,s={}){const n=uK(e.handoff);if(!n){const l=cT(e.authorizationUrl);if(!l.ok)throw new fx(l.message,"invalid_handoff");return{kind:"authorization",url:l.url,host:l.host}}const a=await oGe(n.session,s),i=await a.json().catch(()=>null);if(!a.ok){if(i?.error==="RECENT_LOGIN_REQUIRED"){const l=lGe(i.reauthenticationUrl,n.session);if(l)return l}throw iGe(a.status,i?.error)}const o=cT(typeof i?.authorizationUrl=="string"?i.authorizationUrl:void 0);if(!o.ok)throw new fx("Paperclip Cloud returned an invalid provider sign-in address.","invalid_handoff");return{kind:"authorization",url:o.url,host:o.host}}r(pw,"prepareOAuthNavigation");function mC(e,s=window.sessionStorage){const n=uK({kind:"paperclip_cloud",session:e});if(!n)throw new fx("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");const a={version:1,session:n.session,savedAt:Date.now()};s.setItem(ET,JSON.stringify(a))}r(mC,"savePendingCloudHandoff");function cGe(e=window.sessionStorage){const s=e.getItem(ET);if(!s)return null;try{const n=JSON.parse(s);if(n.version!==1||typeof n.savedAt!="number"||Date.now()-n.savedAt>9e5)throw new Error("expired");return uK({kind:"paperclip_cloud",session:n.session})}catch{return e.removeItem(ET),null}}r(cGe,"readPendingCloudHandoff");function ZY(e=window.sessionStorage){e.removeItem(ET)}r(ZY,"clearPendingCloudHandoff");function eE({host:e,className:s}){return(0,t.jsxs)("div",{className:z("flex flex-wrap items-center gap-2 text-xs",s),children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 font-medium text-amber-700 dark:text-amber-400",children:[(0,t.jsx)(kl,{className:"h-3 w-3"}),"Unverified server"]}),e?(0,t.jsx)("span",{className:"font-mono text-muted-foreground",children:e}):null]})}r(eE,"UnverifiedServerBadge");function tE(e){return!!(e&&ale({...e,methods:e.methods.filter(s=>(s.purpose??"tool")!=="channel"&&s.transport!=="chat_sdk")}))}r(tE,"appSupportsToolCatalogSetup");var dGe=sIe.filter(e=>Xoe(e).some(s=>Fp(s))).map(e=>e.slug);function uGe(e){return dGe.some(s=>s===e)}r(uGe,"isMcpDirectOAuthConnectSlug");function MF(e,s){const n=new URLSearchParams({source:e});return s&&n.set("intent",s),`/apps/connect?${n.toString()}`}r(MF,"appSourceConnectHref");function mGe(e,s){return`/apps/connect?${new URLSearchParams({source:e,resume:s}).toString()}`}r(mGe,"appSourceResumeHref");function P4(e){return e?`/apps/vercel-connect?${new URLSearchParams({source:e}).toString()}`:"/apps/vercel-connect"}r(P4,"vercelConnectSourceHref");function hGe(e){return e.serviceSlug??e.appKey??e.sourceSlug??void 0}r(hGe,"resolveAppsConnectRouteKey");function pGe(e,{chatConnectorsEnabled:s=!1}={}){if(e.get("byo")==="1")return!!(e.get("reconnect")?.trim()&&e.get("applicationId")?.trim()&&e.get("link")?.trim());const n=e.get("source")??"",a=GC(n);return!s&&a?.methods.some(i=>i.transport==="chat_sdk")&&!a.methods.some(i=>(i.purpose??"tool")!=="channel"&&i.transport!=="chat_sdk")?!1:J6(n)&&e.get("reconnect")?.trim()?!0:s?ale(a):tE(a)}r(pGe,"canEnterAppsConnect");var M4=" for the organization",fGe=" for the company";function eJ(e,s){const n=e.trim();if(s!=="organization")return n;const a=n.toLocaleLowerCase();return a.endsWith(M4)?n:a.endsWith(fGe)?`${n.slice(0,n.length-16).trimEnd()}${M4}`:`${n}${M4}`}r(eJ,"connectionNameForGrantKind");function xGe(e){switch(e){case"active":return"Connected";case"needs_reauthorization":return"Needs attention";case"expired":return"Expired";case"revoked":return"Revoked";default:return"Not connected"}}r(xGe,"grantStatusLabel");function gGe(e){switch(e){case"active":return"connected";case"needs_reauthorization":case"expired":return"attention";case"revoked":return"inactive";default:return"missing"}}r(gGe,"grantStatusTone");function bGe(e,s={}){const n=e?.providerTenant?.name?.trim();return n||(e?.kind==="user"?s.subjectLabel?.trim()||"Connected account":e?.kind==="agent"?s.subjectLabel?.trim()||"Dedicated account":"Shared credential")}r(bGe,"grantAccountLabel");function vGe(e){return new Set((e?.members??[]).filter(s=>s.subjectType==="user").map(s=>s.subjectId))}r(vGe,"audienceUserIds");function yGe(e){return e.find(s=>s.kind==="organization"&&s.isDefault)??e.find(s=>s.kind==="organization")??null}r(yGe,"organizationGrant");function jGe(e,s){return s?e.find(n=>n.kind==="user"&&n.subjectUserId===s)??null:null}r(jGe,"personalGrantFor");function wGe(e,s){if(!s)return null;const n=e.find(a=>a.userId===s);return n&&(n.name?.trim()||n.email?.trim())||null}r(wGe,"memberLabel");var tJ=0;function DF(){return tJ+=1,{id:`header-${tJ}`,name:"",value:""}}r(DF,"newCustomHeaderRow");function vS(e){try{return new URL(e).host||null}catch{return null}}r(vS,"endpointHost");function NGe(e=window.location.origin){const s=new URL("/api/tools/oauth/callback",e),n=s.hostname.toLowerCase().replace(/^\[|\]$/g,"");return s.protocol==="http:"&&(n==="127.0.0.1"||n==="::1")&&(s.hostname="localhost"),s.toString()}r(NGe,"oauthCallbackUrlForBrowser");function D4(e){try{const s=new URL(e);return`${s.host.replace(/^www\./,"")}${s.pathname==="/"?"":s.pathname.replace(/\/+$/,"")}`.slice(0,160)||null}catch{return null}}r(D4,"defaultGenericMcpName");function sJ(e,s){const n=s?.trim()||"Paperclip couldn't connect to that address. Check it and try again.";switch(e){case"mcp_remote_url_missing":case"mcp_remote_url_invalid":return{title:"That doesn't look like a server address",body:"Paste the full address, starting with https:// — for example https://mcp.example.com/mcp.",focus:"url"};case"remote_http_private_endpoint":return{title:"That address is inside a private network",body:"This Paperclip is reachable from the internet, so it won't call addresses on your local network. Use the server's public address instead.",focus:"url"};case"remote_http_dns_failed":return{title:"We couldn't find that host",body:"The address didn't resolve. Check the spelling, or confirm the server is published on the internet.",focus:"url"};case"mcp_header_rejected":return{title:"Paperclip can't send that header",body:n,focus:"credentials"};case"tool_access_name_conflict":return{title:"Paperclip couldn’t name this connection",body:"Try connecting again.",focus:"none"};case"oauth_challenge":return{title:"This server wants a credential",body:"It asked us to authenticate but didn't offer a sign-in Paperclip can complete on its own. Add the key or headers its docs list under Advanced authentication.",focus:"credentials"};case"oauth_manual_client_required":case"oauth_manual_client_rebinding_required":return{title:"This server needs sign-in details you create yourself",body:"Register Paperclip in the provider's settings, then add the client ID and secret it gives you under Advanced authentication.",focus:"credentials"};case"oauth_redirect_origin_unsupported":case"oauth_redirect_uri_invalid":return{title:"This Paperclip needs a public HTTPS address first",body:"Sign-in sends the operator back to Paperclip, so this instance has to be reachable over HTTPS. Ask your Paperclip admin to configure it.",focus:"deployment"};case"runtime_error":return{title:"We couldn't reach that server",body:"Nothing answered at that address. Confirm the server is running and the address is right, then try again.",focus:"url"};default:return{title:"Paperclip couldn't connect",body:n,focus:"none"}}}r(sJ,"genericConnectGuidance");function yxe(e){const s=new Set;for(const n of e){const a=n.name.trim();if(!a&&!n.value.trim())continue;const i=$_e(a);if(!i.ok)return $W(a,i.reason);const o=G_e(n.value);if(!o.ok)return $W(a,o.reason);if(!n.value.trim())return`Add a value for "${a}", or remove the row.`;const l=a.toLowerCase();if(s.has(l))return`"${a}" is listed twice.`;s.add(l)}return null}r(yxe,"customHeaderError");function kGe(e){const s={},n=e.keyValue.trim();if((e.authMode==="bearer"||e.authMode==="auto"&&e.needsKey)&&n&&(s["credentials.authorization"]=n),e.authMode==="custom_headers")for(const l of e.headers){const c=l.name.trim();!c||!l.value.trim()||(s[`headers.${c}`]=l.value)}const a=e.name.trim(),i=e.oauthClientId.trim(),o=e.oauthClientSecret.trim();return{link:e.link,...a?{name:a}:{},...e.authMode==="auto"?{}:{authMode:e.authMode},...Object.keys(s).length>0?{credentialValues:s}:{},...e.authMode==="oauth"&&i?{oauthClient:{clientId:i,...o?{clientSecret:o}:{}}}:{}}}r(kGe,"genericConnectPayload");function SGe(e){return e.link.trim()?e.authMode==="auto"?!e.needsKey||e.keyValue.trim().length>0:e.authMode==="bearer"?e.keyValue.trim().length>0:e.authMode==="custom_headers"?e.headers.filter(s=>s.name.trim()&&s.value.trim()).length>0&&yxe(e.headers)===null:!0:!1}r(SGe,"canSubmitGenericConnect");function fw(e){const s=new Set;let n=!1;for(const a of e??[])a.targetType==="company"?n=!0:a.targetType==="agent"&&s.add(a.targetId);return{onAll:n,agentIds:s}}r(fw,"installStateFrom");function jxe(e,s){return e.onAll||e.agentIds.has(s)}r(jxe,"isAgentInstalled");function wxe(e,s){return s.onAll?[{targetType:"company",targetId:e}]:[...s.agentIds].map(n=>({targetType:"agent",targetId:n}))}r(wxe,"installPayload");var CGe="Has access — tick to load its tools into this agent's context.";function Nxe(e){return`paperclip.connector-enrollment-access:${e}`}r(Nxe,"enrollmentAccessStorageKey");function _Ge(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const s=e;if(typeof s.companyId!="string"||!s.companyId.trim()||!(s.grantKind==="user"||s.grantKind==="agent"||s.grantKind==="organization")||s.installChoice!=="specific"&&s.installChoice!=="all"||!Array.isArray(s.agentIds)||s.agentIds.some(a=>typeof a!="string"||!a.trim()))return!1;const n=new Set(s.agentIds);return n.size!==s.agentIds.length?!1:s.grantKind==="agent"?s.installChoice==="specific"&&n.size===1:s.installChoice==="all"?n.size===0:n.size>0}r(_Ge,"validEnrollmentAccessState");function IGe(e,s,n){try{window.sessionStorage.setItem(Nxe(s),JSON.stringify({...n,companyId:e}))}catch{}}r(IGe,"saveEnrollmentAccessState");function AGe(e){const s=Nxe(e);try{const n=window.sessionStorage.getItem(s);if(window.sessionStorage.removeItem(s),!n)return null;const a=JSON.parse(n);return _Ge(a)?a:null}catch{return null}}r(AGe,"consumeEnrollmentAccessState");function nJ(e){if(!e)return null;try{const s=new URL(e);return s.protocol==="https:"&&s.hostname.toLowerCase()==="github.com"?s.toString():null}catch{return null}}r(nJ,"githubRecoveryUrl");function rJ(e,s){return e==="denied"?"Authorization was cancelled or declined. Your saved connection was not changed.":s==="github_installation_required"?"GitHub access is required. Install Paperclip and grant at least one repository, then try again.":"Authorization did not complete. Your saved connection is still here, so you can try again."}r(rJ,"oauthCallbackErrorMessage");var RGe={access:"access",key:"setup",success:"complete"};function aJ(e){return e.requestedAppKey?e.resumeConnectionId||e.routeStage==="setup"?"key":"access":e.hasPrefilledLink||e.zapierSource?"access":"gallery"}r(aJ,"requestedConnectionInitialStep");function TGe(e){const s=e.galleryApps.find(a=>a.slug===e.requestedAppKey);if(s)return s;if(!e.reconnectConnection)return null;const n=e.applications.find(a=>a.id===e.reconnectConnection?.applicationId);return Sx(n)!==e.requestedAppKey?null:J6(e.requestedAppKey)}r(TGe,"requestedConnectionEntry");function EGe(e){return!e.reconnectConnection||!e.reconnectApplication||e.reconnectConnection.applicationId!==e.reconnectApplication.id?!1:e.requestedAppKey?Sx(e.reconnectApplication)===e.requestedAppKey:e.byo&&e.applicationId===e.reconnectApplication.id}r(EGe,"retainedReconnectMatches");function PGe(e){return e.credentialSource==="vercel_connect"&&!e.available&&!e.retainedReconnectMatches}r(PGe,"isVercelConnectUnavailable");function MGe(e){return e.available===!1&&!(e.reconnectConnectionId&&e.reconnectSourceMatches)}r(MGe,"isConnectionDefinitionUnavailable");function DGe(e){return!e.hasRequestedEntry||e.supportedMethodCount===0||e.unsupportedOAuth||e.vercelUnavailable||e.definitionUnavailable?e.reconnectConnectionId?"reconnect_unavailable":"fallback":"ready"}r(DGe,"requestedConnectionSetupResolution");function iJ(e,s,n,a){const i=RGe[s]??"setup",o=new URLSearchParams({source:e,stage:i});return a?.resumeConnectionId&&o.set("resume",a.resumeConnectionId),a?.reconnectConnectionId&&o.set("reconnect",a.reconnectConnectionId),a?.interactionId&&o.set("intent",a.interactionId),a?.connectionMethodKey&&o.set("method",a.connectionMethodKey),`${n==="vercel_connect"?"/apps/vercel-connect":"/apps/connect"}?${o.toString()}`}r(iJ,"appConnectHref");function mI(e,s){if(!s)return e;const[n,a=""]=e.split("?",2),i=new URLSearchParams(a);return i.set("intent",s),`${n}?${i.toString()}`}r(mI,"withConnectionIntent");var oJ=["Pick app","Access","Add your key"],lJ={gallery:0,access:1,key:2},LGe={access:0,key:1},$Ge=["Access","Add MCP URL"],OGe=["Access","Sign in"];function L4(e,s=!1){return s&&e?.auth!=="none"&&(!e?.grantKinds||e.grantKinds.includes("user"))?"user":e?.grantKinds?.length===1||e?.grantKinds&&!e.grantKinds.includes("organization")?e.grantKinds[0]:"organization"}r(L4,"defaultGrantKindFor");function FGe(e){const s=e.config?.oauth;if(!s||typeof s!="object"||Array.isArray(s))return;const n=s.connectorSubjectAgentId;return typeof n=="string"?n:void 0}r(FGe,"configuredAgentIdentity");function Mk(e,s){const n=typeof s=="string"?s:s?.key;return e?.slug==="google-sheets"&&n==="local"}r(Mk,"isGoogleSheetsRobotMethod");function XN(e){return e?Object.fromEntries([...e.tenantFields??[],...e.extensionFields??[]].filter(s=>s.defaultValue!==void 0).map(s=>[s.key,s.defaultValue])):{}}r(XN,"defaultMethodConfig");function Ky(e,s){if(!e)return[];const n=M1(e);return s==="vercel_connect"?n.filter(a=>!!a.credentialSources?.vercelConnect):n}r(Ky,"connectionMethodsForCredentialSource");function M1(e){return Xoe(e).filter(s=>(s.purpose??"tool")!=="channel")}r(M1,"availableToolConnectionMethods");function hI(e,s){const n=M1(e);return s?n.find(a=>a.key===s)??null:Z6(n)}r(hI,"availableToolConnectionMethod");function Ij(e){const s=Z6(e);return e.length===1||s?.capabilityProfile||s?.grantKinds?.includes("agent")?s:null}r(Ij,"recommendedSetupConnectionMethod");function cJ(e){return Ij(e?e.methods.filter(s=>(s.purpose??"tool")==="tool"&&(s.oauthStrategy==="paperclip_cloud_connector"||s.oauthStrategy==="paperclip_id_connector")):[])}r(cJ,"recommendedManagedConnectorMethod");function dJ(e){if(!e)return!1;const s=M1(e),n=s.length===1?s[0]:null;return!!(n&&Fp(n)&&!CIe(n))}r(dJ,"canUseAutomaticOAuthFastPath");function uJ(e){if(!e)return null;const s=M1(e),n=s.length===1?s[0]:null;return n&&Fp(n)?n:null}r(uJ,"automaticOAuthMethod");function BGe(e){const s=e.metadata;if(!s)return null;const n=s.sourceTemplateKey??s.galleryKey;return typeof n=="string"?n:null}r(BGe,"appSourceSlug");function qGe(e){const s=e.config?.sourceTemplateKey??e.transportConfig.sourceTemplateKey;return typeof s=="string"?s:null}r(qGe,"connectionSourceSlug");function mJ(e,s,n,a={}){if(!e)return null;const i=new Set(s.filter(o=>o.status!=="archived"&&BGe(o)===e&&(!a.applicationId||o.id===a.applicationId)).map(o=>o.id));return n.find(o=>{const l=a.applicationId?o.applicationId===a.applicationId:i.has(o.applicationId)||qGe(o)===e;return o.status!=="archived"&&(!a.draftOnly||o.status==="draft")&&o.authKind==="oauth"&&l})??null}r(mJ,"reusableOAuthConnection");function kxe(e,s,n){if(e.origin!==s||!e.data||typeof e.data!="object")return null;const a=e.data;return a.type!=="paperclip.connection-intent.oauth"||a.interactionId!==n?null:a.outcome==="connected"||a.outcome==="declined"||a.outcome==="failed"?a.outcome:null}r(kxe,"readConnectionIntentOAuthOutcome");function sE(e={}){const[s]=Ri(),n=ka(),{selectedCompanyId:a}=xs(),i=ghe(),o=e.interactionId||s.get("intent")||void 0,l=e.serviceSlug||s.get("source")||n.appKey||s.get("appKey"),c=(0,u.useMemo)(()=>{if(o&&pj(l))try{return sessionStorage.getItem(`paperclip:mcp-intent-draft:${a}:${o}`)}catch{}return null},[o,a,l]),d=e.configuredConnection?.id||s.get("resume")||s.get("reconnect")||c,m=!!(d&&(!l||pj(l))),h=ee({queryKey:["tools","connection",d],queryFn:r(()=>ms.getConnection(d),"queryFn"),enabled:m}),p=l||h.data?.config?.sourceTemplateKey,f=s.get("method")||h.data?.config?.connectionMethodKey;return m&&h.isPending?(0,t.jsx)("p",{className:"p-6 text-sm text-muted-foreground",children:"Loading connection…"}):m&&h.isError?(0,t.jsxs)("div",{role:"alert",className:"space-y-3 p-6",children:[(0,t.jsx)("p",{children:"Could not load this connection. Your saved access and credentials have not changed."}),(0,t.jsx)(F,{variant:"outline",onClick:r(()=>{h.refetch()},"onClick"),children:"Try again"})]}):!e.byoOnly&&(e.credentialSource??"paperclip_vault")==="paperclip_vault"&&pj(p)&&(!f||e2(p,f))?i.loaded?i.enabled?(0,t.jsx)(Wqe,{...e,interactionId:o,providerId:p,connection:h.data},`${o||"page"}:${p}`):(0,t.jsx)("p",{role:"status",className:"p-6 text-sm text-muted-foreground",children:"Enable MCP aggregators in Settings → Experimental to set up this connection."}):(0,t.jsx)("p",{className:"p-6 text-sm text-muted-foreground",children:"Loading connection settings…"}):(0,t.jsx)(zGe,{...e})}r(sE,"ConnectionSetupFlow");function zGe({byoOnly:e=!1,credentialSource:s="paperclip_vault",host:n="page",serviceSlug:a,requestedAgentId:i,interactionId:o,forceNewConnection:l=!1,existingConnections:c=[],configuredConnection:d,onUseExisting:m,onComplete:h,onOAuthDeclined:p,aiConnection:f,onPhaseChange:g,onCancel:v,renderCredentialStep:y}={}){const w=Hn(),S=(0,u.useCallback)(($e,Ft)=>{n==="page"&&(Ft?w($e,Ft):w($e))},[n,w]),j=ka(),{selectedCompany:N,selectedCompanyId:_}=xs(),{enabled:A}=Lx(),{setBreadcrumbs:C}=Ln(),{pushToast:I}=Pi(),[T]=Ri(),R=o?.trim()||T.get("intent")?.trim()||null,L=j.appKey??T.get("appKey")??void 0,O=T.get("source")?.trim()||null,$=l||T.get("new")==="1",E=T.get("stage")?.trim()||null,q=T.get("method")?.trim()||null,B=T.get("resume")?.trim()||null,K=T.get("oauth"),U=T.get("code"),D=nJ(T.get("installation_url")),V=nJ(T.get("management_url")),H=d?.id??(T.get("reconnect")?.trim()||null),J=T.get("identity")==="user"?"user":T.get("identity")==="organization"?"organization":null,X=s==="vercel_connect",le=a??O,ce=s==="paperclip_vault"&&uGe(le)?le:null,te=hGe({serviceSlug:a,appKey:L,sourceSlug:O}),re=(a??O??L)==="zapier",de=re?void 0:te,Z=!!d||n==="page"&&(e||T.get("byo")==="1"),[Y]=(0,u.useState)(()=>n==="page"&&T.get("cloud_connector")==="enrolled"&&de?AGe(de):null),[G]=(0,u.useState)(()=>{const $e=T.get("link")?.trim()??"";return{link:/^https?:\/\//i.test($e)?$e:"",name:d?.name??T.get("name")?.trim()??"",applicationId:d?.applicationId??(T.get("applicationId")?.trim()||void 0)}}),[fe,se]=(0,u.useState)(()=>aJ({requestedAppKey:de,routeStage:E,resumeConnectionId:B,hasPrefilledLink:!!G.link,zapierSource:re})),[ae,ie]=(0,u.useState)(null),[ue,pe]=(0,u.useState)(""),[be,oe]=(0,u.useState)(G.link),[je,_e]=(0,u.useState)(G.name||(re?"Zapier":"")),[xe,Ae]=(0,u.useState)(!1),[Ye,Oe]=(0,u.useState)(""),[Xe,me]=(0,u.useState)("auto"),[Le,mt]=(0,u.useState)(()=>[DF()]),[We,ze]=(0,u.useState)(""),[st,pt]=(0,u.useState)(""),[Pt,tt]=(0,u.useState)(!1),[ht,et]=(0,u.useState)(null),[Ie,Ne]=(0,u.useState)(!1),[Je,ft]=(0,u.useState)({}),[Ot,es]=(0,u.useState)(""),[bs,Ke]=(0,u.useState)(""),[Ve,dt]=(0,u.useState)(""),[Be,as]=(0,u.useState)(f&&f.mode!=="responsible_user"?`ai-${f.method}`:""),[Fe,Ut]=(0,u.useState)({}),[At,Ls]=(0,u.useState)(""),[qe,ut]=(0,u.useState)(null),[Dt,is]=(0,u.useState)(null),[Ts,jt]=(0,u.useState)({}),[we,Pe]=(0,u.useState)("all"),[at,Mt]=(0,u.useState)(new Set),[kt,hs]=(0,u.useState)(()=>new Set(Y?.agentIds??(i?[i]:[]))),[bt,Vt]=(0,u.useState)(Y?.grantKind??J??(i?"user":"organization")),[Wt,Me]=(0,u.useState)(Y?.installChoice??(i?"specific":"all")),Ee=!!(B&&(K==="failed"||K==="denied")),[He,Ue]=(0,u.useState)(Ee?"error":"entry"),[Gt,Nt]=(0,u.useState)(()=>Ee?rJ(K,U):null),[ts,ls]=(0,u.useState)(null),Tt=(0,u.useRef)(!1),ys=(0,u.useRef)(!1),ds=(0,u.useRef)(null),[Ys,dn]=(0,u.useState)(null),$n=(0,u.useRef)(null),[kn,Bs]=(0,u.useState)(null),[ks,or]=(0,u.useState)(null),Is=(0,u.useRef)(null),[Lr,jn]=(0,u.useState)(c.length>0&&!!m),[Yn,lr]=(0,u.useState)(null),[Cn,vr]=(0,u.useState)(null),[zr,Qr]=(0,u.useState)(null),rr=(0,u.useCallback)(()=>{n!=="dialog"||$n.current?.closed===!1||($n.current=window.open("about:blank","paperclip-connection-oauth","popup,width=720,height=760,resizable=yes,scrollbars=yes"))},[n]),gr=(0,u.useCallback)($e=>{if(n!=="dialog"){Nc($e);return}or($e);const Ft=$n.current;if(!Ft||Ft.closed){Ue("error"),Nt("Paperclip couldn’t open the sign-in window. Open sign-in in a new tab to continue."),g?.("needs_retry");return}Ft.location.assign($e),Ft.focus()},[n,g]),cr=(0,u.useCallback)(()=>{$n.current=null,Nt(null),Ue("redirecting"),g?.("authorizing")},[g]);(0,u.useEffect)(()=>{if(n!=="dialog"||He!=="redirecting")return;const $e=window.setInterval(()=>{$n.current?.closed&&(Ue("error"),Nt("The sign-in window closed. If authorization did not finish, try again."),or(null),g?.("needs_retry"))},1e3);return()=>window.clearInterval($e)},[n,He,g]);const Gr=(0,u.useCallback)(async $e=>{Is.current?.abort();const Ft=new AbortController;Is.current=Ft;try{const Ms=await pw($e,{signal:Ft.signal});if(Ms.kind==="reauthentication"){const mn=n==="dialog"?$n.current:window;if(!mn||mn.closed||!$e.handoff)throw new Error("Paperclip couldn’t preserve this sign-in while refreshing your account.");mC($e.handoff.session,mn.sessionStorage),Ue("starting")}else ls(Ms.host),Ue("redirecting");gr(Ms.url)}catch(Ms){if(Ft.signal.aborted)return;Ue("error"),Nt(Ms instanceof Error?Ms.message:"Paperclip couldn’t start secure sign-in. Try again."),g?.("needs_retry")}finally{Is.current===Ft&&(Is.current=null)}},[n,g,gr]);(0,u.useEffect)(()=>()=>Is.current?.abort(),[]),(0,u.useEffect)(()=>{if(n!=="dialog"||!R)return;const $e=r(Ft=>{const Ms=kxe(Ft,window.location.origin,R);if(Ms==="connected"){Ue("entry"),or(null),h?.({resolvedByCallback:!0});return}if(Ms==="declined"){Ue("error"),Nt("Authorization was cancelled. You can try again."),g?.("needs_retry");return}Ms==="failed"&&(Ue("error"),Nt("Authorization did not complete. Try again when you’re ready."))},"receiveOAuthOutcome");return window.addEventListener("message",$e),()=>window.removeEventListener("message",$e)},[R,n,h,p]),(0,u.useEffect)(()=>{if(n!=="dialog"||R||!kn)return;let $e=!1,Ft=!1;const Ms=window.setInterval(async()=>{if(Ft||$e)return;const mn=$n.current;if(!mn||mn.closed){Bs(null),Ue("error"),Nt("The sign-in window closed. Try again to finish connecting GitHub.");return}let Br;try{Br=new URL(mn.location.href)}catch{return}if(!(Br.origin!==window.location.origin||!Br.pathname.includes(kn))){if(Br.searchParams.has("oauth")){Bs(null),Ue("error"),Nt("Authorization did not complete. Finish setup in the sign-in window or try again.");return}if(Br.searchParams.get("success")==="1"){Ft=!0;try{const za=await ms.getConnection(kn);!$e&&za.status==="active"&&(Bs(null),mn.close(),h?.({connectionId:za.id}))}catch{$e||(Bs(null),Ue("error"),Nt("Could not confirm the connection. Try again."))}finally{Ft=!1}}}},1e3);return()=>{$e=!0,window.clearInterval(Ms)}},[R,kn,n,h]);const Dn=r(()=>{me("auto"),mt([DF()]),ze(""),pt(""),tt(!1),et(null),Ne(!1)},"resetGenericAuthState"),Rr=r($e=>{if(n==="page"&&!R&&s==="paperclip_vault"&&pj($e.slug)){S(`/apps/connect?source=${$e.slug}`);return}if($e.slug==="zapier"){ie(null),pe(""),oe(""),_e("Zapier"),Ae(!1),Oe(""),Dn(),ft({}),is(null),se("access"),S(mI("/apps/connect?source=zapier",R));return}if(s==="paperclip_vault"&&dJ($e)){S(MF($e.slug,R));return}ie($e),pe($e.name),oe(""),_e(""),Ae(!1),Oe(""),Dn(),ft({}),es(""),Ke(""),dt("");const Ft=Ij(Ky($e,s));as(Ft?.key??""),Ut(XN(Ft)),Ls(""),ut(null),is(null),hs(new Set(i?[i]:[])),Me(i?"specific":"all"),Vt(er??L4(Ft,!!i)),se("access"),S(s==="vercel_connect"?mI(P4($e.slug),R):MF($e.slug,R))},"useMatchedGalleryEntry"),la=r(()=>{se("gallery"),S(mI(s==="vercel_connect"?P4():e?"/apps/byo":"/apps",R))},"backToGallery");(0,u.useEffect)(()=>{if(n==="page")return C([{label:"Connectors",href:"/apps"},{label:X?"Vercel Connect":e?"Connect your own tool":"Connect an app"}]),()=>C([])},[e,n,C,X]);const _n=ee({queryKey:P.apps.gallery(_??"__none__"),queryFn:r(()=>ms.listGallery(_),"queryFn"),select:(0,u.useCallback)($e=>R?{...$e,apps:$e.apps.map(Ft=>({...Ft,methods:Ft.methods.filter(Ms=>f?Ms.ai?.provider===f.provider&&(f.mode==="responsible_user"||Ms.ai.method===f.method):Ms.transport!=="runtime_auth")})).filter(Ft=>Ft.methods.length>0)}:$e,[R,f?.provider,f?.method,f?.mode]),enabled:!!_}),_s=(0,u.useMemo)(()=>(_n.data?.apps??[]).filter($e=>A||!$e.methods.some(Ft=>Ft.transport==="chat_sdk")||tE($e)),[_n.data,A]),ta=de?J6(de):null,Xn=!!ta?.methods.some($e=>$e.oauthStrategy==="paperclip_cloud_connector"||$e.oauthStrategy==="paperclip_id_connector"),gt=!!ae?.methods.some($e=>$e.oauthStrategy==="paperclip_cloud_connector"||$e.oauthStrategy==="paperclip_id_connector"),$s=ae&&Xn&&!gt?cJ(ta):null,[qs,Qe]=(0,u.useState)(null),Yt=ee({queryKey:["cloud-connector","enrollment"],queryFn:r(()=>ms.getCloudConnectorEnrollment(),"queryFn"),refetchInterval:qs?2e3:!1,enabled:!!(_&&Xn&&!gt)}),[an,Fs]=(0,u.useState)(null),Kn=(0,u.useCallback)(()=>{$n.current?.close(),$n.current=null,Qe(null)},[]),Nr=(0,u.useCallback)(()=>{!_||!de||IGe(_,de,{grantKind:bt,installChoice:Wt,agentIds:Wt==="specific"?[...kt]:[]})},[bt,kt,Wt,de,_]),ga=(0,u.useCallback)($e=>{const Ft=cT($e);if(!Ft.ok){Kn(),Fs(Ft.message);return}if(n==="dialog"){Qe(Ft.url);const Ms=$n.current;Ms&&!Ms.closed?(Ms.location.assign(Ft.url),Ms.focus()):Fs("Open authorization in a new tab to continue.");return}Nc(Ft.url)},[n,Kn]);(0,u.useEffect)(()=>{!qs||Yt.data?.status!=="active"||(Kn(),Fs(null),_n.refetch())},[qs,Yt.data?.status,_n.refetch,Kn]);const Vn=ke({mutationFn:r(()=>ms.startCloudConnectorEnrollment(_,N?.name,de?iJ(de,"key",s,{resumeConnectionId:B,reconnectConnectionId:H,interactionId:R})+(n==="dialog"?"&enrollment_host=dialog":""):void 0),"mutationFn"),onSuccess:r($e=>{if(!$e.verificationUrl){Kn(),Fs("Paperclip Cloud did not return an enrollment link. Try again.");return}ga($e.verificationUrl)},"onSuccess"),onError:r($e=>{Kn(),Fs($e instanceof Error?$e.message:"Paperclip couldn’t reach Paperclip Cloud. Try again.")},"onError")}),Qn=ee({queryKey:P.tools.applications(_??"__none__"),queryFn:r(()=>ms.listApplications(_),"queryFn"),enabled:!!_&&(!!ce||!!B||!!H),refetchOnMount:"always"}),ns=ee({queryKey:P.tools.connections(_??"__none__"),queryFn:r(()=>ms.listConnections(_),"queryFn"),enabled:!!_&&(!!ce||!!B||!!H),refetchOnMount:"always"}),on=(0,u.useMemo)(()=>l?null:mJ(ce,Qn.data?.applications??[],ns.data?.connections??[],$?{applicationId:G.applicationId,draftOnly:!0}:{}),[Qn.data,ns.data,$,ce,G.applicationId,l]),Hs=(0,u.useMemo)(()=>H?(ns.data?.connections??[]).find($e=>$e.id===H)??null:null,[ns.data,H]),Jt=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(!d||!ns.isFetchedAfterMount||!Hs||Jt.current===Hs.id)return;const $e=Hs.config?.url??Hs.transportConfig?.url??Hs.transportConfig?.serverUrl??Hs.config?.serverUrl;typeof $e!="string"||!/^https?:\/\//i.test($e)||(Jt.current=Hs.id,oe(Ft=>Ft||$e))},[d,ns.isFetchedAfterMount,Hs]);const As=(0,u.useMemo)(()=>Hs?(Qn.data?.applications??[]).find($e=>$e.id===Hs.applicationId)??null:null,[Qn.data,Hs]),Fn=EGe({requestedAppKey:de,byo:Z,applicationId:G.applicationId,reconnectConnection:Hs,reconnectApplication:As}),In=(0,u.useMemo)(()=>B?(ns.data?.connections??[]).find($e=>$e.id===B)??null:null,[ns.data,B]),Zn=In??Hs,er=Zn?Zn.credentialPolicy==="per_user"?"user":Zn.credentialPolicy==="per_agent"?"agent":"organization":J,na=In?.authKind==="oauth"?In:on,us=on?on.credentialPolicy==="per_user"?"user":on.credentialPolicy==="per_agent"?"agent":"organization":null,Os=er??us;(0,u.useEffect)(()=>{Os&&Vt(Os)},[Os]);const tn=(0,u.useMemo)(()=>be&&!ae?kR(be,_s):null,[ae,_s,be]),Bn=ae?hI(ae,Be||null):null,mr=Bn&&Fp(Bn)?Bn:uJ(ae),Ur=s==="paperclip_vault"&&mr?ae:null,Jn=s==="paperclip_vault"&&dJ(ae)?ae:null,ei=!!ce&&(!Qn.isFetchedAfterMount||!ns.isFetchedAfterMount),ye=r($e=>{se($e),ae&&S(iJ(ae.slug,$e,s,{connectionMethodKey:ae.methods.find(Ft=>Ft.key===Be)?.ai?Be:void 0,resumeConnectionId:B,reconnectConnectionId:H,interactionId:R}))},"setAppStep"),qt=ke({mutationFn:r($e=>ms.startOAuth($e.id,{asCurrentUser:$e.credentialPolicy==="per_user",...$e.credentialPolicy==="per_agent"?{asAgentId:FGe($e)??[...kt][0]}:{},...R?{interactionId:R}:{}}),"mutationFn"),onSuccess:r($e=>{Gr($e)},"onSuccess"),onError:r($e=>{const Ft=$e instanceof vn&&$e.body&&typeof $e.body=="object"?$e.body.details:null;Ue("error"),g?.("needs_retry"),Nt(Ft?.code==="invalid_grant"?"Your authorization expired or was revoked. Reconnect to continue.":$e instanceof Error?$e.message:"Paperclip couldn’t start secure sign-in. Try again.")},"onError")}),un=qt.mutate,Gn=(0,u.useCallback)($e=>{g?.("authorizing"),rr(),n==="dialog"&&!R&&Bs($e.id),un($e)},[un,g,rr,n,R]),An=r(async $e=>{if(i)return;const Ft=wxe(_,(Os??bt)!=="agent"&&Wt==="all"?{onAll:!0,agentIds:new Set}:{onAll:!1,agentIds:kt});await ms.putConnectionInstalls($e,Ft)},"applyAccessInstalls"),ba=Os??bt,Ba=ke({mutationFn:r(async $e=>{const Ft=$e??ae;let Ms;if(Ft){const mn=Os??bt,Br=hI(Ft,Be||null),za=Mk(Ft,Br)?qO(At).ids:[],qr=ue.trim(),So=eJ(qr||Ft.name,mn);Ms=await ms.connectApp(_,{galleryKey:Ft.slug,...Be?{connectionMethodKey:Be}:{},name:So,credentialSource:s,...s==="paperclip_vault"?{credentialValues:Je}:{},...s==="vercel_connect"?{vercelConnect:{connector:Ve.trim()}}:{},...Ot.trim()?{oauthClient:{clientId:Ot.trim(),...bs?{clientSecret:bs}:{}}}:{},configValues:Mk(Ft,Br)?{allowedSpreadsheetIds:za}:Object.keys(Fe).length>0?Fe:void 0,applicationId:G.applicationId,...B?{resumeConnectionId:B}:H?{reconnectConnectionId:H}:{},...mn!=="organization"?{grantKind:mn}:{},...mn==="agent"?{subjectAgentId:[...kt][0]}:{}})}else{const mn=kGe({link:be,name:je,authMode:Xe,needsKey:xe,keyValue:Ye,headers:Le,oauthClientId:We,oauthClientSecret:st}),Br=eJ(mn.name??D4(be)??"Custom app",ba);Ms=await ms.connectApp(_,{...mn,...H?{reconnectConnectionId:H}:{},...re||tn?.slug==="zapier"?{galleryKey:"zapier",connectionMethodKey:"generated-url"}:{},name:Br,applicationId:G.applicationId,...ba!=="organization"?{grantKind:ba}:{},...ba==="agent"?{subjectAgentId:[...kt][0]}:{}})}return Ms.auth?.kind==="oauth"&&!B&&!H&&await An(Ms.connectionId),Ms},"mutationFn"),onSuccess:r($e=>{if($e.auth?.kind==="oauth"){if(is($e),$e.auth.manualClientRequired){et(sJ("oauth_manual_client_required",null)),me("oauth"),tt(!0),Ne(!1);return}if(n==="dialog"||R){Ue("starting"),Ne(!ae),Gn($e.connection);return}const Ms=$e.auth.startUrl?.trim();if(!Ms){Ue("starting"),Ne(!0),Gn($e.connection);return}Ne(!0),Gr({authorizationUrl:Ms,handoff:$e.auth.handoff});return}et(null),is($e);const Ft={};for(const Ms of $e.actions.readOnly)Ft[Ms.catalogEntryId]=!0;for(const Ms of $e.actions.canMakeChanges)Ft[Ms.catalogEntryId]=!0;jt(Ft),It.mutate({result:$e,enabled:Ft})},"onSuccess"),onError:r($e=>{const Ft=$e instanceof vn&&$e.body&&typeof $e.body=="object"?$e.body.details:null;if(Ur){Ue("error"),g?.("needs_retry"),Nt(Ft?.code==="invalid_grant"?"Your authorization expired or was revoked. Reconnect to continue.":$e instanceof Error?$e.message:"Paperclip couldn’t start secure sign-in. Try again.");return}if(!ae&&be){const Ms=typeof Ft?.code=="string"?Ft.code:null,mn=sJ(Ms,$e instanceof Error?$e.message:null);et(mn),Ne(!1),mn.focus==="credentials"&&tt(!0);return}I({title:"Couldn’t connect",body:$e instanceof Error?$e.message:"Please check your key and try again.",tone:"error"})},"onError")}),ne=Ba.mutate,rt=(0,u.useCallback)($e=>{const Ft=$e??ae;(Ft?hI(Ft,Be||null):null)?.auth==="oauth"&&rr(),ne($e)},[Be,ae,ne,rr]);(0,u.useEffect)(()=>{if(!de||_n.isLoading||!_n.data||H&&(!ns.isFetchedAfterMount||!Qn.isFetchedAfterMount))return;const $e=TGe({requestedAppKey:de,galleryApps:_n.data.apps,reconnectConnection:Hs,applications:Qn.data?.applications??[]}),Ft=!!$e?.methods.some(Bi=>Bi.oauthStrategy==="paperclip_cloud_connector"||Bi.oauthStrategy==="paperclip_id_connector");if(Xn&&!Ft&&Yt.isLoading)return;const Ms=Ky($e,s),mn=f??(Hs?.connectionPurpose==="ai"?PW.safeParse(Hs.config?.ai).data:void 0),Br=Ms.find(Bi=>mn?Bi.ai?.provider===mn.provider&&(!("mode"in mn)||mn.mode!=="responsible_user")&&Bi.ai.method===mn.method:Bi.key===q)??(Xn&&!Ft?cJ(ta):null)??Ij(Ms),za=Ms.length===1?Ms[0]:null,qr=s==="paperclip_vault"&&!!uJ($e),So=PGe({credentialSource:s,available:_n.data.credentialSources?.vercelConnect.available===!0,retainedReconnectMatches:!!(H&&Fn)}),kr=Ms.length===1&&za?.auth==="oauth"&&!Fp(za)&&!yR(za),xo=MGe({available:$e?.availability?.available,reconnectConnectionId:H,reconnectSourceMatches:Fn}),Mi=DGe({reconnectConnectionId:H,hasRequestedEntry:!!$e,supportedMethodCount:Ms.length,unsupportedOAuth:kr,vercelUnavailable:So,definitionUnavailable:xo});if(Mi!=="ready"){if(ie(null),se("gallery"),Mi==="reconnect_unavailable"&&H){Qr(H);return}S(mI(s==="vercel_connect"?P4():"/apps/connect",R),{replace:!0});return}if(Qr(null),!!$e){if(ae?.slug!==$e.slug){ie($e),pe($e.name),oe(""),_e(""),Ae(!1),Oe(""),ft({}),es(""),Ke(""),dt(""),as(Br?.key??""),Ut(XN(Br)),Ls(""),ut(null),is(null);const Bi=Y?.companyId===_?Y:null;Vt(er??Bi?.grantKind??L4(Br,!!i)),hs(new Set(Bi?.agentIds??(i?[i]:[]))),Me(Bi?.installChoice??(i?"specific":"all")),se(aJ({requestedAppKey:de,routeStage:E,resumeConnectionId:B,hasPrefilledLink:!!G.link,zapierSource:re}))}else gt!==Ft&&(ie($e),as(Br?.key??""),Ut(XN(Br)));if(!(qr&&(!Qn.isFetchedAfterMount||!ns.isFetchedAfterMount))&&!(qr&&ys.current)&&qr&&(Qn.isError||ns.isError)){Ue("error"),Nt("Paperclip couldn’t check for an existing connection. Try again."),se("key");return}}},[f,q,Qn.isError,Qn.isFetchedAfterMount,Qn.data,ns.isError,ns.isFetchedAfterMount,Yt.data?.configured,Yt.isLoading,Be,s,ae?.slug,gt,_n.data,_n.isLoading,S,er,Hs,H,Fn,B,ta,de,i,Y,E,re]),(0,u.useEffect)(()=>{Hs?.connectionPurpose==="ai"&&fe==="access"&&se("key")},[Hs?.connectionPurpose,fe]),(0,u.useEffect)(()=>{ds.current=null,dn(null)},[B]),(0,u.useEffect)(()=>{if(!In||!ae||In.status!=="draft"||ds.current===In.id)return;const $e=In.config&&typeof In.config=="object"?In.config:{},Ft=typeof $e.sourceTemplateKey=="string"?$e.sourceTemplateKey:null;if(Ft&&Ft!==ae.slug)return;const Ms=typeof $e.connectionMethodKey=="string"?$e.connectionMethodKey:null,mn=Ms?Ky(ae,s).find(za=>za.key===Ms)??null:null;if(pe(In.name||ae.name),mn){as(mn.key);const za=$e.methodConfig&&typeof $e.methodConfig=="object"?$e.methodConfig:{};Ut({...XN(mn),...Object.fromEntries(Object.entries(za).filter(qr=>typeof qr[1]=="string"||typeof qr[1]=="boolean"))})}const Br=$e.oauth&&typeof $e.oauth=="object"?$e.oauth:null;Br?.clientRegistrationSource==="manual"&&typeof Br.clientId=="string"&&es(Br.clientId),K==="failed"||K==="denied"?(Ue("error"),Nt(rJ(K,U))):(Ue("entry"),Nt(null)),se("key"),ds.current=In.id,dn(In.id)},[s,ae,U,K,In]);const It=ke({mutationFn:r(async $e=>{const{result:Ft,enabled:Ms}=$e,mn=Object.entries(Ms).filter(([,kr])=>kr).map(([kr])=>kr),Br=new Set(Array.isArray(Ft.suggestedDefaults.askFirstRiskLevels)?Ft.suggestedDefaults.askFirstRiskLevels.filter(kr=>typeof kr=="string"):[]),za=Ft.actions.canMakeChanges.filter(kr=>Ms[kr.catalogEntryId]&&Br.has(kr.riskLevel)).map(kr=>kr.catalogEntryId),qr=Wt==="all"?"all_agents":{agentIds:Array.from(kt)},So=await ms.finishApp(_,Ft.connectionId,{enabledCatalogEntryIds:mn,askFirstCatalogEntryIds:za,access:qr,...i?{preserveExistingAccess:!0}:{}});return await An(Ft.connectionId),So},"mutationFn"),onSuccess:r(($e,Ft)=>{ye("success"),h?.({connectionId:Ft.result.connectionId})},"onSuccess"),onError:r($e=>{ye("access"),I({title:"Couldn’t finish setup",body:$e instanceof Error?$e.message:"Please try again.",tone:"error"})},"onError")});if(!_)return(0,t.jsx)("div",{className:"p-6 text-sm text-muted-foreground",children:"Select an organization to connect apps."});if((B||H)&&(ns.isError||Qn.isError))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Couldn’t load connection setup"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Paperclip couldn’t check the retained connection. The retained connection was not changed."}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",onClick:r(async()=>{const[$e,Ft]=await Promise.all([ns.refetch(),Qn.refetch()]);!$e.isError&&!Ft.isError&&(Nt(null),Ue("entry"))},"onClick"),children:"Try again"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]})]});if(B&&ns.isFetchedAfterMount&&!In)return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"This setup can’t be resumed"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"The saved connection no longer exists or is not available to this organization."}),(0,t.jsx)(F,{type:"button",variant:"outline",className:"mt-5",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]});if(H&&ns.isFetchedAfterMount&&Qn.isFetchedAfterMount&&(!Hs||!Fn))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"This connection can’t be reconnected"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:Hs?"This reconnect link does not match the retained connection's provider.":"The retained connection no longer exists or is not available to this organization."}),(0,t.jsx)(F,{type:"button",variant:"outline",className:"mt-5",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]});if((B||H)&&_n.isError)return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Couldn’t load connection setup"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Paperclip couldn’t load the provider details needed to restore this connection. The retained connection was not changed."}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",onClick:r(()=>{_n.refetch()},"onClick"),children:"Try again"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]})]});if(H&&zr===H)return(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"This connection can’t be reconnected"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Paperclip no longer has a supported setup method for this retained connection. The retained connection was not changed."}),(0,t.jsx)(F,{type:"button",variant:"outline",className:"mt-5",onClick:r(()=>S("/apps"),"onClick"),children:"Back to apps"})]});if(B&&(!ns.isFetchedAfterMount||_n.isLoading||!ae||Ys!==In?.id))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl space-y-4","aria-label":"Loading saved connection setup",children:[(0,t.jsx)(bn,{className:"h-8 w-48"}),(0,t.jsx)(bn,{className:"h-40 w-full rounded-xl"})]});if(H&&(!ns.isFetchedAfterMount||!Qn.isFetchedAfterMount||_n.isLoading||de&&!ae))return(0,t.jsxs)("div",{className:"mx-auto max-w-xl space-y-4","aria-label":"Loading retained connection setup",children:[(0,t.jsx)(bn,{className:"h-8 w-48"}),(0,t.jsx)(bn,{className:"h-40 w-full rounded-xl"})]});if(Lr&&m)return(0,t.jsxs)("div",{className:"max-w-5xl","data-testid":"connection-existing-choice",children:[(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsxs)("h1",{className:"text-2xl font-bold tracking-tight",children:["Use an existing ",de?"connection":"app connection"]}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Reuse a connection without changing who already has access, or connect a new one."})]}),(0,t.jsx)(pU,{choices:c.map($e=>({id:$e.id,name:$e.name,description:$e.status==="active"&&$e.enabled?"Ready to use":"Setup needs attention"})),pendingId:Yn,onSelect:r(async $e=>{lr($e),vr(null);try{await m($e)}catch(Ft){vr(Ft instanceof Error?Ft.message:"Couldn’t use this connection."),lr(null)}},"onSelect")}),Cn?(0,t.jsx)(Ja,{tone:"danger",className:"mt-4",children:Cn}):null,(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>jn(!1),"onClick"),children:d?"Review connection setup":"Connect new"}),v?(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:v,children:"Cancel"}):null]})]});const Ns=!!(Ur&&fe==="key"&&(Jn||He!=="entry")),Qs=!!(fe==="key"&&ae&&Xn&&!gt&&Yt.data?.configured===!0),sn=!!(fe==="key"&&ae&&Xn&&!gt&&(Yt.isLoading||Yt.isError||Yt.data?.configured!==!0));if(Ns&&Ur)return(0,t.jsx)(LF,{entry:Ur,resuming:!!B,phase:He,error:Gt,recoveryActions:U==="github_installation_required"?{installationUrl:D,managementUrl:V}:void 0,authorizationHost:ts,authorizationUrl:ks,onOpenAuthorization:cr,onRetry:r(async()=>{Nt(null),Ue("starting");const $e=Dt?.connection??na;if($e){Gn($e);return}ys.current=!0;try{const[Ft,Ms]=await Promise.all([Qn.refetch(),ns.refetch()]);if(Ft.isError||Ms.isError){Ue("error"),Nt("Paperclip couldn’t check for an existing connection. Try again.");return}const mn=(B?(Ms.data?.connections??[]).find(Br=>Br.id===B&&Br.authKind==="oauth")??null:null)??mJ(ce,Ft.data?.applications??[],Ms.data?.connections??[],$?{applicationId:G.applicationId,draftOnly:!0}:{});if(!Tt.current&&!B){mn&&Vt(mn.credentialPolicy==="per_user"?"user":mn.credentialPolicy==="per_agent"?"agent":"organization"),Ue("entry"),Nt(null),se("access");return}mn?Gn(mn):Ba.mutate(Ur)}finally{ys.current=!1}},"onRetry"),onBack:r(()=>{Is.current?.abort(),Ue("entry"),Nt(null),ye("access")},"onBack"),onCancel:r(()=>{Is.current?.abort(),(v??(()=>S("/apps")))()},"onCancel")});if(Ie&&!ae&&be&&fe==="key")return(0,t.jsx)(LF,{identity:{name:je.trim()||vS(be)||"this server",unverifiedHost:vS(be)},steps:{labels:oJ,activeIndex:lJ.key},phase:He,error:Gt,authorizationHost:ts,authorizationUrl:ks,onOpenAuthorization:cr,onRetry:r(()=>{Nt(null);const $e=Dt?.connection;if($e){Ue("starting"),Gn($e);return}Ne(!1),Ue("entry")},"onRetry"),onBack:r(()=>{Is.current?.abort(),Ne(!1),Ue("entry"),Nt(null)},"onBack"),onCancel:r(()=>{Is.current?.abort(),(v??(()=>S("/apps")))()},"onCancel")});const ca=Dt?.application.name??ae?.name??(je.trim()||D4(be)||"this app"),$t=Ky(ae,s),rs=$s?[$s]:$t,ln=X?_s.filter($e=>Ky($e,s).length>0):_s,Yr=re?_n.data?.apps.find($e=>$e.slug==="zapier")??null:null,On=(Hs?.connectionPurpose==="ai"?PW.safeParse(Hs.config?.ai).data:void 0)??ae?.methods.find($e=>$e.key===Be)?.ai??(!Be&&ae?.methods.every($e=>$e.ai)?ae.methods[0]?.ai:void 0),qa=ae?y?.({app:ae,name:ue||ae.name,grantKind:ba,agentIds:[...kt],allAgents:Wt==="all",onBack:r(()=>ye("access"),"onBack")})??(On&&_?(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(TT,{companyId:_,provider:On.provider,fixedMethod:!!(f&&f.mode!=="responsible_user"),initialMethod:Hs?.connectionPurpose==="ai"?(Hs.config?.ai).method:On.method,connectionId:Hs?.connectionPurpose==="ai"?Hs.id:void 0,name:Hs?.connectionPurpose==="ai"?Hs.name:ue||`My ${ae.name} ${On.method==="subscription"?"subscription":"API"}`,ownership:(Hs?.connectionPurpose==="ai"?Hs.credentialPolicy==="shared":ba==="organization")?"shared":"personal",agentIds:[...kt],allAgents:Wt==="all",onCancel:r(()=>v?v():S("/apps"),"onCancel"),onComplete:r($e=>{h?.({connectionId:$e.connectionId}),h||S(`/apps/${$e.connectionId}/permissions`)},"onComplete")})}):void 0):void 0,ri=Hs?.connectionPurpose==="ai"?["Reconnect account"]:qa!==void 0?["Access","Connect account"]:re?$Ge:ae&&rs.length>1?["Access","Choose connection"]:ae&&rs[0]?.auth==="oauth"?["Access","Sign in"]:Mk(ae,Be)?["Access","Share sheet"]:ae?["Access","Add your key"]:oJ,pi=ae?Be?rs.find($e=>$e.key===Be)??null:rs[0]??null:null,Si=ae?pi?.auth??"none":Xe==="none"?"none":Xe==="oauth"?"oauth":"api_key",to=!!Jn,ai=to?`Continue to ${ae?.name??"sign-in"}`:Si==="oauth"?"Continue":"Save and continue",Te=Hs?.connectionPurpose==="ai"?0:(re||ae)&&fe!=="gallery"&&fe!=="success"?LGe[fe]:fe==="success"?ri.length:lJ[fe];return(0,t.jsxs)("div",{className:"max-w-5xl",children:[fe!=="success"&&!(e&&fe==="gallery")&&(0,t.jsx)(mK,{subtitle:fe==="gallery"?X?"Choose a reviewed app to connect through Vercel.":"Pick the app you want your agents to use.":`Step ${Te+1} of ${ri.length}`,step:fe,activeIndex:Te,labels:ri,appIdentity:re?{name:"Zapier",logoUrl:Yr?.branding.logoUrl??null,darkLogoUrl:Yr?.branding.darkLogoUrl??null}:ae&&fe!=="gallery"?{name:ae.name,logoUrl:ae.branding.logoUrl,darkLogoUrl:ae.branding.darkLogoUrl??null}:void 0,unverifiedHost:!ae&&!re&&fe!=="gallery"?vS(be):null,onCancel:v??(()=>S("/apps"))}),fe==="gallery"&&(0,t.jsx)(KGe,{loading:_n.isLoading,initialLink:be,apps:ln,vercelConnect:X,vercelConnectAvailability:_n.data?.credentialSources?.vercelConnect??null,byo:Z,byoOnly:e,source:T.get("source"),onPick:Rr,onUseLink:r($e=>{const Ft=kR($e,_s);ie(null),pe(""),oe($e),_e(Ft?.name??D4($e)??""),Ae(!1),Oe(""),ft({}),Ls(""),ut(null),hs(new Set(i?[i]:[])),Me(i?"specific":"all"),Vt(er??(i?"user":"organization")),se("access")},"onUseLink")}),Qs&&ae?(0,t.jsxs)("div",{className:"mx-auto max-w-xl rounded-xl border border-border bg-card p-6",children:[(0,t.jsxs)("h2",{className:"text-lg font-semibold text-foreground",children:[ae.name," sign-in is unavailable"]}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["This instance is connected to Paperclip, but ",ae.name," sign-in is not currently available. Try again shortly or contact your instance administrator."]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between gap-3",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:r(()=>ye("access"),"onClick"),children:"Back"}),(0,t.jsxs)(F,{type:"button",disabled:_n.isFetching,onClick:r(()=>{_n.refetch()},"onClick"),children:[_n.isFetching?(0,t.jsx)(it,{className:"h-4 w-4 animate-spin"}):null,"Try again"]})]})]}):fe==="key"&&ae&&sn?(0,t.jsx)("div",{className:"mx-auto max-w-xl",children:(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-card p-6",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"rounded-lg bg-muted p-2 text-muted-foreground",children:(0,t.jsx)(Hg,{className:"h-5 w-5"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Connect with Paperclip"}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["You must connect this instance to Paperclip to connect to ",ae.name," (you only need to do this once)."]})]})]}),Yt.isError||an?(0,t.jsx)(Ja,{tone:"danger",className:"mt-4",children:an??"Paperclip couldn’t check Cloud registration. Try again."}):null,qs?(0,t.jsxs)("p",{className:"mt-4 text-sm text-muted-foreground",children:["Finish authorization in the opened window."," ",(0,t.jsx)("a",{className:"underline",href:qs,target:"_blank",rel:"noopener noreferrer",children:"Open authorization in a new tab"})]}):null,(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between gap-3",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:r(()=>ye("access"),"onClick"),children:"Back"}),(0,t.jsxs)(F,{type:"button",disabled:Yt.isLoading||Vn.isPending,onClick:r(()=>{Fs(null),rr(),Nr(),Vn.mutate()},"onClick"),children:[Vn.isPending?(0,t.jsx)(it,{className:"h-4 w-4 animate-spin"}):null,Yt.data?.status==="pending"?"Continue":"Connect with Paperclip"]})]})]})}):fe==="key"&&ae&&qa!==void 0?qa:fe==="key"&&ae?(0,t.jsx)(WGe,{entry:ae,error:Ba.isError?Ba.error instanceof Error?Ba.error.message:"Please check your key and try again.":null,values:Je,onChange:ft,oauthClientId:Ot,onOAuthClientIdChange:es,oauthClientSecret:bs,onOAuthClientSecretChange:Ke,credentialSource:s,vercelConnector:Ve,onVercelConnectorChange:dt,vercelConnectAvailability:_n.data?.credentialSources?.vercelConnect??null,methodKey:Be,onMethodChange:r($e=>{as($e?.key??""),!er&&$e?.grantKinds&&!$e.grantKinds.includes(bt)&&Vt(L4($e,!!i)),ft({}),es(""),Ke(""),dt(""),Ut(XN($e))},"onMethodChange"),configValues:Fe,onConfigChange:Ut,googleSheetsLinks:At,googleSheetsError:qe,onGoogleSheetsLinksChange:r($e=>{Ls($e),ut(null)},"onGoogleSheetsLinksChange"),submitting:Ba.isPending,onBack:r(()=>ye("access"),"onBack"),onConnect:r(()=>{if(Mk(ae,Be)){const Ms=qO(At);if(Ms.invalidCount>0){ut("That doesn't look like a Google Sheets link.");return}if(Ms.ids.length===0){ut("Paste at least one Google Sheets link.");return}}const $e=hI(ae,Be||null),Ft=!!($e?.credentialFields?.length||$e?.tenantFields?.some(Ms=>!Ms.hidden)||$e?.extensionFields?.some(Ms=>!Ms.hidden));if($e&&Fp($e)&&na&&!Ft&&!Ot.trim()){Tt.current=!0,Nt(null),Ue("starting"),Gn(na);return}$e&&Fp($e)&&(Tt.current=!0,Nt(null),Ue("starting")),rt()},"onConnect")}):null,fe==="key"&&!ae&&be&&!re&&(0,t.jsx)(VGe,{link:be,name:je,needsKey:xe,onNeedsKeyChange:r($e=>{Ae($e),$e||Oe("")},"onNeedsKeyChange"),keyValue:Ye,onKeyChange:Oe,authMode:Xe,onAuthModeChange:r($e=>{me($e),et(null),$e!=="auto"&&Ae(!1),$e!=="bearer"&&$e!=="auto"&&Oe("")},"onAuthModeChange"),headers:Le,onHeadersChange:r($e=>{mt($e),et(null)},"onHeadersChange"),oauthClientId:We,onOAuthClientIdChange:ze,oauthClientSecret:st,onOAuthClientSecretChange:pt,advancedOpen:Pt,onAdvancedOpenChange:tt,guidance:ht,matchedEntry:tn,onUseMatchedEntry:tn?()=>Rr(tn):void 0,submitting:Ba.isPending||Ie,onBack:r(()=>se("access"),"onBack"),onConnect:r(()=>{et(null),Ba.mutate(void 0)},"onConnect")}),fe==="key"&&!ae&&re&&(0,t.jsx)(UGe,{link:be,onLinkChange:oe,submitting:Ba.isPending,onBack:r(()=>se("access"),"onBack"),onConnect:r(()=>Ba.mutate(void 0),"onConnect")}),fe==="access"&&(0,t.jsxs)(t.Fragment,{children:[ae?.slug==="railway"&&(0,t.jsxs)("div",{className:"mb-6 space-y-3 text-sm text-muted-foreground",children:[(0,t.jsx)("p",{children:pi?.guidanceMd}),(0,t.jsx)("ul",{className:"list-disc space-y-2 pl-5",children:pi?.warnings?.map($e=>(0,t.jsx)("li",{children:$e},$e))})]}),(0,t.jsx)(Cxe,{companyId:_,authKind:Si,grantKinds:Os?[Os]:pi?.grantKinds,grantKind:ba,setGrantKind:Vt,installChoice:Wt,setInstallChoice:Me,installAgentIds:kt,setInstallAgentIds:hs,lockedAgentId:i,capabilities:_n.data?.capabilities,githubIdentity:ae?.slug==="github",submitLabel:ai,continuesToProvider:to,identityLoading:!!Ur&&ei,preserveAgentAccess:!!(Ur&&(na||Hs)),pending:Ba.isPending||qt.isPending||!!(de&&!ae),onBack:la,onContinue:r(()=>{if(Jn){Tt.current=!0,Nt(null),Ue("starting"),ye("key"),na?Gn(na):rt(Jn);return}ae?ye("key"):se("key")},"onContinue")})]}),fe==="success"&&(0,t.jsx)(GGe,{appName:ca,logoUrl:ae?.branding.logoUrl,darkLogoUrl:ae?.branding.darkLogoUrl,summary:QGe({grantKind:ba,authKind:Si,installChoice:Wt,installCount:kt.size,enabledCount:Object.values(Ts).filter(Boolean).length}),onDone:v??(()=>S("/apps"))})]})}r(zGe,"StandardConnectionSetupFlow");function mK({title:e,headingRef:s,subtitle:n,step:a,activeIndex:i,labels:o,appIdentity:l,unverifiedHost:c,onCancel:d}){return(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[l?(0,t.jsx)(yc,{name:l.name,logoUrl:l.logoUrl,darkLogoUrl:l.darkLogoUrl,size:44}):null,(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{ref:s,tabIndex:s?-1:void 0,className:"text-2xl font-bold tracking-tight outline-none",children:e??(l?`Connect ${l.name}`:"Connect your own MCP server")}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:n}),c?(0,t.jsx)(eE,{host:c,className:"mt-2"}):null]})]}),d&&(0,t.jsx)(F,{variant:"ghost",size:"sm",onClick:d,children:"Cancel"})]}),a!=="gallery"&&(0,t.jsxs)("nav",{className:"mt-4","aria-label":"Setup progress","data-testid":"wizard-stepper",children:[(0,t.jsx)("ol",{className:"flex gap-2","aria-hidden":"true",children:o.map((m,h)=>(0,t.jsx)("li",{"data-testid":"wizard-step-dot","data-step-active":h===i?"true":void 0,className:z("h-1 w-20 rounded-full",h<=i?"bg-foreground":"bg-border")},m))}),(0,t.jsx)("div",{className:"mt-2 text-xs text-muted-foreground","data-testid":"wizard-step-labels",children:o.join(" · ")})]})]})}r(mK,"StepHeader");function LF({entry:e,identity:s,resuming:n=!1,phase:a,error:i,recoveryActions:o,authorizationHost:l,authorizationUrl:c,steps:d={labels:OGe,activeIndex:1},onRetry:m,onOpenAuthorization:h,onBack:p,onCancel:f}){const g=e?.name??s?.name??"this server",v=e?null:s?.unverifiedHost??null,y=a==="entry"?{title:n?`Finish connecting ${g}`:`Connect ${g} to Paperclip`,body:n?`Your connection is saved. Continue in ${g} to approve access; its identity and agent access will stay the same.`:`Paperclip will open ${g} so you can choose a workspace and approve access.`}:a==="starting"?{title:"Preparing secure sign-in",body:`Paperclip is creating a secure ${g} connection.`}:a==="redirecting"?{title:`Opening ${g}`,body:l?`Continue at ${l} to choose a workspace and approve access. Only approve access if you recognize that address.`:`Continue in ${g} to choose a workspace and approve access.`}:{title:`${g} couldn’t connect`,body:i??"Paperclip couldn’t start secure sign-in. Try again."};return(0,t.jsxs)("div",{className:"max-w-5xl",children:[(0,t.jsx)(mK,{subtitle:"Secure MCP sign-in",step:"key",activeIndex:d.activeIndex,labels:d.labels,appIdentity:e?{name:e.name,logoUrl:e.branding.logoUrl,darkLogoUrl:e.branding.darkLogoUrl}:void 0,unverifiedHost:v,onCancel:f}),(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"mt-1 inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-lg border border-border bg-background",children:a==="error"?(0,t.jsx)(oc,{className:"h-5 w-5 text-destructive"}):a==="entry"?(0,t.jsx)(Md,{className:"h-5 w-5 text-muted-foreground"}):(0,t.jsx)(it,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h2",{className:"text-xl font-bold tracking-tight",children:y.title}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:y.body}),v?(0,t.jsx)(eE,{host:v,className:"mt-2"}):null]})]}),a==="error"&&o&&(o.installationUrl||o.managementUrl)?(0,t.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[o.installationUrl?(0,t.jsx)(F,{type:"button",variant:"outline",asChild:!0,children:(0,t.jsxs)("a",{href:o.installationUrl,target:"_blank",rel:"noreferrer",children:["Install Paperclip on GitHub",(0,t.jsx)(eo,{className:"ml-1.5 h-3.5 w-3.5"})]})}):null,o.managementUrl?(0,t.jsx)(F,{type:"button",variant:"ghost",asChild:!0,children:(0,t.jsx)("a",{href:o.managementUrl,target:"_blank",rel:"noreferrer",children:"Manage repositories on GitHub"})}):null]}):null,(0,t.jsxs)("div",{className:"mt-6 flex items-center gap-2",children:[a==="error"||a==="entry"?(0,t.jsx)(F,{type:"button",onClick:m,children:a==="entry"?n?`Finish with ${g}`:`Continue to ${g}`:"Try again"}):(0,t.jsx)(F,{type:"button",disabled:!0,children:a==="redirecting"?`Opening ${g}…`:"Preparing…"}),c?(0,t.jsx)(F,{variant:"outline",asChild:!0,children:(0,t.jsx)("a",{href:c,target:"_blank",rel:"noopener noreferrer",onClick:h,children:"Open sign-in in a new tab"})}):null,(0,t.jsx)(F,{type:"button",variant:"ghost",onClick:p,children:"Back"})]})]})]})}r(LF,"OAuthConnectStateScreen");function UGe({link:e,onLinkChange:s,submitting:n,onBack:a,onConnect:i}){const o=$F(e),l=o?new URL(o).hostname:"",c=l==="zapier.com"||l.endsWith(".zapier.com");return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Zapier MCP URL"}),(0,t.jsx)(_t,{type:"password",autoComplete:"off",spellCheck:!1,value:e,onChange:r(d=>s(d.target.value),"onChange"),onKeyDown:r(d=>{d.key==="Enter"&&c&&!n&&i()},"onKeyDown"),placeholder:"https://mcp.zapier.com/api/v1/connect?token=…",className:"mt-2 h-11",autoFocus:!0}),e.trim()&&!c&&(0,t.jsx)("p",{className:"mt-2 text-xs text-destructive",children:"Paste a valid Zapier URL to continue."})]}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:a,disabled:n,children:"Back"}),(0,t.jsxs)(F,{onClick:i,disabled:n||!c,children:[n&&(0,t.jsx)(it,{className:"mr-2 h-4 w-4 animate-spin"}),n?"Checking…":"Check link"]})]})]})}r(UGe,"ZapierConnectStep");function KGe({loading:e,initialLink:s="",apps:n,byo:a=!1,byoOnly:i=!1,vercelConnect:o=!1,vercelConnectAvailability:l=null,source:c=null,onPick:d,onUseLink:m}){const[h,p]=(0,u.useState)(""),[f,g]=(0,u.useState)(s),v=(0,u.useRef)(!1);(0,u.useEffect)(()=>{v.current||g(s)},[s]);const[y,w]=(0,u.useState)(null),S=(0,u.useRef)(null),j=(0,u.useRef)(null),N=(0,u.useRef)(!1);(0,u.useEffect)(()=>{!a||e&&!i||N.current||(i||S.current?.scrollIntoView?.({block:"center"}),j.current?.focus(),j.current?.select(),N.current=!0)},[a,i,e]);const _=(0,u.useMemo)(()=>{const R=h.trim().toLowerCase();return n.filter(L=>!R||L.name.toLowerCase().includes(R))},[n,h]),A=$F(f),C=A?kR(A,n):null,I=c==="zapier",T=r(()=>{const R=$F(f);if(!R){w("Paste a full http or https link.");return}w(null),m(R)},"continueWithLink");return e&&!i?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((R,L)=>(0,t.jsx)(bn,{className:"h-32 w-full rounded-xl"},L))}):(0,t.jsxs)("div",{className:"space-y-6",children:[o?(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-bold tracking-tight",children:"Connect through Vercel"}),(0,t.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-muted-foreground",children:"Create and manage the provider connector in Vercel. Paperclip stores its reference and applies agent access, policy, approval, and audit controls here."})]}),l?(0,t.jsx)(F,{asChild:!0,variant:"outline",size:"sm",className:"shrink-0",children:(0,t.jsxs)("a",{href:l.manageUrl,target:"_blank",rel:"noreferrer",children:["Open Vercel Connect",(0,t.jsx)(eo,{className:"ml-2 h-3.5 w-3.5"})]})}):null]}),l?.available===!1?(0,t.jsx)(Ja,{tone:"danger",compact:!0,className:"mt-4",children:l.reason??"Vercel Connect is unavailable on this instance."}):null]}):null,!i&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(ha,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(_t,{value:h,onChange:r(R=>p(R.target.value),"onChange"),placeholder:"Search apps…",className:"h-11 pl-9"})]}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4",children:_.map(R=>{const L=vxe(R.slug,R.description),O=M1(R),$=O.length===0||O.every(q=>q.auth==="oauth"&&!Fp(q)&&!yR(q)),E=R.availability?.available===!1||o&&l?.available!==!0;return(0,t.jsxs)("button",{type:"button",disabled:$||E,title:E?R.availability?.reason??l?.reason??void 0:void 0,onClick:r(()=>d(R),"onClick"),className:z("flex flex-col rounded-xl border border-border bg-card p-4 text-left transition-colors",$||E?"cursor-not-allowed opacity-60":"hover:border-foreground/30 hover:bg-accent/40"),children:[(0,t.jsx)(yc,{name:R.name,logoUrl:R.branding.logoUrl,darkLogoUrl:R.branding.darkLogoUrl,size:36}),(0,t.jsx)("div",{className:"mt-3 text-sm font-bold text-foreground",children:R.name}),(0,t.jsx)("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:L.tagline}),(0,t.jsx)("div",{className:"mt-3 text-xs font-semibold text-foreground",children:E?(0,t.jsx)("span",{className:"text-muted-foreground",children:R.availability?.reason??l?.reason??"Unavailable on this instance."}):$?(0,t.jsx)("span",{className:"text-muted-foreground",children:"Unavailable"}):(0,t.jsx)("span",{children:"Connect →"})})]},R.slug)})}),_.length===0&&(0,t.jsxs)("div",{className:"py-10 text-center text-sm text-muted-foreground",children:["No apps match “",h,"”."]})]}),o?null:(0,t.jsxs)("div",{ref:S,className:z("grid gap-4 border-t border-border pt-5 md:grid-cols-(--gtc-13)",a&&"-mx-3 rounded-xl border border-primary/40 bg-primary/[0.04] px-3 pb-4 md:mx-0"),children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[(0,t.jsx)(oc,{className:"h-4 w-4 text-muted-foreground"}),I?"Connect Zapier":a?"Connect your own MCP server":"Connect with a link"]}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:I?"Paste the complete MCP URL Zapier gives you, including its token.":a?"Paste your MCP server’s URL and every discovered tool will be available immediately.":"Paste a setup link from an app that is not listed here."}),!I&&(0,t.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["Any remote tool URL works here — including a local MCP server like"," ",(0,t.jsx)("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:"http://127.0.0.1:8848/mcp"}),"."]}),C&&(0,t.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-3 rounded-lg border border-border bg-muted/40 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(yc,{name:C.name,logoUrl:C.branding.logoUrl,darkLogoUrl:C.branding.darkLogoUrl,size:24}),(0,t.jsxs)("span",{className:"truncate",children:["This looks like ",C.name,"."]})]}),(0,t.jsx)(F,{type:"button",size:"sm",variant:"outline",disabled:C.availability?.available===!1,onClick:r(()=>{if(w(null),C.slug==="zapier"){T();return}d(C)},"onClick"),children:C.availability?.available===!1?"Not available":C.slug==="zapier"?"Continue":`Use ${C.name}`})]})]}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-2 sm:min-w-(--sz-360px)",children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(_t,{ref:j,type:I||C?.slug==="zapier"?"password":"url",autoComplete:"off",spellCheck:!1,"aria-label":"MCP server URL",value:f,onChange:r(R=>{v.current=!0,g(R.target.value),w(null)},"onChange"),onKeyDown:r(R=>{R.key==="Enter"&&T()},"onKeyDown"),placeholder:I?"https://mcp.zapier.com/api/v1/connect?token=…":"https://example.com/actions",className:"h-10"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:T,children:"Continue"})]}),y&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:y})]})]})]})}r(KGe,"GalleryStep");function $F(e){try{const s=new URL(e.trim());return s.protocol!=="http:"&&s.protocol!=="https:"?null:s.toString()}catch{return null}}r($F,"normalizeAppLink");function VGe({link:e,name:s,needsKey:n,onNeedsKeyChange:a,keyValue:i,onKeyChange:o,authMode:l,onAuthModeChange:c,headers:d,onHeadersChange:m,oauthClientId:h,onOAuthClientIdChange:p,oauthClientSecret:f,onOAuthClientSecretChange:g,advancedOpen:v,onAdvancedOpenChange:y,guidance:w,matchedEntry:S,onUseMatchedEntry:j,submitting:N,onBack:_,onConnect:A}){const C=vS(e),I=l==="custom_headers"?yxe(d):null,T=SGe({link:e,name:s,authMode:l,needsKey:n,keyValue:i,headers:d,oauthClientId:h,oauthClientSecret:f}),R=l==="auto",L=S?.slug==="zapier"?mle(e):e,O=r(($,E)=>{m(d.map(q=>q.id===$?{...q,...E}:q))},"updateHeader");return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("p",{className:"min-w-0 truncate font-mono text-sm text-muted-foreground",title:L,children:L}),(0,t.jsx)(eE,{host:C})]}),S&&j?(0,t.jsxs)("div",{className:"mt-6 flex flex-wrap items-center justify-between gap-3 rounded-lg border border-border bg-muted/40 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,t.jsx)(yc,{name:S.name,logoUrl:S.branding.logoUrl,darkLogoUrl:S.branding.darkLogoUrl,size:24}),(0,t.jsxs)("span",{className:"truncate",children:["Paperclip has a guided setup for ",S.name,"."]})]}),(0,t.jsxs)(F,{type:"button",size:"sm",variant:"outline",onClick:j,children:["Use ",S.name]})]}):null,w?(0,t.jsx)("div",{className:"mt-6",children:(0,t.jsx)(Ja,{tone:"warning",title:w.title,children:w.body})}):null,(0,t.jsxs)("div",{className:"mt-6 space-y-6",children:[R&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mr-2 text-sm font-medium text-foreground",children:"Does it need a key?"}),(0,t.jsxs)("div",{className:"mt-2 inline-flex rounded-lg border border-border bg-muted/50 p-1",children:[(0,t.jsx)($4,{label:"No",selected:!n,onClick:r(()=>a(!1),"onClick")}),(0,t.jsx)($4,{label:"Yes",selected:n,onClick:r(()=>a(!0),"onClick")})]}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:n?"Paste the key this app gave you.":"Most servers just work from the address — pick Yes only if the server gave you a key, or if it asks you to sign in."})]}),R&&n||l==="bearer"?(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"generic-mcp-key",children:"App key"}),(0,t.jsx)(_t,{id:"generic-mcp-key",type:"password",autoComplete:"off",value:i,onChange:r($=>o($.target.value),"onChange"),placeholder:"••••••••••••••••",className:"mt-2 h-11 font-mono"})]})}):null,(0,t.jsxs)(el,{open:v,onOpenChange:y,children:[(0,t.jsxs)(Wl,{className:"flex w-full items-center justify-between rounded-lg border border-border bg-background px-3 py-2 text-left text-sm font-medium text-foreground hover:bg-accent/40",children:["Advanced authentication",(0,t.jsx)(en,{className:z("h-4 w-4 text-muted-foreground transition-transform",v&&"rotate-180")})]}),(0,t.jsxs)(tl,{className:"space-y-5 pt-4",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Only needed when the server's docs are specific about how to authenticate."}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:hJ.map($=>(0,t.jsx)($4,{label:$.label,selected:l===$.mode,onClick:r(()=>c($.mode),"onClick")},$.mode))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:hJ.find($=>$.mode===l)?.hint}),l==="custom_headers"?(0,t.jsxs)("div",{className:"space-y-3",children:[d.map($=>(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(_t,{value:$.name,onChange:r(E=>O($.id,{name:E.target.value}),"onChange"),placeholder:"Header name","aria-label":"Header name",className:"h-10 font-mono"}),(0,t.jsx)(_t,{type:"password",autoComplete:"off",value:$.value,onChange:r(E=>O($.id,{value:E.target.value}),"onChange"),placeholder:"Value","aria-label":$.name.trim()?`Value for ${$.name.trim()}`:"Header value",className:"h-10 font-mono"}),(0,t.jsx)(F,{type:"button",variant:"ghost",size:"sm",className:"h-10 shrink-0",onClick:r(()=>m(d.filter(E=>E.id!==$.id)),"onClick"),disabled:d.length===1,children:"Remove"})]},$.id)),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",onClick:r(()=>m([...d,DF()]),"onClick"),children:"Add another header"}),I?(0,t.jsx)("p",{className:"text-xs text-destructive",children:I}):null]}):null,l==="oauth"?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Paperclip sets sign-in up on its own whenever the server allows it. Only fill these in when the server's docs tell you to register Paperclip yourself first."}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"generic-mcp-client-id",children:"Client ID"}),(0,t.jsx)(_t,{id:"generic-mcp-client-id",value:h,onChange:r($=>p($.target.value),"onChange"),autoComplete:"off",placeholder:"Optional",className:"mt-2 h-11 font-mono"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"generic-mcp-client-secret",children:"Client secret"}),(0,t.jsx)(_t,{id:"generic-mcp-client-secret",type:"password",autoComplete:"off",value:f,onChange:r($=>g($.target.value),"onChange"),placeholder:"Optional",className:"mt-2 h-11 font-mono"})]})]}):null]})]})]}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:_,disabled:N,children:"Back"}),(0,t.jsxs)(F,{onClick:A,disabled:N||!T||!!I,children:[N&&(0,t.jsx)(it,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":"Check link"]})]})]})}r(VGe,"LinkConnectStep");var hJ=[{mode:"auto",label:"Let Paperclip check",hint:"Paperclip asks the server what it needs and walks you through it. Start here."},{mode:"none",label:"No sign-in needed",hint:"The server is open to anyone with the address."},{mode:"bearer",label:"Key or token",hint:"Paperclip sends your key as an Authorization header."},{mode:"custom_headers",label:"Custom headers",hint:"For servers that name their own headers. Values are stored as Paperclip secrets and can’t be read back."},{mode:"oauth",label:"Browser sign-in",hint:"You’ll sign in at the provider. Add a client ID and secret only if the provider requires you to register Paperclip first."}];function $4({label:e,selected:s,onClick:n}){return(0,t.jsx)("button",{type:"button",onClick:n,"aria-pressed":s,className:z("min-w-(--sz-64px) rounded-md px-4 py-1.5 text-sm font-medium transition-colors",s?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:e})}r($4,"SegmentedOption");function WGe({entry:e,error:s,values:n,onChange:a,oauthClientId:i,onOAuthClientIdChange:o,oauthClientSecret:l,onOAuthClientSecretChange:c,credentialSource:d,vercelConnector:m,onVercelConnectorChange:h,vercelConnectAvailability:p,methodKey:f,onMethodChange:g,configValues:v,onConfigChange:y,googleSheetsLinks:w,googleSheetsError:S,onGoogleSheetsLinksChange:j,submitting:N,onBack:_,onConnect:A}){const C=(0,u.useMemo)(()=>Ky(e,d),[d,e]),I=f?C.find(Oe=>Oe.key===f)??null:Ij(C),T=(0,u.useMemo)(()=>C.some(Oe=>Oe.capabilityProfile)?Array.from(C.reduce((Oe,Xe)=>{const me=Xe.capabilityProfile.key,Le=Oe.get(me);return Le?Le.methods.push(Xe):Oe.set(me,{key:me,label:Xe.capabilityProfile?.label??Xe.label??Xe.key,description:Xe.capabilityProfile?.description??Xe.whenToUse,methods:[Xe]}),Oe},new Map)).map(([,Oe])=>Oe):[],[C]),R=I?.capabilityProfile?.key??I?.key??"",L=T.map(Oe=>Oe.key).join("|"),[O,$]=(0,u.useState)(R||Ij(C)?.capabilityProfile?.key||(T.length===1?T[0].key:""));(0,u.useEffect)(()=>{if(R){$(R);return}$(Oe=>T.some(Xe=>Xe.key===Oe)?Oe:Ij(C)?.capabilityProfile?.key||(T.length===1?T[0].key:""))},[L,T,C,R]);const E=T.length>1?T.find(Oe=>Oe.key===O)?.methods??[]:C,q=(I?.credentialFields??[]).map(Oe=>({...Oe,configPath:ule(Oe),helpUrl:I?.consoleLinks?.keys??I?.consoleLinks?.docs??""})),B=I?.credentialSources?.vercelConnect??null,K=d==="vercel_connect",U=K||q.every(Oe=>Oe.required===!1||(n[Oe.configPath]?.trim().length??0)>0),D=yR(I),V=D&&!Fp(I),H=K||!V||i.trim().length>0,J=!K||m.trim().length>0,X=I?.auth==="oauth"&&D?NGe():null,le=[...I?.tenantFields??[],...I?.extensionFields??[]],ce=le.filter(Oe=>!Oe.hidden),te=ce.filter(Oe=>Oe.advanced!==!0),re=ce.filter(Oe=>Oe.advanced===!0),[de,Z]=(0,u.useState)(!1),Y=le.every(Oe=>{if(!Oe.required)return!0;const Xe=v[Oe.key];return typeof Xe=="boolean"||typeof Xe=="string"&&Xe.trim().length>0}),G=I?.configRequirements?.atLeastOneOf??[],fe=G.length===0||G.some(Oe=>{const Xe=v[Oe];return typeof Xe=="string"&&Xe.trim().length>0}),se=(T.length<=1||!!O)&&(E.length<=1?!!I:!!f),ae=e.availability?.robotEmail??null,ie=e.availability?.available===!1,ue=!K&&D&&!V,pe=re.length>0||ue,be=T.length>1?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"What should Paperclip be able to do?"}),(0,t.jsx)(uu,{ariaLabel:`Access level for ${e.name}`,className:"mt-2",value:O,onValueChange:r(Oe=>{const Xe=T.find(me=>me.key===Oe);Xe&&($(Oe),g(Z6(Xe.methods)))},"onValueChange"),options:T.map(Oe=>({value:Oe.key,title:Oe.label,description:Oe.description}))}),!O&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Choose an access level to continue."})]}):null,oe=E.find(Oe=>Oe.oauthStrategy==="paperclip_cloud_connector"&&tIe(Oe.connectorProfile??"")),je=oe&&E.find(Oe=>yR(Oe)&&!Fp(Oe)),_e=I?.key===je?.key,xe=(0,u.useId)(),Ae=oe&&je&&E.length===2?(0,t.jsx)(F,{type:"button",variant:"link",className:"h-auto p-0 text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground","aria-expanded":_e,"aria-controls":xe,disabled:N,onClick:r(()=>g(_e?oe:je),"onClick"),children:_e?"Use Paperclip instead":"Use your own Google OAuth app"}):E.length>1?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"How do you want to connect?"}),(0,t.jsx)(uu,{ariaLabel:`How to connect ${e.name}`,className:"mt-2",value:f,onValueChange:r(Oe=>{const Xe=E.find(me=>me.key===Oe);Xe&&g(Xe)},"onValueChange"),options:E.map(Oe=>({value:Oe.key,title:Oe.label??(Oe.auth==="oauth"?`Sign in with ${e.name}`:"Use an API key")}))}),!I&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Choose a connection method to continue."})]}):null;if(Mk(e,I)){const Oe=qO(w),Xe=!ie&&!!ae&&w.trim().length>0;return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[(0,t.jsxs)("div",{className:"space-y-6",children:[be,ae?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Share each sheet with this email"}),(0,t.jsxs)("div",{className:"mt-2 flex min-w-0 flex-col gap-2 sm:flex-row",children:[(0,t.jsx)("div",{title:ae,className:"min-h-11 min-w-0 flex-1 rounded-md border border-input bg-muted/40 px-3 py-2.5 font-mono text-xs leading-tight text-foreground break-all",children:ae}),(0,t.jsx)(Sxe,{value:ae,ariaLabel:"Copy sharing email"})]}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"In Google Sheets, click Share and add this email as an Editor. Then paste the sheet links below."})]}):(0,t.jsx)("div",{className:"rounded-lg bg-muted/50 p-4 text-sm text-muted-foreground",children:"Google Sheets is not available on this instance yet."}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Paste links to the sheets you shared"}),(0,t.jsx)(En,{value:w,onChange:r(me=>j(me.target.value),"onChange"),placeholder:"https://docs.google.com/spreadsheets/d/...",className:"mt-2 min-h-28"}),(0,t.jsx)("div",{className:"mt-2 text-xs text-muted-foreground",children:Oe.ids.length>0?`${Oe.ids.length} ${Oe.ids.length===1?"sheet":"sheets"} ready to connect.`:"Paste one link per line. Both .../edit and .../edit#gid=... links work."}),S&&(0,t.jsx)("div",{className:"mt-2 text-xs text-destructive",children:S})]})]}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:_,disabled:N,children:"Back"}),(0,t.jsxs)(F,{onClick:A,disabled:N||!Xe,children:[N&&(0,t.jsx)(it,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":"Connect"]})]})]})}const Ye=I?.consoleLinks?.docs??e.docsUrl;return(0,t.jsxs)("div",{className:"mx-auto max-w-xl",children:[Ye?(0,t.jsx)("div",{className:"mb-4 flex justify-end",children:(0,t.jsxs)("a",{href:Ye,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs font-medium text-muted-foreground underline underline-offset-2 hover:text-foreground",children:["Review requirements",(0,t.jsx)(eo,{className:"h-3 w-3"})]})}):null,(0,t.jsxs)("div",{className:"space-y-6",children:[be,Ae,K&&B&&p?(0,t.jsxs)("div",{className:"space-y-4 rounded-lg border border-border p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Create or attach the connector in Vercel"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Paperclip does not copy Vercel’s setup forms. Finish connector setup there, then paste its UID below."}),(0,t.jsxs)("a",{href:p.manageUrl,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2",children:["Open Vercel Connect",(0,t.jsx)(eo,{className:"h-3 w-3"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"vercel-connect-connector",children:"Connector UID or ID"}),(0,t.jsx)(_t,{id:"vercel-connect-connector",value:m,onChange:r(Oe=>h(Oe.target.value),"onChange"),autoComplete:"off",placeholder:"service/my-connector or scl_…",className:"mt-2 h-11 font-mono"}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Paperclip validates the connector and stores only its reference and redacted verification metadata."})]})]}):null,s?(0,t.jsx)("div",{role:"alert",children:(0,t.jsx)(Ja,{tone:"danger",children:s})}):null,te.map(Oe=>(0,t.jsx)(fJ,{field:Oe,value:v[Oe.key],onChange:r(Xe=>y({...v,[Oe.key]:Xe}),"onChange")},Oe.key)),pe&&(0,t.jsxs)(el,{open:de,onOpenChange:Z,children:[(0,t.jsxs)(Wl,{className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[(0,t.jsx)(en,{className:z("h-4 w-4 transition-transform",de&&"rotate-180")}),"Advanced"]}),(0,t.jsx)(tl,{className:"pt-4",children:(0,t.jsxs)("div",{className:"space-y-6",children:[re.map(Oe=>(0,t.jsx)(fJ,{field:Oe,value:v[Oe.key],onChange:r(Xe=>y({...v,[Oe.key]:Xe}),"onChange")},Oe.key)),ue?(0,t.jsx)(pJ,{entry:e,method:I,callbackUrl:X,clientId:i,onClientIdChange:o,clientSecret:l,onClientSecretChange:c,required:!1}):null]})})]}),!K&&I?.auth==="oauth"&&V?(0,t.jsx)("div",{id:xe,role:"region","aria-label":"Your OAuth app",children:(0,t.jsx)(pJ,{entry:e,method:I,callbackUrl:X,clientId:i,onClientIdChange:o,clientSecret:l,onClientSecretChange:c,required:!0})}):null,K||!I||q.length===0?null:q.map(Oe=>(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:XY(e.name,Oe.label,q.length)}),(0,t.jsx)(_t,{type:"password","aria-label":XY(e.name,Oe.label,q.length),autoComplete:"off",value:n[Oe.configPath]??"",onChange:r(Xe=>a({...n,[Oe.configPath]:Xe.target.value}),"onChange"),placeholder:"••••••••••••••••",className:"mt-2 h-11 font-mono"}),Oe.helpUrl&&(0,t.jsxs)("a",{href:Oe.helpUrl,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2",children:["Where do I find this?",(0,t.jsx)(eo,{className:"h-3 w-3"})]})]},Oe.configPath))]}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)(F,{variant:"ghost",onClick:_,disabled:N,children:"Back"}),(0,t.jsxs)(F,{onClick:A,disabled:N||!se||!U||!H||!J||!Y||!fe,children:[N&&(0,t.jsx)(it,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":K?I?.auth==="oauth"?"Validate and continue":"Validate and connect":I?.auth==="oauth"?e.slug==="github"?"Continue to GitHub":"Continue to sign in":"Connect"]})]})]})}r(WGe,"KeyStep");function Sxe({value:e,ariaLabel:s}){const{copied:n,failed:a,copy:i}=uf();return(0,t.jsxs)(F,{type:"button",variant:"outline",className:"shrink-0","aria-label":s,onClick:r(()=>{i(e)},"onClick"),children:[n?(0,t.jsx)(fs,{className:"mr-2 h-4 w-4"}):(0,t.jsx)(jr,{className:"mr-2 h-4 w-4"}),n?"Copied":a?"Copy failed":"Copy"]})}r(Sxe,"CopyValueButton");function pJ({entry:e,method:s,callbackUrl:n,clientId:a,onClientIdChange:i,clientSecret:o,onClientSecretChange:l,required:c}){return(0,t.jsxs)("div",{className:"space-y-4 rounded-lg border border-border p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:c?"Your OAuth app":"Use your own OAuth app"}),(0,t.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["Register Paperclip's callback URI in ",e.name,", then enter the customer-owned client details."]}),s.consoleLinks?.register?(0,t.jsxs)("a",{href:s.consoleLinks.register,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2",children:["Open ",e.name," app settings",(0,t.jsx)(eo,{className:"h-3 w-3"})]}):null]}),n?(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Paperclip callback URL"}),(0,t.jsxs)("div",{className:"mt-2 flex min-w-0 flex-col gap-2 sm:flex-row",children:[(0,t.jsx)("div",{title:n,className:"min-h-11 min-w-0 flex-1 rounded-md border border-input bg-muted/40 px-3 py-2.5 font-mono text-xs leading-tight text-foreground break-all",children:n}),(0,t.jsx)(Sxe,{value:n,ariaLabel:"Copy callback URL"})]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Add this exact URL to ",e.name," before continuing. It must match the authorization request."]})]}):null,(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"curated-oauth-client-id",children:"Client ID"}),(0,t.jsx)(_t,{id:"curated-oauth-client-id",value:a,onChange:r(d=>i(d.target.value),"onChange"),autoComplete:"off",placeholder:c?"Required":"Optional",className:"mt-2 h-11 font-mono"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",htmlFor:"curated-oauth-client-secret",children:"Client secret"}),(0,t.jsx)(_t,{id:"curated-oauth-client-secret",type:"password",value:o,onChange:r(d=>l(d.target.value),"onChange"),autoComplete:"off",placeholder:"Optional for public clients",className:"mt-2 h-11 font-mono"})]})]})}r(pJ,"OAuthClientFields");function fJ({field:e,value:s,onChange:n}){return e.type==="checkbox"?(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4 rounded-lg border border-border p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:e.label}),e.helperMd&&(0,t.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:e.helperMd})]}),(0,t.jsx)(_i,{checked:s===!0,onCheckedChange:n})]}):(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:e.label}),e.type==="textarea"?(0,t.jsx)(En,{value:typeof s=="string"?s:"",onChange:r(a=>n(a.target.value),"onChange"),placeholder:e.placeholder,className:"mt-2 min-h-24"}):e.type==="select"?(0,t.jsxs)("select",{value:typeof s=="string"?s:"",onChange:r(a=>n(a.target.value),"onChange"),className:"mt-2 h-11 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30",children:[(0,t.jsx)("option",{value:"",disabled:!0,children:"Select an option"}),(e.options??[]).map(a=>(0,t.jsx)("option",{value:a.value,children:a.label},a.value))]}):(0,t.jsx)(_t,{value:typeof s=="string"?s:"",onChange:r(a=>n(a.target.value),"onChange"),placeholder:e.placeholder,className:"mt-2 h-11"}),e.helperMd&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:e.helperMd})]})}r(fJ,"MethodConfigField");function Cxe({companyId:e,...s}){const n=ee({queryKey:P.agents.list(e),queryFn:r(()=>zt.list(e),"queryFn")});return(0,t.jsx)(_xe,{...s,agents:(n.data??[]).filter(a=>a.status!=="terminated"),agentsLoading:n.isLoading})}r(Cxe,"AccessStep");function _xe({agents:e,agentsLoading:s=!1,authKind:n,grantKinds:a,grantKind:i,setGrantKind:o,installChoice:l,setInstallChoice:c,installAgentIds:d,setInstallAgentIds:m,lockedAgentId:h,capabilities:p,githubIdentity:f=!1,submitLabel:g,continuesToProvider:v=!1,identityLoading:y=!1,preserveAgentAccess:w=!1,pending:S=!1,onBack:j,onContinue:N}){const _=p?.editableAgentIds,A=_?e.filter(B=>_.includes(B.id)):e,C=p?.canSetCompanyInstall??!0,I=p?.canCreateOrganizationGrant??!0,T=n!=="none",R=a??["user","organization"],L=(!T||i==="user"||i==="agent"||I)&&(w?!0:h?d.has(h):i==="agent"?l==="specific"&&d.size===1:l==="all"?C:d.size>0),O=h?e.find(B=>B.id===h)?.name??"the requesting agent":null,$=f?"Connect GitHub as":"Which humans can use this credential?",E=i==="agent"?"Which agent owns this GitHub account?":f&&i==="user"?"Which agents may use your GitHub when you’re responsible?":f?"Which agents may use the shared GitHub account?":"Which agents can use this connection?",q=f?E:"Which agents can use this connection?";return(0,t.jsxs)("div",{className:"mx-auto max-w-2xl",children:[(0,t.jsx)("div",{className:"overflow-hidden rounded-xl border border-border",children:(0,t.jsxs)("div",{className:"divide-y divide-border",children:[(0,t.jsxs)("section",{className:"p-6",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:$}),f&&i==="agent"?(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This agent uses this GitHub account for everyone’s work, instead of the person giving instructions."}):null,y?(0,t.jsxs)("div",{className:"mt-4 grid gap-2 sm:grid-cols-2","aria-label":"Loading connection identity",children:[(0,t.jsx)(bn,{className:"h-20 w-full rounded-md"}),(0,t.jsx)(bn,{className:"h-20 w-full rounded-md"})]}):T&&R.length===1?(0,t.jsxs)("div",{className:"mt-4 flex items-center gap-3 rounded-md border border-border p-4",children:[R[0]==="user"?(0,t.jsx)(vu,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):R[0]==="agent"?(0,t.jsx)(Xi,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):(0,t.jsx)(yj,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:R[0]==="user"?f?"My GitHub account":"Just me":R[0]==="agent"?"A dedicated account for an agent":f?"Shared organization GitHub account (advanced)":"Any human in the organization"}),f?(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:R[0]==="user"?"Agents use it only for runs where you are the responsible person.":R[0]==="agent"?"That agent always uses this account, regardless of who starts the run.":"Eligible agents use one shared credential, regardless of who starts the run."}):null]})]}):T?(0,t.jsx)(uu,{ariaLabel:f?$:"Which humans can use this credential?",className:"mt-4 sm:grid-cols-2",value:i,onValueChange:r(B=>{const K=B;o(K),K==="agent"&&(c("specific"),d.size>1&&m(new Set([[...d][0]])))},"onValueChange"),options:[{value:"user",title:f?"My GitHub account":"Just me",description:f?"Agents use it only for runs where you are the responsible person.":void 0,icon:(0,t.jsx)(vu,{className:"h-4 w-4","aria-hidden":"true"})},{value:"agent",title:"A dedicated account for an agent",description:f?"That agent always uses this account, regardless of who starts the run.":void 0,icon:(0,t.jsx)(Xi,{className:"h-4 w-4","aria-hidden":"true"})},{value:"organization",title:f?"Shared organization GitHub account (advanced)":"Any human in the organization",description:f?"Eligible agents use one shared credential, regardless of who starts the run.":void 0,icon:(0,t.jsx)(yj,{className:"h-4 w-4","aria-hidden":"true"}),accessibleLabel:I?f?"Shared organization GitHub account (advanced)":"Any human in the organization":`${f?"Shared organization GitHub account (advanced)":"Any human in the organization"}. Unavailable: ${p?.organizationGrantReason??"Only a connection manager can share this credential with the organization."}`,tooltip:I?void 0:p?.organizationGrantReason??"Only a connection manager can share this credential with the organization.",disabled:!I}].filter(B=>R.includes(B.value))}):(0,t.jsx)("p",{className:"mt-4 text-sm text-muted-foreground",children:"No identity required"})]}),(0,t.jsxs)("section",{className:"p-6",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:E}),w?(0,t.jsxs)("div",{className:"mt-4 flex items-start gap-3 rounded-md border border-border bg-muted/40 p-4",children:[(0,t.jsx)(yj,{className:"mt-0.5 h-4 w-4 shrink-0 text-primary","aria-hidden":"true"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Existing agent access stays the same"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Reconnecting replaces the credential without changing which agents can use it."})]})]}):h?(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["This task grants access only to ",(0,t.jsx)("span",{className:"font-medium text-foreground",children:O}),". Existing connection access is left unchanged."]}):i==="agent"?(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Choose exactly one agent. This identity cannot be shared with other agents."}):(0,t.jsx)(uu,{ariaLabel:q,className:"mt-4 sm:grid-cols-2",value:l,onValueChange:r(B=>c(B),"onValueChange"),options:[{value:"specific",title:f?"Only agents I choose":"Just agents I pick",description:f?i==="user"?"Only selected agents may use your GitHub when you’re responsible.":"Only selected agents may use the shared account.":void 0,icon:(0,t.jsx)(Xi,{className:"h-4 w-4","aria-hidden":"true"})},{value:"all",title:"Any agent",description:f?i==="user"?"Every agent may use your GitHub when you’re responsible.":"Every agent may use the shared account.":void 0,icon:(0,t.jsx)(HGe,{}),accessibleLabel:C?"Any agent":`Any agent. Unavailable: ${p?.companyInstallReason??"Only someone who can configure this connection can choose this."}`,tooltip:C?void 0:p?.companyInstallReason??"Only someone who can configure this connection can choose this.",disabled:!C}]}),!w&&!h&&l==="specific"?(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)(kv,{agents:A,selectedAgentIds:d,onChange:r(B=>m(i==="agent"&&B.size>1?new Set([[...B].at(-1)]):B),"onChange"),loading:s,emptyMessage:"You cannot edit any agents yet.",showSelectionPreview:!1})}):null]})]})}),(0,t.jsxs)("div",{className:"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsx)(F,{variant:"ghost",className:"w-full sm:w-auto",onClick:j,disabled:S,children:"Back"}),(0,t.jsxs)(F,{className:"w-full sm:w-auto",onClick:N,disabled:!L||y||S,children:[S?(0,t.jsx)(it,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):null,g,!S&&v?(0,t.jsx)(eo,{className:"h-4 w-4","aria-hidden":"true"}):null]})]})]})}r(_xe,"AccessStepContent");function HGe(){return(0,t.jsxs)("span",{className:"relative block h-4 w-5","aria-hidden":"true",children:[(0,t.jsx)(Xi,{className:"absolute left-0 top-0 h-3.5 w-3.5"}),(0,t.jsx)(Xi,{className:"absolute bottom-0 right-0 h-3.5 w-3.5"})]})}r(HGe,"BotGroupIcon");function QGe(e){const s=e.authKind==="none"?"No identity required":e.grantKind==="user"?"Your identity":e.grantKind==="agent"?"Dedicated agent identity":"Organization identity",n=e.installChoice==="all"?"Any agent":`${e.installCount} selected ${e.installCount===1?"agent":"agents"}`;return[{label:"Identity",value:s},{label:"Available to",value:n},{label:"Actions",value:`${e.enabledCount} ${e.enabledCount===1?"action":"actions"} on`}]}r(QGe,"accessSummaryLines");function GGe({appName:e,logoUrl:s,darkLogoUrl:n,summary:a,onDone:i}){return(0,t.jsxs)("div",{className:"mx-auto max-w-md py-10 text-center",children:[(0,t.jsx)("div",{className:"mx-auto flex h-20 w-20 items-center justify-center rounded-full border-2 border-emerald-500 bg-emerald-500/10",children:(0,t.jsx)(fs,{className:"h-9 w-9 text-emerald-600 dark:text-emerald-400"})}),(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-center gap-2",children:[(0,t.jsx)(yc,{name:e,logoUrl:s,darkLogoUrl:n,size:28}),(0,t.jsxs)("h2",{className:"text-2xl font-bold tracking-tight",children:[e," is ready."]})]}),(0,t.jsx)("dl",{className:"mx-auto mt-6 max-w-xs space-y-1 text-left",children:a.map(o=>(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-4",children:[(0,t.jsx)("dt",{className:"text-xs font-medium text-muted-foreground",children:o.label}),(0,t.jsx)("dd",{className:"text-sm text-foreground",children:o.value})]},o.label))}),(0,t.jsx)("div",{className:"mt-8",children:(0,t.jsx)(F,{size:"lg",className:"px-10",onClick:i,children:"View connection"})})]})}r(GGe,"ConnectionSetupCompletionScreen");function Ixe(){const{newProjectOpen:e,closeNewProject:s}=c1(),{selectedCompanyId:n}=xs();return n&&e?(0,t.jsx)(YGe,{companyId:n,onClose:s},n):null}r(Ixe,"NewProjectDialog");function YGe({companyId:e,onClose:s}){const n=Kt(),[a,i]=(0,u.useState)(""),[o,l]=(0,u.useState)([]),[c,d]=(0,u.useState)(!1),m=(0,u.useRef)(null),h=ke({mutationFn:r(()=>ia.create(e,{name:a.trim(),status:"planned",repositoryIds:o.map(p=>p.id)}),"mutationFn"),onSuccess:r(()=>{n.invalidateQueries({queryKey:P.projects.all(e)}),s()},"onSuccess")});return(0,t.jsx)(Js,{open:!0,onOpenChange:r(p=>{!p&&!h.isPending&&s()},"onOpenChange"),children:(0,t.jsx)(Zs,{showCloseButton:!1,"aria-describedby":void 0,className:"flex max-h-(--sz-calc-18) flex-col gap-0 overflow-hidden p-0 shadow-sm sm:max-w-lg",onOpenAutoFocus:r(p=>{p.preventDefault(),m.current?.focus()},"onOpenAutoFocus"),children:c?(0,t.jsxs)("div",{className:"min-h-0 overflow-y-auto p-5",children:[(0,t.jsx)(rn,{className:"sr-only",children:"Connect GitHub"}),(0,t.jsx)(sE,{host:"dialog",serviceSlug:"github",forceNewConnection:!0,onCancel:r(()=>d(!1),"onCancel"),onComplete:r(()=>{n.invalidateQueries({queryKey:hU(e)}),d(!1)},"onComplete")})]}):(0,t.jsxs)("form",{className:"flex min-h-0 flex-col overflow-hidden",onSubmit:r(p=>{p.preventDefault(),a.trim()&&!h.isPending&&h.mutate()},"onSubmit"),children:[(0,t.jsxs)("div",{className:"flex shrink-0 flex-col gap-4 px-5 pb-4 pt-5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)(rn,{className:"text-lg font-semibold",children:"Create project"}),(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-sm",disabled:h.isPending,"aria-label":"Close new project",onClick:s,children:(0,t.jsx)(ir,{className:"size-4"})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-input px-3 focus-within:border-ring focus-within:ring-1 focus-within:ring-ring",children:[(0,t.jsx)(Kc,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,t.jsx)("input",{ref:m,"aria-label":"Project name",value:a,disabled:h.isPending,onChange:r(p=>i(p.target.value),"onChange"),placeholder:"Project name",required:!0,className:"h-10 w-full min-w-0 border-0 bg-transparent text-base outline-none placeholder:text-muted-foreground md:text-sm"})]})]}),(0,t.jsx)("div",{role:"region","aria-label":"Source repositories",tabIndex:0,className:"min-h-0 overflow-y-auto overscroll-contain px-5 pb-1 outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring",children:(0,t.jsx)(Qme,{companyId:e,selected:o,onChange:l,onConnect:r(()=>d(!0),"onConnect"),disabled:h.isPending})}),h.isError&&(0,t.jsx)("p",{role:"alert",className:"px-5 pt-3 text-sm text-destructive",children:h.error.message}),(0,t.jsxs)("div",{className:"flex shrink-0 justify-end gap-2 px-5 py-5",children:[(0,t.jsx)(F,{type:"button",variant:"ghost",disabled:h.isPending,onClick:s,children:"Cancel"}),(0,t.jsx)(F,{type:"submit",disabled:!a.trim()||h.isPending,children:h.isPending?"Creating…":"Create project"})]})]})})})}r(YGe,"NewProjectForm");var xx={list:r(e=>Re.get(`/companies/${e}/goals`),"list"),get:r(e=>Re.get(`/goals/${e}`),"get"),create:r((e,s)=>Re.post(`/companies/${e}/goals`,s),"create"),update:r((e,s)=>Re.patch(`/goals/${e}`,s),"update"),remove:r(e=>Re.delete(`/goals/${e}`),"remove")};function Axe(e){return{"--sc":`var(${e})`}}r(Axe,"scStyle");function JGe(e){const s=e.replace(/_/g," ");return s.charAt(0).toUpperCase()+s.slice(1)}r(JGe,"sentenceCaseStatus");function ni({status:e,label:s}){return(0,t.jsx)("span",{className:z("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap shrink-0",X$[e]??"bg-muted text-muted-foreground"),children:s??e.replace(/[_-]/g," ")})}r(ni,"StatusBadge$5");function Rxe({status:e}){const s=H2e[e]??"--status-agent-idle",n=e==="active"?"idle":e;return(0,t.jsx)("span",{className:"status-chip inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium leading-none whitespace-nowrap shrink-0",style:Axe(s),children:n.replace(/_/g," ")})}r(Rxe,"AgentStatusBadge");function Tp({status:e,externalConversationState:s}){const n=e==="in_review"&&s==="waiting"?"idle":e,a=z2e[n]??"--status-task-backlog";return(0,t.jsxs)("span",{className:z("status-chip inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-normal leading-none whitespace-nowrap shrink-0",n==="cancelled"&&"line-through"),style:Axe(a),children:[(0,t.jsx)(o1,{status:n,size:"sm"}),JGe(n)]})}r(Tp,"IssueStatusBadge");var xJ={company:"Organization",team:"Team",agent:"Agent",task:"Task"};function Txe(){const{newGoalOpen:e,newGoalDefaults:s,closeNewGoal:n}=c1(),{selectedCompanyId:a,selectedCompany:i}=xs(),o=Kt(),[l,c]=(0,u.useState)(""),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)("planned"),[f,g]=(0,u.useState)("task"),[v,y]=(0,u.useState)(""),[w,S]=(0,u.useState)(!1),[j,N]=(0,u.useState)(!1),[_,A]=(0,u.useState)(!1),[C,I]=(0,u.useState)(!1),T=(0,u.useRef)(null),R=v||s.parentId||"",{data:L}=ee({queryKey:P.goals.list(a),queryFn:r(()=>xx.list(a),"queryFn"),enabled:!!a&&e}),O=ke({mutationFn:r(U=>xx.create(a,U),"mutationFn"),onSuccess:r(()=>{o.invalidateQueries({queryKey:P.goals.list(a)}),E(),n()},"onSuccess")}),$=ke({mutationFn:r(async U=>{if(!a)throw new Error("No organization selected");return d0.uploadImage(a,U,"goals/drafts")},"mutationFn")});function E(){c(""),m(""),p("planned"),g("task"),y(""),S(!1)}r(E,"reset");function q(){!a||!l.trim()||O.mutate({title:l.trim(),description:d.trim()||void 0,status:h,level:f,...R?{parentId:R}:{}})}r(q,"handleSubmit");function B(U){U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&(U.preventDefault(),q())}r(B,"handleKeyDown");const K=(L??[]).find(U=>U.id===R);return(0,t.jsx)(Js,{open:e,onOpenChange:r(U=>{U||(E(),n())},"onOpenChange"),children:(0,t.jsxs)(Zs,{showCloseButton:!1,className:z("p-0 gap-0",w?"sm:max-w-2xl":"sm:max-w-lg"),onKeyDown:B,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[i&&(0,t.jsx)("span",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-medium",children:i.issuePrefix}),(0,t.jsx)("span",{className:"text-muted-foreground/60",children:"›"}),(0,t.jsx)("span",{children:s.parentId?"New sub-goal":"New goal"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:r(()=>S(!w),"onClick"),children:w?(0,t.jsx)(Sz,{className:"h-3.5 w-3.5"}):(0,t.jsx)(i0,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:r(()=>{E(),n()},"onClick"),children:(0,t.jsx)("span",{className:"text-lg leading-none",children:"×"})})]})]}),(0,t.jsx)("div",{className:"px-4 pt-4 pb-2 shrink-0",children:(0,t.jsx)("input",{className:"w-full text-lg font-semibold bg-transparent outline-none placeholder:text-muted-foreground/50",placeholder:"Goal title",value:l,onChange:r(U=>c(U.target.value),"onChange"),onKeyDown:r(U=>{U.key==="Tab"&&!U.shiftKey&&(U.preventDefault(),T.current?.focus())},"onKeyDown"),autoFocus:!0})}),(0,t.jsx)("div",{className:"px-4 pb-2 overflow-y-auto max-h-(--sz-50vh)",children:(0,t.jsx)(wc,{ref:T,value:d,onChange:m,placeholder:"Add description...",bordered:!1,contentClassName:z("text-sm text-muted-foreground",w?"min-h-(--sz-220px)":"min-h-(--sz-120px)"),imageUploadHandler:r(async U=>(await $.mutateAsync(U)).contentPath,"imageUploadHandler")})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-4 py-2 border-t border-border flex-wrap",children:[(0,t.jsxs)(nr,{open:j,onOpenChange:N,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsx)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:(0,t.jsx)(ni,{status:h})})}),(0,t.jsx)(Wn,{className:"w-40 p-1",align:"start",children:lle.map(U=>(0,t.jsx)("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 capitalize",U===h&&"bg-accent"),onClick:r(()=>{p(U),N(!1)},"onClick"),children:U},U))})]}),(0,t.jsxs)(nr,{open:_,onOpenChange:A,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:[(0,t.jsx)(hl,{className:"h-3 w-3 text-muted-foreground"}),xJ[f]??f]})}),(0,t.jsx)(Wn,{className:"w-40 p-1",align:"start",children:sle.map(U=>(0,t.jsx)("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",U===f&&"bg-accent"),onClick:r(()=>{g(U),A(!1)},"onClick"),children:xJ[U]??U},U))})]}),(0,t.jsxs)(nr,{open:C,onOpenChange:I,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs hover:bg-accent/50 transition-colors",children:[(0,t.jsx)(vx,{className:"h-3 w-3 text-muted-foreground"}),K?K.title:"Parent goal"]})}),(0,t.jsxs)(Wn,{className:"w-48 p-1",align:"start",children:[(0,t.jsx)("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",!R&&"bg-accent"),onClick:r(()=>{y(""),I(!1)},"onClick"),children:"No parent"}),(L??[]).map(U=>(0,t.jsx)("button",{className:z("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 truncate",U.id===R&&"bg-accent"),onClick:r(()=>{y(U.id),I(!1)},"onClick"),children:U.title},U.id))]})]})]}),(0,t.jsx)("div",{className:"flex items-center justify-end px-4 py-2.5 border-t border-border",children:(0,t.jsx)(F,{size:"sm",disabled:!l.trim()||O.isPending,onClick:q,children:O.isPending?"Creating…":s.parentId?"Create sub-goal":"Create goal"})})]})})}r(Txe,"NewGoalDialog");function XGe(e){const s=ZGe(e),n=eYe(e);return`You're invited to join a Paperclip company as an agent.
288
288
 
289
289
  First, respond to your user that you understand the request and are going to onboard into Paperclip. Then work through the steps below.
290
290
 
@@ -333,7 +333,7 @@ After you have connected to Paperclip, review and follow the full onboarding ins
333
333
  `}r(XGe,"buildAgentOnboardingPrompt");function ZGe(e){const s=(e.connectionCandidates??[]).map(o=>o.trim()).filter(Boolean),n=new Set;let a=null;try{a=new URL(e.onboardingTextUrl),n.add(a.toString())}catch{const o=e.onboardingTextUrl.trim();o&&n.add(o)}if(!a){for(const o of s)n.add(o);return Array.from(n)}const i=`${a.pathname}${a.search}`;for(const o of s)try{const l=new URL(o);n.add(`${l.origin}${i}`)}catch{n.add(o)}return Array.from(n)}r(ZGe,"buildCandidateOnboardingUrls");function eYe(e){const s=e.testResolutionUrl?.trim();if(s)return s;try{const n=new URL(e.onboardingTextUrl),a=n.pathname.replace(/\/onboarding\.txt$/,"/test-resolution");return`${n.origin}${a}`}catch{return null}}r(eYe,"buildResolutionTestUrl");function tYe({companyId:e,onClose:s,onBack:n}){const a=Kt(),i=(0,u.useRef)(!0);(0,u.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);const[o,l]=(0,u.useState)(""),[c,d]=(0,u.useState)(null),[m,h]=(0,u.useState)(!1),[p,f]=(0,u.useState)(!1);async function g(y){try{await Hr(y),i.current&&(h(!0),f(!1))}catch{i.current&&f(!0)}}r(g,"copy");const v=ke({mutationFn:r(async()=>{const y=await ur.createCompanyInvite(e,{allowedJoinTypes:"agent",humanRole:null,agentMessage:o.trim()||null});a.invalidateQueries({queryKey:P.access.invites(e,"all",5)});const w=y.onboardingTextUrl??y.onboardingTextPath??`/api/invites/${y.token}/onboarding.txt`,S=new URL(w,window.location.origin).href,j=await ur.getInviteOnboarding(y.token).catch(()=>null);return XGe({onboardingTextUrl:S,connectionCandidates:j?.onboarding.connectivity?.connectionCandidates??null,testResolutionUrl:j?.onboarding.connectivity?.testResolutionEndpoint?.url??null})},"mutationFn"),onSuccess:r(async y=>{i.current&&(d(y),await g(y))},"onSuccess")});return(0,t.jsx)(Js,{open:!0,onOpenChange:r(y=>{y||s()},"onOpenChange"),children:(0,t.jsxs)(Zs,{className:"max-h-(--sz-calc-16) overflow-y-auto sm:max-w-2xl",children:[(0,t.jsx)(rn,{children:c?"Agent onboarding prompt":"Invite an external agent"}),(0,t.jsx)(Mn,{children:c?"Send this one-time prompt to the agent that should join your organization.":"Generate a one-time onboarding prompt for an external agent. An organization admin must approve its join request before it can claim an API key."}),c?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(En,{"aria-label":"Agent onboarding prompt",readOnly:!0,value:c,className:"min-h-64 font-mono text-xs"}),p&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-muted-foreground",children:"Clipboard unavailable. Copy the prompt manually from the field above."}),(0,t.jsxs)("div",{className:"flex justify-between gap-4",children:[(0,t.jsx)(F,{variant:"ghost",onClick:s,children:"Done"}),(0,t.jsx)(F,{variant:"outline",onClick:r(()=>{g(c)},"onClick"),children:m?"Copied prompt":"Copy prompt"})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,t.jsx)("span",{children:"Optional message for the agent"}),(0,t.jsx)(En,{value:o,onChange:r(y=>l(y.target.value),"onChange"),maxLength:4e3,className:"min-h-24"})]}),v.error&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:v.error.message}),(0,t.jsxs)("div",{className:"flex justify-between gap-4",children:[(0,t.jsx)(F,{variant:"ghost",onClick:n,children:"Back"}),(0,t.jsx)(F,{disabled:v.isPending,onClick:r(()=>v.mutate(),"onClick"),children:v.isPending?"Generating…":"Generate onboarding prompt"})]})]})]})})}r(tYe,"ExternalAgentInviteDialog");function Exe(){const{newAgentOpen:e,closeNewAgent:s}=c1(),{selectedCompanyId:n}=xs();return e?(0,t.jsx)(sYe,{companyId:n,onClose:s},n):null}r(Exe,"NewAgentDialog");function sYe({companyId:e,onClose:s}){const n=Hn(),[a,i]=(0,u.useState)(!1);return a&&e?(0,t.jsx)(tYe,{companyId:e,onClose:s,onBack:r(()=>i(!1),"onBack")}):(0,t.jsx)(hxe,{open:!0,onClose:s,onInvite:e?()=>i(!0):void 0,onContinue:r(o=>{s(),n(`/agents/new?${new URLSearchParams(o)}`)},"onContinue")})}r(sYe,"NewAgentDialogContent");var nYe=[{title:"Inbox",shortcuts:[{keys:["j"],label:"Move down"},{keys:["↓"],label:"Move down"},{keys:["k"],label:"Move up"},{keys:["↑"],label:"Move up"},{keys:["←"],label:"Collapse selected group"},{keys:["→"],label:"Expand selected group"},{keys:["Enter"],label:"Open selected item"},{keys:["a"],label:"Archive item"},{keys:["y"],label:"Archive item"},{keys:["r"],label:"Mark as read"},{keys:["U"],label:"Mark as unread"}]},{title:"Task detail",shortcuts:[{keys:["y"],label:"Quick-archive back to inbox"},{keys:["g","i"],label:"Go to inbox"},{keys:["g","c"],label:"Focus comment composer"}]},{title:"Decisions",shortcuts:[{keys:["j"],label:"Move down"},{keys:["↓"],label:"Move down"},{keys:["k"],label:"Move up"},{keys:["↑"],label:"Move up"},{keys:["Enter"],label:"Open or close selected decision"},{keys:["x"],label:"Dismiss selected decision"}]},{title:"Global",shortcuts:[{keys:["/"],label:"Search current page or quick search"},{keys:["c"],label:"New task"},{keys:["["],label:"Toggle sidebar"},{keys:["]"],label:"Toggle panel"},{keys:["?"],label:"Show keyboard shortcuts"}]}];function gJ({children:e}){return(0,t.jsx)("kbd",{className:"inline-flex h-6 min-w-6 items-center justify-center rounded border border-border bg-muted px-1.5 font-mono text-xs font-medium text-foreground shadow-(--shadow-extract-10)",children:e})}r(gJ,"KeyCap");function rYe(){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"divide-y divide-border border-t border-border",children:nYe.map(e=>(0,t.jsxs)("div",{className:"px-5 py-3",children:[(0,t.jsx)("h3",{className:"mb-2 text-(length:--text-micro) font-semibold uppercase tracking-wider text-muted-foreground",children:e.title}),(0,t.jsx)("div",{className:"space-y-1.5",children:e.shortcuts.map(s=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,t.jsx)("span",{className:"text-sm text-foreground/90",children:s.label}),(0,t.jsx)("div",{className:"flex items-center gap-1",children:s.keys.map((n,a)=>(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[a>0&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:s.combo?"+":"then"}),(0,t.jsx)(gJ,{children:n})]},n))})]},s.label+s.keys.join()))})]},e.title))}),(0,t.jsx)("div",{className:"border-t border-border px-5 py-3",children:(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Press ",(0,t.jsx)(gJ,{children:"Esc"})," to close · Shortcuts are disabled in text fields"]})})]})}r(rYe,"KeyboardShortcutsCheatsheetContent");function Pxe({open:e,onOpenChange:s}){return(0,t.jsx)(Js,{open:e,onOpenChange:s,children:(0,t.jsxs)(Zs,{className:"sm:max-w-md gap-0 p-0 overflow-hidden",showCloseButton:!1,children:[(0,t.jsx)(Sn,{className:"px-5 pt-5 pb-3",children:(0,t.jsx)(rn,{className:"text-base",children:"Keyboard shortcuts"})}),(0,t.jsx)(rYe,{})]})})}r(Pxe,"KeyboardShortcutsCheatsheet");var aYe={info:"border-sky-300 bg-sky-50 text-sky-900 dark:border-sky-500/25 dark:bg-sky-950/60 dark:text-sky-100",success:"border-emerald-300 bg-emerald-50 text-emerald-900 dark:border-emerald-500/25 dark:bg-emerald-950/60 dark:text-emerald-100",warn:"border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-500/25 dark:bg-amber-950/60 dark:text-amber-100",error:"border-red-300 bg-red-50 text-red-900 dark:border-red-500/30 dark:bg-red-950/60 dark:text-red-100"},iYe={info:"bg-sky-500 dark:bg-sky-400",success:"bg-emerald-500 dark:bg-emerald-400",warn:"bg-amber-500 dark:bg-amber-400",error:"bg-red-500 dark:bg-red-400"};function oYe({toast:e,onDismiss:s}){const[n,a]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{const i=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(i)},[]),(0,t.jsx)("li",{className:z("pointer-events-auto rounded-sm border shadow-lg backdrop-blur-xl transition-(--tp-transform-opacity) duration-200 ease-out",n?"translate-y-0 opacity-100":"translate-y-3 opacity-0",aYe[e.tone]),children:(0,t.jsxs)("div",{className:"flex items-start gap-3 px-3 py-2.5",children:[(0,t.jsx)("span",{className:z("mt-1 h-2 w-2 shrink-0 rounded-full",iYe[e.tone])}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"text-sm font-semibold leading-5",children:e.title}),e.body&&(0,t.jsx)("p",{className:"mt-1 text-xs leading-4 opacity-70",children:e.body}),e.action&&(e.action.onClick?(0,t.jsx)("button",{type:"button",onClick:r(()=>{e.action?.onClick?.(),s(e.id)},"onClick"),className:"mt-2 inline-flex text-xs font-medium underline underline-offset-4 hover:opacity-90",children:e.action.label}):e.action.href?(0,t.jsx)(Ge,{to:e.action.href,onClick:r(()=>s(e.id),"onClick"),className:"mt-2 inline-flex text-xs font-medium underline underline-offset-4 hover:opacity-90",children:e.action.label}):null)]}),(0,t.jsx)("button",{type:"button","aria-label":"Dismiss notification",onClick:r(()=>s(e.id),"onClick"),className:"mt-0.5 shrink-0 rounded p-1 opacity-50 hover:bg-black/10 hover:opacity-100 dark:hover:bg-white/10",children:(0,t.jsx)(ir,{className:"h-3.5 w-3.5"})})]})})}r(oYe,"AnimatedToast");function Mxe(){const e=tue(),{dismissToast:s}=da();return e.length===0?null:(0,t.jsx)("aside",{"aria-live":"polite","aria-atomic":"false",className:"pointer-events-none fixed bottom-3 left-3 z-(--z-120) w-full max-w-sm px-1",children:(0,t.jsx)("ol",{className:"flex w-full flex-col-reverse gap-2",children:e.map(n=>(0,t.jsx)(oYe,{toast:n,onDismiss:s},n.id))})})}r(Mxe,"ToastViewport");async function bJ(e,s){const n=await fetch(`/api/announcements/${e}`,{credentials:"same-origin",cache:"no-store",...s});if(!n.ok)throw new vn("Announcement request failed",n.status,null);return n}r(bJ,"request");var vJ={async current(e){const s=await(await bJ("current",{signal:e})).json();return s===null?null:AIe.parse(s)},async dismiss(e,s,n){await bJ(`${encodeURIComponent(e)}/dismiss`,{method:"POST",signal:n,headers:{"Content-Type":"application/json"},body:JSON.stringify({companyId:s})})}},OF=new Map;function hK(e){return`paperclip.announcement-dismissals.v1:${encodeURIComponent(e)}:`}r(hK,"announcementStoragePrefix");function pI(e){const s=hK(e),n=new Map;try{for(let a=0;a<localStorage.length;a++){const i=localStorage.key(a);if(!i?.startsWith(s))continue;const o=i.slice(s.length),l=localStorage.getItem(i);gle.safeParse(o).success&&(l==="pending"||l==="synced")&&OF.set(i,l==="pending")}}catch{}for(const[a,i]of OF)a.startsWith(s)&&n.set(a.slice(s.length),i);return n}r(pI,"readAnnouncementDismissals");function O4(e,s,n){const a=`${hK(e)}${s}`;OF.set(a,n);try{return localStorage.setItem(a,n?"pending":"synced"),!0}catch{return!1}}r(O4,"saveAnnouncementDismissal");var lYe=3e3;function cYe(e){const{userId:s,enabled:n}=e,a=(0,u.useRef)(e);a.current=e;const[i,o]=(0,u.useState)(null),l=(0,u.useRef)(()=>{});(0,u.useEffect)(()=>{if(o(null),!s||!n)return;let d=!1,m=0,h=null,p;const f=new Map,g=new Set,v=hK(s);let y=null;try{y=new BroadcastChannel(v)}catch{}const w=r(()=>!d&&a.current.userId===s&&a.current.enabled,"active");async function S(R,L=!0){if(!w()||f.has(R)||!a.current.companyId)return;const O=new AbortController;f.set(R,O);const $=setTimeout(()=>O.abort(),1e4);try{await vJ.dismiss(R,a.current.companyId,O.signal),w()&&O4(s,R,!1)}catch{w()&&!g.has(R)&&(g.add(R),a.current.onSaveFailure(L))}finally{clearTimeout($),f.delete(R)}}r(S,"sync");async function j(){for(const[R,L]of pI(s)){if(!w())return;L&&await S(R)}}r(j,"flush");function N(){m++,clearTimeout(p),h?.abort(),h=null,o(null)}r(N,"suspend");function _(){if(!w()||document.visibilityState==="hidden")return;N();const R=m,L=new AbortController;h=L;const O=r(()=>w()&&m===R&&!L.signal.aborted,"stillCurrent");let $=!1,E=!1,q=null;const B=r(()=>{!O()||!$||!E||q&&!pI(s).has(q.id)&&(!q.expiresAt||Date.parse(q.expiresAt)>Date.now())&&o({userId:s,announcement:q})},"show");p=setTimeout(()=>{$=!0,B()},lYe),j(),vJ.current(L.signal).then(K=>{q=K,E=!0,B()}).catch(()=>{})}r(_,"resume");function A(){const R=pI(s);o(L=>L?.userId===s&&R.has(L.announcement.id)?null:L)}r(A,"receive");function C(R){R.key?.startsWith(v)&&A()}r(C,"onStorage");function I(){document.visibilityState==="hidden"?N():_()}r(I,"onVisibility");function T(){j()}return r(T,"onOnline"),y&&(y.onmessage=R=>{const L=gle.safeParse(R.data);L.success&&(pI(s).has(L.data)||O4(s,L.data,!0),A())}),l.current=R=>{if(!w())return;const L=O4(s,R,!0);o(null),m++,h?.abort();try{y?.postMessage(R)}catch{}S(R,L)},document.addEventListener("visibilitychange",I),window.addEventListener("online",T),window.addEventListener("storage",C),_(),()=>{d=!0,m++,clearTimeout(p),h?.abort();for(const R of f.values())R.abort();y?.close(),document.removeEventListener("visibilitychange",I),window.removeEventListener("online",T),window.removeEventListener("storage",C),l.current=()=>{}}},[s,n]);const c=n&&i?.userId===s?i.announcement:null;return(0,u.useEffect)(()=>{if(!c?.expiresAt)return;let d;const m=r(()=>{const h=Date.parse(c.expiresAt)-Date.now();h<=0?o(null):d=setTimeout(m,Math.min(h,2147483647))},"check");return m(),()=>clearTimeout(d)},[c]),{announcement:c,dismiss:(0,u.useCallback)(d=>l.current(d),[])}}r(cYe,"useAnnouncement");function dYe(e,s){const n=L2e(),a=s??`/api/announcements/${encodeURIComponent(e.id)}/animation`,i=`${a}:${e.animation?.path??""}`,[o,l]=(0,u.useState)(null),c=!!e.animation&&!n;return(0,u.useEffect)(()=>{if(!c)return;const d=new AbortController,m=setTimeout(()=>d.abort(),5e3);return(async()=>{try{const h=await fetch(a,{credentials:"same-origin",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",signal:d.signal});if(!h.ok||h.headers.get("content-type")?.split(";")[0]!=="text/html")return;const p=await h.text();d.signal.aborted||l({key:i,document:`<meta http-equiv="Content-Security-Policy" content="${T_e}">${p}`})}catch{}finally{clearTimeout(m)}})(),()=>{d.abort(),clearTimeout(m)}},[c,i,a]),c&&o?.key===i?o.document:null}r(dYe,"useAnnouncementAnimation");function yJ({action:e,primary:s,onClick:n}){const a=(0,t.jsxs)(t.Fragment,{children:[e.label,!s&&e.kind==="external"&&(0,t.jsx)(eo,{className:"size-3.5 shrink-0","aria-hidden":"true"})]}),i=r(o=>{o.button===1&&n()},"onAuxClick");return(0,t.jsx)(F,{asChild:!0,variant:s?"default":"ghost",size:"sm",className:"h-auto min-h-9 min-w-0 whitespace-normal py-2 text-left",children:e.kind==="external"?(0,t.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:n,onAuxClick:i,children:a}):(0,t.jsx)(Ge,{to:e.path,onClick:n,onAuxClick:i,children:a})})}r(yJ,"Action");function I2({announcement:e,onDismiss:s,imageSrc:n,animationSrc:a,className:i}){const o=(0,u.useId)(),[l,c]=(0,u.useState)(null),d=n??`/api/announcements/${encodeURIComponent(e.id)}/image`,m=!!(e.image&&l!==d),h=dYe(e,a),p=!!h;return(0,t.jsxs)(Xs,{role:"region","aria-labelledby":o,className:z("relative w-full max-w-(--announcement-width) gap-0 overflow-hidden rounded-xl p-0 shadow-sm",i),onKeyDown:r(f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),s())},"onKeyDown"),children:[(m||h)&&(0,t.jsxs)("div",{className:"relative h-(--announcement-image-mobile-height) w-full shrink-0 overflow-hidden bg-muted md:h-(--announcement-image-height)",children:[m&&(0,t.jsx)("img",{src:d,alt:p?"":e.image.alt,referrerPolicy:"no-referrer",onError:r(()=>c(d),"onError"),className:"h-full w-full object-cover"}),p&&(0,t.jsx)("div",{role:"img","aria-label":e.animation.alt,className:"pointer-events-none absolute inset-0",children:(0,t.jsx)("iframe",{title:e.animation.alt,"aria-hidden":"true",tabIndex:-1,sandbox:"",referrerPolicy:"no-referrer",srcDoc:h,className:"h-full w-full border-0"})})]}),(0,t.jsx)(F,{variant:"secondary",size:"icon","aria-label":"Dismiss announcement",onClick:s,className:"absolute right-2 top-2 z-10 size-8 rounded-full shadow-sm",children:(0,t.jsx)(ir,{className:"size-4","aria-hidden":"true"})}),(0,t.jsxs)("div",{className:z("flex flex-col gap-1 px-4 py-4",!m&&!h&&"pr-12"),children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.eyebrow}),(0,t.jsx)("h2",{id:o,className:"break-words text-base font-semibold leading-snug",children:e.title}),(0,t.jsx)("p",{className:"break-words text-sm leading-snug text-muted-foreground",children:e.description})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t px-3 py-2",children:[e.secondaryLink&&(0,t.jsx)(yJ,{action:e.secondaryLink,onClick:s}),(0,t.jsx)("div",{className:"ml-auto min-w-0 max-w-full",children:(0,t.jsx)(yJ,{action:e.primaryAction,primary:!0,onClick:s})})]})]})}r(I2,"AnnouncementCard");var uYe='[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"], [aria-modal="true"]:not([data-state="closed"]), dialog[open]';function mYe(e){const[s,n]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{if(!e)return;const a=r(()=>n(!!document.querySelector(uYe)),"scan");a();const i=new MutationObserver(a);return i.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-state","aria-modal","open"]}),()=>i.disconnect()},[e]),s}r(mYe,"useModalOpen");function hYe({health:e}){const{userId:s,settled:n}=Z3(),{selectedCompanyId:a,loading:i}=xs(),{onboardingOpen:o}=h5(),l=Sc(),c=oDe(),d=e?.deploymentMode==="local_trusted"?"local-board":n?s:null,{announcement:m,dismiss:h}=cYe({userId:d,companyId:a,enabled:!!(d&&!i&&a&&!o),onSaveFailure:r(f=>l?.pushToast({title:f?"Dismissed in this browser":"Dismissed for this visit",body:"Couldn’t save across devices. We’ll retry when you reconnect or return.",tone:"info",dedupeKey:"announcement-dismissal-sync"}),"onSaveFailure")}),p=mYe(!!m);return!m||p||(c?.length??0)>0?null:(0,t.jsx)("aside",{"aria-label":"Paperclip announcements",className:"announcement-well fixed left-3 bottom-(--announcement-mobile-bottom) z-40 w-(--announcement-available-width) max-w-(--announcement-width) max-h-(--announcement-mobile-max-height) overflow-y-auto md:bottom-3 md:max-h-(--announcement-max-height)",children:(0,t.jsx)(I2,{announcement:m,onDismiss:r(()=>h(m.id),"onDismiss")},m.id)})}r(hYe,"AnnouncementWell");function nE(e){const s=e.split("/").filter(Boolean);return s.length===1?s[0]?.toLowerCase()==="onboarding":s.length===2?s[1]?.toLowerCase()==="onboarding":!1}r(nE,"isOnboardingPath");function pYe(e){const s=e.split("/").filter(Boolean);if(s.length===2&&s[1]?.toLowerCase()==="onboarding")return s[0]}r(pYe,"companyPrefixFromOnboardingPath");function PT(){return 3}r(PT,"onboardingStepForCompany");function fYe(e){const{pathname:s,companyPrefix:n,companies:a,cloudManaged:i}=e;if(!nE(s))return null;const o=r(()=>a.length===1?{initialStep:PT(),companyId:a[0].id}:null,"managedFallback");if(!n)return i?o():{initialStep:1};const l=a.find(c=>c.issuePrefix.toUpperCase()===n.toUpperCase())??null;return l?{initialStep:PT(),companyId:l.id}:i?o():{initialStep:1}}r(fYe,"resolveRouteOnboardingOptions");function xYe(e){return!e.agentsLoaded||e.agentsRefreshing||e.agentCount>0?!1:!nE(e.pathname)}r(xYe,"shouldRouteAgentlessCompanyToOnboarding");function gYe(e){return e.currentStep>1&&e.currentStep>e.entryStep}r(gYe,"canGoBackFromOnboardingStep");function jJ(e){return e.targetStep<e.currentStep&&e.targetStep>=e.entryStep}r(jJ,"canJumpToOnboardingStep");function pK(e){return!e.hasCompanies&&!nE(e.pathname)}r(pK,"shouldRedirectCompanylessRouteToOnboarding");function bYe(e){return e.onboardingOpen||!e.routeDismissed}r(bYe,"isOnboardingWizardActive");function vYe({context:e}){const{slots:s,errorMessage:n}=Hc({slotTypes:["appShellOverlay"],companyId:e.companyId});return n||s.length===0?null:(0,t.jsx)("aside",{className:"plugin-app-shell-overlays","aria-label":"Application extensions",children:s.map(a=>(0,t.jsx)(yu,{slot:a,context:e,className:"plugin-app-shell-overlay"},`${a.pluginId}:${a.pluginVersion}:${a.id}`))})}r(vYe,"AppShellEntries");function Dxe({localTrusted:e=!1}){const{userId:s,settled:n}=Z3(),{selectedCompanyId:a,selectedCompany:i,loading:o}=xs(),{onboardingOpen:l,onboardingRouteDismissed:c}=h5(),{pathname:d}=ea(),m=n?s??(e?"local-board":null):null,h=l||!c&&nE(d);if(!m||o||h)return null;const p={companyId:a,companyPrefix:i?.issuePrefix??null,projectId:null,entityId:null,entityType:null,parentEntityId:null,userId:s};return(0,t.jsx)(vYe,{context:p},JSON.stringify([m,a]))}r(Dxe,"PluginAppShellOverlays");function Lxe({visible:e}){const s=ea(),{selectedCompanyId:n}=xs(),{openNewIssue:a}=$o(),i=Zz(n),o=(0,u.useMemo)(()=>[{type:"link",to:"/dashboard",label:"Home",icon:bde},{type:"link",to:"/issues",label:"Tasks",icon:oa},{type:"action",label:"New Task",icon:g1,onClick:r(()=>a(),"onClick")},{type:"link",to:"/agents/all",label:"Agents",icon:Xo},{type:"link",to:"/inbox",label:"Inbox",icon:Ed,badge:i.inbox}],[a,i.inbox]);return(0,t.jsx)("nav",{className:z("fixed bottom-0 left-0 right-0 z-30 bg-border/50 transition-transform duration-200 ease-out dark:bg-muted md:hidden pb-(--sz-safe-bottom)",e?"translate-y-0":"translate-y-full"),"aria-label":"Mobile navigation",children:(0,t.jsx)("div",{className:"grid h-16 grid-cols-5 px-1",children:o.map(l=>{if(l.type==="action"){const d=l.icon,m=/\/issues\/new(?:\/|$)/.test(s.pathname);return(0,t.jsxs)("button",{type:"button",onClick:l.onClick,className:z("relative flex min-w-0 flex-col items-center justify-center gap-1 rounded-md text-(length:--text-nano) font-medium transition-colors",m?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(d,{className:"h-(--sz-18px) w-(--sz-18px)"}),(0,t.jsx)("span",{className:"truncate",children:l.label})]},l.label)}const c=l.icon;return(0,t.jsx)(a0,{to:l.to,state:ff,className:r(({isActive:d})=>z("relative flex min-w-0 flex-col items-center justify-center gap-1 rounded-md text-(length:--text-nano) font-medium transition-colors",d?"text-foreground":"text-muted-foreground hover:text-foreground"),"className"),children:r(({isActive:d})=>(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"relative",children:[(0,t.jsx)(c,{className:z("h-(--sz-18px) w-(--sz-18px)",d&&"stroke-(length:--sw-2_3)")}),l.badge!=null&&l.badge>0&&(0,t.jsx)(ct,{variant:"ghost",className:"absolute -right-2 -top-2 bg-primary px-1.5 text-(length:--text-nano) leading-none text-primary-foreground",children:l.badge>99?"99+":l.badge})]}),(0,t.jsx)("span",{className:"truncate",children:l.label})]}),"children")},l.label)})})})}r(Lxe,"MobileBottomNav");function ij(e){if(typeof document>"u")return null;const s=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content")?.trim();return s||null}r(ij,"readMetaContent");function FF(e){if(!e)return null;const s=e.startsWith("#")?e.slice(1):e;return/^[0-9a-fA-F]{3}$/.test(s)?`#${s.split("").map(n=>`${n}${n}`).join("").toLowerCase()}`:/^[0-9a-fA-F]{6}$/.test(s)?`#${s.toLowerCase()}`:null}r(FF,"normalizeHexColor");function yYe(e){const s=FF(e)??"#000000";return{r:Number.parseInt(s.slice(1,3),16),g:Number.parseInt(s.slice(3,5),16),b:Number.parseInt(s.slice(5,7),16)}}r(yYe,"hexToRgb");function F4(e){const s=e/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4}r(F4,"relativeLuminanceChannel");function jYe(e){const{r:s,g:n,b:a}=yYe(e),i=.2126*F4(s)+.7152*F4(n)+.0722*F4(a);return 1.05/(i+.05)>=(i+.05)/.05?l2e:i2e}r(jYe,"pickReadableTextColor");function wYe(){return ij("paperclip-worktree-enabled")==="true"}r(wYe,"isWorktreeRuntime");function NYe(){return ij("paperclip-instance-id")}r(NYe,"getWorktreeInstanceId");function kYe(){if(ij("paperclip-worktree-enabled")!=="true")return null;const e=ij("paperclip-worktree-name"),s=FF(ij("paperclip-worktree-color"));return!e||!s?null:{enabled:!0,name:e,color:s,textColor:FF(ij("paperclip-worktree-text-color"))??jYe(s)}}r(kYe,"getWorktreeUiBranding");function $xe(){const e=kYe(),{copied:s,failed:n,copy:a}=uf(),i=(0,u.useCallback)(()=>{e&&a(e.name)},[e,a]);return e?(0,t.jsx)("div",{className:"relative overflow-hidden border-b px-3 py-1.5 text-(length:--text-micro) font-medium tracking-(--tracking-caps) uppercase",style:{backgroundColor:e.color,color:e.textColor,borderColor:`${e.textColor}22`,boxShadow:`inset 0 -1px 0 ${e.textColor}18`,backgroundImage:`linear-gradient(90deg, ${e.textColor}14, transparent 28%, transparent 72%, ${e.textColor}12), repeating-linear-gradient(135deg, transparent 0 10px, ${e.textColor}08 10px 20px)`},children:(0,t.jsxs)("div",{className:"flex items-center gap-2 overflow-hidden whitespace-nowrap",children:[(0,t.jsx)("span",{className:"shrink-0 opacity-70",children:"Worktree"}),(0,t.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-70","aria-hidden":"true"}),(0,t.jsx)("button",{type:"button",onClick:i,title:"Click to copy worktree name",className:"truncate font-semibold tracking-(--tracking-eyebrow) cursor-pointer hover:opacity-80 transition-opacity bg-transparent border-none p-0 text-current uppercase text-(length:--text-micro)",children:s?"Copied!":n?"Copy failed":e.name})]})}):null}r($xe,"WorktreeBanner");var SYe=3e4;function CYe(e){if(!e)return null;const s=new Date(e).getTime();if(Number.isNaN(s))return null;const n=Date.now()-s;if(n<6e4)return"just now";const a=Math.round(n/6e4);if(a<60)return`${a}m ago`;const i=Math.round(a/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}r(CYe,"formatRelativeTimestamp");function _Ye(e){return e.reason==="backend_changes_and_pending_migrations"?"backend files changed and migrations are pending":e.reason==="pending_migrations"?"pending migrations need a fresh boot":"backend files changed since this server booted"}r(_Ye,"describeReason");function Oxe({devServer:e}){const[s,n]=(0,u.useState)(!1);if((0,u.useEffect)(()=>{if(!s)return;const d=window.setTimeout(()=>{n(!1)},SYe);return()=>window.clearTimeout(d)},[s]),!e?.enabled||!e.restartRequired)return null;const a=e,i=CYe(e.lastChangedAt),o=e.changedPathsSample.slice(0,3),l=`${e.activeRunCount} live run${e.activeRunCount===1?"":"s"}`;async function c(){const d=a.activeRunCount>0?`Restart Paperclip now? This may interrupt ${l}.`:"Restart Paperclip now?";if(window.confirm(d)){n(!0);try{await tm.requestDevServerRestart()}catch(m){n(!1),window.alert(m instanceof Error?m.message:"Failed to request restart")}}}return r(c,"requestRestartNow"),(0,t.jsx)("div",{className:"border-b border-amber-300/60 bg-amber-50 text-amber-950 dark:border-amber-500/25 dark:bg-amber-500/10 dark:text-amber-100",children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 px-3 py-2.5 md:flex-row md:items-center md:justify-between",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs font-semibold uppercase tracking-(--tracking-caps)",children:[(0,t.jsx)(Rs,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{children:"Restart Required"}),e.autoRestartEnabled?(0,t.jsx)(ct,{variant:"ghost",className:"bg-amber-900/10 text-(length:--text-nano) tracking-(--tracking-eyebrow) dark:bg-amber-100/10",children:"Auto-Restart On"}):null]}),(0,t.jsxs)("p",{className:"mt-1 text-sm",children:[_Ye(e),i?` · updated ${i}`:""]}),(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-amber-900/80 dark:text-amber-100/75",children:[o.length>0?(0,t.jsxs)("span",{children:["Changed: ",o.join(", "),e.changedPathCount>o.length?` +${e.changedPathCount-o.length} more`:""]}):null,e.pendingMigrations.length>0?(0,t.jsxs)("span",{children:["Pending migrations: ",e.pendingMigrations.slice(0,2).join(", "),e.pendingMigrations.length>2?` +${e.pendingMigrations.length-2} more`:""]}):null]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs font-medium md:justify-end",children:[e.waitingForIdle?(0,t.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-900/10 px-3 py-1.5 dark:bg-amber-100/10",children:[(0,t.jsx)(YEe,{className:"h-3.5 w-3.5"}),(0,t.jsxs)("span",{children:["Waiting for ",l," to finish"]})]}):e.autoRestartEnabled?(0,t.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-900/10 px-3 py-1.5 dark:bg-amber-100/10",children:[(0,t.jsx)(Ii,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:"Auto-restart will trigger when the instance is idle"})]}):(0,t.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-900/10 px-3 py-1.5 dark:bg-amber-100/10",children:[(0,t.jsx)(Ii,{className:"h-3.5 w-3.5"}),(0,t.jsxs)("span",{children:["Restart ",(0,t.jsx)("code",{children:"pnpm dev:once"})," after the active work is safe to interrupt"]})]}),(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md bg-amber-950 px-3 py-1.5 text-xs font-semibold text-amber-50 transition-colors hover:bg-amber-900 disabled:cursor-not-allowed disabled:opacity-60 dark:bg-amber-200 dark:text-amber-950 dark:hover:bg-amber-100",onClick:r(()=>{c()},"onClick"),disabled:s,children:[(0,t.jsx)(Ii,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:s?"Restart requested":"Restart now"})]})]})]})})}r(Oxe,"DevRestartBanner");var Fxe=["standalone","fullscreen","window-controls-overlay"];function IYe(e){return`(display-mode: ${e})`}r(IYe,"displayModeQuery");function AYe(){if(!(typeof window>"u"||typeof window.matchMedia!="function"))return window.matchMedia.bind(window)}r(AYe,"defaultMatchMedia");function wJ(e=AYe(),s=typeof navigator>"u"?void 0:navigator.standalone){return s===!0?!0:e?Fxe.some(n=>e(IYe(n)).matches):!1}r(wJ,"isChromelessDisplayMode");function B4({label:e,children:s,onClick:n}){return(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-sm",className:"size-8 text-muted-foreground hover:text-foreground","aria-label":e,onClick:r(()=>{n()},"onClick"),children:s})}),(0,t.jsx)(Un,{children:e})]})}r(B4,"ControlButton");function BF({mobile:e}){const[s,n]=(0,u.useState)(()=>typeof window<"u"&&e?wJ():!1),a=Sc();(0,u.useEffect)(()=>{if(!e||typeof window>"u"){n(!1);return}const c=r(()=>n(wJ()),"update");if(c(),typeof window.matchMedia!="function")return;const d=Fxe.map(m=>window.matchMedia(`(display-mode: ${m})`));return d.every(m=>typeof m.addEventListener=="function")?(d.forEach(m=>m.addEventListener("change",c)),()=>d.forEach(m=>m.removeEventListener("change",c))):(d.forEach(m=>m.addListener(c)),()=>d.forEach(m=>m.removeListener(c)))},[e]);const i=(0,u.useCallback)(()=>{window.location.reload()},[]),o=(0,u.useCallback)(async()=>{const c=window.location.href;try{if(navigator.share){await navigator.share({title:document.title||"Paperclip",url:c});return}await Hr(c),a?.pushToast({title:"Link copied",tone:"success"})}catch(d){if(d instanceof DOMException&&d.name==="AbortError")return;a?.pushToast({title:"Share failed",body:"Try opening the page in your browser.",tone:"error"})}},[a]),l=(0,u.useCallback)(()=>{window.open(window.location.href,"_blank","noopener,noreferrer")},[]);return!e||!s?null:(0,t.jsxs)("div",{className:"flex h-10 items-center justify-end gap-1 border-b border-border bg-background/95 px-3 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:[(0,t.jsx)(B4,{label:"Refresh",onClick:i,children:(0,t.jsx)(Ki,{className:"h-4 w-4"})}),(0,t.jsx)(B4,{label:"Share",onClick:o,children:(0,t.jsx)(Pde,{className:"h-4 w-4"})}),(0,t.jsx)(B4,{label:"Open in Browser",onClick:l,children:(0,t.jsx)(xr,{className:"h-4 w-4"})})]})}r(BF,"StandaloneBrowserControls");var RYe=16384,TYe=40;function EYe(e){if(!e)return;const s=[];for(const n of e.slice(0,RYe).split(`
334
334
  `).slice(0,41)){const a=/^\s*(?:at|in) ([A-Za-z_$][\w$.-]{0,99})(?:\s|$)/.exec(n)?.[1]??/^([A-Za-z_$][\w$.-]{0,99})@/.exec(n)?.[1];if(a&&s.push(` at ${a}`),s.length===TYe)break}return s.length?`
335
335
  ${s.join(`
336
- `)}`:void 0}r(EYe,"sanitizeComponentStack");function PYe(e){const s=EYe(e.componentStack),n={};if(typeof document<"u"){try{const a=document.readyState;(a==="loading"||a==="interactive"||a==="complete")&&(n.ready_state=a)}catch{}try{const a=document.visibilityState;(a==="visible"||a==="hidden")&&(n.visibility_state=a)}catch{}try{const a=document.documentElement.classList;n.translation_marker=a.contains("translated-ltr")||a.contains("translated-rtl")}catch{}}return{tags:{react_error_boundary:e.boundary},contexts:{react:s?{componentStack:s}:{},browser_state:n}}}r(PYe,"buildBrowserErrorContext");var NJ=Promise.resolve();function fK(e){const s=NJ.then(e);return NJ=s.catch(()=>{}),s}r(fK,"enqueue");var xw=null;function MYe(e,s){return fK(async()=>{if(!xw)try{const n=await vc(()=>import("./prod-COP_vZWu.js"),__vite__mapDeps([4,5]));n.init(LYe(e,s)),xw=n}catch{}})}r(MYe,"initBrowserErrorMonitoring");function DYe(){return fK(async()=>{const e=xw;if(xw=null,!e)return;const s=e.getClient();try{e.getCurrentScope().setClient(void 0)}catch{}try{await s?.close(2e3)}catch{}})}r(DYe,"teardownBrowserErrorMonitoring");function Bxe(e,s){let n;try{s&&(n=PYe(s))}catch{}fK(async()=>{try{n?xw?.captureException(e,n):xw?.captureException(e)}catch{}})}r(Bxe,"captureBrowserException");function LYe(e,s){return{dsn:e,environment:s??void 0,release:"1ba59a4abf6bb796897fdce1b9983ba2caeca576",tracesSampleRate:0,sendDefaultPii:!1,integrations:r(n=>n.filter(a=>a.name!=="HttpContext"&&a.name!=="Breadcrumbs"),"integrations")}}r(LYe,"buildBrowserSentryInitOptions");var $Ye=class extends u.Component{static{r(this,"RouteErrorBoundaryInner")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,s){Bxe(e,{boundary:"route",componentStack:s.componentStack})}componentDidUpdate(e){this.state.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){const{error:e}=this.state;return e?(0,t.jsxs)("div",{className:"mx-auto max-w-2xl space-y-4 px-4 py-10",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"This page hit an error"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Something went wrong while rendering this page. You can go back and try again, or reload."})]}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive whitespace-pre-wrap",children:e.message}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(F,{variant:"outline",size:"sm",onClick:this.props.onReset,children:"Go back"}),(0,t.jsx)(F,{size:"sm",onClick:r(()=>window.location.reload(),"onClick"),children:"Reload page"})]})]}):this.props.children}};function qxe({children:e}){const s=ea(),n=Hn(),a=`${s.pathname}${s.search}`;return(0,t.jsx)($Ye,{resetKey:a,onReset:r(()=>n(-1),"onReset"),children:e})}r(qxe,"RouteErrorBoundary");var fI=240,qF=208,zF=420,kJ=16;function MT(e){return Math.min(zF,Math.max(qF,e))}r(MT,"clampSidebarWidth$1");function SJ(e){if(typeof window>"u")return fI;try{const s=window.localStorage.getItem(e);if(!s)return fI;const n=Number.parseInt(s,10);return Number.isFinite(n)?MT(n):fI}catch{return fI}}r(SJ,"readStoredSidebarWidth$1");function CJ(e,s){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(MT(s)))}catch{}}r(CJ,"writeStoredSidebarWidth$1");function OYe({children:e,open:s,collapsed:n=!1,peeking:a=!1,resizable:i=!1,storageKey:o="paperclip.sidebar.width",className:l,onPanelMouseEnter:c,onPanelMouseLeave:d,onPanelFocusCapture:m,onPanelBlurCapture:h}){const[p,f]=(0,u.useState)(()=>SJ(o)),[g,v]=(0,u.useState)(!1),y=(0,u.useRef)(p),w=(0,u.useRef)(null);(0,u.useEffect)(()=>{const E=SJ(o);y.current=E,f(E)},[o]);const S=s?p:0,j=s?n?64:S:0,N=s?n&&!a?64:S:0,_=N>j,A=i&&s&&!n,C=(0,u.useMemo)(()=>({width:`${j}px`}),[j]),I=(0,u.useMemo)(()=>({width:`${N}px`}),[N]),T=(0,u.useCallback)(E=>{const q=MT(E);y.current=q,f(q),CJ(o,q)},[o]),R=(0,u.useCallback)(E=>{A&&(E.preventDefault(),E.currentTarget.setPointerCapture(E.pointerId),w.current={startX:E.clientX,startWidth:y.current},v(!0))},[A]),L=(0,u.useCallback)(E=>{if(!w.current)return;const q=MT(w.current.startWidth+E.clientX-w.current.startX);y.current=q,f(q)},[]),O=(0,u.useCallback)(()=>{w.current&&(w.current=null,v(!1),CJ(o,y.current))},[o]),$=(0,u.useCallback)(E=>{A&&(E.key==="ArrowLeft"?(E.preventDefault(),T(p-kJ)):E.key==="ArrowRight"?(E.preventDefault(),T(p+kJ)):E.key==="Home"?(E.preventDefault(),T(qF)):E.key==="End"&&(E.preventDefault(),T(zF)))},[A,T,p]);return(0,t.jsxs)("div",{className:z("relative h-full shrink-0",l),style:C,children:[(0,t.jsx)("div",{className:z("absolute inset-y-0 left-0 flex flex-col overflow-hidden",_?"z-30 border-r border-border bg-background shadow-lg":"z-0"),style:I,"data-sidebar-overlay":_?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:m,onBlurCapture:h,children:e}),A?(0,t.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":qF,"aria-valuemax":zF,"aria-valuenow":p,tabIndex:0,"data-dragging":g?"":void 0,className:"group absolute inset-y-0 z-20 cursor-col-resize touch-none outline-none",style:{right:-4,width:8},onPointerDown:R,onPointerMove:L,onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,onKeyDown:$,children:(0,t.jsx)("div",{className:z("mx-auto h-full w-0.5 transition-colors",g?"bg-ring":"bg-transparent group-hover:bg-ring group-focus-visible:bg-ring")})}):null]})}r(OYe,"SidebarShell$1");function xI({children:e,className:s}){return(0,t.jsx)("div",{"data-secondary-sidebar":"",className:z("h-full w-full min-w-0 overflow-hidden",s),children:(0,t.jsx)(Zde,{children:e})})}r(xI,"SecondarySidebar$1");var FYe="Toggle the app appearance.";function Aj({className:e,variant:s="icon",onAfterToggle:n}){const{theme:a,toggleTheme:i}=aRe(),o=a==="dark",l=o?"Switch to light mode":"Switch to dark mode",c=o?Mde:_de;function d(){i(),n?.()}return r(d,"handleClick"),s==="compact-menu-action"?(0,t.jsxs)("button",{type:"button",className:z("flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-foreground transition-colors hover:bg-accent",e),onClick:d,"aria-label":l,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(c,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:l})]}):s==="menu-action"?(0,t.jsxs)("button",{type:"button",className:z("flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-accent/60",e),onClick:d,"aria-label":l,children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(c,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:l}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:FYe})]})]}):(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":l,title:l,className:z("text-muted-foreground",e),children:(0,t.jsx)(c,{})})}r(Aj,"ThemeToggle");function BYe(e){if(!e)return"Unavailable";const s=new Date(e);return Number.isNaN(s.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(s)}r(BYe,"formatTimestamp$2");function qYe(e){return!!e&&!Number.isNaN(new Date(e).getTime())}r(qYe,"isValidTimestamp");function zYe(e){return e?.devServer?.lastRestartAt??e?.serverInfo?.processStartedAt??null}r(zYe,"restartTimestamp");function UYe(e){const s=e?.serverInfo?.git;return s?.available?`${s.shortSha} · ${s.subject}`:"Commit unavailable"}r(UYe,"commitLabel");function KYe(e){const s=e?.serverInfo?.git;if(!s?.available)return"Unavailable";const n=s.localChanges;if(!n||!n.available)return"Change status unavailable";if(!n.hasLocalChanges)return"Clean checkout";const a=[[n.stagedFileCount,"staged"],[n.unstagedFileCount,"unstaged"],[n.untrackedFileCount,"untracked"]].filter(([i])=>Number(i)>0).map(([i,o])=>`${i} ${o}`);return a.length>0?`Local changes present (${a.join(", ")})`:"Local changes present"}r(KYe,"localChangesLabel");function q4({icon:e,label:s,value:n,dateTime:a}){return(0,t.jsxs)("div",{className:"flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left",children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(e,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:s}),a?(0,t.jsx)("time",{dateTime:a,className:"block break-words text-xs text-muted-foreground",children:n}):(0,t.jsx)("span",{className:"block break-words text-xs text-muted-foreground",children:n})]})]})}r(q4,"ServerInfoRow");function zxe(){const e=ee({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn")}).data?.enableServerInfoDebugView===!0,s=ee({queryKey:P.health,queryFn:r(()=>tm.get(),"queryFn"),enabled:e,refetchOnMount:"always",refetchInterval:r(h=>h.state.data?.devServer?.enabled?2e3:!1,"refetchInterval")});if(!e)return null;const n=s.data,a=s.isLoading&&!n,i=s.isError,o=zYe(n),l=qYe(o),c=i?"Health unavailable":a?"Loading...":BYe(o),d=i?"Health unavailable":a?"Loading...":UYe(n),m=i?"Health unavailable":a?"Loading...":KYe(n);return(0,t.jsxs)("div",{className:"mt-2 border-t border-border pt-2",children:[(0,t.jsx)("p",{className:"px-3 pb-1 pt-1 text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Server"}),(0,t.jsx)(q4,{icon:th,label:"Last restarted",value:c,dateTime:!i&&!a&&l?o:null}),(0,t.jsx)(q4,{icon:gde,label:"Running commit",value:d}),(0,t.jsx)(q4,{icon:A3e,label:"Checkout state",value:m})]})}r(zxe,"SidebarServerInfo");var VYe="/company/settings/instance/profile",WYe="https://docs.paperclip.ing/",HYe="https://paperclip.ing/feedback";function QYe(e){const s=e.trim().split(/\s+/).filter(Boolean);return s.length>=2?`${s[0]?.[0]??""}${s[s.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}r(QYe,"deriveInitials$2");function GYe(e,s,n){const a=[e,s?.split("@")[0],s,n];for(const i of a){const o=i?.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(o)return o}return"me"}r(GYe,"deriveUserSlug$1");function gI({label:e,icon:s,onClick:n,href:a,external:i=!1}){const o="flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-foreground transition-colors hover:bg-accent",l=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(s,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e})]});return a?i?(0,t.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",className:o,onClick:n,children:l}):(0,t.jsx)(Ge,{to:a,className:o,onClick:n,children:l}):(0,t.jsx)("button",{type:"button",className:o,onClick:n,children:l})}r(gI,"MenuAction$1");function _J({deploymentMode:e,open:s,onOpenChange:n,forceExpanded:a=!1}){const i=!!Qc(),[o,l]=(0,u.useState)(!1),{isMobile:c,setSidebarOpen:d,collapsed:m,peeking:h}=Wa(),p=m&&!h&&!a,f=s??o,g=n??l,{data:v}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),y=Yw({onSignedOut:_}),w=v?.user.name?.trim()||"Board",S=v?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),j=QYe(w),N=`/u/${GYe(v?.user.name,v?.user.email,v?.user.id)}`;function _(){g(!1),c&&d(!1)}r(_,"closeNavigationChrome");function A(){y.mutate()}return r(A,"handleSignOut"),(0,t.jsx)("div",{className:"bg-border/50 px-3 py-2 dark:bg-muted",children:(0,t.jsxs)("div",{className:z("flex items-center gap-0.5",!p&&"px-2"),children:[(0,t.jsxs)(nr,{open:f,onOpenChange:g,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:z("flex min-w-0 items-center gap-2.5 rounded-lg text-left text-(length:--text-compact) font-medium text-foreground/80 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",p?"w-full px-3 py-2":"flex-1 px-2 py-1.5"),"aria-label":"Open account menu",children:[(0,t.jsxs)(Yi,{size:"sm",children:[v?.user.image?(0,t.jsx)(Vc,{src:v.user.image,alt:w}):null,(0,t.jsx)(Ji,{children:j})]}),(0,t.jsx)("span",{className:z("min-w-0 flex-1 truncate",p&&"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none"),children:w})]})}),(0,t.jsxs)(Wn,{side:"top",align:"start",sideOffset:10,className:"min-h-(--profile-popover-min-height) w-(--profile-popover-width) max-w-(--sz-calc-24) overflow-hidden rounded-xl border-border bg-popover p-0 shadow-(--shadow-profile-popover)",children:[(0,t.jsxs)("div",{className:"flex h-(--profile-popover-header-height) shrink-0 items-center gap-2.5 px-3.5",children:[(0,t.jsxs)(Yi,{className:"size-9",children:[v?.user.image?(0,t.jsx)(Vc,{src:v.user.image,alt:w}):null,(0,t.jsx)(Ji,{className:"text-xs text-foreground",children:j})]}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("h2",{className:"truncate text-sm font-semibold leading-(--profile-popover-label-line-height) text-foreground",children:w}),(0,t.jsx)("p",{className:"truncate text-(length:--text-micro) leading-(--profile-popover-meta-line-height) text-muted-foreground",children:S})]})]}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-0.5 border-t border-border px-2.5 pb-2.5 pt-2",children:[(0,t.jsx)(gI,{label:"Settings",icon:Ld,href:"/company/settings",onClick:_}),(0,t.jsx)(gI,{label:"View profile",icon:vu,href:N,onClick:_}),(0,t.jsx)(gI,{label:"Edit profile",icon:b1,href:VYe,onClick:_}),(0,t.jsx)(gI,{label:"Documentation",icon:Ww,href:WYe,external:!0,onClick:r(()=>g(!1),"onClick")}),(0,t.jsx)(Aj,{variant:"compact-menu-action",onAfterToggle:r(()=>g(!1),"onAfterToggle")}),e==="authenticated"?(0,t.jsxs)("button",{type:"button",className:z("flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-foreground transition-colors hover:bg-destructive/10",y.isPending&&"cursor-not-allowed opacity-60"),onClick:A,disabled:y.isPending,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(Yh,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:y.isPending?"Signing out...":"Sign out"})]}):null,(0,t.jsx)(zxe,{})]})]})]}),!p&&!i?(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)("a",{href:HYe,target:"_blank",rel:"noreferrer","aria-label":"Share feedback",className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground/50 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(Ex,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsx)(Un,{side:"top",children:"Share feedback"})]}):null]})})}r(_J,"SidebarAccountMenu$1");function Uxe({enabled:e=!0,onNewIssue:s,onSearch:n,onToggleSidebar:a,onTogglePanel:i,onShowShortcuts:o,onGoToInbox:l}){(0,u.useEffect)(()=>{if(!e)return;let c=!1,d=null;const m=r(()=>{d!==null&&(window.clearTimeout(d),d=null)},"clearGoChordTimeout"),h=r(()=>{c=!1,m()},"disarmGoChord"),p=r(()=>{c=!0,m(),d=window.setTimeout(()=>{c=!1,d=null},1200)},"armGoChord");function f(y){if(y.defaultPrevented){h();return}if(l){const w=Zle({armed:c,defaultPrevented:y.defaultPrevented,key:y.key,metaKey:y.metaKey,ctrlKey:y.ctrlKey,altKey:y.altKey,target:y.target,hasOpenDialog:Rh()});if(w==="arm"){p();return}if(w==="navigate_inbox"){h(),y.preventDefault(),l();return}if(w==="focus_comment"||w==="open_file_viewer"){h(),y.preventDefault();return}w==="disarm"&&h()}if(!XC(y.target)){if(y.key==="/"&&!y.metaKey&&!y.ctrlKey&&!y.altKey){if(Rh())return;y.preventDefault(),WAe()||n?.();return}if(y.key==="?"&&!y.metaKey&&!y.ctrlKey&&!y.altKey){y.preventDefault(),o?.();return}y.key==="c"&&!y.metaKey&&!y.ctrlKey&&!y.altKey&&(y.preventDefault(),s?.()),y.key==="["&&!y.metaKey&&!y.ctrlKey&&(y.preventDefault(),a?.()),y.key==="]"&&!y.metaKey&&!y.ctrlKey&&(y.preventDefault(),i?.())}}r(f,"handleKeyDown");const g=r(()=>h(),"handlePointerDown"),v=r(y=>{y.target instanceof HTMLElement&&y.target!==document.body&&h()},"handleFocusIn");return document.addEventListener("pointerdown",g,!0),document.addEventListener("focusin",v,!0),document.addEventListener("keydown",f),()=>{h(),document.removeEventListener("pointerdown",g,!0),document.removeEventListener("focusin",v,!0),document.removeEventListener("keydown",f)}},[e,s,n,a,i,o,l])}r(Uxe,"useKeyboardShortcuts");var YYe=new Set(["auth","invite","board-claim","cli-auth","docs"]);function Kxe(e){const s=(e.split("?")[0]??"").split("/").filter(Boolean);if(s.length===0)return!0;const[n]=s;return!YYe.has(n)}r(Kxe,"isRememberableCompanyPath");function JYe(e){const s=Ob(e.companyPrefix);return e.companies.find(n=>Ob(n.issuePrefix)===s)??null}r(JYe,"findCompanyByPrefix");function XYe(e){const s=sz(e.pathname);return s?JYe({companies:e.companies,companyPrefix:s})?.id??null:e.fallbackCompanyId}r(XYe,"getRememberedPathOwnerCompanyId");function ZYe(e){const s=e.path?s5(e.path):"/dashboard";if(!Kxe(s))return"/dashboard";const[n,a]=(s.split("?")[0]??"").split("/").filter(Boolean);if(n==="issues"&&a){const i=/^([A-Za-z]+)-\d+$/.exec(a);if(i&&Ob(i[1]??"")!==Ob(e.companyPrefix))return"/dashboard"}return s}r(ZYe,"sanitizeRememberedPathForCompany");var Vxe="paperclip.companyPaths";function Wxe(){try{const e=localStorage.getItem(Vxe);if(e)return JSON.parse(e)}catch{}return{}}r(Wxe,"getCompanyPaths");function eJe(e,s){const n=Wxe();n[e]=s,localStorage.setItem(Vxe,JSON.stringify(n))}r(eJe,"saveCompanyPath");function Hxe(){const{companies:e,selectedCompanyId:s,selectedCompany:n,selectionSource:a}=xs(),i=ea(),o=Hn(),l=(0,u.useRef)(s),c=(0,u.useMemo)(()=>XYe({companies:e,pathname:i.pathname,fallbackCompanyId:l.current}),[e,i.pathname]),d=i.pathname+i.search;(0,u.useEffect)(()=>{const m=c,h=s5(d);m&&Kxe(h)&&eJe(m,h)},[d,c]),(0,u.useEffect)(()=>{if(s){if(l.current!==null&&s!==l.current&&a!=="route_sync"&&n){const m=Wxe(),h=ZYe({path:m[s],companyPrefix:n.issuePrefix});o(`/${n.issuePrefix}${h}`,{replace:!0})}l.current=s}},[n,s,a,o])}r(Hxe,"useCompanyPageMemory");var tJe=24,sJe=8;function Qxe(e,s,n){const a=n&&!xme(e,s).isTaskDetail,i=(0,u.useRef)(0),[o,l]=(0,u.useState)(!0),c=(0,u.useCallback)(d=>{const m=d-i.current;i.current=d,d<=tJe?l(!0):m>sJe?l(!1):m<-8&&l(!0)},[]);return(0,u.useEffect)(()=>{if(i.current=0,!a){l(!0);return}const d=r(()=>{c(window.scrollY||document.documentElement.scrollTop||0)},"onScroll");return d(),window.addEventListener("scroll",d,{passive:!0}),()=>window.removeEventListener("scroll",d)},[a,e,c]),o}r(Qxe,"useMobileNavAutoHide");function Gxe(e){const{matchedCompany:s,selectedCompanyId:n,companies:a}=e;return!s||s.status!=="archived"||n===s.id?null:a.find(i=>i.id===n&&i.status!=="archived")??a.find(i=>i.status!=="archived")??null}r(Gxe,"resolveArchivedCompanyBounce");function nJe(e){const{archivedCompanyId:s,companies:n,cloudPortfolioUrl:a}=e,i=n.find(o=>o.id!==s&&o.status!=="archived");return i?{kind:"company",company:i}:a?{kind:"cloud_portfolio",url:a}:{kind:"companies_list"}}r(nJe,"resolveCompanyArchiveDeparture");function Yxe(e){const{selectionSource:s,selectedCompanyId:n,routeCompanyId:a}=e;return!(n===a||s==="manual"&&n)}r(Yxe,"shouldSyncCompanySelectionFromRoute");function rJe(e,s){return e instanceof HTMLElement?!(s instanceof HTMLElement)||!document.contains(s)||s===document.body||s===document.documentElement?!0:!e.contains(s):!1}r(rJe,"shouldFocusMainContentAfterNavigation");function Jxe(e){if(!(e instanceof HTMLElement))return()=>{};const s=window.requestAnimationFrame(()=>{rJe(e,document.activeElement)&&e.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(s)}r(Jxe,"scheduleMainContentFocus");function Xxe(e=document,s=window){const n=r(()=>{e.documentElement.scrollTop!==0&&(e.documentElement.scrollTop=0),e.body.scrollTop!==0&&(e.body.scrollTop=0)},"onScroll");return s.addEventListener("scroll",n,{capture:!0}),()=>s.removeEventListener("scroll",n,{capture:!0})}r(Xxe,"pinDocumentScrollToZero");function xu({scope:e="global",requestedPrefix:s}){const n=ea(),{setBreadcrumbs:a}=Ln(),{companies:i,selectedCompany:o}=xs();(0,u.useEffect)(()=>{a([{label:"Not Found"}])},[a]);const l=o??i[0]??null,c=l?`/${l.issuePrefix}/dashboard`:"/",d=`${n.pathname}${n.search}${n.hash}`,m=s?.toUpperCase(),h=e==="invalid_company_prefix"?"Organization not found":"Page not found",p=e==="invalid_company_prefix"?`No organization matches prefix "${m??"unknown"}".`:"This route does not exist.";return(0,t.jsx)("div",{className:"mx-auto max-w-2xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 p-2",children:(0,t.jsx)(Rs,{className:"h-5 w-5 text-destructive"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:h}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:p})]})]}),(0,t.jsxs)("div",{className:"mt-4 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:["Requested path: ",(0,t.jsx)("code",{className:"font-mono",children:d})]}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{asChild:!0,children:(0,t.jsxs)(Ge,{to:c,children:[(0,t.jsx)(AR,{className:"mr-1.5 h-4 w-4"}),"Open dashboard"]})}),(0,t.jsx)(F,{variant:"outline",asChild:!0,children:(0,t.jsx)(Ge,{to:"/",children:"Go home"})})]})]})})}r(xu,"NotFoundPage");function aJe(e,s){return fme(e,s)[0]?.toLowerCase()??null}r(aJe,"getCompanyRouteSegment$1");var iJe=new Set(["browse","connections","connect","chat","vercel-connect","review","attention","gateways","advanced","app"]);function oJe({sidebarSections:e}){const{sidebarOpen:s,setSidebarOpen:n,toggleSidebar:a,collapsed:i,peeking:o,setPeeking:l,isMobile:c,setForceCollapsed:d}=Wa(),{openNewIssue:m,openOnboarding:h}=$o(),{togglePanelVisible:p}=bf(),f=Sc()?.pushToast??null,{companies:g,loading:v,selectedCompany:y,selectedCompanyId:w,selectionSource:S,setSelectedCompanyId:j}=xs(),{companyPrefix:N,pluginRoutePath:_,agentId:A,routineId:C}=ka(),I=Hn(),T=ea(),R=t5(),{enabled:L}=kc(),O=xme(T.pathname,N),$=O.builtInContextualSurface==="settings",E=O.companySegments,q=O.isTaskDetail,B=L&&q,K=E[0]?.toLowerCase()==="tools",U=E[0]?.toLowerCase()==="apps",D=U&&E[1]&&!iJe.has(E[1].toLowerCase())?E[1]:null,V=U&&E[1]?.toLowerCase()==="app"&&E[2]?E[2]:null,H=(0,u.useRef)(!1),J=(0,u.useRef)(null),X=(0,u.useRef)(null),le=(0,u.useRef)(new Yde),ce=(0,u.useRef)(T.key),te=Qxe(T.pathname,N,c),[re,de]=(0,u.useState)(!1),Z=(0,u.useMemo)(()=>{if(!N)return null;const ft=N.toUpperCase();return g.find(Ot=>Ot.issuePrefix.toUpperCase()===ft)??null},[g,N]),Y=!!N&&!v&&g.length>0&&!Z,G=(0,u.useMemo)(()=>_?.toLowerCase()??aJe(T.pathname,N),[N,T.pathname,_]),fe=Z?.id??null,se=Z?.issuePrefix??null,{slots:ae}=Hc({slotTypes:["page","routeSidebar"],companyId:fe,enabled:!!(fe&&G)}),ie=(0,u.useMemo)(()=>Vz(ae,G),[G,ae]),ue=(0,u.useMemo)(()=>({companyId:fe,companyPrefix:se}),[fe,se]),pe=$?(0,t.jsx)(jOe,{}):!L&&O.builtInContextualSurface==="skills"?(0,t.jsx)(fQ,{}):D?(0,t.jsx)(hQ,{kind:"connection",connectionId:D}):V?(0,t.jsx)(hQ,{kind:"application",applicationId:V}):U||K?(0,t.jsx)(IOe,{}):ie?L?(0,t.jsx)(N1,{surface:`plugin:${ie.id}`,title:ie.displayName,children:(0,t.jsx)(yu,{slot:ie,context:ue,className:"min-h-0 flex-1",missingBehavior:"placeholder"})}):(0,t.jsx)(yu,{slot:ie,context:ue,className:"h-full w-full",missingBehavior:"placeholder"}):null,be=O.builtInContextualSurface==="agent"&&A?(0,t.jsx)(UOe,{agentRef:A}):L&&O.builtInContextualSurface==="routine"&&C?(0,t.jsx)(Q4e,{children:(0,t.jsx)(WOe,{routineId:C})}):L&&O.builtInContextualSurface==="skills"?(0,t.jsx)(fQ,{}):pe,oe=be!=null,je=L&&oe&&(O.builtInContextualSurface==="skills"||O.builtInContextualSurface==="agent"||O.builtInContextualSurface==="routine"||U||K),_e=L&&oe&&!je,xe=oe&&(!L||je),Ae=!L||!oe?null:ie&&!O.builtInContextualSurface?`plugin:${ie.id}`:O.builtInContextualSurface,Ye=(0,u.useRef)(null),{data:Oe}=ee({queryKey:P.health,queryFn:r(()=>tm.get(),"queryFn"),retry:!1,refetchInterval:r(ft=>ft.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1}),Xe=ee({queryKey:P.instance.generalSettings,queryFn:r(()=>Ir.getGeneral(),"queryFn")}).data?.keyboardShortcuts===!0;(0,u.useLayoutEffect)(()=>(d(!L&&oe),()=>d(!1)),[oe,d,L]),(0,u.useEffect)(()=>{const ft=Ye.current;Ae&&N&&ft&&ft.surface!==Ae&&ft.pathname!==T.pathname&&bOe({surface:Ae,companyPrefix:N,previousPathname:ft.pathname}),Ye.current={pathname:T.pathname,surface:Ae}},[N,Ae,T.pathname]),(0,u.useEffect)(()=>{v||H.current||Oe?.deploymentMode!=="authenticated"&&(Oe?.cloud||g.length===0&&(H.current=!0,h()))},[g,v,h,Oe?.cloud,Oe?.deploymentMode]),(0,u.useEffect)(()=>{if(!N||v||g.length===0)return;if(!Z){const Ot=(w?g.find(es=>es.id===w):null)??g[0]??null;Ot&&w!==Ot.id&&j(Ot.id,{source:"route_sync"});return}if(N!==Z.issuePrefix){const Ot=T.pathname.replace(/^\/[^/]+/,"");I(`/${Z.issuePrefix}${Ot}${T.search}`,{replace:!0});return}const ft=Gxe({matchedCompany:Z,selectedCompanyId:w,companies:g});if(ft){f?.({title:`${Z.name} is archived`,body:`Switched to ${ft.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${Z.id}`}),j(ft.id,{source:"route_sync"}),I(`/${ft.issuePrefix}/dashboard`,{replace:!0});return}Yxe({selectionSource:S,selectedCompanyId:w,routeCompanyId:Z.id})&&j(Z.id,{source:"route_sync"})},[N,g,v,Z,T.pathname,T.search,I,f,S,w,j]);const me=p,Le=(0,u.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),mt=(0,u.useRef)(null),We=(0,u.useRef)(!1),ze=(0,u.useRef)(!1),st=(0,u.useCallback)(()=>{mt.current!==null&&(window.clearTimeout(mt.current),mt.current=null)},[]),pt=(0,u.useCallback)(()=>{st(),mt.current=window.setTimeout(()=>l(!0),50)},[st,l]),Pt=(0,u.useCallback)(()=>{st(),l(!0)},[st,l]),tt=(0,u.useCallback)(()=>{st(),mt.current=window.setTimeout(()=>l(!1),120)},[st,l]),ht=(0,u.useCallback)(()=>{We.current=!0,i&&!ze.current&&pt()},[i,pt]),et=(0,u.useCallback)(()=>{We.current=!1,ze.current=!1,tt()},[tt]),Ie=(0,u.useCallback)(()=>{ze.current||Pt()},[Pt]),Ne=(0,u.useCallback)(()=>{We.current||tt()},[tt]);(0,u.useEffect)(()=>st,[st]);const Je=(0,u.useRef)(i);return(0,u.useEffect)(()=>{i!==Je.current&&(i?(st(),l(!1),ze.current=We.current):ze.current=!1,Je.current=i)},[i,st,l]),(0,u.useEffect)(()=>{if(!o)return;const ft=r(Ot=>{Ot.key==="Escape"&&(st(),l(!1))},"onKeyDown");return window.addEventListener("keydown",ft),()=>window.removeEventListener("keydown",ft)},[o,st,l]),Hxe(),Uxe({enabled:Xe,onNewIssue:r(()=>m(),"onNewIssue"),onSearch:Le,onToggleSidebar:a,onTogglePanel:me,onShowShortcuts:r(()=>de(!0),"onShowShortcuts"),onGoToInbox:r(()=>I("/inbox"),"onGoToInbox")}),(0,u.useEffect)(()=>{if(!c)return;const ft=30,Ot=50,es=75;let bs=0,Ke=0;const Ve=r(Be=>{const as=Be.touches[0];bs=as.clientX,Ke=as.clientY},"onTouchStart"),dt=r(Be=>{const as=Be.changedTouches[0],Fe=as.clientX-bs;if(!(Math.abs(as.clientY-Ke)>es)){if(!s&&bs<ft&&Fe>Ot){n(!0);return}s&&Fe<-50&&n(!1)}},"onTouchEnd");return document.addEventListener("touchstart",Ve,{passive:!0}),document.addEventListener("touchend",dt,{passive:!0}),()=>{document.removeEventListener("touchstart",Ve),document.removeEventListener("touchend",dt)}},[c,s,n]),(0,u.useEffect)(()=>{const ft=document.body.style.overflow;return document.body.style.overflow=c?"visible":"clip",()=>{document.body.style.overflow=ft}},[c]),(0,u.useEffect)(()=>{if(!c)return Xxe()},[c]),(0,u.useEffect)(()=>{if(typeof document>"u")return;const ft=X.current;return Jxe(ft)},[T.pathname]),(0,u.useEffect)(()=>{const ft=X.current;if(!ft)return;const Ot=r(()=>{le.current.remember(ce.current,ft.scrollTop)},"recordScroll");return ft.addEventListener("scroll",Ot,{passive:!0}),()=>ft.removeEventListener("scroll",Ot)},[]),(0,u.useLayoutEffect)(()=>{const ft=X.current,Ot=Gde({previousPathname:J.current,pathname:T.pathname,navigationType:R,state:T.state});J.current=T.pathname;const es=R==="POP",bs=es?le.current.recall(T.key):0;if(ce.current=T.key,es){WR(ft,bs);const Ke=requestAnimationFrame(()=>WR(ft,bs));return()=>cancelAnimationFrame(Ke)}Ot&&Jde(ft)},[T.key,T.pathname,T.state,R]),(0,t.jsx)(Qde,{children:(0,t.jsx)(tce,{value:{keyboardShortcutsEnabled:Xe},children:(0,t.jsxs)("div",{className:z("bg-background text-foreground pt-(--sz-safe-top)",c?"min-h-dvh overflow-x-clip":"flex h-dvh flex-col overflow-clip"),children:[(0,t.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:left-3 focus:top-3 focus:z-(--z-200) focus:rounded-md focus:bg-background focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Skip to Main Content"}),(0,t.jsx)($xe,{}),(0,t.jsx)(Oxe,{devServer:Oe?.devServer}),(0,t.jsxs)("div",{className:z("min-h-0 flex-1",c?"w-full":"flex overflow-clip"),children:[c&&s&&(0,t.jsx)("button",{type:"button",className:"fixed inset-0 z-40 bg-black/50",onClick:r(()=>n(!1),"onClick"),"aria-label":"Close sidebar"}),c?(0,t.jsxs)("div",{className:z("fixed inset-y-0 left-0 z-50 flex flex-col overflow-hidden pt-(--sz-safe-top) transition-transform duration-100 ease-out",s?"translate-x-0":"-translate-x-full"),children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:(0,t.jsx)("div",{className:"w-60 shrink-0 overflow-hidden",children:oe?(0,t.jsx)(xI,{children:be}):(0,t.jsx)(cQ,{children:e})})}),(0,t.jsx)(_J,{deploymentMode:Oe?.deploymentMode,forceExpanded:_e})]}):(0,t.jsxs)(OYe,{open:s,collapsed:_e?!1:i,peeking:_e?!1:o,resizable:!0,onPanelMouseEnter:_e?void 0:ht,onPanelMouseLeave:_e?void 0:et,onPanelFocusCapture:!_e&&i?Ie:void 0,onPanelBlurCapture:!_e&&i?Ne:void 0,children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0",children:_e?(0,t.jsx)(xI,{children:be}):(0,t.jsx)(cQ,{children:e})}),(0,t.jsx)(_J,{deploymentMode:Oe?.deploymentMode,forceExpanded:_e})]}),!c&&xe&&!je?(0,t.jsx)(xI,{className:"w-60 shrink-0",children:be}):null,(0,t.jsxs)("div",{className:z("flex min-w-0 flex-col",c?"w-full":"h-full flex-1"),children:[(0,t.jsxs)("div",{className:z(!c&&B&&"hidden",c&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:[(0,t.jsx)(BF,{mobile:c}),(0,t.jsx)(gQ,{}),c&&$?(0,t.jsx)("div",{className:"border-b border-border px-4 pb-3",children:(0,t.jsx)(vme,{})}):null]}),(0,t.jsxs)("div",{className:z(c?"block":"flex flex-1 min-h-0",!c&&B&&"streamlined-task-detail-surface"),children:[!c&&je?(0,t.jsx)(xI,{className:"w-60 shrink-0 bg-background",children:be}):null,(0,t.jsxs)("div",{className:z(!c&&B?"flex min-w-0 flex-1 flex-col":"contents"),children:[!c&&B?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(BF,{mobile:!1}),(0,t.jsx)(gQ,{taskDetailLayout:!0})]}):null,(0,t.jsx)("main",{id:"main-content",ref:X,tabIndex:-1,style:c?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:z("flex-1 p-4 outline-none md:p-6",!c&&B&&"pt-0 md:pt-0",c?"overflow-visible pb-(--sz-calc-14)":"overflow-auto [scrollbar-gutter:stable]"),children:Y?(0,t.jsx)(xu,{scope:"invalid_company_prefix",requestedPrefix:N??y?.issuePrefix}):(0,t.jsx)(qxe,{children:(0,t.jsx)(r0,{})})})]}),(0,t.jsx)(Tme,{taskDetailLayout:!c&&B})]})]})]}),c&&(0,t.jsx)(Lxe,{visible:te}),(0,t.jsx)(Mme,{}),(0,t.jsx)(Hme,{}),(0,t.jsx)(Ixe,{}),(0,t.jsx)(Txe,{}),(0,t.jsx)(Exe,{}),(0,t.jsx)(Pxe,{open:re,onOpenChange:de}),(0,t.jsx)(Mxe,{}),(0,t.jsx)(hYe,{health:Oe}),(0,t.jsx)(Dxe,{localTrusted:Oe?.deploymentMode==="local_trusted"})]})})})}r(oJe,"Layout$1");var Zxe=(0,u.createContext)(!1);function lJe({children:e}){return(0,t.jsx)(Zxe.Provider,{value:!0,children:e})}r(lJe,"SidebarNavExpandedProvider");function cJe(){return(0,u.useContext)(Zxe)}r(cJe,"useSidebarNavExpanded");function Ya({to:e,label:s,icon:n,iconNode:a,end:i,className:o,labelClassName:l,badge:c,badgeTone:d="default",badgeLabel:m,textBadge:h,textBadgeTone:p="default",alert:f=!1,liveCount:g,active:v,trailing:y,trailingLabel:w,liveAccessory:S}){const{isMobile:j,setSidebarOpen:N,collapsed:_,peeking:A}=Wa(),C=cJe(),I=_&&!A&&!C,T=c!=null&&c>0,R=g!=null&&g>0,L=R?`${g} live`:T?`${c}${m?` ${m}`:""}`:f?"attention needed":void 0,O=!I||!L&&!w?void 0:`${s}${L?`, ${L}`:""}${w?`, ${w}`:""}`,$=(0,t.jsxs)(a0,{to:e,state:ff,end:i,"aria-label":O,onClick:r(()=>{j&&N(!1)},"onClick"),className:r(({isActive:E})=>z("flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium transition-colors",v??E?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground",o),"className"),children:[(0,t.jsxs)("span",{className:"relative shrink-0",children:[a??(n?(0,t.jsx)(n,{className:"h-4 w-4"}):null),f&&(0,t.jsx)("span",{className:"absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-red-500 shadow-(--shadow-extract-12)","aria-hidden":"true"}),I&&!f&&R&&(0,t.jsxs)("span",{className:"absolute -right-0.5 -top-0.5 flex h-2 w-2","aria-hidden":"true",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-600 dark:bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-blue-600 dark:bg-blue-400 shadow-(--shadow-extract-12)"})]}),I&&!f&&!R&&T&&(0,t.jsx)("span",{className:z("absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full shadow-(--shadow-extract-12)",d==="danger"?"bg-red-600":d==="warning"?"bg-amber-500":"bg-primary"),"aria-hidden":"true"})]}),(0,t.jsx)("span",{className:I?fv:z("min-w-0 flex-1 truncate",l),children:s}),!I&&y,!I&&h&&(0,t.jsx)(ct,{variant:"ghost",className:z("ml-auto px-1.5 text-(length:--text-nano) leading-none",p==="amber"?"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400":"bg-muted text-muted-foreground"),children:h}),!I&&(R||S)&&(0,t.jsxs)("span",{className:"ml-auto flex items-center gap-1.5",children:[S,R&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-600 dark:bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-600 dark:bg-blue-400"})]}),(0,t.jsxs)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:[g," live"]})]})]}),!I&&T&&(0,t.jsx)(ct,{variant:"ghost",className:z("ml-auto px-1.5 leading-none",d==="danger"?"bg-red-600/90 text-red-50":d==="warning"?"bg-amber-500/90 text-amber-50":"bg-primary text-primary-foreground"),children:c})]});return I?(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)("div",{children:$})}),(0,t.jsx)(Un,{side:"right",children:s})]}):$}r(Ya,"SidebarNavItem");var dJe=3,IJ=12e4,uJe=[{value:"top",label:"Top"},{value:"alphabetical",label:"Alphabetical"},{value:"recent",label:"Recent"}];function fy(e,s){const n=e[s];if(!n)return 0;const a=new Date(n).getTime();return Number.isFinite(a)?a:0}r(fy,"agentTimestamp");function AJ(e,s){if(s==="top")return e;const n=[...e];return s==="alphabetical"?(n.sort((a,i)=>a.name.localeCompare(i.name,void 0,{sensitivity:"base"})),n):(n.sort((a,i)=>{const o=fy(i,"lastHeartbeatAt")-fy(a,"lastHeartbeatAt");if(o!==0)return o;const l=fy(i,"updatedAt")-fy(a,"updatedAt");if(l!==0)return l;const c=fy(i,"createdAt")-fy(a,"createdAt");return c!==0?c:a.name.localeCompare(i.name,void 0,{sensitivity:"base"})}),n)}r(AJ,"sortAgents");var mJe="opacity-0 transition-opacity group-hover/agent:opacity-100 group-focus-within/agent:opacity-100";function hJe({activeAgentId:e,activeTab:s,agent:n,disabled:a,isMobile:i,leaving:o,onLeaveAgent:l,onPauseResume:c,rail:d,runCount:m,setSidebarOpen:h,builtInStatus:p,starred:f=!1,onToggleStar:g,starPending:v=!1}){const y=jc(n),w=s?`${Qu(n)}/${s}`:Qu(n),S=`${Qu(n)}/configuration`,j=e===y,N=n.status==="paused",_=N&&n.pauseReason==="budget",A=n.orgChainHealth?.status==="invalid_org_chain",C=N?"Resume agent":"Pause agent",I=a||n.status==="pending_approval"||_||N&&A,T=a?"Updating...":_?"Budget paused":N&&A?"Invalid org chain":C,R=p==="needs_setup"||p==="pending_approval",L=[R?`Built-in agent ${p.replace(/_/g," ")}`:null,A?"Invalid reporting chain":null].filter(Boolean).join(", ")||void 0,O=(0,t.jsx)(Ya,{to:w,label:n.name,iconNode:(0,t.jsx)(pr,{agent:n,size:16,className:"shrink-0 h-4 w-4"}),active:j,liveCount:m,labelClassName:R?"min-w-(--sz-4_5rem) flex-initial":void 0,className:z("min-w-0 flex-1",f&&!i?"pr-14":"pr-8"),trailing:R||A?(0,t.jsxs)("span",{className:"ml-1 flex shrink-0 items-center gap-1",children:[R?(0,t.jsx)(wj,{status:p,compact:!0}):null,A?(0,t.jsx)(Rs,{className:"h-3.5 w-3.5 shrink-0 text-amber-500","aria-label":"Invalid reporting chain"}):null]}):void 0,trailingLabel:L,liveAccessory:n.pauseReason==="budget"?(0,t.jsx)(y1,{title:"Agent paused by budget"}):void 0});return d?O:(0,t.jsxs)("div",{className:"group/agent relative flex items-center",children:[O,f&&!i&&g?(0,t.jsx)("span",{className:"absolute right-10 top-1/2 -translate-y-1/2",children:(0,t.jsx)(l0,{size:"row",quiet:!0,starred:!0,pending:v,resourceName:n.name,onToggle:r(()=>g(n,!1),"onToggle"),revealClassName:mJe})}):null,(0,t.jsxs)(fa,{children:[(0,t.jsx)(pa,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:z("absolute right-3 top-1/2 h-6 w-6 -translate-y-1/2 transition-opacity data-[state=open]:pointer-events-auto data-[state=open]:opacity-100",i?"opacity-100":"pointer-events-none opacity-0 group-hover/agent:pointer-events-auto group-hover/agent:opacity-100 group-focus-within/agent:pointer-events-auto group-focus-within/agent:opacity-100"),"aria-label":`Open actions for ${n.name}`,children:(0,t.jsx)(Ei,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(xa,{align:"end",className:"w-48",children:[g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(ps,{onClick:r(()=>{v||g(n,!f)},"onClick"),disabled:v,children:[v?(0,t.jsx)(it,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Th,{className:z("size-4",f&&"fill-amber-500 text-amber-500")}),(0,t.jsx)("span",{children:f?"Remove from starred":"Star agent"})]}),(0,t.jsx)(ui,{})]}):null,(0,t.jsx)(ps,{asChild:!0,children:(0,t.jsxs)(Ge,{to:S,onClick:r(()=>{i&&h(!1)},"onClick"),children:[(0,t.jsx)(Kl,{className:"size-4"}),(0,t.jsx)("span",{children:"Edit agent"})]})}),(0,t.jsx)(ui,{}),(0,t.jsxs)(ps,{onClick:r(()=>{I||c(n,N?"resume":"pause")},"onClick"),disabled:I,title:_?"Agent was paused by budget limits":void 0,children:[N?(0,t.jsx)(f1,{className:"size-4"}):(0,t.jsx)(dd,{className:"size-4"}),(0,t.jsx)("span",{children:T})]}),(0,t.jsx)(ui,{}),(0,t.jsxs)(ps,{onClick:r(()=>{o||l(n)},"onClick"),disabled:o,children:[o?(0,t.jsx)(it,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Yh,{className:"size-4"}),(0,t.jsx)("span",{children:o?"Leaving...":"Leave agent"})]})]})]})]})}r(hJe,"SidebarAgentItem");function pJe({streamlined:e=!1}={}){const[s,n]=(0,u.useState)(!0),[a,i]=(0,u.useState)(()=>new Set),[o,l]=(0,u.useState)(0),c=(0,u.useRef)(new Map),d=Kt(),{selectedCompanyId:m}=xs(),{openNewAgent:h}=$o(),{isMobile:p,setSidebarOpen:f,collapsed:g,peeking:v}=Wa(),y=g&&!v,{pushToast:w}=da(),S=ea(),{data:j}=ee({queryKey:P.agents.list(m),queryFn:r(()=>zt.list(m),"queryFn"),enabled:!!m}),{data:N}=ee({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn"),enabled:!!m}),_=N?.enableBuiltInAgents===!0,{data:A}=ee({queryKey:P.builtInAgents.list(m),queryFn:r(()=>fh.list(m),"queryFn"),enabled:!!m&&_}),C=(0,u.useMemo)(()=>{const xe=new Map;if(!_)return xe;for(const Ae of A??[])Ae.agentId&&xe.set(Ae.agentId,Ae.status);return xe},[A,_]),{data:I}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn")}),T=xf(m),R=gf(m),L=P.liveRuns(m),O=mo({companyId:m,resourceKey:"live-runs",queryKey:L,enabled:!!m,refetchInterval:!1,leaderOnly:!0}),{data:$,dataUpdatedAt:E}=ee({queryKey:L,queryFn:r(()=>Zr.liveRunsForCompany(m),"queryFn"),enabled:O.enabled,refetchInterval:O.refetchInterval});ho(O,$,E);const q=(0,u.useMemo)(()=>{const xe=new Map;for(const Ae of $??[])xe.set(Ae.agentId,(xe.get(Ae.agentId)??0)+1);return xe},[$]),B=(0,u.useMemo)(()=>{const xe=new Set;for(const[Ae,Ye]of q)Ye>0&&xe.add(Ae);return xe},[q]),K=(0,u.useMemo)(()=>(j??[]).filter(xe=>xe.status!=="terminated"&&(!T.isSuccess||kx(T.data,"agent",xe.id)!=="left")),[j,T.data,T.isSuccess]),U=I?.user?.id??I?.session?.userId??null,D=(0,u.useMemo)(()=>m?iue(m,U):null,[U,m]),[V,H]=(0,u.useState)(()=>D?Nj(D):"top"),{orderedAgents:J}=cue({agents:K,companyId:m,userId:U}),X=(0,u.useMemo)(()=>AJ(J,V),[J,V]),le=(0,u.useMemo)(()=>new Set(X.map(xe=>xe.id)),[X]);(0,u.useEffect)(()=>{const xe=Date.now();for(const Ae of B)c.current.set(Ae,xe);for(const Ae of c.current.keys())le.has(Ae)||c.current.delete(Ae)},[B,le]);const ce=(0,u.useMemo)(()=>{const xe=Date.now(),Ae=c.current;return X.filter(Ye=>{if((q.get(Ye.id)??0)>0)return!0;const Oe=Ae.get(Ye.id);return Oe!==void 0&&xe-Oe<=IJ})},[q,o,X]),te=ce.length>0,re=e?te?ce:X.slice(0,dJe):X,de=e&&X.length>0,Z=S.pathname.match(/^\/(?:[^/]+\/)?agents\/([^/]+)(?:\/([^/]+))?/),Y=Z?.[1]??null,G=Z?.[2]??null;(0,u.useEffect)(()=>{if(!D){H("top");return}H(Nj(D))},[D]),(0,u.useEffect)(()=>{if(!D)return;const xe=r(Ye=>{Ye.key===D&&H(Nj(D))},"onStorage"),Ae=r(Ye=>{const Oe=Ye.detail;!Oe||Oe.storageKey!==D||H(Oe.sortMode)},"onCustomEvent");return window.addEventListener("storage",xe),window.addEventListener(HS,Ae),()=>{window.removeEventListener("storage",xe),window.removeEventListener(HS,Ae)}},[D]),(0,u.useEffect)(()=>{if(!e)return;const xe=Date.now();let Ae=null;for(const Oe of X){if((q.get(Oe.id)??0)>0)continue;const Xe=c.current.get(Oe.id);if(Xe===void 0)continue;const me=Xe+IJ;me<xe||(Ae=Ae===null?me:Math.min(Ae,me))}if(Ae===null)return;const Ye=window.setTimeout(()=>{l(Oe=>Oe+1)},Math.max(0,Ae-xe+1));return()=>{window.clearTimeout(Ye)}},[e,X,q,o]);const fe=(0,u.useCallback)(xe=>{const Ae=xe==="alphabetical"||xe==="recent"?xe:"top";H(Ae),D&&lue(D,Ae)},[D]),se=ke({mutationFn:r(({agent:xe,action:Ae})=>Ae==="pause"?zt.pause(xe.id,m??void 0):zt.resume(xe.id,m??void 0),"mutationFn"),onMutate:r(({agent:xe})=>{i(Ae=>{const Ye=new Set(Ae);return Ye.add(xe.id),Ye})},"onMutate"),onSuccess:r(async(xe,{agent:Ae,action:Ye})=>{m&&await Promise.all([d.invalidateQueries({queryKey:P.agents.list(m)}),d.invalidateQueries({queryKey:P.liveRuns(m)}),d.invalidateQueries({queryKey:P.dashboard(m)})]),await Promise.all([d.invalidateQueries({queryKey:P.agents.detail(Ae.id)}),d.invalidateQueries({queryKey:P.agents.detail(jc(Ae))})]),w({title:Ye==="pause"?"Agent paused":"Agent resumed",body:Ae.name,tone:"success"})},"onSuccess"),onError:r((xe,{agent:Ae,action:Ye})=>{w({title:Ye==="pause"?"Could not pause agent":"Could not resume agent",body:xe instanceof Error?xe.message:Ae.name,tone:"error"})},"onError"),onSettled:r((xe,Ae,{agent:Ye})=>{i(Oe=>{const Xe=new Set(Oe);return Xe.delete(Ye.id),Xe})},"onSettled")}),ae=(0,u.useCallback)(xe=>R.mutate({resourceType:"agent",resourceId:xe.id,resourceName:xe.name,state:"left"}),[R]),ie=(0,u.useCallback)(xe=>R.isPending&&R.variables?.resourceType==="agent"&&R.variables.resourceId===xe.id,[R.isPending,R.variables]),ue=(0,u.useCallback)((xe,Ae)=>R.mutate({resourceType:"agent",resourceId:xe.id,resourceName:xe.name,starred:Ae}),[R]),pe=(0,u.useCallback)(xe=>R.isPending&&R.variables?.resourceType==="agent"&&R.variables.resourceId===xe.id&&R.variables.starred!==void 0,[R.isPending,R.variables]),be=(0,u.useMemo)(()=>new Set(k5(T.data,"agent")),[T.data]),oe=(0,u.useMemo)(()=>AJ(K.filter(xe=>be.has(xe.id)),"alphabetical"),[K,be]),je=(0,u.useMemo)(()=>re.filter(xe=>!be.has(xe.id)),[re,be]),_e=r((xe,Ae)=>(0,t.jsx)(hJe,{activeAgentId:Y,activeTab:G,agent:xe,disabled:a.has(xe.id),isMobile:p,leaving:ie(xe),onLeaveAgent:ae,onPauseResume:r((Ye,Oe)=>se.mutate({agent:Ye,action:Oe}),"onPauseResume"),rail:y,runCount:q.get(xe.id)??0,setSidebarOpen:f,builtInStatus:C.get(xe.id),starred:Ae||o0(T.data,"agent",xe.id),onToggleStar:ue,starPending:pe(xe)},xe.id),"renderAgentRow");return(0,t.jsxs)(px,{label:"Agents",collapsible:{open:s,onOpenChange:n},headerAction:{ariaLabel:"New agent",icon:yn,onClick:h},menu:{ariaLabel:"Agents section actions",actions:[{type:"item",label:"Browse agents",icon:Xo,href:"/agents/all"},{type:"separator"}],radioLabel:"Agent sort",radioChoices:uJe,radioValue:V,onRadioValueChange:fe},children:[oe.map(xe=>_e(xe,!0)),je.map(xe=>_e(xe,!1)),de&&(()=>{const xe=(0,t.jsxs)(Ge,{to:"/agents/all",state:ff,"aria-label":y?"See all agents":void 0,onClick:r(()=>{p&&f(!1)},"onClick"),className:"flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(Xo,{className:"shrink-0 h-4 w-4"}),(0,t.jsx)("span",{className:y?"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none":void 0,children:"See all agents"})]});return y?(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:xe}),(0,t.jsx)(Un,{side:"right",children:"See all agents"})]}):xe})()]})}r(pJe,"SidebarAgents");var fJe="opacity-0 transition-opacity group-hover/starred-project:opacity-100 group-focus-within/starred-project:opacity-100";function xJe(){const{selectedCompanyId:e}=xs(),{isMobile:s,setSidebarOpen:n,collapsed:a,peeking:i}=Wa(),o=a&&!i,l=ea(),{data:c}=ee({queryKey:P.projects.list(e),queryFn:r(()=>ia.list(e),"queryFn"),enabled:!!e}),d=xf(e),m=gf(e),h=l.pathname.match(/^\/(?:[^/]+\/)?projects\/([^/]+)/)?.[1]??null,p=(0,u.useMemo)(()=>{if(!d.isSuccess)return[];const y=new Set(k5(d.data,"project"));if(y.size===0)return[];const w=new Map((c??[]).map(S=>[S.id,S]));return Array.from(y).map(S=>w.get(S)).filter(S=>!!S).sort((S,j)=>S.name.localeCompare(j.name,void 0,{sensitivity:"base"}))},[d.data,d.isSuccess,c]),f=(0,u.useCallback)(y=>m.mutate({resourceType:"project",resourceId:y.id,resourceName:y.name,starred:!1}),[m]),g=(0,u.useCallback)(y=>m.mutate({resourceType:"project",resourceId:y.id,resourceName:y.name,state:"left"}),[m]),v=(0,u.useCallback)(y=>m.isPending&&m.variables?.resourceType==="project"&&m.variables.resourceId===y.id,[m.isPending,m.variables]);return!d.isSuccess||p.length===0?null:(0,t.jsx)("div",{className:"flex flex-col gap-0.5","aria-label":"Starred projects",children:p.map(y=>{const w=n0(y),S=h===w||h===y.id,j=v(y),N=j&&m.variables?.starred===!1,_=j&&m.variables?.state==="left",A=o0(d.data,"project",y.id),C=(0,t.jsxs)(a0,{to:`/projects/${w}/issues`,state:ff,onClick:r(()=>{s&&n(!1)},"onClick"),className:z("flex min-w-0 flex-1 items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 pr-8 text-(length:--text-compact) font-medium transition-colors",!o&&"pl-6",S?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground"),children:[(0,t.jsx)(Hm,{color:y.color??null,icon:y.icon??null,size:"xs"}),(0,t.jsx)("span",{className:o?fv:"flex-1 truncate",children:y.name}),!o&&y.pauseReason==="budget"?(0,t.jsx)(y1,{title:"Project paused by budget"}):null]});return(0,t.jsxs)("div",{className:"group/starred-project relative flex items-center",children:[o?(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)("div",{className:"min-w-0 flex-1",children:C})}),(0,t.jsx)(Un,{side:"right",children:y.name})]}):C,!o&&!s?(0,t.jsx)("span",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:(0,t.jsx)(l0,{size:"row",quiet:!0,starred:A,pending:N,resourceName:y.name,onToggle:r(()=>f(y),"onToggle"),revealClassName:fJe})}):null,!o&&s?(0,t.jsxs)(fa,{children:[(0,t.jsx)(pa,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:"absolute right-3 top-1/2 h-6 w-6 -translate-y-1/2 opacity-100","aria-label":`Open actions for ${y.name}`,children:(0,t.jsx)(Ei,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(xa,{align:"end",className:"w-48",children:[(0,t.jsxs)(ps,{onClick:r(()=>{j||f(y)},"onClick"),disabled:j,children:[N?(0,t.jsx)(it,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Th,{className:"size-4 fill-amber-500 text-amber-500"}),(0,t.jsx)("span",{children:"Remove from starred"})]}),(0,t.jsx)(ui,{}),(0,t.jsxs)(ps,{onClick:r(()=>{j||g(y)},"onClick"),disabled:j,children:[_?(0,t.jsx)(it,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Yh,{className:"size-4"}),(0,t.jsx)("span",{children:"Leave project"})]})]})]}):null]},y.id)})})}r(xJe,"SidebarStarredProjects");var ege="size-5 shrink-0 rounded-md text-(length:--text-micro)",tge="size-(--organization-popover-avatar-size) shrink-0 rounded-lg text-(length:--text-micro)",sge="h-(--organization-popover-company-row-height) min-w-0 gap-(--organization-popover-row-gap) rounded-lg px-2.5 py-0 text-(length:--text-compact) focus:bg-accent/50 focus:text-foreground",z4="h-(--organization-popover-action-row-height) gap-(--organization-popover-row-gap) rounded-lg px-2.5 py-0 text-(length:--text-compact) font-medium leading-(--organization-popover-action-line-height) text-foreground focus:bg-accent/50 focus:text-foreground";function nge({company:e,inPopover:s=!1}){return(0,t.jsx)(Dx,{companyName:e.name,logoUrl:e.logoUrl,className:s?tge:ege})}r(nge,"WorkspaceIcon");function gJe({displayName:e}){return(0,t.jsx)(Dx,{companyName:e,className:tge})}r(gJe,"StackIcon");function bJe({displayName:e,company:s}){return(0,t.jsx)(Dx,{companyName:e,logoUrl:s?.logoUrl,className:ege})}r(bJe,"CurrentStackIcon");function vJe({stack:e,isSelected:s,onSelect:n}){return(0,t.jsxs)(ps,{onSelect:r(()=>n(e),"onSelect"),className:sge,children:[(0,t.jsx)(gJe,{displayName:e.displayName}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate font-medium leading-(--organization-popover-name-line-height)",title:e.displayName,children:e.displayName}),(0,t.jsx)("span",{className:"block truncate text-(length:--text-nano) leading-(--organization-popover-prefix-line-height) text-muted-foreground",title:e.stackSlug,children:e.stackSlug})]}),(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center",children:s?(0,t.jsx)(fs,{className:"size-4 text-foreground"}):null})]})}r(vJe,"CloudStackItem");function yJe({company:e,isEditing:s,isSelected:n,onSelect:a}){const{attributes:i,listeners:o,setActivatorNodeRef:l,setNodeRef:c,transform:d,transition:m,isDragging:h}=Fw({id:e.id,disabled:!s});return(0,t.jsxs)(ps,{ref:c,style:{transform:Lw.Transform.toString(d),transition:m,zIndex:h?10:void 0},onSelect:r(p=>{if(s){p.preventDefault();return}a(e)},"onSelect"),className:z(sge,s&&"cursor-grab",h&&"opacity-80"),children:[(0,t.jsx)(nge,{company:e,inPopover:!0}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate font-medium leading-(--organization-popover-name-line-height)",children:e.name}),s?null:(0,t.jsx)("span",{className:"block truncate text-(length:--text-nano) leading-(--organization-popover-prefix-line-height) text-muted-foreground",children:e.issuePrefix})]}),s?(0,t.jsx)("button",{type:"button",ref:l,"aria-label":`Reorder ${e.name}`,className:"inline-flex size-8 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-(length:--rad-2) focus-visible:ring-ring",onClick:r(p=>{p.preventDefault(),p.stopPropagation()},"onClick"),...i,...o,children:(0,t.jsx)(jz,{className:"size-4","aria-hidden":"true"})}):(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center",children:n?(0,t.jsx)(fs,{className:"size-4 text-foreground"}):null})]})}r(yJe,"SortableCompanyItem");function jJe(e={}){return(0,t.jsx)(cme,{...e,children:(0,t.jsx)(wJe,{...e})})}r(jJe,"SidebarCompanyMenu");function wJe({open:e,onOpenChange:s}){const[n,a]=(0,u.useState)(!1),[i,o]=(0,u.useState)(!1),{companies:l,selectedCompany:c,setSelectedCompanyId:d,companyListUnavailable:m,retryCompanies:h}=xs(),{openOnboarding:p}=$o(),{isMobile:f,setSidebarOpen:g,collapsed:v,peeking:y}=Wa(),w=v&&!y,S=ea(),j=Hn(),N=e??n,_=s??a,A=Ow(nf(az,{activationConstraint:{distance:8}}),nf(sce,{activationConstraint:{delay:180,tolerance:6}})),C=(0,u.useMemo)(()=>l.filter(G=>G.status!=="archived"),[l]),{data:I}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),T=I?.user?.id??I?.session?.userId??null,{orderedCompanies:R,persistOrder:L}=ome({companies:C,userId:T}),O=Qc(),$=!!O,{hidden:E,loaded:q}=Zm(),B=q&&!BS(E,"company.members")&&!BS(E,"company.invites"),K=O?.cloudBaseUrl??null,U=ee({queryKey:P.cloud.stacks,queryFn:r(()=>ame.listStacks(),"queryFn"),enabled:$,staleTime:3e4,retry:!1}),D=U.data?.stacks??[],V=$?D.find(G=>G.isCurrent)??D.find(G=>!!O?.stackSlug&&G.stackSlug===O?.stackSlug)??null:null,H=$?R5(K):null,J=$?"organization":"company",X=$?V?.displayName??O?.stackDisplayName??O?.stackSlug??null:c?.name??null,le=Yw({onSignedOut:te});function ce(G){G||o(!1),_(G)}r(ce,"handleOpenChange");function te(){_(!1),o(!1),f&&g(!1)}r(te,"closeNavigationChrome");function re(G){const fe=S.pathname.split("/")[1]?.toUpperCase(),se=C.some(ie=>ie.issuePrefix.toUpperCase()===fe),ae=G.id!==c?.id&&(S.pathname.startsWith("/instance/")||se);d(G.id),_(!1),f&&g(!1),ae&&j(`/${G.issuePrefix}/dashboard`)}r(re,"selectCompany");function de(G){if(_(!1),f&&g(!1),G.stackSlug===V?.stackSlug)return;const fe=lme(K,G.stackSlug);fe&&Nc(fe)}r(de,"selectStack");function Z(){if(_(!1),f&&g(!1),$){H&&Nc(H);return}p({initialStep:1})}r(Z,"addCompany");const Y=(0,u.useCallback)(G=>{const{active:fe,over:se}=G;if(!se||fe.id===se.id)return;const ae=R.map(pe=>pe.id),ie=ae.indexOf(fe.id),ue=ae.indexOf(se.id);ie===-1||ue===-1||L(n5(ae,ie,ue))},[R,L]);return(0,t.jsxs)(fa,{open:N,onOpenChange:ce,children:[(0,t.jsx)(pa,{asChild:!0,children:(0,t.jsxs)(F,{variant:"ghost",className:"h-9 min-w-0 flex-1 justify-start gap-2 px-4 text-left hover:bg-accent/50 hover:text-foreground has-[>svg]:px-4 dark:hover:bg-accent/50","aria-label":X?`Open ${X} ${J} switcher`:`Open ${J} switcher`,children:[(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[$?X?(0,t.jsx)(bJe,{displayName:X,company:c}):null:c?(0,t.jsx)(nge,{company:c}):null,(0,t.jsx)("span",{className:z("min-w-0 truncate text-sm font-bold text-foreground",w&&"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none"),title:X??void 0,children:X??($?"Select organization":"Select company")})]}),!w&&(0,t.jsx)(u5,{className:"size-3.5 shrink-0 text-muted-foreground"})]})}),(0,t.jsxs)(xa,{align:"start",sideOffset:8,className:"ml-2 w-(--organization-popover-width) max-w-(--sz-calc-24) overflow-hidden rounded-xl border-border bg-popover p-0 shadow-(--shadow-profile-popover)",children:[(0,t.jsxs)("div",{className:"flex h-(--organization-popover-header-height) items-center justify-between gap-2 px-3.5",children:[(0,t.jsx)(qw,{className:"p-0 text-(length:--text-compact) font-semibold text-foreground",children:"Organizations"}),$?null:(0,t.jsx)("button",{type:"button",onClick:r(G=>{G.preventDefault(),G.stopPropagation(),o(fe=>!fe)},"onClick"),className:"rounded px-1.5 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:i?"Done":"Edit"})]}),(0,t.jsx)("div",{className:"flex max-h-96 flex-col gap-0.5 overflow-y-auto px-2.5 pb-2 pt-1",children:$?(0,t.jsxs)(t.Fragment,{children:[D.map(G=>(0,t.jsx)(vJe,{stack:G,isSelected:G.stackSlug===V?.stackSlug,onSelect:de},G.stackSlug)),D.length===0?(0,t.jsx)(ps,{disabled:!0,children:U.isLoading?"Loading organizations...":U.isError?"Could not load organizations":"No organizations"}):null]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Dw,{sensors:A,collisionDetection:ZC,onDragEnd:Y,children:(0,t.jsx)(Mw,{items:R.map(G=>G.id),strategy:JC,children:R.map(G=>(0,t.jsx)(yJe,{company:G,isEditing:i,isSelected:G.id===c?.id,onSelect:re},G.id))})}),R.length===0?m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ps,{disabled:!0,children:"Couldn't load companies"}),(0,t.jsxs)(ps,{onSelect:r(G=>{G.preventDefault(),h()},"onSelect"),children:[(0,t.jsx)(Ki,{className:"h-4 w-4 mr-2"}),"Try again"]})]}):(0,t.jsx)(ps,{disabled:!0,children:"No companies"}):null]})}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5 border-t border-border px-2.5 pb-2.5 pt-2",children:[$&&!H?null:(0,t.jsxs)(ps,{onClick:Z,className:z4,disabled:i,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(yn,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:"Create organization"})]}),B?(0,t.jsx)(ps,{asChild:!0,disabled:i,className:z4,children:(0,t.jsxs)(Ge,{to:"/company/settings/invites",onClick:r(G=>{if(i){G.preventDefault();return}te()},"onClick"),children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(wv,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:X?`Invite people to ${X}`:"Invite people"})]})}):null,I?.session?(0,t.jsxs)(ps,{className:z4,onClick:r(()=>le.mutate(),"onClick"),disabled:i||le.isPending,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(Yh,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:le.isPending?"Signing out...":"Sign out"})]}):null]})]})]})}r(wJe,"BuiltinCompanyMenu");function RJ(){const{openNewIssue:e}=$o(),[s,n]=(0,u.useState)(!0),[a,i]=(0,u.useState)(!0),{selectedCompanyId:o,selectedCompany:l}=xs(),{collapsed:c,peeking:d}=Wa(),m=c&&!d,h=Zz(o),{data:p,isFetched:f}=ee({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn")}),g=P.liveRuns(o),v=mo({companyId:o,resourceKey:"live-runs",queryKey:g,enabled:!!o,refetchInterval:!1,leaderOnly:!0}),{data:y,dataUpdatedAt:w}=ee({queryKey:g,queryFn:r(()=>Zr.liveRunsForCompany(o),"queryFn"),enabled:v.enabled,refetchInterval:v.refetchInterval});ho(v,y,w);const S=y?.length??0,j=p?.enableIsolatedWorkspaces===!0,N=p?.enableApps===!0,_=p?.enablePipelines===!0,A=p?.enableStatusCards===!0,C=!f,I=p?.enableGoalsSidebarLink===!0,T=p?.enableDecisions===!0,{data:R}=ee({queryKey:P.attention(o),queryFn:r(()=>I5.list(o),"queryFn"),enabled:!!o&&T,refetchInterval:6e4}),L=Lue(R),O=p?.enableCases===!0,$=!0,E=p?.enableConferenceRoomChat===!0,q={companyId:o,companyPrefix:l?.issuePrefix??null};return(0,t.jsxs)("aside",{className:"w-full h-full min-h-0 border-r border-border bg-background flex flex-col",children:[(0,t.jsx)("div",{className:"flex items-center gap-1 px-3 h-12 shrink-0",children:(0,t.jsx)(jJe,{})}),(0,t.jsxs)("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide flex flex-col gap-4 pointer-coarse:gap-3 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(()=>{const B=(0,t.jsxs)("button",{onClick:r(()=>e(),"onClick"),"data-slot":"icon-button","aria-label":m?"New Task":void 0,className:"flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium text-foreground/80 hover:bg-accent/50 hover:text-foreground transition-colors",children:[(0,t.jsx)(g1,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:m?fv:"truncate",children:"New Task"})]});return m?(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:B}),(0,t.jsx)(Un,{side:"right",children:"New Task"})]}):B})(),(0,t.jsx)(Ya,{to:"/search",label:"Search",icon:ha}),(0,t.jsx)(Ya,{to:"/dashboard",label:"Dashboard",icon:hx,liveCount:S}),(0,t.jsx)(Ya,{to:"/inbox",label:"Inbox",icon:Ed,badge:h.inbox,badgeLabel:"unread",badgeTone:h.failedRuns>0?"danger":"default",alert:h.failedRuns>0}),T?(0,t.jsx)(Ya,{to:"/decisions",label:"Decisions",icon:x1,badge:L,badgeLabel:"decisions"}):null,A?(0,t.jsx)(Ya,{to:"/status",label:"Status",icon:Hw,textBadge:"beta"}):null,E?(0,t.jsx)(Ya,{to:"/board-chat",label:"Conference Room",icon:Sde}):null]}),(0,t.jsxs)(px,{label:"Work",collapsible:{open:s,onOpenChange:n},children:[(0,t.jsx)(Ya,{to:"/issues",label:"Tasks",icon:od}),O?(0,t.jsx)(Ya,{to:"/cases",label:"Cases",icon:hl,textBadge:"beta"}):null,(0,t.jsx)(Ya,{to:"/routines",label:"Routines",icon:fu}),_?(0,t.jsx)(Ya,{to:"/pipelines",label:"Pipelines",icon:sl}):null,I?(0,t.jsx)(Ya,{to:"/goals",label:"Goals",icon:vx}):C?(0,t.jsx)("div",{"data-testid":"sidebar-goals-placeholder",className:"h-8 pointer-coarse:h-7","aria-hidden":"true"}):null,(0,t.jsx)(Ya,{to:"/artifacts",label:"Artifacts",icon:Eh}),(0,t.jsx)(Ya,{to:"/skills",label:"Skills",icon:Ul}),j?(0,t.jsx)(Ya,{to:"/workspaces",label:"Workspaces",icon:sl}):null,(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Ya,{to:"/projects",label:"Projects",icon:Io}),(0,t.jsx)(xJe,{})]}),(0,t.jsx)(zh,{slotTypes:["sidebar"],context:q,className:"flex flex-col gap-0.5",itemClassName:"text-(length:--text-compact) font-medium",missingBehavior:"placeholder"}),(0,t.jsx)(Gw,{placementZones:["sidebar"],context:q,className:"flex flex-col gap-0.5",itemClassName:"text-(length:--text-compact) font-medium"})]}),null,(0,t.jsx)(pJe,{streamlined:$}),(0,t.jsxs)(px,{label:"Company",collapsible:{open:a,onOpenChange:i},children:[(0,t.jsx)(Ya,{to:"/org",label:"Org",icon:qb}),N?(0,t.jsx)(Ya,{to:"/apps",label:"Connectors",icon:KR}):null,(0,t.jsx)(Ya,{to:"/timeline",label:"Timeline",icon:yg}),(0,t.jsx)(Ya,{to:"/costs",label:"Costs",icon:_h}),(0,t.jsx)(Ya,{to:"/activity",label:"Activity",icon:Sl}),(0,t.jsx)(Ya,{to:"/company/settings",label:"Settings",icon:Ld})]}),(0,t.jsx)(zh,{slotTypes:["sidebarPanel"],context:q,className:"flex flex-col gap-3",itemClassName:"rounded-lg border border-border p-3",missingBehavior:"placeholder"})]})]})}r(RJ,"Sidebar");function NJe(e){const s=e.manifestJson.environmentDrivers??[];return s.length===0?!1:s.every(n=>n.kind==="sandbox_provider")}r(NJe,"isSandboxProviderOnly");function kJe(){const{selectedCompany:e,selectedCompanyId:s}=xs(),{isMobile:n,setSidebarOpen:a}=Wa(),{hidden:i}=Zm(),o=r(f=>!i.has(f),"showPage"),l=o("instance.plugins"),c=!!Qc(),{slots:d}=Hc({slotTypes:["companySettingsPage"],companyId:s,enabled:!!s}),{data:m}=ee({queryKey:s?P.sidebarBadges(s):["sidebar-badges","__disabled__"],queryFn:r(async()=>{try{return await pme.get(s)}catch(f){if(f instanceof vn&&(f.status===401||f.status===403))return null;throw f}},"queryFn"),enabled:!!s,retry:!1,refetchInterval:15e3}),{data:h}=ee({queryKey:P.plugins.all,queryFn:r(()=>Jo.list(),"queryFn"),enabled:l}),p=(h??[]).filter(f=>!NJe(f));return(0,t.jsxs)("aside",{className:"w-full h-full min-h-0 border-r border-border bg-background flex flex-col",children:[(0,t.jsx)("div",{className:"flex flex-col gap-1 px-3 py-3 shrink-0",children:(0,t.jsxs)(Ge,{to:"/dashboard",onClick:r(()=>{n&&a(!1)},"onClick"),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(bu,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e?.name??"Company"})]})}),(0,t.jsx)("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide px-3 py-2",children:(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)(Ya,{to:"/company/settings",label:"General",icon:sm,end:!0}),o("instance.profile")&&(0,t.jsx)(Ya,{to:"/company/settings/instance/profile",label:"Profile",icon:b1,end:!0}),o("company.members")&&(0,t.jsx)(Ya,{to:"/company/settings/members",label:"Members",icon:Xo,badge:m?.joinRequests??0,end:!0}),d.filter(f=>f.routePath).map(f=>(0,t.jsx)(Ya,{to:`/company/settings/${f.routePath}`,label:f.displayName,icon:Pg,end:!0},`${f.pluginKey}:${f.id}`)),o("company.invites")&&(0,t.jsx)(Ya,{to:"/company/settings/invites",label:"Invites",icon:C5e,end:!0}),o("company.secrets")&&(0,t.jsx)(Ya,{to:"/company/settings/secrets",label:"Secrets",icon:yi,end:!0}),o("instance.environments")&&(0,t.jsx)(Ya,{to:"/company/settings/instance/environments",label:"Environments",icon:Cde,end:!0}),o("instance.access")&&(0,t.jsx)(Ya,{to:"/company/settings/instance/access",label:"Access",icon:l5,end:!0}),o("instance.heartbeats")&&(0,t.jsx)(Ya,{to:"/company/settings/instance/heartbeats",label:"Heartbeats",icon:th,end:!0}),o("company.export")&&(0,t.jsx)(Ya,{to:"/company/export",label:"Export",icon:zo}),!c&&o("company.import")&&(0,t.jsx)(Ya,{to:"/company/import",label:"Import",icon:Zj,end:!0}),o("instance.experimental")&&(0,t.jsx)(Ya,{to:"/company/settings/instance/experimental",label:"Experimental",icon:Zu}),l&&(0,t.jsx)(Ya,{to:"/company/settings/instance/plugins",label:"Plugins",icon:Pg}),l&&p.length>0?(0,t.jsx)("div",{className:"ml-4 mt-1 flex flex-col gap-0.5 border-l border-border/70 pl-3",children:p.map(f=>(0,t.jsx)(a0,{to:`${xh}/plugins/${f.id}`,state:ff,className:r(({isActive:g})=>["rounded-md px-2 py-1.5 text-xs transition-colors",g?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"].join(" "),"className"),children:f.manifestJson.displayName??f.packageName},f.id))}):null,o("instance.adapters")&&(0,t.jsx)(Ya,{to:"/company/settings/instance/adapters",label:"Adapters",icon:Lm})]})})]})}r(kJe,"CompanySettingsSidebar");function SJe(){const{pathname:e}=ea(),{selectedCompany:s}=xs(),{isMobile:n,setSidebarOpen:a}=Wa(),i=wme(),{enabled:o}=T5(),l=rU.filter(d=>!jme(d.key)||o);if(e.endsWith("/apps/chat/connect"))return(0,t.jsx)(Mz,{});const c=e.match(/\/apps\/chat\/([^/]+)(?:\/(?:settings|access|reviews|conversations|activity))?\/?$/);return c?(0,t.jsx)(yme,{endpointId:c[1],NavItem:Ya}):(0,t.jsxs)("aside",{className:"w-full h-full min-h-0 border-r border-border bg-background flex flex-col",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 px-3 py-3 shrink-0",children:[(0,t.jsxs)(Ge,{to:"/dashboard",onClick:r(()=>{n&&a(!1)},"onClick"),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(bu,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:s?.name??"Company"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1",children:[(0,t.jsx)(uH,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"flex-1 truncate text-sm font-bold text-foreground",children:"Connectors"})]})]}),(0,t.jsxs)("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide px-3 py-2",children:[(0,t.jsx)("div",{className:"px-3 pb-1 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Connectors"}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)(Ya,{to:"/apps",label:"Browse",icon:VS,end:!0}),(0,t.jsx)(Ya,{to:"/apps/review",label:"Review",icon:Qw,badge:i>0?i:void 0,badgeTone:"warning",badgeLabel:"waiting for your OK"})]}),(0,t.jsx)("div",{className:"px-3 pb-1 pt-4 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Developer"}),(0,t.jsx)("p",{className:"px-3 pb-1.5 text-(length:--text-micro) leading-snug text-muted-foreground/70",children:"Advanced setup for developers. Most teams never open this."}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)(Ya,{to:"/apps/connections",label:"Connections",icon:uH,end:!0}),l.map(d=>(0,t.jsx)(Ya,{to:Dg(d.key),label:d.label,icon:d.icon,end:!0},d.key))]})]})]})}r(SJe,"AppsSidebar");function TJ(e){const{selectedCompanyId:s}=xs(),{isMobile:n,setSidebarOpen:a}=Wa(),i=ee({queryKey:P.tools.connection(e.kind==="connection"?e.connectionId:"__none__"),queryFn:r(()=>ms.getConnection(e.kind==="connection"?e.connectionId:""),"queryFn"),enabled:e.kind==="connection"&&!!e.connectionId}),o=ee({queryKey:P.tools.applications(s??"__none__"),queryFn:r(()=>ms.listApplications(s),"queryFn"),enabled:e.kind==="application"&&!!s}),l=ee({queryKey:P.tools.connections(s??"__none__"),queryFn:r(()=>ms.listConnections(s),"queryFn"),enabled:e.kind==="application"&&!!s}),c=ee({queryKey:P.apps.gallery(s??"__none__"),queryFn:r(()=>ms.listGallery(s),"queryFn"),enabled:!!s}),d=ee({queryKey:P.apps.attention(s??"__none__"),queryFn:r(()=>ms.listAppsAttention(s),"queryFn"),enabled:!!s,refetchInterval:3e4}),m=i.data,h=e.kind==="application"?(o.data?.applications??[]).find(S=>S.id===e.applicationId):null,p=IJe(e.kind==="application"?(l.data?.connections??[]).filter(S=>S.applicationId===e.applicationId):[]),f=m?of(m):h?.name??"App",g=_Je(c.data?.apps??[],m,h??void 0),v=m?.id??p?.id??null,y=v?d.data?.apps.find(S=>S.connection.id===v):null,w=(y?.pendingActionRequestCount??0)+((y?.quarantinedCatalogEntryCount??0)>0?1:0);return(0,t.jsxs)("aside",{className:"flex h-full min-h-0 w-full flex-col border-r border-border bg-background",children:[(0,t.jsxs)("div",{className:"flex shrink-0 flex-col gap-3 px-3 py-3",children:[(0,t.jsxs)(Ge,{to:"/apps/connections",onClick:r(()=>{n&&a(!1)},"onClick"),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(bu,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:"All apps"})]}),(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-2 py-1",children:[(0,t.jsx)(yc,{name:f,logoUrl:k1(g),size:28}),(0,t.jsx)("span",{className:"flex-1 truncate text-sm font-bold text-foreground",children:f})]})]}),(0,t.jsx)("nav",{className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto px-3 py-2",children:(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:E5.map(S=>(0,t.jsx)(Ya,{to:CJe(e,S.key),label:S.label,icon:S.icon,end:!0,badge:S.key==="review"&&w>0?w:void 0,badgeTone:"danger",badgeLabel:"needing review"},S.key))})})]})}r(TJ,"AppDetailSidebar");function CJe(e,s){return e.kind==="connection"?Ku(e.connectionId,s):cS(e.applicationId,s)}r(CJe,"tabHref");function _Je(e,s,n){if(n?.applicationKey){const i=e.find(o=>Bc(o)===n.applicationKey);if(i)return i}const a=(s?.name??n?.name)?.toLowerCase();return a?e.find(i=>Yg(i).toLowerCase()===a)??e.find(i=>Bc(i)===a)??null:null}r(_Je,"galleryEntryFor$1");function IJe(e){const s=e.filter(n=>n.status==="archived");return s.length===0?null:s.reduce((n,a)=>{const i=new Date(n.updatedAt??n.createdAt??0).getTime();return new Date(a.updatedAt??a.createdAt??0).getTime()>i?a:n})}r(IJe,"latestArchivedConnection$1");function U4({identifier:e}){return e?(0,t.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e}):null}r(U4,"CrumbIdentifier");function AJe({context:e}){const{slots:s}=Hc({slotTypes:["globalToolbarButton"],companyId:e.companyId}),{launchers:n}=eU({placementZones:["globalToolbarButton"],companyId:e.companyId,enabled:!!e.companyId});return(0,t.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1 pl-2 empty:hidden",children:[s.length>0?(0,t.jsx)(zh,{slotTypes:["globalToolbarButton"],context:e,className:"flex items-center gap-1"}):null,n.length>0?(0,t.jsx)(Gw,{placementZones:["globalToolbarButton"],context:e,className:"flex items-center gap-1"}):null]})}r(AJe,"GlobalToolbar");function RJe(){const{breadcrumbs:e,mobileToolbar:s}=Ln(),{toggleSidebar:n,isMobile:a}=Wa(),{selectedCompanyId:i,selectedCompany:o}=xs(),l=(0,u.useMemo)(()=>({companyId:i??null,companyPrefix:o?.issuePrefix??null}),[i,o?.issuePrefix]),c=(0,t.jsx)(AJe,{context:l});if(a&&s)return(0,t.jsx)("div",{className:"border-b border-border px-2 h-12 shrink-0 flex items-center",children:s});if(e.length===0)return(0,t.jsx)("div",{className:"border-b border-border px-4 md:px-6 h-12 shrink-0 flex items-center justify-end",children:c});const d=a&&(0,t.jsx)(F,{variant:"ghost",size:"icon-sm",className:"mr-2 shrink-0",onClick:n,"aria-label":"Open sidebar",children:(0,t.jsx)(Nde,{className:"h-5 w-5"})});return e.length===1?(0,t.jsxs)("div",{className:"border-b border-border px-4 md:px-6 h-12 shrink-0 flex items-center",children:[d,(0,t.jsx)("div",{className:"min-w-0 overflow-hidden flex-1",children:e[0].leading||e[0].identifier?(0,t.jsxs)("h1",{className:"flex items-center gap-1.5 text-sm font-semibold uppercase tracking-wider",children:[e[0].leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:e[0].leading}),(0,t.jsx)(U4,{identifier:e[0].identifier}),(0,t.jsx)("span",{className:"truncate",children:e[0].label})]}):(0,t.jsx)("h1",{className:"text-sm font-semibold uppercase tracking-wider truncate",children:e[0].label})}),c]}):(0,t.jsxs)("div",{className:"border-b border-border px-4 md:px-6 h-12 shrink-0 flex items-center",children:[d,(0,t.jsx)("div",{className:"min-w-0 overflow-hidden flex-1",children:(0,t.jsx)(aU,{className:"min-w-0 overflow-hidden",children:(0,t.jsx)(iU,{className:"flex-nowrap",children:e.map((m,h)=>{const p=h===e.length-1;return(0,t.jsxs)(u.Fragment,{children:[h>0&&(0,t.jsx)(tT,{}),(0,t.jsx)(dS,{className:p?"min-w-0":"shrink-0",children:p||!m.href?m.leading||m.identifier?(0,t.jsxs)(XS,{className:"flex min-w-0 items-center gap-1.5",children:[m.leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:m.leading}),(0,t.jsx)(U4,{identifier:m.identifier}),(0,t.jsx)("span",{className:"truncate",children:m.label})]}):(0,t.jsx)(XS,{className:"truncate",children:m.label}):(0,t.jsx)(eT,{asChild:!0,children:m.leading||m.identifier?(0,t.jsxs)(Ge,{to:m.href,onClick:m.onClick,className:"flex items-center gap-1.5",children:[m.leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:m.leading}),(0,t.jsx)(U4,{identifier:m.identifier}),(0,t.jsx)("span",{className:"truncate",children:m.label})]}):(0,t.jsx)(Ge,{to:m.href,onClick:m.onClick,children:m.label})})})]},h)})})})}),c]})}r(RJe,"BreadcrumbBar");var bI=240,UF=208,KF=420,EJ=16;function DT(e){return Math.min(KF,Math.max(UF,e))}r(DT,"clampSidebarWidth");function PJ(e){if(typeof window>"u")return bI;try{const s=window.localStorage.getItem(e);if(!s)return bI;const n=Number.parseInt(s,10);return Number.isFinite(n)?DT(n):bI}catch{return bI}}r(PJ,"readStoredSidebarWidth");function MJ(e,s){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(DT(s)))}catch{}}r(MJ,"writeStoredSidebarWidth");function TJe({children:e,open:s,collapsed:n=!1,peeking:a=!1,resizable:i=!1,storageKey:o="paperclip.sidebar.width",className:l,onPanelMouseEnter:c,onPanelMouseLeave:d,onPanelFocusCapture:m,onPanelBlurCapture:h}){const[p,f]=(0,u.useState)(()=>PJ(o)),[g,v]=(0,u.useState)(!1),y=(0,u.useRef)(p),w=(0,u.useRef)(null);(0,u.useEffect)(()=>{const E=PJ(o);y.current=E,f(E)},[o]);const S=s?p:0,j=s?n?64:S:0,N=s?n&&!a?64:S:0,_=N>j,A=i&&s&&!n,C=(0,u.useMemo)(()=>({width:`${j}px`}),[j]),I=(0,u.useMemo)(()=>({width:`${N}px`}),[N]),T=(0,u.useCallback)(E=>{const q=DT(E);y.current=q,f(q),MJ(o,q)},[o]),R=(0,u.useCallback)(E=>{A&&(E.preventDefault(),E.currentTarget.setPointerCapture(E.pointerId),w.current={startX:E.clientX,startWidth:y.current},v(!0))},[A]),L=(0,u.useCallback)(E=>{if(!w.current)return;const q=DT(w.current.startWidth+E.clientX-w.current.startX);y.current=q,f(q)},[]),O=(0,u.useCallback)(()=>{w.current&&(w.current=null,v(!1),MJ(o,y.current))},[o]),$=(0,u.useCallback)(E=>{A&&(E.key==="ArrowLeft"?(E.preventDefault(),T(p-EJ)):E.key==="ArrowRight"?(E.preventDefault(),T(p+EJ)):E.key==="Home"?(E.preventDefault(),T(UF)):E.key==="End"&&(E.preventDefault(),T(KF)))},[A,T,p]);return(0,t.jsx)("div",{className:z("relative h-full shrink-0",l),style:C,children:(0,t.jsxs)("div",{className:z("absolute inset-y-0 left-0 flex flex-col overflow-hidden",_?"z-30 border-r border-border bg-background shadow-lg":"z-0"),style:I,"data-sidebar-overlay":_?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:m,onBlurCapture:h,children:[e,A?(0,t.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":UF,"aria-valuemax":KF,"aria-valuenow":p,tabIndex:0,className:z("absolute inset-y-0 right-0 z-20 w-3 cursor-col-resize touch-none outline-none","before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-transparent before:transition-colors","hover:before:bg-border focus-visible:before:bg-ring",g&&"before:bg-ring"),onPointerDown:R,onPointerMove:L,onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,onKeyDown:$}):null]})})}r(TJe,"SidebarShell");function EJe({children:e,className:s}){return(0,t.jsx)("div",{"data-secondary-sidebar":"",className:z("h-full w-60 shrink-0 overflow-y-auto border-r border-border bg-background",s),children:(0,t.jsx)(lJe,{children:e})})}r(EJe,"SecondarySidebar");var PJe="/company/settings/instance/profile",MJe="https://docs.paperclip.ing/",DJe="https://paperclip.ing/feedback";function LJe(e){const s=e.trim().split(/\s+/).filter(Boolean);return s.length>=2?`${s[0]?.[0]??""}${s[s.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}r(LJe,"deriveInitials$1");function $Je(e,s,n){const a=[e,s?.split("@")[0],s,n];for(const i of a){const o=i?.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(o)return o}return"me"}r($Je,"deriveUserSlug");function K4({label:e,description:s,icon:n,onClick:a,href:i,external:o=!1}){const l="flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-accent/60",c=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(n,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:e}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:s})]})]});return i?o?(0,t.jsx)("a",{href:i,target:"_blank",rel:"noreferrer",className:l,onClick:a,children:c}):(0,t.jsx)(Ge,{to:i,className:l,onClick:a,children:c}):(0,t.jsx)("button",{type:"button",className:l,onClick:a,children:c})}r(K4,"MenuAction");function DJ({deploymentMode:e,open:s,onOpenChange:n}){const a=!!Qc(),[i,o]=(0,u.useState)(!1),{isMobile:l,setSidebarOpen:c,collapsed:d,peeking:m}=Wa(),h=d&&!m,p=s??i,f=n??o,{data:g}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),v=Yw({onSignedOut:N}),y=g?.user.name?.trim()||"Board",w=g?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),S=LJe(y),j=`/u/${$Je(g?.user.name,g?.user.email,g?.user.id)}`;function N(){f(!1),l&&c(!1)}r(N,"closeNavigationChrome");function _(){v.mutate()}return r(_,"handleSignOut"),(0,t.jsx)("div",{className:"border-t border-r border-border bg-background px-3 py-2",children:(0,t.jsxs)("div",{className:z("flex items-center gap-0.5",!h&&"px-2"),children:[(0,t.jsxs)(nr,{open:p,onOpenChange:f,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:z("flex min-w-0 items-center gap-2.5 rounded-lg text-left text-(length:--text-compact) font-medium text-foreground/80 transition-colors hover:bg-accent/50 hover:text-foreground",h?"w-full px-3 py-2":"flex-1 px-2 py-1.5"),"aria-label":"Open account menu",children:[(0,t.jsxs)(Yi,{size:"sm",children:[g?.user.image?(0,t.jsx)(Vc,{src:g.user.image,alt:y}):null,(0,t.jsx)(Ji,{children:S})]}),(0,t.jsx)("span",{className:z("min-w-0 flex-1 truncate",h&&"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none"),children:y})]})}),(0,t.jsxs)(Wn,{side:"top",align:"start",sideOffset:10,className:"w-(--sz-277px) max-w-(--sz-calc-24) overflow-hidden rounded-t-2xl rounded-b-none border-border p-0 shadow-2xl",children:[(0,t.jsx)("div",{className:"h-24 bg-(image:--gradient-extract-25)"}),(0,t.jsxs)("div",{className:"-mt-8 px-4 pb-4",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"rounded-2xl border-4 border-popover bg-popover p-0.5 shadow-sm",children:(0,t.jsxs)(Yi,{size:"lg",children:[g?.user.image?(0,t.jsx)(Vc,{src:g.user.image,alt:y}):null,(0,t.jsx)(Ji,{children:S})]})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 pt-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold text-foreground",children:y}),(0,t.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:w})]})]}),(0,t.jsxs)("div",{className:"mt-4 space-y-1",children:[(0,t.jsx)(K4,{label:"View profile",description:"Open your activity, task, and usage ledger.",icon:vu,href:j,onClick:N}),(0,t.jsx)(K4,{label:"Edit profile",description:"Update your display name and avatar.",icon:b1,href:PJe,onClick:N}),(0,t.jsx)(K4,{label:"Documentation",description:"Open Paperclip docs in a new tab.",icon:Ww,href:MJe,external:!0,onClick:r(()=>f(!1),"onClick")}),(0,t.jsx)(Aj,{variant:"menu-action",onAfterToggle:r(()=>f(!1),"onAfterToggle")}),e==="authenticated"?(0,t.jsxs)("button",{type:"button",className:z("flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-destructive/10",v.isPending&&"cursor-not-allowed opacity-60"),onClick:_,disabled:v.isPending,children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(Yh,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:v.isPending?"Signing out...":"Sign out"}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:"End this browser session."})]})]}):null,(0,t.jsx)(zxe,{})]})]})]})]}),!h&&!a?(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)("a",{href:DJe,target:"_blank",rel:"noreferrer","aria-label":"Share feedback",className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground/50 transition-colors hover:bg-accent/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(Ex,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsx)(Un,{side:"top",children:"Share feedback"})]}):null]})})}r(DJ,"SidebarAccountMenu");function OJe(e,s){return rge(e,s)[0]?.toLowerCase()??null}r(OJe,"getCompanyRouteSegment");function rge(e,s){if(!s)return[];const n=e.split("/").filter(Boolean);return n.length<2?[]:n[0]?.toUpperCase()!==s.toUpperCase()?[]:n.slice(1)}r(rge,"getCompanyPathSegments");var FJe=new Set(["browse","connections","connect","chat","review","attention","gateways","advanced","app"]);function BJe(e,s){const n=e.split("/").filter(Boolean);return n[0]?.toLowerCase()==="skills"?!0:s?n[0]?.toUpperCase()===s.toUpperCase()&&n[1]?.toLowerCase()==="skills":!1}r(BJe,"isSkillsStoreRoute");function qJe(){const{sidebarOpen:e,setSidebarOpen:s,toggleSidebar:n,collapsed:a,peeking:i,setPeeking:o,isMobile:l,setForceCollapsed:c}=Wa(),{openNewIssue:d,openOnboarding:m}=$o(),{togglePanelVisible:h}=bf(),p=Sc()?.pushToast??null,{companies:f,loading:g,selectedCompany:v,selectedCompanyId:y,selectionSource:w,setSelectedCompanyId:S}=xs(),{companyPrefix:j,pluginRoutePath:N}=ka(),_=Hn(),A=ea(),C=t5(),I=["/company/settings","/company/export","/company/import"].some(We=>A.pathname.includes(We)),T=rge(A.pathname,j),R=T[0]?.toLowerCase()==="tools",L=T[0]?.toLowerCase()==="apps",O=L&&T[1]&&!FJe.has(T[1].toLowerCase())?T[1]:null,$=L&&T[1]?.toLowerCase()==="app"&&T[2]?T[2]:null,E=BJe(A.pathname,j),q=(0,u.useRef)(!1),B=(0,u.useRef)(null),K=(0,u.useRef)(null),U=(0,u.useRef)(new Yde),D=(0,u.useRef)(A.key),V=Qxe(A.pathname,j,l),[H,J]=(0,u.useState)(!1),X=(0,u.useMemo)(()=>{if(!j)return null;const We=j.toUpperCase();return f.find(ze=>ze.issuePrefix.toUpperCase()===We)??null},[f,j]),le=!!j&&!g&&f.length>0&&!X,ce=(0,u.useMemo)(()=>N?.toLowerCase()??OJe(A.pathname,j),[j,A.pathname,N]),te=X?.id??null,re=X?.issuePrefix??null,{slots:de}=Hc({slotTypes:["page","routeSidebar"],companyId:te,enabled:!!(te&&ce)}),Z=(0,u.useMemo)(()=>Vz(de,ce),[ce,de]),Y=(0,u.useMemo)(()=>({companyId:te,companyPrefix:re}),[te,re]),G=I?(0,t.jsx)(kJe,{}):O?(0,t.jsx)(TJ,{kind:"connection",connectionId:O}):$?(0,t.jsx)(TJ,{kind:"application",applicationId:$}):L||R?(0,t.jsx)(SJe,{}):Z?(0,t.jsx)(yu,{slot:Z,context:Y,className:"h-full w-full",missingBehavior:"placeholder"}):null,fe=G!=null,{data:se}=ee({queryKey:P.health,queryFn:r(()=>tm.get(),"queryFn"),retry:!1,refetchInterval:r(We=>We.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1}),ae=ee({queryKey:P.instance.generalSettings,queryFn:r(()=>Ir.getGeneral(),"queryFn")}).data?.keyboardShortcuts===!0,ie=fe||E;(0,u.useLayoutEffect)(()=>(c(ie),()=>c(!1)),[ie,c]),(0,u.useEffect)(()=>{g||q.current||se?.deploymentMode!=="authenticated"&&(se?.cloud||f.length===0&&(q.current=!0,m()))},[f,g,m,se?.cloud,se?.deploymentMode]),(0,u.useEffect)(()=>{if(!j||g||f.length===0)return;if(!X){const ze=(y?f.find(st=>st.id===y):null)??f[0]??null;ze&&y!==ze.id&&S(ze.id,{source:"route_sync"});return}if(j!==X.issuePrefix){const ze=A.pathname.replace(/^\/[^/]+/,"");_(`/${X.issuePrefix}${ze}${A.search}`,{replace:!0});return}const We=Gxe({matchedCompany:X,selectedCompanyId:y,companies:f});if(We){p?.({title:`${X.name} is archived`,body:`Switched to ${We.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${X.id}`}),S(We.id,{source:"route_sync"}),_(`/${We.issuePrefix}/dashboard`,{replace:!0});return}Yxe({selectionSource:w,selectedCompanyId:y,routeCompanyId:X.id})&&S(X.id,{source:"route_sync"})},[j,f,g,X,A.pathname,A.search,_,p,w,y,S]);const ue=h,pe=(0,u.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),be=(0,u.useRef)(null),oe=(0,u.useRef)(!1),je=(0,u.useRef)(!1),_e=(0,u.useCallback)(()=>{be.current!==null&&(window.clearTimeout(be.current),be.current=null)},[]),xe=(0,u.useCallback)(()=>{_e(),be.current=window.setTimeout(()=>o(!0),50)},[_e,o]),Ae=(0,u.useCallback)(()=>{_e(),o(!0)},[_e,o]),Ye=(0,u.useCallback)(()=>{_e(),be.current=window.setTimeout(()=>o(!1),120)},[_e,o]),Oe=(0,u.useCallback)(()=>{oe.current=!0,a&&!je.current&&xe()},[a,xe]),Xe=(0,u.useCallback)(()=>{oe.current=!1,je.current=!1,Ye()},[Ye]),me=(0,u.useCallback)(()=>{je.current||Ae()},[Ae]),Le=(0,u.useCallback)(()=>{oe.current||Ye()},[Ye]);(0,u.useEffect)(()=>_e,[_e]);const mt=(0,u.useRef)(a);return(0,u.useEffect)(()=>{a!==mt.current&&(a?(_e(),o(!1),je.current=oe.current):je.current=!1,mt.current=a)},[a,_e,o]),(0,u.useEffect)(()=>{if(!i)return;const We=r(ze=>{ze.key==="Escape"&&(_e(),o(!1))},"onKeyDown");return window.addEventListener("keydown",We),()=>window.removeEventListener("keydown",We)},[i,_e,o]),Hxe(),Uxe({enabled:ae,onNewIssue:r(()=>d(),"onNewIssue"),onSearch:pe,onToggleSidebar:n,onTogglePanel:ue,onShowShortcuts:r(()=>J(!0),"onShowShortcuts"),onGoToInbox:r(()=>_("/inbox"),"onGoToInbox")}),(0,u.useEffect)(()=>{if(!l)return;const We=30,ze=50,st=75;let pt=0,Pt=0;const tt=r(et=>{const Ie=et.touches[0];pt=Ie.clientX,Pt=Ie.clientY},"onTouchStart"),ht=r(et=>{const Ie=et.changedTouches[0],Ne=Ie.clientX-pt;if(!(Math.abs(Ie.clientY-Pt)>st)){if(!e&&pt<We&&Ne>ze){s(!0);return}e&&Ne<-50&&s(!1)}},"onTouchEnd");return document.addEventListener("touchstart",tt,{passive:!0}),document.addEventListener("touchend",ht,{passive:!0}),()=>{document.removeEventListener("touchstart",tt),document.removeEventListener("touchend",ht)}},[l,e,s]),(0,u.useEffect)(()=>{const We=document.body.style.overflow;return document.body.style.overflow=l?"visible":"clip",()=>{document.body.style.overflow=We}},[l]),(0,u.useEffect)(()=>{if(!l)return Xxe()},[l]),(0,u.useEffect)(()=>{if(typeof document>"u")return;const We=K.current;return Jxe(We)},[A.pathname]),(0,u.useEffect)(()=>{const We=K.current;if(!We)return;const ze=r(()=>{U.current.remember(D.current,We.scrollTop)},"recordScroll");return We.addEventListener("scroll",ze,{passive:!0}),()=>We.removeEventListener("scroll",ze)},[]),(0,u.useLayoutEffect)(()=>{const We=K.current,ze=Gde({previousPathname:B.current,pathname:A.pathname,navigationType:C,state:A.state});B.current=A.pathname;const st=C==="POP",pt=st?U.current.recall(A.key):0;if(D.current=A.key,st){WR(We,pt);const Pt=requestAnimationFrame(()=>WR(We,pt));return()=>cancelAnimationFrame(Pt)}ze&&Jde(We)},[A.key,A.pathname,A.state,C]),(0,t.jsx)(Qde,{children:(0,t.jsx)(tce,{value:{keyboardShortcutsEnabled:ae},children:(0,t.jsxs)("div",{className:z("bg-background text-foreground pt-(--sz-safe-top)",l?"min-h-dvh overflow-x-clip":"flex h-dvh flex-col overflow-clip"),children:[(0,t.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:left-3 focus:top-3 focus:z-(--z-200) focus:rounded-md focus:bg-background focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Skip to Main Content"}),(0,t.jsx)($xe,{}),(0,t.jsx)(Oxe,{devServer:se?.devServer}),(0,t.jsxs)("div",{className:z("min-h-0 flex-1",l?"w-full":"flex overflow-clip"),children:[l&&e&&(0,t.jsx)("button",{type:"button",className:"fixed inset-0 z-40 bg-black/50",onClick:r(()=>s(!1),"onClick"),"aria-label":"Close sidebar"}),l?(0,t.jsxs)("div",{className:z("fixed inset-y-0 left-0 z-50 flex flex-col overflow-hidden pt-(--sz-safe-top) transition-transform duration-100 ease-out",e?"translate-x-0":"-translate-x-full"),children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:(0,t.jsx)("div",{className:"w-60 shrink-0 overflow-hidden",children:fe?G:(0,t.jsx)(RJ,{})})}),(0,t.jsx)(DJ,{deploymentMode:se?.deploymentMode})]}):(0,t.jsxs)(TJe,{open:e,collapsed:a,peeking:i,resizable:!0,onPanelMouseEnter:Oe,onPanelMouseLeave:Xe,onPanelFocusCapture:a?me:void 0,onPanelBlurCapture:a?Le:void 0,children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0",children:(0,t.jsx)(RJ,{})}),(0,t.jsx)(DJ,{deploymentMode:se?.deploymentMode})]}),!l&&fe?(0,t.jsx)(EJe,{children:G}):null,(0,t.jsxs)("div",{className:z("flex min-w-0 flex-col",l?"w-full":"h-full flex-1"),children:[(0,t.jsxs)("div",{className:z(l&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:[(0,t.jsx)(BF,{mobile:l}),(0,t.jsx)(RJe,{}),l&&I?(0,t.jsx)("div",{className:"border-b border-border px-4 pb-3",children:(0,t.jsx)(vme,{})}):null]}),(0,t.jsxs)("div",{className:z(l?"block":"flex flex-1 min-h-0"),children:[(0,t.jsx)("main",{id:"main-content",ref:K,tabIndex:-1,style:l?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:z("flex-1 p-4 outline-none md:p-6",l?"overflow-visible pb-(--sz-calc-14)":"overflow-auto [scrollbar-gutter:stable]"),children:le?(0,t.jsx)(xu,{scope:"invalid_company_prefix",requestedPrefix:j??v?.issuePrefix}):(0,t.jsx)(qxe,{children:(0,t.jsx)(r0,{})})}),(0,t.jsx)(Tme,{})]})]})]}),l&&(0,t.jsx)(Lxe,{visible:V}),(0,t.jsx)(Mme,{}),(0,t.jsx)(Hme,{}),(0,t.jsx)(Ixe,{}),(0,t.jsx)(Txe,{}),(0,t.jsx)(Exe,{}),(0,t.jsx)(Pxe,{open:H,onOpenChange:J}),(0,t.jsx)(Mxe,{}),(0,t.jsx)(Dxe,{localTrusted:se?.deploymentMode==="local_trusted"})]})})})}r(qJe,"Layout");var LJ=null;function zJe(){return LJ??=new t1,LJ}r(zJe,"getDetachedClient");function UJe(){const e=(0,u.useContext)(J3),{data:s,isFetched:n}=ee({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn"),enabled:e!=null},e??zJe());return e?{enabled:s?.enableConferenceRoomChat===!0,loaded:n}:{enabled:!1,loaded:!0}}r(UJe,"useConferenceRoomChatEnabled");function KJe(){const{enabled:e,loaded:s}=UJe();return s?e?(0,t.jsx)(r0,{}):(0,t.jsx)(wn,{to:"/dashboard",replace:!0}):null}r(KJe,"ConferenceRoomChatGate");var VJe=["session-start","human-message","agent-message","thinking","responding","responding-burst","tool-call","diff","working","running","completed","activity-phases","awaiting-approval","plan-todo","interrupted","refused","truncated","live-token-cost"],WJe={"session-start":{id:"session-start",label:"Session start",tier:"live",surface:"thread",protocol:'acpx.session → TranscriptEntry kind:"init"'},"human-message":{id:"human-message",label:"Human message",tier:"live",surface:"thread",protocol:'IssueComment authorType:"user"'},"agent-message":{id:"agent-message",label:"Final response",tier:"live",surface:"thread",protocol:'PRP item.delta kind:"agentMessage" channel:"final"'},thinking:{id:"thinking",label:"Thinking",tier:"live",surface:"thread",protocol:"text_delta stream:thought (ACP agent_thought_chunk)"},responding:{id:"responding",label:"Progress update (streaming)",tier:"live",surface:"thread",protocol:'PRP item.delta kind:"agentMessage" channel:"progress"'},"responding-burst":{id:"responding-burst",label:"Progress update burst",tier:"live",surface:"thread",protocol:"text_delta stream:output ×N, tool calls between (PAP-368 dwell)"},"tool-call":{id:"tool-call",label:"Tool call",tier:"live",surface:"thread",protocol:"acpx.tool_call (ACP tool_call / tool_call_update)"},diff:{id:"diff",label:"Diff",tier:"live",surface:"thread",protocol:'ToolCallContent type:"diff" → TranscriptEntry kind:"diff"'},working:{id:"working",label:"Working",tier:"live",surface:"thread",protocol:"heartbeat.run.progress + acpx.status"},running:{id:"running",label:"Running",tier:"live",surface:"thread",protocol:'message.status.type === "running"'},completed:{id:"completed",label:"Completed (collapsed)",tier:"live",surface:"thread",protocol:"acpx.result (StopReason in subtype)"},"activity-phases":{id:"activity-phases",label:"Long-run activity phases",tier:"live",surface:"thread",protocol:"assistant boundaries + chronological tool calls"},"awaiting-approval":{id:"awaiting-approval",label:"Awaiting approval",tier:"tier-b",surface:"thread",protocol:"ACP RequestPermissionRequest + PermissionOptionKind"},"plan-todo":{id:"plan-todo",label:"Plan / todo",tier:"tier-b",surface:"plan",protocol:"ACP Plan { entries: PlanEntry[] }, PlanEntryStatus"},interrupted:{id:"interrupted",label:"Interrupted",tier:"tier-b",surface:"thread",protocol:'AcpRuntimeTurnResult.status:"cancelled" / StopReason "cancelled"'},refused:{id:"refused",label:"Refused",tier:"tier-b",surface:"thread",protocol:'StopReason "refusal"'},truncated:{id:"truncated",label:"Truncated",tier:"tier-b",surface:"thread",protocol:'StopReason "max_tokens" | "max_turn_requests"'},"live-token-cost":{id:"live-token-cost",label:"Live token / cost",tier:"tier-b",surface:"thread",protocol:"ACP UsageUpdate { used, size, cost }"}},G8t=VJe.map(e=>WJe[e]);function age({item:e}){return(0,t.jsx)("article",{className:"rounded-lg border border-border bg-card p-3","aria-label":`Project created: ${e.name}`,children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(W3e,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Project created"}),(0,t.jsx)(Ge,{to:`/projects/${e.projectId}`,className:"break-words text-sm font-medium hover:underline focus-visible:underline",children:e.name}),e.description&&(0,t.jsx)("p",{className:"line-clamp-3 text-sm text-muted-foreground",children:e.description}),e.repositories.length>0&&(0,t.jsx)("ul",{className:"space-y-1 pt-1",children:e.repositories.map(s=>(0,t.jsxs)("li",{className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[(0,t.jsx)(sl,{className:"size-3 shrink-0","aria-hidden":!0}),(0,t.jsx)("a",{className:"truncate hover:underline focus-visible:underline",href:s.url,target:"_blank",rel:"noreferrer",children:s.name})]},s.id))})]})]})})}r(age,"TaskChatProjectCreatedCard");function HJe({item:e,onOpen:s}){return(0,t.jsx)("article",{className:"rounded-lg border border-border bg-card p-3","aria-label":`Skill created: ${e.name}`,children:(0,t.jsxs)("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:r(()=>s?.(e.skillId,e.name),"onClick"),children:[(0,t.jsx)(yx,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,t.jsxs)("span",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Skill created"}),(0,t.jsx)("span",{className:"block break-words text-sm font-medium hover:underline focus-visible:underline",children:e.name}),e.description?(0,t.jsx)("span",{className:"block line-clamp-3 text-sm text-muted-foreground",children:e.description}):null]})]})})}r(HJe,"TaskChatSkillCreatedCard");var ige=(0,u.createContext)("streamlined");function QJe({mode:e,children:s}){return(0,t.jsx)(ige.Provider,{value:e,children:s})}r(QJe,"TaskChatPresentationProvider");function Xh(){return(0,u.useContext)(ige)==="streamlined"}r(Xh,"useStreamlinedTaskChatPresentation");function GJe(e){return(0,t.jsxs)("svg",{viewBox:"0 0 180 180",fill:"none",stroke:"currentColor",strokeWidth:14,strokeLinecap:"round",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,t.jsx)("path",{d:"M18 84.8528L85.8822 16.9706C95.2548 7.59798 110.451 7.59798 119.823 16.9706C129.196 26.3431 129.196 41.5391 119.823 50.9117L68.5581 102.177"}),(0,t.jsx)("path",{d:"M69.2652 101.47L119.823 50.9117C129.196 41.5391 144.392 41.5391 153.765 50.9117L154.118 51.2652C163.491 60.6378 163.491 75.8338 154.118 85.2063L92.7248 146.6C89.6006 149.724 89.6006 154.789 92.7248 157.913L105.331 170.52"}),(0,t.jsx)("path",{d:"M102.853 33.9411L52.6482 84.1457C43.2756 93.5183 43.2756 108.714 52.6482 118.087C62.0208 127.459 77.2167 127.459 86.5893 118.087L136.794 67.8822"})]})}r(GJe,"McpIcon");var YJe=new Set(["tool","tool call","tool_call","acp_tool"]);function Id(e){const s=(e??"").trim().toLowerCase().replace(/\s*\((?:pending|in[_ -]?progress|completed|failed|cancelled|canceled)\)$/,"");return!s||YJe.has(s)}r(Id,"isGenericToolName");function xK(e){const s=e.match(/^mcp__(.+?)__(.+)$/i);if(s)return{namespace:s[1],name:s[2]};const n=e.match(/^mcp\.([^.]+)\.(.+)$/i);return n?{namespace:n[1],name:n[2]}:null}r(xK,"mcpToolIdentity");function gK(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[^A-Za-z0-9]+/g," ").trim().toLowerCase().split(/\s+/).filter(Boolean)}r(gK,"identifierWords");function oge(e){if(e.length===0)return"";const s=e.map(n=>["api","id","lsp","mcp","pr","url"].includes(n)?n.toUpperCase():n).join(" ");return s.charAt(0).toUpperCase()+s.slice(1)}r(oge,"sentenceCase");function Rj(e){const s=(e??"").trim();return Id(s)?"Unnamed tool":oge(gK(xK(s)?.name??s))}r(Rj,"humanizeToolName");var nd=r((e,s,n)=>({key:e,singular:s,plural:n}),"group"),JJe={bash:{action:"run"},terminal:{action:"run"},shell:{action:"run"},command:{action:"run"},run:{action:"run"},execute:{action:"run"},exec_command:{action:"run"},apply_patch:{action:"update",running:"Applying a patch",completed:"Applied a patch"},read:{action:"read",running:"Reading a file",completed:"Read a file"},write:{action:"update",running:"Writing a file",completed:"Wrote a file"},edit:{action:"update",running:"Editing a file",completed:"Edited a file"},notebook_read:{action:"read",running:"Reading a notebook",completed:"Read a notebook"},notebook_edit:{action:"update",running:"Editing a notebook",completed:"Edited a notebook"},glob:{action:"search",running:"Searching files",completed:"Searched files"},grep:{action:"search",running:"Searching file contents",completed:"Searched file contents",family:"grep"},tool_search:{action:"search",running:"Searching available tools",completed:"Searched available tools",group:nd("tool_search","tool search","tool searches")},web_search:{action:"search",running:"Searching the web",completed:"Searched the web",family:"web"},web_fetch:{action:"fetch",running:"Fetching a web page",completed:"Fetched a web page",family:"web"},todo_write:{action:"update",running:"Updating the task list",completed:"Updated the task list",family:"plan",group:nd("task_operation","task operation","task operations")},task_create:{action:"create",running:"Creating a task",completed:"Created a task",family:"plan",group:nd("task_operation","task operation","task operations")},task_update:{action:"update",running:"Updating a task",completed:"Updated a task",family:"plan",group:nd("task_operation","task operation","task operations")},task_list:{action:"list",running:"Listing tasks",completed:"Listed tasks",family:"plan",group:nd("task_operation","task operation","task operations")},task_get:{action:"read",running:"Reading a task",completed:"Read a task",family:"plan",group:nd("task_operation","task operation","task operations")},enter_plan_mode:{action:"switch",running:"Entering plan mode",completed:"Entered plan mode",family:"plan"},exit_plan_mode:{action:"switch",running:"Leaving plan mode",completed:"Left plan mode",family:"plan"},skill:{action:"read",running:"Loading a skill",completed:"Loaded a skill"},ask_user_question:{action:"request",running:"Requesting input",completed:"Requested input",family:"question"},request_human_input:{action:"request",running:"Requesting input",completed:"Requested input",family:"question",group:nd("task_operation","task operation","task operations")},agent:{action:"start",running:"Starting a subagent",completed:"Started a subagent",family:"agent"},task:{action:"start",running:"Starting a subagent",completed:"Started a subagent",family:"agent"},task_output:{action:"read",running:"Checking subagent progress",completed:"Checked subagent progress",family:"agent"},task_stop:{action:"stop",running:"Stopping a subagent",completed:"Stopped a subagent",family:"agent"},send_message:{action:"post",running:"Messaging a subagent",completed:"Messaged a subagent",family:"agent"},spawn_agent:{action:"start",running:"Starting a subagent",completed:"Started a subagent",family:"agent"},wait_agent:{action:"wait",running:"Checking subagent progress",completed:"Checked subagent progress",family:"agent"},wait_threads:{action:"wait",running:"Checking task progress",completed:"Checked task progress",family:"agent"},interrupt_agent:{action:"stop",running:"Interrupting a subagent",completed:"Interrupted a subagent",family:"agent"},report_findings:{action:"post",running:"Reporting findings",completed:"Reported findings",family:"safety"},guardian_review:{action:"think",running:"Reviewing safety",completed:"Reviewed safety",family:"safety"},lsp:{action:"read",running:"Inspecting code intelligence",completed:"Inspected code intelligence"},compact_conversation:{action:"think",running:"Compacting context",completed:"Compacted context"},image_generation:{action:"create",running:"Generating an image",completed:"Generated an image",family:"image"},view_image:{action:"read",running:"Viewing an image",completed:"Viewed an image",family:"image"},multi_tool_use_parallel:{action:"run",running:"Running tools in parallel",completed:"Ran tools in parallel"},get_task_context:{action:"read",running:"Reading task context",completed:"Read task context"},get_task_history:{action:"read",running:"Reading task history",completed:"Read task history"},list_documents:{action:"list",running:"Listing documents",completed:"Listed documents"},read_document:{action:"read",running:"Reading a document",completed:"Read a document"},list_document_revisions:{action:"list",running:"Listing document revisions",completed:"Listed document revisions"},report_progress:{action:"post",running:"Reporting progress",completed:"Reported progress"},answer_status_question:{action:"post",running:"Answering a status question",completed:"Answered a status question"},write_document:{action:"update",running:"Writing a document",completed:"Wrote a document"},register_deliverable:{action:"create",running:"Registering a deliverable",completed:"Registered a deliverable"},finish_task:{action:"finish",running:"Reporting completion",completed:"Reported completion"},paperclip_finish:{action:"finish",running:"Reporting completion",completed:"Reported completion"},block_task:{action:"block",running:"Reporting a blocker",completed:"Reported a blocker"},paperclip_block:{action:"block",running:"Reporting a blocker",completed:"Reported a blocker"},request_review:{action:"request",running:"Requesting review",completed:"Requested review"},list_agents:{action:"list",running:"Listing agents",completed:"Listed agents"},get_agent:{action:"read",running:"Reading agent details",completed:"Read agent details"},search_tasks:{action:"search",running:"Searching tasks",completed:"Searched tasks"},list_approvals:{action:"list",running:"Listing approvals",completed:"Listed approvals"},get_approval:{action:"read",running:"Reading an approval",completed:"Read an approval"},get_approval_context:{action:"read",running:"Reading approval context",completed:"Read approval context"},get_workspace_runtime:{action:"read",running:"Reading workspace status",completed:"Read workspace status"},control_workspace_service:{action:"run",running:"Controlling a workspace service",completed:"Controlled a workspace service"},set_dependencies:{action:"update",running:"Updating task dependencies",completed:"Updated task dependencies"},create_task:{action:"create",running:"Creating a task",completed:"Created a task"},request_approval:{action:"request",running:"Requesting approval",completed:"Requested approval"},decide_approval:{action:"update",running:"Deciding an approval",completed:"Decided an approval"},comment_on_approval:{action:"post",running:"Commenting on an approval",completed:"Commented on an approval"},schedule_wake:{action:"create",running:"Scheduling a wake-up",completed:"Scheduled a wake-up",family:"wait"},generic_api_request:{action:"request",running:"Calling the Paperclip API",completed:"Called the Paperclip API"}},XJe={read:["get","read","inspect","view"],list:["list","glob"],search:["find","search","grep","query","lookup"],fetch:["fetch","browse"],open:["open"],update:["write","edit","update","set","patch","upsert","sync"],create:["create","add","register","upload"],delete:["delete","remove"],move:["move","rename"],run:["run","execute","bash","shell","command"],request:["request","ask","prompt"],post:["send","message","comment","report","answer"],start:["start","spawn","delegate"],stop:["stop","cancel","interrupt"],wait:["wait","sleep","poll"],finish:["finish","complete"],block:["block"],think:["think","reason","compact","review"],switch:["switch","enter","exit"],other:[]},ZJe={read:"read",edit:"update",delete:"delete",move:"move",search:"search",list:"list",execute:"run",think:"think",fetch:"fetch",switch_mode:"switch"};function eXe(e){return gK(e).join("_")}r(eXe,"normalizedKey");function tXe(e){const s=e[0];if(!s)return null;for(const[n,a]of Object.entries(XJe))if(a.includes(s))return n;return null}r(tXe,"inferredAction");function sXe(e){return e==="run"?"terminal":e==="read"||e==="list"?"read":e==="search"?"search":e==="fetch"||e==="open"?"web":["update","create","delete","move"].includes(e)?"edit":e==="request"?"question":e==="start"||e==="stop"?"agent":e==="wait"?"wait":"other"}r(sXe,"actionFamily");var nXe={terminal:Fb,grep:NEe,search:ha,read:Ww,edit:x5,web:GTe,plan:x1,question:Td,agent:qb,safety:Ai,image:yde,wait:th,mcp:GJe,other:yx};function rXe(e,s){const n=s?` ${s}`:"";switch(e){case"read":return{running:`Reading${n||" data"}`,completed:`Read${n||" data"}`};case"list":return{running:`Listing${n||" items"}`,completed:`Listed${n||" items"}`};case"search":return{running:`Searching${n||""}`,completed:`Searched${n||""}`};case"fetch":return{running:`Fetching${n||" data"}`,completed:`Fetched${n||" data"}`};case"open":return{running:`Opening${n||" an item"}`,completed:`Opened${n||" an item"}`};case"update":return{running:`Updating${n||" data"}`,completed:`Updated${n||" data"}`};case"create":return{running:`Creating${n||" an item"}`,completed:`Created${n||" an item"}`};case"delete":return{running:`Deleting${n||" an item"}`,completed:`Deleted${n||" an item"}`};case"move":return{running:`Moving${n||" an item"}`,completed:`Moved${n||" an item"}`};case"run":return{running:"Running a command",completed:"Ran a command"};case"request":return{running:`Requesting${n||" input"}`,completed:`Requested${n||" input"}`};case"post":return{running:`Posting${n||" an update"}`,completed:`Posted${n||" an update"}`};case"start":return{running:`Starting${n||" an operation"}`,completed:`Started${n||" an operation"}`};case"stop":return{running:`Stopping${n||" an operation"}`,completed:`Stopped${n||" an operation"}`};case"wait":return{running:"Waiting",completed:"Finished waiting"};case"finish":return{running:"Reporting completion",completed:"Reported completion"};case"block":return{running:"Reporting a blocker",completed:"Reported a blocker"};case"think":return{running:"Thinking",completed:"Finished thinking"};case"switch":return{running:`Switching${n||" mode"}`,completed:`Switched${n||" mode"}`};case"other":return{running:"Running",completed:"Ran"}}}r(rXe,"actionCopy");function aXe(e){switch(e){case"run":return nd("command","command","commands");case"read":case"list":return nd("read","read","reads");case"search":return nd("search","search","searches");case"update":case"create":case"delete":case"move":return nd("file_change","file change","file changes");case"start":case"stop":return nd("delegation","delegation","delegations");case"wait":return nd("wait","wait","waits");default:return nd("tool_action","tool action","tool actions")}}r(aXe,"defaultSummaryGroup");function iXe(e){return e==="read"||e==="list"?nd("paperclip_read","Paperclip read","Paperclip reads"):nd("task_operation","task operation","task operations")}r(iXe,"paperclipSummaryGroup");function Jb(e){const s=(e.name??"").trim(),n=xK(s),a=(e.namespace??n?.namespace??"").trim(),i=(n?"mcp":e.transport??"builtin").toLowerCase(),o=(n?.name??s).trim(),l=gK(o),c=eXe(o),d=JJe[c],m=ZJe[(e.operation??"").trim().toLowerCase()],h=tXe(l),p=d?.action??m??h??"other",f=d?"exact":m?"kind":h?"inferred":Id(o)?"unnamed":"fallback",g=Id(o)?"Unnamed tool":Rj(o),v=/^[A-Za-z][A-Za-z0-9_.:-]*$/.test(o),y=h&&v&&l.length>1?l.slice(1):[],w=y.length?oge(y).replace(/^./,C=>C.toLowerCase()):void 0,S=d?.running&&d.completed?{running:d.running,completed:d.completed}:p==="other"?Id(o)?{running:"Running an unnamed tool",completed:"Ran an unnamed tool"}:{running:`Running ${g}`,completed:`Ran ${g}`}:rXe(p,d?void 0:w),j=d?.family??sXe(p),N=i==="mcp"?"mcp":j,_=a?Rj(a):i==="mcp"?"MCP":void 0,A=a.toLowerCase()==="paperclip"?iXe(p):d?.group??aXe(p);return{icon:nXe[N],family:N,runningLabel:S.running,completedLabel:S.completed,failedLabel:`${S.completed} · failed`,interruptedLabel:`${S.running} · stopped`,displayName:g,sourceLabel:_,technicalName:s||void 0,confidence:f,summaryGroup:A}}r(Jb,"toolActivityPresentation");function rE(e){const s=Jb({name:e});return{family:s.family,icon:s.icon,verbLabel:s.runningLabel}}r(rE,"toolTaxonomy");function oXe(e){const s=(e??"").trim().toLowerCase();return s==="thinking"?Eg:s==="responding"||s.startsWith("responding (")?L5e:null}r(oXe,"statusLabelIcon");var V4=["Clipping","Organizing","Sorting","Synthesizing","Analyzing","Filing","Collating","Stapling","Indexing","Annotating","Drafting","Proofreading","Alphabetizing","Photocopying","Laminating","Hole-punching","Bookmarking","Highlighting","Typing","Trimming","Aligning","Combining","Whiteboarding","Diagramming","Sketching","Labeling","Sticky-noting"],W4=["Brewing","Tinkering","Distilling","Deliberating"],$J=(()=>{const e=[],s=Math.max(V4.length,W4.length);for(let n=0;n<s;n++)n<V4.length&&e.push(V4[n]),n<W4.length&&e.push(W4[n]);return e})(),lXe=1e4;function cXe(e){const s=(e??"").trim().toLowerCase();return s==="running"||s==="working"}r(cXe,"isGenericStatusLabel");function dXe(e){let s=2166136261;for(let n=0;n<e.length;n++)s^=e.charCodeAt(n),s=Math.imul(s,16777619);return s>>>0}r(dXe,"fnv1a");function uXe(e,s=0){const n=Math.floor(Math.max(0,s)/lXe);return $J[(dXe(e)+n)%$J.length]}r(uXe,"whimsyWord");var mXe=[{name:"--motion-ease-out-expo",group:"Easing",kind:"easing"},{name:"--motion-ease-standard",group:"Easing",kind:"easing"},{name:"--motion-ease-out",group:"Easing",kind:"easing"},{name:"--motion-ease-scroll-pill-in",group:"Easing",kind:"easing"},{name:"--motion-ease-scroll-pill-out",group:"Easing",kind:"easing"},{name:"--motion-ease-in",group:"Easing",kind:"easing"},{name:"--motion-duration-instant",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-fast",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-base",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-slow",group:"Durations",kind:"time",min:0,max:1500,step:10},{name:"--motion-duration-deliberate",group:"Durations",kind:"time",min:0,max:2e3,step:10},{name:"--motion-duration-enter",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-exit",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-swap",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-marker-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-bubble-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-cot-line-stagger",group:"States",kind:"time",min:0,max:300,step:5},{name:"--motion-cot-collapse",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-tool-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-diff-reveal",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-status-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-status-exit",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-approval-pulse",group:"States",kind:"time",min:0,max:3e3,step:20},{name:"--motion-plan-entry-stagger",group:"States",kind:"time",min:0,max:300,step:5},{name:"--motion-plan-check",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-question-page-enter",group:"States",kind:"time",min:0,max:1e3,step:10},{name:"--motion-count-tween",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-streaming-cursor-blink",group:"States",kind:"time",min:0,max:3e3,step:20},{name:"--motion-turn-fold",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-turn-meta",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-line-scroll",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-interstitial-dwell",group:"States",kind:"time",min:0,max:1e4,step:100},{name:"--motion-scroll-pill-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-scroll-pill-exit",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-scrollbar-idle-delay",group:"States",kind:"time",min:0,max:2e3,step:10},{name:"--motion-pane-glide",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-side-panel-tab",group:"States",kind:"time",min:0,max:1500,step:10}],Y8t=Array.from(new Set(mXe.map(e=>e.group)));function lge(e){const s=e.trim();if(s.endsWith("ms"))return parseFloat(s);if(s.endsWith("s"))return parseFloat(s)*1e3;const n=parseFloat(s);return Number.isFinite(n)?n:0}r(lge,"parseCssTimeMs");function hXe(e){if(e==null)return null;const s=Math.round(e/1e3);return s<60?`${s}s`:`${Math.floor(s/60)}m ${s%60}s`}r(hXe,"elapsedLabel");function pXe(e){if(e==null)return null;const s=Math.max(0,e)/1e3;return s<60?`${s.toFixed(1)}s`:`${Math.floor(s/60)}m ${(s%60).toFixed(1)}s`}r(pXe,"liveElapsedLabel");function fXe(e,s){const[n,a]=(0,u.useState)(()=>Date.now());return(0,u.useEffect)(()=>{if(e==null||!s)return;const i=window.setInterval(()=>a(Date.now()),100);return()=>window.clearInterval(i)},[e,s]),e==null?void 0:Math.max(0,n-e)}r(fXe,"useLiveElapsedMs");function xXe(e,s){return!Number.isFinite(e)||!Number.isFinite(s)||s<=0?0:Math.max(0,Math.round(e/s)-1)}r(xXe,"lineScrollOffset");function A2(e){const s=getComputedStyle(document.documentElement).getPropertyValue(e),n=lge(s);return Number.isFinite(n)?n:0}r(A2,"motionTokenMs");function gXe({text:e,streaming:s,leaving:n}){const a=(0,u.useRef)(null),[i,o]=(0,u.useState)(0),[l,c]=(0,u.useState)(!1),[d,m]=(0,u.useState)(!1);(0,u.useLayoutEffect)(()=>{const p=a.current;if(!p)return;const f=r(()=>{const v=parseFloat(window.getComputedStyle(p).lineHeight);o(xXe(p.scrollHeight,v))},"measure");if(f(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(f);return g.observe(p),()=>g.disconnect()},[e,s]),(0,u.useEffect)(()=>{const p=requestAnimationFrame(()=>c(!0)),f=window.setTimeout(()=>m(!0),A2("--motion-line-scroll"));return()=>{cancelAnimationFrame(p),window.clearTimeout(f)}},[]);const h=l?n?-1:s?-i:0:1;return(0,t.jsx)("span",{className:"tc-line-scroll min-w-0 flex-1","data-testid":"task-chat-live-self-talk","data-streaming":s||void 0,"data-leaving":n||void 0,children:(0,t.jsx)("span",{ref:a,className:z("tc-line-scroll-inner block",!s&&"truncate"),style:{transform:h!==0?`translateY(calc(${h} * 1lh))`:void 0,transition:d&&!n?"none":void 0},children:e})})}r(gXe,"LiveSelfTalkLine");function bXe(e,s){const[n,a]=(0,u.useState)(null),i=(0,u.useRef)(n),o=(0,u.useRef)(null),l=(0,u.useRef)(e),c=(0,u.useRef)(0),d=(0,u.useRef)(null),m=(0,u.useRef)(null),h=(0,u.useRef)(null);return l.current=e,(0,u.useEffect)(()=>{const p=r(w=>{w.current!=null&&(window.clearTimeout(w.current),w.current=null)},"clear"),f=r(w=>{i.current=w,a(w)},"show"),g=r(()=>{p(m),p(h),m.current=window.setTimeout(()=>{if(m.current=null,o.current!=null)return;const w=i.current;w==null||w.streaming||(f({...w,leaving:!0}),h.current=window.setTimeout(()=>{h.current=null,i.current?.leaving&&f(null)},A2("--motion-line-scroll")))},A2("--motion-interstitial-dwell"))},"scheduleLeave"),v=r((w,S)=>{p(m),p(h),c.current=Date.now(),f({text:w,streaming:S,swapKey:(i.current?.swapKey??0)+1}),S||g()},"swapIn");if(!s){p(d),p(m),p(h),o.current=null,i.current&&f(null);return}const y=i.current;if(e==null){y?.streaming&&(f({...y,streaming:!1}),g());return}if(y==null){v(e,!0);return}if(y.streaming){y.text!==e&&f({...y,text:e});return}if(o.current=e,d.current==null){const w=A2("--motion-interstitial-dwell"),S=Math.max(0,c.current+w-Date.now());d.current=window.setTimeout(()=>{d.current=null;const j=o.current;o.current=null,j!=null&&v(j,l.current!=null)},S)}},[e,s]),(0,u.useEffect)(()=>()=>{d.current!=null&&window.clearTimeout(d.current),m.current!=null&&window.clearTimeout(m.current),h.current!=null&&window.clearTimeout(h.current)},[]),n}r(bXe,"useHeldSelfTalk");var vXe={running:{Icon:it,spin:!0,tone:"text-(--status-agent-running)"},working:{Icon:it,spin:!0,tone:"text-(--status-agent-running)"},awaiting_approval:{Icon:Qw,spin:!1,tone:"text-primary"},interrupted:{Icon:Cz,spin:!1,tone:"text-destructive"},refused:{Icon:Vu,spin:!1,tone:"text-destructive"},truncated:{Icon:vEe,spin:!1,tone:"text-(--status-agent-paused)"}};function cge({item:e,onApprovalDecision:s,chevronOpen:n,onToggle:a}){const{Icon:i,spin:o,tone:l}=vXe[e.status],c=e.status==="awaiting_approval",d=e.status==="running"||e.status==="working",m=fXe(e.startedAtMs,d),h=bXe(d?e.selfTalk:void 0,d),p=hXe(e.elapsedMs);if(d){const f=pXe(m??e.elapsedMs),g=e.selfTalk!=null,v=e.toolName?rE(e.toolName).icon:g?null:oXe(e.label),y=g||cXe(e.label)?uXe(e.id,m??e.elapsedMs??0):e.label,w=(0,t.jsxs)("div",{className:"tc-enter-status flex items-center gap-2 py-0.5 text-xs text-muted-foreground",children:[n!==void 0?(0,t.jsx)("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center","data-testid":"task-chat-status-caret-slot",children:(0,t.jsx)(fn,{className:z("h-3 w-3 transition-transform",n?"rotate-90":null),"aria-hidden":!0})}):null,(0,t.jsx)("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center","data-testid":"task-chat-status-dot-slot",children:(0,t.jsx)("span",{"aria-hidden":!0,className:"h-2 w-2 animate-pulse rounded-full bg-(--status-agent-running)"})}),v?(0,t.jsx)(v,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null,(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-baseline gap-2",children:[(0,t.jsxs)("span",{className:"shimmer-text shimmer-text-muted shrink-0 font-medium",children:[y,"…"]}),f?(0,t.jsx)("span",{className:"shrink-0 font-mono tabular-nums text-(length:--text-micro)",children:f}):null,e.detail?(0,t.jsx)("span",{className:"min-w-0 truncate font-mono text-(length:--text-micro)",children:e.detail}):null,e.tokens?(0,t.jsxs)("span",{className:"ml-auto shrink-0 font-mono text-(length:--text-micro)",children:[e.tokens.used.toLocaleString(),"/",e.tokens.size.toLocaleString()," ctx"]}):null]})]});return(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 py-0.5 text-xs text-muted-foreground","data-testid":"task-chat-interstitial-row",children:[(0,t.jsx)("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 shrink-0"}),h?(0,t.jsx)(gXe,{text:h.text,streaming:h.streaming,leaving:h.leaving},h.swapKey):(0,t.jsx)("span",{"aria-hidden":!0,className:"tc-line-scroll min-w-0 flex-1"})]}),a?(0,t.jsx)("button",{type:"button",onClick:a,"aria-expanded":n,className:"-mx-1.5 block w-full rounded-sm px-1.5 text-left transition-colors hover:bg-muted/60","data-testid":"task-chat-live-turn",children:w}):w]})}return(0,t.jsxs)("div",{className:z("tc-enter-status flex flex-col gap-2 rounded-lg border px-3 py-2 text-sm",c?"tc-approval border-primary/40 bg-primary/5":"border-border bg-muted/40"),children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(i,{className:z("h-4 w-4 shrink-0",l,o&&"animate-spin")}),(0,t.jsx)("span",{className:"min-w-0 truncate font-medium",children:e.label}),(0,t.jsxs)("span",{className:"ml-auto flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[p?(0,t.jsx)("span",{children:p}):null,e.tokens?(0,t.jsxs)("span",{children:[e.tokens.used.toLocaleString(),"/",e.tokens.size.toLocaleString()," ctx"]}):null]})]}),e.detail?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.detail}):null,c&&e.approval?(0,t.jsx)("div",{className:"flex flex-wrap justify-end gap-2 pt-1",children:e.approval.options.map(f=>{const g=f.kind.startsWith("reject");return(0,t.jsx)("button",{type:"button",onClick:r(()=>s?.(f.id),"onClick"),className:z("rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",g?"border-border text-muted-foreground hover:bg-accent/50 hover:text-foreground":"border-primary bg-primary text-primary-foreground hover:bg-primary/90"),children:f.label},f.id)})}):null]})}r(cge,"TaskChatStatusPill");function dge(e,s){const n=URL.createObjectURL(s),a=document.createElement("a");a.href=n,a.download=e,a.rel="noreferrer",a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(n)}r(dge,"downloadBlob$1");function yXe(e,s,n){dge(e,new Blob([s],{type:`${n};charset=utf-8`}))}r(yXe,"downloadTextFile");var H4="flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50";function uge({issueId:e,documentKey:s,title:n,format:a,body:i,className:o}){const[l,c]=(0,u.useState)(null),[d,m]=(0,u.useState)(null),[h,p]=(0,u.useState)(null),{copy:f,copied:g,failed:v}=uf(),y=(0,u.useRef)(void 0);(0,u.useEffect)(()=>()=>clearTimeout(y.current),[]);const w=(0,u.useCallback)(async(C,I)=>{c(C),p(null);try{await I(),m(C)}catch(T){m(null),p(T instanceof Error?T.message:"Export failed")}finally{c(null)}clearTimeout(y.current),y.current=setTimeout(()=>{m(null),p(null)},2e3)},[]),S=(0,u.useCallback)(async()=>i??(await Rt.getDocument(e,s)).body,[i,s,e]),j=(0,u.useCallback)(()=>{c("copy"),p(null),(async()=>{try{await f(await S())==="failed"&&p("Copy failed")}catch(C){p(C instanceof Error?C.message:"Copy failed")}finally{c(null)}})()},[f,S]),N=v||h==="Copy failed"?"Copy failed":g?"Copied!":"Copy full content",_=d==="download"?"Downloaded!":"Download source",A=d==="pdf"?"Downloaded!":"Export to PDF";return(0,t.jsxs)("div",{className:z("flex items-center gap-0.5",o),"data-testid":"document-export-actions",children:[(0,t.jsx)("button",{type:"button",className:H4,disabled:l!==null,"aria-label":"Copy full content",title:N,"data-testid":"document-export-copy",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),j()},"onClick"),children:g?(0,t.jsx)(fs,{"aria-hidden":"true",className:"h-3.5 w-3.5"}):(0,t.jsx)(jr,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:H4,disabled:l!==null,"aria-label":"Download source",title:_,"data-testid":"document-export-download",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),w("download",async()=>{const I=gRe(a);yXe(iH(n,I),await S(),I==="md"?"text/markdown":"text/plain")})},"onClick"),children:(0,t.jsx)(zo,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:H4,disabled:l!==null,"aria-label":"Export to PDF",title:A,"data-testid":"document-export-pdf",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),w("pdf",async()=>{dge(iH(n,"pdf"),await Rt.getDocumentPdf(e,s))})},"onClick"),children:(0,t.jsx)(T3e,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite",children:h??(g?"Copied!":v?"Copy failed":d?"Downloaded!":"")})]})}r(uge,"DocumentExportActions");function hC({children:e,className:s}){return(0,t.jsx)("div",{className:z("relative aspect-video w-full overflow-hidden bg-accent/20",s),children:e})}r(hC,"PreviewFrame");function LT({label:e}){return(0,t.jsx)(hC,{className:"flex items-center justify-center",children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5 text-muted-foreground/50",children:[(0,t.jsx)(Vl,{className:"h-7 w-7","aria-hidden":"true"}),e?(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide",children:e}):null]})})}r(LT,"PlaceholderPreview");function jXe({artifact:e}){const[s,n]=(0,u.useState)(!1);return s||!e.contentPath?(0,t.jsx)(LT,{label:"Image"}):(0,t.jsx)(hC,{children:(0,t.jsx)("img",{src:e.contentPath,alt:e.title,loading:"lazy",className:"h-full w-full object-cover",onError:r(()=>n(!0),"onError")})})}r(jXe,"ImagePreview");function wXe({artifact:e}){const[s,n]=(0,u.useState)(!1),[a,i]=(0,u.useState)(!1),o=(0,u.useRef)(!1),l=(0,u.useRef)(null);if((0,u.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),s||!e.contentPath)return(0,t.jsx)(hC,{className:"flex items-center justify-center bg-black/80",children:(0,t.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-full bg-white/15",children:(0,t.jsx)(_o,{className:"h-5 w-5 translate-x-0.5 text-white","aria-hidden":"true"})})});const c=r(()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null),i(!0)},"markFrameReady"),d=r(()=>{l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(c,3e3)},"scheduleFrameReadyFallback"),m=r(p=>{if(o.current)return;o.current=!0;const f=p.currentTarget,g=Number.isFinite(f.duration)&&f.duration>0?f.duration:0,v=g>0?Math.min(1,g/4):.05;try{Math.abs(f.currentTime-v)>.001?(f.currentTime=v,d()):c()}catch{c()}},"loadThumbnailFrame"),h=r(p=>{(o.current||p.currentTarget.currentTime>0)&&c()},"handleLoadedData");return(0,t.jsxs)(hC,{className:"bg-black",children:[(0,t.jsx)("video",{src:e.contentPath,preload:"metadata",muted:!0,playsInline:!0,"data-frame-ready":a?"true":"false",className:z("h-full w-full object-contain transition-opacity",a?"opacity-100":"opacity-0"),onLoadedMetadata:m,onLoadedData:h,onSeeked:c,onError:r(()=>n(!0),"onError")}),(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:(0,t.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-full bg-black/55",children:(0,t.jsx)(_o,{className:"h-5 w-5 translate-x-0.5 text-white","aria-hidden":"true"})})})]})}r(wXe,"VideoPreview");function NXe({artifact:e}){const s=e.previewText?.trim();return s?(0,t.jsxs)(hC,{className:"bg-card",children:[(0,t.jsx)("div",{className:"absolute inset-0 overflow-hidden p-3",children:(0,t.jsx)("p",{className:"max-h-full overflow-hidden whitespace-pre-wrap break-words text-base leading-6 text-muted-foreground/75",children:s})}),(0,t.jsx)("div",{className:"pointer-events-none absolute bottom-0 left-0 right-0 h-10 bg-gradient-to-t from-card to-transparent"})]}):(0,t.jsx)(LT,{label:e.source==="document"?"Document":"Text"})}r(NXe,"TextPreview");function D1({artifact:e}){switch(e.mediaKind){case"image":return(0,t.jsx)(jXe,{artifact:e},e.contentPath);case"video":return(0,t.jsx)(wXe,{artifact:e},e.contentPath);case"text":case"document":return(0,t.jsx)(NXe,{artifact:e});case"file":return(0,t.jsx)(LT,{label:"File"});default:return(0,t.jsx)(LT,{})}}r(D1,"ArtifactPreview");function OJ({href:e,download:s,title:n,children:a}){return(0,t.jsx)("a",{href:e,...s?{download:""}:{target:"_blank",rel:"noreferrer"},title:n,"aria-label":n,onClick:r(i=>i.stopPropagation(),"onClick"),className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:a})}r(OJ,"SecondaryAction");function kXe({artifact:e}){return(0,t.jsxs)(Ge,{to:e.href,disableIssueQuicklook:!0,"data-testid":"artifact-card","data-media-kind":e.mediaKind,className:"group flex flex-col overflow-hidden rounded-lg border border-border bg-card cursor-pointer transition-colors hover:border-foreground/20 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,t.jsx)(D1,{artifact:e}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1 p-3",children:[(0,t.jsxs)("div",{className:"flex h-7 items-start justify-between gap-2",children:[(0,t.jsx)("h3",{className:"min-w-0 flex-1 truncate text-sm font-medium leading-7 text-foreground/85",title:e.title,children:e.title}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:[e.source==="document"&&e.documentKey?(0,t.jsx)(uge,{issueId:e.issue.id,documentKey:e.documentKey,title:e.title}):null,e.openPath?(0,t.jsx)(OJ,{href:e.openPath,title:"Open file in new tab",children:(0,t.jsx)(xr,{className:"h-3.5 w-3.5"})}):null,e.downloadPath?(0,t.jsx)(OJ,{href:e.downloadPath,download:!0,title:"Download file",children:(0,t.jsx)(zo,{className:"h-3.5 w-3.5"})}):null]})]}),(0,t.jsxs)("div",{className:"mt-0.5 flex items-center gap-1.5 text-(length:--text-micro) text-muted-foreground/65",children:[(0,t.jsxs)("span",{children:["Last edited ",pu(e.updatedAt)]}),e.createdByAgent?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-muted-foreground/50",children:"·"}),(0,t.jsx)("span",{className:"truncate",children:e.createdByAgent.name})]}):null]})]})]})}r(kXe,"ArtifactCard");function sN(e){if(!Number.isFinite(e)||e<0)return"0 B";if(e<1024)return`${Math.round(e)} B`;const s=["KB","MB","GB","TB"];let n=e/1024,a=0;for(;n>=1024&&a<s.length-1;)n/=1024,a+=1;const i=n.toFixed(1);return`${i.endsWith(".0")?i.slice(0,-2):i} ${s[a]}`}r(sN,"formatBytes$5");var $T=new Set(["application/octet-stream","binary/octet-stream","application/x-binary"]),SXe=[".mp4",".m4v",".webm",".mov",".qt",".quicktime"],CXe=[".png",".jpg",".jpeg",".gif",".webp",".avif",".bmp",".svg",".ico"],_Xe=new Set(["application/wasm"]),IXe=new Set(["application/zip","application/x-zip","application/x-zip-compressed"]),mge=new Set(["text/markdown","text/x-markdown","application/markdown","application/x-markdown"]),AXe=new Set(["application/csv","application/ecmascript","application/graphql","application/html","application/javascript","application/json","application/ld+json","application/sql","application/toml","application/x-httpd-php","application/x-javascript","application/x-python","application/x-sh","application/x-yaml","application/xhtml+xml","application/xml","application/yaml"]),RXe=[".csv",".css",".graphql",".htm",".html",".js",".json",".jsx",".log",".markdown",".md",".mdx",".php",".py",".sh",".sql",".toml",".ts",".tsx",".txt",".xml",".yaml",".yml"];function L1(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}r(L1,"normalizeOutputContentType");function TXe(e){const s=(e??"").trim().toLowerCase();return s?RXe.some(n=>s.endsWith(n)):!1}r(TXe,"hasDocumentLikeFilename");function hge(e){return IXe.has(e)||e.endsWith("+zip")}r(hge,"isZipContentType");function EXe(e){return e?!!(e.startsWith("text/")||mge.has(e)||AXe.has(e)||e.startsWith("application/")&&(e.endsWith("+json")||e.endsWith("+xml"))):!1}r(EXe,"isDocumentLikeOutputContentType");function PXe(e,s){const n=L1(e);return!n||EXe(n)||$T.has(n)&&TXe(s)?!1:n.startsWith("video/")||n.startsWith("image/")||n==="application/pdf"||_Xe.has(n)||hge(n)||$T.has(n)}r(PXe,"isOutputEligibleContentType");function MXe(e){const s=L1(e);if(s.startsWith("video/")){const n=s.slice(6);return n==="quicktime"?{label:"MOV",tone:"video"}:{label:(n||"vid").toUpperCase().slice(0,4),tone:"video"}}return s==="application/pdf"?{label:"PDF",tone:"pdf"}:hge(s)?{label:"ZIP",tone:"zip"}:s.startsWith("image/")?{label:"IMG",tone:"image"}:mge.has(s)?{label:"MD",tone:"bin"}:s==="text/plain"?{label:"TXT",tone:"bin"}:s==="text/csv"||s==="application/csv"?{label:"CSV",tone:"bin"}:s==="text/html"||s==="application/html"||s==="application/xhtml+xml"?{label:"HTML",tone:"bin"}:s==="application/json"||s.endsWith("+json")?{label:"JSON",tone:"bin"}:s==="application/xml"||s==="text/xml"||s.endsWith("+xml")?{label:"XML",tone:"bin"}:s==="application/wasm"?{label:"WASM",tone:"bin"}:{label:"BIN",tone:"bin"}}r(MXe,"getOutputFileGlyph");function $d(e,s){const n=L1(e);if(n.startsWith("video/"))return!0;if(!$T.has(n))return!1;const a=(s??"").trim().toLowerCase();return SXe.some(i=>a.endsWith(i))}r($d,"isVideoLikeOutput");function gw(e){return L1(e).startsWith("image/")}r(gw,"isImageContentType");function pC(e,s){const n=L1(e);if(gw(n))return!0;if(n&&!$T.has(n))return!1;const a=(s??"").trim().toLowerCase();return CXe.some(i=>a.endsWith(i))}r(pC,"isImageLikeOutput");function FJ(e){const s=new Date(e).getTime();return Number.isNaN(s)?0:s}r(FJ,"toTime");function aE(e){const s=(e??[]).filter(n=>n.type==="artifact"&&n.provider==="paperclip").flatMap(n=>{const a=LIe.safeParse(n.metadata);return a.success&&!PXe(a.data.contentType,a.data.originalFilename)?[]:[{id:n.id,title:n.title,status:typeof n.status=="string"?n.status:"active",isPrimary:!!n.isPrimary,createdAt:n.createdAt,metadata:a.success?a.data:null,degraded:!a.success,workProduct:n}]});return s.sort((n,a)=>n.isPrimary!==a.isPrimary?n.isPrimary?-1:1:FJ(a.createdAt)-FJ(n.createdAt)),{items:s,primary:s[0]??null,rest:s.slice(1),count:s.length}}r(aE,"getIssueOutputs");function bK(e){return e.metadata?.originalFilename||e.title||"output"}r(bK,"outputFilename");function pge(e){return new Set(aE(e).items.flatMap(s=>{const n=s.metadata?.attachmentId;return n?[n]:[]}))}r(pge,"getPromotedOutputAttachmentIds");var jh={connect:r((e,s)=>Re.post(`/companies/${e}/email/connections`,s),"connect"),inspectSaved:r((e,s)=>Re.post(`/companies/${e}/email/connections/${s}/inspect`,{}),"inspectSaved"),list:r(e=>Re.get(`/companies/${e}/email/inboxes`),"list"),setup:r((e,s)=>Re.post(`/companies/${e}/email/inboxes`,s),"setup"),inspect:r((e,s)=>Re.post(`/companies/${e}/email/inspect`,{apiKey:s}),"inspect"),control:r((e,s)=>Re.post(`/email/inboxes/${e}/control`,{action:s}),"control"),reconnect:r((e,s,n)=>Re.post(`/email/inboxes/${e}/reconnect`,{apiKey:s,receiveMode:n}),"reconnect"),resolve:r((e,s,n,a)=>Re.post(`/companies/${e}/email/deliveries/${s}/resolve`,{outcome:n,providerMessageId:a}),"resolve"),thread:r((e,s)=>Re.get(`/companies/${e}/email/tasks/${s}`),"thread"),send:r((e,s)=>Re.post(`/companies/${e}/email/send`,s),"send")},fge=(0,u.createContext)(null);function DXe({companyId:e,issueId:s,children:n}){const{enabled:a}=Lx(),i=ee({queryKey:["email-thread",e,s],queryFn:r(()=>jh.thread(e,s),"queryFn"),enabled:a,refetchInterval:a?3e3:!1});return(0,t.jsx)(fge.Provider,{value:i.data??null,children:n})}r(DXe,"EmailThreadProvider");function xge(e){const s=(0,u.useContext)(fge),n=s?.messages.find(a=>a.commentId===e);return n&&s?(0,t.jsx)(gge,{message:n,publication:s.publications.find(a=>a.providerMessageId===n.providerMessageId),issueId:s.issueId}):null}r(xge,"useEmailComment");function gge({message:e,publication:s,issueId:n}){const a=ee({queryKey:["email-attachments",n],queryFn:r(()=>Rt.listAttachments(n),"queryFn"),enabled:e.attachmentIds.length>0});return(0,t.jsxs)("article",{"aria-label":e.direction==="inbound"?"Email received":"Email sent",className:"space-y-4 rounded-xl border border-border bg-card p-5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-sm font-semibold",children:[(0,t.jsx)(wce,{className:"size-4"}),e.direction==="inbound"?"Email received":"Email sent"]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("p",{className:"text-sm font-medium",children:[e.from,e.direction==="inbound"&&(0,t.jsx)("span",{className:"ml-2 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground",children:"External"})]}),(0,t.jsxs)("p",{className:"break-words text-xs text-muted-foreground",children:["To: ",e.to.join(", ")]}),!!e.cc?.length&&(0,t.jsxs)("p",{className:"break-words text-xs text-muted-foreground",children:["Cc: ",e.cc.join(", ")]}),(0,t.jsx)("p",{className:"text-sm font-semibold",children:e.subject})]}),(0,t.jsx)("div",{className:"whitespace-pre-wrap break-words text-sm",children:e.text||"(No text body)"}),!!e.attachmentIds.length&&(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:e.attachmentIds.map(i=>{const o=a.data?.find(l=>l.id===i);return(0,t.jsxs)("a",{href:`/api/attachments/${i}/content`,target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 rounded-md border border-border px-3 py-2 text-xs",children:[(0,t.jsx)(Vl,{className:"size-3.5"}),o?.originalFilename??"Open attachment"]},i)})}),(0,t.jsxs)("details",{className:"text-xs text-muted-foreground",children:[(0,t.jsx)("summary",{className:"cursor-pointer",children:"Email details"}),(0,t.jsxs)("div",{className:"space-y-2 pt-3",children:[!!e.bcc?.length&&(0,t.jsxs)("p",{children:["Bcc: ",e.bcc.join(", ")]}),(0,t.jsxs)("p",{className:"break-all",children:["Message ID: ",e.providerMessageId]}),e.fullText!==e.text&&(0,t.jsx)("div",{className:"whitespace-pre-wrap break-words",children:e.fullText})]})]}),s&&(0,t.jsxs)("p",{className:"border-t border-border pt-3 text-xs text-muted-foreground",children:[s.outcome==="delivered"?"Delivered":s.outcome==="failed"?"Delivery failed":s.outcome==="uncertain"?"Delivery uncertain":s.outcome==="queued"?"Queued":"Sent",s.error?` · ${s.error}`:""]}),a.error&&(0,t.jsx)("p",{role:"alert",className:"text-xs text-destructive",children:"Attachments could not be loaded."})]})}r(gge,"EmailMessageCard");var Tj=(0,u.createContext)(null);function LXe(e){return e.contentType.toLowerCase().split(";")[0]?.trim()??""}r(LXe,"normalizedContentType$1");function $1(e){return e.originalFilename??e.id}r($1,"attachmentFilename");function vK(e){return e.openPath??e.contentPath}r(vK,"attachmentOpenPath");function iE(e){return e.downloadPath??`${e.contentPath}?download=1`}r(iE,"attachmentDownloadPath");function bge(e){const s=LXe(e);return pC(s,e.originalFilename)&&!/^image\/hei[cf](?:-sequence)?$/.test(s)}r(bge,"isImageAttachment$2");function vge(e){return $d(e.contentType,e.originalFilename)}r(vge,"isVideoAttachment");function $Xe(e){return aIe(e)}r($Xe,"isMarkdownAttachment");function nN({items:e,initialIndex:s,open:n,onOpenChange:a}){const[i,o]=(0,u.useState)(s),l=(0,u.useRef)(null),c=(0,u.useCallback)(v=>{l.current=v},[]);(0,u.useEffect)(()=>{n&&o(s)},[n,s]);const d=(0,u.useCallback)(()=>{o(v=>(v+1)%e.length)},[e.length]),m=(0,u.useCallback)(()=>{o(v=>(v-1+e.length)%e.length)},[e.length]);(0,u.useEffect)(()=>{i<e.length||o(0)},[i,e.length]),(0,u.useEffect)(()=>{if(!n)return;const v=r(y=>{y.key==="ArrowRight"?d():y.key==="ArrowLeft"?m():y.key==="Escape"&&a(!1)},"handler");return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n,d,m,a]);const h=(0,u.useCallback)(v=>{const y=v.target;y.closest("button")||y.closest("a")||y===l.current||a(!1)},[a]);if(e.length===0)return null;const p=e[i];if(!p)return null;const f=$1(p),g=$d(p.contentType,p.originalFilename);return(0,t.jsx)(b2e,{open:n,onOpenChange:a,children:(0,t.jsxs)(x2e,{children:[(0,t.jsx)(g2e,{className:"fixed inset-0 z-50 bg-black/90 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-200"}),(0,t.jsxs)(w2e,{className:"fixed inset-0 z-50 flex flex-col outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-200",onClick:h,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 text-white/80 text-sm shrink-0",children:[(0,t.jsx)("span",{className:"truncate max-w-(--pct-50) font-medium",title:f,children:f}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsxs)("span",{className:"text-white/40 tabular-nums text-xs",children:[i+1," / ",e.length]}),(0,t.jsx)("a",{href:iE(p),download:f,className:"text-white/50 hover:text-white transition-colors",title:"Download","aria-label":`Download ${f}`,onClick:r(v=>v.stopPropagation(),"onClick"),children:(0,t.jsx)(zo,{className:"h-4.5 w-4.5"})}),(0,t.jsx)("button",{type:"button",onClick:r(()=>a(!1),"onClick"),className:"text-white/50 hover:text-white transition-colors",title:"Close",children:(0,t.jsx)(ir,{className:"h-5 w-5"})})]})]}),(0,t.jsxs)("div",{className:"flex-1 flex items-center min-h-0",children:[(0,t.jsx)("div",{className:"w-16 md:w-24 shrink-0 flex items-center justify-center h-full",children:e.length>1&&(0,t.jsx)("button",{type:"button",onClick:m,className:"rounded-full bg-white/10 p-3 text-white/60 hover:text-white hover:bg-white/20 transition-colors",title:"Previous",children:(0,t.jsx)(bu,{className:"h-7 w-7"})})}),(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center min-w-0 min-h-0 h-full px-2",children:g?(0,t.jsx)("video",{ref:c,src:p.contentPath,className:"max-w-full max-h-full rounded-lg",controls:!0,playsInline:!0}):(0,t.jsx)("img",{ref:c,src:p.contentPath,alt:f,className:"max-w-full max-h-full object-contain select-none rounded-lg",draggable:!1})}),(0,t.jsx)("div",{className:"w-16 md:w-24 shrink-0 flex items-center justify-center h-full",children:e.length>1&&(0,t.jsx)("button",{type:"button",onClick:d,className:"rounded-full bg-white/10 p-3 text-white/60 hover:text-white hover:bg-white/20 transition-colors",title:"Next",children:(0,t.jsx)(fn,{className:"h-7 w-7"})})})]}),(0,t.jsx)("div",{className:"h-6 shrink-0"})]})]})})}r(nN,"ImageGalleryModal");function VF(e,s){if(e&&!s)return e;if(!e&&s)return s;if(e||s)return{...e,...s}}r(VF,"mergeObjects");var yK={};function jK(e,s,n,a,i){if(!n&&!a&&!i&&!e)return OT(s);let o=OT(e);return s&&(o=Dk(o,s)),n&&(o=Dk(o,n)),a&&(o=Dk(o,a)),i&&(o=Dk(o,i)),o}r(jK,"mergeProps");function OXe(e){if(e.length===0)return yK;if(e.length===1)return OT(e[0]);let s=OT(e[0]);for(let n=1;n<e.length;n+=1)s=Dk(s,e[n]);return s}r(OXe,"mergePropsN");function OT(e){return wK(e)?{...jge(e,yK)}:FXe(e)}r(OT,"createInitialMergedProps");function Dk(e,s){return wK(s)?jge(s,e):BXe(e,s)}r(Dk,"mergeInto");function FXe(e){const s={...e};for(const n in s){const a=s[n];yge(n,a)&&(s[n]=wge(a))}return s}r(FXe,"copyInitialProps");function BXe(e,s){if(!s)return e;for(const n in s){const a=s[n];switch(n){case"style":e[n]=VF(e.style,a);break;case"className":e[n]=kge(e.className,a);break;default:yge(n,a)?e[n]=qXe(e[n],a):e[n]=a}}return e}r(BXe,"mutablyMergeInto");function yge(e,s){const n=e.charCodeAt(0),a=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&a===110&&i>=65&&i<=90&&(typeof s=="function"||typeof s>"u")}r(yge,"isEventHandler");function wK(e){return typeof e=="function"}r(wK,"isPropsGetter");function jge(e,s){return wK(e)?e(s):e??yK}r(jge,"resolvePropsGetter");function qXe(e,s){return s?e?(...n)=>{const a=n[0];if(Sge(a)){const o=a;Nge(o);const l=s(...n);return o.baseUIHandlerPrevented||e?.(...n),l}const i=s(...n);return e?.(...n),i}:wge(s):e}r(qXe,"mergeEventHandlers");function wge(e){return e&&((...s)=>{const n=s[0];return Sge(n)&&Nge(n),e(...s)})}r(wge,"wrapEventHandler");function Nge(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}r(Nge,"makeEventPreventable");function kge(e,s){return s?e?s+" "+e:s:e}r(kge,"mergeClassNames");function Sge(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}r(Sge,"isSyntheticEvent");function zXe(e,s){return r(function(a,...i){const o=new URL(e);return o.searchParams.set("code",a.toString()),i.forEach(l=>o.searchParams.append("args[]",l)),`${s} error #${a}; visit ${o} for the full message.`},"formatErrorMessage")}r(zXe,"createFormatErrorMessage");var UXe=zXe("https://base-ui.com/production-error","Base UI"),BJ={};function Cge(e,s){const n=u.useRef(BJ);return n.current===BJ&&(n.current=e(s)),n}r(Cge,"useRefWithInit");function qJ(e,s,n,a){const i=Cge(_ge).current;return VXe(i,e,s,n,a)&&Ige(i,[e,s,n,a]),i.callback}r(qJ,"useMergedRefs");function KXe(e){const s=Cge(_ge).current;return WXe(s,e)&&Ige(s,e),s.callback}r(KXe,"useMergedRefsN");function _ge(){return{callback:null,cleanup:null,refs:[]}}r(_ge,"createForkRef");function VXe(e,s,n,a,i){return e.refs[0]!==s||e.refs[1]!==n||e.refs[2]!==a||e.refs[3]!==i}r(VXe,"didChange");function WXe(e,s){return e.refs.length!==s.length||e.refs.some((n,a)=>n!==s[a])}r(WXe,"didChangeN");function Ige(e,s){if(e.refs=s,s.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const a=Array(s.length).fill(null);for(let i=0;i<s.length;i+=1){const o=s[i];if(o!=null)switch(typeof o){case"function":{const l=o(n);typeof l=="function"&&(a[i]=l);break}case"object":o.current=n}}e.cleanup=()=>{for(let i=0;i<s.length;i+=1){const o=s[i];if(o!=null)switch(typeof o){case"function":{const l=a[i];typeof l=="function"?l():o(null);break}case"object":o.current=null}}}}}}r(Ige,"update");var HXe=parseInt("19.2.8",10);function QXe(e){return HXe>=e}r(QXe,"isReactVersionAtLeast");function zJ(e){if(!u.isValidElement(e))return null;const s=e,n=s.props;return(QXe(19)?n?.ref:s.ref)??null}r(zJ,"getReactElementRef");var J8t=Object.freeze([]),Lk=Object.freeze({});function GXe(e,s){const n={};for(const a in e){const i=e[a];if(s?.hasOwnProperty(a)){const o=s[a](i);o!=null&&Object.assign(n,o);continue}i===!0?n[`data-${a.toLowerCase()}`]="":i&&(n[`data-${a.toLowerCase()}`]=i.toString())}return n}r(GXe,"getStateAttributesProps");function YXe(e,s){return typeof e=="function"?e(s):e}r(YXe,"resolveClassName");function JXe(e,s){return typeof e=="function"?e(s):e}r(JXe,"resolveStyle");function XXe(e,s,n={}){const a=s.render,i=ZXe(s,n);return n.enabled===!1?null:sZe(e,a,i,n.state??Lk)}r(XXe,"useRenderElement");function ZXe(e,s={}){const{className:n,style:a,render:i}=e,{state:o=Lk,ref:l,props:c,stateAttributesMapping:d,enabled:m=!0}=s,h=m?YXe(n,o):void 0,p=m?JXe(a,o):void 0,f=m?GXe(o,d):Lk,g=m&&c?eZe(c):void 0,v=m?VF(f,g)??{}:Lk;return typeof document<"u"&&(m?Array.isArray(l)?v.ref=KXe([v.ref,zJ(i),...l]):v.ref=qJ(v.ref,zJ(i),l):qJ(null,null)),m?(h!==void 0&&(v.className=kge(v.className,h)),p!==void 0&&(v.style=VF(v.style,p)),v):Lk}r(ZXe,"useRenderElementProps");function eZe(e){return Array.isArray(e)?OXe(e):jK(void 0,e)}r(eZe,"resolveRenderFunctionProps");var tZe=Symbol.for("react.lazy");function sZe(e,s,n,a){if(s){if(typeof s=="function")return s(n,a);const i=jK(n,s.props);i.ref=n.ref;let o=s;return o?.$$typeof===tZe&&(o=u.Children.toArray(s)[0]),u.cloneElement(o,i)}if(e&&typeof e=="string")return nZe(e,n);throw new Error(UXe(8))}r(sZe,"evaluateRenderProp");function nZe(e,s){return e==="button"?(0,u.createElement)("button",{type:"button",...s,key:s.key}):e==="img"?(0,u.createElement)("img",{alt:"",...s,key:s.key}):u.createElement(e,s)}r(nZe,"renderTag");function rZe(e){return XXe(e.defaultTagName??"div",e,e)}r(rZe,"useRender");var aZe=pz("group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-none border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed",{variants:{size:{default:"gap-2 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5",sm:"gap-2.5 text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1",xs:"gap-1.5 rounded-none text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1"},orientation:{horizontal:"min-w-40 items-center",vertical:"w-24 flex-col has-data-[slot=attachment-content]:w-30"}}});function Age({className:e,state:s="done",size:n="default",orientation:a="horizontal",...i}){return(0,t.jsx)("div",{"data-slot":"attachment","data-state":s,"data-size":n,"data-orientation":a,className:z(aZe({size:n,orientation:a}),e),...i})}r(Age,"Attachment");var iZe=pz("relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-none bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-none group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5",{variants:{variant:{icon:"",image:"opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover"}},defaultVariants:{variant:"icon"}});function Rge({className:e,variant:s="icon",...n}){return(0,t.jsx)("div",{"data-slot":"attachment-media","data-variant":s,className:z(iZe({variant:s}),e),...n})}r(Rge,"AttachmentMedia");function Tge({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-content",className:z("max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1",e),...s})}r(Tge,"AttachmentContent");function Ege({className:e,...s}){return(0,t.jsx)("span",{"data-slot":"attachment-title",className:z("block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer",e),...s})}r(Ege,"AttachmentTitle");function Pge({className:e,...s}){return(0,t.jsx)("span",{"data-slot":"attachment-description",className:z("mt-0.5 block min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive/80","max-w-full",e),...s})}r(Pge,"AttachmentDescription");function oZe({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-actions",className:z("relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:right-3 group-data-[orientation=vertical]/attachment:gap-1",e),...s})}r(oZe,"AttachmentActions$1");function lZe({className:e,variant:s,size:n="icon-xs",...a}){return(0,t.jsx)(F,{"data-slot":"attachment-action",variant:s??"ghost",size:n,className:z(e),...a})}r(lZe,"AttachmentAction");function cZe({className:e,render:s,type:n,...a}){return rZe({defaultTagName:"button",props:jK({type:s?n:n??"button",className:z("absolute inset-0 z-10 outline-none",e)},a),render:s,state:{slot:"attachment-trigger"}})}r(cZe,"AttachmentTrigger");function Mge({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-group",className:z("flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start",e),...s})}r(Mge,"AttachmentGroup");var dZe=new Set(["png","jpg","jpeg","gif","webp","svg","avif","bmp","ico","heic"]),uZe={pdf:{icon:mi,label:"PDF"},doc:{icon:mi,label:"Doc"},docx:{icon:mi,label:"Doc"},txt:{icon:mi,label:"Text"},md:{icon:mi,label:"Markdown"},rtf:{icon:mi,label:"Text"},csv:{icon:Ik,label:"CSV"},tsv:{icon:Ik,label:"TSV"},xls:{icon:Ik,label:"Sheet"},xlsx:{icon:Ik,label:"Sheet"},zip:{icon:V0,label:"ZIP"},gz:{icon:V0,label:"Archive"},tar:{icon:V0,label:"Archive"},tgz:{icon:V0,label:"Archive"},rar:{icon:V0,label:"Archive"},"7z":{icon:V0,label:"Archive"},mp3:{icon:_k,label:"Audio"},wav:{icon:_k,label:"Audio"},m4a:{icon:_k,label:"Audio"},ogg:{icon:_k,label:"Audio"},mp4:{icon:r2,label:"Video"},mov:{icon:r2,label:"Video"},webm:{icon:r2,label:"Video"},json:{icon:jl,label:"JSON"},yaml:{icon:jl,label:"YAML"},yml:{icon:jl,label:"YAML"},xml:{icon:jl,label:"XML"},html:{icon:jl,label:"HTML"},css:{icon:jl,label:"CSS"},js:{icon:jl,label:"Code"},jsx:{icon:jl,label:"Code"},ts:{icon:jl,label:"Code"},tsx:{icon:jl,label:"Code"},py:{icon:jl,label:"Code"},rb:{icon:jl,label:"Code"},go:{icon:jl,label:"Code"},rs:{icon:jl,label:"Code"},sh:{icon:jl,label:"Code"},sql:{icon:jl,label:"SQL"},log:{icon:mi,label:"Log"},patch:{icon:jl,label:"Patch"},diff:{icon:jl,label:"Patch"}};function Dge(e){const s=/\.([a-z0-9]+)$/i.exec(e.trim());return s?s[1].toLowerCase():""}r(Dge,"extensionOf");function UJ(e){return dZe.has(Dge(e))}r(UJ,"isImageFilename");function Lge(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}r(Lge,"normalizedContentType");function vI(e){const s=Lge(e.contentType);return s.startsWith("image/")?!0:s&&s!=="application/octet-stream"?!1:UJ(e.name)||UJ(e.url.split("?")[0])}r(vI,"isImageAttachment$1");function $ge(e){return uZe[Dge(e)]??{icon:cO,label:"File"}}r($ge,"fileKindForName");function mZe(e){const s=$ge(e.name);if(s.label!=="File")return s;const n=Lge(e.contentType);return n==="application/pdf"?{icon:mi,label:"PDF"}:n==="application/json"||n.endsWith("+json")?{icon:jl,label:"JSON"}:n==="text/csv"||n==="application/csv"?{icon:Ik,label:"CSV"}:n.startsWith("text/")?{icon:mi,label:"Text"}:n.startsWith("audio/")?{icon:_k,label:"Audio"}:n.startsWith("video/")?{icon:r2,label:"Video"}:n.includes("zip")||n.includes("archive")?{icon:V0,label:"Archive"}:s}r(mZe,"fileKindForAttachment");function Oge(e){return e===void 0||!Number.isFinite(e)||e<=0?"":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}r(Oge,"formatFileSize");function hZe(e){return/\/api\/(?:attachments|assets)\/([^/?]+)\/content/.exec(e)?.[1]??null}r(hZe,"attachmentIdFromUrl");function KJ(e,s){const n=new Map(s.map(i=>[i.id,i])),a=new Map(s.flatMap(i=>[[i.contentPath,i],...i.openPath?[[i.openPath,i]]:[]]));return e.map(i=>{const o=i.url.split("?")[0],l=a.get(o)??n.get(hZe(i.url)??"");return l?{...i,id:l.id,name:l.originalFilename?.trim()||i.name,contentType:l.contentType,byteSize:l.byteSize,openPath:l.openPath,downloadPath:l.downloadPath}:i})}r(KJ,"hydrateAttachmentRefs");var VJ=/(?<!!)\[((?:\\.|[^\]\\])+)\]\((\/api\/(?:attachments|assets)\/[^()\s]+\/content(?:\?[^()\s]*)?)\)/g,Fge=/!\[((?:\\.|[^\]\\])*)\]\(([^()\s]+)\)/g;function Bge(e){return e.replace(Fge,"").trim().length===0&&e.trim().length>0}r(Bge,"isStandaloneImageEmbedLine");function pZe(e){const s=[],n=new Set;for(const a of e.split(`
336
+ `)}`:void 0}r(EYe,"sanitizeComponentStack");function PYe(e){const s=EYe(e.componentStack),n={};if(typeof document<"u"){try{const a=document.readyState;(a==="loading"||a==="interactive"||a==="complete")&&(n.ready_state=a)}catch{}try{const a=document.visibilityState;(a==="visible"||a==="hidden")&&(n.visibility_state=a)}catch{}try{const a=document.documentElement.classList;n.translation_marker=a.contains("translated-ltr")||a.contains("translated-rtl")}catch{}}return{tags:{react_error_boundary:e.boundary},contexts:{react:s?{componentStack:s}:{},browser_state:n}}}r(PYe,"buildBrowserErrorContext");var NJ=Promise.resolve();function fK(e){const s=NJ.then(e);return NJ=s.catch(()=>{}),s}r(fK,"enqueue");var xw=null;function MYe(e,s){return fK(async()=>{if(!xw)try{const n=await vc(()=>import("./prod-COP_vZWu.js"),__vite__mapDeps([4,5]));n.init(LYe(e,s)),xw=n}catch{}})}r(MYe,"initBrowserErrorMonitoring");function DYe(){return fK(async()=>{const e=xw;if(xw=null,!e)return;const s=e.getClient();try{e.getCurrentScope().setClient(void 0)}catch{}try{await s?.close(2e3)}catch{}})}r(DYe,"teardownBrowserErrorMonitoring");function Bxe(e,s){let n;try{s&&(n=PYe(s))}catch{}fK(async()=>{try{n?xw?.captureException(e,n):xw?.captureException(e)}catch{}})}r(Bxe,"captureBrowserException");function LYe(e,s){return{dsn:e,environment:s??void 0,release:"6a21a6bd8ac991b63796f26f1abf77a9a4242192",tracesSampleRate:0,sendDefaultPii:!1,integrations:r(n=>n.filter(a=>a.name!=="HttpContext"&&a.name!=="Breadcrumbs"),"integrations")}}r(LYe,"buildBrowserSentryInitOptions");var $Ye=class extends u.Component{static{r(this,"RouteErrorBoundaryInner")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,s){Bxe(e,{boundary:"route",componentStack:s.componentStack})}componentDidUpdate(e){this.state.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){const{error:e}=this.state;return e?(0,t.jsxs)("div",{className:"mx-auto max-w-2xl space-y-4 px-4 py-10",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"This page hit an error"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Something went wrong while rendering this page. You can go back and try again, or reload."})]}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive whitespace-pre-wrap",children:e.message}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(F,{variant:"outline",size:"sm",onClick:this.props.onReset,children:"Go back"}),(0,t.jsx)(F,{size:"sm",onClick:r(()=>window.location.reload(),"onClick"),children:"Reload page"})]})]}):this.props.children}};function qxe({children:e}){const s=ea(),n=Hn(),a=`${s.pathname}${s.search}`;return(0,t.jsx)($Ye,{resetKey:a,onReset:r(()=>n(-1),"onReset"),children:e})}r(qxe,"RouteErrorBoundary");var fI=240,qF=208,zF=420,kJ=16;function MT(e){return Math.min(zF,Math.max(qF,e))}r(MT,"clampSidebarWidth$1");function SJ(e){if(typeof window>"u")return fI;try{const s=window.localStorage.getItem(e);if(!s)return fI;const n=Number.parseInt(s,10);return Number.isFinite(n)?MT(n):fI}catch{return fI}}r(SJ,"readStoredSidebarWidth$1");function CJ(e,s){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(MT(s)))}catch{}}r(CJ,"writeStoredSidebarWidth$1");function OYe({children:e,open:s,collapsed:n=!1,peeking:a=!1,resizable:i=!1,storageKey:o="paperclip.sidebar.width",className:l,onPanelMouseEnter:c,onPanelMouseLeave:d,onPanelFocusCapture:m,onPanelBlurCapture:h}){const[p,f]=(0,u.useState)(()=>SJ(o)),[g,v]=(0,u.useState)(!1),y=(0,u.useRef)(p),w=(0,u.useRef)(null);(0,u.useEffect)(()=>{const E=SJ(o);y.current=E,f(E)},[o]);const S=s?p:0,j=s?n?64:S:0,N=s?n&&!a?64:S:0,_=N>j,A=i&&s&&!n,C=(0,u.useMemo)(()=>({width:`${j}px`}),[j]),I=(0,u.useMemo)(()=>({width:`${N}px`}),[N]),T=(0,u.useCallback)(E=>{const q=MT(E);y.current=q,f(q),CJ(o,q)},[o]),R=(0,u.useCallback)(E=>{A&&(E.preventDefault(),E.currentTarget.setPointerCapture(E.pointerId),w.current={startX:E.clientX,startWidth:y.current},v(!0))},[A]),L=(0,u.useCallback)(E=>{if(!w.current)return;const q=MT(w.current.startWidth+E.clientX-w.current.startX);y.current=q,f(q)},[]),O=(0,u.useCallback)(()=>{w.current&&(w.current=null,v(!1),CJ(o,y.current))},[o]),$=(0,u.useCallback)(E=>{A&&(E.key==="ArrowLeft"?(E.preventDefault(),T(p-kJ)):E.key==="ArrowRight"?(E.preventDefault(),T(p+kJ)):E.key==="Home"?(E.preventDefault(),T(qF)):E.key==="End"&&(E.preventDefault(),T(zF)))},[A,T,p]);return(0,t.jsxs)("div",{className:z("relative h-full shrink-0",l),style:C,children:[(0,t.jsx)("div",{className:z("absolute inset-y-0 left-0 flex flex-col overflow-hidden",_?"z-30 border-r border-border bg-background shadow-lg":"z-0"),style:I,"data-sidebar-overlay":_?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:m,onBlurCapture:h,children:e}),A?(0,t.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":qF,"aria-valuemax":zF,"aria-valuenow":p,tabIndex:0,"data-dragging":g?"":void 0,className:"group absolute inset-y-0 z-20 cursor-col-resize touch-none outline-none",style:{right:-4,width:8},onPointerDown:R,onPointerMove:L,onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,onKeyDown:$,children:(0,t.jsx)("div",{className:z("mx-auto h-full w-0.5 transition-colors",g?"bg-ring":"bg-transparent group-hover:bg-ring group-focus-visible:bg-ring")})}):null]})}r(OYe,"SidebarShell$1");function xI({children:e,className:s}){return(0,t.jsx)("div",{"data-secondary-sidebar":"",className:z("h-full w-full min-w-0 overflow-hidden",s),children:(0,t.jsx)(Zde,{children:e})})}r(xI,"SecondarySidebar$1");var FYe="Toggle the app appearance.";function Aj({className:e,variant:s="icon",onAfterToggle:n}){const{theme:a,toggleTheme:i}=aRe(),o=a==="dark",l=o?"Switch to light mode":"Switch to dark mode",c=o?Mde:_de;function d(){i(),n?.()}return r(d,"handleClick"),s==="compact-menu-action"?(0,t.jsxs)("button",{type:"button",className:z("flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-foreground transition-colors hover:bg-accent",e),onClick:d,"aria-label":l,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(c,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:l})]}):s==="menu-action"?(0,t.jsxs)("button",{type:"button",className:z("flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-accent/60",e),onClick:d,"aria-label":l,children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(c,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:l}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:FYe})]})]}):(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":l,title:l,className:z("text-muted-foreground",e),children:(0,t.jsx)(c,{})})}r(Aj,"ThemeToggle");function BYe(e){if(!e)return"Unavailable";const s=new Date(e);return Number.isNaN(s.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(s)}r(BYe,"formatTimestamp$2");function qYe(e){return!!e&&!Number.isNaN(new Date(e).getTime())}r(qYe,"isValidTimestamp");function zYe(e){return e?.devServer?.lastRestartAt??e?.serverInfo?.processStartedAt??null}r(zYe,"restartTimestamp");function UYe(e){const s=e?.serverInfo?.git;return s?.available?`${s.shortSha} · ${s.subject}`:"Commit unavailable"}r(UYe,"commitLabel");function KYe(e){const s=e?.serverInfo?.git;if(!s?.available)return"Unavailable";const n=s.localChanges;if(!n||!n.available)return"Change status unavailable";if(!n.hasLocalChanges)return"Clean checkout";const a=[[n.stagedFileCount,"staged"],[n.unstagedFileCount,"unstaged"],[n.untrackedFileCount,"untracked"]].filter(([i])=>Number(i)>0).map(([i,o])=>`${i} ${o}`);return a.length>0?`Local changes present (${a.join(", ")})`:"Local changes present"}r(KYe,"localChangesLabel");function q4({icon:e,label:s,value:n,dateTime:a}){return(0,t.jsxs)("div",{className:"flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left",children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(e,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:s}),a?(0,t.jsx)("time",{dateTime:a,className:"block break-words text-xs text-muted-foreground",children:n}):(0,t.jsx)("span",{className:"block break-words text-xs text-muted-foreground",children:n})]})]})}r(q4,"ServerInfoRow");function zxe(){const e=ee({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn")}).data?.enableServerInfoDebugView===!0,s=ee({queryKey:P.health,queryFn:r(()=>tm.get(),"queryFn"),enabled:e,refetchOnMount:"always",refetchInterval:r(h=>h.state.data?.devServer?.enabled?2e3:!1,"refetchInterval")});if(!e)return null;const n=s.data,a=s.isLoading&&!n,i=s.isError,o=zYe(n),l=qYe(o),c=i?"Health unavailable":a?"Loading...":BYe(o),d=i?"Health unavailable":a?"Loading...":UYe(n),m=i?"Health unavailable":a?"Loading...":KYe(n);return(0,t.jsxs)("div",{className:"mt-2 border-t border-border pt-2",children:[(0,t.jsx)("p",{className:"px-3 pb-1 pt-1 text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Server"}),(0,t.jsx)(q4,{icon:th,label:"Last restarted",value:c,dateTime:!i&&!a&&l?o:null}),(0,t.jsx)(q4,{icon:gde,label:"Running commit",value:d}),(0,t.jsx)(q4,{icon:A3e,label:"Checkout state",value:m})]})}r(zxe,"SidebarServerInfo");var VYe="/company/settings/instance/profile",WYe="https://docs.paperclip.ing/",HYe="https://paperclip.ing/feedback";function QYe(e){const s=e.trim().split(/\s+/).filter(Boolean);return s.length>=2?`${s[0]?.[0]??""}${s[s.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}r(QYe,"deriveInitials$2");function GYe(e,s,n){const a=[e,s?.split("@")[0],s,n];for(const i of a){const o=i?.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(o)return o}return"me"}r(GYe,"deriveUserSlug$1");function gI({label:e,icon:s,onClick:n,href:a,external:i=!1}){const o="flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-foreground transition-colors hover:bg-accent",l=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(s,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e})]});return a?i?(0,t.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",className:o,onClick:n,children:l}):(0,t.jsx)(Ge,{to:a,className:o,onClick:n,children:l}):(0,t.jsx)("button",{type:"button",className:o,onClick:n,children:l})}r(gI,"MenuAction$1");function _J({deploymentMode:e,open:s,onOpenChange:n,forceExpanded:a=!1}){const i=!!Qc(),[o,l]=(0,u.useState)(!1),{isMobile:c,setSidebarOpen:d,collapsed:m,peeking:h}=Wa(),p=m&&!h&&!a,f=s??o,g=n??l,{data:v}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),y=Yw({onSignedOut:_}),w=v?.user.name?.trim()||"Board",S=v?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),j=QYe(w),N=`/u/${GYe(v?.user.name,v?.user.email,v?.user.id)}`;function _(){g(!1),c&&d(!1)}r(_,"closeNavigationChrome");function A(){y.mutate()}return r(A,"handleSignOut"),(0,t.jsx)("div",{className:"bg-border/50 px-3 py-2 dark:bg-muted",children:(0,t.jsxs)("div",{className:z("flex items-center gap-0.5",!p&&"px-2"),children:[(0,t.jsxs)(nr,{open:f,onOpenChange:g,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:z("flex min-w-0 items-center gap-2.5 rounded-lg text-left text-(length:--text-compact) font-medium text-foreground/80 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",p?"w-full px-3 py-2":"flex-1 px-2 py-1.5"),"aria-label":"Open account menu",children:[(0,t.jsxs)(Yi,{size:"sm",children:[v?.user.image?(0,t.jsx)(Vc,{src:v.user.image,alt:w}):null,(0,t.jsx)(Ji,{children:j})]}),(0,t.jsx)("span",{className:z("min-w-0 flex-1 truncate",p&&"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none"),children:w})]})}),(0,t.jsxs)(Wn,{side:"top",align:"start",sideOffset:10,className:"min-h-(--profile-popover-min-height) w-(--profile-popover-width) max-w-(--sz-calc-24) overflow-hidden rounded-xl border-border bg-popover p-0 shadow-(--shadow-profile-popover)",children:[(0,t.jsxs)("div",{className:"flex h-(--profile-popover-header-height) shrink-0 items-center gap-2.5 px-3.5",children:[(0,t.jsxs)(Yi,{className:"size-9",children:[v?.user.image?(0,t.jsx)(Vc,{src:v.user.image,alt:w}):null,(0,t.jsx)(Ji,{className:"text-xs text-foreground",children:j})]}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("h2",{className:"truncate text-sm font-semibold leading-(--profile-popover-label-line-height) text-foreground",children:w}),(0,t.jsx)("p",{className:"truncate text-(length:--text-micro) leading-(--profile-popover-meta-line-height) text-muted-foreground",children:S})]})]}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-0.5 border-t border-border px-2.5 pb-2.5 pt-2",children:[(0,t.jsx)(gI,{label:"Settings",icon:Ld,href:"/company/settings",onClick:_}),(0,t.jsx)(gI,{label:"View profile",icon:vu,href:N,onClick:_}),(0,t.jsx)(gI,{label:"Edit profile",icon:b1,href:VYe,onClick:_}),(0,t.jsx)(gI,{label:"Documentation",icon:Ww,href:WYe,external:!0,onClick:r(()=>g(!1),"onClick")}),(0,t.jsx)(Aj,{variant:"compact-menu-action",onAfterToggle:r(()=>g(!1),"onAfterToggle")}),e==="authenticated"?(0,t.jsxs)("button",{type:"button",className:z("flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-foreground transition-colors hover:bg-destructive/10",y.isPending&&"cursor-not-allowed opacity-60"),onClick:A,disabled:y.isPending,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(Yh,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:y.isPending?"Signing out...":"Sign out"})]}):null,(0,t.jsx)(zxe,{})]})]})]}),!p&&!i?(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)("a",{href:HYe,target:"_blank",rel:"noreferrer","aria-label":"Share feedback",className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground/50 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(Ex,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsx)(Un,{side:"top",children:"Share feedback"})]}):null]})})}r(_J,"SidebarAccountMenu$1");function Uxe({enabled:e=!0,onNewIssue:s,onSearch:n,onToggleSidebar:a,onTogglePanel:i,onShowShortcuts:o,onGoToInbox:l}){(0,u.useEffect)(()=>{if(!e)return;let c=!1,d=null;const m=r(()=>{d!==null&&(window.clearTimeout(d),d=null)},"clearGoChordTimeout"),h=r(()=>{c=!1,m()},"disarmGoChord"),p=r(()=>{c=!0,m(),d=window.setTimeout(()=>{c=!1,d=null},1200)},"armGoChord");function f(y){if(y.defaultPrevented){h();return}if(l){const w=Zle({armed:c,defaultPrevented:y.defaultPrevented,key:y.key,metaKey:y.metaKey,ctrlKey:y.ctrlKey,altKey:y.altKey,target:y.target,hasOpenDialog:Rh()});if(w==="arm"){p();return}if(w==="navigate_inbox"){h(),y.preventDefault(),l();return}if(w==="focus_comment"||w==="open_file_viewer"){h(),y.preventDefault();return}w==="disarm"&&h()}if(!XC(y.target)){if(y.key==="/"&&!y.metaKey&&!y.ctrlKey&&!y.altKey){if(Rh())return;y.preventDefault(),WAe()||n?.();return}if(y.key==="?"&&!y.metaKey&&!y.ctrlKey&&!y.altKey){y.preventDefault(),o?.();return}y.key==="c"&&!y.metaKey&&!y.ctrlKey&&!y.altKey&&(y.preventDefault(),s?.()),y.key==="["&&!y.metaKey&&!y.ctrlKey&&(y.preventDefault(),a?.()),y.key==="]"&&!y.metaKey&&!y.ctrlKey&&(y.preventDefault(),i?.())}}r(f,"handleKeyDown");const g=r(()=>h(),"handlePointerDown"),v=r(y=>{y.target instanceof HTMLElement&&y.target!==document.body&&h()},"handleFocusIn");return document.addEventListener("pointerdown",g,!0),document.addEventListener("focusin",v,!0),document.addEventListener("keydown",f),()=>{h(),document.removeEventListener("pointerdown",g,!0),document.removeEventListener("focusin",v,!0),document.removeEventListener("keydown",f)}},[e,s,n,a,i,o,l])}r(Uxe,"useKeyboardShortcuts");var YYe=new Set(["auth","invite","board-claim","cli-auth","docs"]);function Kxe(e){const s=(e.split("?")[0]??"").split("/").filter(Boolean);if(s.length===0)return!0;const[n]=s;return!YYe.has(n)}r(Kxe,"isRememberableCompanyPath");function JYe(e){const s=Ob(e.companyPrefix);return e.companies.find(n=>Ob(n.issuePrefix)===s)??null}r(JYe,"findCompanyByPrefix");function XYe(e){const s=sz(e.pathname);return s?JYe({companies:e.companies,companyPrefix:s})?.id??null:e.fallbackCompanyId}r(XYe,"getRememberedPathOwnerCompanyId");function ZYe(e){const s=e.path?s5(e.path):"/dashboard";if(!Kxe(s))return"/dashboard";const[n,a]=(s.split("?")[0]??"").split("/").filter(Boolean);if(n==="issues"&&a){const i=/^([A-Za-z]+)-\d+$/.exec(a);if(i&&Ob(i[1]??"")!==Ob(e.companyPrefix))return"/dashboard"}return s}r(ZYe,"sanitizeRememberedPathForCompany");var Vxe="paperclip.companyPaths";function Wxe(){try{const e=localStorage.getItem(Vxe);if(e)return JSON.parse(e)}catch{}return{}}r(Wxe,"getCompanyPaths");function eJe(e,s){const n=Wxe();n[e]=s,localStorage.setItem(Vxe,JSON.stringify(n))}r(eJe,"saveCompanyPath");function Hxe(){const{companies:e,selectedCompanyId:s,selectedCompany:n,selectionSource:a}=xs(),i=ea(),o=Hn(),l=(0,u.useRef)(s),c=(0,u.useMemo)(()=>XYe({companies:e,pathname:i.pathname,fallbackCompanyId:l.current}),[e,i.pathname]),d=i.pathname+i.search;(0,u.useEffect)(()=>{const m=c,h=s5(d);m&&Kxe(h)&&eJe(m,h)},[d,c]),(0,u.useEffect)(()=>{if(s){if(l.current!==null&&s!==l.current&&a!=="route_sync"&&n){const m=Wxe(),h=ZYe({path:m[s],companyPrefix:n.issuePrefix});o(`/${n.issuePrefix}${h}`,{replace:!0})}l.current=s}},[n,s,a,o])}r(Hxe,"useCompanyPageMemory");var tJe=24,sJe=8;function Qxe(e,s,n){const a=n&&!xme(e,s).isTaskDetail,i=(0,u.useRef)(0),[o,l]=(0,u.useState)(!0),c=(0,u.useCallback)(d=>{const m=d-i.current;i.current=d,d<=tJe?l(!0):m>sJe?l(!1):m<-8&&l(!0)},[]);return(0,u.useEffect)(()=>{if(i.current=0,!a){l(!0);return}const d=r(()=>{c(window.scrollY||document.documentElement.scrollTop||0)},"onScroll");return d(),window.addEventListener("scroll",d,{passive:!0}),()=>window.removeEventListener("scroll",d)},[a,e,c]),o}r(Qxe,"useMobileNavAutoHide");function Gxe(e){const{matchedCompany:s,selectedCompanyId:n,companies:a}=e;return!s||s.status!=="archived"||n===s.id?null:a.find(i=>i.id===n&&i.status!=="archived")??a.find(i=>i.status!=="archived")??null}r(Gxe,"resolveArchivedCompanyBounce");function nJe(e){const{archivedCompanyId:s,companies:n,cloudPortfolioUrl:a}=e,i=n.find(o=>o.id!==s&&o.status!=="archived");return i?{kind:"company",company:i}:a?{kind:"cloud_portfolio",url:a}:{kind:"companies_list"}}r(nJe,"resolveCompanyArchiveDeparture");function Yxe(e){const{selectionSource:s,selectedCompanyId:n,routeCompanyId:a}=e;return!(n===a||s==="manual"&&n)}r(Yxe,"shouldSyncCompanySelectionFromRoute");function rJe(e,s){return e instanceof HTMLElement?!(s instanceof HTMLElement)||!document.contains(s)||s===document.body||s===document.documentElement?!0:!e.contains(s):!1}r(rJe,"shouldFocusMainContentAfterNavigation");function Jxe(e){if(!(e instanceof HTMLElement))return()=>{};const s=window.requestAnimationFrame(()=>{rJe(e,document.activeElement)&&e.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(s)}r(Jxe,"scheduleMainContentFocus");function Xxe(e=document,s=window){const n=r(()=>{e.documentElement.scrollTop!==0&&(e.documentElement.scrollTop=0),e.body.scrollTop!==0&&(e.body.scrollTop=0)},"onScroll");return s.addEventListener("scroll",n,{capture:!0}),()=>s.removeEventListener("scroll",n,{capture:!0})}r(Xxe,"pinDocumentScrollToZero");function xu({scope:e="global",requestedPrefix:s}){const n=ea(),{setBreadcrumbs:a}=Ln(),{companies:i,selectedCompany:o}=xs();(0,u.useEffect)(()=>{a([{label:"Not Found"}])},[a]);const l=o??i[0]??null,c=l?`/${l.issuePrefix}/dashboard`:"/",d=`${n.pathname}${n.search}${n.hash}`,m=s?.toUpperCase(),h=e==="invalid_company_prefix"?"Organization not found":"Page not found",p=e==="invalid_company_prefix"?`No organization matches prefix "${m??"unknown"}".`:"This route does not exist.";return(0,t.jsx)("div",{className:"mx-auto max-w-2xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 p-2",children:(0,t.jsx)(Rs,{className:"h-5 w-5 text-destructive"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:h}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:p})]})]}),(0,t.jsxs)("div",{className:"mt-4 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:["Requested path: ",(0,t.jsx)("code",{className:"font-mono",children:d})]}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{asChild:!0,children:(0,t.jsxs)(Ge,{to:c,children:[(0,t.jsx)(AR,{className:"mr-1.5 h-4 w-4"}),"Open dashboard"]})}),(0,t.jsx)(F,{variant:"outline",asChild:!0,children:(0,t.jsx)(Ge,{to:"/",children:"Go home"})})]})]})})}r(xu,"NotFoundPage");function aJe(e,s){return fme(e,s)[0]?.toLowerCase()??null}r(aJe,"getCompanyRouteSegment$1");var iJe=new Set(["browse","connections","connect","chat","vercel-connect","review","attention","gateways","advanced","app"]);function oJe({sidebarSections:e}){const{sidebarOpen:s,setSidebarOpen:n,toggleSidebar:a,collapsed:i,peeking:o,setPeeking:l,isMobile:c,setForceCollapsed:d}=Wa(),{openNewIssue:m,openOnboarding:h}=$o(),{togglePanelVisible:p}=bf(),f=Sc()?.pushToast??null,{companies:g,loading:v,selectedCompany:y,selectedCompanyId:w,selectionSource:S,setSelectedCompanyId:j}=xs(),{companyPrefix:N,pluginRoutePath:_,agentId:A,routineId:C}=ka(),I=Hn(),T=ea(),R=t5(),{enabled:L}=kc(),O=xme(T.pathname,N),$=O.builtInContextualSurface==="settings",E=O.companySegments,q=O.isTaskDetail,B=L&&q,K=E[0]?.toLowerCase()==="tools",U=E[0]?.toLowerCase()==="apps",D=U&&E[1]&&!iJe.has(E[1].toLowerCase())?E[1]:null,V=U&&E[1]?.toLowerCase()==="app"&&E[2]?E[2]:null,H=(0,u.useRef)(!1),J=(0,u.useRef)(null),X=(0,u.useRef)(null),le=(0,u.useRef)(new Yde),ce=(0,u.useRef)(T.key),te=Qxe(T.pathname,N,c),[re,de]=(0,u.useState)(!1),Z=(0,u.useMemo)(()=>{if(!N)return null;const ft=N.toUpperCase();return g.find(Ot=>Ot.issuePrefix.toUpperCase()===ft)??null},[g,N]),Y=!!N&&!v&&g.length>0&&!Z,G=(0,u.useMemo)(()=>_?.toLowerCase()??aJe(T.pathname,N),[N,T.pathname,_]),fe=Z?.id??null,se=Z?.issuePrefix??null,{slots:ae}=Hc({slotTypes:["page","routeSidebar"],companyId:fe,enabled:!!(fe&&G)}),ie=(0,u.useMemo)(()=>Vz(ae,G),[G,ae]),ue=(0,u.useMemo)(()=>({companyId:fe,companyPrefix:se}),[fe,se]),pe=$?(0,t.jsx)(jOe,{}):!L&&O.builtInContextualSurface==="skills"?(0,t.jsx)(fQ,{}):D?(0,t.jsx)(hQ,{kind:"connection",connectionId:D}):V?(0,t.jsx)(hQ,{kind:"application",applicationId:V}):U||K?(0,t.jsx)(IOe,{}):ie?L?(0,t.jsx)(N1,{surface:`plugin:${ie.id}`,title:ie.displayName,children:(0,t.jsx)(yu,{slot:ie,context:ue,className:"min-h-0 flex-1",missingBehavior:"placeholder"})}):(0,t.jsx)(yu,{slot:ie,context:ue,className:"h-full w-full",missingBehavior:"placeholder"}):null,be=O.builtInContextualSurface==="agent"&&A?(0,t.jsx)(UOe,{agentRef:A}):L&&O.builtInContextualSurface==="routine"&&C?(0,t.jsx)(Q4e,{children:(0,t.jsx)(WOe,{routineId:C})}):L&&O.builtInContextualSurface==="skills"?(0,t.jsx)(fQ,{}):pe,oe=be!=null,je=L&&oe&&(O.builtInContextualSurface==="skills"||O.builtInContextualSurface==="agent"||O.builtInContextualSurface==="routine"||U||K),_e=L&&oe&&!je,xe=oe&&(!L||je),Ae=!L||!oe?null:ie&&!O.builtInContextualSurface?`plugin:${ie.id}`:O.builtInContextualSurface,Ye=(0,u.useRef)(null),{data:Oe}=ee({queryKey:P.health,queryFn:r(()=>tm.get(),"queryFn"),retry:!1,refetchInterval:r(ft=>ft.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1}),Xe=ee({queryKey:P.instance.generalSettings,queryFn:r(()=>Ir.getGeneral(),"queryFn")}).data?.keyboardShortcuts===!0;(0,u.useLayoutEffect)(()=>(d(!L&&oe),()=>d(!1)),[oe,d,L]),(0,u.useEffect)(()=>{const ft=Ye.current;Ae&&N&&ft&&ft.surface!==Ae&&ft.pathname!==T.pathname&&bOe({surface:Ae,companyPrefix:N,previousPathname:ft.pathname}),Ye.current={pathname:T.pathname,surface:Ae}},[N,Ae,T.pathname]),(0,u.useEffect)(()=>{v||H.current||Oe?.deploymentMode!=="authenticated"&&(Oe?.cloud||g.length===0&&(H.current=!0,h()))},[g,v,h,Oe?.cloud,Oe?.deploymentMode]),(0,u.useEffect)(()=>{if(!N||v||g.length===0)return;if(!Z){const Ot=(w?g.find(es=>es.id===w):null)??g[0]??null;Ot&&w!==Ot.id&&j(Ot.id,{source:"route_sync"});return}if(N!==Z.issuePrefix){const Ot=T.pathname.replace(/^\/[^/]+/,"");I(`/${Z.issuePrefix}${Ot}${T.search}`,{replace:!0});return}const ft=Gxe({matchedCompany:Z,selectedCompanyId:w,companies:g});if(ft){f?.({title:`${Z.name} is archived`,body:`Switched to ${ft.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${Z.id}`}),j(ft.id,{source:"route_sync"}),I(`/${ft.issuePrefix}/dashboard`,{replace:!0});return}Yxe({selectionSource:S,selectedCompanyId:w,routeCompanyId:Z.id})&&j(Z.id,{source:"route_sync"})},[N,g,v,Z,T.pathname,T.search,I,f,S,w,j]);const me=p,Le=(0,u.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),mt=(0,u.useRef)(null),We=(0,u.useRef)(!1),ze=(0,u.useRef)(!1),st=(0,u.useCallback)(()=>{mt.current!==null&&(window.clearTimeout(mt.current),mt.current=null)},[]),pt=(0,u.useCallback)(()=>{st(),mt.current=window.setTimeout(()=>l(!0),50)},[st,l]),Pt=(0,u.useCallback)(()=>{st(),l(!0)},[st,l]),tt=(0,u.useCallback)(()=>{st(),mt.current=window.setTimeout(()=>l(!1),120)},[st,l]),ht=(0,u.useCallback)(()=>{We.current=!0,i&&!ze.current&&pt()},[i,pt]),et=(0,u.useCallback)(()=>{We.current=!1,ze.current=!1,tt()},[tt]),Ie=(0,u.useCallback)(()=>{ze.current||Pt()},[Pt]),Ne=(0,u.useCallback)(()=>{We.current||tt()},[tt]);(0,u.useEffect)(()=>st,[st]);const Je=(0,u.useRef)(i);return(0,u.useEffect)(()=>{i!==Je.current&&(i?(st(),l(!1),ze.current=We.current):ze.current=!1,Je.current=i)},[i,st,l]),(0,u.useEffect)(()=>{if(!o)return;const ft=r(Ot=>{Ot.key==="Escape"&&(st(),l(!1))},"onKeyDown");return window.addEventListener("keydown",ft),()=>window.removeEventListener("keydown",ft)},[o,st,l]),Hxe(),Uxe({enabled:Xe,onNewIssue:r(()=>m(),"onNewIssue"),onSearch:Le,onToggleSidebar:a,onTogglePanel:me,onShowShortcuts:r(()=>de(!0),"onShowShortcuts"),onGoToInbox:r(()=>I("/inbox"),"onGoToInbox")}),(0,u.useEffect)(()=>{if(!c)return;const ft=30,Ot=50,es=75;let bs=0,Ke=0;const Ve=r(Be=>{const as=Be.touches[0];bs=as.clientX,Ke=as.clientY},"onTouchStart"),dt=r(Be=>{const as=Be.changedTouches[0],Fe=as.clientX-bs;if(!(Math.abs(as.clientY-Ke)>es)){if(!s&&bs<ft&&Fe>Ot){n(!0);return}s&&Fe<-50&&n(!1)}},"onTouchEnd");return document.addEventListener("touchstart",Ve,{passive:!0}),document.addEventListener("touchend",dt,{passive:!0}),()=>{document.removeEventListener("touchstart",Ve),document.removeEventListener("touchend",dt)}},[c,s,n]),(0,u.useEffect)(()=>{const ft=document.body.style.overflow;return document.body.style.overflow=c?"visible":"clip",()=>{document.body.style.overflow=ft}},[c]),(0,u.useEffect)(()=>{if(!c)return Xxe()},[c]),(0,u.useEffect)(()=>{if(typeof document>"u")return;const ft=X.current;return Jxe(ft)},[T.pathname]),(0,u.useEffect)(()=>{const ft=X.current;if(!ft)return;const Ot=r(()=>{le.current.remember(ce.current,ft.scrollTop)},"recordScroll");return ft.addEventListener("scroll",Ot,{passive:!0}),()=>ft.removeEventListener("scroll",Ot)},[]),(0,u.useLayoutEffect)(()=>{const ft=X.current,Ot=Gde({previousPathname:J.current,pathname:T.pathname,navigationType:R,state:T.state});J.current=T.pathname;const es=R==="POP",bs=es?le.current.recall(T.key):0;if(ce.current=T.key,es){WR(ft,bs);const Ke=requestAnimationFrame(()=>WR(ft,bs));return()=>cancelAnimationFrame(Ke)}Ot&&Jde(ft)},[T.key,T.pathname,T.state,R]),(0,t.jsx)(Qde,{children:(0,t.jsx)(tce,{value:{keyboardShortcutsEnabled:Xe},children:(0,t.jsxs)("div",{className:z("bg-background text-foreground pt-(--sz-safe-top)",c?"min-h-dvh overflow-x-clip":"flex h-dvh flex-col overflow-clip"),children:[(0,t.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:left-3 focus:top-3 focus:z-(--z-200) focus:rounded-md focus:bg-background focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Skip to Main Content"}),(0,t.jsx)($xe,{}),(0,t.jsx)(Oxe,{devServer:Oe?.devServer}),(0,t.jsxs)("div",{className:z("min-h-0 flex-1",c?"w-full":"flex overflow-clip"),children:[c&&s&&(0,t.jsx)("button",{type:"button",className:"fixed inset-0 z-40 bg-black/50",onClick:r(()=>n(!1),"onClick"),"aria-label":"Close sidebar"}),c?(0,t.jsxs)("div",{className:z("fixed inset-y-0 left-0 z-50 flex flex-col overflow-hidden pt-(--sz-safe-top) transition-transform duration-100 ease-out",s?"translate-x-0":"-translate-x-full"),children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:(0,t.jsx)("div",{className:"w-60 shrink-0 overflow-hidden",children:oe?(0,t.jsx)(xI,{children:be}):(0,t.jsx)(cQ,{children:e})})}),(0,t.jsx)(_J,{deploymentMode:Oe?.deploymentMode,forceExpanded:_e})]}):(0,t.jsxs)(OYe,{open:s,collapsed:_e?!1:i,peeking:_e?!1:o,resizable:!0,onPanelMouseEnter:_e?void 0:ht,onPanelMouseLeave:_e?void 0:et,onPanelFocusCapture:!_e&&i?Ie:void 0,onPanelBlurCapture:!_e&&i?Ne:void 0,children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0",children:_e?(0,t.jsx)(xI,{children:be}):(0,t.jsx)(cQ,{children:e})}),(0,t.jsx)(_J,{deploymentMode:Oe?.deploymentMode,forceExpanded:_e})]}),!c&&xe&&!je?(0,t.jsx)(xI,{className:"w-60 shrink-0",children:be}):null,(0,t.jsxs)("div",{className:z("flex min-w-0 flex-col",c?"w-full":"h-full flex-1"),children:[(0,t.jsxs)("div",{className:z(!c&&B&&"hidden",c&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:[(0,t.jsx)(BF,{mobile:c}),(0,t.jsx)(gQ,{}),c&&$?(0,t.jsx)("div",{className:"border-b border-border px-4 pb-3",children:(0,t.jsx)(vme,{})}):null]}),(0,t.jsxs)("div",{className:z(c?"block":"flex flex-1 min-h-0",!c&&B&&"streamlined-task-detail-surface"),children:[!c&&je?(0,t.jsx)(xI,{className:"w-60 shrink-0 bg-background",children:be}):null,(0,t.jsxs)("div",{className:z(!c&&B?"flex min-w-0 flex-1 flex-col":"contents"),children:[!c&&B?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(BF,{mobile:!1}),(0,t.jsx)(gQ,{taskDetailLayout:!0})]}):null,(0,t.jsx)("main",{id:"main-content",ref:X,tabIndex:-1,style:c?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:z("flex-1 p-4 outline-none md:p-6",!c&&B&&"pt-0 md:pt-0",c?"overflow-visible pb-(--sz-calc-14)":"overflow-auto [scrollbar-gutter:stable]"),children:Y?(0,t.jsx)(xu,{scope:"invalid_company_prefix",requestedPrefix:N??y?.issuePrefix}):(0,t.jsx)(qxe,{children:(0,t.jsx)(r0,{})})})]}),(0,t.jsx)(Tme,{taskDetailLayout:!c&&B})]})]})]}),c&&(0,t.jsx)(Lxe,{visible:te}),(0,t.jsx)(Mme,{}),(0,t.jsx)(Hme,{}),(0,t.jsx)(Ixe,{}),(0,t.jsx)(Txe,{}),(0,t.jsx)(Exe,{}),(0,t.jsx)(Pxe,{open:re,onOpenChange:de}),(0,t.jsx)(Mxe,{}),(0,t.jsx)(hYe,{health:Oe}),(0,t.jsx)(Dxe,{localTrusted:Oe?.deploymentMode==="local_trusted"})]})})})}r(oJe,"Layout$1");var Zxe=(0,u.createContext)(!1);function lJe({children:e}){return(0,t.jsx)(Zxe.Provider,{value:!0,children:e})}r(lJe,"SidebarNavExpandedProvider");function cJe(){return(0,u.useContext)(Zxe)}r(cJe,"useSidebarNavExpanded");function Ya({to:e,label:s,icon:n,iconNode:a,end:i,className:o,labelClassName:l,badge:c,badgeTone:d="default",badgeLabel:m,textBadge:h,textBadgeTone:p="default",alert:f=!1,liveCount:g,active:v,trailing:y,trailingLabel:w,liveAccessory:S}){const{isMobile:j,setSidebarOpen:N,collapsed:_,peeking:A}=Wa(),C=cJe(),I=_&&!A&&!C,T=c!=null&&c>0,R=g!=null&&g>0,L=R?`${g} live`:T?`${c}${m?` ${m}`:""}`:f?"attention needed":void 0,O=!I||!L&&!w?void 0:`${s}${L?`, ${L}`:""}${w?`, ${w}`:""}`,$=(0,t.jsxs)(a0,{to:e,state:ff,end:i,"aria-label":O,onClick:r(()=>{j&&N(!1)},"onClick"),className:r(({isActive:E})=>z("flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium transition-colors",v??E?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground",o),"className"),children:[(0,t.jsxs)("span",{className:"relative shrink-0",children:[a??(n?(0,t.jsx)(n,{className:"h-4 w-4"}):null),f&&(0,t.jsx)("span",{className:"absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-red-500 shadow-(--shadow-extract-12)","aria-hidden":"true"}),I&&!f&&R&&(0,t.jsxs)("span",{className:"absolute -right-0.5 -top-0.5 flex h-2 w-2","aria-hidden":"true",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-600 dark:bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-blue-600 dark:bg-blue-400 shadow-(--shadow-extract-12)"})]}),I&&!f&&!R&&T&&(0,t.jsx)("span",{className:z("absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full shadow-(--shadow-extract-12)",d==="danger"?"bg-red-600":d==="warning"?"bg-amber-500":"bg-primary"),"aria-hidden":"true"})]}),(0,t.jsx)("span",{className:I?fv:z("min-w-0 flex-1 truncate",l),children:s}),!I&&y,!I&&h&&(0,t.jsx)(ct,{variant:"ghost",className:z("ml-auto px-1.5 text-(length:--text-nano) leading-none",p==="amber"?"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400":"bg-muted text-muted-foreground"),children:h}),!I&&(R||S)&&(0,t.jsxs)("span",{className:"ml-auto flex items-center gap-1.5",children:[S,R&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-600 dark:bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-600 dark:bg-blue-400"})]}),(0,t.jsxs)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:[g," live"]})]})]}),!I&&T&&(0,t.jsx)(ct,{variant:"ghost",className:z("ml-auto px-1.5 leading-none",d==="danger"?"bg-red-600/90 text-red-50":d==="warning"?"bg-amber-500/90 text-amber-50":"bg-primary text-primary-foreground"),children:c})]});return I?(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)("div",{children:$})}),(0,t.jsx)(Un,{side:"right",children:s})]}):$}r(Ya,"SidebarNavItem");var dJe=3,IJ=12e4,uJe=[{value:"top",label:"Top"},{value:"alphabetical",label:"Alphabetical"},{value:"recent",label:"Recent"}];function fy(e,s){const n=e[s];if(!n)return 0;const a=new Date(n).getTime();return Number.isFinite(a)?a:0}r(fy,"agentTimestamp");function AJ(e,s){if(s==="top")return e;const n=[...e];return s==="alphabetical"?(n.sort((a,i)=>a.name.localeCompare(i.name,void 0,{sensitivity:"base"})),n):(n.sort((a,i)=>{const o=fy(i,"lastHeartbeatAt")-fy(a,"lastHeartbeatAt");if(o!==0)return o;const l=fy(i,"updatedAt")-fy(a,"updatedAt");if(l!==0)return l;const c=fy(i,"createdAt")-fy(a,"createdAt");return c!==0?c:a.name.localeCompare(i.name,void 0,{sensitivity:"base"})}),n)}r(AJ,"sortAgents");var mJe="opacity-0 transition-opacity group-hover/agent:opacity-100 group-focus-within/agent:opacity-100";function hJe({activeAgentId:e,activeTab:s,agent:n,disabled:a,isMobile:i,leaving:o,onLeaveAgent:l,onPauseResume:c,rail:d,runCount:m,setSidebarOpen:h,builtInStatus:p,starred:f=!1,onToggleStar:g,starPending:v=!1}){const y=jc(n),w=s?`${Qu(n)}/${s}`:Qu(n),S=`${Qu(n)}/configuration`,j=e===y,N=n.status==="paused",_=N&&n.pauseReason==="budget",A=n.orgChainHealth?.status==="invalid_org_chain",C=N?"Resume agent":"Pause agent",I=a||n.status==="pending_approval"||_||N&&A,T=a?"Updating...":_?"Budget paused":N&&A?"Invalid org chain":C,R=p==="needs_setup"||p==="pending_approval",L=[R?`Built-in agent ${p.replace(/_/g," ")}`:null,A?"Invalid reporting chain":null].filter(Boolean).join(", ")||void 0,O=(0,t.jsx)(Ya,{to:w,label:n.name,iconNode:(0,t.jsx)(pr,{agent:n,size:16,className:"shrink-0 h-4 w-4"}),active:j,liveCount:m,labelClassName:R?"min-w-(--sz-4_5rem) flex-initial":void 0,className:z("min-w-0 flex-1",f&&!i?"pr-14":"pr-8"),trailing:R||A?(0,t.jsxs)("span",{className:"ml-1 flex shrink-0 items-center gap-1",children:[R?(0,t.jsx)(wj,{status:p,compact:!0}):null,A?(0,t.jsx)(Rs,{className:"h-3.5 w-3.5 shrink-0 text-amber-500","aria-label":"Invalid reporting chain"}):null]}):void 0,trailingLabel:L,liveAccessory:n.pauseReason==="budget"?(0,t.jsx)(y1,{title:"Agent paused by budget"}):void 0});return d?O:(0,t.jsxs)("div",{className:"group/agent relative flex items-center",children:[O,f&&!i&&g?(0,t.jsx)("span",{className:"absolute right-10 top-1/2 -translate-y-1/2",children:(0,t.jsx)(l0,{size:"row",quiet:!0,starred:!0,pending:v,resourceName:n.name,onToggle:r(()=>g(n,!1),"onToggle"),revealClassName:mJe})}):null,(0,t.jsxs)(fa,{children:[(0,t.jsx)(pa,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:z("absolute right-3 top-1/2 h-6 w-6 -translate-y-1/2 transition-opacity data-[state=open]:pointer-events-auto data-[state=open]:opacity-100",i?"opacity-100":"pointer-events-none opacity-0 group-hover/agent:pointer-events-auto group-hover/agent:opacity-100 group-focus-within/agent:pointer-events-auto group-focus-within/agent:opacity-100"),"aria-label":`Open actions for ${n.name}`,children:(0,t.jsx)(Ei,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(xa,{align:"end",className:"w-48",children:[g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(ps,{onClick:r(()=>{v||g(n,!f)},"onClick"),disabled:v,children:[v?(0,t.jsx)(it,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Th,{className:z("size-4",f&&"fill-amber-500 text-amber-500")}),(0,t.jsx)("span",{children:f?"Remove from starred":"Star agent"})]}),(0,t.jsx)(ui,{})]}):null,(0,t.jsx)(ps,{asChild:!0,children:(0,t.jsxs)(Ge,{to:S,onClick:r(()=>{i&&h(!1)},"onClick"),children:[(0,t.jsx)(Kl,{className:"size-4"}),(0,t.jsx)("span",{children:"Edit agent"})]})}),(0,t.jsx)(ui,{}),(0,t.jsxs)(ps,{onClick:r(()=>{I||c(n,N?"resume":"pause")},"onClick"),disabled:I,title:_?"Agent was paused by budget limits":void 0,children:[N?(0,t.jsx)(f1,{className:"size-4"}):(0,t.jsx)(dd,{className:"size-4"}),(0,t.jsx)("span",{children:T})]}),(0,t.jsx)(ui,{}),(0,t.jsxs)(ps,{onClick:r(()=>{o||l(n)},"onClick"),disabled:o,children:[o?(0,t.jsx)(it,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Yh,{className:"size-4"}),(0,t.jsx)("span",{children:o?"Leaving...":"Leave agent"})]})]})]})]})}r(hJe,"SidebarAgentItem");function pJe({streamlined:e=!1}={}){const[s,n]=(0,u.useState)(!0),[a,i]=(0,u.useState)(()=>new Set),[o,l]=(0,u.useState)(0),c=(0,u.useRef)(new Map),d=Kt(),{selectedCompanyId:m}=xs(),{openNewAgent:h}=$o(),{isMobile:p,setSidebarOpen:f,collapsed:g,peeking:v}=Wa(),y=g&&!v,{pushToast:w}=da(),S=ea(),{data:j}=ee({queryKey:P.agents.list(m),queryFn:r(()=>zt.list(m),"queryFn"),enabled:!!m}),{data:N}=ee({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn"),enabled:!!m}),_=N?.enableBuiltInAgents===!0,{data:A}=ee({queryKey:P.builtInAgents.list(m),queryFn:r(()=>fh.list(m),"queryFn"),enabled:!!m&&_}),C=(0,u.useMemo)(()=>{const xe=new Map;if(!_)return xe;for(const Ae of A??[])Ae.agentId&&xe.set(Ae.agentId,Ae.status);return xe},[A,_]),{data:I}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn")}),T=xf(m),R=gf(m),L=P.liveRuns(m),O=mo({companyId:m,resourceKey:"live-runs",queryKey:L,enabled:!!m,refetchInterval:!1,leaderOnly:!0}),{data:$,dataUpdatedAt:E}=ee({queryKey:L,queryFn:r(()=>Zr.liveRunsForCompany(m),"queryFn"),enabled:O.enabled,refetchInterval:O.refetchInterval});ho(O,$,E);const q=(0,u.useMemo)(()=>{const xe=new Map;for(const Ae of $??[])xe.set(Ae.agentId,(xe.get(Ae.agentId)??0)+1);return xe},[$]),B=(0,u.useMemo)(()=>{const xe=new Set;for(const[Ae,Ye]of q)Ye>0&&xe.add(Ae);return xe},[q]),K=(0,u.useMemo)(()=>(j??[]).filter(xe=>xe.status!=="terminated"&&(!T.isSuccess||kx(T.data,"agent",xe.id)!=="left")),[j,T.data,T.isSuccess]),U=I?.user?.id??I?.session?.userId??null,D=(0,u.useMemo)(()=>m?iue(m,U):null,[U,m]),[V,H]=(0,u.useState)(()=>D?Nj(D):"top"),{orderedAgents:J}=cue({agents:K,companyId:m,userId:U}),X=(0,u.useMemo)(()=>AJ(J,V),[J,V]),le=(0,u.useMemo)(()=>new Set(X.map(xe=>xe.id)),[X]);(0,u.useEffect)(()=>{const xe=Date.now();for(const Ae of B)c.current.set(Ae,xe);for(const Ae of c.current.keys())le.has(Ae)||c.current.delete(Ae)},[B,le]);const ce=(0,u.useMemo)(()=>{const xe=Date.now(),Ae=c.current;return X.filter(Ye=>{if((q.get(Ye.id)??0)>0)return!0;const Oe=Ae.get(Ye.id);return Oe!==void 0&&xe-Oe<=IJ})},[q,o,X]),te=ce.length>0,re=e?te?ce:X.slice(0,dJe):X,de=e&&X.length>0,Z=S.pathname.match(/^\/(?:[^/]+\/)?agents\/([^/]+)(?:\/([^/]+))?/),Y=Z?.[1]??null,G=Z?.[2]??null;(0,u.useEffect)(()=>{if(!D){H("top");return}H(Nj(D))},[D]),(0,u.useEffect)(()=>{if(!D)return;const xe=r(Ye=>{Ye.key===D&&H(Nj(D))},"onStorage"),Ae=r(Ye=>{const Oe=Ye.detail;!Oe||Oe.storageKey!==D||H(Oe.sortMode)},"onCustomEvent");return window.addEventListener("storage",xe),window.addEventListener(HS,Ae),()=>{window.removeEventListener("storage",xe),window.removeEventListener(HS,Ae)}},[D]),(0,u.useEffect)(()=>{if(!e)return;const xe=Date.now();let Ae=null;for(const Oe of X){if((q.get(Oe.id)??0)>0)continue;const Xe=c.current.get(Oe.id);if(Xe===void 0)continue;const me=Xe+IJ;me<xe||(Ae=Ae===null?me:Math.min(Ae,me))}if(Ae===null)return;const Ye=window.setTimeout(()=>{l(Oe=>Oe+1)},Math.max(0,Ae-xe+1));return()=>{window.clearTimeout(Ye)}},[e,X,q,o]);const fe=(0,u.useCallback)(xe=>{const Ae=xe==="alphabetical"||xe==="recent"?xe:"top";H(Ae),D&&lue(D,Ae)},[D]),se=ke({mutationFn:r(({agent:xe,action:Ae})=>Ae==="pause"?zt.pause(xe.id,m??void 0):zt.resume(xe.id,m??void 0),"mutationFn"),onMutate:r(({agent:xe})=>{i(Ae=>{const Ye=new Set(Ae);return Ye.add(xe.id),Ye})},"onMutate"),onSuccess:r(async(xe,{agent:Ae,action:Ye})=>{m&&await Promise.all([d.invalidateQueries({queryKey:P.agents.list(m)}),d.invalidateQueries({queryKey:P.liveRuns(m)}),d.invalidateQueries({queryKey:P.dashboard(m)})]),await Promise.all([d.invalidateQueries({queryKey:P.agents.detail(Ae.id)}),d.invalidateQueries({queryKey:P.agents.detail(jc(Ae))})]),w({title:Ye==="pause"?"Agent paused":"Agent resumed",body:Ae.name,tone:"success"})},"onSuccess"),onError:r((xe,{agent:Ae,action:Ye})=>{w({title:Ye==="pause"?"Could not pause agent":"Could not resume agent",body:xe instanceof Error?xe.message:Ae.name,tone:"error"})},"onError"),onSettled:r((xe,Ae,{agent:Ye})=>{i(Oe=>{const Xe=new Set(Oe);return Xe.delete(Ye.id),Xe})},"onSettled")}),ae=(0,u.useCallback)(xe=>R.mutate({resourceType:"agent",resourceId:xe.id,resourceName:xe.name,state:"left"}),[R]),ie=(0,u.useCallback)(xe=>R.isPending&&R.variables?.resourceType==="agent"&&R.variables.resourceId===xe.id,[R.isPending,R.variables]),ue=(0,u.useCallback)((xe,Ae)=>R.mutate({resourceType:"agent",resourceId:xe.id,resourceName:xe.name,starred:Ae}),[R]),pe=(0,u.useCallback)(xe=>R.isPending&&R.variables?.resourceType==="agent"&&R.variables.resourceId===xe.id&&R.variables.starred!==void 0,[R.isPending,R.variables]),be=(0,u.useMemo)(()=>new Set(k5(T.data,"agent")),[T.data]),oe=(0,u.useMemo)(()=>AJ(K.filter(xe=>be.has(xe.id)),"alphabetical"),[K,be]),je=(0,u.useMemo)(()=>re.filter(xe=>!be.has(xe.id)),[re,be]),_e=r((xe,Ae)=>(0,t.jsx)(hJe,{activeAgentId:Y,activeTab:G,agent:xe,disabled:a.has(xe.id),isMobile:p,leaving:ie(xe),onLeaveAgent:ae,onPauseResume:r((Ye,Oe)=>se.mutate({agent:Ye,action:Oe}),"onPauseResume"),rail:y,runCount:q.get(xe.id)??0,setSidebarOpen:f,builtInStatus:C.get(xe.id),starred:Ae||o0(T.data,"agent",xe.id),onToggleStar:ue,starPending:pe(xe)},xe.id),"renderAgentRow");return(0,t.jsxs)(px,{label:"Agents",collapsible:{open:s,onOpenChange:n},headerAction:{ariaLabel:"New agent",icon:yn,onClick:h},menu:{ariaLabel:"Agents section actions",actions:[{type:"item",label:"Browse agents",icon:Xo,href:"/agents/all"},{type:"separator"}],radioLabel:"Agent sort",radioChoices:uJe,radioValue:V,onRadioValueChange:fe},children:[oe.map(xe=>_e(xe,!0)),je.map(xe=>_e(xe,!1)),de&&(()=>{const xe=(0,t.jsxs)(Ge,{to:"/agents/all",state:ff,"aria-label":y?"See all agents":void 0,onClick:r(()=>{p&&f(!1)},"onClick"),className:"flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(Xo,{className:"shrink-0 h-4 w-4"}),(0,t.jsx)("span",{className:y?"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none":void 0,children:"See all agents"})]});return y?(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:xe}),(0,t.jsx)(Un,{side:"right",children:"See all agents"})]}):xe})()]})}r(pJe,"SidebarAgents");var fJe="opacity-0 transition-opacity group-hover/starred-project:opacity-100 group-focus-within/starred-project:opacity-100";function xJe(){const{selectedCompanyId:e}=xs(),{isMobile:s,setSidebarOpen:n,collapsed:a,peeking:i}=Wa(),o=a&&!i,l=ea(),{data:c}=ee({queryKey:P.projects.list(e),queryFn:r(()=>ia.list(e),"queryFn"),enabled:!!e}),d=xf(e),m=gf(e),h=l.pathname.match(/^\/(?:[^/]+\/)?projects\/([^/]+)/)?.[1]??null,p=(0,u.useMemo)(()=>{if(!d.isSuccess)return[];const y=new Set(k5(d.data,"project"));if(y.size===0)return[];const w=new Map((c??[]).map(S=>[S.id,S]));return Array.from(y).map(S=>w.get(S)).filter(S=>!!S).sort((S,j)=>S.name.localeCompare(j.name,void 0,{sensitivity:"base"}))},[d.data,d.isSuccess,c]),f=(0,u.useCallback)(y=>m.mutate({resourceType:"project",resourceId:y.id,resourceName:y.name,starred:!1}),[m]),g=(0,u.useCallback)(y=>m.mutate({resourceType:"project",resourceId:y.id,resourceName:y.name,state:"left"}),[m]),v=(0,u.useCallback)(y=>m.isPending&&m.variables?.resourceType==="project"&&m.variables.resourceId===y.id,[m.isPending,m.variables]);return!d.isSuccess||p.length===0?null:(0,t.jsx)("div",{className:"flex flex-col gap-0.5","aria-label":"Starred projects",children:p.map(y=>{const w=n0(y),S=h===w||h===y.id,j=v(y),N=j&&m.variables?.starred===!1,_=j&&m.variables?.state==="left",A=o0(d.data,"project",y.id),C=(0,t.jsxs)(a0,{to:`/projects/${w}/issues`,state:ff,onClick:r(()=>{s&&n(!1)},"onClick"),className:z("flex min-w-0 flex-1 items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 pr-8 text-(length:--text-compact) font-medium transition-colors",!o&&"pl-6",S?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground"),children:[(0,t.jsx)(Hm,{color:y.color??null,icon:y.icon??null,size:"xs"}),(0,t.jsx)("span",{className:o?fv:"flex-1 truncate",children:y.name}),!o&&y.pauseReason==="budget"?(0,t.jsx)(y1,{title:"Project paused by budget"}):null]});return(0,t.jsxs)("div",{className:"group/starred-project relative flex items-center",children:[o?(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)("div",{className:"min-w-0 flex-1",children:C})}),(0,t.jsx)(Un,{side:"right",children:y.name})]}):C,!o&&!s?(0,t.jsx)("span",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:(0,t.jsx)(l0,{size:"row",quiet:!0,starred:A,pending:N,resourceName:y.name,onToggle:r(()=>f(y),"onToggle"),revealClassName:fJe})}):null,!o&&s?(0,t.jsxs)(fa,{children:[(0,t.jsx)(pa,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:"absolute right-3 top-1/2 h-6 w-6 -translate-y-1/2 opacity-100","aria-label":`Open actions for ${y.name}`,children:(0,t.jsx)(Ei,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(xa,{align:"end",className:"w-48",children:[(0,t.jsxs)(ps,{onClick:r(()=>{j||f(y)},"onClick"),disabled:j,children:[N?(0,t.jsx)(it,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Th,{className:"size-4 fill-amber-500 text-amber-500"}),(0,t.jsx)("span",{children:"Remove from starred"})]}),(0,t.jsx)(ui,{}),(0,t.jsxs)(ps,{onClick:r(()=>{j||g(y)},"onClick"),disabled:j,children:[_?(0,t.jsx)(it,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Yh,{className:"size-4"}),(0,t.jsx)("span",{children:"Leave project"})]})]})]}):null]},y.id)})})}r(xJe,"SidebarStarredProjects");var ege="size-5 shrink-0 rounded-md text-(length:--text-micro)",tge="size-(--organization-popover-avatar-size) shrink-0 rounded-lg text-(length:--text-micro)",sge="h-(--organization-popover-company-row-height) min-w-0 gap-(--organization-popover-row-gap) rounded-lg px-2.5 py-0 text-(length:--text-compact) focus:bg-accent/50 focus:text-foreground",z4="h-(--organization-popover-action-row-height) gap-(--organization-popover-row-gap) rounded-lg px-2.5 py-0 text-(length:--text-compact) font-medium leading-(--organization-popover-action-line-height) text-foreground focus:bg-accent/50 focus:text-foreground";function nge({company:e,inPopover:s=!1}){return(0,t.jsx)(Dx,{companyName:e.name,logoUrl:e.logoUrl,className:s?tge:ege})}r(nge,"WorkspaceIcon");function gJe({displayName:e}){return(0,t.jsx)(Dx,{companyName:e,className:tge})}r(gJe,"StackIcon");function bJe({displayName:e,company:s}){return(0,t.jsx)(Dx,{companyName:e,logoUrl:s?.logoUrl,className:ege})}r(bJe,"CurrentStackIcon");function vJe({stack:e,isSelected:s,onSelect:n}){return(0,t.jsxs)(ps,{onSelect:r(()=>n(e),"onSelect"),className:sge,children:[(0,t.jsx)(gJe,{displayName:e.displayName}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate font-medium leading-(--organization-popover-name-line-height)",title:e.displayName,children:e.displayName}),(0,t.jsx)("span",{className:"block truncate text-(length:--text-nano) leading-(--organization-popover-prefix-line-height) text-muted-foreground",title:e.stackSlug,children:e.stackSlug})]}),(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center",children:s?(0,t.jsx)(fs,{className:"size-4 text-foreground"}):null})]})}r(vJe,"CloudStackItem");function yJe({company:e,isEditing:s,isSelected:n,onSelect:a}){const{attributes:i,listeners:o,setActivatorNodeRef:l,setNodeRef:c,transform:d,transition:m,isDragging:h}=Fw({id:e.id,disabled:!s});return(0,t.jsxs)(ps,{ref:c,style:{transform:Lw.Transform.toString(d),transition:m,zIndex:h?10:void 0},onSelect:r(p=>{if(s){p.preventDefault();return}a(e)},"onSelect"),className:z(sge,s&&"cursor-grab",h&&"opacity-80"),children:[(0,t.jsx)(nge,{company:e,inPopover:!0}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate font-medium leading-(--organization-popover-name-line-height)",children:e.name}),s?null:(0,t.jsx)("span",{className:"block truncate text-(length:--text-nano) leading-(--organization-popover-prefix-line-height) text-muted-foreground",children:e.issuePrefix})]}),s?(0,t.jsx)("button",{type:"button",ref:l,"aria-label":`Reorder ${e.name}`,className:"inline-flex size-8 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-(length:--rad-2) focus-visible:ring-ring",onClick:r(p=>{p.preventDefault(),p.stopPropagation()},"onClick"),...i,...o,children:(0,t.jsx)(jz,{className:"size-4","aria-hidden":"true"})}):(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center",children:n?(0,t.jsx)(fs,{className:"size-4 text-foreground"}):null})]})}r(yJe,"SortableCompanyItem");function jJe(e={}){return(0,t.jsx)(cme,{...e,children:(0,t.jsx)(wJe,{...e})})}r(jJe,"SidebarCompanyMenu");function wJe({open:e,onOpenChange:s}){const[n,a]=(0,u.useState)(!1),[i,o]=(0,u.useState)(!1),{companies:l,selectedCompany:c,setSelectedCompanyId:d,companyListUnavailable:m,retryCompanies:h}=xs(),{openOnboarding:p}=$o(),{isMobile:f,setSidebarOpen:g,collapsed:v,peeking:y}=Wa(),w=v&&!y,S=ea(),j=Hn(),N=e??n,_=s??a,A=Ow(nf(az,{activationConstraint:{distance:8}}),nf(sce,{activationConstraint:{delay:180,tolerance:6}})),C=(0,u.useMemo)(()=>l.filter(G=>G.status!=="archived"),[l]),{data:I}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),T=I?.user?.id??I?.session?.userId??null,{orderedCompanies:R,persistOrder:L}=ome({companies:C,userId:T}),O=Qc(),$=!!O,{hidden:E,loaded:q}=Zm(),B=q&&!BS(E,"company.members")&&!BS(E,"company.invites"),K=O?.cloudBaseUrl??null,U=ee({queryKey:P.cloud.stacks,queryFn:r(()=>ame.listStacks(),"queryFn"),enabled:$,staleTime:3e4,retry:!1}),D=U.data?.stacks??[],V=$?D.find(G=>G.isCurrent)??D.find(G=>!!O?.stackSlug&&G.stackSlug===O?.stackSlug)??null:null,H=$?R5(K):null,J=$?"organization":"company",X=$?V?.displayName??O?.stackDisplayName??O?.stackSlug??null:c?.name??null,le=Yw({onSignedOut:te});function ce(G){G||o(!1),_(G)}r(ce,"handleOpenChange");function te(){_(!1),o(!1),f&&g(!1)}r(te,"closeNavigationChrome");function re(G){const fe=S.pathname.split("/")[1]?.toUpperCase(),se=C.some(ie=>ie.issuePrefix.toUpperCase()===fe),ae=G.id!==c?.id&&(S.pathname.startsWith("/instance/")||se);d(G.id),_(!1),f&&g(!1),ae&&j(`/${G.issuePrefix}/dashboard`)}r(re,"selectCompany");function de(G){if(_(!1),f&&g(!1),G.stackSlug===V?.stackSlug)return;const fe=lme(K,G.stackSlug);fe&&Nc(fe)}r(de,"selectStack");function Z(){if(_(!1),f&&g(!1),$){H&&Nc(H);return}p({initialStep:1})}r(Z,"addCompany");const Y=(0,u.useCallback)(G=>{const{active:fe,over:se}=G;if(!se||fe.id===se.id)return;const ae=R.map(pe=>pe.id),ie=ae.indexOf(fe.id),ue=ae.indexOf(se.id);ie===-1||ue===-1||L(n5(ae,ie,ue))},[R,L]);return(0,t.jsxs)(fa,{open:N,onOpenChange:ce,children:[(0,t.jsx)(pa,{asChild:!0,children:(0,t.jsxs)(F,{variant:"ghost",className:"h-9 min-w-0 flex-1 justify-start gap-2 px-4 text-left hover:bg-accent/50 hover:text-foreground has-[>svg]:px-4 dark:hover:bg-accent/50","aria-label":X?`Open ${X} ${J} switcher`:`Open ${J} switcher`,children:[(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[$?X?(0,t.jsx)(bJe,{displayName:X,company:c}):null:c?(0,t.jsx)(nge,{company:c}):null,(0,t.jsx)("span",{className:z("min-w-0 truncate text-sm font-bold text-foreground",w&&"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none"),title:X??void 0,children:X??($?"Select organization":"Select company")})]}),!w&&(0,t.jsx)(u5,{className:"size-3.5 shrink-0 text-muted-foreground"})]})}),(0,t.jsxs)(xa,{align:"start",sideOffset:8,className:"ml-2 w-(--organization-popover-width) max-w-(--sz-calc-24) overflow-hidden rounded-xl border-border bg-popover p-0 shadow-(--shadow-profile-popover)",children:[(0,t.jsxs)("div",{className:"flex h-(--organization-popover-header-height) items-center justify-between gap-2 px-3.5",children:[(0,t.jsx)(qw,{className:"p-0 text-(length:--text-compact) font-semibold text-foreground",children:"Organizations"}),$?null:(0,t.jsx)("button",{type:"button",onClick:r(G=>{G.preventDefault(),G.stopPropagation(),o(fe=>!fe)},"onClick"),className:"rounded px-1.5 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:i?"Done":"Edit"})]}),(0,t.jsx)("div",{className:"flex max-h-96 flex-col gap-0.5 overflow-y-auto px-2.5 pb-2 pt-1",children:$?(0,t.jsxs)(t.Fragment,{children:[D.map(G=>(0,t.jsx)(vJe,{stack:G,isSelected:G.stackSlug===V?.stackSlug,onSelect:de},G.stackSlug)),D.length===0?(0,t.jsx)(ps,{disabled:!0,children:U.isLoading?"Loading organizations...":U.isError?"Could not load organizations":"No organizations"}):null]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Dw,{sensors:A,collisionDetection:ZC,onDragEnd:Y,children:(0,t.jsx)(Mw,{items:R.map(G=>G.id),strategy:JC,children:R.map(G=>(0,t.jsx)(yJe,{company:G,isEditing:i,isSelected:G.id===c?.id,onSelect:re},G.id))})}),R.length===0?m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ps,{disabled:!0,children:"Couldn't load companies"}),(0,t.jsxs)(ps,{onSelect:r(G=>{G.preventDefault(),h()},"onSelect"),children:[(0,t.jsx)(Ki,{className:"h-4 w-4 mr-2"}),"Try again"]})]}):(0,t.jsx)(ps,{disabled:!0,children:"No companies"}):null]})}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5 border-t border-border px-2.5 pb-2.5 pt-2",children:[$&&!H?null:(0,t.jsxs)(ps,{onClick:Z,className:z4,disabled:i,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(yn,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:"Create organization"})]}),B?(0,t.jsx)(ps,{asChild:!0,disabled:i,className:z4,children:(0,t.jsxs)(Ge,{to:"/company/settings/invites",onClick:r(G=>{if(i){G.preventDefault();return}te()},"onClick"),children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(wv,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:X?`Invite people to ${X}`:"Invite people"})]})}):null,I?.session?(0,t.jsxs)(ps,{className:z4,onClick:r(()=>le.mutate(),"onClick"),disabled:i||le.isPending,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(Yh,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:le.isPending?"Signing out...":"Sign out"})]}):null]})]})]})}r(wJe,"BuiltinCompanyMenu");function RJ(){const{openNewIssue:e}=$o(),[s,n]=(0,u.useState)(!0),[a,i]=(0,u.useState)(!0),{selectedCompanyId:o,selectedCompany:l}=xs(),{collapsed:c,peeking:d}=Wa(),m=c&&!d,h=Zz(o),{data:p,isFetched:f}=ee({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn")}),g=P.liveRuns(o),v=mo({companyId:o,resourceKey:"live-runs",queryKey:g,enabled:!!o,refetchInterval:!1,leaderOnly:!0}),{data:y,dataUpdatedAt:w}=ee({queryKey:g,queryFn:r(()=>Zr.liveRunsForCompany(o),"queryFn"),enabled:v.enabled,refetchInterval:v.refetchInterval});ho(v,y,w);const S=y?.length??0,j=p?.enableIsolatedWorkspaces===!0,N=p?.enableApps===!0,_=p?.enablePipelines===!0,A=p?.enableStatusCards===!0,C=!f,I=p?.enableGoalsSidebarLink===!0,T=p?.enableDecisions===!0,{data:R}=ee({queryKey:P.attention(o),queryFn:r(()=>I5.list(o),"queryFn"),enabled:!!o&&T,refetchInterval:6e4}),L=Lue(R),O=p?.enableCases===!0,$=!0,E=p?.enableConferenceRoomChat===!0,q={companyId:o,companyPrefix:l?.issuePrefix??null};return(0,t.jsxs)("aside",{className:"w-full h-full min-h-0 border-r border-border bg-background flex flex-col",children:[(0,t.jsx)("div",{className:"flex items-center gap-1 px-3 h-12 shrink-0",children:(0,t.jsx)(jJe,{})}),(0,t.jsxs)("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide flex flex-col gap-4 pointer-coarse:gap-3 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(()=>{const B=(0,t.jsxs)("button",{onClick:r(()=>e(),"onClick"),"data-slot":"icon-button","aria-label":m?"New Task":void 0,className:"flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium text-foreground/80 hover:bg-accent/50 hover:text-foreground transition-colors",children:[(0,t.jsx)(g1,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:m?fv:"truncate",children:"New Task"})]});return m?(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:B}),(0,t.jsx)(Un,{side:"right",children:"New Task"})]}):B})(),(0,t.jsx)(Ya,{to:"/search",label:"Search",icon:ha}),(0,t.jsx)(Ya,{to:"/dashboard",label:"Dashboard",icon:hx,liveCount:S}),(0,t.jsx)(Ya,{to:"/inbox",label:"Inbox",icon:Ed,badge:h.inbox,badgeLabel:"unread",badgeTone:h.failedRuns>0?"danger":"default",alert:h.failedRuns>0}),T?(0,t.jsx)(Ya,{to:"/decisions",label:"Decisions",icon:x1,badge:L,badgeLabel:"decisions"}):null,A?(0,t.jsx)(Ya,{to:"/status",label:"Status",icon:Hw,textBadge:"beta"}):null,E?(0,t.jsx)(Ya,{to:"/board-chat",label:"Conference Room",icon:Sde}):null]}),(0,t.jsxs)(px,{label:"Work",collapsible:{open:s,onOpenChange:n},children:[(0,t.jsx)(Ya,{to:"/issues",label:"Tasks",icon:od}),O?(0,t.jsx)(Ya,{to:"/cases",label:"Cases",icon:hl,textBadge:"beta"}):null,(0,t.jsx)(Ya,{to:"/routines",label:"Routines",icon:fu}),_?(0,t.jsx)(Ya,{to:"/pipelines",label:"Pipelines",icon:sl}):null,I?(0,t.jsx)(Ya,{to:"/goals",label:"Goals",icon:vx}):C?(0,t.jsx)("div",{"data-testid":"sidebar-goals-placeholder",className:"h-8 pointer-coarse:h-7","aria-hidden":"true"}):null,(0,t.jsx)(Ya,{to:"/artifacts",label:"Artifacts",icon:Eh}),(0,t.jsx)(Ya,{to:"/skills",label:"Skills",icon:Ul}),j?(0,t.jsx)(Ya,{to:"/workspaces",label:"Workspaces",icon:sl}):null,(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Ya,{to:"/projects",label:"Projects",icon:Io}),(0,t.jsx)(xJe,{})]}),(0,t.jsx)(zh,{slotTypes:["sidebar"],context:q,className:"flex flex-col gap-0.5",itemClassName:"text-(length:--text-compact) font-medium",missingBehavior:"placeholder"}),(0,t.jsx)(Gw,{placementZones:["sidebar"],context:q,className:"flex flex-col gap-0.5",itemClassName:"text-(length:--text-compact) font-medium"})]}),null,(0,t.jsx)(pJe,{streamlined:$}),(0,t.jsxs)(px,{label:"Company",collapsible:{open:a,onOpenChange:i},children:[(0,t.jsx)(Ya,{to:"/org",label:"Org",icon:qb}),N?(0,t.jsx)(Ya,{to:"/apps",label:"Connectors",icon:KR}):null,(0,t.jsx)(Ya,{to:"/timeline",label:"Timeline",icon:yg}),(0,t.jsx)(Ya,{to:"/costs",label:"Costs",icon:_h}),(0,t.jsx)(Ya,{to:"/activity",label:"Activity",icon:Sl}),(0,t.jsx)(Ya,{to:"/company/settings",label:"Settings",icon:Ld})]}),(0,t.jsx)(zh,{slotTypes:["sidebarPanel"],context:q,className:"flex flex-col gap-3",itemClassName:"rounded-lg border border-border p-3",missingBehavior:"placeholder"})]})]})}r(RJ,"Sidebar");function NJe(e){const s=e.manifestJson.environmentDrivers??[];return s.length===0?!1:s.every(n=>n.kind==="sandbox_provider")}r(NJe,"isSandboxProviderOnly");function kJe(){const{selectedCompany:e,selectedCompanyId:s}=xs(),{isMobile:n,setSidebarOpen:a}=Wa(),{hidden:i}=Zm(),o=r(f=>!i.has(f),"showPage"),l=o("instance.plugins"),c=!!Qc(),{slots:d}=Hc({slotTypes:["companySettingsPage"],companyId:s,enabled:!!s}),{data:m}=ee({queryKey:s?P.sidebarBadges(s):["sidebar-badges","__disabled__"],queryFn:r(async()=>{try{return await pme.get(s)}catch(f){if(f instanceof vn&&(f.status===401||f.status===403))return null;throw f}},"queryFn"),enabled:!!s,retry:!1,refetchInterval:15e3}),{data:h}=ee({queryKey:P.plugins.all,queryFn:r(()=>Jo.list(),"queryFn"),enabled:l}),p=(h??[]).filter(f=>!NJe(f));return(0,t.jsxs)("aside",{className:"w-full h-full min-h-0 border-r border-border bg-background flex flex-col",children:[(0,t.jsx)("div",{className:"flex flex-col gap-1 px-3 py-3 shrink-0",children:(0,t.jsxs)(Ge,{to:"/dashboard",onClick:r(()=>{n&&a(!1)},"onClick"),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(bu,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e?.name??"Company"})]})}),(0,t.jsx)("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide px-3 py-2",children:(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)(Ya,{to:"/company/settings",label:"General",icon:sm,end:!0}),o("instance.profile")&&(0,t.jsx)(Ya,{to:"/company/settings/instance/profile",label:"Profile",icon:b1,end:!0}),o("company.members")&&(0,t.jsx)(Ya,{to:"/company/settings/members",label:"Members",icon:Xo,badge:m?.joinRequests??0,end:!0}),d.filter(f=>f.routePath).map(f=>(0,t.jsx)(Ya,{to:`/company/settings/${f.routePath}`,label:f.displayName,icon:Pg,end:!0},`${f.pluginKey}:${f.id}`)),o("company.invites")&&(0,t.jsx)(Ya,{to:"/company/settings/invites",label:"Invites",icon:C5e,end:!0}),o("company.secrets")&&(0,t.jsx)(Ya,{to:"/company/settings/secrets",label:"Secrets",icon:yi,end:!0}),o("instance.environments")&&(0,t.jsx)(Ya,{to:"/company/settings/instance/environments",label:"Environments",icon:Cde,end:!0}),o("instance.access")&&(0,t.jsx)(Ya,{to:"/company/settings/instance/access",label:"Access",icon:l5,end:!0}),o("instance.heartbeats")&&(0,t.jsx)(Ya,{to:"/company/settings/instance/heartbeats",label:"Heartbeats",icon:th,end:!0}),o("company.export")&&(0,t.jsx)(Ya,{to:"/company/export",label:"Export",icon:zo}),!c&&o("company.import")&&(0,t.jsx)(Ya,{to:"/company/import",label:"Import",icon:Zj,end:!0}),o("instance.experimental")&&(0,t.jsx)(Ya,{to:"/company/settings/instance/experimental",label:"Experimental",icon:Zu}),l&&(0,t.jsx)(Ya,{to:"/company/settings/instance/plugins",label:"Plugins",icon:Pg}),l&&p.length>0?(0,t.jsx)("div",{className:"ml-4 mt-1 flex flex-col gap-0.5 border-l border-border/70 pl-3",children:p.map(f=>(0,t.jsx)(a0,{to:`${xh}/plugins/${f.id}`,state:ff,className:r(({isActive:g})=>["rounded-md px-2 py-1.5 text-xs transition-colors",g?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"].join(" "),"className"),children:f.manifestJson.displayName??f.packageName},f.id))}):null,o("instance.adapters")&&(0,t.jsx)(Ya,{to:"/company/settings/instance/adapters",label:"Adapters",icon:Lm})]})})]})}r(kJe,"CompanySettingsSidebar");function SJe(){const{pathname:e}=ea(),{selectedCompany:s}=xs(),{isMobile:n,setSidebarOpen:a}=Wa(),i=wme(),{enabled:o}=T5(),l=rU.filter(d=>!jme(d.key)||o);if(e.endsWith("/apps/chat/connect"))return(0,t.jsx)(Mz,{});const c=e.match(/\/apps\/chat\/([^/]+)(?:\/(?:settings|access|reviews|conversations|activity))?\/?$/);return c?(0,t.jsx)(yme,{endpointId:c[1],NavItem:Ya}):(0,t.jsxs)("aside",{className:"w-full h-full min-h-0 border-r border-border bg-background flex flex-col",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 px-3 py-3 shrink-0",children:[(0,t.jsxs)(Ge,{to:"/dashboard",onClick:r(()=>{n&&a(!1)},"onClick"),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(bu,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:s?.name??"Company"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1",children:[(0,t.jsx)(uH,{className:"h-4 w-4 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"flex-1 truncate text-sm font-bold text-foreground",children:"Connectors"})]})]}),(0,t.jsxs)("nav",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-auto-hide px-3 py-2",children:[(0,t.jsx)("div",{className:"px-3 pb-1 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Connectors"}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)(Ya,{to:"/apps",label:"Browse",icon:VS,end:!0}),(0,t.jsx)(Ya,{to:"/apps/review",label:"Review",icon:Qw,badge:i>0?i:void 0,badgeTone:"warning",badgeLabel:"waiting for your OK"})]}),(0,t.jsx)("div",{className:"px-3 pb-1 pt-4 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Developer"}),(0,t.jsx)("p",{className:"px-3 pb-1.5 text-(length:--text-micro) leading-snug text-muted-foreground/70",children:"Advanced setup for developers. Most teams never open this."}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)(Ya,{to:"/apps/connections",label:"Connections",icon:uH,end:!0}),l.map(d=>(0,t.jsx)(Ya,{to:Dg(d.key),label:d.label,icon:d.icon,end:!0},d.key))]})]})]})}r(SJe,"AppsSidebar");function TJ(e){const{selectedCompanyId:s}=xs(),{isMobile:n,setSidebarOpen:a}=Wa(),i=ee({queryKey:P.tools.connection(e.kind==="connection"?e.connectionId:"__none__"),queryFn:r(()=>ms.getConnection(e.kind==="connection"?e.connectionId:""),"queryFn"),enabled:e.kind==="connection"&&!!e.connectionId}),o=ee({queryKey:P.tools.applications(s??"__none__"),queryFn:r(()=>ms.listApplications(s),"queryFn"),enabled:e.kind==="application"&&!!s}),l=ee({queryKey:P.tools.connections(s??"__none__"),queryFn:r(()=>ms.listConnections(s),"queryFn"),enabled:e.kind==="application"&&!!s}),c=ee({queryKey:P.apps.gallery(s??"__none__"),queryFn:r(()=>ms.listGallery(s),"queryFn"),enabled:!!s}),d=ee({queryKey:P.apps.attention(s??"__none__"),queryFn:r(()=>ms.listAppsAttention(s),"queryFn"),enabled:!!s,refetchInterval:3e4}),m=i.data,h=e.kind==="application"?(o.data?.applications??[]).find(S=>S.id===e.applicationId):null,p=IJe(e.kind==="application"?(l.data?.connections??[]).filter(S=>S.applicationId===e.applicationId):[]),f=m?of(m):h?.name??"App",g=_Je(c.data?.apps??[],m,h??void 0),v=m?.id??p?.id??null,y=v?d.data?.apps.find(S=>S.connection.id===v):null,w=(y?.pendingActionRequestCount??0)+((y?.quarantinedCatalogEntryCount??0)>0?1:0);return(0,t.jsxs)("aside",{className:"flex h-full min-h-0 w-full flex-col border-r border-border bg-background",children:[(0,t.jsxs)("div",{className:"flex shrink-0 flex-col gap-3 px-3 py-3",children:[(0,t.jsxs)(Ge,{to:"/apps/connections",onClick:r(()=>{n&&a(!1)},"onClick"),className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[(0,t.jsx)(bu,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:"All apps"})]}),(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2 px-2 py-1",children:[(0,t.jsx)(yc,{name:f,logoUrl:k1(g),size:28}),(0,t.jsx)("span",{className:"flex-1 truncate text-sm font-bold text-foreground",children:f})]})]}),(0,t.jsx)("nav",{className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto px-3 py-2",children:(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:E5.map(S=>(0,t.jsx)(Ya,{to:CJe(e,S.key),label:S.label,icon:S.icon,end:!0,badge:S.key==="review"&&w>0?w:void 0,badgeTone:"danger",badgeLabel:"needing review"},S.key))})})]})}r(TJ,"AppDetailSidebar");function CJe(e,s){return e.kind==="connection"?Ku(e.connectionId,s):cS(e.applicationId,s)}r(CJe,"tabHref");function _Je(e,s,n){if(n?.applicationKey){const i=e.find(o=>Bc(o)===n.applicationKey);if(i)return i}const a=(s?.name??n?.name)?.toLowerCase();return a?e.find(i=>Yg(i).toLowerCase()===a)??e.find(i=>Bc(i)===a)??null:null}r(_Je,"galleryEntryFor$1");function IJe(e){const s=e.filter(n=>n.status==="archived");return s.length===0?null:s.reduce((n,a)=>{const i=new Date(n.updatedAt??n.createdAt??0).getTime();return new Date(a.updatedAt??a.createdAt??0).getTime()>i?a:n})}r(IJe,"latestArchivedConnection$1");function U4({identifier:e}){return e?(0,t.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e}):null}r(U4,"CrumbIdentifier");function AJe({context:e}){const{slots:s}=Hc({slotTypes:["globalToolbarButton"],companyId:e.companyId}),{launchers:n}=eU({placementZones:["globalToolbarButton"],companyId:e.companyId,enabled:!!e.companyId});return(0,t.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1 pl-2 empty:hidden",children:[s.length>0?(0,t.jsx)(zh,{slotTypes:["globalToolbarButton"],context:e,className:"flex items-center gap-1"}):null,n.length>0?(0,t.jsx)(Gw,{placementZones:["globalToolbarButton"],context:e,className:"flex items-center gap-1"}):null]})}r(AJe,"GlobalToolbar");function RJe(){const{breadcrumbs:e,mobileToolbar:s}=Ln(),{toggleSidebar:n,isMobile:a}=Wa(),{selectedCompanyId:i,selectedCompany:o}=xs(),l=(0,u.useMemo)(()=>({companyId:i??null,companyPrefix:o?.issuePrefix??null}),[i,o?.issuePrefix]),c=(0,t.jsx)(AJe,{context:l});if(a&&s)return(0,t.jsx)("div",{className:"border-b border-border px-2 h-12 shrink-0 flex items-center",children:s});if(e.length===0)return(0,t.jsx)("div",{className:"border-b border-border px-4 md:px-6 h-12 shrink-0 flex items-center justify-end",children:c});const d=a&&(0,t.jsx)(F,{variant:"ghost",size:"icon-sm",className:"mr-2 shrink-0",onClick:n,"aria-label":"Open sidebar",children:(0,t.jsx)(Nde,{className:"h-5 w-5"})});return e.length===1?(0,t.jsxs)("div",{className:"border-b border-border px-4 md:px-6 h-12 shrink-0 flex items-center",children:[d,(0,t.jsx)("div",{className:"min-w-0 overflow-hidden flex-1",children:e[0].leading||e[0].identifier?(0,t.jsxs)("h1",{className:"flex items-center gap-1.5 text-sm font-semibold uppercase tracking-wider",children:[e[0].leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:e[0].leading}),(0,t.jsx)(U4,{identifier:e[0].identifier}),(0,t.jsx)("span",{className:"truncate",children:e[0].label})]}):(0,t.jsx)("h1",{className:"text-sm font-semibold uppercase tracking-wider truncate",children:e[0].label})}),c]}):(0,t.jsxs)("div",{className:"border-b border-border px-4 md:px-6 h-12 shrink-0 flex items-center",children:[d,(0,t.jsx)("div",{className:"min-w-0 overflow-hidden flex-1",children:(0,t.jsx)(aU,{className:"min-w-0 overflow-hidden",children:(0,t.jsx)(iU,{className:"flex-nowrap",children:e.map((m,h)=>{const p=h===e.length-1;return(0,t.jsxs)(u.Fragment,{children:[h>0&&(0,t.jsx)(tT,{}),(0,t.jsx)(dS,{className:p?"min-w-0":"shrink-0",children:p||!m.href?m.leading||m.identifier?(0,t.jsxs)(XS,{className:"flex min-w-0 items-center gap-1.5",children:[m.leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:m.leading}),(0,t.jsx)(U4,{identifier:m.identifier}),(0,t.jsx)("span",{className:"truncate",children:m.label})]}):(0,t.jsx)(XS,{className:"truncate",children:m.label}):(0,t.jsx)(eT,{asChild:!0,children:m.leading||m.identifier?(0,t.jsxs)(Ge,{to:m.href,onClick:m.onClick,className:"flex items-center gap-1.5",children:[m.leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:m.leading}),(0,t.jsx)(U4,{identifier:m.identifier}),(0,t.jsx)("span",{className:"truncate",children:m.label})]}):(0,t.jsx)(Ge,{to:m.href,onClick:m.onClick,children:m.label})})})]},h)})})})}),c]})}r(RJe,"BreadcrumbBar");var bI=240,UF=208,KF=420,EJ=16;function DT(e){return Math.min(KF,Math.max(UF,e))}r(DT,"clampSidebarWidth");function PJ(e){if(typeof window>"u")return bI;try{const s=window.localStorage.getItem(e);if(!s)return bI;const n=Number.parseInt(s,10);return Number.isFinite(n)?DT(n):bI}catch{return bI}}r(PJ,"readStoredSidebarWidth");function MJ(e,s){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(DT(s)))}catch{}}r(MJ,"writeStoredSidebarWidth");function TJe({children:e,open:s,collapsed:n=!1,peeking:a=!1,resizable:i=!1,storageKey:o="paperclip.sidebar.width",className:l,onPanelMouseEnter:c,onPanelMouseLeave:d,onPanelFocusCapture:m,onPanelBlurCapture:h}){const[p,f]=(0,u.useState)(()=>PJ(o)),[g,v]=(0,u.useState)(!1),y=(0,u.useRef)(p),w=(0,u.useRef)(null);(0,u.useEffect)(()=>{const E=PJ(o);y.current=E,f(E)},[o]);const S=s?p:0,j=s?n?64:S:0,N=s?n&&!a?64:S:0,_=N>j,A=i&&s&&!n,C=(0,u.useMemo)(()=>({width:`${j}px`}),[j]),I=(0,u.useMemo)(()=>({width:`${N}px`}),[N]),T=(0,u.useCallback)(E=>{const q=DT(E);y.current=q,f(q),MJ(o,q)},[o]),R=(0,u.useCallback)(E=>{A&&(E.preventDefault(),E.currentTarget.setPointerCapture(E.pointerId),w.current={startX:E.clientX,startWidth:y.current},v(!0))},[A]),L=(0,u.useCallback)(E=>{if(!w.current)return;const q=DT(w.current.startWidth+E.clientX-w.current.startX);y.current=q,f(q)},[]),O=(0,u.useCallback)(()=>{w.current&&(w.current=null,v(!1),MJ(o,y.current))},[o]),$=(0,u.useCallback)(E=>{A&&(E.key==="ArrowLeft"?(E.preventDefault(),T(p-EJ)):E.key==="ArrowRight"?(E.preventDefault(),T(p+EJ)):E.key==="Home"?(E.preventDefault(),T(UF)):E.key==="End"&&(E.preventDefault(),T(KF)))},[A,T,p]);return(0,t.jsx)("div",{className:z("relative h-full shrink-0",l),style:C,children:(0,t.jsxs)("div",{className:z("absolute inset-y-0 left-0 flex flex-col overflow-hidden",_?"z-30 border-r border-border bg-background shadow-lg":"z-0"),style:I,"data-sidebar-overlay":_?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:m,onBlurCapture:h,children:[e,A?(0,t.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":UF,"aria-valuemax":KF,"aria-valuenow":p,tabIndex:0,className:z("absolute inset-y-0 right-0 z-20 w-3 cursor-col-resize touch-none outline-none","before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:bg-transparent before:transition-colors","hover:before:bg-border focus-visible:before:bg-ring",g&&"before:bg-ring"),onPointerDown:R,onPointerMove:L,onPointerUp:O,onPointerCancel:O,onLostPointerCapture:O,onKeyDown:$}):null]})})}r(TJe,"SidebarShell");function EJe({children:e,className:s}){return(0,t.jsx)("div",{"data-secondary-sidebar":"",className:z("h-full w-60 shrink-0 overflow-y-auto border-r border-border bg-background",s),children:(0,t.jsx)(lJe,{children:e})})}r(EJe,"SecondarySidebar");var PJe="/company/settings/instance/profile",MJe="https://docs.paperclip.ing/",DJe="https://paperclip.ing/feedback";function LJe(e){const s=e.trim().split(/\s+/).filter(Boolean);return s.length>=2?`${s[0]?.[0]??""}${s[s.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}r(LJe,"deriveInitials$1");function $Je(e,s,n){const a=[e,s?.split("@")[0],s,n];for(const i of a){const o=i?.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(o)return o}return"me"}r($Je,"deriveUserSlug");function K4({label:e,description:s,icon:n,onClick:a,href:i,external:o=!1}){const l="flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-accent/60",c=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(n,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:e}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:s})]})]});return i?o?(0,t.jsx)("a",{href:i,target:"_blank",rel:"noreferrer",className:l,onClick:a,children:c}):(0,t.jsx)(Ge,{to:i,className:l,onClick:a,children:c}):(0,t.jsx)("button",{type:"button",className:l,onClick:a,children:c})}r(K4,"MenuAction");function DJ({deploymentMode:e,open:s,onOpenChange:n}){const a=!!Qc(),[i,o]=(0,u.useState)(!1),{isMobile:l,setSidebarOpen:c,collapsed:d,peeking:m}=Wa(),h=d&&!m,p=s??i,f=n??o,{data:g}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),v=Yw({onSignedOut:N}),y=g?.user.name?.trim()||"Board",w=g?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),S=LJe(y),j=`/u/${$Je(g?.user.name,g?.user.email,g?.user.id)}`;function N(){f(!1),l&&c(!1)}r(N,"closeNavigationChrome");function _(){v.mutate()}return r(_,"handleSignOut"),(0,t.jsx)("div",{className:"border-t border-r border-border bg-background px-3 py-2",children:(0,t.jsxs)("div",{className:z("flex items-center gap-0.5",!h&&"px-2"),children:[(0,t.jsxs)(nr,{open:p,onOpenChange:f,children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:z("flex min-w-0 items-center gap-2.5 rounded-lg text-left text-(length:--text-compact) font-medium text-foreground/80 transition-colors hover:bg-accent/50 hover:text-foreground",h?"w-full px-3 py-2":"flex-1 px-2 py-1.5"),"aria-label":"Open account menu",children:[(0,t.jsxs)(Yi,{size:"sm",children:[g?.user.image?(0,t.jsx)(Vc,{src:g.user.image,alt:y}):null,(0,t.jsx)(Ji,{children:S})]}),(0,t.jsx)("span",{className:z("min-w-0 flex-1 truncate",h&&"block w-0 min-w-0 overflow-hidden whitespace-nowrap text-transparent select-none"),children:y})]})}),(0,t.jsxs)(Wn,{side:"top",align:"start",sideOffset:10,className:"w-(--sz-277px) max-w-(--sz-calc-24) overflow-hidden rounded-t-2xl rounded-b-none border-border p-0 shadow-2xl",children:[(0,t.jsx)("div",{className:"h-24 bg-(image:--gradient-extract-25)"}),(0,t.jsxs)("div",{className:"-mt-8 px-4 pb-4",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"rounded-2xl border-4 border-popover bg-popover p-0.5 shadow-sm",children:(0,t.jsxs)(Yi,{size:"lg",children:[g?.user.image?(0,t.jsx)(Vc,{src:g.user.image,alt:y}):null,(0,t.jsx)(Ji,{children:S})]})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 pt-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold text-foreground",children:y}),(0,t.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:w})]})]}),(0,t.jsxs)("div",{className:"mt-4 space-y-1",children:[(0,t.jsx)(K4,{label:"View profile",description:"Open your activity, task, and usage ledger.",icon:vu,href:j,onClick:N}),(0,t.jsx)(K4,{label:"Edit profile",description:"Update your display name and avatar.",icon:b1,href:PJe,onClick:N}),(0,t.jsx)(K4,{label:"Documentation",description:"Open Paperclip docs in a new tab.",icon:Ww,href:MJe,external:!0,onClick:r(()=>f(!1),"onClick")}),(0,t.jsx)(Aj,{variant:"menu-action",onAfterToggle:r(()=>f(!1),"onAfterToggle")}),e==="authenticated"?(0,t.jsxs)("button",{type:"button",className:z("flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-destructive/10",v.isPending&&"cursor-not-allowed opacity-60"),onClick:_,disabled:v.isPending,children:[(0,t.jsx)("span",{className:"mt-0.5 rounded-lg border border-border bg-background/70 p-2 text-muted-foreground",children:(0,t.jsx)(Yh,{className:"size-4"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium text-foreground",children:v.isPending?"Signing out...":"Sign out"}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:"End this browser session."})]})]}):null,(0,t.jsx)(zxe,{})]})]})]})]}),!h&&!a?(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)("a",{href:DJe,target:"_blank",rel:"noreferrer","aria-label":"Share feedback",className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground/50 transition-colors hover:bg-accent/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:(0,t.jsx)(Ex,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsx)(Un,{side:"top",children:"Share feedback"})]}):null]})})}r(DJ,"SidebarAccountMenu");function OJe(e,s){return rge(e,s)[0]?.toLowerCase()??null}r(OJe,"getCompanyRouteSegment");function rge(e,s){if(!s)return[];const n=e.split("/").filter(Boolean);return n.length<2?[]:n[0]?.toUpperCase()!==s.toUpperCase()?[]:n.slice(1)}r(rge,"getCompanyPathSegments");var FJe=new Set(["browse","connections","connect","chat","review","attention","gateways","advanced","app"]);function BJe(e,s){const n=e.split("/").filter(Boolean);return n[0]?.toLowerCase()==="skills"?!0:s?n[0]?.toUpperCase()===s.toUpperCase()&&n[1]?.toLowerCase()==="skills":!1}r(BJe,"isSkillsStoreRoute");function qJe(){const{sidebarOpen:e,setSidebarOpen:s,toggleSidebar:n,collapsed:a,peeking:i,setPeeking:o,isMobile:l,setForceCollapsed:c}=Wa(),{openNewIssue:d,openOnboarding:m}=$o(),{togglePanelVisible:h}=bf(),p=Sc()?.pushToast??null,{companies:f,loading:g,selectedCompany:v,selectedCompanyId:y,selectionSource:w,setSelectedCompanyId:S}=xs(),{companyPrefix:j,pluginRoutePath:N}=ka(),_=Hn(),A=ea(),C=t5(),I=["/company/settings","/company/export","/company/import"].some(We=>A.pathname.includes(We)),T=rge(A.pathname,j),R=T[0]?.toLowerCase()==="tools",L=T[0]?.toLowerCase()==="apps",O=L&&T[1]&&!FJe.has(T[1].toLowerCase())?T[1]:null,$=L&&T[1]?.toLowerCase()==="app"&&T[2]?T[2]:null,E=BJe(A.pathname,j),q=(0,u.useRef)(!1),B=(0,u.useRef)(null),K=(0,u.useRef)(null),U=(0,u.useRef)(new Yde),D=(0,u.useRef)(A.key),V=Qxe(A.pathname,j,l),[H,J]=(0,u.useState)(!1),X=(0,u.useMemo)(()=>{if(!j)return null;const We=j.toUpperCase();return f.find(ze=>ze.issuePrefix.toUpperCase()===We)??null},[f,j]),le=!!j&&!g&&f.length>0&&!X,ce=(0,u.useMemo)(()=>N?.toLowerCase()??OJe(A.pathname,j),[j,A.pathname,N]),te=X?.id??null,re=X?.issuePrefix??null,{slots:de}=Hc({slotTypes:["page","routeSidebar"],companyId:te,enabled:!!(te&&ce)}),Z=(0,u.useMemo)(()=>Vz(de,ce),[ce,de]),Y=(0,u.useMemo)(()=>({companyId:te,companyPrefix:re}),[te,re]),G=I?(0,t.jsx)(kJe,{}):O?(0,t.jsx)(TJ,{kind:"connection",connectionId:O}):$?(0,t.jsx)(TJ,{kind:"application",applicationId:$}):L||R?(0,t.jsx)(SJe,{}):Z?(0,t.jsx)(yu,{slot:Z,context:Y,className:"h-full w-full",missingBehavior:"placeholder"}):null,fe=G!=null,{data:se}=ee({queryKey:P.health,queryFn:r(()=>tm.get(),"queryFn"),retry:!1,refetchInterval:r(We=>We.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1}),ae=ee({queryKey:P.instance.generalSettings,queryFn:r(()=>Ir.getGeneral(),"queryFn")}).data?.keyboardShortcuts===!0,ie=fe||E;(0,u.useLayoutEffect)(()=>(c(ie),()=>c(!1)),[ie,c]),(0,u.useEffect)(()=>{g||q.current||se?.deploymentMode!=="authenticated"&&(se?.cloud||f.length===0&&(q.current=!0,m()))},[f,g,m,se?.cloud,se?.deploymentMode]),(0,u.useEffect)(()=>{if(!j||g||f.length===0)return;if(!X){const ze=(y?f.find(st=>st.id===y):null)??f[0]??null;ze&&y!==ze.id&&S(ze.id,{source:"route_sync"});return}if(j!==X.issuePrefix){const ze=A.pathname.replace(/^\/[^/]+/,"");_(`/${X.issuePrefix}${ze}${A.search}`,{replace:!0});return}const We=Gxe({matchedCompany:X,selectedCompanyId:y,companies:f});if(We){p?.({title:`${X.name} is archived`,body:`Switched to ${We.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${X.id}`}),S(We.id,{source:"route_sync"}),_(`/${We.issuePrefix}/dashboard`,{replace:!0});return}Yxe({selectionSource:w,selectedCompanyId:y,routeCompanyId:X.id})&&S(X.id,{source:"route_sync"})},[j,f,g,X,A.pathname,A.search,_,p,w,y,S]);const ue=h,pe=(0,u.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),be=(0,u.useRef)(null),oe=(0,u.useRef)(!1),je=(0,u.useRef)(!1),_e=(0,u.useCallback)(()=>{be.current!==null&&(window.clearTimeout(be.current),be.current=null)},[]),xe=(0,u.useCallback)(()=>{_e(),be.current=window.setTimeout(()=>o(!0),50)},[_e,o]),Ae=(0,u.useCallback)(()=>{_e(),o(!0)},[_e,o]),Ye=(0,u.useCallback)(()=>{_e(),be.current=window.setTimeout(()=>o(!1),120)},[_e,o]),Oe=(0,u.useCallback)(()=>{oe.current=!0,a&&!je.current&&xe()},[a,xe]),Xe=(0,u.useCallback)(()=>{oe.current=!1,je.current=!1,Ye()},[Ye]),me=(0,u.useCallback)(()=>{je.current||Ae()},[Ae]),Le=(0,u.useCallback)(()=>{oe.current||Ye()},[Ye]);(0,u.useEffect)(()=>_e,[_e]);const mt=(0,u.useRef)(a);return(0,u.useEffect)(()=>{a!==mt.current&&(a?(_e(),o(!1),je.current=oe.current):je.current=!1,mt.current=a)},[a,_e,o]),(0,u.useEffect)(()=>{if(!i)return;const We=r(ze=>{ze.key==="Escape"&&(_e(),o(!1))},"onKeyDown");return window.addEventListener("keydown",We),()=>window.removeEventListener("keydown",We)},[i,_e,o]),Hxe(),Uxe({enabled:ae,onNewIssue:r(()=>d(),"onNewIssue"),onSearch:pe,onToggleSidebar:n,onTogglePanel:ue,onShowShortcuts:r(()=>J(!0),"onShowShortcuts"),onGoToInbox:r(()=>_("/inbox"),"onGoToInbox")}),(0,u.useEffect)(()=>{if(!l)return;const We=30,ze=50,st=75;let pt=0,Pt=0;const tt=r(et=>{const Ie=et.touches[0];pt=Ie.clientX,Pt=Ie.clientY},"onTouchStart"),ht=r(et=>{const Ie=et.changedTouches[0],Ne=Ie.clientX-pt;if(!(Math.abs(Ie.clientY-Pt)>st)){if(!e&&pt<We&&Ne>ze){s(!0);return}e&&Ne<-50&&s(!1)}},"onTouchEnd");return document.addEventListener("touchstart",tt,{passive:!0}),document.addEventListener("touchend",ht,{passive:!0}),()=>{document.removeEventListener("touchstart",tt),document.removeEventListener("touchend",ht)}},[l,e,s]),(0,u.useEffect)(()=>{const We=document.body.style.overflow;return document.body.style.overflow=l?"visible":"clip",()=>{document.body.style.overflow=We}},[l]),(0,u.useEffect)(()=>{if(!l)return Xxe()},[l]),(0,u.useEffect)(()=>{if(typeof document>"u")return;const We=K.current;return Jxe(We)},[A.pathname]),(0,u.useEffect)(()=>{const We=K.current;if(!We)return;const ze=r(()=>{U.current.remember(D.current,We.scrollTop)},"recordScroll");return We.addEventListener("scroll",ze,{passive:!0}),()=>We.removeEventListener("scroll",ze)},[]),(0,u.useLayoutEffect)(()=>{const We=K.current,ze=Gde({previousPathname:B.current,pathname:A.pathname,navigationType:C,state:A.state});B.current=A.pathname;const st=C==="POP",pt=st?U.current.recall(A.key):0;if(D.current=A.key,st){WR(We,pt);const Pt=requestAnimationFrame(()=>WR(We,pt));return()=>cancelAnimationFrame(Pt)}ze&&Jde(We)},[A.key,A.pathname,A.state,C]),(0,t.jsx)(Qde,{children:(0,t.jsx)(tce,{value:{keyboardShortcutsEnabled:ae},children:(0,t.jsxs)("div",{className:z("bg-background text-foreground pt-(--sz-safe-top)",l?"min-h-dvh overflow-x-clip":"flex h-dvh flex-col overflow-clip"),children:[(0,t.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:left-3 focus:top-3 focus:z-(--z-200) focus:rounded-md focus:bg-background focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:"Skip to Main Content"}),(0,t.jsx)($xe,{}),(0,t.jsx)(Oxe,{devServer:se?.devServer}),(0,t.jsxs)("div",{className:z("min-h-0 flex-1",l?"w-full":"flex overflow-clip"),children:[l&&e&&(0,t.jsx)("button",{type:"button",className:"fixed inset-0 z-40 bg-black/50",onClick:r(()=>s(!1),"onClick"),"aria-label":"Close sidebar"}),l?(0,t.jsxs)("div",{className:z("fixed inset-y-0 left-0 z-50 flex flex-col overflow-hidden pt-(--sz-safe-top) transition-transform duration-100 ease-out",e?"translate-x-0":"-translate-x-full"),children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:(0,t.jsx)("div",{className:"w-60 shrink-0 overflow-hidden",children:fe?G:(0,t.jsx)(RJ,{})})}),(0,t.jsx)(DJ,{deploymentMode:se?.deploymentMode})]}):(0,t.jsxs)(TJe,{open:e,collapsed:a,peeking:i,resizable:!0,onPanelMouseEnter:Oe,onPanelMouseLeave:Xe,onPanelFocusCapture:a?me:void 0,onPanelBlurCapture:a?Le:void 0,children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0",children:(0,t.jsx)(RJ,{})}),(0,t.jsx)(DJ,{deploymentMode:se?.deploymentMode})]}),!l&&fe?(0,t.jsx)(EJe,{children:G}):null,(0,t.jsxs)("div",{className:z("flex min-w-0 flex-col",l?"w-full":"h-full flex-1"),children:[(0,t.jsxs)("div",{className:z(l&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:[(0,t.jsx)(BF,{mobile:l}),(0,t.jsx)(RJe,{}),l&&I?(0,t.jsx)("div",{className:"border-b border-border px-4 pb-3",children:(0,t.jsx)(vme,{})}):null]}),(0,t.jsxs)("div",{className:z(l?"block":"flex flex-1 min-h-0"),children:[(0,t.jsx)("main",{id:"main-content",ref:K,tabIndex:-1,style:l?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:z("flex-1 p-4 outline-none md:p-6",l?"overflow-visible pb-(--sz-calc-14)":"overflow-auto [scrollbar-gutter:stable]"),children:le?(0,t.jsx)(xu,{scope:"invalid_company_prefix",requestedPrefix:j??v?.issuePrefix}):(0,t.jsx)(qxe,{children:(0,t.jsx)(r0,{})})}),(0,t.jsx)(Tme,{})]})]})]}),l&&(0,t.jsx)(Lxe,{visible:V}),(0,t.jsx)(Mme,{}),(0,t.jsx)(Hme,{}),(0,t.jsx)(Ixe,{}),(0,t.jsx)(Txe,{}),(0,t.jsx)(Exe,{}),(0,t.jsx)(Pxe,{open:H,onOpenChange:J}),(0,t.jsx)(Mxe,{}),(0,t.jsx)(Dxe,{localTrusted:se?.deploymentMode==="local_trusted"})]})})})}r(qJe,"Layout");var LJ=null;function zJe(){return LJ??=new t1,LJ}r(zJe,"getDetachedClient");function UJe(){const e=(0,u.useContext)(J3),{data:s,isFetched:n}=ee({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn"),enabled:e!=null},e??zJe());return e?{enabled:s?.enableConferenceRoomChat===!0,loaded:n}:{enabled:!1,loaded:!0}}r(UJe,"useConferenceRoomChatEnabled");function KJe(){const{enabled:e,loaded:s}=UJe();return s?e?(0,t.jsx)(r0,{}):(0,t.jsx)(wn,{to:"/dashboard",replace:!0}):null}r(KJe,"ConferenceRoomChatGate");var VJe=["session-start","human-message","agent-message","thinking","responding","responding-burst","tool-call","diff","working","running","completed","activity-phases","awaiting-approval","plan-todo","interrupted","refused","truncated","live-token-cost"],WJe={"session-start":{id:"session-start",label:"Session start",tier:"live",surface:"thread",protocol:'acpx.session → TranscriptEntry kind:"init"'},"human-message":{id:"human-message",label:"Human message",tier:"live",surface:"thread",protocol:'IssueComment authorType:"user"'},"agent-message":{id:"agent-message",label:"Final response",tier:"live",surface:"thread",protocol:'PRP item.delta kind:"agentMessage" channel:"final"'},thinking:{id:"thinking",label:"Thinking",tier:"live",surface:"thread",protocol:"text_delta stream:thought (ACP agent_thought_chunk)"},responding:{id:"responding",label:"Progress update (streaming)",tier:"live",surface:"thread",protocol:'PRP item.delta kind:"agentMessage" channel:"progress"'},"responding-burst":{id:"responding-burst",label:"Progress update burst",tier:"live",surface:"thread",protocol:"text_delta stream:output ×N, tool calls between (PAP-368 dwell)"},"tool-call":{id:"tool-call",label:"Tool call",tier:"live",surface:"thread",protocol:"acpx.tool_call (ACP tool_call / tool_call_update)"},diff:{id:"diff",label:"Diff",tier:"live",surface:"thread",protocol:'ToolCallContent type:"diff" → TranscriptEntry kind:"diff"'},working:{id:"working",label:"Working",tier:"live",surface:"thread",protocol:"heartbeat.run.progress + acpx.status"},running:{id:"running",label:"Running",tier:"live",surface:"thread",protocol:'message.status.type === "running"'},completed:{id:"completed",label:"Completed (collapsed)",tier:"live",surface:"thread",protocol:"acpx.result (StopReason in subtype)"},"activity-phases":{id:"activity-phases",label:"Long-run activity phases",tier:"live",surface:"thread",protocol:"assistant boundaries + chronological tool calls"},"awaiting-approval":{id:"awaiting-approval",label:"Awaiting approval",tier:"tier-b",surface:"thread",protocol:"ACP RequestPermissionRequest + PermissionOptionKind"},"plan-todo":{id:"plan-todo",label:"Plan / todo",tier:"tier-b",surface:"plan",protocol:"ACP Plan { entries: PlanEntry[] }, PlanEntryStatus"},interrupted:{id:"interrupted",label:"Interrupted",tier:"tier-b",surface:"thread",protocol:'AcpRuntimeTurnResult.status:"cancelled" / StopReason "cancelled"'},refused:{id:"refused",label:"Refused",tier:"tier-b",surface:"thread",protocol:'StopReason "refusal"'},truncated:{id:"truncated",label:"Truncated",tier:"tier-b",surface:"thread",protocol:'StopReason "max_tokens" | "max_turn_requests"'},"live-token-cost":{id:"live-token-cost",label:"Live token / cost",tier:"tier-b",surface:"thread",protocol:"ACP UsageUpdate { used, size, cost }"}},G8t=VJe.map(e=>WJe[e]);function age({item:e}){return(0,t.jsx)("article",{className:"rounded-lg border border-border bg-card p-3","aria-label":`Project created: ${e.name}`,children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(W3e,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Project created"}),(0,t.jsx)(Ge,{to:`/projects/${e.projectId}`,className:"break-words text-sm font-medium hover:underline focus-visible:underline",children:e.name}),e.description&&(0,t.jsx)("p",{className:"line-clamp-3 text-sm text-muted-foreground",children:e.description}),e.repositories.length>0&&(0,t.jsx)("ul",{className:"space-y-1 pt-1",children:e.repositories.map(s=>(0,t.jsxs)("li",{className:"flex min-w-0 items-center gap-2 text-xs text-muted-foreground",children:[(0,t.jsx)(sl,{className:"size-3 shrink-0","aria-hidden":!0}),(0,t.jsx)("a",{className:"truncate hover:underline focus-visible:underline",href:s.url,target:"_blank",rel:"noreferrer",children:s.name})]},s.id))})]})]})})}r(age,"TaskChatProjectCreatedCard");function HJe({item:e,onOpen:s}){return(0,t.jsx)("article",{className:"rounded-lg border border-border bg-card p-3","aria-label":`Skill created: ${e.name}`,children:(0,t.jsxs)("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:r(()=>s?.(e.skillId,e.name),"onClick"),children:[(0,t.jsx)(yx,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,t.jsxs)("span",{className:"min-w-0 flex-1 space-y-1",children:[(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Skill created"}),(0,t.jsx)("span",{className:"block break-words text-sm font-medium hover:underline focus-visible:underline",children:e.name}),e.description?(0,t.jsx)("span",{className:"block line-clamp-3 text-sm text-muted-foreground",children:e.description}):null]})]})})}r(HJe,"TaskChatSkillCreatedCard");var ige=(0,u.createContext)("streamlined");function QJe({mode:e,children:s}){return(0,t.jsx)(ige.Provider,{value:e,children:s})}r(QJe,"TaskChatPresentationProvider");function Xh(){return(0,u.useContext)(ige)==="streamlined"}r(Xh,"useStreamlinedTaskChatPresentation");function GJe(e){return(0,t.jsxs)("svg",{viewBox:"0 0 180 180",fill:"none",stroke:"currentColor",strokeWidth:14,strokeLinecap:"round",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,t.jsx)("path",{d:"M18 84.8528L85.8822 16.9706C95.2548 7.59798 110.451 7.59798 119.823 16.9706C129.196 26.3431 129.196 41.5391 119.823 50.9117L68.5581 102.177"}),(0,t.jsx)("path",{d:"M69.2652 101.47L119.823 50.9117C129.196 41.5391 144.392 41.5391 153.765 50.9117L154.118 51.2652C163.491 60.6378 163.491 75.8338 154.118 85.2063L92.7248 146.6C89.6006 149.724 89.6006 154.789 92.7248 157.913L105.331 170.52"}),(0,t.jsx)("path",{d:"M102.853 33.9411L52.6482 84.1457C43.2756 93.5183 43.2756 108.714 52.6482 118.087C62.0208 127.459 77.2167 127.459 86.5893 118.087L136.794 67.8822"})]})}r(GJe,"McpIcon");var YJe=new Set(["tool","tool call","tool_call","acp_tool"]);function Id(e){const s=(e??"").trim().toLowerCase().replace(/\s*\((?:pending|in[_ -]?progress|completed|failed|cancelled|canceled)\)$/,"");return!s||YJe.has(s)}r(Id,"isGenericToolName");function xK(e){const s=e.match(/^mcp__(.+?)__(.+)$/i);if(s)return{namespace:s[1],name:s[2]};const n=e.match(/^mcp\.([^.]+)\.(.+)$/i);return n?{namespace:n[1],name:n[2]}:null}r(xK,"mcpToolIdentity");function gK(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[^A-Za-z0-9]+/g," ").trim().toLowerCase().split(/\s+/).filter(Boolean)}r(gK,"identifierWords");function oge(e){if(e.length===0)return"";const s=e.map(n=>["api","id","lsp","mcp","pr","url"].includes(n)?n.toUpperCase():n).join(" ");return s.charAt(0).toUpperCase()+s.slice(1)}r(oge,"sentenceCase");function Rj(e){const s=(e??"").trim();return Id(s)?"Unnamed tool":oge(gK(xK(s)?.name??s))}r(Rj,"humanizeToolName");var nd=r((e,s,n)=>({key:e,singular:s,plural:n}),"group"),JJe={bash:{action:"run"},terminal:{action:"run"},shell:{action:"run"},command:{action:"run"},run:{action:"run"},execute:{action:"run"},exec_command:{action:"run"},apply_patch:{action:"update",running:"Applying a patch",completed:"Applied a patch"},read:{action:"read",running:"Reading a file",completed:"Read a file"},write:{action:"update",running:"Writing a file",completed:"Wrote a file"},edit:{action:"update",running:"Editing a file",completed:"Edited a file"},notebook_read:{action:"read",running:"Reading a notebook",completed:"Read a notebook"},notebook_edit:{action:"update",running:"Editing a notebook",completed:"Edited a notebook"},glob:{action:"search",running:"Searching files",completed:"Searched files"},grep:{action:"search",running:"Searching file contents",completed:"Searched file contents",family:"grep"},tool_search:{action:"search",running:"Searching available tools",completed:"Searched available tools",group:nd("tool_search","tool search","tool searches")},web_search:{action:"search",running:"Searching the web",completed:"Searched the web",family:"web"},web_fetch:{action:"fetch",running:"Fetching a web page",completed:"Fetched a web page",family:"web"},todo_write:{action:"update",running:"Updating the task list",completed:"Updated the task list",family:"plan",group:nd("task_operation","task operation","task operations")},task_create:{action:"create",running:"Creating a task",completed:"Created a task",family:"plan",group:nd("task_operation","task operation","task operations")},task_update:{action:"update",running:"Updating a task",completed:"Updated a task",family:"plan",group:nd("task_operation","task operation","task operations")},task_list:{action:"list",running:"Listing tasks",completed:"Listed tasks",family:"plan",group:nd("task_operation","task operation","task operations")},task_get:{action:"read",running:"Reading a task",completed:"Read a task",family:"plan",group:nd("task_operation","task operation","task operations")},enter_plan_mode:{action:"switch",running:"Entering plan mode",completed:"Entered plan mode",family:"plan"},exit_plan_mode:{action:"switch",running:"Leaving plan mode",completed:"Left plan mode",family:"plan"},skill:{action:"read",running:"Loading a skill",completed:"Loaded a skill"},ask_user_question:{action:"request",running:"Requesting input",completed:"Requested input",family:"question"},request_human_input:{action:"request",running:"Requesting input",completed:"Requested input",family:"question",group:nd("task_operation","task operation","task operations")},agent:{action:"start",running:"Starting a subagent",completed:"Started a subagent",family:"agent"},task:{action:"start",running:"Starting a subagent",completed:"Started a subagent",family:"agent"},task_output:{action:"read",running:"Checking subagent progress",completed:"Checked subagent progress",family:"agent"},task_stop:{action:"stop",running:"Stopping a subagent",completed:"Stopped a subagent",family:"agent"},send_message:{action:"post",running:"Messaging a subagent",completed:"Messaged a subagent",family:"agent"},spawn_agent:{action:"start",running:"Starting a subagent",completed:"Started a subagent",family:"agent"},wait_agent:{action:"wait",running:"Checking subagent progress",completed:"Checked subagent progress",family:"agent"},wait_threads:{action:"wait",running:"Checking task progress",completed:"Checked task progress",family:"agent"},interrupt_agent:{action:"stop",running:"Interrupting a subagent",completed:"Interrupted a subagent",family:"agent"},report_findings:{action:"post",running:"Reporting findings",completed:"Reported findings",family:"safety"},guardian_review:{action:"think",running:"Reviewing safety",completed:"Reviewed safety",family:"safety"},lsp:{action:"read",running:"Inspecting code intelligence",completed:"Inspected code intelligence"},compact_conversation:{action:"think",running:"Compacting context",completed:"Compacted context"},image_generation:{action:"create",running:"Generating an image",completed:"Generated an image",family:"image"},view_image:{action:"read",running:"Viewing an image",completed:"Viewed an image",family:"image"},multi_tool_use_parallel:{action:"run",running:"Running tools in parallel",completed:"Ran tools in parallel"},get_task_context:{action:"read",running:"Reading task context",completed:"Read task context"},get_task_history:{action:"read",running:"Reading task history",completed:"Read task history"},list_documents:{action:"list",running:"Listing documents",completed:"Listed documents"},read_document:{action:"read",running:"Reading a document",completed:"Read a document"},list_document_revisions:{action:"list",running:"Listing document revisions",completed:"Listed document revisions"},report_progress:{action:"post",running:"Reporting progress",completed:"Reported progress"},answer_status_question:{action:"post",running:"Answering a status question",completed:"Answered a status question"},write_document:{action:"update",running:"Writing a document",completed:"Wrote a document"},register_deliverable:{action:"create",running:"Registering a deliverable",completed:"Registered a deliverable"},finish_task:{action:"finish",running:"Reporting completion",completed:"Reported completion"},paperclip_finish:{action:"finish",running:"Reporting completion",completed:"Reported completion"},block_task:{action:"block",running:"Reporting a blocker",completed:"Reported a blocker"},paperclip_block:{action:"block",running:"Reporting a blocker",completed:"Reported a blocker"},request_review:{action:"request",running:"Requesting review",completed:"Requested review"},list_agents:{action:"list",running:"Listing agents",completed:"Listed agents"},get_agent:{action:"read",running:"Reading agent details",completed:"Read agent details"},search_tasks:{action:"search",running:"Searching tasks",completed:"Searched tasks"},list_approvals:{action:"list",running:"Listing approvals",completed:"Listed approvals"},get_approval:{action:"read",running:"Reading an approval",completed:"Read an approval"},get_approval_context:{action:"read",running:"Reading approval context",completed:"Read approval context"},get_workspace_runtime:{action:"read",running:"Reading workspace status",completed:"Read workspace status"},control_workspace_service:{action:"run",running:"Controlling a workspace service",completed:"Controlled a workspace service"},set_dependencies:{action:"update",running:"Updating task dependencies",completed:"Updated task dependencies"},create_task:{action:"create",running:"Creating a task",completed:"Created a task"},request_approval:{action:"request",running:"Requesting approval",completed:"Requested approval"},decide_approval:{action:"update",running:"Deciding an approval",completed:"Decided an approval"},comment_on_approval:{action:"post",running:"Commenting on an approval",completed:"Commented on an approval"},schedule_wake:{action:"create",running:"Scheduling a wake-up",completed:"Scheduled a wake-up",family:"wait"},generic_api_request:{action:"request",running:"Calling the Paperclip API",completed:"Called the Paperclip API"}},XJe={read:["get","read","inspect","view"],list:["list","glob"],search:["find","search","grep","query","lookup"],fetch:["fetch","browse"],open:["open"],update:["write","edit","update","set","patch","upsert","sync"],create:["create","add","register","upload"],delete:["delete","remove"],move:["move","rename"],run:["run","execute","bash","shell","command"],request:["request","ask","prompt"],post:["send","message","comment","report","answer"],start:["start","spawn","delegate"],stop:["stop","cancel","interrupt"],wait:["wait","sleep","poll"],finish:["finish","complete"],block:["block"],think:["think","reason","compact","review"],switch:["switch","enter","exit"],other:[]},ZJe={read:"read",edit:"update",delete:"delete",move:"move",search:"search",list:"list",execute:"run",think:"think",fetch:"fetch",switch_mode:"switch"};function eXe(e){return gK(e).join("_")}r(eXe,"normalizedKey");function tXe(e){const s=e[0];if(!s)return null;for(const[n,a]of Object.entries(XJe))if(a.includes(s))return n;return null}r(tXe,"inferredAction");function sXe(e){return e==="run"?"terminal":e==="read"||e==="list"?"read":e==="search"?"search":e==="fetch"||e==="open"?"web":["update","create","delete","move"].includes(e)?"edit":e==="request"?"question":e==="start"||e==="stop"?"agent":e==="wait"?"wait":"other"}r(sXe,"actionFamily");var nXe={terminal:Fb,grep:NEe,search:ha,read:Ww,edit:x5,web:GTe,plan:x1,question:Td,agent:qb,safety:Ai,image:yde,wait:th,mcp:GJe,other:yx};function rXe(e,s){const n=s?` ${s}`:"";switch(e){case"read":return{running:`Reading${n||" data"}`,completed:`Read${n||" data"}`};case"list":return{running:`Listing${n||" items"}`,completed:`Listed${n||" items"}`};case"search":return{running:`Searching${n||""}`,completed:`Searched${n||""}`};case"fetch":return{running:`Fetching${n||" data"}`,completed:`Fetched${n||" data"}`};case"open":return{running:`Opening${n||" an item"}`,completed:`Opened${n||" an item"}`};case"update":return{running:`Updating${n||" data"}`,completed:`Updated${n||" data"}`};case"create":return{running:`Creating${n||" an item"}`,completed:`Created${n||" an item"}`};case"delete":return{running:`Deleting${n||" an item"}`,completed:`Deleted${n||" an item"}`};case"move":return{running:`Moving${n||" an item"}`,completed:`Moved${n||" an item"}`};case"run":return{running:"Running a command",completed:"Ran a command"};case"request":return{running:`Requesting${n||" input"}`,completed:`Requested${n||" input"}`};case"post":return{running:`Posting${n||" an update"}`,completed:`Posted${n||" an update"}`};case"start":return{running:`Starting${n||" an operation"}`,completed:`Started${n||" an operation"}`};case"stop":return{running:`Stopping${n||" an operation"}`,completed:`Stopped${n||" an operation"}`};case"wait":return{running:"Waiting",completed:"Finished waiting"};case"finish":return{running:"Reporting completion",completed:"Reported completion"};case"block":return{running:"Reporting a blocker",completed:"Reported a blocker"};case"think":return{running:"Thinking",completed:"Finished thinking"};case"switch":return{running:`Switching${n||" mode"}`,completed:`Switched${n||" mode"}`};case"other":return{running:"Running",completed:"Ran"}}}r(rXe,"actionCopy");function aXe(e){switch(e){case"run":return nd("command","command","commands");case"read":case"list":return nd("read","read","reads");case"search":return nd("search","search","searches");case"update":case"create":case"delete":case"move":return nd("file_change","file change","file changes");case"start":case"stop":return nd("delegation","delegation","delegations");case"wait":return nd("wait","wait","waits");default:return nd("tool_action","tool action","tool actions")}}r(aXe,"defaultSummaryGroup");function iXe(e){return e==="read"||e==="list"?nd("paperclip_read","Paperclip read","Paperclip reads"):nd("task_operation","task operation","task operations")}r(iXe,"paperclipSummaryGroup");function Jb(e){const s=(e.name??"").trim(),n=xK(s),a=(e.namespace??n?.namespace??"").trim(),i=(n?"mcp":e.transport??"builtin").toLowerCase(),o=(n?.name??s).trim(),l=gK(o),c=eXe(o),d=JJe[c],m=ZJe[(e.operation??"").trim().toLowerCase()],h=tXe(l),p=d?.action??m??h??"other",f=d?"exact":m?"kind":h?"inferred":Id(o)?"unnamed":"fallback",g=Id(o)?"Unnamed tool":Rj(o),v=/^[A-Za-z][A-Za-z0-9_.:-]*$/.test(o),y=h&&v&&l.length>1?l.slice(1):[],w=y.length?oge(y).replace(/^./,C=>C.toLowerCase()):void 0,S=d?.running&&d.completed?{running:d.running,completed:d.completed}:p==="other"?Id(o)?{running:"Running an unnamed tool",completed:"Ran an unnamed tool"}:{running:`Running ${g}`,completed:`Ran ${g}`}:rXe(p,d?void 0:w),j=d?.family??sXe(p),N=i==="mcp"?"mcp":j,_=a?Rj(a):i==="mcp"?"MCP":void 0,A=a.toLowerCase()==="paperclip"?iXe(p):d?.group??aXe(p);return{icon:nXe[N],family:N,runningLabel:S.running,completedLabel:S.completed,failedLabel:`${S.completed} · failed`,interruptedLabel:`${S.running} · stopped`,displayName:g,sourceLabel:_,technicalName:s||void 0,confidence:f,summaryGroup:A}}r(Jb,"toolActivityPresentation");function rE(e){const s=Jb({name:e});return{family:s.family,icon:s.icon,verbLabel:s.runningLabel}}r(rE,"toolTaxonomy");function oXe(e){const s=(e??"").trim().toLowerCase();return s==="thinking"?Eg:s==="responding"||s.startsWith("responding (")?L5e:null}r(oXe,"statusLabelIcon");var V4=["Clipping","Organizing","Sorting","Synthesizing","Analyzing","Filing","Collating","Stapling","Indexing","Annotating","Drafting","Proofreading","Alphabetizing","Photocopying","Laminating","Hole-punching","Bookmarking","Highlighting","Typing","Trimming","Aligning","Combining","Whiteboarding","Diagramming","Sketching","Labeling","Sticky-noting"],W4=["Brewing","Tinkering","Distilling","Deliberating"],$J=(()=>{const e=[],s=Math.max(V4.length,W4.length);for(let n=0;n<s;n++)n<V4.length&&e.push(V4[n]),n<W4.length&&e.push(W4[n]);return e})(),lXe=1e4;function cXe(e){const s=(e??"").trim().toLowerCase();return s==="running"||s==="working"}r(cXe,"isGenericStatusLabel");function dXe(e){let s=2166136261;for(let n=0;n<e.length;n++)s^=e.charCodeAt(n),s=Math.imul(s,16777619);return s>>>0}r(dXe,"fnv1a");function uXe(e,s=0){const n=Math.floor(Math.max(0,s)/lXe);return $J[(dXe(e)+n)%$J.length]}r(uXe,"whimsyWord");var mXe=[{name:"--motion-ease-out-expo",group:"Easing",kind:"easing"},{name:"--motion-ease-standard",group:"Easing",kind:"easing"},{name:"--motion-ease-out",group:"Easing",kind:"easing"},{name:"--motion-ease-scroll-pill-in",group:"Easing",kind:"easing"},{name:"--motion-ease-scroll-pill-out",group:"Easing",kind:"easing"},{name:"--motion-ease-in",group:"Easing",kind:"easing"},{name:"--motion-duration-instant",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-fast",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-base",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-slow",group:"Durations",kind:"time",min:0,max:1500,step:10},{name:"--motion-duration-deliberate",group:"Durations",kind:"time",min:0,max:2e3,step:10},{name:"--motion-duration-enter",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-exit",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-duration-swap",group:"Durations",kind:"time",min:0,max:1e3,step:10},{name:"--motion-marker-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-bubble-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-cot-line-stagger",group:"States",kind:"time",min:0,max:300,step:5},{name:"--motion-cot-collapse",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-tool-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-diff-reveal",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-status-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-status-exit",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-approval-pulse",group:"States",kind:"time",min:0,max:3e3,step:20},{name:"--motion-plan-entry-stagger",group:"States",kind:"time",min:0,max:300,step:5},{name:"--motion-plan-check",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-question-page-enter",group:"States",kind:"time",min:0,max:1e3,step:10},{name:"--motion-count-tween",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-streaming-cursor-blink",group:"States",kind:"time",min:0,max:3e3,step:20},{name:"--motion-turn-fold",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-turn-meta",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-line-scroll",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-interstitial-dwell",group:"States",kind:"time",min:0,max:1e4,step:100},{name:"--motion-scroll-pill-enter",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-scroll-pill-exit",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-scrollbar-idle-delay",group:"States",kind:"time",min:0,max:2e3,step:10},{name:"--motion-pane-glide",group:"States",kind:"time",min:0,max:1500,step:10},{name:"--motion-side-panel-tab",group:"States",kind:"time",min:0,max:1500,step:10}],Y8t=Array.from(new Set(mXe.map(e=>e.group)));function lge(e){const s=e.trim();if(s.endsWith("ms"))return parseFloat(s);if(s.endsWith("s"))return parseFloat(s)*1e3;const n=parseFloat(s);return Number.isFinite(n)?n:0}r(lge,"parseCssTimeMs");function hXe(e){if(e==null)return null;const s=Math.round(e/1e3);return s<60?`${s}s`:`${Math.floor(s/60)}m ${s%60}s`}r(hXe,"elapsedLabel");function pXe(e){if(e==null)return null;const s=Math.max(0,e)/1e3;return s<60?`${s.toFixed(1)}s`:`${Math.floor(s/60)}m ${(s%60).toFixed(1)}s`}r(pXe,"liveElapsedLabel");function fXe(e,s){const[n,a]=(0,u.useState)(()=>Date.now());return(0,u.useEffect)(()=>{if(e==null||!s)return;const i=window.setInterval(()=>a(Date.now()),100);return()=>window.clearInterval(i)},[e,s]),e==null?void 0:Math.max(0,n-e)}r(fXe,"useLiveElapsedMs");function xXe(e,s){return!Number.isFinite(e)||!Number.isFinite(s)||s<=0?0:Math.max(0,Math.round(e/s)-1)}r(xXe,"lineScrollOffset");function A2(e){const s=getComputedStyle(document.documentElement).getPropertyValue(e),n=lge(s);return Number.isFinite(n)?n:0}r(A2,"motionTokenMs");function gXe({text:e,streaming:s,leaving:n}){const a=(0,u.useRef)(null),[i,o]=(0,u.useState)(0),[l,c]=(0,u.useState)(!1),[d,m]=(0,u.useState)(!1);(0,u.useLayoutEffect)(()=>{const p=a.current;if(!p)return;const f=r(()=>{const v=parseFloat(window.getComputedStyle(p).lineHeight);o(xXe(p.scrollHeight,v))},"measure");if(f(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(f);return g.observe(p),()=>g.disconnect()},[e,s]),(0,u.useEffect)(()=>{const p=requestAnimationFrame(()=>c(!0)),f=window.setTimeout(()=>m(!0),A2("--motion-line-scroll"));return()=>{cancelAnimationFrame(p),window.clearTimeout(f)}},[]);const h=l?n?-1:s?-i:0:1;return(0,t.jsx)("span",{className:"tc-line-scroll min-w-0 flex-1","data-testid":"task-chat-live-self-talk","data-streaming":s||void 0,"data-leaving":n||void 0,children:(0,t.jsx)("span",{ref:a,className:z("tc-line-scroll-inner block",!s&&"truncate"),style:{transform:h!==0?`translateY(calc(${h} * 1lh))`:void 0,transition:d&&!n?"none":void 0},children:e})})}r(gXe,"LiveSelfTalkLine");function bXe(e,s){const[n,a]=(0,u.useState)(null),i=(0,u.useRef)(n),o=(0,u.useRef)(null),l=(0,u.useRef)(e),c=(0,u.useRef)(0),d=(0,u.useRef)(null),m=(0,u.useRef)(null),h=(0,u.useRef)(null);return l.current=e,(0,u.useEffect)(()=>{const p=r(w=>{w.current!=null&&(window.clearTimeout(w.current),w.current=null)},"clear"),f=r(w=>{i.current=w,a(w)},"show"),g=r(()=>{p(m),p(h),m.current=window.setTimeout(()=>{if(m.current=null,o.current!=null)return;const w=i.current;w==null||w.streaming||(f({...w,leaving:!0}),h.current=window.setTimeout(()=>{h.current=null,i.current?.leaving&&f(null)},A2("--motion-line-scroll")))},A2("--motion-interstitial-dwell"))},"scheduleLeave"),v=r((w,S)=>{p(m),p(h),c.current=Date.now(),f({text:w,streaming:S,swapKey:(i.current?.swapKey??0)+1}),S||g()},"swapIn");if(!s){p(d),p(m),p(h),o.current=null,i.current&&f(null);return}const y=i.current;if(e==null){y?.streaming&&(f({...y,streaming:!1}),g());return}if(y==null){v(e,!0);return}if(y.streaming){y.text!==e&&f({...y,text:e});return}if(o.current=e,d.current==null){const w=A2("--motion-interstitial-dwell"),S=Math.max(0,c.current+w-Date.now());d.current=window.setTimeout(()=>{d.current=null;const j=o.current;o.current=null,j!=null&&v(j,l.current!=null)},S)}},[e,s]),(0,u.useEffect)(()=>()=>{d.current!=null&&window.clearTimeout(d.current),m.current!=null&&window.clearTimeout(m.current),h.current!=null&&window.clearTimeout(h.current)},[]),n}r(bXe,"useHeldSelfTalk");var vXe={running:{Icon:it,spin:!0,tone:"text-(--status-agent-running)"},working:{Icon:it,spin:!0,tone:"text-(--status-agent-running)"},awaiting_approval:{Icon:Qw,spin:!1,tone:"text-primary"},interrupted:{Icon:Cz,spin:!1,tone:"text-destructive"},refused:{Icon:Vu,spin:!1,tone:"text-destructive"},truncated:{Icon:vEe,spin:!1,tone:"text-(--status-agent-paused)"}};function cge({item:e,onApprovalDecision:s,chevronOpen:n,onToggle:a}){const{Icon:i,spin:o,tone:l}=vXe[e.status],c=e.status==="awaiting_approval",d=e.status==="running"||e.status==="working",m=fXe(e.startedAtMs,d),h=bXe(d?e.selfTalk:void 0,d),p=hXe(e.elapsedMs);if(d){const f=pXe(m??e.elapsedMs),g=e.selfTalk!=null,v=e.toolName?rE(e.toolName).icon:g?null:oXe(e.label),y=g||cXe(e.label)?uXe(e.id,m??e.elapsedMs??0):e.label,w=(0,t.jsxs)("div",{className:"tc-enter-status flex items-center gap-2 py-0.5 text-xs text-muted-foreground",children:[n!==void 0?(0,t.jsx)("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center","data-testid":"task-chat-status-caret-slot",children:(0,t.jsx)(fn,{className:z("h-3 w-3 transition-transform",n?"rotate-90":null),"aria-hidden":!0})}):null,(0,t.jsx)("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center","data-testid":"task-chat-status-dot-slot",children:(0,t.jsx)("span",{"aria-hidden":!0,className:"h-2 w-2 animate-pulse rounded-full bg-(--status-agent-running)"})}),v?(0,t.jsx)(v,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null,(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-baseline gap-2",children:[(0,t.jsxs)("span",{className:"shimmer-text shimmer-text-muted shrink-0 font-medium",children:[y,"…"]}),f?(0,t.jsx)("span",{className:"shrink-0 font-mono tabular-nums text-(length:--text-micro)",children:f}):null,e.detail?(0,t.jsx)("span",{className:"min-w-0 truncate font-mono text-(length:--text-micro)",children:e.detail}):null,e.tokens?(0,t.jsxs)("span",{className:"ml-auto shrink-0 font-mono text-(length:--text-micro)",children:[e.tokens.used.toLocaleString(),"/",e.tokens.size.toLocaleString()," ctx"]}):null]})]});return(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 py-0.5 text-xs text-muted-foreground","data-testid":"task-chat-interstitial-row",children:[(0,t.jsx)("span",{"aria-hidden":!0,className:"h-3.5 w-3.5 shrink-0"}),h?(0,t.jsx)(gXe,{text:h.text,streaming:h.streaming,leaving:h.leaving},h.swapKey):(0,t.jsx)("span",{"aria-hidden":!0,className:"tc-line-scroll min-w-0 flex-1"})]}),a?(0,t.jsx)("button",{type:"button",onClick:a,"aria-expanded":n,className:"-mx-1.5 block w-full rounded-sm px-1.5 text-left transition-colors hover:bg-muted/60","data-testid":"task-chat-live-turn",children:w}):w]})}return(0,t.jsxs)("div",{className:z("tc-enter-status flex flex-col gap-2 rounded-lg border px-3 py-2 text-sm",c?"tc-approval border-primary/40 bg-primary/5":"border-border bg-muted/40"),children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(i,{className:z("h-4 w-4 shrink-0",l,o&&"animate-spin")}),(0,t.jsx)("span",{className:"min-w-0 truncate font-medium",children:e.label}),(0,t.jsxs)("span",{className:"ml-auto flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[p?(0,t.jsx)("span",{children:p}):null,e.tokens?(0,t.jsxs)("span",{children:[e.tokens.used.toLocaleString(),"/",e.tokens.size.toLocaleString()," ctx"]}):null]})]}),e.detail?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.detail}):null,c&&e.approval?(0,t.jsx)("div",{className:"flex flex-wrap justify-end gap-2 pt-1",children:e.approval.options.map(f=>{const g=f.kind.startsWith("reject");return(0,t.jsx)("button",{type:"button",onClick:r(()=>s?.(f.id),"onClick"),className:z("rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",g?"border-border text-muted-foreground hover:bg-accent/50 hover:text-foreground":"border-primary bg-primary text-primary-foreground hover:bg-primary/90"),children:f.label},f.id)})}):null]})}r(cge,"TaskChatStatusPill");function dge(e,s){const n=URL.createObjectURL(s),a=document.createElement("a");a.href=n,a.download=e,a.rel="noreferrer",a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(n)}r(dge,"downloadBlob$1");function yXe(e,s,n){dge(e,new Blob([s],{type:`${n};charset=utf-8`}))}r(yXe,"downloadTextFile");var H4="flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50";function uge({issueId:e,documentKey:s,title:n,format:a,body:i,className:o}){const[l,c]=(0,u.useState)(null),[d,m]=(0,u.useState)(null),[h,p]=(0,u.useState)(null),{copy:f,copied:g,failed:v}=uf(),y=(0,u.useRef)(void 0);(0,u.useEffect)(()=>()=>clearTimeout(y.current),[]);const w=(0,u.useCallback)(async(C,I)=>{c(C),p(null);try{await I(),m(C)}catch(T){m(null),p(T instanceof Error?T.message:"Export failed")}finally{c(null)}clearTimeout(y.current),y.current=setTimeout(()=>{m(null),p(null)},2e3)},[]),S=(0,u.useCallback)(async()=>i??(await Rt.getDocument(e,s)).body,[i,s,e]),j=(0,u.useCallback)(()=>{c("copy"),p(null),(async()=>{try{await f(await S())==="failed"&&p("Copy failed")}catch(C){p(C instanceof Error?C.message:"Copy failed")}finally{c(null)}})()},[f,S]),N=v||h==="Copy failed"?"Copy failed":g?"Copied!":"Copy full content",_=d==="download"?"Downloaded!":"Download source",A=d==="pdf"?"Downloaded!":"Export to PDF";return(0,t.jsxs)("div",{className:z("flex items-center gap-0.5",o),"data-testid":"document-export-actions",children:[(0,t.jsx)("button",{type:"button",className:H4,disabled:l!==null,"aria-label":"Copy full content",title:N,"data-testid":"document-export-copy",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),j()},"onClick"),children:g?(0,t.jsx)(fs,{"aria-hidden":"true",className:"h-3.5 w-3.5"}):(0,t.jsx)(jr,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:H4,disabled:l!==null,"aria-label":"Download source",title:_,"data-testid":"document-export-download",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),w("download",async()=>{const I=gRe(a);yXe(iH(n,I),await S(),I==="md"?"text/markdown":"text/plain")})},"onClick"),children:(0,t.jsx)(zo,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:H4,disabled:l!==null,"aria-label":"Export to PDF",title:A,"data-testid":"document-export-pdf",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),w("pdf",async()=>{dge(iH(n,"pdf"),await Rt.getDocumentPdf(e,s))})},"onClick"),children:(0,t.jsx)(T3e,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("span",{className:"sr-only",role:"status","aria-live":"polite",children:h??(g?"Copied!":v?"Copy failed":d?"Downloaded!":"")})]})}r(uge,"DocumentExportActions");function hC({children:e,className:s}){return(0,t.jsx)("div",{className:z("relative aspect-video w-full overflow-hidden bg-accent/20",s),children:e})}r(hC,"PreviewFrame");function LT({label:e}){return(0,t.jsx)(hC,{className:"flex items-center justify-center",children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5 text-muted-foreground/50",children:[(0,t.jsx)(Vl,{className:"h-7 w-7","aria-hidden":"true"}),e?(0,t.jsx)("span",{className:"text-(length:--text-micro) font-medium uppercase tracking-wide",children:e}):null]})})}r(LT,"PlaceholderPreview");function jXe({artifact:e}){const[s,n]=(0,u.useState)(!1);return s||!e.contentPath?(0,t.jsx)(LT,{label:"Image"}):(0,t.jsx)(hC,{children:(0,t.jsx)("img",{src:e.contentPath,alt:e.title,loading:"lazy",className:"h-full w-full object-cover",onError:r(()=>n(!0),"onError")})})}r(jXe,"ImagePreview");function wXe({artifact:e}){const[s,n]=(0,u.useState)(!1),[a,i]=(0,u.useState)(!1),o=(0,u.useRef)(!1),l=(0,u.useRef)(null);if((0,u.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),s||!e.contentPath)return(0,t.jsx)(hC,{className:"flex items-center justify-center bg-black/80",children:(0,t.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-full bg-white/15",children:(0,t.jsx)(_o,{className:"h-5 w-5 translate-x-0.5 text-white","aria-hidden":"true"})})});const c=r(()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null),i(!0)},"markFrameReady"),d=r(()=>{l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(c,3e3)},"scheduleFrameReadyFallback"),m=r(p=>{if(o.current)return;o.current=!0;const f=p.currentTarget,g=Number.isFinite(f.duration)&&f.duration>0?f.duration:0,v=g>0?Math.min(1,g/4):.05;try{Math.abs(f.currentTime-v)>.001?(f.currentTime=v,d()):c()}catch{c()}},"loadThumbnailFrame"),h=r(p=>{(o.current||p.currentTarget.currentTime>0)&&c()},"handleLoadedData");return(0,t.jsxs)(hC,{className:"bg-black",children:[(0,t.jsx)("video",{src:e.contentPath,preload:"metadata",muted:!0,playsInline:!0,"data-frame-ready":a?"true":"false",className:z("h-full w-full object-contain transition-opacity",a?"opacity-100":"opacity-0"),onLoadedMetadata:m,onLoadedData:h,onSeeked:c,onError:r(()=>n(!0),"onError")}),(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:(0,t.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-full bg-black/55",children:(0,t.jsx)(_o,{className:"h-5 w-5 translate-x-0.5 text-white","aria-hidden":"true"})})})]})}r(wXe,"VideoPreview");function NXe({artifact:e}){const s=e.previewText?.trim();return s?(0,t.jsxs)(hC,{className:"bg-card",children:[(0,t.jsx)("div",{className:"absolute inset-0 overflow-hidden p-3",children:(0,t.jsx)("p",{className:"max-h-full overflow-hidden whitespace-pre-wrap break-words text-base leading-6 text-muted-foreground/75",children:s})}),(0,t.jsx)("div",{className:"pointer-events-none absolute bottom-0 left-0 right-0 h-10 bg-gradient-to-t from-card to-transparent"})]}):(0,t.jsx)(LT,{label:e.source==="document"?"Document":"Text"})}r(NXe,"TextPreview");function D1({artifact:e}){switch(e.mediaKind){case"image":return(0,t.jsx)(jXe,{artifact:e},e.contentPath);case"video":return(0,t.jsx)(wXe,{artifact:e},e.contentPath);case"text":case"document":return(0,t.jsx)(NXe,{artifact:e});case"file":return(0,t.jsx)(LT,{label:"File"});default:return(0,t.jsx)(LT,{})}}r(D1,"ArtifactPreview");function OJ({href:e,download:s,title:n,children:a}){return(0,t.jsx)("a",{href:e,...s?{download:""}:{target:"_blank",rel:"noreferrer"},title:n,"aria-label":n,onClick:r(i=>i.stopPropagation(),"onClick"),className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:a})}r(OJ,"SecondaryAction");function kXe({artifact:e}){return(0,t.jsxs)(Ge,{to:e.href,disableIssueQuicklook:!0,"data-testid":"artifact-card","data-media-kind":e.mediaKind,className:"group flex flex-col overflow-hidden rounded-lg border border-border bg-card cursor-pointer transition-colors hover:border-foreground/20 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[(0,t.jsx)(D1,{artifact:e}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1 p-3",children:[(0,t.jsxs)("div",{className:"flex h-7 items-start justify-between gap-2",children:[(0,t.jsx)("h3",{className:"min-w-0 flex-1 truncate text-sm font-medium leading-7 text-foreground/85",title:e.title,children:e.title}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:[e.source==="document"&&e.documentKey?(0,t.jsx)(uge,{issueId:e.issue.id,documentKey:e.documentKey,title:e.title}):null,e.openPath?(0,t.jsx)(OJ,{href:e.openPath,title:"Open file in new tab",children:(0,t.jsx)(xr,{className:"h-3.5 w-3.5"})}):null,e.downloadPath?(0,t.jsx)(OJ,{href:e.downloadPath,download:!0,title:"Download file",children:(0,t.jsx)(zo,{className:"h-3.5 w-3.5"})}):null]})]}),(0,t.jsxs)("div",{className:"mt-0.5 flex items-center gap-1.5 text-(length:--text-micro) text-muted-foreground/65",children:[(0,t.jsxs)("span",{children:["Last edited ",pu(e.updatedAt)]}),e.createdByAgent?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-muted-foreground/50",children:"·"}),(0,t.jsx)("span",{className:"truncate",children:e.createdByAgent.name})]}):null]})]})]})}r(kXe,"ArtifactCard");function sN(e){if(!Number.isFinite(e)||e<0)return"0 B";if(e<1024)return`${Math.round(e)} B`;const s=["KB","MB","GB","TB"];let n=e/1024,a=0;for(;n>=1024&&a<s.length-1;)n/=1024,a+=1;const i=n.toFixed(1);return`${i.endsWith(".0")?i.slice(0,-2):i} ${s[a]}`}r(sN,"formatBytes$5");var $T=new Set(["application/octet-stream","binary/octet-stream","application/x-binary"]),SXe=[".mp4",".m4v",".webm",".mov",".qt",".quicktime"],CXe=[".png",".jpg",".jpeg",".gif",".webp",".avif",".bmp",".svg",".ico"],_Xe=new Set(["application/wasm"]),IXe=new Set(["application/zip","application/x-zip","application/x-zip-compressed"]),mge=new Set(["text/markdown","text/x-markdown","application/markdown","application/x-markdown"]),AXe=new Set(["application/csv","application/ecmascript","application/graphql","application/html","application/javascript","application/json","application/ld+json","application/sql","application/toml","application/x-httpd-php","application/x-javascript","application/x-python","application/x-sh","application/x-yaml","application/xhtml+xml","application/xml","application/yaml"]),RXe=[".csv",".css",".graphql",".htm",".html",".js",".json",".jsx",".log",".markdown",".md",".mdx",".php",".py",".sh",".sql",".toml",".ts",".tsx",".txt",".xml",".yaml",".yml"];function L1(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}r(L1,"normalizeOutputContentType");function TXe(e){const s=(e??"").trim().toLowerCase();return s?RXe.some(n=>s.endsWith(n)):!1}r(TXe,"hasDocumentLikeFilename");function hge(e){return IXe.has(e)||e.endsWith("+zip")}r(hge,"isZipContentType");function EXe(e){return e?!!(e.startsWith("text/")||mge.has(e)||AXe.has(e)||e.startsWith("application/")&&(e.endsWith("+json")||e.endsWith("+xml"))):!1}r(EXe,"isDocumentLikeOutputContentType");function PXe(e,s){const n=L1(e);return!n||EXe(n)||$T.has(n)&&TXe(s)?!1:n.startsWith("video/")||n.startsWith("image/")||n==="application/pdf"||_Xe.has(n)||hge(n)||$T.has(n)}r(PXe,"isOutputEligibleContentType");function MXe(e){const s=L1(e);if(s.startsWith("video/")){const n=s.slice(6);return n==="quicktime"?{label:"MOV",tone:"video"}:{label:(n||"vid").toUpperCase().slice(0,4),tone:"video"}}return s==="application/pdf"?{label:"PDF",tone:"pdf"}:hge(s)?{label:"ZIP",tone:"zip"}:s.startsWith("image/")?{label:"IMG",tone:"image"}:mge.has(s)?{label:"MD",tone:"bin"}:s==="text/plain"?{label:"TXT",tone:"bin"}:s==="text/csv"||s==="application/csv"?{label:"CSV",tone:"bin"}:s==="text/html"||s==="application/html"||s==="application/xhtml+xml"?{label:"HTML",tone:"bin"}:s==="application/json"||s.endsWith("+json")?{label:"JSON",tone:"bin"}:s==="application/xml"||s==="text/xml"||s.endsWith("+xml")?{label:"XML",tone:"bin"}:s==="application/wasm"?{label:"WASM",tone:"bin"}:{label:"BIN",tone:"bin"}}r(MXe,"getOutputFileGlyph");function $d(e,s){const n=L1(e);if(n.startsWith("video/"))return!0;if(!$T.has(n))return!1;const a=(s??"").trim().toLowerCase();return SXe.some(i=>a.endsWith(i))}r($d,"isVideoLikeOutput");function gw(e){return L1(e).startsWith("image/")}r(gw,"isImageContentType");function pC(e,s){const n=L1(e);if(gw(n))return!0;if(n&&!$T.has(n))return!1;const a=(s??"").trim().toLowerCase();return CXe.some(i=>a.endsWith(i))}r(pC,"isImageLikeOutput");function FJ(e){const s=new Date(e).getTime();return Number.isNaN(s)?0:s}r(FJ,"toTime");function aE(e){const s=(e??[]).filter(n=>n.type==="artifact"&&n.provider==="paperclip").flatMap(n=>{const a=LIe.safeParse(n.metadata);return a.success&&!PXe(a.data.contentType,a.data.originalFilename)?[]:[{id:n.id,title:n.title,status:typeof n.status=="string"?n.status:"active",isPrimary:!!n.isPrimary,createdAt:n.createdAt,metadata:a.success?a.data:null,degraded:!a.success,workProduct:n}]});return s.sort((n,a)=>n.isPrimary!==a.isPrimary?n.isPrimary?-1:1:FJ(a.createdAt)-FJ(n.createdAt)),{items:s,primary:s[0]??null,rest:s.slice(1),count:s.length}}r(aE,"getIssueOutputs");function bK(e){return e.metadata?.originalFilename||e.title||"output"}r(bK,"outputFilename");function pge(e){return new Set(aE(e).items.flatMap(s=>{const n=s.metadata?.attachmentId;return n?[n]:[]}))}r(pge,"getPromotedOutputAttachmentIds");var jh={connect:r((e,s)=>Re.post(`/companies/${e}/email/connections`,s),"connect"),inspectSaved:r((e,s)=>Re.post(`/companies/${e}/email/connections/${s}/inspect`,{}),"inspectSaved"),list:r(e=>Re.get(`/companies/${e}/email/inboxes`),"list"),setup:r((e,s)=>Re.post(`/companies/${e}/email/inboxes`,s),"setup"),inspect:r((e,s)=>Re.post(`/companies/${e}/email/inspect`,{apiKey:s}),"inspect"),control:r((e,s)=>Re.post(`/email/inboxes/${e}/control`,{action:s}),"control"),reconnect:r((e,s,n)=>Re.post(`/email/inboxes/${e}/reconnect`,{apiKey:s,receiveMode:n}),"reconnect"),resolve:r((e,s,n,a)=>Re.post(`/companies/${e}/email/deliveries/${s}/resolve`,{outcome:n,providerMessageId:a}),"resolve"),thread:r((e,s)=>Re.get(`/companies/${e}/email/tasks/${s}`),"thread"),send:r((e,s)=>Re.post(`/companies/${e}/email/send`,s),"send")},fge=(0,u.createContext)(null);function DXe({companyId:e,issueId:s,children:n}){const{enabled:a}=Lx(),i=ee({queryKey:["email-thread",e,s],queryFn:r(()=>jh.thread(e,s),"queryFn"),enabled:a,refetchInterval:a?3e3:!1});return(0,t.jsx)(fge.Provider,{value:i.data??null,children:n})}r(DXe,"EmailThreadProvider");function xge(e){const s=(0,u.useContext)(fge),n=s?.messages.find(a=>a.commentId===e);return n&&s?(0,t.jsx)(gge,{message:n,publication:s.publications.find(a=>a.providerMessageId===n.providerMessageId),issueId:s.issueId}):null}r(xge,"useEmailComment");function gge({message:e,publication:s,issueId:n}){const a=ee({queryKey:["email-attachments",n],queryFn:r(()=>Rt.listAttachments(n),"queryFn"),enabled:e.attachmentIds.length>0});return(0,t.jsxs)("article",{"aria-label":e.direction==="inbound"?"Email received":"Email sent",className:"space-y-4 rounded-xl border border-border bg-card p-5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 text-sm font-semibold",children:[(0,t.jsx)(wce,{className:"size-4"}),e.direction==="inbound"?"Email received":"Email sent"]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("p",{className:"text-sm font-medium",children:[e.from,e.direction==="inbound"&&(0,t.jsx)("span",{className:"ml-2 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground",children:"External"})]}),(0,t.jsxs)("p",{className:"break-words text-xs text-muted-foreground",children:["To: ",e.to.join(", ")]}),!!e.cc?.length&&(0,t.jsxs)("p",{className:"break-words text-xs text-muted-foreground",children:["Cc: ",e.cc.join(", ")]}),(0,t.jsx)("p",{className:"text-sm font-semibold",children:e.subject})]}),(0,t.jsx)("div",{className:"whitespace-pre-wrap break-words text-sm",children:e.text||"(No text body)"}),!!e.attachmentIds.length&&(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:e.attachmentIds.map(i=>{const o=a.data?.find(l=>l.id===i);return(0,t.jsxs)("a",{href:`/api/attachments/${i}/content`,target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 rounded-md border border-border px-3 py-2 text-xs",children:[(0,t.jsx)(Vl,{className:"size-3.5"}),o?.originalFilename??"Open attachment"]},i)})}),(0,t.jsxs)("details",{className:"text-xs text-muted-foreground",children:[(0,t.jsx)("summary",{className:"cursor-pointer",children:"Email details"}),(0,t.jsxs)("div",{className:"space-y-2 pt-3",children:[!!e.bcc?.length&&(0,t.jsxs)("p",{children:["Bcc: ",e.bcc.join(", ")]}),(0,t.jsxs)("p",{className:"break-all",children:["Message ID: ",e.providerMessageId]}),e.fullText!==e.text&&(0,t.jsx)("div",{className:"whitespace-pre-wrap break-words",children:e.fullText})]})]}),s&&(0,t.jsxs)("p",{className:"border-t border-border pt-3 text-xs text-muted-foreground",children:[s.outcome==="delivered"?"Delivered":s.outcome==="failed"?"Delivery failed":s.outcome==="uncertain"?"Delivery uncertain":s.outcome==="queued"?"Queued":"Sent",s.error?` · ${s.error}`:""]}),a.error&&(0,t.jsx)("p",{role:"alert",className:"text-xs text-destructive",children:"Attachments could not be loaded."})]})}r(gge,"EmailMessageCard");var Tj=(0,u.createContext)(null);function LXe(e){return e.contentType.toLowerCase().split(";")[0]?.trim()??""}r(LXe,"normalizedContentType$1");function $1(e){return e.originalFilename??e.id}r($1,"attachmentFilename");function vK(e){return e.openPath??e.contentPath}r(vK,"attachmentOpenPath");function iE(e){return e.downloadPath??`${e.contentPath}?download=1`}r(iE,"attachmentDownloadPath");function bge(e){const s=LXe(e);return pC(s,e.originalFilename)&&!/^image\/hei[cf](?:-sequence)?$/.test(s)}r(bge,"isImageAttachment$2");function vge(e){return $d(e.contentType,e.originalFilename)}r(vge,"isVideoAttachment");function $Xe(e){return aIe(e)}r($Xe,"isMarkdownAttachment");function nN({items:e,initialIndex:s,open:n,onOpenChange:a}){const[i,o]=(0,u.useState)(s),l=(0,u.useRef)(null),c=(0,u.useCallback)(v=>{l.current=v},[]);(0,u.useEffect)(()=>{n&&o(s)},[n,s]);const d=(0,u.useCallback)(()=>{o(v=>(v+1)%e.length)},[e.length]),m=(0,u.useCallback)(()=>{o(v=>(v-1+e.length)%e.length)},[e.length]);(0,u.useEffect)(()=>{i<e.length||o(0)},[i,e.length]),(0,u.useEffect)(()=>{if(!n)return;const v=r(y=>{y.key==="ArrowRight"?d():y.key==="ArrowLeft"?m():y.key==="Escape"&&a(!1)},"handler");return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n,d,m,a]);const h=(0,u.useCallback)(v=>{const y=v.target;y.closest("button")||y.closest("a")||y===l.current||a(!1)},[a]);if(e.length===0)return null;const p=e[i];if(!p)return null;const f=$1(p),g=$d(p.contentType,p.originalFilename);return(0,t.jsx)(b2e,{open:n,onOpenChange:a,children:(0,t.jsxs)(x2e,{children:[(0,t.jsx)(g2e,{className:"fixed inset-0 z-50 bg-black/90 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-200"}),(0,t.jsxs)(w2e,{className:"fixed inset-0 z-50 flex flex-col outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 duration-200",onClick:h,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 text-white/80 text-sm shrink-0",children:[(0,t.jsx)("span",{className:"truncate max-w-(--pct-50) font-medium",title:f,children:f}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsxs)("span",{className:"text-white/40 tabular-nums text-xs",children:[i+1," / ",e.length]}),(0,t.jsx)("a",{href:iE(p),download:f,className:"text-white/50 hover:text-white transition-colors",title:"Download","aria-label":`Download ${f}`,onClick:r(v=>v.stopPropagation(),"onClick"),children:(0,t.jsx)(zo,{className:"h-4.5 w-4.5"})}),(0,t.jsx)("button",{type:"button",onClick:r(()=>a(!1),"onClick"),className:"text-white/50 hover:text-white transition-colors",title:"Close",children:(0,t.jsx)(ir,{className:"h-5 w-5"})})]})]}),(0,t.jsxs)("div",{className:"flex-1 flex items-center min-h-0",children:[(0,t.jsx)("div",{className:"w-16 md:w-24 shrink-0 flex items-center justify-center h-full",children:e.length>1&&(0,t.jsx)("button",{type:"button",onClick:m,className:"rounded-full bg-white/10 p-3 text-white/60 hover:text-white hover:bg-white/20 transition-colors",title:"Previous",children:(0,t.jsx)(bu,{className:"h-7 w-7"})})}),(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center min-w-0 min-h-0 h-full px-2",children:g?(0,t.jsx)("video",{ref:c,src:p.contentPath,className:"max-w-full max-h-full rounded-lg",controls:!0,playsInline:!0}):(0,t.jsx)("img",{ref:c,src:p.contentPath,alt:f,className:"max-w-full max-h-full object-contain select-none rounded-lg",draggable:!1})}),(0,t.jsx)("div",{className:"w-16 md:w-24 shrink-0 flex items-center justify-center h-full",children:e.length>1&&(0,t.jsx)("button",{type:"button",onClick:d,className:"rounded-full bg-white/10 p-3 text-white/60 hover:text-white hover:bg-white/20 transition-colors",title:"Next",children:(0,t.jsx)(fn,{className:"h-7 w-7"})})})]}),(0,t.jsx)("div",{className:"h-6 shrink-0"})]})]})})}r(nN,"ImageGalleryModal");function VF(e,s){if(e&&!s)return e;if(!e&&s)return s;if(e||s)return{...e,...s}}r(VF,"mergeObjects");var yK={};function jK(e,s,n,a,i){if(!n&&!a&&!i&&!e)return OT(s);let o=OT(e);return s&&(o=Dk(o,s)),n&&(o=Dk(o,n)),a&&(o=Dk(o,a)),i&&(o=Dk(o,i)),o}r(jK,"mergeProps");function OXe(e){if(e.length===0)return yK;if(e.length===1)return OT(e[0]);let s=OT(e[0]);for(let n=1;n<e.length;n+=1)s=Dk(s,e[n]);return s}r(OXe,"mergePropsN");function OT(e){return wK(e)?{...jge(e,yK)}:FXe(e)}r(OT,"createInitialMergedProps");function Dk(e,s){return wK(s)?jge(s,e):BXe(e,s)}r(Dk,"mergeInto");function FXe(e){const s={...e};for(const n in s){const a=s[n];yge(n,a)&&(s[n]=wge(a))}return s}r(FXe,"copyInitialProps");function BXe(e,s){if(!s)return e;for(const n in s){const a=s[n];switch(n){case"style":e[n]=VF(e.style,a);break;case"className":e[n]=kge(e.className,a);break;default:yge(n,a)?e[n]=qXe(e[n],a):e[n]=a}}return e}r(BXe,"mutablyMergeInto");function yge(e,s){const n=e.charCodeAt(0),a=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&a===110&&i>=65&&i<=90&&(typeof s=="function"||typeof s>"u")}r(yge,"isEventHandler");function wK(e){return typeof e=="function"}r(wK,"isPropsGetter");function jge(e,s){return wK(e)?e(s):e??yK}r(jge,"resolvePropsGetter");function qXe(e,s){return s?e?(...n)=>{const a=n[0];if(Sge(a)){const o=a;Nge(o);const l=s(...n);return o.baseUIHandlerPrevented||e?.(...n),l}const i=s(...n);return e?.(...n),i}:wge(s):e}r(qXe,"mergeEventHandlers");function wge(e){return e&&((...s)=>{const n=s[0];return Sge(n)&&Nge(n),e(...s)})}r(wge,"wrapEventHandler");function Nge(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}r(Nge,"makeEventPreventable");function kge(e,s){return s?e?s+" "+e:s:e}r(kge,"mergeClassNames");function Sge(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}r(Sge,"isSyntheticEvent");function zXe(e,s){return r(function(a,...i){const o=new URL(e);return o.searchParams.set("code",a.toString()),i.forEach(l=>o.searchParams.append("args[]",l)),`${s} error #${a}; visit ${o} for the full message.`},"formatErrorMessage")}r(zXe,"createFormatErrorMessage");var UXe=zXe("https://base-ui.com/production-error","Base UI"),BJ={};function Cge(e,s){const n=u.useRef(BJ);return n.current===BJ&&(n.current=e(s)),n}r(Cge,"useRefWithInit");function qJ(e,s,n,a){const i=Cge(_ge).current;return VXe(i,e,s,n,a)&&Ige(i,[e,s,n,a]),i.callback}r(qJ,"useMergedRefs");function KXe(e){const s=Cge(_ge).current;return WXe(s,e)&&Ige(s,e),s.callback}r(KXe,"useMergedRefsN");function _ge(){return{callback:null,cleanup:null,refs:[]}}r(_ge,"createForkRef");function VXe(e,s,n,a,i){return e.refs[0]!==s||e.refs[1]!==n||e.refs[2]!==a||e.refs[3]!==i}r(VXe,"didChange");function WXe(e,s){return e.refs.length!==s.length||e.refs.some((n,a)=>n!==s[a])}r(WXe,"didChangeN");function Ige(e,s){if(e.refs=s,s.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const a=Array(s.length).fill(null);for(let i=0;i<s.length;i+=1){const o=s[i];if(o!=null)switch(typeof o){case"function":{const l=o(n);typeof l=="function"&&(a[i]=l);break}case"object":o.current=n}}e.cleanup=()=>{for(let i=0;i<s.length;i+=1){const o=s[i];if(o!=null)switch(typeof o){case"function":{const l=a[i];typeof l=="function"?l():o(null);break}case"object":o.current=null}}}}}}r(Ige,"update");var HXe=parseInt("19.2.8",10);function QXe(e){return HXe>=e}r(QXe,"isReactVersionAtLeast");function zJ(e){if(!u.isValidElement(e))return null;const s=e,n=s.props;return(QXe(19)?n?.ref:s.ref)??null}r(zJ,"getReactElementRef");var J8t=Object.freeze([]),Lk=Object.freeze({});function GXe(e,s){const n={};for(const a in e){const i=e[a];if(s?.hasOwnProperty(a)){const o=s[a](i);o!=null&&Object.assign(n,o);continue}i===!0?n[`data-${a.toLowerCase()}`]="":i&&(n[`data-${a.toLowerCase()}`]=i.toString())}return n}r(GXe,"getStateAttributesProps");function YXe(e,s){return typeof e=="function"?e(s):e}r(YXe,"resolveClassName");function JXe(e,s){return typeof e=="function"?e(s):e}r(JXe,"resolveStyle");function XXe(e,s,n={}){const a=s.render,i=ZXe(s,n);return n.enabled===!1?null:sZe(e,a,i,n.state??Lk)}r(XXe,"useRenderElement");function ZXe(e,s={}){const{className:n,style:a,render:i}=e,{state:o=Lk,ref:l,props:c,stateAttributesMapping:d,enabled:m=!0}=s,h=m?YXe(n,o):void 0,p=m?JXe(a,o):void 0,f=m?GXe(o,d):Lk,g=m&&c?eZe(c):void 0,v=m?VF(f,g)??{}:Lk;return typeof document<"u"&&(m?Array.isArray(l)?v.ref=KXe([v.ref,zJ(i),...l]):v.ref=qJ(v.ref,zJ(i),l):qJ(null,null)),m?(h!==void 0&&(v.className=kge(v.className,h)),p!==void 0&&(v.style=VF(v.style,p)),v):Lk}r(ZXe,"useRenderElementProps");function eZe(e){return Array.isArray(e)?OXe(e):jK(void 0,e)}r(eZe,"resolveRenderFunctionProps");var tZe=Symbol.for("react.lazy");function sZe(e,s,n,a){if(s){if(typeof s=="function")return s(n,a);const i=jK(n,s.props);i.ref=n.ref;let o=s;return o?.$$typeof===tZe&&(o=u.Children.toArray(s)[0]),u.cloneElement(o,i)}if(e&&typeof e=="string")return nZe(e,n);throw new Error(UXe(8))}r(sZe,"evaluateRenderProp");function nZe(e,s){return e==="button"?(0,u.createElement)("button",{type:"button",...s,key:s.key}):e==="img"?(0,u.createElement)("img",{alt:"",...s,key:s.key}):u.createElement(e,s)}r(nZe,"renderTag");function rZe(e){return XXe(e.defaultTagName??"div",e,e)}r(rZe,"useRender");var aZe=pz("group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-none border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed",{variants:{size:{default:"gap-2 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5",sm:"gap-2.5 text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1",xs:"gap-1.5 rounded-none text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1"},orientation:{horizontal:"min-w-40 items-center",vertical:"w-24 flex-col has-data-[slot=attachment-content]:w-30"}}});function Age({className:e,state:s="done",size:n="default",orientation:a="horizontal",...i}){return(0,t.jsx)("div",{"data-slot":"attachment","data-state":s,"data-size":n,"data-orientation":a,className:z(aZe({size:n,orientation:a}),e),...i})}r(Age,"Attachment");var iZe=pz("relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-none bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-none group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5",{variants:{variant:{icon:"",image:"opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover"}},defaultVariants:{variant:"icon"}});function Rge({className:e,variant:s="icon",...n}){return(0,t.jsx)("div",{"data-slot":"attachment-media","data-variant":s,className:z(iZe({variant:s}),e),...n})}r(Rge,"AttachmentMedia");function Tge({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-content",className:z("max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1",e),...s})}r(Tge,"AttachmentContent");function Ege({className:e,...s}){return(0,t.jsx)("span",{"data-slot":"attachment-title",className:z("block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer",e),...s})}r(Ege,"AttachmentTitle");function Pge({className:e,...s}){return(0,t.jsx)("span",{"data-slot":"attachment-description",className:z("mt-0.5 block min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive/80","max-w-full",e),...s})}r(Pge,"AttachmentDescription");function oZe({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-actions",className:z("relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:right-3 group-data-[orientation=vertical]/attachment:gap-1",e),...s})}r(oZe,"AttachmentActions$1");function lZe({className:e,variant:s,size:n="icon-xs",...a}){return(0,t.jsx)(F,{"data-slot":"attachment-action",variant:s??"ghost",size:n,className:z(e),...a})}r(lZe,"AttachmentAction");function cZe({className:e,render:s,type:n,...a}){return rZe({defaultTagName:"button",props:jK({type:s?n:n??"button",className:z("absolute inset-0 z-10 outline-none",e)},a),render:s,state:{slot:"attachment-trigger"}})}r(cZe,"AttachmentTrigger");function Mge({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-group",className:z("flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start",e),...s})}r(Mge,"AttachmentGroup");var dZe=new Set(["png","jpg","jpeg","gif","webp","svg","avif","bmp","ico","heic"]),uZe={pdf:{icon:mi,label:"PDF"},doc:{icon:mi,label:"Doc"},docx:{icon:mi,label:"Doc"},txt:{icon:mi,label:"Text"},md:{icon:mi,label:"Markdown"},rtf:{icon:mi,label:"Text"},csv:{icon:Ik,label:"CSV"},tsv:{icon:Ik,label:"TSV"},xls:{icon:Ik,label:"Sheet"},xlsx:{icon:Ik,label:"Sheet"},zip:{icon:V0,label:"ZIP"},gz:{icon:V0,label:"Archive"},tar:{icon:V0,label:"Archive"},tgz:{icon:V0,label:"Archive"},rar:{icon:V0,label:"Archive"},"7z":{icon:V0,label:"Archive"},mp3:{icon:_k,label:"Audio"},wav:{icon:_k,label:"Audio"},m4a:{icon:_k,label:"Audio"},ogg:{icon:_k,label:"Audio"},mp4:{icon:r2,label:"Video"},mov:{icon:r2,label:"Video"},webm:{icon:r2,label:"Video"},json:{icon:jl,label:"JSON"},yaml:{icon:jl,label:"YAML"},yml:{icon:jl,label:"YAML"},xml:{icon:jl,label:"XML"},html:{icon:jl,label:"HTML"},css:{icon:jl,label:"CSS"},js:{icon:jl,label:"Code"},jsx:{icon:jl,label:"Code"},ts:{icon:jl,label:"Code"},tsx:{icon:jl,label:"Code"},py:{icon:jl,label:"Code"},rb:{icon:jl,label:"Code"},go:{icon:jl,label:"Code"},rs:{icon:jl,label:"Code"},sh:{icon:jl,label:"Code"},sql:{icon:jl,label:"SQL"},log:{icon:mi,label:"Log"},patch:{icon:jl,label:"Patch"},diff:{icon:jl,label:"Patch"}};function Dge(e){const s=/\.([a-z0-9]+)$/i.exec(e.trim());return s?s[1].toLowerCase():""}r(Dge,"extensionOf");function UJ(e){return dZe.has(Dge(e))}r(UJ,"isImageFilename");function Lge(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}r(Lge,"normalizedContentType");function vI(e){const s=Lge(e.contentType);return s.startsWith("image/")?!0:s&&s!=="application/octet-stream"?!1:UJ(e.name)||UJ(e.url.split("?")[0])}r(vI,"isImageAttachment$1");function $ge(e){return uZe[Dge(e)]??{icon:cO,label:"File"}}r($ge,"fileKindForName");function mZe(e){const s=$ge(e.name);if(s.label!=="File")return s;const n=Lge(e.contentType);return n==="application/pdf"?{icon:mi,label:"PDF"}:n==="application/json"||n.endsWith("+json")?{icon:jl,label:"JSON"}:n==="text/csv"||n==="application/csv"?{icon:Ik,label:"CSV"}:n.startsWith("text/")?{icon:mi,label:"Text"}:n.startsWith("audio/")?{icon:_k,label:"Audio"}:n.startsWith("video/")?{icon:r2,label:"Video"}:n.includes("zip")||n.includes("archive")?{icon:V0,label:"Archive"}:s}r(mZe,"fileKindForAttachment");function Oge(e){return e===void 0||!Number.isFinite(e)||e<=0?"":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}r(Oge,"formatFileSize");function hZe(e){return/\/api\/(?:attachments|assets)\/([^/?]+)\/content/.exec(e)?.[1]??null}r(hZe,"attachmentIdFromUrl");function KJ(e,s){const n=new Map(s.map(i=>[i.id,i])),a=new Map(s.flatMap(i=>[[i.contentPath,i],...i.openPath?[[i.openPath,i]]:[]]));return e.map(i=>{const o=i.url.split("?")[0],l=a.get(o)??n.get(hZe(i.url)??"");return l?{...i,id:l.id,name:l.originalFilename?.trim()||i.name,contentType:l.contentType,byteSize:l.byteSize,openPath:l.openPath,downloadPath:l.downloadPath}:i})}r(KJ,"hydrateAttachmentRefs");var VJ=/(?<!!)\[((?:\\.|[^\]\\])+)\]\((\/api\/(?:attachments|assets)\/[^()\s]+\/content(?:\?[^()\s]*)?)\)/g,Fge=/!\[((?:\\.|[^\]\\])*)\]\(([^()\s]+)\)/g;function Bge(e){return e.replace(Fge,"").trim().length===0&&e.trim().length>0}r(Bge,"isStandaloneImageEmbedLine");function pZe(e){const s=[],n=new Set;for(const a of e.split(`
337
337
  `))if(Bge(a))for(const i of a.matchAll(Fge)){const[,o,l]=i;n.has(l)||(n.add(l),s.push({name:o.replace(/\\([[\]])/g,"$1"),url:l}))}return s}r(pZe,"extractImageRefs");function fZe(e){return e.split(`
338
338
  `).filter(s=>!Bge(s)).join(`
339
339
  `).replace(/\n{3,}/g,`
@@ -722,7 +722,7 @@ Last resolved: user values resolve per member`;return(0,t.jsxs)("div",{role:"row
722
722
  | Stage | Qualified |
723
723
  | Owner | growth-bot |`,argumentsSummaryJson:JSON.stringify({spreadsheetId:"1AbC…xyz",range:"Leads!A2:D2",values:[["Priya Anand","Northwind","Qualified","growth-bot"]],apiKey:"[redacted]"},null,2),argumentsHash:"sha256:9f2c1a7be4d0c8a3",expiresAt:G7(42)};function Lv(e){const{toolAction:s,payload:n,...a}=e;return al({id:"interaction-tool-action-default",title:void 0,summary:void 0,createdByAgentId:"agent-codex",payload:{version:1,prompt:"Approve running this tool call?",acceptLabel:"Approve & run",rejectLabel:"Decline",...n,toolAction:{...izt,...s}},...a})}r(Lv,"createToolActionConfirmationInteraction");var B7t=Lv({id:"interaction-tool-action-pending-write"}),q7t=Lv({id:"interaction-tool-action-pending-destructive",toolAction:{actionRequestId:"aaaaaaa5-5555-4555-8555-5555555555a5",invocationId:"bbbbbbb6-6666-4666-8666-6666666666b6",toolName:"google_sheets.delete_rows",toolDisplayName:"Delete rows from spreadsheet",risk:"destructive",previewMarkdown:"**Permanently delete 12 rows** (rows 30–41) from the **Q3 Growth Leads** sheet. This cannot be undone.",argumentsSummaryJson:JSON.stringify({spreadsheetId:"1AbC…xyz",range:"Leads!A30:D41",rowCount:12},null,2),argumentsHash:"sha256:1c4e77aa90b3f2d1",expiresAt:G7(4)}}),z7t=Lv({id:"interaction-tool-action-running",status:"accepted",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:00.000Z"),result:{version:1,outcome:"accepted",toolAction:{version:1,status:"approved",updatedAt:"2026-04-20T15:02:00.000Z"}}}),U7t=Lv({id:"interaction-tool-action-executed",status:"accepted",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:12.000Z"),result:{version:1,outcome:"accepted",toolAction:{version:1,status:"executed",resultSummary:"Row 42 added to “Q3 Growth Leads”.",resultHref:"https://docs.google.com/spreadsheets/d/1AbCxyz/edit#gid=0&range=A42",updatedAt:"2026-04-20T15:02:12.000Z"}}}),K7t=Lv({id:"interaction-tool-action-failed",status:"accepted",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:09.000Z"),result:{version:1,outcome:"accepted",toolAction:{version:1,status:"failed",errorCode:"insufficient_permission",errorMessage:"The caller does not have permission to edit this spreadsheet (Google API 403). Ask the sheet owner to grant edit access to the connected account.",updatedAt:"2026-04-20T15:02:09.000Z"}}}),V7t=Lv({id:"interaction-tool-action-declined",status:"rejected",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:01:00.000Z"),updatedAt:new Date("2026-04-20T15:01:00.000Z"),result:{version:1,outcome:"rejected",reason:"We don't add leads to this sheet manually — use the CRM sync instead."}}),W7t=Lv({id:"interaction-tool-action-expired",status:"expired",updatedAt:new Date("2026-04-20T16:00:00.000Z"),resolvedAt:new Date("2026-04-20T16:00:00.000Z"),toolAction:{expiresAt:"2026-04-20T16:00:00.000Z"},result:{version:1,outcome:"superseded_by_comment",toolAction:{version:1,status:"expired",updatedAt:"2026-04-20T16:00:00.000Z"}}}),ozt={version:1,proposalId:"eeeeeee5-5555-4555-8555-5555555555e5",sourceSecretLabel:"OpenAI API key",configPath:"access.evals_openai_api_key",targetAgentId:"ffffffff-6666-4666-8666-6666666666f6",targetAgentName:"EvalsEngineer",justification:"The evaluation runner needs the existing credential under its canonical config name.",expiresAt:G7(20160)};function s_(e){const{secretProposal:s,payload:n,...a}=e;return al({id:"interaction-secret-proposal-default",title:void 0,summary:"Review a proposed alias for an existing secret binding.",createdByAgentId:"agent-codex",resolverPolicy:"human_only",requestedResolverPolicy:"human_only",effectiveResolverPolicy:"human_only",payload:{version:1,prompt:"Approve this secret binding?",acceptLabel:"Approve & bind",rejectLabel:"Reject",allowDeclineReason:!0,...n,secretProposal:{...ozt,...s}},...a})}r(s_,"createSecretProposalConfirmationInteraction");var H7t=s_({id:"interaction-secret-proposal-pending"});function n1e(e={}){const{payload:s,...n}=e;return al({id:"interaction-connection-authorization-default",title:"Connect your Gmail to continue",summary:"Outreach Agent needs your Gmail identity for work running as you.",createdByAgentId:"agent-codex",addresseeUserId:$r.currentUserId,resolverPolicy:"human_only",requestedResolverPolicy:"human_only",effectiveResolverPolicy:"human_only",payload:{version:1,prompt:"Connect your Gmail to continue",acceptLabel:"Connect Gmail",rejectLabel:"Not now",...s,connectionAuthorization:{version:1,providerName:"Gmail",connectionName:null,requestingAgentName:"Outreach Agent"},target:{type:"custom",key:"connection:gmail-abc:user:user-dotta",label:"Connect Gmail",href:"https://accounts.google.com/o/oauth2/v2/auth?client_id=paperclip"}},...n})}r(n1e,"createConnectionAuthorizationInteraction");var Q7t=n1e({id:"interaction-connection-authorization-pending"}),G7t=n1e({id:"interaction-connection-authorization-resolved",status:"accepted",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:03.000Z"),result:{version:1,outcome:"accepted"}});function $v(e={}){return{id:"interaction-connection-intent-default",companyId:$r.companyId,issueId:$r.issueId,kind:"connection_intent",title:"Connect Notion",summary:"Researcher needs this connection to continue.",status:"pending",continuationPolicy:"wake_assignee",createdByAgentId:"11111111-1111-4111-8111-111111111111",createdByUserId:null,resolvedByAgentId:null,resolvedByUserId:null,addresseeUserId:$r.currentUserId,createdAt:new Date("2026-04-20T15:08:00.000Z"),updatedAt:new Date("2026-04-20T15:08:00.000Z"),resolvedAt:null,payload:{version:1,serviceSlug:"notion",serviceName:"Notion",serviceLogoUrl:null,requestingAgentId:"11111111-1111-4111-8111-111111111111",requestingAgentName:"Researcher",phase:"requested"},result:null,resolverPolicy:"human_only",requestedResolverPolicy:"human_only",effectiveResolverPolicy:"human_only",resolverPolicyProvenance:"explicit",effectiveResolverPolicySource:"governed_action",legacyResolverPolicyAliases:{requested:"board_only",effective:"board_only"},...e}}r($v,"createConnectionIntentInteraction");var lzt=$v(),czt=$v({id:"interaction-connection-intent-retry",payload:{version:1,serviceSlug:"notion",serviceName:"Notion",serviceLogoUrl:null,requestingAgentId:"11111111-1111-4111-8111-111111111111",requestingAgentName:"Researcher",phase:"needs_retry"}}),Y7t=$v({id:"interaction-connection-intent-authorizing",payload:{version:1,serviceSlug:"notion",serviceName:"Notion",serviceLogoUrl:null,requestingAgentId:"11111111-1111-4111-8111-111111111111",requestingAgentName:"Researcher",phase:"authorizing"}}),dzt=$v({id:"interaction-connection-intent-connected",status:"accepted",result:{version:1,outcome:"connected",connectionId:"22222222-2222-4222-8222-222222222222"},resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:12:00.000Z")}),J7t=$v({id:"interaction-connection-intent-declined",status:"rejected",result:{version:1,outcome:"declined",reason:"Not right now"},resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:12:00.000Z")}),X7t=$v({id:"interaction-connection-intent-superseded",status:"expired",result:{version:1,outcome:"superseded"},resolvedAt:new Date("2026-04-20T15:12:00.000Z")}),Z7t=$v({id:"interaction-connection-intent-expired",status:"expired",result:{version:1,outcome:"expired"},resolvedAt:new Date("2026-04-20T15:12:00.000Z")}),e9t=s_({id:"interaction-secret-proposal-executed",status:"accepted",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:03.000Z"),result:{version:1,outcome:"accepted",secretProposal:{version:1,status:"executed",updatedAt:"2026-04-20T15:02:03.000Z"}}}),t9t=s_({id:"interaction-secret-proposal-failed",status:"accepted",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:03.000Z"),result:{version:1,outcome:"accepted",secretProposal:{version:1,status:"failed",errorCode:"binding_snapshot_stale",updatedAt:"2026-04-20T15:02:03.000Z"}}}),s9t=s_({id:"interaction-secret-proposal-rejected",status:"rejected",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:00.000Z"),result:{version:1,outcome:"rejected",reason:"Use the project-scoped credential instead.",secretProposal:{version:1,status:"rejected",updatedAt:"2026-04-20T15:02:00.000Z"}}}),n9t=s_({id:"interaction-secret-proposal-expired",status:"expired",resolvedAt:new Date("2026-05-04T15:02:00.000Z"),updatedAt:new Date("2026-05-04T15:02:00.000Z"),secretProposal:{expiresAt:"2026-05-04T15:02:00.000Z"},result:{version:1,outcome:"superseded_by_newer_request",secretProposal:{version:1,status:"expired",updatedAt:"2026-05-04T15:02:00.000Z"}}}),r9t=al({id:"interaction-confirmation-expired-comment",status:"expired",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T14:38:00.000Z"),updatedAt:new Date("2026-04-20T14:38:00.000Z"),result:{version:1,outcome:"superseded_by_comment",commentId:"22222222-2222-4222-8222-222222222222"}}),a9t=al({id:"interaction-confirmation-expired-target",status:"expired",resolvedByAgentId:"agent-codex",resolvedAt:new Date("2026-04-20T14:40:00.000Z"),updatedAt:new Date("2026-04-20T14:40:00.000Z"),payload:{version:1,prompt:"Approve the plan and let the responsible start implementation?",acceptLabel:"Approve plan",rejectLabel:"Request revisions",rejectRequiresReason:!0,target:{type:"issue_document",issueId:$r.issueId,key:"plan",revisionId:"44444444-4444-4444-8444-444444444444",revisionNumber:4}},result:{version:1,outcome:"stale_target",staleTarget:{type:"issue_document",issueId:$r.issueId,key:"plan",revisionId:"11111111-1111-4111-8111-111111111111",revisionNumber:3}}}),i9t=al({id:"interaction-confirmation-failed",status:"failed",updatedAt:new Date("2026-04-20T14:42:00.000Z")}),o9t=al({id:"interaction-confirmation-agent-addressed",title:"Confirm the deploy window with the release agent",summary:"Directed to the release agent, who owns this response without waiting on the board.",addresseeAgentId:"agent-codex"}),l9t=al({id:"interaction-confirmation-not-creator",title:"Independent review of the migration plan",summary:"Asked for a second pair of eyes, so the agent that wrote the plan cannot approve it.",requestedResolverPolicy:"not_creator"}),c9t=al({id:"interaction-confirmation-human-only",title:"Approve the customer-facing announcement",summary:"Reserved for a human on the board because it commits the organization publicly.",requestedResolverPolicy:"human_only"}),d9t=al({id:"interaction-confirmation-company-capped",title:"Confirm the data retention change",summary:"Asked for an open audience; the organization caps this kind at a human decision.",requestedResolverPolicy:"anyone",effectiveResolverPolicy:"human_only",effectiveResolverPolicySource:"company_cap"}),u9t=al({id:"interaction-confirmation-legacy-restricted",title:"Confirm the archived cleanup batch",summary:"Created before Anyone became the default, so it stays restricted until re-created.",requestedResolverPolicy:"not_creator",resolverPolicyProvenance:"legacy_inherited_restriction"}),m9t=al({id:"interaction-confirmation-agent-resolved",title:"Approved by the release agent",status:"accepted",createdByAgentId:"agent-codex",resolvedByAgentId:"agent-codex",resolvedByRunId:"run-agent-resolve-1",resolvedAt:new Date("2026-04-20T15:05:00.000Z"),updatedAt:new Date("2026-04-20T15:05:00.000Z"),result:{version:1,outcome:"accepted"}}),h9t=al({id:"interaction-confirmation-withdrawn",title:"Withdrawn: approve the plan",status:"cancelled",createdByAgentId:"agent-codex",resolvedByAgentId:"agent-codex",resolvedByRunId:"run-agent-withdraw-1",resolvedAt:new Date("2026-04-20T15:10:00.000Z"),updatedAt:new Date("2026-04-20T15:10:00.000Z"),result:{version:1,outcome:"withdrawn",reason:"Plan superseded by a newer revision; no board decision needed."}}),p9t=al({id:"interaction-confirmation-issue-closed",title:"Expired: confirm the migration cutover",status:"expired",resolvedAt:new Date(2026,3,20,15,12,0,0),updatedAt:new Date(2026,3,20,15,12,0,0),result:{version:1,outcome:"issue_closed",reason:"Issue was closed before the confirmation was resolved."}}),f9t=Dv({}),x9t=Dv({id:"interaction-checkbox-bounded",title:"Pick the regions to deploy first",summary:"Choose between two and three regions for the Phase 1 rollout.",payload:{version:1,prompt:"Which regions should we deploy to initially?",detailsMarkdown:"Select at least 2 and at most 3 regions.",options:[{id:"us-west",label:"US West (Oregon)",description:"Lowest latency for our primary user base."},{id:"us-east",label:"US East (Virginia)",description:"Redundancy and east coast coverage."},{id:"eu-west",label:"EU West (Ireland)",description:"GDPR compliance and European users."},{id:"ap-southeast",label:"AP Southeast (Singapore)",description:"Asia-Pacific expansion."}],defaultSelectedOptionIds:["us-west","us-east"],minSelected:2,maxSelected:3,acceptLabel:"Confirm regions",rejectLabel:"Reconsider",rejectRequiresReason:!0,rejectReasonLabel:"What should change about the region set?"}}),g9t=Dv({id:"interaction-checkbox-accepted",status:"accepted",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T14:49:00.000Z"),updatedAt:new Date("2026-04-20T14:49:00.000Z"),result:{version:1,outcome:"accepted",selectedOptionIds:["draft-march-report","draft-spec-v1"]}}),r1e=Array.from({length:100},(e,s)=>{const n=s+1;return{id:`record-${n}`,label:`Customer record #${n}`,description:n%4===0?"Flagged as a possible duplicate during the last import.":void 0}}),uzt=Dv({id:"interaction-checkbox-many",title:"Select the customer records to archive",summary:"The cleanup job found 100 stale customer records. Confirm which ones to archive.",payload:{version:1,prompt:"Check every customer record you want archived.",detailsMarkdown:"The list scrolls. Use Select all / Clear selection to move quickly.",options:r1e,defaultSelectedOptionIds:[],minSelected:0,maxSelected:null,acceptLabel:"Archive selected",rejectLabel:"Reject",rejectRequiresReason:!1}}),b9t=Dv({id:"interaction-checkbox-many-accepted",status:"accepted",title:"Select the customer records to archive",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T14:52:00.000Z"),updatedAt:new Date("2026-04-20T14:52:00.000Z"),payload:uzt.payload,result:{version:1,outcome:"accepted",selectedOptionIds:r1e.slice(0,42).map(e=>e.id)}}),v9t=Dv({id:"interaction-checkbox-rejected",status:"rejected",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T14:50:00.000Z"),updatedAt:new Date("2026-04-20T14:50:00.000Z"),result:{version:1,outcome:"rejected",reason:"Don't delete anything yet — let me confirm with the data owner first."}}),y9t=Dv({id:"interaction-checkbox-stale",status:"expired",resolvedByAgentId:"agent-codex",resolvedAt:new Date("2026-04-20T14:51:00.000Z"),updatedAt:new Date("2026-04-20T14:51:00.000Z"),payload:{version:1,prompt:"Check the draft documents you want me to delete.",acceptLabel:"Delete selected",rejectLabel:"Reject",options:[{id:"draft-march-report",label:"Old draft report"},{id:"draft-spec-v1",label:"Spec v1 (superseded)"}],target:{type:"issue_document",issueId:$r.issueId,key:"plan",revisionId:"44444444-4444-4444-8444-444444444444",revisionNumber:4}},result:{version:1,outcome:"stale_target",staleTarget:{type:"issue_document",issueId:$r.issueId,key:"plan",revisionId:"11111111-1111-4111-8111-111111111111",revisionNumber:3}}});function n_(e){return{id:"interaction-verdicts-default",companyId:$r.companyId,issueId:$r.issueId,kind:"request_item_verdicts",title:"Review 5 blog posts",summary:"This task drafted five blog posts. Approve the ones that are ready and reject the rest with a reason — each decision fans out on its own.",status:"pending",continuationPolicy:"wake_assignee",createdByAgentId:"agent-codex",createdByUserId:null,resolvedByAgentId:null,resolvedByUserId:null,createdAt:new Date("2026-04-20T15:02:00.000Z"),updatedAt:new Date("2026-04-20T15:02:00.000Z"),resolvedAt:null,payload:{version:1,prompt:"Review the 5 blog posts this task drafted.",detailsMarkdown:"Each approved post publishes immediately; rejected posts go back for a revision pass with your reason attached.",items:[{id:"post-spring-recap",label:"Spring launch recap",description:"820 words · product marketing",previewMarkdown:"**Spring launch recap** — a warm retrospective on the Q1 launch and what shipped.",href:"/PAP/issues/PAP-9001"},{id:"post-changelog-digest",label:"Monthly changelog digest",description:"540 words · engineering",previewMarkdown:"A tidy digest of the month's shipped changes, grouped by area.",href:"/PAP/issues/PAP-9002"},{id:"post-founder-note",label:"Founder's note on reliability",description:"1,100 words · leadership",previewMarkdown:"A candid note on the reliability push and the road ahead.",href:"/PAP/issues/PAP-9003"},{id:"post-customer-story",label:"Customer story: Northwind",description:"760 words · customer marketing",previewMarkdown:"How Northwind cut review time in half with the new workflow.",href:"/PAP/issues/PAP-9004"},{id:"post-hiring-push",label:"We're hiring: platform engineers",description:"420 words · recruiting",previewMarkdown:"An open call for platform engineers to join the team.",href:"/PAP/issues/PAP-9005"}],verdicts:["approve","reject"],requireReasonOn:["reject"],reasonLabel:"Why reject?",allowBulkApprove:!0,supersedeOnUserComment:!0},result:null,...e,...t_(e)}}r(n_,"createRequestItemVerdictsInteraction");var j9t=n_({}),w9t=n_({id:"interaction-verdicts-partial",updatedAt:new Date("2026-04-20T15:08:00.000Z"),result:{version:1,outcome:"resolved",complete:!1,items:[{id:"post-spring-recap",verdict:"approve",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")},{id:"post-changelog-digest",verdict:"reject",reason:"Tone is off-brand — too dry. Warm it up and re-submit.",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")}]}}),N9t=n_({id:"interaction-verdicts-complete",status:"answered",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:14:00.000Z"),updatedAt:new Date("2026-04-20T15:14:00.000Z"),result:{version:1,outcome:"resolved",complete:!0,items:[{id:"post-spring-recap",verdict:"approve",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")},{id:"post-changelog-digest",verdict:"reject",reason:"Tone is off-brand — too dry. Warm it up and re-submit.",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")},{id:"post-founder-note",verdict:"approve",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:14:00.000Z")},{id:"post-customer-story",verdict:"approve",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:14:00.000Z")},{id:"post-hiring-push",verdict:"reject",reason:"Hold the recruiting post until the req is approved.",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:14:00.000Z")}]}}),k9t=n_({id:"interaction-verdicts-superseded",status:"expired",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:16:00.000Z"),updatedAt:new Date("2026-04-20T15:16:00.000Z"),result:{version:1,outcome:"superseded_by_comment",complete:!1,commentId:"33333333-3333-4333-8333-333333333333",items:[{id:"post-spring-recap",verdict:"approve",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")},{id:"post-changelog-digest",verdict:"reject",reason:"Tone is off-brand — too dry. Warm it up and re-submit.",resolvedByUserId:$r.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")}]}}),mzt=Array.from({length:24},(e,s)=>{const n=s+1;return{id:`draft-post-${n}`,label:`Draft post #${n}`,description:`${300+n*17} words · auto-generated series`}}),S9t=n_({id:"interaction-verdicts-many",title:"Review 24 generated posts",summary:"A batch-generation task produced 24 posts. Decide them in passes; the card stays until all are decided.",payload:{version:1,prompt:"Review the 24 posts this batch produced.",detailsMarkdown:"The expanded list scrolls. Approve all to accept the batch, or decide item by item.",items:mzt,verdicts:["approve","reject"],requireReasonOn:["reject"],reasonLabel:"Why reject?",allowBulkApprove:!0,supersedeOnUserComment:!0}}),C9t=[woe({id:"comment-thread-board",body:"Pressure-test first-class issue-thread interactions before we touch persistence. I want to see the cards in the real feed, not in a disconnected mock.",createdAt:new Date("2026-04-20T14:02:00.000Z"),updatedAt:new Date("2026-04-20T14:02:00.000Z")}),woe({id:"comment-thread-agent",authorAgentId:"agent-codex",authorUserId:null,body:"I found the existing issue chat surface and I am adding prototype-only interaction records so the Storybook review can happen before persistence work.",createdAt:new Date("2026-04-20T14:09:00.000Z"),updatedAt:new Date("2026-04-20T14:09:00.000Z"),runId:"run-thread-interaction",runAgentId:"agent-codex"})],_9t=[{id:"event-thread-checkout",createdAt:new Date("2026-04-20T14:01:00.000Z"),actorType:"user",actorId:$r.currentUserId,statusChange:{from:"todo",to:"in_progress"}}],hzt=new Set(["local_path","agent_package"]);function W3(e){return hzt.has(e.type)?"unsupported_in_ui":e.pinned?"ok":"unpinned"}r(W3,"sourceWarningCode");function pzt(e){let s="safe";for(const n of e.sourceRefs){const a=W3(n);if(a==="unsupported_in_ui")return"blocked";a==="unpinned"&&(s="has_warnings")}return s}r(pzt,"teamRisk");function fzt(e){return e.counts.localSkills+e.counts.catalogSkills+e.counts.externalSkillSources}r(fzt,"skillCount");function Noe(e){return e.replace(/[-_/]+/g," ").replace(/\b\w/g,s=>s.toUpperCase()).trim()}r(Noe,"titleCase");var xzt={markdown_only:{label:"Markdown only",tip:"Contains only markdown and references. No executable content.",tone:"text-emerald-600 dark:text-emerald-300 border-emerald-500/30",Icon:Ai},assets:{label:"Assets",tip:"Includes static assets (images, fixtures). No executable content.",tone:"text-emerald-600 dark:text-emerald-300 border-emerald-500/30",Icon:Ai},scripts_executables:{label:"Scripts",tip:"Includes executable scripts that were security-reviewed before bundling.",tone:"text-amber-600 dark:text-amber-300 border-amber-500/30",Icon:Rs},external_sources:{label:"External sources",tip:"References external sources resolved at install time.",tone:"text-amber-600 dark:text-amber-300 border-amber-500/30",Icon:Rs}};function a1e({level:e,iconOnly:s=!1}){const n=xzt[e],{Icon:a}=n;return(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsxs)(ct,{variant:"outline",className:z("px-1.5 text-(length:--text-micro)",n.tone),children:[(0,t.jsx)(a,{className:"h-3 w-3"}),!s&&n.label]})}),(0,t.jsx)(Un,{children:n.tip})]})}r(a1e,"TrustChip");function i1e(e){switch(e){case"github":return Sd;case"url":return oc;case"local_path":return Kc;case"agent_package":return Eh;case"skills_sh":return Ul;default:return oc}}r(i1e,"sourceKindIcon");function gzt({team:e}){const s=new Set(e.rootAgentSlugs),n=e.agentSlugs.filter(i=>!s.has(i)),a=e.rootAgentSlugs.length>0;return(0,t.jsx)("div",{className:"max-h-72 overflow-auto rounded-md border border-border",children:(0,t.jsxs)("ul",{className:"divide-y divide-border/60",children:[e.rootAgentSlugs.map(i=>(0,t.jsxs)("li",{className:z("flex items-center gap-2 px-3 py-2 text-sm",a&&"border-l-2 border-amber-500/50"),children:[(0,t.jsx)(p2e,{className:"h-3.5 w-3.5 text-amber-500"}),(0,t.jsx)("span",{className:"font-medium",children:Noe(i)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"root agent"})]},i)),n.map(i=>(0,t.jsxs)("li",{className:"flex items-center gap-2 px-3 py-2 pl-7 text-sm",children:[(0,t.jsx)(yj,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsx)("span",{children:Noe(i)})]},i)),e.agentSlugs.length===0&&(0,t.jsx)("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No agents in this team."})]})})}r(gzt,"TeamHierarchyPreview");function bzt({children:e}){return(0,t.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e})}r(bzt,"SectionHeader");function vzt({skills:e}){return e.length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No required skills."}):(0,t.jsx)("ul",{className:"space-y-1",children:e.map(s=>(0,t.jsxs)("li",{className:"flex items-center gap-2 rounded-md border border-border px-3 py-2 text-sm",children:[(0,t.jsx)(Ul,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.ref}),(0,t.jsx)(ct,{variant:"outline",className:"ml-auto text-(length:--text-nano)",children:s.type}),s.resolved?(0,t.jsx)(ct,{variant:"outline",className:"text-(length:--text-nano) text-emerald-600 dark:text-emerald-300 border-emerald-500/30",children:"resolved"}):(0,t.jsx)(ct,{variant:"outline",className:"text-(length:--text-nano) text-amber-600 dark:text-amber-300 border-amber-500/30",children:"external"})]},`${s.type}:${s.ref}`))})}r(vzt,"RequiredSkillsList");function yzt({inputs:e}){return e.length===0?null:(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(bzt,{children:"Secrets & env inputs"}),(0,t.jsx)("ul",{className:"space-y-1",children:e.map(s=>(0,t.jsxs)("li",{className:"flex items-center gap-2 rounded-md border border-border px-3 py-2 text-sm",children:[(0,t.jsx)(yi,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-mono text-xs uppercase tracking-wide",children:s.key}),(0,t.jsx)(ct,{variant:"outline",className:z("ml-auto text-(length:--text-nano)",s.kind==="secret"?"text-rose-600 dark:text-rose-300 border-rose-500/30":"text-muted-foreground"),children:s.kind}),s.requirement==="required"&&(0,t.jsx)(ct,{variant:"outline",className:"text-(length:--text-nano)",children:"required"})]},s.key))})]})}r(yzt,"EnvInputsList");function jzt({sources:e}){const s=e.filter(i=>i.type!=="include"),[n,a]=(0,u.useState)(!1);return s.length===0?null:(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("button",{type:"button",onClick:r(()=>a(i=>!i),"onClick"),className:"flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[n?(0,t.jsx)(en,{className:"h-3 w-3"}):(0,t.jsx)(fn,{className:"h-3 w-3"}),"External sources · ",s.length]}),n&&(0,t.jsx)("ul",{className:"divide-y divide-border rounded-md border border-border",children:s.map(i=>{const o=i1e(i.type),l=W3(i);return(0,t.jsxs)("li",{className:"flex items-center gap-2 px-3 py-2 text-sm",children:[(0,t.jsx)(o,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-mono text-xs truncate",children:i.ref}),(0,t.jsxs)("span",{className:"ml-auto text-(length:--text-micro)",children:[l==="ok"&&(0,t.jsx)("span",{className:"text-emerald-600 dark:text-emerald-300",children:"Pinned"}),l==="unpinned"&&(0,t.jsx)("span",{className:"text-amber-600 dark:text-amber-300",children:"Unpinned"}),l==="unsupported_in_ui"&&(0,t.jsx)("span",{className:"text-rose-600 dark:text-rose-300",children:"Unsupported in browser install"})]})]},`${i.type}:${i.ref}`)})})]})}r(jzt,"ExternalSourcesList");function wzt({team:e,allowExternalSources:s,allowUnpinnedOptionalSources:n,allowLocalPathSources:a,onChange:i}){const o=e.sourceRefs.filter(c=>c.type!=="include"),l=o.some(c=>W3(c)==="unsupported_in_ui");return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{role:"alert",className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-sm text-amber-700 dark:text-amber-300",children:["This team references ",o.length," external source",o.length===1?"":"s",". Review each one and decide what to allow before continuing."]}),(0,t.jsx)("ul",{className:"divide-y divide-border rounded-md border border-border",children:o.map(c=>{const d=i1e(c.type),m=W3(c);return(0,t.jsxs)("li",{className:"flex items-center gap-2 px-3 py-2.5 text-sm",children:[(0,t.jsx)(d,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"font-mono text-xs truncate",children:c.ref}),(0,t.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:[m==="ok"&&"pinned",m==="unpinned"&&"unpinned reference",m==="unsupported_in_ui"&&"not installable from the browser"]})]}),(0,t.jsx)(ct,{variant:"outline",className:z("ml-auto text-(length:--text-nano)",m==="unsupported_in_ui"?"text-rose-600 dark:text-rose-300 border-rose-500/30":m==="unpinned"?"text-amber-600 dark:text-amber-300 border-amber-500/30":"text-emerald-600 dark:text-emerald-300 border-emerald-500/30"),children:c.type})]},`${c.type}:${c.ref}`)})}),(0,t.jsxs)("div",{className:"space-y-2.5 rounded-md border border-border p-3",children:[(0,t.jsx)(z$,{label:"Allow external sources",description:"Resolve github/url skill and team sources at install time.",checked:s,onChange:r(c=>i("external",c),"onChange")}),(0,t.jsx)(z$,{label:"Allow unpinned optional sources",description:"Permit optional sources that are not pinned to a ref or checksum.",checked:n,onChange:r(c=>i("unpinned",c),"onChange")}),(0,t.jsx)(z$,{label:"Allow local-path sources",description:"Required for local_path / agent_package sources. Development use only.",checked:a,onChange:r(c=>i("localPath",c),"onChange")})]}),l&&!a&&(0,t.jsx)("p",{className:"text-xs text-rose-600 dark:text-rose-300",children:"This team has local-path sources. Enable “Allow local-path sources” to continue, or install it from the CLI."})]})}r(wzt,"StepSourcePolicy");function z$({label:e,description:s,checked:n,onChange:a}){return(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:e}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:s})]}),(0,t.jsx)(_i,{checked:n,onCheckedChange:a})]})}r(z$,"PolicyToggle");var Nzt={already_in_package:{label:"Bundled in package",tone:"text-emerald-600 dark:text-emerald-300 border-emerald-500/30"},catalog_install_required:{label:"Will install from catalog",tone:"text-blue-600 dark:text-blue-300 border-blue-500/30"},external_import_required:{label:"Will import from source",tone:"text-amber-600 dark:text-amber-300 border-amber-500/30"},blocked:{label:"Blocked",tone:"text-rose-600 dark:text-rose-300 border-rose-500/30"}};function kzt({team:e,preparations:s}){return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("div",{role:"alert",className:"rounded-md border border-blue-500/30 bg-blue-500/10 px-3 py-2.5 text-sm text-blue-700 dark:text-blue-300",children:"Before agents are imported, the catalog resolves the skills they depend on. This is the resolution plan."}),(0,t.jsx)("ul",{className:"divide-y divide-border rounded-md border border-border",children:(s??e.requiredSkills.map(Szt)).map(n=>{const a=Nzt[n.action];return(0,t.jsxs)("li",{className:"flex items-center gap-2 px-3 py-2.5 text-sm",children:[(0,t.jsx)(Ul,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"font-mono text-xs truncate",children:n.ref}),n.reason&&(0,t.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground",children:n.reason})]}),(0,t.jsx)(ct,{variant:"outline",className:z("ml-auto text-(length:--text-nano)",a.tone),children:a.label})]},`${n.type}:${n.ref}`)})})]})}r(kzt,"StepSkillPlan");function Szt(e){return{type:e.type,ref:e.ref,agentSlugs:e.agentSlugs,action:e.type==="catalog"?"catalog_install_required":e.resolved?"already_in_package":"external_import_required",catalogSkillId:e.catalogSkillId??null,catalogSkillKey:e.catalogSkillKey??null,sourceLocator:e.sourceLocator??null,sourceRef:e.sourceRef??null,reason:null}}r(Szt,"toPreparation");function QA({team:e,selected:s,onSelect:n,installed:a}){const i=pzt(e),o=!!a?.outOfDate;return(0,t.jsxs)("button",{type:"button",onClick:n,className:z("flex w-full flex-col gap-1 border-b border-border/60 px-3 py-2.5 text-left transition-colors hover:bg-accent/30",s&&"bg-accent/40"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(yj,{className:z("h-3.5 w-3.5 text-muted-foreground",e.kind==="optional"&&"opacity-70")}),(0,t.jsx)("span",{className:z("line-clamp-2 text-(length:--text-compact) font-medium",s&&"text-foreground"),children:e.name}),o&&(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)("span",{"aria-label":"Update available",className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-300",children:(0,t.jsx)(l1,{className:"h-3 w-3"})})}),(0,t.jsx)(Un,{children:"Update available — installed team is out of date"})]}),i!=="safe"&&(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)(Rs,{className:z("ml-auto h-3.5 w-3.5",i==="blocked"?"text-rose-500":"text-amber-500")})}),(0,t.jsx)(Un,{children:"Has external sources"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsxs)("span",{children:[e.counts.agents,"a · ",e.counts.projects,"p · ",e.counts.routines,"r · ",fzt(e),"s"]}),(0,t.jsx)(a1e,{level:e.trustLevel,iconOnly:!0})]})]})}r(QA,"TeamRow");function Czt({team:e,selected:s=!1,onSelect:n}){return(0,t.jsxs)("button",{type:"button",onClick:n,"aria-pressed":s,className:z("flex aspect-square w-full flex-col gap-2 rounded-lg border border-border bg-card p-4 text-left transition-colors hover:bg-accent/30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",s&&"ring-2 ring-ring"),children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-md border border-border bg-background",children:(0,t.jsx)(yj,{className:"h-4 w-4 text-muted-foreground"})}),e.trustLevel!=="markdown_only"&&(0,t.jsx)(a1e,{level:e.trustLevel,iconOnly:!0})]}),(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold leading-snug",children:e.name}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.counts.agents," agent",e.counts.agents===1?"":"s"," ·"," ",e.counts.projects," project",e.counts.projects===1?"":"s"," ·"," ",e.counts.routines," routine",e.counts.routines===1?"":"s"]})]}),e.description&&(0,t.jsx)("p",{className:"line-clamp-3 text-xs text-muted-foreground",children:e.description}),e.tags.length>0&&(0,t.jsx)("div",{className:"mt-auto flex flex-wrap gap-1",children:e.tags.map(a=>(0,t.jsx)(ct,{variant:"outline",className:"text-(length:--text-nano)",children:a},a))})]})}r(Czt,"TeamCard");var gc={id:"paperclipai:bundled:company-defaults:core-exec-team",key:"paperclipai/bundled/company-defaults/core-exec-team",kind:"bundled",category:"company-defaults",slug:"core-exec-team",name:"Core Exec Team",description:"A starter executive team: a CEO who manages a CTO and a CMO, plus a launch project and a weekly standup routine. Installs ready-to-run agents you can customize.",path:"catalog/bundled/company-defaults/core-exec-team",entrypoint:"TEAM.md",schema:"agentcompanies/v1",defaultInstall:!0,recommendedForCompanyTypes:["company-root"],tags:["exec","starter"],counts:{agents:3,projects:1,tasks:1,routines:1,localSkills:1,catalogSkills:1,externalSkillSources:1},rootAgentSlugs:["ceo"],agentSlugs:["ceo","cto","cmo"],projectSlugs:["launch"],requiredSkills:[{type:"catalog",ref:"engineering/code-review",agentSlugs:["cto"],resolved:!0,catalogSkillKey:"engineering/code-review"},{type:"github",ref:"acme/growth-playbook@v1.2.0",agentSlugs:["cmo"],resolved:!1,sourceRef:"v1.2.0"}],envInputs:[{key:"OPENAI_API_KEY",agentSlug:"cto",projectSlug:null,kind:"secret",requirement:"required"},{key:"DEFAULT_TIMEZONE",agentSlug:null,projectSlug:"launch",kind:"plain",requirement:"optional"}],sourceRefs:[{type:"github",ref:"acme/growth-playbook@v1.2.0",pinned:!0},{type:"url",ref:"https://example.com/policies/brand.md",pinned:!1}],files:[{path:"TEAM.md",kind:"team",sizeBytes:2144,sha256:"a1"},{path:"README.md",kind:"readme",sizeBytes:980,sha256:"a2"},{path:"agents/ceo/AGENTS.md",kind:"agent",sizeBytes:1200,sha256:"a3"},{path:"agents/cto/AGENTS.md",kind:"agent",sizeBytes:1100,sha256:"a4"},{path:"agents/cmo/AGENTS.md",kind:"agent",sizeBytes:1050,sha256:"a5"},{path:"projects/launch/PROJECT.md",kind:"project",sizeBytes:640,sha256:"a6"}],trustLevel:"external_sources",compatibility:"compatible",contentHash:"sha256:deadbeefdeadbeefdeadbeefdeadbeef",packageName:"@tickernelz/paperclip-pro-teams-catalog",packageVersion:"0.1.0"},_zt={...gc,id:"paperclipai:optional:software-development:platform-pod",key:"paperclipai/optional/software-development/platform-pod",kind:"optional",category:"software-development",slug:"platform-pod",name:"Platform Engineering Pod",description:"An optional platform pod with a tech lead and two engineers.",recommendedForCompanyTypes:[],counts:{...gc.counts,agents:4,routines:2},rootAgentSlugs:["tech-lead"],agentSlugs:["tech-lead","eng-1","eng-2","sre"],trustLevel:"markdown_only",sourceRefs:[]},koe={...gc,id:"paperclipai:optional:research:lab-with-local-source",slug:"lab-with-local-source",name:"Research Lab (local source)",kind:"optional",category:"research",trustLevel:"scripts_executables",sourceRefs:[{type:"url",ref:"https://example.com/unpinned.md",pinned:!1},{type:"local_path",ref:"/Users/dev/skills/secret-sauce",pinned:!1}]},o1e={catalogId:gc.id,catalogKey:gc.key,present:!0,currentContentHash:gc.contentHash,installedOriginHashes:["sha256:0000older0000older0000older"],agentCount:3,outOfDate:!0},Izt={...o1e,installedOriginHashes:[gc.contentHash],outOfDate:!1},Azt=[{type:"catalog",ref:"engineering/code-review",agentSlugs:["cto"],action:"already_in_package",catalogSkillId:"skill-1",catalogSkillKey:"engineering/code-review",sourceLocator:null,sourceRef:null,reason:null},{type:"github",ref:"acme/growth-playbook@v1.2.0",agentSlugs:["cmo"],action:"external_import_required",catalogSkillId:null,catalogSkillKey:null,sourceLocator:"github.com/acme/growth-playbook",sourceRef:"v1.2.0",reason:"Resolved from GitHub at install time"}],Soe=[{...gc,trustLevel:"markdown_only",sourceRefs:[],requiredSkills:[],counts:{...gc.counts,localSkills:0,catalogSkills:0,externalSkillSources:0}},{...gc,id:"paperclipai:bundled:company-defaults:growth-pod",key:"paperclipai/bundled/company-defaults/growth-pod",slug:"growth-pod",name:"Growth Pod",description:"A lean growth squad: a head of growth managing a content marketer and a data analyst, wired to a launch project and a weekly metrics routine.",tags:["growth","marketing","starter"],counts:{agents:3,projects:1,tasks:0,routines:1,localSkills:0,catalogSkills:0,externalSkillSources:0},rootAgentSlugs:["head-of-growth"],agentSlugs:["head-of-growth","content-marketer","data-analyst"],trustLevel:"assets",sourceRefs:[],requiredSkills:[]},{...gc,id:"paperclipai:bundled:company-defaults:support-pod",key:"paperclipai/bundled/company-defaults/support-pod",slug:"support-pod",name:"Support Pod",description:"A two-person support desk with a lead and an agent, plus a triage routine.",tags:["support","ops"],counts:{agents:2,projects:0,tasks:0,routines:1,localSkills:0,catalogSkills:0,externalSkillSources:0},rootAgentSlugs:["support-lead"],agentSlugs:["support-lead","support-agent"],projectSlugs:[],trustLevel:"markdown_only",sourceRefs:[],requiredSkills:[]}];function V6(e,s,n,a,i){const o=`/api/attachments/${s}/content`;return{id:e,companyId:"demo-company",projectId:null,issueId:"demo-issue",executionWorkspaceId:null,runtimeServiceId:null,type:"artifact",provider:"paperclip",externalId:null,title:a,url:null,status:"active",reviewState:"none",isPrimary:!!i.isPrimary,healthStatus:"unknown",summary:null,createdByRunId:null,createdAt:new Date(i.createdAt),updatedAt:new Date(i.createdAt),metadata:{attachmentId:s,contentType:n,byteSize:i.byteSize,contentPath:o,openPath:o,downloadPath:`${o}?download=1`,originalFilename:a}}}r(V6,"sampleOutput");var Rzt=[V6("wp-vid","aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa","video/mp4","q3-summary.mp4",{byteSize:19293798,isPrimary:!0,createdAt:"2026-05-30T12:00:00Z"}),V6("wp-pdf","bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb","application/pdf","talking-points.pdf",{byteSize:421888,createdAt:"2026-05-30T11:52:00Z"})],Tzt=[{...V6("wp-broken","cccccccc-cccc-4ccc-8ccc-cccccccccccc","video/mp4","corrupt-output.mp4",{byteSize:0,isPrimary:!0,createdAt:"2026-05-30T12:01:00Z"}),metadata:{attachmentId:"cccccccc-cccc-4ccc-8ccc-cccccccccccc",contentType:"video/mp4"}}],GA={id:"design-guide-task",identifier:"PAP-427",title:"Reconcile the navigation model across operator surfaces",status:"in_progress",priority:"medium",blockerAttention:!1};function Or({title:e,children:s}){return(0,t.jsxs)("section",{className:"space-y-4",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:e}),(0,t.jsx)(ml,{}),s]})}r(Or,"Section");function sr({title:e,children:s}){return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:e}),s]})}r(sr,"SubSection");function Ezt(){const[e,s]=(0,u.useState)(Soe[0]?.id??null);return(0,t.jsx)("div",{className:"grid max-w-2xl gap-4 md:grid-cols-2 lg:grid-cols-3",children:Soe.map(n=>(0,t.jsx)(Czt,{team:n,selected:n.id===e,onSelect:r(()=>s(n.id),"onSelect")},n.id))})}r(Ezt,"TeamCardShowcase");var Coe=[{id:"dg-github",companyId:"dg",scope:"company",ownerUserId:null,userSecretDefinitionId:null,key:"github_token",name:"GITHUB_TOKEN",provider:"local_encrypted",status:"active",managedMode:"paperclip_managed",externalRef:null,providerConfigId:null,providerMetadata:null,latestVersion:3,description:null,lastResolvedAt:null,lastRotatedAt:null,deletedAt:null,createdByAgentId:null,createdByUserId:null,createdAt:new Date("2026-03-01T10:00:00.000Z"),updatedAt:new Date("2026-03-01T10:00:00.000Z")},{id:"dg-db",companyId:"dg",scope:"company",ownerUserId:null,userSecretDefinitionId:null,key:"db_connection",name:"DB_CONNECTION",provider:"local_encrypted",status:"active",managedMode:"paperclip_managed",externalRef:null,providerConfigId:null,providerMetadata:null,latestVersion:3,description:null,lastResolvedAt:null,lastRotatedAt:null,deletedAt:null,createdByAgentId:null,createdByUserId:null,createdAt:new Date("2026-03-01T10:00:00.000Z"),updatedAt:new Date("2026-03-01T10:00:00.000Z")}];function Pzt(){const[e,s]=(0,u.useState)({NODE_ENV:{type:"plain",value:"production"},GH_TOKEN:{type:"secret_ref",secretId:"dg-github",version:"latest"},DB_URL:{type:"secret_ref",secretId:"dg-db",version:3},STRIPE_API_KEY:{type:"plain",value:"sk-live-51H8xL0aBcDeFgHiJkLmNoPq"}});return(0,t.jsx)("div",{className:"max-w-(--sz-640px) rounded-md border border-border p-4",children:(0,t.jsx)(Yb,{value:e,secrets:Coe,onChange:r(n=>s(n??{}),"onChange"),onCreateSecret:r(async n=>({...Coe[0],id:`dg-${n}`,key:n,name:n.toUpperCase(),latestVersion:1}),"onCreateSecret")})})}r(Pzt,"EnvironmentVariablesEditorShowcase");function ec({name:e,cssVar:s}){return(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"h-8 w-8 rounded-md border border-border shrink-0",style:{backgroundColor:`var(${s})`}}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-mono",children:s}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e})]})]})}r(ec,"Swatch");function Mzt(){const[e,s]=(0,u.useState)(!0),[n,a]=(0,u.useState)(null),[i,o]=(0,u.useState)(!0);return(0,t.jsxs)("div",{className:"max-w-xl space-y-4",children:[(0,t.jsx)("div",{className:"w-52 rounded-md border border-border p-1",children:(0,t.jsx)(Bwe,{scope:"subtree",canPause:e,canResume:!e,canCancel:!0,canRestore:!e,onPause:r(()=>s(!1),"onPause"),onResume:r(()=>a("resume"),"onResume"),onCancel:r(()=>a("cancel"),"onCancel"),onRestore:r(()=>a("restore"),"onRestore")})}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e?"Running: type to switch Stop to Send.":"Paused: resume from the menu."}),(0,t.jsx)(age,{item:{id:"design-project",kind:"project_created",projectId:"example-project",name:"Onboarding improvements",description:"Help new teams reach their first useful result.",timestamp:"2026-09-11T00:00:00Z",repositories:[{id:"1",name:"paperclipai/paperclip",url:"https://github.com/paperclipai/paperclip"}]}}),e?null:(0,t.jsx)(Vge,{item:{id:"design-cancelled",kind:"marker",variant:"interrupted",tone:"neutral",label:"Run cancelled",detail:"The run was cancelled before returning an answer.",collapsible:!0}}),(0,t.jsx)(ywe,{pause:e?null:{scope:"subtree",onResume:r(()=>a("resume"),"onResume")},onAdd:r(async()=>{},"onAdd"),workMode:"standard",stopScope:"subtree",onStop:e?async()=>s(!1):void 0}),(0,t.jsx)(qwe,{open:n!==null,onOpenChange:r(l=>{l||a(null)},"onOpenChange"),mode:n??"cancel",scope:"subtree",affectedCount:3,affectedAgentCount:2,loading:!1,pending:!1,valid:!0,wakeAgents:i,onWakeAgentsChange:o,onRetry:r(()=>{},"onRetry"),onApply:r(()=>{s(n!=="cancel"&&i),a(null)},"onApply")})]})}r(Mzt,"TaskExecutionControlsExample");function Dzt(){const[e,s]=(0,u.useState)("closed");return(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>s("empty"),"onClick"),children:"Empty picker"}),(0,t.jsx)(F,{variant:"outline",onClick:r(()=>s("loading"),"onClick"),children:"Loading picker"}),(0,t.jsx)(F,{variant:"outline",onClick:r(()=>s("error"),"onClick"),children:"Failed picker"}),(0,t.jsx)(Iue,{agents:[],open:e!=="closed",onOpenChange:r(n=>{n||s("closed")},"onOpenChange"),onSelect:r(()=>{},"onSelect"),loading:e==="loading",error:e==="error"?new Error("Unavailable"):null,onRetry:r(()=>s("empty"),"onRetry")})]})}r(Dzt,"AgentChatPickerExample");function Lzt(){const[e,s]=(0,u.useState)(0),[n,a]=(0,u.useState)("todo"),[i,o]=(0,u.useState)("medium"),[l,c]=(0,u.useState)("in_progress"),[d,m]=(0,u.useState)(!0),[h,p]=(0,u.useState)(!1),[f,g]=(0,u.useState)("Click to edit this text"),[v,y]=(0,u.useState)("Editable Title"),[w,S]=(0,u.useState)("This is an editable description. Click to edit it — the textarea auto-sizes to fit the content without layout shift."),[j,N]=(0,u.useState)([{key:"status",label:"Status",value:"Active"}]),[_,A]=(0,u.useState)(!1),[C,I]=(0,u.useState)(!1),[T,R]=(0,u.useState)(!1);return(0,t.jsxs)("div",{className:"space-y-10 max-w-4xl",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-xl font-bold",children:"Design Guide"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Every component, style, and pattern used across Paperclip."})]}),(0,t.jsxs)(Or,{title:"Component Coverage",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"This page should be updated when new UI primitives or app-level patterns ship."}),(0,t.jsxs)("div",{className:"grid gap-6 md:grid-cols-2",children:[(0,t.jsx)(sr,{title:"UI primitives",children:(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:["avatar","badge","breadcrumb","button","card","checkbox","collapsible","command","dialog","dropdown-menu","input","label","popover","resizable-panels","scroll-area","select","separator","sheet","skeleton","tabs","textarea","tooltip"].map(L=>(0,t.jsx)(ct,{variant:"outline",className:"font-mono text-(length:--text-nano)",children:L},L))})}),(0,t.jsx)(sr,{title:"App components",children:(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:["StatusBadge","StatusIcon","PriorityIcon","EntityRow","EmptyState","MetricCard","FilterBar","InlineEditor","PageSkeleton","Identity","CommentThread","MarkdownEditor","PropertiesPanel","Sidebar","CommandPalette","EnvironmentVariablesEditor","InlineBanner","BuiltInAgentGate","BuiltInLifecycleChip","CollectionToolbar","IssueRow","ContextualSidebarFrame"].map(L=>(0,t.jsx)(ct,{variant:"ghost",className:"font-mono text-(length:--text-nano)",children:L},L))})})]})]}),(0,t.jsx)(Or,{title:"Announcements",children:(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,t.jsx)(I2,{announcement:Q6t,imageSrc:"/announcement-preview.svg",animationSrc:G6t,onDismiss:r(()=>{},"onDismiss")}),(0,t.jsx)(I2,{announcement:U6,imageSrc:"/announcement-preview.svg",onDismiss:r(()=>{},"onDismiss")}),(0,t.jsx)(I2,{announcement:{...U6,image:void 0,secondaryLink:void 0},onDismiss:r(()=>{},"onDismiss")})]})}),(0,t.jsx)(Or,{title:"Task Execution Controls",children:(0,t.jsx)(Mzt,{})}),(0,t.jsxs)(Or,{title:"Task Collection",children:[(0,t.jsx)("p",{className:"max-w-prose text-sm text-muted-foreground",children:"CollectionToolbar owns shared geometry while each page owns its state and behavior. The canonical task row is opt-in during migration: status leads, unread work uses title emphasis, metadata remains stable, and the task identifier trails."}),(0,t.jsx)(gce,{context:(0,t.jsx)("span",{className:"text-sm font-medium",children:"Recent tasks"}),search:(0,t.jsx)(_t,{"aria-label":"Search task collection example",placeholder:"Search tasks..."}),controls:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Filter"}),actions:(0,t.jsx)(F,{size:"sm",children:"New task"}),feedback:(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"1 task · Updated newest first"})}),(0,t.jsx)("div",{className:"overflow-hidden rounded-lg border border-border",children:(0,t.jsx)(xv,{issue:GA,presentation:"task",unreadState:"visible",metadata:(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Updated 12m ago"}),actions:(0,t.jsx)(F,{variant:"ghost",size:"xs",children:"More"})})})]}),(0,t.jsx)(Or,{title:"Theme Toggle",children:(0,t.jsx)(sr,{title:"Variants",children:(0,t.jsxs)("div",{className:"flex max-w-sm flex-col items-start gap-3",children:[(0,t.jsx)(Aj,{}),(0,t.jsx)(Aj,{variant:"menu-action"}),(0,t.jsx)(Aj,{variant:"compact-menu-action"})]})})}),(0,t.jsxs)(Or,{title:"Colors",children:[(0,t.jsx)(sr,{title:"Core",children:(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[(0,t.jsx)(ec,{name:"Background",cssVar:"--background"}),(0,t.jsx)(ec,{name:"Foreground",cssVar:"--foreground"}),(0,t.jsx)(ec,{name:"Card",cssVar:"--card"}),(0,t.jsx)(ec,{name:"Primary",cssVar:"--primary"}),(0,t.jsx)(ec,{name:"Primary foreground",cssVar:"--primary-foreground"}),(0,t.jsx)(ec,{name:"Secondary",cssVar:"--secondary"}),(0,t.jsx)(ec,{name:"Muted",cssVar:"--muted"}),(0,t.jsx)(ec,{name:"Muted foreground",cssVar:"--muted-foreground"}),(0,t.jsx)(ec,{name:"Accent",cssVar:"--accent"}),(0,t.jsx)(ec,{name:"Destructive",cssVar:"--destructive"}),(0,t.jsx)(ec,{name:"Border",cssVar:"--border"}),(0,t.jsx)(ec,{name:"Ring",cssVar:"--ring"})]})}),(0,t.jsx)(sr,{title:"Sidebar",children:(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[(0,t.jsx)(ec,{name:"Sidebar",cssVar:"--sidebar"}),(0,t.jsx)(ec,{name:"Sidebar border",cssVar:"--sidebar-border"})]})}),(0,t.jsx)(sr,{title:"Chart",children:(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[(0,t.jsx)(ec,{name:"Chart 1",cssVar:"--chart-1"}),(0,t.jsx)(ec,{name:"Chart 2",cssVar:"--chart-2"}),(0,t.jsx)(ec,{name:"Chart 3",cssVar:"--chart-3"}),(0,t.jsx)(ec,{name:"Chart 4",cssVar:"--chart-4"}),(0,t.jsx)(ec,{name:"Chart 5",cssVar:"--chart-5"})]})})]}),(0,t.jsxs)(Or,{title:"Runner activity",children:[(0,t.jsx)(fC,{item:{id:"design-runner-activity",kind:"activity_phase",active:!0,summary:"",interstitial:{id:"design-runner-commentary",kind:"message",author:"agent",text:"I’ll inspect the activity feed and check the layout.",interstitial:!0},items:[{id:"design-runner-read",kind:"tool",name:"read",target:"TaskChatRunnerTurn.tsx",status:"completed",detail:"Found the activity groups."},{id:"design-runner-check",kind:"tool",name:"exec_command",target:"pnpm check:token-gates",status:"in_progress"}]}}),(0,t.jsx)(fC,{item:{id:"design-runner-completed",kind:"activity_phase",active:!1,summary:"",items:[{id:"design-completed-read",kind:"tool",name:"read",target:"TaskChatRunnerTurn.tsx",status:"completed",detail:"Read the activity groups."},{id:"design-completed-check",kind:"tool",name:"exec_command",target:"pnpm check:token-gates",status:"failed",detail:"A token check needs another pass."}]}})]}),(0,t.jsx)(Or,{title:"Typography",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("h2",{className:"text-xl font-bold",children:"Page Title — text-xl font-bold"}),(0,t.jsx)("h2",{className:"text-lg font-semibold",children:"Section Title — text-lg font-semibold"}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Section Heading — text-sm font-semibold uppercase tracking-wide"}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"Card Title — text-sm font-medium"}),(0,t.jsx)("p",{className:"text-sm font-semibold",children:"Card Title Alt — text-sm font-semibold"}),(0,t.jsx)("p",{className:"text-sm",children:"Body text — text-sm"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Muted description — text-sm text-muted-foreground"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Tiny label — text-xs text-muted-foreground"}),(0,t.jsx)("p",{className:"text-sm font-mono text-muted-foreground",children:"Mono identifier — text-sm font-mono text-muted-foreground"}),(0,t.jsx)("p",{className:"text-2xl font-bold",children:"Large stat — text-2xl font-bold"}),(0,t.jsx)("p",{className:"font-mono text-xs",children:"Log/code text — font-mono text-xs"})]})}),(0,t.jsx)(Or,{title:"Radius",children:(0,t.jsx)("div",{className:"flex items-end gap-4 flex-wrap",children:[["sm","var(--radius-sm)"],["md","var(--radius-md)"],["lg","var(--radius-lg)"],["xl","var(--radius-xl)"],["full","9999px"]].map(([L,O])=>(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,t.jsx)("div",{className:"h-12 w-12 bg-primary",style:{borderRadius:O}}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:L})]},L))})}),(0,t.jsxs)(Or,{title:"Buttons",children:[(0,t.jsx)(sr,{title:"Variants",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(F,{variant:"default",children:"Default"}),(0,t.jsx)(F,{variant:"secondary",children:"Secondary"}),(0,t.jsx)(F,{variant:"outline",children:"Outline"}),(0,t.jsx)(F,{variant:"ghost",children:"Ghost"}),(0,t.jsx)(F,{variant:"destructive",children:"Destructive"}),(0,t.jsx)(F,{variant:"link",children:"Link"})]})}),(0,t.jsx)(sr,{title:"Sizes",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(F,{size:"xs",children:"Extra Small"}),(0,t.jsx)(F,{size:"sm",children:"Small"}),(0,t.jsx)(F,{size:"default",children:"Default"}),(0,t.jsx)(F,{size:"lg",children:"Large"})]})}),(0,t.jsx)(sr,{title:"Icon buttons",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",children:(0,t.jsx)(ha,{})}),(0,t.jsx)(F,{variant:"ghost",size:"icon-sm",children:(0,t.jsx)(ha,{})}),(0,t.jsx)(F,{variant:"outline",size:"icon",children:(0,t.jsx)(ha,{})}),(0,t.jsx)(F,{variant:"outline",size:"icon-lg",children:(0,t.jsx)(ha,{})})]})}),(0,t.jsx)(sr,{title:"With icons",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsxs)(F,{children:[(0,t.jsx)(yn,{})," New Issue"]}),(0,t.jsxs)(F,{variant:"outline",children:[(0,t.jsx)(Zj,{})," Upload"]}),(0,t.jsxs)(F,{variant:"destructive",children:[(0,t.jsx)(Ia,{})," Delete"]}),(0,t.jsxs)(F,{size:"sm",children:[(0,t.jsx)(yn,{})," Add"]})]})}),(0,t.jsx)(sr,{title:"States",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(F,{disabled:!0,children:"Disabled"}),(0,t.jsx)(F,{variant:"outline",disabled:!0,children:"Disabled Outline"})]})})]}),(0,t.jsx)(Or,{title:"Badges",children:(0,t.jsx)(sr,{title:"Variants",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(ct,{variant:"default",children:"Default"}),(0,t.jsx)(ct,{variant:"secondary",children:"Secondary"}),(0,t.jsx)(ct,{variant:"outline",children:"Outline"}),(0,t.jsx)(ct,{variant:"destructive",children:"Destructive"}),(0,t.jsx)(ct,{variant:"ghost",children:"Ghost"})]})})}),(0,t.jsxs)(Or,{title:"Status System",children:[(0,t.jsx)(sr,{title:"StatusBadge (all statuses)",children:(0,t.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:["active","running","paused","idle","archived","planned","achieved","completed","failed","timed_out","succeeded","error","pending_approval","backlog","todo","in_progress","in_review","blocked","done","terminated","cancelled","pending","revision_requested","approved","rejected"].map(L=>(0,t.jsx)(ni,{status:L},L))})}),(0,t.jsx)(sr,{title:"IssueStatusBadge (brand chip + glyph — PAP-75)",children:(0,t.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:["backlog","todo","in_progress","in_review","done","blocked","cancelled"].map(L=>(0,t.jsx)(Tp,{status:L},L))})}),(0,t.jsxs)(sr,{title:"Idle Slack conversation",children:[(0,t.jsx)(Gi,{status:"in_review",externalConversationState:"waiting",showLabel:!0}),(0,t.jsx)(Tp,{status:"in_review",externalConversationState:"waiting"})]}),(0,t.jsxs)(sr,{title:"StatusIcon (interactive)",children:[(0,t.jsx)("div",{className:"flex items-center gap-3 flex-wrap",children:["backlog","todo","in_progress","in_review","done","cancelled","blocked"].map(L=>(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(Gi,{status:L}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:L})]},L))}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-2",children:[(0,t.jsx)(Gi,{status:n,onChange:a}),(0,t.jsxs)("span",{className:"text-sm",children:["Click the icon to change status (current: ",n,")"]})]})]}),!1,(0,t.jsx)(sr,{title:"Agent status dots",children:(0,t.jsx)("div",{className:"flex items-center gap-4 flex-wrap",children:["running","active","paused","error","archived"].map(L=>(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"relative flex h-2.5 w-2.5",children:(0,t.jsx)("span",{className:`inline-flex h-full w-full rounded-full ${V2e[L]??"bg-neutral-400"}`})}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:L})]},L))})}),(0,t.jsx)(sr,{title:"Run invocation badges",children:(0,t.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:[["timer","bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300"],["assignment","bg-violet-100 text-violet-700 dark:bg-violet-900/50 dark:text-violet-300"],["on_demand","bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300"],["automation","bg-muted text-muted-foreground"]].map(([L,O])=>(0,t.jsx)(ct,{variant:"ghost",className:`px-1.5 text-(length:--text-nano) ${O}`,children:L},L))})}),(0,t.jsxs)(sr,{title:"IssueReferencePill",children:[(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Used wherever a task is referenced — in markdown, the Related Work tab, and activity summaries. Pass ",(0,t.jsx)("code",{className:"font-mono",children:"status"})," to show the target issue's state at a glance. Use ",(0,t.jsx)("code",{className:"font-mono",children:'variant="property"'})," for compact badges with direct navigation. Pass ",(0,t.jsx)("code",{className:"font-mono",children:"onRemove"})," for a separate blocker removal control with reserved space. Use ",(0,t.jsx)("code",{className:"font-mono",children:"strikethrough"}),' for "removed" contexts.']}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(ad,{issue:{id:"demo-1",identifier:"PAP-123",title:"Identifier only — no status yet"}}),(0,t.jsx)(ad,{issue:{id:"demo-2",identifier:"PAP-456",title:"With in_progress status",status:"in_progress"}}),(0,t.jsx)(ad,{issue:{id:"demo-3",identifier:"PAP-789",title:"Done status",status:"done"}}),(0,t.jsx)(ad,{issue:{id:"demo-4",identifier:"PAP-101",title:"Blocked status",status:"blocked"}}),(0,t.jsx)(ad,{onRemove:r(()=>window.alert("Blocker removed"),"onRemove"),issue:{id:"demo-blocker",identifier:"PAP-303",title:"Hover or focus to remove blocker",status:"in_review"}}),(0,t.jsx)(ad,{strikethrough:!0,issue:{id:"demo-5",identifier:"PAP-202",title:"Removed (strikethrough)",status:"todo"}})]})]})]}),(0,t.jsxs)(Or,{title:"Agent Capsule",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground max-w-prose",children:['The brand "capsule is the agent" motif. A single agent reads as a tall pill that moves through three states as it comes to life. The online fill uses the live brand agent-gradient tokens (',(0,t.jsx)("code",{className:"font-mono",children:"--agent-Na"})," →"," ",(0,t.jsx)("code",{className:"font-mono",children:"--agent-Nb"}),"); ",(0,t.jsx)("code",{className:"font-mono",children:"prefers-reduced-motion"})," ","skips the liquid rise and pulses and renders the final state."]}),(0,t.jsx)(sr,{title:"States",children:(0,t.jsxs)("div",{className:"flex items-end gap-10",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Gf,{state:"slot"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"slot"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Gf,{state:"configured"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"configured"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Gf,{state:"online",gradient:5}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"online"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Gf,{state:"online",gradient:5,glow:"blue"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"online · blue glow"})]})]})}),(0,t.jsx)(sr,{title:"Sizes",children:(0,t.jsxs)("div",{className:"flex items-end gap-8",children:[(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Gf,{state:"online",size:"sm",gradient:1}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"sm"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Gf,{state:"online",size:"md",gradient:4}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"md"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Gf,{state:"online",size:"lg",gradient:8}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"lg"})]}),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)(Gf,{state:"online",size:{width:28,height:96},gradient:6}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"custom px"})]})]})}),(0,t.jsx)(sr,{title:"Gradients",children:(0,t.jsx)("div",{className:"flex items-end gap-3 flex-wrap",children:Array.from({length:10},(L,O)=>(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[(0,t.jsx)(Gf,{state:"online",size:"sm",gradient:O+1}),(0,t.jsx)("span",{className:"text-(length:--text-nano) font-mono text-muted-foreground",children:O+1})]},O))})})]}),(0,t.jsx)(Or,{title:"Form Elements",children:(0,t.jsxs)("div",{className:"grid gap-6 md:grid-cols-2",children:[(0,t.jsxs)(sr,{title:"Input",children:[(0,t.jsx)(_t,{placeholder:"Default input"}),(0,t.jsx)(_t,{placeholder:"Disabled input",disabled:!0,className:"mt-2"})]}),(0,t.jsx)(sr,{title:"Textarea",children:(0,t.jsx)(En,{placeholder:"Write something..."})}),(0,t.jsx)(sr,{title:"Checkbox & Label",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Fi,{id:"check1",defaultChecked:!0}),(0,t.jsx)(Ws,{htmlFor:"check1",children:"Checked item"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Fi,{id:"check2"}),(0,t.jsx)(Ws,{htmlFor:"check2",children:"Unchecked item"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Fi,{id:"check3",disabled:!0}),(0,t.jsx)(Ws,{htmlFor:"check3",children:"Disabled item"})]})]})}),(0,t.jsx)(sr,{title:"Inline Editor",children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"Title (single-line)"}),(0,t.jsx)(Ah,{value:v,onSave:y,as:"h2",className:"text-xl font-bold"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"Body text (single-line)"}),(0,t.jsx)(Ah,{value:f,onSave:g,as:"p",className:"text-sm"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-1",children:"Description (multiline, auto-sizing)"}),(0,t.jsx)(Ah,{value:w,onSave:S,as:"p",className:"text-sm text-muted-foreground",placeholder:"Add a description...",multiline:!0})]})]})})]})}),(0,t.jsx)(Or,{title:"Select",children:(0,t.jsxs)("div",{className:"grid gap-6 md:grid-cols-2",children:[(0,t.jsxs)(sr,{title:"Default size",children:[(0,t.jsxs)(La,{value:l,onValueChange:c,children:[(0,t.jsx)(Da,{className:"w-full",children:(0,t.jsx)(Pa,{placeholder:"Select status"})}),(0,t.jsxs)(Ma,{children:[(0,t.jsx)(Nn,{value:"backlog",children:"Backlog"}),(0,t.jsx)(Nn,{value:"todo",children:"Todo"}),(0,t.jsx)(Nn,{value:"in_progress",children:"In Progress"}),(0,t.jsx)(Nn,{value:"in_review",children:"In Review"}),(0,t.jsx)(Nn,{value:"done",children:"Done"})]})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Current value: ",l]})]}),(0,t.jsx)(sr,{title:"Small trigger",children:(0,t.jsxs)(La,{defaultValue:"high",children:[(0,t.jsx)(Da,{size:"sm",className:"w-full",children:(0,t.jsx)(Pa,{})}),(0,t.jsxs)(Ma,{children:[(0,t.jsx)(Nn,{value:"critical",children:"Critical"}),(0,t.jsx)(Nn,{value:"high",children:"High"}),(0,t.jsx)(Nn,{value:"medium",children:"Medium"}),(0,t.jsx)(Nn,{value:"low",children:"Low"})]})]})})]})}),(0,t.jsx)(Or,{title:"Dropdown Menu",children:(0,t.jsxs)(fa,{children:[(0,t.jsx)(pa,{asChild:!0,children:(0,t.jsxs)(F,{variant:"outline",size:"sm",children:["Quick Actions",(0,t.jsx)(en,{className:"h-4 w-4"})]})}),(0,t.jsxs)(xa,{align:"start",className:"w-56",children:[(0,t.jsxs)(ps,{children:[(0,t.jsx)(fs,{className:"h-4 w-4"}),"Mark as done",(0,t.jsx)(A2e,{children:"⌘D"})]}),(0,t.jsxs)(ps,{children:[(0,t.jsx)(Ww,{className:"h-4 w-4"}),"Open docs"]}),(0,t.jsx)(ui,{}),(0,t.jsx)(mz,{checked:d,onCheckedChange:r(L=>m(L===!0),"onCheckedChange"),children:"Watch issue"}),(0,t.jsxs)(ps,{variant:"destructive",children:[(0,t.jsx)(Ia,{className:"h-4 w-4"}),"Delete issue"]})]})]})}),(0,t.jsx)(Or,{title:"Popover",children:(0,t.jsxs)(nr,{children:[(0,t.jsx)(dr,{asChild:!0,children:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Open Popover"})}),(0,t.jsxs)(Wn,{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Agent heartbeat"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Last run succeeded 24s ago. Next timer run in 9m."}),(0,t.jsx)(F,{size:"xs",children:"Wake now"})]})]})}),(0,t.jsx)(Or,{title:"Collapsible",children:(0,t.jsxs)(el,{open:h,onOpenChange:p,className:"space-y-2",children:[(0,t.jsx)(Wl,{asChild:!0,children:(0,t.jsxs)(F,{variant:"outline",size:"sm",children:[h?"Hide":"Show"," advanced filters"]})}),(0,t.jsx)(tl,{className:"rounded-md border border-border p-3",children:(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(Ws,{htmlFor:"owner-filter",children:"Owner"}),(0,t.jsx)(_t,{id:"owner-filter",placeholder:"Filter by agent name"})]})})]})}),(0,t.jsx)(Or,{title:"Sheet",children:(0,t.jsxs)(Gh,{children:[(0,t.jsx)(_ce,{asChild:!0,children:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Open Side Panel"})}),(0,t.jsxs)(Qh,{side:"right",children:[(0,t.jsxs)(Fh,{children:[(0,t.jsx)(Gm,{children:"Issue Properties"}),(0,t.jsx)(US,{children:"Edit metadata without leaving the current page."})]}),(0,t.jsxs)("div",{className:"space-y-4 px-4",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Ws,{htmlFor:"sheet-title",children:"Title"}),(0,t.jsx)(_t,{id:"sheet-title",defaultValue:"Improve onboarding docs"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Ws,{htmlFor:"sheet-description",children:"Description"}),(0,t.jsx)(En,{id:"sheet-description",defaultValue:"Capture setup pitfalls and screenshots."})]})]}),(0,t.jsxs)(Cce,{children:[(0,t.jsx)(F,{variant:"outline",children:"Cancel"}),(0,t.jsx)(F,{children:"Save"})]})]})]})}),(0,t.jsx)(Or,{title:"Scroll Area",children:(0,t.jsx)(rx,{className:"h-36 rounded-md border border-border",children:(0,t.jsx)("div",{className:"space-y-2 p-3",children:Array.from({length:12}).map((L,O)=>(0,t.jsxs)("div",{className:"rounded-md border border-border p-2 text-sm",children:["Heartbeat run #",O+1,": completed successfully"]},O))})})}),(0,t.jsx)(Or,{title:"Command (CMDK)",children:(0,t.jsx)("div",{className:"rounded-md border border-border",children:(0,t.jsxs)(d5,{children:[(0,t.jsx)(r1,{placeholder:"Type a command or search..."}),(0,t.jsxs)(a1,{children:[(0,t.jsx)(i1,{children:"No results found."}),(0,t.jsxs)(zu,{heading:"Pages",children:[(0,t.jsxs)(Eo,{children:[(0,t.jsx)(hx,{className:"h-4 w-4"}),"Dashboard"]}),(0,t.jsxs)(Eo,{children:[(0,t.jsx)(od,{className:"h-4 w-4"}),"Issues"]})]}),(0,t.jsx)(Zf,{}),(0,t.jsxs)(zu,{heading:"Actions",children:[(0,t.jsxs)(Eo,{children:[(0,t.jsx)(m3e,{className:"h-4 w-4"}),"Open command palette"]}),(0,t.jsxs)(Eo,{children:[(0,t.jsx)(yn,{className:"h-4 w-4"}),"Create new issue"]})]})]})]})})}),(0,t.jsx)(Or,{title:"Breadcrumb",children:(0,t.jsx)(aU,{children:(0,t.jsxs)(iU,{children:[(0,t.jsx)(dS,{children:(0,t.jsx)(eT,{href:"#",children:"Projects"})}),(0,t.jsx)(tT,{}),(0,t.jsx)(dS,{children:(0,t.jsx)(eT,{href:"#",children:"Paperclip App"})}),(0,t.jsx)(tT,{}),(0,t.jsx)(dS,{children:(0,t.jsx)(XS,{children:"Issue List"})})]})})}),(0,t.jsxs)(Or,{title:"Cards",children:[(0,t.jsxs)(sr,{title:"Dashboard agent runs",children:[(0,t.jsx)("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:["running","queued","succeeded","failed","timed_out","cancelled","interrupted"].map(L=>(0,t.jsx)(Fye,{companyId:"design-guide",run:{id:`design-guide-${L}`,agentId:"design-guide-agent",agentName:"CodexCoder",status:L,adapterType:"codex_local",invocationSource:"on_demand",triggerDetail:"manual",startedAt:null,finishedAt:null,createdAt:"2026-09-11T12:00:00Z",issueId:"design-guide-task"},issue:{identifier:"PAP-559",title:"Recreate this wireframe on pages Paperclip",status:L==="succeeded"?"done":"in_progress"}},L))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"The dashboard and Live runs page use the same compact cards. In-progress task icons animate across the app, including between runs, to represent task workflow status. Live indicators report active execution. Open a run to view its status and transcript."})]}),(0,t.jsx)(sr,{title:"Standard Card",children:(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(Zi,{children:[(0,t.jsx)(uo,{children:"Card Title"}),(0,t.jsx)(Nl,{children:"Card description with supporting text."})]}),(0,t.jsx)(Qa,{children:(0,t.jsx)("p",{className:"text-sm",children:"Card content goes here. This is the main body area."})}),(0,t.jsxs)(cRe,{className:"gap-2",children:[(0,t.jsx)(F,{size:"sm",children:"Action"}),(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Cancel"})]})]})}),(0,t.jsx)(sr,{title:"Metric Cards",children:(0,t.jsxs)("div",{className:"grid md:grid-cols-2 xl:grid-cols-4 gap-4",children:[(0,t.jsx)(Cg,{icon:Xi,value:12,label:"Active Agents",description:"+3 this week"}),(0,t.jsx)(Cg,{icon:od,value:48,label:"Open Issues"}),(0,t.jsx)(Cg,{icon:_h,value:"$1,234",label:"Monthly Cost",description:"Under budget"}),(0,t.jsx)(Cg,{icon:rH,value:"99.9%",label:"Uptime"})]})})]}),(0,t.jsxs)(Or,{title:"Tabs",children:[(0,t.jsx)(sr,{title:"Default (pill) variant",children:(0,t.jsxs)(ki,{defaultValue:"overview",children:[(0,t.jsxs)(Uc,{children:[(0,t.jsx)(Ea,{value:"overview",children:"Overview"}),(0,t.jsx)(Ea,{value:"runs",children:"Runs"}),(0,t.jsx)(Ea,{value:"config",children:"Config"}),(0,t.jsx)(Ea,{value:"costs",children:"Costs"})]}),(0,t.jsx)(aa,{value:"overview",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Overview tab content."})}),(0,t.jsx)(aa,{value:"runs",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Runs tab content."})}),(0,t.jsx)(aa,{value:"config",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Config tab content."})}),(0,t.jsx)(aa,{value:"costs",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Costs tab content."})})]})}),(0,t.jsx)(sr,{title:"Line variant",children:(0,t.jsxs)(ki,{defaultValue:"summary",children:[(0,t.jsxs)(Uc,{variant:"line",children:[(0,t.jsx)(Ea,{value:"summary",children:"Summary"}),(0,t.jsx)(Ea,{value:"details",children:"Details"}),(0,t.jsx)(Ea,{value:"comments",children:"Comments"})]}),(0,t.jsx)(aa,{value:"summary",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Summary content with underline tabs."})}),(0,t.jsx)(aa,{value:"details",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Details content."})}),(0,t.jsx)(aa,{value:"comments",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Comments content."})})]})})]}),(0,t.jsxs)(Or,{title:"Entity Rows",children:[(0,t.jsxs)("div",{className:"border border-border rounded-md",children:[(0,t.jsx)(ed,{leading:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Gi,{status:"in_progress"}),!1]}),identifier:"PAP-001",title:"Implement authentication flow",subtitle:"Responsible: Agent Alpha",trailing:(0,t.jsx)(Tp,{status:"in_progress"}),onClick:r(()=>{},"onClick")}),(0,t.jsx)(ed,{leading:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Gi,{status:"done"}),!1]}),identifier:"PAP-002",title:"Set up CI/CD pipeline",subtitle:"Completed 2 days ago",trailing:(0,t.jsx)(Tp,{status:"done"}),onClick:r(()=>{},"onClick")}),(0,t.jsx)(ed,{leading:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Gi,{status:"todo"}),!1]}),identifier:"PAP-003",title:"Write API documentation",trailing:(0,t.jsx)(Tp,{status:"todo"}),onClick:r(()=>{},"onClick")}),(0,t.jsx)(ed,{leading:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Gi,{status:"blocked"}),!1]}),identifier:"PAP-004",title:"Deploy to production",subtitle:"Blocked by PAP-001",trailing:(0,t.jsx)(Tp,{status:"blocked"}),selected:!0})]}),(0,t.jsx)(sr,{title:"Membership action",children:(0,t.jsxs)("div",{className:"border border-border rounded-md",children:[(0,t.jsx)(ed,{title:"Joined resource",subtitle:"Hover or focus the row to reveal the reserved action slot.",className:"group",trailing:(0,t.jsx)(Ag,{state:"joined",resourceName:"Joined resource",onJoin:r(()=>{},"onJoin"),onLeave:r(()=>{},"onLeave")})}),(0,t.jsx)(ed,{title:"Left resource",subtitle:"Persistent action with dimmed row content.",className:"group text-foreground/55",trailing:(0,t.jsx)(Ag,{state:"left",resourceName:"Left resource",onJoin:r(()=>{},"onJoin"),onLeave:r(()=>{},"onLeave")})}),(0,t.jsx)(ed,{title:"Leaving resource",subtitle:"Disabled while the optimistic mutation is pending.",className:"group text-foreground/55",trailing:(0,t.jsx)(Ag,{state:"left",pending:!0,pendingState:"left",resourceName:"Leaving resource",onJoin:r(()=>{},"onJoin"),onLeave:r(()=>{},"onLeave")})}),(0,t.jsx)(ed,{title:"Joining resource",subtitle:"The target state is visible immediately while the server confirms.",className:"group",trailing:(0,t.jsx)(Ag,{state:"joined",pending:!0,pendingState:"joined",resourceName:"Joining resource",onJoin:r(()=>{},"onJoin"),onLeave:r(()=>{},"onLeave")})})]})})]}),(0,t.jsxs)(Or,{title:"Filter Bar",children:[(0,t.jsx)(RK,{filters:j,onRemove:r(L=>N(O=>O.filter($=>$.key!==L)),"onRemove"),onClear:r(()=>N([]),"onClear")}),j.length===0&&(0,t.jsx)(F,{variant:"outline",size:"sm",onClick:r(()=>N([{key:"status",label:"Status",value:"Active"}]),"onClick"),children:"Reset filters"})]}),(0,t.jsxs)(Or,{title:"Avatars",children:[(0,t.jsx)(sr,{title:"Sizes",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(Yi,{size:"sm",children:(0,t.jsx)(Ji,{children:"SM"})}),(0,t.jsx)(Yi,{children:(0,t.jsx)(Ji,{children:"DF"})}),(0,t.jsx)(Yi,{size:"lg",children:(0,t.jsx)(Ji,{children:"LG"})})]})}),(0,t.jsx)(sr,{title:"Group",children:(0,t.jsxs)(Ice,{children:[(0,t.jsx)(Yi,{children:(0,t.jsx)(Ji,{children:"A1"})}),(0,t.jsx)(Yi,{children:(0,t.jsx)(Ji,{children:"A2"})}),(0,t.jsx)(Yi,{children:(0,t.jsx)(Ji,{children:"A3"})}),(0,t.jsx)(S2e,{children:"+5"})]})})]}),(0,t.jsx)(Or,{title:"App logos",children:(0,t.jsx)(sr,{title:"Official marks and runtime fallback",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(yc,{name:"Notion",logoUrl:"/brands/apps/notion.svg",darkLogoUrl:"/brands/apps/notion-dark.svg",size:36}),(0,t.jsx)(yc,{name:"Jira",logoUrl:"/brands/apps/jira.svg",darkLogoUrl:"/brands/apps/jira-dark.svg",size:44}),(0,t.jsx)(yc,{name:"Fallback",logoUrl:"/brands/apps/does-not-exist.svg",size:36})]})})}),(0,t.jsxs)(Or,{title:"Agent personas",children:[(0,t.jsx)(sr,{title:"Stable palette identities",children:(0,t.jsx)("div",{className:"flex flex-wrap gap-3",children:IIe.map(L=>(0,t.jsx)(pr,{appearance:RIe(L),size:48,label:L},L))})}),(0,t.jsxs)(sr,{title:"Onboarding and live character",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Place one live character beside the agent name. Onboarding uses a larger padded frame. Onboarding and agent headers follow the pointer across the page; other placements track within their region. Full-page examples are in Storybook under Agents / Personas / Full pages."}),(0,t.jsxs)("div",{className:"flex gap-4",children:[(0,t.jsx)(uC,{muted:!0,state:"sleepy",motion:"still",size:128}),(0,t.jsx)(uC,{size:128})]})]})]}),(0,t.jsxs)(Or,{title:"Human identity",children:[(0,t.jsx)(sr,{title:"Sizes",children:(0,t.jsxs)("div",{className:"flex items-center gap-6",children:[(0,t.jsx)(Fl,{name:"Alex Morgan",size:"sm"}),(0,t.jsx)(Fl,{name:"Alex Morgan"}),(0,t.jsx)(Fl,{name:"Alex Morgan",size:"lg"})]})}),(0,t.jsx)(sr,{title:"Initials derivation",children:(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(Fl,{name:"Casey Jordan",size:"sm"}),(0,t.jsx)(Fl,{name:"Alpha",size:"sm"}),(0,t.jsx)(Fl,{name:"Quinn Lee",size:"sm"})]})}),(0,t.jsx)(sr,{title:"Custom initials",children:(0,t.jsx)(Fl,{name:"Backend Service",initials:"BS",size:"sm"})})]}),(0,t.jsx)(Or,{title:"Tooltips",children:(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Hover me"})}),(0,t.jsx)(Un,{children:"This is a tooltip"})]}),(0,t.jsxs)(qn,{children:[(0,t.jsx)(zn,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-sm",children:(0,t.jsx)(Ld,{})})}),(0,t.jsx)(Un,{children:"Settings"})]})]})}),(0,t.jsx)(Or,{title:"Dialog",children:(0,t.jsxs)(Js,{children:[(0,t.jsx)(zw,{asChild:!0,children:(0,t.jsx)(F,{variant:"outline",children:"Open Dialog"})}),(0,t.jsxs)(Zs,{children:[(0,t.jsxs)(Sn,{children:[(0,t.jsx)(rn,{children:"Dialog Title"}),(0,t.jsx)(Mn,{children:"This is a sample dialog showing the standard layout with header, content, and footer."})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(Ws,{children:"Name"}),(0,t.jsx)(_t,{placeholder:"Enter a name",className:"mt-1.5"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(Ws,{children:"Description"}),(0,t.jsx)(En,{placeholder:"Describe...",className:"mt-1.5"})]})]}),(0,t.jsxs)(br,{children:[(0,t.jsx)(F,{variant:"outline",children:"Cancel"}),(0,t.jsx)(F,{children:"Save"})]})]})]})}),(0,t.jsx)(Or,{title:"Empty State",children:(0,t.jsx)("div",{className:"border border-border rounded-md",children:(0,t.jsx)(Tn,{icon:Ed,message:"No items to show. Create your first one to get started.",action:"Create Item",onAction:r(()=>{},"onAction")})})}),(0,t.jsx)(Or,{title:"Progress Bars (Budget)",children:(0,t.jsx)("div",{className:"space-y-3",children:[{label:"Under budget (40%)",pct:40,color:"bg-green-400"},{label:"Warning (75%)",pct:75,color:"bg-yellow-400"},{label:"Over budget (95%)",pct:95,color:"bg-red-400"}].map(({label:L,pct:O,color:$})=>(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:L}),(0,t.jsxs)("span",{className:"text-xs font-mono",children:[O,"%"]})]}),(0,t.jsx)("div",{className:"w-full h-2 bg-muted rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:`h-full rounded-full transition-(--tp-width-background-color) duration-150 ${$}`,style:{width:`${O}%`}})})]},L))})}),(0,t.jsx)(Or,{title:"Log Viewer",children:(0,t.jsxs)("div",{className:"bg-neutral-950 rounded-lg p-3 font-mono text-xs max-h-80 overflow-y-auto",children:[(0,t.jsx)("div",{className:"text-foreground",children:"[12:00:01] INFO Agent started successfully"}),(0,t.jsx)("div",{className:"text-foreground",children:"[12:00:02] INFO Processing task PAP-001"}),(0,t.jsx)("div",{className:"text-yellow-400",children:"[12:00:05] WARN Rate limit approaching (80%)"}),(0,t.jsx)("div",{className:"text-foreground",children:"[12:00:08] INFO Task PAP-001 completed"}),(0,t.jsx)("div",{className:"text-red-400",children:"[12:00:12] ERROR Connection timeout to upstream service"}),(0,t.jsx)("div",{className:"text-blue-300",children:"[12:00:12] SYS Retrying connection in 5s..."}),(0,t.jsx)("div",{className:"text-foreground",children:"[12:00:17] INFO Reconnected successfully"}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"relative flex h-1.5 w-1.5",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full bg-blue-400 animate-pulse"}),(0,t.jsx)("span",{className:"inline-flex h-full w-full rounded-full bg-blue-500"})]}),(0,t.jsx)("span",{className:"text-blue-600 dark:text-blue-400",children:"Live"})]})]})}),(0,t.jsx)(Or,{title:"Property Row Pattern",children:(0,t.jsxs)("div",{className:"border border-border rounded-md p-4 space-y-1 max-w-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Status"}),(0,t.jsx)(ni,{status:"active"})]}),!1,(0,t.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Responsible"}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(Yi,{size:"sm",children:(0,t.jsx)(Ji,{children:"A"})}),(0,t.jsx)("span",{className:"text-xs",children:"Agent Alpha"})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between py-1.5",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Created"}),(0,t.jsx)("span",{className:"text-xs",children:"Jan 15, 2025"})]})]})}),(0,t.jsxs)(Or,{title:"Navigation Patterns",children:[(0,t.jsxs)(sr,{title:"Independent MCP connections",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Zapier, Arcade, Composio and Executor each own a connection. Their controlled setup views share Access → Connect. Tool discovery completes setup. Saved connections reuse the standard Permissions action list and per-action Test dialog. Storybook’s Apps / Connections groups use in-memory provider fixtures."}),(0,t.jsx)(W6t,{})]}),(0,t.jsxs)(sr,{title:"Setup wizard",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Shared by connection setup and trigger previews. Setup navigation takes over the section sidebar; each step owns a single footer."}),(0,t.jsxs)("div",{className:"max-w-sm space-y-6",children:[(0,t.jsx)(N5,{inline:!0,labels:["Choose trigger","Configure","Review"],step:e,availableStep:2,onSelect:s}),(0,t.jsx)(Ub,{onSaveExit:r(()=>s(0),"onSaveExit"),children:(0,t.jsx)(F,{onClick:r(()=>s((e+1)%3),"onClick"),children:"Continue"})})]})]}),(0,t.jsx)(sr,{title:"Agent chat picker",children:(0,t.jsx)(Dzt,{})}),(0,t.jsxs)(sr,{title:"Sidebar nav items",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Layout accepts sidebarSections to compose additional SidebarSection groups inside the shared sidebar. Use SidebarNavItem for each row, with sibling action buttons for starring or menus. The Chats section shows starred agents, the earliest-created agent when unstarred, then four recent agents without duplicates. Compose and star controls share a vertical column. Compose appears on hover or keyboard focus and remains visible on touch; starred icons remain visible. The picker searches all company agents by name or role without a subtitle, count, continuation labels, or footer. Task breadcrumbs support leading identity and trailing actions beside the label, including single-item task headers; see the Agent chat Storybook."}),(0,t.jsxs)(Xs,{className:"block w-60 p-3 space-y-0.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium bg-accent text-accent-foreground",children:[(0,t.jsx)(hx,{className:"h-4 w-4"}),"Dashboard"]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground cursor-pointer",children:[(0,t.jsx)(od,{className:"h-4 w-4"}),"Issues",(0,t.jsx)(ct,{variant:"ghost",className:"ml-auto bg-primary text-primary-foreground px-1.5",children:"12"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground cursor-pointer",children:[(0,t.jsx)(Xi,{className:"h-4 w-4"}),"Agents"]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-md text-sm font-medium text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground cursor-pointer",children:[(0,t.jsx)(Rd,{className:"h-4 w-4"}),"Projects"]})]})]}),(0,t.jsx)(sr,{title:"View toggle",children:(0,t.jsxs)("div",{className:"flex items-center border border-border rounded-md w-fit",children:[(0,t.jsxs)("button",{className:"px-3 py-1.5 text-xs font-medium bg-accent text-foreground rounded-l-md",children:[(0,t.jsx)(pH,{className:"h-3.5 w-3.5 inline mr-1"}),"List"]}),(0,t.jsxs)("button",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent/50 rounded-r-md",children:[(0,t.jsx)(vx,{className:"h-3.5 w-3.5 inline mr-1"}),"Org"]})]})})]}),(0,t.jsx)(Or,{title:"Grouped List (Issues pattern)",children:(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 bg-muted/50 rounded-t-md",children:[(0,t.jsx)(Gi,{status:"in_progress"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:"In Progress"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground ml-1",children:"2"})]}),(0,t.jsxs)("div",{className:"border border-border rounded-b-md",children:[(0,t.jsx)(ed,{leading:void 0,identifier:"PAP-101",title:"Build agent heartbeat system",onClick:r(()=>{},"onClick")}),(0,t.jsx)(ed,{leading:void 0,identifier:"PAP-102",title:"Add cost tracking dashboard",onClick:r(()=>{},"onClick")})]})]})}),(0,t.jsx)(Or,{title:"Comment Thread Pattern",children:(0,t.jsxs)("div",{className:"space-y-3 max-w-2xl",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:"Comments (2)"}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Agent"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Jan 15, 2025"})]}),(0,t.jsx)("p",{className:"text-sm",children:"Started working on the authentication module. Will need API keys configured."})]}),(0,t.jsxs)("div",{className:"rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Human"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Jan 16, 2025"})]}),(0,t.jsx)("p",{className:"text-sm",children:"API keys have been added to the vault. Please proceed."})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(En,{placeholder:"Leave a comment...",rows:3}),(0,t.jsx)(F,{size:"sm",children:"Comment"})]})]})}),(0,t.jsx)(Or,{title:"Cost Table Pattern",children:(0,t.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,t.jsxs)("table",{className:"w-full text-xs",children:[(0,t.jsx)("thead",{className:"border-b border-border bg-accent/20",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Model"}),(0,t.jsx)("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Tokens"}),(0,t.jsx)("th",{className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Cost"})]})}),(0,t.jsxs)("tbody",{children:[(0,t.jsxs)("tr",{className:"border-b border-border",children:[(0,t.jsx)("td",{className:"px-3 py-2",children:"claude-sonnet-4-20250514"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono",children:"1.2M"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono",children:"$18.00"})]}),(0,t.jsxs)("tr",{className:"border-b border-border",children:[(0,t.jsx)("td",{className:"px-3 py-2",children:"claude-haiku-4-20250506"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono",children:"500k"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono",children:"$1.25"})]}),(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{className:"px-3 py-2 font-medium",children:"Total"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono",children:"1.7M"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono font-medium",children:"$19.25"})]})]})]})})}),(0,t.jsxs)(Or,{title:"Skeletons",children:[(0,t.jsx)(sr,{title:"Individual",children:(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(bn,{className:"h-4 w-48"}),(0,t.jsx)(bn,{className:"h-8 w-full max-w-sm"}),(0,t.jsx)(bn,{className:"h-20 w-full"})]})}),(0,t.jsx)(sr,{title:"Page Skeleton (list)",children:(0,t.jsx)("div",{className:"border border-border rounded-md p-4",children:(0,t.jsx)(Na,{variant:"list"})})}),(0,t.jsx)(sr,{title:"Page Skeleton (detail)",children:(0,t.jsx)("div",{className:"border border-border rounded-md p-4",children:(0,t.jsx)(Na,{variant:"detail"})})})]}),(0,t.jsx)(Or,{title:"Separator",children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Horizontal"}),(0,t.jsx)(ml,{}),(0,t.jsxs)("div",{className:"flex items-center gap-4 h-8",children:[(0,t.jsx)("span",{className:"text-sm",children:"Left"}),(0,t.jsx)(ml,{orientation:"vertical"}),(0,t.jsx)("span",{className:"text-sm",children:"Right"})]})]})}),(0,t.jsxs)(Or,{title:"Team Catalog",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Components from the Team Catalog browse/install surface (",(0,t.jsx)("code",{className:"font-mono text-xs",children:"/teams-catalog"}),"). Fixtures are shared with the Storybook stories."]}),(0,t.jsxs)(sr,{title:"TeamRow (browse list)",children:[(0,t.jsxs)("div",{className:"w-(--sz-28rem) rounded-md border border-border",children:[(0,t.jsx)("div",{className:"px-3 py-2 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Bundled · 1"}),(0,t.jsx)(QA,{team:gc,selected:!0,onSelect:r(()=>{},"onSelect")}),(0,t.jsx)("div",{className:"px-3 py-2 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Optional · 2"}),(0,t.jsx)(QA,{team:_zt,selected:!1,onSelect:r(()=>{},"onSelect")}),(0,t.jsx)("div",{className:"px-3 py-2 text-(length:--text-micro) font-semibold uppercase tracking-wide text-muted-foreground",children:"Installed · 2"}),(0,t.jsx)(QA,{team:gc,selected:!1,onSelect:r(()=>{},"onSelect"),installed:o1e}),(0,t.jsx)(QA,{team:koe,selected:!1,onSelect:r(()=>{},"onSelect"),installed:Izt})]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Installed teams collapse under ",(0,t.jsx)("code",{className:"font-mono",children:"INSTALLED · N"}),"; an out-of-date install (server ",(0,t.jsx)("code",{className:"font-mono",children:"originHash"})," ≠ catalog ",(0,t.jsx)("code",{className:"font-mono",children:"contentHash"}),") shows the amber ",(0,t.jsx)("code",{className:"font-mono",children:"↑"})," badge (PAP-10256)."]})]}),(0,t.jsxs)(sr,{title:"TeamCard (onboarding grid)",children:[(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Square tile for the onboarding “Pick a starter team” grid. Selected tile gets"," ",(0,t.jsx)("code",{className:"font-mono",children:"ring-2 ring-ring"}),". Drives the"," ",(0,t.jsx)("code",{className:"font-mono",children:"useInstallTeamCatalogEntry"})," simplified flow."]}),(0,t.jsx)(Ezt,{})]}),(0,t.jsx)(sr,{title:"TeamHierarchyPreview",children:(0,t.jsx)("div",{className:"max-w-md",children:(0,t.jsx)(gzt,{team:gc})})}),(0,t.jsx)(sr,{title:"RequiredSkillsList",children:(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(vzt,{skills:gc.requiredSkills})})}),(0,t.jsx)(sr,{title:"EnvInputsList",children:(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(yzt,{inputs:gc.envInputs})})}),(0,t.jsx)(sr,{title:"ExternalSourcesList",children:(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(jzt,{sources:gc.sourceRefs})})}),(0,t.jsx)(sr,{title:"Source policy step (StepSourcePolicy)",children:(0,t.jsx)("div",{className:"max-w-xl rounded-md border border-border p-4",children:(0,t.jsx)(wzt,{team:koe,allowExternalSources:_,allowUnpinnedOptionalSources:C,allowLocalPathSources:T,onChange:r((L,O)=>{L==="external"&&A(O),L==="unpinned"&&I(O),L==="localPath"&&R(O)},"onChange")})})}),(0,t.jsx)(sr,{title:"Skill plan step (StepSkillPlan)",children:(0,t.jsx)("div",{className:"max-w-xl rounded-md border border-border p-4",children:(0,t.jsx)(kzt,{team:gc,preparations:Azt})})})]}),(0,t.jsx)(Or,{title:"Common Icons (Lucide)",children:(0,t.jsx)("div",{className:"grid grid-cols-4 md:grid-cols-6 gap-4",children:[["Inbox",Ed],["ListTodo",pH],["CircleDot",od],["Hexagon",Rd],["Target",vx],["LayoutDashboard",hx],["Bot",Xi],["DollarSign",_h],["History",Sl],["Search",ha],["Plus",yn],["Trash2",Ia],["Settings",Ld],["User",bc],["Mail",wce],["Upload",Zj],["Zap",rH]].map(([L,O])=>(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5 p-2",children:[(0,t.jsx)(O,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground font-mono",children:L})]},L))})}),(0,t.jsx)(Or,{title:"Keyboard Shortcuts",children:(0,t.jsx)("div",{className:"border border-border rounded-md divide-y divide-border text-sm",children:[["Cmd+K / Ctrl+K","Open Command Palette"],["C","New Issue (outside inputs)"],["[","Toggle Sidebar"],["]","Toggle Properties Panel"],["Cmd+Enter / Ctrl+Enter","Submit markdown comment"]].map(([L,O])=>(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:O}),(0,t.jsx)("kbd",{className:"px-2 py-0.5 text-xs font-mono bg-muted rounded border border-border",children:L})]},L))})}),(0,t.jsxs)(Or,{title:"Issue Output Surface",children:[(0,t.jsx)(sr,{title:"Multiple outputs (primary video + 'Also produced')",children:(0,t.jsx)(y3,{workProducts:Rzt})}),(0,t.jsx)(sr,{title:"Degraded output (invalid / failed attachment metadata)",children:(0,t.jsx)(y3,{workProducts:Tzt})}),(0,t.jsx)(sr,{title:"Empty state",children:(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"When an issue has produced no artifact work products, the Output section renders nothing at all (no placeholder card)."})})]}),(0,t.jsxs)(Or,{title:"Tools & Access",children:[(0,t.jsxs)(sr,{title:"EnforcementBanner — default / denied-detected",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(ib,{companyId:"",forceVariant:"default",recentDenialCount:0}),(0,t.jsx)(ib,{companyId:"",forceVariant:"denied-detected",recentDenialCount:3})]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Persistent at the top of the Tools & Access surface. Tints to ",(0,t.jsx)("code",{children:"denied-detected"})," when governed tool calls were denied or failed in the last hour. Observability only — enforcement lives in the tool gateway."]})]}),(0,t.jsxs)(sr,{title:"EnforcementBanner — presentational tones (info / warning / error)",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(ib,{tone:"info",title:"Effective access — server resolved.",body:"This is exactly what the tool gateway will accept. Profile and policy edits reflect within ~5s; the prompt cannot expand it."}),(0,t.jsx)(ib,{tone:"warning",title:"Local stdio is local code execution, not a security sandbox.",body:"A local-stdio slot runs with the orchestrator's privileges. Only bind trusted commands; quarantine anything you would not run yourself."}),(0,t.jsx)(ib,{tone:"error",title:"Runtime failed closed.",body:"The supervisor is restarting (attempt 2/3). The gateway returns runtime-error and the agent does not see partial output."})]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Static governance copy with a tone. Used for the PAP-10400 trust-tier banner on Runtime and the effective-access banner on Agent → Tools. Pass ",(0,t.jsx)("code",{children:"title"}),"/",(0,t.jsx)("code",{children:"body"})," and an optional"," ",(0,t.jsx)("code",{children:"icon"}),"."]})]}),(0,t.jsxs)(sr,{title:"Action approval card — pending / stale (surfaces 11/12)",children:[(0,t.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,t.jsx)(K6,{toolName:"slack.post_message",risk:"medium",isWrite:!0,binding:{application:"Slack",manifestVersion:"2.4.1",connection:"https://slack.com/api · acme-workspace",catalogSha256:"sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",payloadSha256:"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"},input:{channel:"#launch",text:"Deploy v2 is live 🎉",unfurl_links:!1},reason:"This tool can write to your workspace, so a human signs off before the agent posts.",policyNumber:7,expiresInLabel:"expires in 23h 51m"}),(0,t.jsx)(K6,{variant:"stale",toolName:"slack.post_message",risk:"medium",isWrite:!0,binding:{application:"Slack",manifestVersion:"2.4.1",connection:"https://slack.com/api · acme-workspace",catalogSha256:"sha256:7d793037a0760186574b0282f2f435e7a4b1b2b0b822cd15d6c15b0f00a0e3f1",previousCatalogSha256:"sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",payloadSha256:"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"},input:{channel:"#launch",text:"Deploy v2 is live 🎉",unfurl_links:!1},reason:"This tool can write to your workspace, so a human signs off before the agent posts.",policyNumber:7,expiresInLabel:"expires in 18h 02m"})]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Signed payload sha256 + expiry surface on every variant (PAP-10400). The"," ",(0,t.jsx)("code",{children:"stale"})," variant tints the border amber, banners the catalog-hash mismatch, strikes through the previous hash next to the current one, and renders ",(0,t.jsx)("code",{children:"Approve"})," disabled until the request is re-issued."]})]}),(0,t.jsxs)(sr,{title:"Action approval card — mobile (390×844, surface 99)",children:[(0,t.jsx)("div",{className:"w-(--sz-390px) max-w-full rounded-xl border border-border bg-background p-3",children:(0,t.jsx)(rzt,{toolName:"slack.post_message",risk:"medium",isWrite:!0,binding:{application:"Slack",manifestVersion:"2.4.1",connection:"https://slack.com/api · acme-workspace",catalogSha256:"sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",payloadSha256:"sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"},input:{channel:"#launch",text:"Deploy v2 is live 🎉"},reason:"This tool can write to your workspace, so a human signs off before the agent posts.",policyNumber:7,expiresInLabel:"expires in 23h 51m"})}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Identical content; the three buttons stack full-width in the order Approve / Deny / Edit & re-sign, and the bindings table uses a 70px label column."})]}),(0,t.jsxs)(sr,{title:"BindingsTable (reused in the audit row drilldown)",children:[(0,t.jsx)(s1e,{rows:[{label:"Application",value:"Slack · manifest v2.4.1"},{label:"Connection",value:"https://slack.com/api · acme-workspace",mono:!0},{label:"Catalog",value:"sha256:9f86d081…f00a08",mono:!0},{label:"Payload",value:"sha256:2c26b46b…66e7ae",mono:!0}]}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Two-column key/value block with mono values. Lives inside ",(0,t.jsx)("code",{children:"ActionCard"})," and is reused standalone in the audit row drilldown."]})]}),(0,t.jsxs)(sr,{title:"Tool-access status keys (StatusBadge)",children:[(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:["allowed","denied","block","require-approval","redacted","rate-limit","deferred","hidden","quarantined","healthy","degraded","runtime-error","unchecked"].map(L=>(0,t.jsx)(ni,{status:L},L))}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Policy decisions, connection/runtime health, and catalog quarantine all route through the canonical"," ",(0,t.jsx)("code",{children:"StatusBadge"})," keys defined in ",(0,t.jsx)("code",{children:"lib/status-colors"}),"."]})]}),(0,t.jsx)(sr,{title:"EmptyState (canonical, with description + action)",children:(0,t.jsx)(Tn,{icon:Ed,message:"No connections yet",description:"Add a connection to an application to configure credentials and discover its tools.",action:"New connection",onAction:r(()=>{},"onAction")})})]}),(0,t.jsxs)(Or,{title:"Source Repositories",children:[(0,t.jsx)(sr,{title:"Empty and disconnected",children:(0,t.jsx)(BO,{selected:[],onChange:r(()=>{},"onChange"),state:"disconnected",onConnect:r(()=>{},"onConnect"),onRetry:r(()=>{},"onRetry")})}),(0,t.jsx)(sr,{title:"Selected and searchable",children:(0,t.jsx)(BO,{selected:[{id:"1",fullName:"paperclipai/paperclip",url:"https://github.com/paperclipai/paperclip",connections:["Your GitHub"]}],available:[{id:"2",fullName:"paperclipai/docs",url:"https://github.com/paperclipai/docs",connections:["Company GitHub"]}],onChange:r(()=>{},"onChange"),onConnect:r(()=>{},"onConnect"),onRetry:r(()=>{},"onRetry")})}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading, errors, empty search, mobile, and short viewports are covered in the Project repos Storybook stories."})]}),(0,t.jsxs)(Or,{title:"Environment Variables Editor",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Reusable env-var editor (agents, projects, environments, routines). One shared grid, an in-field Text/Secret source switch, a fuzzy secret picker with a pinned “Create secret” item, automatic sensitive-value detection, and inline secret-health warnings. See the Storybook ",(0,t.jsx)("span",{className:"font-mono",children:"Product/Environment Variables Editor"})," stories for all 10 states."]}),(0,t.jsx)(Pzt,{})]}),(0,t.jsxs)(Or,{title:"Tasks created from a task",children:[(0,t.jsx)(sr,{title:"Subtasks and created work are independent",children:(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(qk,{subtasks:[GA],createdTasks:[{...GA,projectId:"design-board",project:{id:"design-board",name:"Board UI"}},{...GA,id:"design-followup",identifier:"PAP-428",title:"Write release notes",status:"todo",projectId:null}],projects:[]})})}),(0,t.jsxs)(sr,{title:"Empty, loading and failed",children:[(0,t.jsx)(qk,{subtasks:[],createdTasks:[],projects:[]}),(0,t.jsx)(qk,{subtasks:[],createdTasks:[],projects:[],isLoading:!0}),(0,t.jsx)(qk,{subtasks:[],createdTasks:[],projects:[],hasError:!0,onRetry:r(()=>{},"onRetry")})]})]}),(0,t.jsx)(Or,{title:"Execution recovery",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Recovery runs in the background. Task lists keep their ordinary status without execution badges. Active transcript headers keep saying Working during automatic recovery. Recovery decisions and attempts belong in the run log; there is no execution status card or reconciliation form."})}),(0,t.jsxs)(Or,{title:"Saved provider API keys",children:[(0,t.jsx)(Cj,{options:[{id:"example",label:"Claude API key (Your key)",binding:{type:"user_secret_ref",key:"ANTHROPIC_API_KEY",version:"latest"}}],value:"example",onChange:r(()=>{},"onChange"),loading:!1,error:!1}),(0,t.jsx)(Cj,{options:[],value:"",onChange:r(()=>{},"onChange"),loading:!0,error:!1}),(0,t.jsx)(Cj,{options:[],value:"",onChange:r(()=>{},"onChange"),loading:!1,error:!0})]}),(0,t.jsxs)(Or,{title:"Connection Intent",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"The task card is the dialog host for the shared connection setup flow. Provider forms, validation, OAuth, access selection, and completion come from the same feature module as the full-page Apps setup; this card owns only audience, dialog, and task refresh behavior. Pending connections stay in the timeline beside a usable composer. The independently addressable Connections/In-task connections stories cover access, OAuth recovery, narrow layouts, completion, and historical outcomes."}),(0,t.jsxs)("div",{className:"grid gap-4 xl:grid-cols-3",children:[(0,t.jsx)(ef,{interaction:lzt,currentUserId:$r.currentUserId}),(0,t.jsx)(ef,{interaction:czt,currentUserId:$r.currentUserId}),(0,t.jsx)(ef,{interaction:dzt,currentUserId:$r.currentUserId})]})]}),(0,t.jsxs)(Or,{title:"Resizable Panels",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Design-system wrapper over ",(0,t.jsx)("span",{className:"font-mono",children:"react-resizable-panels"})," ","(Skill Studio D2). Drag a handle to resize; panels accept percentage or pixel (",(0,t.jsx)("span",{className:"font-mono",children:'minSize="240px"'}),") constraints and the middle panel is collapsible. Use anywhere a split view is needed."]}),(0,t.jsx)("div",{className:"h-48 max-w-2xl overflow-hidden rounded-md border border-border",children:(0,t.jsxs)(z7,{children:[(0,t.jsx)(Mb,{id:"a",minSize:"120px",className:"bg-muted/30",children:(0,t.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"Panel A"})}),(0,t.jsx)(VC,{}),(0,t.jsx)(Mb,{id:"b",minSize:"120px",collapsible:!0,collapsedSize:"40px",className:"bg-muted/10",children:(0,t.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"Panel B (collapsible)"})}),(0,t.jsx)(VC,{}),(0,t.jsx)(Mb,{id:"c",minSize:"120px",className:"bg-muted/30",children:(0,t.jsx)("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"Panel C"})})]})})]}),(0,t.jsx)(Or,{title:"Webhook URL warnings",children:(0,t.jsx)("div",{className:"space-y-3",children:["http://localhost:3100","https://paperclip.internal","https://paperclip.example-tailnet.ts.net","http://paperclip.example.com","not-a-url"].map(L=>(0,t.jsx)(o7,{url:L},L))})}),(0,t.jsxs)(Or,{title:"Inline Banner",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Token-backed full-width notice (",(0,t.jsx)("span",{className:"font-mono",children:"brandBanner"})," tones). Use"," ",(0,t.jsx)("span",{className:"font-mono",children:"info"})," for provenance/context and"," ",(0,t.jsx)("span",{className:"font-mono",children:"warning"})," for paused/attention. Supports an optional bold title and a trailing actions slot. Replaces hand-rolled"," ",(0,t.jsx)("span",{className:"font-mono",children:"bg-yellow-*"}),"/",(0,t.jsx)("span",{className:"font-mono",children:"bg-blue-*"})," ","banners."]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)(Ja,{tone:"info",title:"Built-in agent",actions:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Reset to defaults"}),children:["Ships with Paperclip and powers ",(0,t.jsx)("strong",{children:"Briefs"}),". It can be paused but not deleted."]}),(0,t.jsx)(Ja,{tone:"warning",title:"Briefs is paused.",actions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(F,{variant:"ghost",size:"sm",children:"View agent"}),(0,t.jsx)(F,{size:"sm",children:"Resume agent"})]}),children:"Its built-in agent was paused 2 days ago, so new briefs aren't being generated."}),(0,t.jsx)(Ja,{tone:"danger",title:"Summary generation failed.",actions:(0,t.jsx)(F,{size:"sm",children:"Retry"}),children:"The linked issue reached a terminal state before a summary was written."}),(0,t.jsx)(Ja,{tone:"info",compact:!0,children:"Compact variant for embedding inside dialogs and modals."})]})]}),(0,t.jsxs)(Or,{title:"Media artifacts",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Images and videos use gallery tiles. The whole tile opens the task gallery; files and links keep compact, fully clickable rows. Task/Artifact Gallery in Storybook covers playable videos, mixed files, narrow panels, and unavailable previews."}),(0,t.jsxs)("div",{className:"grid max-w-2xl grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,t.jsx)(BT,{id:"design-image",title:"Launch artwork",contentPath:"/announcement-preview.svg",contentType:"image/svg+xml",originalFilename:"launch.svg",detail:"Image"}),(0,t.jsx)(BT,{id:"design-video",title:"Video preview unavailable",contentPath:"",contentType:"video/mp4",originalFilename:"preview.mp4",detail:"Video"})]})]}),(0,t.jsx)(Or,{title:"AI Connections",children:(0,t.jsx)(J6t,{})}),(0,t.jsxs)(Or,{title:"Built-in Agent Lifecycle Chips",children:[(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["A derived lifecycle chip (amber) for attention states. The lifecycle chip is separate from the agent status vocabulary and only shows for"," ",(0,t.jsx)("span",{className:"font-mono",children:"needs_setup"})," / ",(0,t.jsx)("span",{className:"font-mono",children:"pending_approval"}),"."]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,t.jsx)(wj,{status:"needs_setup"}),(0,t.jsx)(wj,{status:"pending_approval"}),(0,t.jsx)(wj,{status:"needs_setup",compact:!0})]}),(0,t.jsxs)("p",{className:"mt-3 text-sm text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-mono",children:"<BuiltInAgentGate agentKey>"})," composes"," ",(0,t.jsx)("span",{className:"font-mono",children:"PageSkeleton"})," + ",(0,t.jsx)("span",{className:"font-mono",children:"EmptyState"})," ","+ ",(0,t.jsx)("span",{className:"font-mono",children:"InlineBanner"})," to render the loading / setup / pending-approval / paused / ready states of a feature that depends on a built-in agent."]})]})]})}r(Lzt,"DesignGuide");function $zt(e,s){return e?.enableWorktreeRunExecution!==!0?{kind:"off"}:e.worktreeRunExecutionActivatedAt?s?e.worktreeRunExecutionActivationInstanceId!==s?{kind:"fail_closed",reason:"instance_mismatch"}:{kind:"armed",activatedAt:e.worktreeRunExecutionActivatedAt}:{kind:"fail_closed",reason:"missing_instance_id"}:{kind:"fail_closed",reason:"missing_cutoff"}}r($zt,"resolveWorktreeRunExecutionDisplayState");function Ozt(e){const s=new Date(e);return Number.isNaN(s.getTime())?e:s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}r(Ozt,"formatActivationTimestamp");function l1e(){return(0,t.jsxs)(ct,{variant:"outline",className:"text-muted-foreground",children:[(0,t.jsx)(Md,{"aria-hidden":"true"}),"Managed by Paperclip Cloud"]})}r(l1e,"ManagedByCloudBadge");function Co({title:e,description:s,footnote:n,checked:a,onCheckedChange:i,disabled:o,settingKey:l,managed:c,ariaLabel:d}){const{hidden:m}=Zm(),h=c?.managed===!0;return m.has(vle(l))?null:(0,t.jsx)(Xs,{className:"block bg-transparent p-5",children:(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:e}),h?(0,t.jsx)(l1e,{}):null]}),(0,t.jsx)("p",{className:"max-w-2xl text-sm text-muted-foreground",children:s}),n?(0,t.jsx)("p",{className:"max-w-2xl text-xs text-muted-foreground",children:n}):null]}),(0,t.jsx)(_i,{checked:a,onCheckedChange:r(p=>{h||i(p)},"onCheckedChange"),disabled:o||h,"aria-label":d})]})})}r(Co,"ExperimentalToggleCard");function Fzt(){const{setBreadcrumbs:e}=Ln(),s=Kt(),{hidden:n}=Zm(),[a,i]=(0,u.useState)(null);(0,u.useEffect)(()=>{e([{label:"Settings",href:"/company/settings"},{label:"Experimental"}])},[e]);const o=ee({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Ir.getExperimental(),"queryFn")}),l=ke({mutationFn:r(async Z=>Ir.updateExperimental(Z),"mutationFn"),onMutate:r(async Z=>{await s.cancelQueries({queryKey:P.instance.experimentalSettings});const Y=s.getQueryData(P.instance.experimentalSettings);return Y&&s.setQueryData(P.instance.experimentalSettings,{...Y,...Z}),{previousSettings:Y}},"onMutate"),onSuccess:r(async Z=>{i(null),s.setQueryData(P.instance.experimentalSettings,Z),await Promise.all([s.invalidateQueries({queryKey:P.instance.experimentalSettings}),s.invalidateQueries({queryKey:P.adapters.all}),s.invalidateQueries({queryKey:["built-in-agents"]}),s.invalidateQueries({queryKey:P.health}),s.invalidateQueries({queryKey:["apps"]})])},"onSuccess"),onError:r((Z,Y,G)=>{G?.previousSettings&&s.setQueryData(P.instance.experimentalSettings,G.previousSettings),i(Z instanceof Error?Z.message:"Failed to update experimental settings.")},"onError")});if(o.isLoading)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading experimental settings..."});if(o.error)return(0,t.jsx)("div",{className:"text-sm text-destructive",children:o.error instanceof Error?o.error.message:"Failed to load experimental settings."});const c=wYe(),d=o.data?.managedKeys??{},m=o.data?.enableWorktreeRunExecution===!0,h=d.enableWorktreeRunExecution?.managed===!0,p=$zt(o.data,NYe()),f=o.data?.enableEnvironments===!0,g=o.data?.enableNativeRunner===!0,v=o.data?.enableChatConnectors===!0,y=o.data?.enableManagedSandboxOnly===!0,w=o.data?.enableIsolatedWorkspaces===!0,S=o.data?.enableIsolatedWorkspacesByDefault===!0,j=o.data?.enableStreamlinedUi!==!1;o.data?.enableConferenceRoomChat;const N=o.data?.enableClassicTaskInterface===!0,_=o.data?.enableIssuePlanDecompositions===!0,A=o.data?.enableExperimentalFileViewer===!0,C=o.data?.enableExternalObjects===!0,I=o.data?.enableBuiltInAgents===!0,T=o.data?.enableBetaSkills===!0,R=o.data?.enableSummaries===!0,L=o.data?.enableStatusCards===!0,O=d.enableSummaries?.managed===!0,$=d.enableStatusCards?.managed===!0,E=O&&!R,q=$&&L,B=o.data?.enableDecisions===!0,K=o.data?.enableGoalsSidebarLink===!0,U=o.data?.enableCases===!0,D=o.data?.enableServerInfoDebugView===!0,V=o.data?.enablePaperclipDeveloperMode===!0,H=o.data?.enableSimplifiedEnglishInteractions===!0,J=o.data?.enableFirstTaskPlanProposal===!0,X=o.data?.enableSmokeLab===!0,le=o.data?.autoRestartDevServerWhenIdle===!0,ce=r(Z=>!n.has(vle(Z)),"isVisible"),te=c&&ce("enableWorktreeRunExecution"),re=te||["autoRestartDevServerWhenIdle","enableManagedSandboxOnly","enablePaperclipDeveloperMode","enableServerInfoDebugView","enableSmokeLab","enableIssuePlanDecompositions"].some(ce),de=ce("enableClassicTaskInterface")||ce("enableGoalsSidebarLink");return(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Zu,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Experimental"})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Opt into features that are still being evaluated before they become default behavior."})]}),(0,t.jsx)("div",{role:"alert",className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(Rs,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,t.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"Experimental features may break at any time."}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"These features are opt-in and come with no compatibility guarantees. They may change, break, or be removed without notice. Avoid relying on them for critical or production workflows."})]})]})}),a&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:a}),(0,t.jsxs)("section",{className:"space-y-3","aria-labelledby":"experimental-features-heading",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h2",{id:"experimental-features-heading",className:"text-sm font-semibold",children:"Experimental features"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Optional product features that are still being evaluated."})]}),(0,t.jsx)(Co,{title:"Agent Chat",description:"Talk to each agent in one ongoing conversation. Clarify goals and create tasks for execution.",footnote:"Turning this off preserves conversations and lets active runs finish, but prevents new messages.",checked:o.data?.enableAgentChat??!1,onCheckedChange:r(Z=>l.mutate({enableAgentChat:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableAgentChat",managed:d.enableAgentChat,ariaLabel:"Toggle agent chat experimental setting"}),(0,t.jsx)(Co,{title:"Beta skills",description:"Allow agents to pin beta releases of the Paperclip core skill. Disabling this returns every agent to the default live skill without removing saved pins.",checked:T,onCheckedChange:r(Z=>l.mutate({enableBetaSkills:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableBetaSkills",managed:d.enableBetaSkills,ariaLabel:"Toggle beta skills experimental setting"}),(0,t.jsx)(Co,{title:"Built-in Agents",description:"Show Paperclip-managed built-in agent surfaces, including built-in roster badges, the Built-in agents tab, and built-in agent setup controls.",checked:I,onCheckedChange:r(Z=>l.mutate({enableBuiltInAgents:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableBuiltInAgents",managed:d.enableBuiltInAgents,ariaLabel:"Toggle built-in agents experimental setting"}),(0,t.jsx)(Co,{title:"Cases",description:"Durable work products (blog posts, tweet storms…) that tasks create and iterate on. Adds the Cases tab and the agent case API.",footnote:"Turning Cases off hides the tab and blocks the case API; existing case data is kept.",checked:U,onCheckedChange:r(Z=>l.mutate({enableCases:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableCases",managed:d.enableCases,ariaLabel:"Toggle cases experimental setting"}),(0,t.jsx)(Co,{title:"Chat connectors",description:"Connect agents to Slack, GitHub, Discord, Microsoft Teams, and Telegram conversations.",footnote:"Turning this off hides chat setup, channels, and connected-task controls. Existing chat connections keep running. GitHub and other tool connectors stay available.",checked:v,onCheckedChange:r(Z=>l.mutate({enableChatConnectors:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableChatConnectors",managed:d.enableChatConnectors,ariaLabel:"Toggle chat connectors experimental setting"}),null,(0,t.jsx)(Co,{title:"Decisions",description:"Show the Decisions item in the main sidebar — the attention home that surfaces the tasks awaiting your input — while the surface is still being evaluated.",checked:B,onCheckedChange:r(Z=>l.mutate({enableDecisions:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableDecisions",managed:d.enableDecisions,ariaLabel:"Toggle decisions experimental setting"}),(0,t.jsx)(Co,{title:"Enable Environments",description:"Show environment management in company settings and allow project and agent environment assignment controls.",checked:f,onCheckedChange:r(Z=>l.mutate({enableEnvironments:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableEnvironments",managed:d.enableEnvironments,ariaLabel:"Toggle environments experimental setting"}),(0,t.jsx)(Co,{title:"Enable External Objects",description:"Detect external URLs in issues and show resolved status for pull requests, tickets, and other referenced work objects.",checked:C,onCheckedChange:r(Z=>l.mutate({enableExternalObjects:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableExternalObjects",managed:d.enableExternalObjects,ariaLabel:"Toggle external objects experimental setting"}),(0,t.jsx)(Co,{title:"Enable Isolated Workspaces",description:"Show execution workspace controls in project configuration and allow isolated workspace behavior for new and existing task runs.",checked:w,onCheckedChange:r(Z=>l.mutate({enableIsolatedWorkspaces:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableIsolatedWorkspaces",managed:d.enableIsolatedWorkspaces,ariaLabel:"Toggle isolated workspaces experimental setting"}),(0,t.jsx)(Co,{title:"Experimental File Viewer",description:"Show task detail controls for browsing and previewing workspace files relative to a task.",checked:A,onCheckedChange:r(Z=>l.mutate({enableExperimentalFileViewer:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableExperimentalFileViewer",managed:d.enableExperimentalFileViewer,ariaLabel:"Toggle experimental file viewer setting"}),(0,t.jsx)(Co,{title:"First task: propose with a plan document",description:"When the user's first request is a single task, the chief of staff writes a short plan document and a checkbox card instead of a one-card confirmation. Applies to organizations created after the toggle is flipped.",checked:J,onCheckedChange:r(Z=>l.mutate({enableFirstTaskPlanProposal:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableFirstTaskPlanProposal",managed:d.enableFirstTaskPlanProposal,ariaLabel:"Toggle first task plan proposal experimental setting"}),(0,t.jsx)(Co,{title:"MCP aggregators",description:"Connect Zapier, Arcade, Composio Connect, and Executor through their MCP servers.",footnote:"Turning this off hides setup for these connectors. Existing MCP connections keep running.",checked:o.data?.enableMcpAggregators===!0,onCheckedChange:r(Z=>l.mutate({enableMcpAggregators:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableMcpAggregators",managed:d.enableMcpAggregators,ariaLabel:"Toggle MCP aggregators experimental setting"}),(0,t.jsx)(Co,{title:"Paperclip Runner",description:"Allow new Codex agents to select the experimental Rust Paperclip Runner, including authenticated runner ingress when a sandbox requires it. Onboarding continues to use legacy adapters. Turning this off hides the choice without affecting existing native runs.",checked:g,onCheckedChange:r(Z=>l.mutate({enableNativeRunner:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableNativeRunner",managed:d.enableNativeRunner,ariaLabel:"Toggle Paperclip Runner experimental setting"}),(0,t.jsx)(Co,{title:"Simplified English Interactions",description:"Instruct agents to write user interactions (plan confirmations, questions, suggested tasks, checkbox prompts) in ASD-STE100 Simplified Technical English, with brief context on what information the decision needs and what happens for each choice.",checked:H,onCheckedChange:r(Z=>l.mutate({enableSimplifiedEnglishInteractions:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableSimplifiedEnglishInteractions",managed:d.enableSimplifiedEnglishInteractions,ariaLabel:"Toggle simplified english interactions experimental setting"}),(0,t.jsx)(Co,{title:"Status Cards",description:"Enable the experimental shared status-card board and its gated API. Existing card data is kept when this is disabled.",footnote:"Enabling Status Cards also enables Summaries.",checked:L,onCheckedChange:r(Z=>l.mutate(Z?{enableSummaries:!0,enableStatusCards:!0}:{enableStatusCards:!1}),"onCheckedChange"),disabled:l.isPending||E,settingKey:"enableStatusCards",managed:d.enableStatusCards,ariaLabel:"Toggle status cards experimental setting"}),(0,t.jsx)(Co,{title:"Streamlined UI",description:"Use the simplified main sidebar, shared Tasks and Inbox presentation, focused task detail layout, and contextual navigation across Agents, Routines, Skills, and Settings.",footnote:"Turning this off restores the legacy shell and navigation. Task and page data are unchanged.",checked:j,onCheckedChange:r(Z=>l.mutate({enableStreamlinedUi:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableStreamlinedUi",managed:d.enableStreamlinedUi,ariaLabel:"Toggle Streamlined UI experimental setting"}),(0,t.jsx)(Co,{title:"Summaries",description:"Show Summarizer-generated status slots on project and workspace pages, with on-demand refresh and revision history. Existing summary data is kept when this is disabled.",footnote:"Status Cards requires Summaries. Disabling Summaries also disables Status Cards.",checked:R,onCheckedChange:r(Z=>l.mutate(Z||!L?{enableSummaries:Z}:{enableSummaries:!1,enableStatusCards:!1}),"onCheckedChange"),disabled:l.isPending||q,settingKey:"enableSummaries",managed:d.enableSummaries,ariaLabel:"Toggle summaries experimental setting"}),w&&(0,t.jsx)(Co,{title:"Use Isolated Workspaces By Default",description:"Treat a project that has no execution workspace policy of its own as if it selected isolated workspaces, so its tasks get a per-task worktree instead of sharing the project checkout. A project that carries its own policy keeps it.",checked:S,onCheckedChange:r(Z=>l.mutate({enableIsolatedWorkspacesByDefault:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableIsolatedWorkspacesByDefault",managed:d.enableIsolatedWorkspacesByDefault,ariaLabel:"Toggle isolated workspaces by default experimental setting"})]}),re?(0,t.jsxs)("section",{className:"space-y-3","aria-labelledby":"developer-mode-heading",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h2",{id:"developer-mode-heading",className:"text-sm font-semibold",children:"Paperclip Developer Mode"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Internal tools for developing, testing, and debugging Paperclip."})]}),(0,t.jsx)(Co,{title:"Auto-Restart Dev Server When Idle",description:"In `pnpm dev:once`, wait for all queued and running local agent runs to finish, then restart the server automatically when backend changes or migrations make the current boot stale.",checked:le,onCheckedChange:r(Z=>l.mutate({autoRestartDevServerWhenIdle:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"autoRestartDevServerWhenIdle",managed:d.autoRestartDevServerWhenIdle,ariaLabel:"Toggle guarded dev-server auto-restart"}),(0,t.jsx)(Co,{title:"Managed Environment Only",description:"Hide the local environment and run all agents in the platform-managed environment.",checked:y,onCheckedChange:r(Z=>l.mutate({enableManagedSandboxOnly:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableManagedSandboxOnly",managed:d.enableManagedSandboxOnly,ariaLabel:"Toggle managed environment only experimental setting"}),(0,t.jsx)(Co,{title:"Paperclip Developer Mode",description:"Show internal Paperclip maintainer tools and observability links, including Honeycomb trace queries on run pages.",checked:V,onCheckedChange:r(Z=>l.mutate({enablePaperclipDeveloperMode:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enablePaperclipDeveloperMode",managed:d.enablePaperclipDeveloperMode,ariaLabel:"Toggle Paperclip developer mode experimental setting"}),te?(0,t.jsx)(Xs,{className:"block bg-transparent p-5",children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:"Run tasks in this worktree"}),h?(0,t.jsx)(l1e,{}):null]}),(0,t.jsx)("p",{className:"max-w-2xl text-sm text-muted-foreground",children:"This is an isolated git-worktree preview instance. Turn this on to let the scheduler execute runs here. Only tasks created after enabling will run automatically — copied/pre-existing tasks stay parked. Toggling off and on resets the cutoff."})]}),(0,t.jsx)(_i,{checked:m,onCheckedChange:r(Z=>{h||l.mutate({enableWorktreeRunExecution:Z})},"onCheckedChange"),disabled:l.isPending||h,"aria-label":"Toggle worktree run execution setting"})]}),p.kind==="armed"?(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-sm text-foreground",children:[(0,t.jsx)(_o,{className:"h-4 w-4 shrink-0 text-emerald-600"}),(0,t.jsxs)("span",{children:["Running tasks created after"," ",(0,t.jsx)("span",{className:"font-medium",children:Ozt(p.activatedAt)}),"."]})]}):null,p.kind==="fail_closed"?(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-sm",children:[(0,t.jsx)(Rs,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,t.jsxs)("div",{className:"space-y-0.5",children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"Execution is suppressed — effectively off."}),(0,t.jsxs)("p",{className:"text-muted-foreground",children:[p.reason==="instance_mismatch"?"This setting was armed in a different instance and copied here, so no tasks run automatically.":"This setting is missing its activation cutoff, so no tasks run automatically."," ","Toggle it off and back on to arm execution for tasks created here."]})]})]}):null]})}):null,(0,t.jsx)(Co,{title:"Server Info Debug View",description:'Show a "Server" section in the account drawer with the current server restart time and running commit.',checked:D,onCheckedChange:r(Z=>l.mutate({enableServerInfoDebugView:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableServerInfoDebugView",managed:d.enableServerInfoDebugView,ariaLabel:"Toggle server info debug view experimental setting"}),(0,t.jsx)(Co,{title:"Smoke Lab",description:'Add a "Smoke Lab" tab under Apps → Developer and an "Integration smoke" card on the dashboard for exercising every integration path against deterministic local fixtures (fake OAuth provider + loopback MCP servers). Private (non-public) deployments only.',checked:X,onCheckedChange:r(Z=>l.mutate({enableSmokeLab:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableSmokeLab",managed:d.enableSmokeLab,ariaLabel:"Toggle smoke lab experimental setting"}),(0,t.jsx)(Co,{title:"Task Plan Decomposition",description:"Show accepted-plan decomposition history on task detail pages. Intended for debugging and validating subtask creation behavior while the presentation is still being refined.",checked:_,onCheckedChange:r(Z=>l.mutate({enableIssuePlanDecompositions:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableIssuePlanDecompositions",managed:d.enableIssuePlanDecompositions,ariaLabel:"Toggle task plan decomposition panel experimental setting"})]}):null,de?(0,t.jsxs)("section",{className:"space-y-3","aria-labelledby":"legacy-heading",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("h2",{id:"legacy-heading",className:"text-sm font-semibold",children:"Legacy"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"These features are going to be removed."})]}),(0,t.jsx)(Co,{title:"Classic Task Interface",description:"Restores the previous task detail page: the page-level header with inline description editing, the plain comment thread, and the fixed Properties sidebar. Chat-only features — streaming activity folding, inline plan and question cards, the three-mode composer — are unavailable in the classic view.",footnote:"Switching takes effect immediately. No task data is affected.",checked:N,onCheckedChange:r(Z=>l.mutate({enableClassicTaskInterface:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableClassicTaskInterface",managed:d.enableClassicTaskInterface,ariaLabel:"Toggle classic task interface experimental setting"}),(0,t.jsx)(Co,{title:"Goals Sidebar Link",description:"Restore the Goals item in the main sidebar while the goals surface is being evaluated.",checked:K,onCheckedChange:r(Z=>l.mutate({enableGoalsSidebarLink:Z}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableGoalsSidebarLink",managed:d.enableGoalsSidebarLink,ariaLabel:"Toggle goals sidebar link experimental setting"})]}):null]})}r(Fzt,"InstanceExperimentalSettings");function Bzt(){const{userId:e,settled:s}=Z3(),{setBreadcrumbs:n}=Ln(),{pushToast:a}=Pi(),i=Kt(),[o,l]=(0,u.useState)(""),[c,d]=(0,u.useState)(null),[m,h]=(0,u.useState)(new Set);(0,u.useEffect)(()=>{n([{label:"Settings",href:"/company/settings"},{label:"Instance settings",href:"/company/settings/instance/general"},{label:"Access"}])},[n]);const p=ee({queryKey:P.access.adminUsers(o),queryFn:r(()=>ur.searchAdminUsers(o),"queryFn")}),f=ee({...B_e(e),enabled:s&&p.isSuccess}),g=f.data??[],v=(0,u.useMemo)(()=>p.data?.find(j=>j.id===c)??null,[c,p.data]),y=ee({queryKey:P.access.userCompanyAccess(c??""),queryFn:r(()=>ur.getUserCompanyAccess(c),"queryFn"),enabled:!!c});(0,u.useEffect)(()=>{!c&&p.data?.[0]&&d(p.data[0].id)},[c,p.data]),(0,u.useEffect)(()=>{y.data&&h(new Set(y.data.companyAccess.filter(j=>j.status==="active").map(j=>j.companyId)))},[y.data]);const w=ke({mutationFn:r(()=>ur.setUserCompanyAccess(c,[...m]),"mutationFn"),onSuccess:r(async()=>{await i.invalidateQueries({queryKey:P.access.userCompanyAccess(c)}),await i.invalidateQueries({queryKey:P.access.adminUsers(o)}),await i.invalidateQueries({queryKey:P.companies.all}),a({title:"Organization access updated",tone:"success"})},"onSuccess")}),S=ke({mutationFn:r(async j=>{if(!c)throw new Error("No user selected");return j?ur.promoteInstanceAdmin(c):ur.demoteInstanceAdmin(c)},"mutationFn"),onSuccess:r(async()=>{await i.invalidateQueries({queryKey:P.access.adminUsers(o)}),c&&await i.invalidateQueries({queryKey:P.access.userCompanyAccess(c)}),a({title:"Instance role updated",tone:"success"})},"onSuccess")});if(p.isLoading||!s||p.isSuccess&&f.isPending)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading instance access…"});if(p.error){const j=p.error instanceof vn&&p.error.status===403?"Instance admin access is required to manage users.":p.error instanceof Error?p.error.message:"Failed to load users.";return(0,t.jsx)("div",{className:"text-sm text-destructive",children:j})}return f.error?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm text-destructive",children:"Failed to load organizations. Try again before changing access."}),(0,t.jsx)(F,{onClick:r(()=>{f.refetch()},"onClick"),children:"Try again"})]}):(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(l5,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Instance Access"})]}),(0,t.jsx)("p",{className:"max-w-3xl text-sm text-muted-foreground",children:"Search users, manage instance-admin status, and control which organizations they can access."})]}),(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-(--gtc-34)",children:[(0,t.jsxs)(Xs,{className:"block space-y-4 p-4",children:[(0,t.jsxs)("label",{className:"block space-y-2 text-sm",children:[(0,t.jsx)("span",{className:"font-medium",children:"Search users"}),(0,t.jsx)("input",{className:"w-full rounded-md border border-border bg-background px-3 py-2",value:o,onChange:r(j=>l(j.target.value),"onChange"),placeholder:"Search by name or email"})]}),(0,t.jsx)("div",{className:"space-y-2",children:(p.data??[]).map(j=>(0,t.jsxs)("button",{type:"button",onClick:r(()=>d(j.id),"onClick"),className:`w-full rounded-lg border px-3 py-3 text-left transition-colors ${j.id===c?"border-foreground bg-accent":"border-border hover:bg-accent/40"}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"truncate font-medium",children:j.name||j.email||j.id}),(0,t.jsx)("div",{className:"truncate text-sm text-muted-foreground",children:j.email||j.id})]}),j.isInstanceAdmin?(0,t.jsx)(Ai,{className:"h-4 w-4 text-emerald-600"}):null]}),(0,t.jsxs)("div",{className:"mt-2 text-xs text-muted-foreground",children:[j.activeCompanyMembershipCount," active organization memberships"]})]},j.id))})]}),(0,t.jsx)(Xs,{className:"block space-y-4 p-5",children:c?y.isLoading?(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading user access…"}):y.error?(0,t.jsx)("div",{className:"text-sm text-destructive",children:y.error instanceof Error?y.error.message:"Failed to load user access."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-lg font-semibold",children:v?.name||v?.email||c}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:v?.email||c})]}),(0,t.jsx)(F,{variant:v?.isInstanceAdmin?"outline":"default",onClick:r(()=>S.mutate(!(v?.isInstanceAdmin??!1)),"onClick"),disabled:S.isPending,children:v?.isInstanceAdmin?"Remove instance admin":"Promote to instance admin"})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-sm font-semibold",children:"Organization access"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Toggle organization membership for this user. New access defaults to an active operator membership."})]}),(0,t.jsx)("div",{className:"grid gap-3 md:grid-cols-2",children:g.map(j=>(0,t.jsxs)("label",{className:"flex items-start gap-3 rounded-lg border border-border px-3 py-3",children:[(0,t.jsx)(Fi,{checked:m.has(j.id),onCheckedChange:r(N=>{h(_=>{const A=new Set(_);return N?A.add(j.id):A.delete(j.id),A})},"onCheckedChange")}),(0,t.jsxs)("span",{className:"space-y-1",children:[(0,t.jsx)("span",{className:"block text-sm font-medium",children:j.name}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:j.issuePrefix})]})]},j.id))}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(F,{onClick:r(()=>w.mutate(),"onClick"),disabled:w.isPending,children:w.isPending?"Saving…":"Save organization access"})})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold",children:"Current memberships"}),(0,t.jsx)("div",{className:"space-y-2",children:(y.data?.companyAccess??[]).map(j=>(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-border px-3 py-2 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"font-medium",children:j.companyName||j.companyId}),(0,t.jsxs)("div",{className:"text-muted-foreground",children:[j.membershipRole||"unset"," • ",j.status]})]}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:new Date(j.updatedAt).toLocaleDateString()})]},j.id))})]})]}):(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Select a user to inspect instance access."})})]})]})}r(Bzt,"InstanceAccess");var _oe={getMine:r(e=>Re.get(`/companies/${e}/users/me/inbox-agent-policy`),"getMine"),updateMine:r((e,s)=>Re.put(`/companies/${e}/users/me/inbox-agent-policy`,s),"updateMine")},qzt=[{value:"open",title:"Any of my agents",description:"Let any agent you manage archive tasks out of your inbox."},{value:"allowlist",title:"Only chosen agents",description:"Restrict inbox tidying to the agents you pick below."},{value:"disabled",title:"Off",description:"Agents can never archive tasks from your inbox."}];function YA(e,s){return`${e}:${[...s].sort().join(",")}`}r(YA,"policyKey");function zzt({companyId:e}){const s=Kt(),[n,a]=(0,u.useState)(null),i=(0,u.useRef)(null),o=ee({queryKey:e?P.inboxAgentPolicy.mine(e):["inbox-agent-policy","none"],queryFn:r(()=>_oe.getMine(e),"queryFn"),enabled:!!e}),l=o.data,c=ee({queryKey:e?P.agents.list(e):["agents","none"],queryFn:r(()=>zt.list(e),"queryFn"),enabled:!!e}),d=(0,u.useMemo)(()=>(c.data??[]).filter(af),[c.data]),m=(0,u.useMemo)(()=>d.map(g=>({id:g.id,name:g.name,title:g.title??g.role,icon:g.icon})),[d]),h=(0,u.useMemo)(()=>new Set(n?.allowedAgentIds??[]),[n?.allowedAgentIds]);(0,u.useEffect)(()=>{if(!l)return;const g=YA(l.mode,l.allowedAgentIds);a(v=>v===null||YA(v.mode,v.allowedAgentIds)===i.current?{mode:l.mode,allowedAgentIds:l.allowedAgentIds}:v),i.current=g},[l]);const p=ke({mutationFn:r(g=>_oe.updateMine(e,{mode:g.mode,allowedAgentIds:g.mode==="allowlist"?g.allowedAgentIds:[]}),"mutationFn"),onSuccess:r(g=>{s.setQueryData(P.inboxAgentPolicy.mine(e),g)},"onSuccess")}),f=!!(n&&l&&YA(n.mode,n.allowedAgentIds)!==YA(l.mode,l.allowedAgentIds));return o.error?(0,t.jsx)("div",{className:"text-sm text-destructive",children:o.error instanceof Error?o.error.message:"Failed to load inbox agent policy."}):o.isLoading||!n?(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading inbox agent policy…"}):(0,t.jsxs)("section",{className:"space-y-4","aria-label":"Let agents tidy my inbox",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ed,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Let agents tidy my inbox"})]}),(0,t.jsx)("p",{className:"max-w-2xl text-sm text-muted-foreground",children:"Choose whether the agents you manage may archive tasks out of your inbox on your behalf. You can undo any archive, and every agent archive is attributed in the task's properties."})]}),(0,t.jsx)(uu,{ariaLabel:"Inbox agent archiving policy",value:n.mode,onValueChange:r(g=>a(v=>v&&{...v,mode:g}),"onValueChange"),options:qzt,className:"max-w-2xl"}),n.mode==="allowlist"?(0,t.jsxs)("div",{className:"max-w-2xl space-y-2",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:"Agents allowed to tidy my inbox"}),(0,t.jsx)(kv,{agents:m,selectedAgentIds:h,onChange:r(g=>a(v=>v&&{...v,allowedAgentIds:[...g]}),"onChange"),triggerLabel:h.size===0?"Select agents":`${h.size} ${h.size===1?"agent":"agents"} selected`,triggerFullWidth:!1,showSelectionPreview:!1,emptyMessage:"You don’t manage any agents yet."})]}):null,p.error?(0,t.jsx)("div",{className:"max-w-2xl rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:p.error instanceof Error?p.error.message:"Failed to save inbox agent policy."}):null,(0,t.jsxs)("div",{className:"flex max-w-2xl items-center justify-end gap-3",children:[p.isSuccess&&!f?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",role:"status",children:"Saved"}):null,(0,t.jsxs)(F,{type:"button",disabled:!f||p.isPending,onClick:r(()=>n&&p.mutate(n),"onClick"),children:[p.isPending?(0,t.jsx)(it,{className:"size-4 animate-spin"}):(0,t.jsx)(Hp,{className:"size-4"}),p.isPending?"Saving…":"Save"]})]})]})}r(zzt,"InboxAgentPolicyControl");function Uzt(e){const s=e.trim().split(/\s+/).filter(Boolean);return s.length>=2?`${s[0]?.[0]??""}${s[s.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}r(Uzt,"deriveInitials");function Kzt(){const{setBreadcrumbs:e}=Ln(),{selectedCompanyId:s,selectedCompany:n}=xs(),a=Kt(),i=(0,u.useId)(),o=(0,u.useRef)(null),[l,c]=(0,u.useState)(""),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(null),f=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1});(0,u.useEffect)(()=>{e([{label:"Settings",href:"/company/settings"},{label:"Profile"}])},[e]),(0,u.useEffect)(()=>{const T=f.data;T&&(c(T.user.name??""),m(T.user.image??""))},[f.data]);function g(T){a.setQueryData(P.auth.session,R=>R&&{...R,user:{...R.user,...T}})}r(g,"syncSessionProfile");async function v(T){const R=await Fa.updateProfile(T);return g(R),R}r(v,"persistProfile");function y(){return l.trim()||f.data?.user.name||"Board"}r(y,"resolveProfileName");const w=ke({mutationFn:r(T=>v(T),"mutationFn"),onSuccess:r(T=>{p(null),c(T.name??""),m(T.image??"")},"onSuccess"),onError:r(T=>{p(T instanceof Error?T.message:"Failed to update profile.")},"onError")}),S=ke({mutationFn:r(async T=>{if(!s)throw new Error("Select an organization before uploading a profile avatar.");const R=await d0.uploadImage(s,T,`profiles/${f.data?.user.id??"board-user"}`);return v({name:y(),image:R.contentPath})},"mutationFn"),onSuccess:r(T=>{p(null),c(T.name??""),m(T.image??"")},"onSuccess"),onError:r(T=>{p(T instanceof Error?T.message:"Failed to upload avatar.")},"onError")}),j=ke({mutationFn:r(()=>v({name:y(),image:null}),"mutationFn"),onSuccess:r(T=>{p(null),c(T.name??""),m(T.image??"")},"onSuccess"),onError:r(T=>{p(T instanceof Error?T.message:"Failed to remove avatar.")},"onError")});if(f.isLoading)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading profile..."});if(f.error||!f.data)return(0,t.jsx)("div",{className:"text-sm text-destructive",children:f.error instanceof Error?f.error.message:"Failed to load profile."});const N=l.trim()||f.data.user.name||"Board",_=d.trim()||null,A=Uzt(N),C=w.isPending||S.isPending||j.isPending,I=n?`Stored in Paperclip file storage for ${n.name}.`:"Select an organization to upload an avatar into Paperclip storage.";return(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(b1,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Profile"})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Control how your account appears in the sidebar and other board surfaces."})]}),h?(0,t.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:h}):null,(0,t.jsxs)("section",{className:"space-y-8",children:[(0,t.jsxs)(Xs,{className:"block relative overflow-hidden rounded-(--rad-28) border-border/70",children:[(0,t.jsx)("div",{className:"absolute inset-x-0 top-0 h-32 bg-(image:--gradient-extract-26)"}),(0,t.jsx)("div",{className:"absolute inset-0 bg-(image:--gradient-extract-7)"}),(0,t.jsx)("div",{className:"relative p-6 pt-10",children:(0,t.jsxs)("div",{className:"flex flex-wrap items-end gap-5 rounded-(--rad-24) border border-border/70 bg-background/92 p-5 shadow-(--shadow-extract-18) backdrop-blur-sm",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("label",{htmlFor:i,className:"group relative block cursor-pointer rounded-full focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background",children:[(0,t.jsx)("input",{ref:o,id:i,type:"file",accept:"image/*",className:"sr-only",disabled:!s||C,onChange:r(T=>{const R=T.target.files?.[0];R&&(S.mutate(R),T.target.value="")},"onChange")}),(0,t.jsx)("span",{className:"absolute inset-0 z-10 rounded-full bg-black/0 transition-colors group-hover:bg-black/14 group-focus-within:bg-black/14"}),(0,t.jsx)("span",{className:"absolute bottom-1 right-1 z-20 flex size-9 items-center justify-center rounded-full border border-background bg-primary text-primary-foreground shadow-sm",children:S.isPending?(0,t.jsx)(it,{className:"size-4 animate-spin"}):(0,t.jsx)(mH,{className:"size-4"})}),(0,t.jsxs)(Yi,{size:"lg",className:"data-[size=lg]:size-24 ring-4 ring-background shadow-xl",children:[_?(0,t.jsx)(Vc,{src:_,alt:N}):null,(0,t.jsx)(Ji,{children:A})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)(F,{type:"button",variant:"secondary",onClick:r(()=>o.current?.click(),"onClick"),disabled:!s||C,children:[S.isPending?(0,t.jsx)(it,{className:"size-4 animate-spin"}):(0,t.jsx)(mH,{className:"size-4"}),_?"Change photo":"Upload photo"]}),_?(0,t.jsxs)(F,{type:"button",variant:"outline",onClick:r(()=>j.mutate(),"onClick"),disabled:C,children:[j.isPending?(0,t.jsx)(it,{className:"size-4 animate-spin"}):(0,t.jsx)(Ia,{className:"size-4"}),"Remove"]}):null]})]}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 space-y-2 pb-1",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"truncate text-2xl font-semibold text-foreground",children:N}),(0,t.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:f.data.user.email??"No email"})]}),(0,t.jsxs)("p",{className:"max-w-2xl text-sm leading-6 text-muted-foreground",children:["Click the avatar to upload a new image. ",I]})]})]})})]}),(0,t.jsxs)("form",{className:"grid gap-6 md:grid-cols-2",onSubmit:r(T=>{T.preventDefault(),w.mutate({name:y(),image:d.trim()||null})},"onSubmit"),children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(Ws,{htmlFor:"profile-name",children:"Display name"}),(0,t.jsx)(_t,{id:"profile-name",value:l,onChange:r(T=>c(T.target.value),"onChange"),maxLength:120,placeholder:"Board"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Shown in the sidebar account footer and comment author surfaces."})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(Ws,{htmlFor:"profile-email",children:"Email"}),(0,t.jsx)(_t,{id:"profile-email",value:f.data.user.email??"",readOnly:!0,disabled:!0}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Email is managed by your auth session and is read-only here."})]}),(0,t.jsx)("div",{className:"md:col-span-2 flex justify-end",children:(0,t.jsxs)(F,{type:"submit",disabled:C||!l.trim(),children:[w.isPending?(0,t.jsx)(it,{className:"size-4 animate-spin"}):(0,t.jsx)(Hp,{className:"size-4"}),w.isPending?"Saving...":"Save profile"]})})]}),(0,t.jsx)(zzt,{companyId:s})]})]})}r(Kzt,"ProfileSettings");function Vzt(e){return e?e.split(/\r?\n/).map(s=>s.trim()).find(Boolean)??null:null}r(Vzt,"firstNonEmptyLine");function Ioe(e){return Vzt(e.lastError)??"Plugin entered an error state without a stored error message."}r(Ioe,"getPluginErrorSummary");function Aoe(e){if(e.bundledExperimental)return!0;const s=e.packageName??"",n=e.packagePath??"";return s.includes("sandbox")||n.includes("sandbox")?!0:e.manifestJson?.environmentDrivers?.some(a=>a.kind==="sandbox_provider")===!0}r(Aoe,"isExperimentalPluginIdentity");function Roe(){return(0,t.jsx)(ct,{variant:"outline",className:"border-amber-500/30 bg-amber-500/10 text-amber-700 hover:bg-amber-500/10 dark:text-amber-200",children:"Experimental"})}r(Roe,"ExperimentalBadge");function Wzt(){const{selectedCompany:e}=xs(),{setBreadcrumbs:s}=Ln(),n=Kt(),{pushToast:a}=da(),[i,o]=(0,u.useState)(""),[l,c]=(0,u.useState)(!1),[d,m]=(0,u.useState)(null),[h,p]=(0,u.useState)(""),[f,g]=(0,u.useState)(null);(0,u.useEffect)(()=>{s([{label:e?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Plugins"}])},[e?.name,s]);const{data:v,isLoading:y,error:w}=ee({queryKey:P.plugins.all,queryFn:r(()=>Jo.list(),"queryFn")}),S=ee({queryKey:P.plugins.examples,queryFn:r(()=>Jo.listBundled(),"queryFn")}),j=r(()=>{n.invalidateQueries({queryKey:P.plugins.all}),n.invalidateQueries({queryKey:P.plugins.examples}),n.invalidateQueries({queryKey:P.plugins.uiContributions})},"invalidatePluginQueries"),N=ke({mutationFn:r(E=>Jo.install(E),"mutationFn"),onSuccess:r(()=>{j(),c(!1),o(""),a({title:"Plugin installed successfully",tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Failed to install plugin",body:E.message,tone:"error"})},"onError")}),_=ke({mutationFn:r(E=>Jo.uninstall(E),"mutationFn"),onSuccess:r(()=>{j(),a({title:"Plugin uninstalled successfully",tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Failed to uninstall plugin",body:E.message,tone:"error"})},"onError")}),A=ke({mutationFn:r(E=>Jo.enable(E),"mutationFn"),onSuccess:r(()=>{j(),a({title:"Plugin enabled",tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Failed to enable plugin",body:E.message,tone:"error"})},"onError")}),C=ke({mutationFn:r(E=>Jo.disable(E),"mutationFn"),onSuccess:r(()=>{j(),a({title:"Plugin disabled",tone:"info"})},"onSuccess"),onError:r(E=>{a({title:"Failed to disable plugin",body:E.message,tone:"error"})},"onError")}),I=v??[],T=S.data??[],R=new Map(I.map(E=>[E.packageName,E])),L=new Map(T.map(E=>[E.packageName,E])),O=N.variables?.isLocalPath?N.error?.message??null:null,$=(0,u.useMemo)(()=>new Map(I.map(E=>[E.id,Ioe(E)])),[I]);return y?(0,t.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading plugins..."}):w?(0,t.jsx)("div",{className:"p-4 text-sm text-destructive",children:"Failed to load plugins."}):(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Pg,{className:"h-6 w-6 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Plugin Manager"})]}),(0,t.jsxs)(Js,{open:l,onOpenChange:c,children:[(0,t.jsx)(zw,{asChild:!0,children:(0,t.jsxs)(F,{size:"sm",className:"gap-2",children:[(0,t.jsx)(yn,{className:"h-4 w-4"}),"Install Plugin"]})}),(0,t.jsxs)(Zs,{children:[(0,t.jsxs)(Sn,{children:[(0,t.jsx)(rn,{children:"Install Plugin"}),(0,t.jsx)(Mn,{children:"Enter the npm package name of the plugin you wish to install."})]}),(0,t.jsx)("div",{className:"grid gap-4 py-4",children:(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(Ws,{htmlFor:"packageName",children:"npm Package Name"}),(0,t.jsx)(_t,{id:"packageName",placeholder:"@tickernelz/paperclip-pro-plugin-example",value:i,onChange:r(E=>o(E.target.value),"onChange")})]})}),(0,t.jsxs)(br,{children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>c(!1),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{onClick:r(()=>N.mutate({packageName:i}),"onClick"),disabled:!i||N.isPending,children:N.isPending?"Installing...":"Install"})]})]})]})]}),(0,t.jsx)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(Rs,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,t.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"Plugins are alpha."}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"The plugin runtime and API surface are still changing. Expect breaking changes while this feature settles."})]})]})}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Zu,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Available Plugins"}),(0,t.jsx)(ct,{variant:"outline",children:"Bundled"})]}),O&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/25 bg-destructive/[0.06] px-4 py-3 text-sm text-destructive whitespace-pre-wrap break-words",children:O}),S.isLoading?(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading bundled plugins..."}):S.error?(0,t.jsx)("div",{className:"text-sm text-destructive",children:"Failed to load bundled plugins."}):T.length===0?(0,t.jsx)("div",{className:"rounded-md border border-dashed px-4 py-3 text-sm text-muted-foreground",children:"No bundled plugins were found in this checkout."}):(0,t.jsx)(Xs,{className:"block py-0",children:(0,t.jsx)("ul",{className:"divide-y",children:T.map(E=>{const q=R.get(E.packageName),B=N.isPending&&N.variables?.isLocalPath&&N.variables.packageName===E.localPath;return(0,t.jsx)("li",{children:(0,t.jsxs)("div",{className:"flex items-center gap-4 px-4 py-3",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"font-medium",children:E.displayName}),(0,t.jsx)(ct,{variant:"outline",children:E.tag==="first-party"?"First-party":"Example"}),Aoe({packageName:E.packageName,packagePath:E.localPath,bundledExperimental:E.experimental})&&(0,t.jsx)(Roe,{}),q?(0,t.jsx)(ct,{variant:q.status==="ready"?"default":"secondary",className:q.status==="ready"?"bg-green-600 hover:bg-green-700":"",children:q.status}):(0,t.jsx)(ct,{variant:"secondary",children:"Not installed"})]}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:E.description}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:E.packageName}),B&&!E.hasBuiltEntrypoints&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Building plugin..."})]}),(0,t.jsx)("div",{className:"flex items-center gap-2 shrink-0",children:q?(0,t.jsxs)(t.Fragment,{children:[q.status!=="ready"&&(0,t.jsx)(F,{variant:"outline",size:"sm",disabled:A.isPending,onClick:r(()=>A.mutate(q.id),"onClick"),children:"Enable"}),(0,t.jsx)(F,{variant:"outline",size:"sm",asChild:!0,children:(0,t.jsx)(Ge,{to:`/company/settings/instance/plugins/${q.id}`,children:q.status==="ready"?"Open Settings":"Review"})})]}):(0,t.jsx)(F,{size:"sm",disabled:B||N.isPending,onClick:r(()=>N.mutate({packageName:E.localPath,isLocalPath:!0}),"onClick"),children:B?"Installing...":"Install"})})]})},E.packageName)})})})]}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Pg,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Installed Plugins"})]}),I.length?(0,t.jsx)(Xs,{className:"block py-0",children:(0,t.jsx)("ul",{className:"divide-y",children:I.map(E=>(0,t.jsx)("li",{children:(0,t.jsxs)("div",{className:"flex items-start gap-4 px-4 py-3",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(Ge,{to:`/company/settings/instance/plugins/${E.id}`,className:"font-medium hover:underline truncate block",title:E.manifestJson.displayName??E.packageName,children:E.manifestJson.displayName??E.packageName}),L.has(E.packageName)&&(0,t.jsx)(ct,{variant:"outline",children:L.get(E.packageName)?.tag==="first-party"?"First-party":"Example"}),Aoe({packageName:E.packageName,packagePath:E.packagePath,manifestJson:E.manifestJson,bundledExperimental:L.get(E.packageName)?.experimental})&&(0,t.jsx)(Roe,{})]}),(0,t.jsx)("div",{children:(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",title:E.packageName,children:[E.packageName," · v",E.manifestJson.version??E.version]})}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground truncate mt-0.5",title:E.manifestJson.description,children:E.manifestJson.description||"No description provided."}),E.status==="error"&&(0,t.jsx)("div",{className:"mt-3 rounded-md border border-red-500/25 bg-red-500/[0.06] px-3 py-2",children:(0,t.jsxs)("div",{className:"flex flex-wrap items-start gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-red-700 dark:text-red-300",children:[(0,t.jsx)(Rs,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{children:"Plugin error"})]}),(0,t.jsx)("p",{className:"mt-1 text-sm text-red-700/90 dark:text-red-200/90 break-words",title:E.lastError??void 0,children:$.get(E.id)})]}),(0,t.jsx)(F,{variant:"outline",size:"sm",className:"border-red-500/30 bg-background/60 text-red-700 hover:bg-red-500/10 hover:text-red-800 dark:text-red-200 dark:hover:text-red-100",onClick:r(()=>g(E),"onClick"),children:"View full error"})]})})]}),(0,t.jsx)("div",{className:"flex shrink-0 self-center",children:(0,t.jsxs)("div",{className:"flex flex-col items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(ct,{variant:E.status==="ready"?"default":E.status==="error"?"destructive":"secondary",className:z("shrink-0",E.status==="ready"?"bg-green-600 hover:bg-green-700":""),children:E.status}),(0,t.jsx)(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8",title:E.status==="ready"?"Disable":"Enable",onClick:r(()=>{E.status==="ready"?C.mutate(E.id):A.mutate(E.id)},"onClick"),disabled:A.isPending||C.isPending,children:(0,t.jsx)(_z,{className:z("h-4 w-4",E.status==="ready"?"text-green-600":"")})}),(0,t.jsx)(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8 text-destructive hover:text-destructive",title:"Uninstall",onClick:r(()=>{m(E.id),p(E.manifestJson.displayName??E.packageName)},"onClick"),disabled:_.isPending,children:(0,t.jsx)(ePe,{className:"h-4 w-4"})})]}),(0,t.jsx)(F,{variant:"outline",size:"sm",className:"mt-2 h-8",asChild:!0,children:(0,t.jsxs)(Ge,{to:`/company/settings/instance/plugins/${E.id}`,children:[(0,t.jsx)(Ld,{className:"h-4 w-4"}),"Configure"]})})]})})]})},E.id))})}):(0,t.jsx)(Xs,{className:"bg-muted/30",children:(0,t.jsxs)(Qa,{className:"flex flex-col items-center justify-center py-10",children:[(0,t.jsx)(Pg,{className:"h-10 w-10 text-muted-foreground mb-4"}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"No plugins installed"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Install a plugin to extend functionality."})]})})]}),(0,t.jsx)(Js,{open:d!==null,onOpenChange:r(E=>{E||m(null)},"onOpenChange"),children:(0,t.jsxs)(Zs,{children:[(0,t.jsxs)(Sn,{children:[(0,t.jsx)(rn,{children:"Uninstall Plugin"}),(0,t.jsxs)(Mn,{children:["Are you sure you want to uninstall ",(0,t.jsx)("strong",{children:h}),"? This action cannot be undone."]})]}),(0,t.jsxs)(br,{children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>m(null),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{variant:"destructive",disabled:_.isPending,onClick:r(()=>{d&&_.mutate(d,{onSettled:r(()=>m(null),"onSettled")})},"onClick"),children:_.isPending?"Uninstalling...":"Uninstall"})]})]})}),(0,t.jsx)(Js,{open:f!==null,onOpenChange:r(E=>{E||g(null)},"onOpenChange"),children:(0,t.jsxs)(Zs,{className:"sm:max-w-2xl",children:[(0,t.jsxs)(Sn,{children:[(0,t.jsx)(rn,{children:"Error Details"}),(0,t.jsxs)(Mn,{children:[f?.manifestJson.displayName??f?.packageName??"Plugin"," hit an error state."]})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("div",{className:"rounded-md border border-red-500/25 bg-red-500/[0.06] px-4 py-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(Rs,{className:"mt-0.5 h-4 w-4 shrink-0 text-red-700 dark:text-red-300"}),(0,t.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,t.jsx)("p",{className:"font-medium text-red-700 dark:text-red-300",children:"What errored"}),(0,t.jsx)("p",{className:"text-red-700/90 dark:text-red-200/90 break-words",children:f?Ioe(f):"No error summary available."})]})]})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Full error output"}),(0,t.jsx)("pre",{className:"max-h-(--sz-50vh) overflow-auto rounded-md border bg-muted/40 p-3 text-xs leading-5 whitespace-pre-wrap break-words",children:f?.lastError??"No stored error message."})]})]}),(0,t.jsx)(br,{children:(0,t.jsx)(F,{variant:"outline",onClick:r(()=>g(null),"onClick"),children:"Close"})})]})})]})}r(Wzt,"PluginManager");function Hzt(){const{selectedCompany:e,selectedCompanyId:s}=xs(),{setBreadcrumbs:n}=Ln(),{companyPrefix:a,pluginId:i}=ka(),{hideHostPaths:o}=B1(),[l,c]=(0,u.useState)("configuration"),{data:d,isLoading:m}=ee({queryKey:P.plugins.detail(i),queryFn:r(()=>Jo.get(i),"queryFn"),enabled:!!i}),{data:h,isLoading:p}=ee({queryKey:P.plugins.health(i),queryFn:r(()=>Jo.health(i),"queryFn"),enabled:!!i&&d?.status==="ready",refetchInterval:3e4}),{data:f}=ee({queryKey:P.plugins.dashboard(i),queryFn:r(()=>Jo.dashboard(i),"queryFn"),enabled:!!i,refetchInterval:3e4}),{data:g}=ee({queryKey:P.plugins.logs(i),queryFn:r(()=>Jo.logs(i,{limit:50}),"queryFn"),enabled:!!i&&d?.status==="ready",refetchInterval:3e4}),v=d?.manifestJson?.instanceConfigSchema,y=v&&v.properties&&Object.keys(v.properties).length>0,w=i&&s?P.plugins.config(i,s):["plugins",i??"__missing_plugin__","companies","__missing_company__","config"],{data:S,isLoading:j}=ee({queryKey:w,queryFn:r(()=>Jo.getConfig(i,s),"queryFn"),enabled:!!i&&!!y&&!!s}),{slots:N}=Hc({slotTypes:["settingsPage"],companyId:s,enabled:!!s}),_=N.filter(q=>q.pluginId===i),A=_.length>0;if((0,u.useEffect)(()=>{n([{label:e?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Plugins",href:"/company/settings/instance/plugins"},{label:d?.manifestJson?.displayName??d?.packageName??"Plugin Details"}])},[e?.name,n,a,d]),(0,u.useEffect)(()=>{c("configuration")},[i]),m)return(0,t.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading plugin details..."});if(!d)return(0,t.jsx)(wn,{to:"/company/settings/instance/plugins",replace:!0});const C=d.status,I=d.status==="ready"?"default":d.status==="error"?"destructive":"secondary",T=d.manifestJson.description||"No description provided.",R=d.manifestJson.capabilities??[],L=d.manifestJson.environmentDrivers??[],O=d.manifestJson.localFolders??[],$=O.length>0&&!o,E=L.map(q=>q.displayName?.trim()||q.driverKey).filter((q,B,K)=>K.indexOf(q)===B).join(", ");return(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsx)(Ge,{to:"/company/settings/instance/plugins",children:(0,t.jsx)(F,{variant:"outline",size:"icon",className:"h-8 w-8",children:(0,t.jsx)(ic,{className:"h-4 w-4"})})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Pg,{className:"h-6 w-6 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-xl font-semibold",children:d.manifestJson.displayName??d.packageName}),(0,t.jsx)(ct,{variant:I,className:"ml-2",children:C}),(0,t.jsxs)(ct,{variant:"outline",className:"ml-1",children:["v",d.manifestJson.version??d.version]})]})]}),(0,t.jsxs)(ki,{value:l,onValueChange:r(q=>c(q),"onValueChange"),className:"space-y-6",children:[(0,t.jsx)(ac,{align:"start",items:[{value:"configuration",label:"Configuration"},{value:"status",label:"Status"}],value:l,onValueChange:r(q=>c(q),"onValueChange")}),(0,t.jsx)(aa,{value:"configuration",className:"space-y-6",children:(0,t.jsxs)("div",{className:"space-y-8",children:[(0,t.jsxs)("section",{className:"space-y-5",children:[(0,t.jsx)("h2",{className:"text-base font-semibold",children:"About"}),(0,t.jsxs)("div",{className:"grid gap-8 lg:grid-cols-(--gtc-52)",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-muted-foreground",children:"Description"}),(0,t.jsx)("p",{className:"text-sm leading-6 text-foreground/90",children:T})]}),(0,t.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("h3",{className:"font-medium text-muted-foreground",children:"Author"}),(0,t.jsx)("p",{className:"text-foreground",children:d.manifestJson.author})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"font-medium text-muted-foreground",children:"Categories"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:d.categories.length>0?d.categories.map(q=>(0,t.jsx)(ct,{variant:"outline",className:"capitalize",children:q},q)):(0,t.jsx)("span",{className:"text-foreground",children:"None"})})]})]})]})]}),(0,t.jsx)(ml,{}),(0,t.jsxs)("section",{className:"space-y-4",children:[(0,t.jsx)("div",{className:"space-y-1",children:(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Settings"})}),$?(0,t.jsx)(Qzt,{pluginId:i,companyId:s,declarations:O}):null,A?(0,t.jsx)("div",{className:"space-y-3",children:_.map(q=>(0,t.jsx)(yu,{slot:q,context:{companyId:s,companyPrefix:a??null},missingBehavior:"placeholder"},`${q.pluginKey}:${q.id}`))}):y?(0,t.jsx)(Zzt,{pluginId:i,companyId:s,schema:v,initialValues:S?.configJson,isLoading:j,pluginStatus:d.status,supportsConfigTest:d.supportsConfigTest===!0}):L.length>0?(0,t.jsxs)("div",{className:"rounded-md border border-border/60 bg-muted/20 px-4 py-3 text-sm",children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"Configure this plugin from Settings → Environments."}),(0,t.jsxs)("p",{className:"mt-1 text-muted-foreground",children:[E||"This plugin"," registers environment runtime settings there so the execution target stays instance-scoped while secret bindings still resolve through the selected organization context."]}),(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)(Ge,{to:"/company/settings/instance/environments",children:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Open Environments"})})})]}):$?null:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"This plugin does not require any settings."})]})]})}),(0,t.jsx)(aa,{value:"status",className:"space-y-6",children:(0,t.jsxs)("div",{className:"grid gap-6 xl:grid-cols-(--gtc-39)",children:[(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(Zi,{children:[(0,t.jsxs)(uo,{className:"text-base flex items-center gap-1.5",children:[(0,t.jsx)(Lm,{className:"h-4 w-4"}),"Runtime Dashboard"]}),(0,t.jsx)(Nl,{children:"Worker process, scheduled jobs, and webhook deliveries"})]}),(0,t.jsx)(Qa,{className:"space-y-6",children:f?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,t.jsx)(Lm,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Worker Process"]}),f.worker?(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Status"}),(0,t.jsx)(ct,{variant:f.worker.status==="running"?"default":"secondary",children:f.worker.status})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"PID"}),(0,t.jsx)("span",{className:"font-mono text-xs",children:f.worker.pid??"—"})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Uptime"}),(0,t.jsx)("span",{className:"text-xs",children:eUt(f.worker.uptime)})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Pending RPCs"}),(0,t.jsx)("span",{className:"text-xs",children:f.worker.pendingRequests})]}),f.worker.totalCrashes>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,t.jsxs)("span",{className:"text-muted-foreground flex items-center gap-1",children:[(0,t.jsx)(Rs,{className:"h-3 w-3 text-amber-500"}),"Crashes"]}),(0,t.jsxs)("span",{className:"text-xs",children:[f.worker.consecutiveCrashes," consecutive / ",f.worker.totalCrashes," total"]})]}),f.worker.lastCrashAt&&(0,t.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Last Crash"}),(0,t.jsx)("span",{className:"text-xs",children:tUt(f.worker.lastCrashAt)})]})]})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No worker process registered."})]}),(0,t.jsx)(ml,{}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,t.jsx)(Wg,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Recent Job Runs"]}),f.recentJobRuns.length>0?(0,t.jsx)("div",{className:"space-y-2",children:f.recentJobRuns.map(q=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-muted/50 px-2 py-1.5 text-sm",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(sUt,{status:q.status}),(0,t.jsx)("span",{className:"truncate font-mono text-xs",title:q.jobKey??q.jobId,children:q.jobKey??q.jobId.slice(0,8)}),(0,t.jsx)(ct,{variant:"outline",className:"px-1 py-0 text-(length:--text-nano)",children:q.trigger})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[q.durationMs!=null?(0,t.jsx)("span",{children:Eoe(q.durationMs)}):null,(0,t.jsx)("span",{title:q.createdAt,children:Poe(q.createdAt)})]})]},q.id))}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No job runs recorded yet."})]}),(0,t.jsx)(ml,{}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,t.jsx)(Tz,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Recent Webhook Deliveries"]}),f.recentWebhookDeliveries.length>0?(0,t.jsx)("div",{className:"space-y-2",children:f.recentWebhookDeliveries.map(q=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-muted/50 px-2 py-1.5 text-sm",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)(nUt,{status:q.status}),(0,t.jsx)("span",{className:"truncate font-mono text-xs",title:q.webhookKey,children:q.webhookKey})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-muted-foreground",children:[q.durationMs!=null?(0,t.jsx)("span",{children:Eoe(q.durationMs)}):null,(0,t.jsx)("span",{title:q.createdAt,children:Poe(q.createdAt)})]})]},q.id))}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No webhook deliveries recorded yet."})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 border-t border-border/50 pt-2 text-xs text-muted-foreground",children:[(0,t.jsx)(fo,{className:"h-3 w-3"}),"Last checked: ",new Date(f.checkedAt).toLocaleTimeString()]})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Runtime diagnostics are unavailable right now."})})]}),g&&g.length>0?(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(Zi,{children:[(0,t.jsxs)(uo,{className:"text-base flex items-center gap-1.5",children:[(0,t.jsx)(fH,{className:"h-4 w-4"}),"Recent Logs"]}),(0,t.jsxs)(Nl,{children:["Last ",g.length," log entries"]})]}),(0,t.jsx)(Qa,{children:(0,t.jsx)("div",{className:"max-h-64 space-y-1 overflow-y-auto font-mono text-xs",children:g.map(q=>(0,t.jsxs)("div",{className:`flex gap-2 py-0.5 ${q.level==="error"?"text-destructive":q.level==="warn"?"text-yellow-600 dark:text-yellow-400":q.level==="debug"?"text-muted-foreground/60":"text-muted-foreground"}`,children:[(0,t.jsx)("span",{className:"shrink-0 text-muted-foreground/50",children:new Date(q.createdAt).toLocaleTimeString()}),(0,t.jsx)(ct,{variant:"outline",className:"h-4 shrink-0 px-1 text-(length:--text-nano)",children:q.level}),(0,t.jsx)("span",{className:"truncate",title:q.message,children:q.message})]},q.id))})})]}):null]}),(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)(Xs,{children:[(0,t.jsx)(Zi,{children:(0,t.jsxs)(uo,{className:"text-base flex items-center gap-1.5",children:[(0,t.jsx)(fH,{className:"h-4 w-4"}),"Health Status"]})}),(0,t.jsx)(Qa,{children:p?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Checking health..."}):h?(0,t.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Overall"}),(0,t.jsx)(ct,{variant:h.healthy?"default":"destructive",children:h.status})]}),h.checks.length>0?(0,t.jsx)("div",{className:"space-y-2 border-t border-border/50 pt-2",children:h.checks.map((q,B)=>(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("span",{className:"truncate text-muted-foreground",title:q.name,children:q.name}),q.passed?(0,t.jsx)(XTe,{className:"h-4 w-4 shrink-0 text-green-500"}):(0,t.jsx)(rc,{className:"h-4 w-4 shrink-0 text-destructive"})]},B))}):null,h.lastError?(0,t.jsx)("div",{className:"break-words rounded border border-destructive/20 bg-destructive/10 p-2 text-xs text-destructive",children:h.lastError}):null]}):(0,t.jsxs)("div",{className:"space-y-3 text-sm text-muted-foreground",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{children:"Lifecycle"}),(0,t.jsx)(ct,{variant:I,children:C})]}),(0,t.jsx)("p",{children:"Health checks run once the plugin is ready."}),d.lastError?(0,t.jsx)("div",{className:"break-words rounded border border-destructive/20 bg-destructive/10 p-2 text-xs text-destructive",children:d.lastError}):null]})})]}),(0,t.jsxs)(Xs,{children:[(0,t.jsx)(Zi,{children:(0,t.jsx)(uo,{className:"text-base",children:"Details"})}),(0,t.jsxs)(Qa,{className:"space-y-3 text-sm text-muted-foreground",children:[(0,t.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,t.jsx)("span",{children:"Plugin ID"}),(0,t.jsx)("span",{className:"font-mono text-xs text-right",children:d.id})]}),(0,t.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,t.jsx)("span",{children:"Plugin Key"}),(0,t.jsx)("span",{className:"font-mono text-xs text-right",children:d.pluginKey})]}),(0,t.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,t.jsx)("span",{children:"NPM Package"}),(0,t.jsx)("span",{className:"max-w-(--sz-170px) truncate text-right text-xs",title:d.packageName,children:d.packageName})]}),(0,t.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,t.jsx)("span",{children:"Version"}),(0,t.jsxs)("span",{className:"text-right text-foreground",children:["v",d.manifestJson.version??d.version]})]})]})]}),(0,t.jsxs)(Xs,{children:[(0,t.jsx)(Zi,{children:(0,t.jsxs)(uo,{className:"text-base flex items-center gap-1.5",children:[(0,t.jsx)(kl,{className:"h-4 w-4"}),"Permissions"]})}),(0,t.jsx)(Qa,{children:R.length>0?(0,t.jsx)("ul",{className:"space-y-2 text-sm text-muted-foreground",children:R.map(q=>(0,t.jsx)("li",{className:"rounded-md bg-muted/40 px-2.5 py-2 font-mono text-xs text-foreground/85",children:q},q))}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No special permissions requested."})})]})]})]})})]})]})}r(Hzt,"PluginSettings");function Qzt({pluginId:e,companyId:s,declarations:n}){const{data:a,isLoading:i,error:o}=ee({queryKey:s?P.plugins.localFolders(e,s):["plugins",e,"companies","none","local-folders"],queryFn:r(()=>Jo.listLocalFolders(e,s),"queryFn"),enabled:!!s}),l=new Map((a?.folders??[]).map(c=>[c.folderKey,c]));return s?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Io,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("h3",{className:"text-sm font-medium",children:"Local folders"})]}),o?(0,t.jsx)("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:o.message||"Failed to load local folder settings."}):null,i?(0,t.jsxs)("div",{className:"flex items-center gap-2 py-3 text-sm text-muted-foreground",children:[(0,t.jsx)(it,{className:"h-4 w-4 animate-spin"}),"Loading local folders..."]}):(0,t.jsx)("div",{className:"space-y-3",children:n.map(c=>(0,t.jsx)(Gzt,{pluginId:e,companyId:s,declaration:c,status:l.get(c.folderKey)},c.folderKey))})]}):(0,t.jsx)("div",{className:"rounded-md border border-border/60 bg-muted/20 px-4 py-3 text-sm text-muted-foreground",children:"Select an organization to configure this plugin's local folders."})}r(Qzt,"PluginLocalFoldersSettings");function Gzt({pluginId:e,companyId:s,declaration:n,status:a}){const i=Kt(),o=a?.path??"",[l,c]=(0,u.useState)(o),[d,m]=(0,u.useState)(null);(0,u.useEffect)(()=>{c(o),m(null)},[o,n.folderKey]);const h=ke({mutationFn:r(y=>Jo.configureLocalFolder(e,s,n.folderKey,{path:y,access:n.access,requiredDirectories:n.requiredDirectories,requiredFiles:n.requiredFiles}),"mutationFn"),onSuccess:r(y=>{m({type:y.healthy?"success":"error",text:y.healthy?"Local folder saved.":"Local folder saved, but validation still needs attention."}),i.invalidateQueries({queryKey:P.plugins.localFolders(e,s)})},"onSuccess"),onError:r(y=>{m({type:"error",text:y.message||"Failed to save local folder."})},"onError")}),p=l.trim(),f=p!==o,g=a?.access??n.access??"readWrite",v=(0,u.useCallback)(()=>{if(!p){m({type:"error",text:"Local folder path is required."});return}if(!Xzt(p)){m({type:"error",text:"Local folder must be a full absolute path."});return}m(null),h.mutate(p)},[h,p]);return(0,t.jsxs)("div",{className:"space-y-4 rounded-md border border-border/70 bg-background px-4 py-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("h4",{className:"text-sm font-medium",children:n.displayName}),(0,t.jsx)(ct,{variant:"outline",className:"font-mono text-(length:--text-nano)",children:n.folderKey}),(0,t.jsx)(ct,{variant:a?.healthy?"default":"secondary",children:a?.healthy?"Healthy":"Needs attention"})]}),n.description?(0,t.jsx)("p",{className:"max-w-3xl text-sm leading-5 text-muted-foreground",children:n.description}):null]}),(0,t.jsx)(ct,{variant:g==="readWrite"?"default":"outline",children:g==="readWrite"?"Read/write":"Read only"})]}),(0,t.jsxs)("div",{className:"grid gap-3 text-sm sm:grid-cols-3",children:[(0,t.jsx)(U$,{label:"Configured",value:a?.configured?"Yes":"No",ok:!!a?.configured}),(0,t.jsx)(U$,{label:"Readable",value:a?.readable?"Yes":"No",ok:!!a?.readable}),(0,t.jsx)(U$,{label:"Writable",value:g==="read"?"Not requested":a?.writable?"Yes":"No",ok:g==="read"||!!a?.writable})]}),a?.path?(0,t.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Configured path"}),(0,t.jsx)("div",{className:"break-all rounded-md bg-muted/60 px-2 py-1.5 font-mono text-xs text-foreground",children:a.path})]}):null,(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-muted-foreground",htmlFor:`local-folder-${n.folderKey}`,children:"Local folder path"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{id:`local-folder-${n.folderKey}`,className:"min-w-0 flex-1 rounded-md border border-border bg-background px-2.5 py-1.5 font-mono text-sm outline-none focus:border-foreground/40 focus:ring-2 focus:ring-ring/20",value:l,onChange:r(y=>{c(y.target.value),m(null)},"onChange"),placeholder:"/absolute/path/to/folder"}),(0,t.jsx)(hd,{className:"h-8"}),(0,t.jsxs)(F,{size:"sm",onClick:v,disabled:h.isPending||!f||!s,children:[h.isPending?(0,t.jsx)(it,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(Hp,{className:"h-3.5 w-3.5"}),"Save"]})]})]}),(0,t.jsx)(Yzt,{status:a,declaration:n}),a?.problems?.length?(0,t.jsxs)("div",{className:"space-y-2 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[(0,t.jsx)("div",{className:"font-medium",children:"Validation problems"}),(0,t.jsx)("ul",{className:"space-y-1",children:a.problems.map((y,w)=>(0,t.jsxs)("li",{children:[y.message,y.path?(0,t.jsxs)("span",{className:"font-mono",children:[" ",y.path]}):null]},`${y.code}:${y.path??""}:${w}`))})]}):null,d?(0,t.jsx)("div",{className:`rounded-md border px-3 py-2 text-sm ${d.type==="success"?"border-green-200 bg-green-50 text-green-700 dark:border-green-900 dark:bg-green-950/30 dark:text-green-400":"border-destructive/20 bg-destructive/10 text-destructive"}`,children:d.text}):null]})}r(Gzt,"PluginLocalFolderRow");function U$({label:e,value:s,ok:n}){return(0,t.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border/60 px-2.5 py-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:e}),(0,t.jsx)(ct,{variant:n?"default":"secondary",children:s})]})}r(U$,"FolderStatusMetric");function Yzt({status:e,declaration:s}){const n=e?.requiredDirectories??s.requiredDirectories??[],a=e?.requiredFiles??s.requiredFiles??[],i=e?.missingDirectories??n,o=e?.missingFiles??a,l=Jzt(e);return n.length===0&&a.length===0?null:(0,t.jsxs)("div",{className:"grid gap-3 text-sm md:grid-cols-2",children:[(0,t.jsx)(Toe,{title:"Required directories",items:n,missingItems:i,missingLabel:"Missing directories",inspectionUnavailable:l}),(0,t.jsx)(Toe,{title:"Required files",items:a,missingItems:o,missingLabel:"Missing files",inspectionUnavailable:l})]})}r(Yzt,"FolderRequirements");function Jzt(e){return!e?.configured||e.readable?!1:e.problems.some(s=>s.code==="missing"||s.code==="not_readable"||s.code==="not_directory")}r(Jzt,"isRootNotInspected");function Toe({title:e,items:s,missingItems:n,missingLabel:a,inspectionUnavailable:i}){return(0,t.jsxs)("div",{className:"space-y-2 rounded-md border border-border/60 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:e}),i?(0,t.jsx)(ct,{variant:"secondary",className:"text-(length:--text-nano)",children:"Not inspected"}):n.length>0?(0,t.jsxs)(ct,{variant:"destructive",className:"text-(length:--text-nano)",children:[n.length," missing"]}):(0,t.jsx)(ct,{variant:"outline",className:"text-(length:--text-nano)",children:"Present"})]}),s.length>0?(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.map(o=>{const l=n.includes(o);return(0,t.jsx)("span",{className:`rounded border px-1.5 py-0.5 font-mono text-(length:--text-micro) ${i?"border-amber-300/60 bg-amber-50 text-amber-700 dark:border-amber-800/70 dark:bg-amber-950/30 dark:text-amber-300":l?"border-destructive/30 bg-destructive/10 text-destructive":"border-border bg-muted/50 text-foreground/80"}`,children:o},o)})}):(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"None declared."}),i?(0,t.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"Configured root was not inspected."}):n.length>0?(0,t.jsxs)("p",{className:"text-xs text-destructive",children:[a,": ",n.join(", ")]}):null]})}r(Toe,"RequirementList");function Xzt(e){return e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)||e.startsWith("\\\\")}r(Xzt,"isLikelyAbsolutePath");function Zzt({pluginId:e,companyId:s,schema:n,initialValues:a,isLoading:i,pluginStatus:o,supportsConfigTest:l}){const c=Kt(),[d,m]=(0,u.useState)(()=>({...zp(n),...a??{}})),h=(0,u.useRef)(!1);(0,u.useEffect)(()=>{h.current=!1,m(zp(n))},[s,e,n]),(0,u.useEffect)(()=>{a&&!h.current&&(h.current=!0,m({...zp(n),...a}))},[a,n]);const[p,f]=(0,u.useState)({}),[g,v]=(0,u.useState)(null),[y,w]=(0,u.useState)(null),S=JSON.stringify(d)!==JSON.stringify({...zp(n),...a??{}}),j=ke({mutationFn:r(I=>{if(!s)throw new Error("Select an organization before saving plugin configuration.");return Jo.saveConfig(e,s,I)},"mutationFn"),onSuccess:r(()=>{v({type:"success",text:"Configuration saved."}),w(null),s&&c.invalidateQueries({queryKey:P.plugins.config(e,s)}),setTimeout(()=>v(null),3e3)},"onSuccess"),onError:r(I=>{v({type:"error",text:I.message||"Failed to save configuration."})},"onError")}),N=ke({mutationFn:r(I=>{if(!s)throw new Error("Select an organization before testing plugin configuration.");return Jo.testConfig(e,s,I)},"mutationFn"),onSuccess:r(I=>{I.valid?w({type:"success",text:"Configuration test passed."}):w({type:"error",text:I.message||"Configuration test failed."})},"onSuccess"),onError:r(I=>{w({type:"error",text:I.message||"Configuration test failed."})},"onError")}),_=(0,u.useCallback)(I=>{m(I),f({}),v(null)},[]),A=(0,u.useCallback)(()=>{const I=Hb(n,d);if(Object.keys(I).length>0){f(I);return}f({}),j.mutate(d)},[n,d,j]),C=(0,u.useCallback)(()=>{const I=Hb(n,d);if(Object.keys(I).length>0){f(I);return}f({}),w(null),N.mutate(d)},[n,d,N]);return i?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4",children:[(0,t.jsx)(it,{className:"h-4 w-4 animate-spin"}),"Loading configuration..."]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(_1,{schema:n,values:d,onChange:_,errors:p,disabled:j.isPending}),g&&(0,t.jsx)("div",{className:`text-sm p-2 rounded border ${g.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-destructive bg-destructive/10 border-destructive/20"}`,children:g.text}),y&&(0,t.jsx)("div",{className:`text-sm p-2 rounded border ${y.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-destructive bg-destructive/10 border-destructive/20"}`,children:y.text}),(0,t.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,t.jsx)(F,{onClick:A,disabled:j.isPending||!S,size:"sm",children:j.isPending?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(it,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):"Save Configuration"}),o==="ready"&&l&&(0,t.jsx)(F,{variant:"outline",onClick:C,disabled:N.isPending||!s,size:"sm",children:N.isPending?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(it,{className:"h-3.5 w-3.5 animate-spin"}),"Testing..."]}):"Test Configuration"})]})]})}r(Zzt,"PluginConfigForm");function eUt(e){if(e==null)return"—";const s=Math.floor(e/1e3);if(s<60)return`${s}s`;const n=Math.floor(s/60);if(n<60)return`${n}m ${s%60}s`;const a=Math.floor(n/60);return a<24?`${a}h ${n%60}m`:`${Math.floor(a/24)}d ${a%24}h`}r(eUt,"formatUptime");function Eoe(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}r(Eoe,"formatDuration");function Poe(e){const s=Date.now()-new Date(e).getTime();if(s<0)return"just now";const n=Math.floor(s/1e3);if(n<60)return`${n}s ago`;const a=Math.floor(n/60);if(a<60)return`${a}m ago`;const i=Math.floor(a/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}r(Poe,"formatRelativeTime");function tUt(e){return new Date(e).toLocaleString()}r(tUt,"formatTimestamp");function sUt({status:e}){return(0,t.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${e==="success"||e==="succeeded"?"bg-green-500":e==="failed"?"bg-red-500":e==="running"?"bg-blue-500 animate-pulse":e==="cancelled"?"bg-gray-400":"bg-amber-500"}`,title:e})}r(sUt,"JobStatusDot");function nUt({status:e}){return(0,t.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${e==="processed"||e==="success"?"bg-green-500":e==="failed"?"bg-red-500":e==="received"?"bg-blue-500":"bg-amber-500"}`,title:e})}r(nUt,"DeliveryStatusDot");function K$({adapter:e,canRemove:s,onToggle:n,onRemove:a,onReload:i,onReinstall:o,isToggling:l,isReloading:c,isReinstalling:d,overriddenBy:m,toggleTitleEnabled:h,toggleTitleDisabled:p,disabledBadgeLabel:f}){return(0,t.jsx)("li",{children:(0,t.jsxs)("div",{className:"flex items-center gap-4 px-4 py-3",children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:z("font-medium",e.disabled&&"text-muted-foreground line-through"),children:e.label&&e.label!==e.type?e.label:df(e.type)}),(0,t.jsx)(ct,{variant:"outline",children:e.source==="external"?"External":"Built-in"}),e.source==="external"&&(e.isLocalPath?(0,t.jsx)("span",{title:"Installed from local path",children:(0,t.jsx)(Io,{className:"h-4 w-4 text-amber-500"})}):(0,t.jsx)("span",{title:"Installed from npm",children:(0,t.jsx)(Eh,{className:"h-4 w-4 text-red-500"})})),e.version&&(0,t.jsxs)(ct,{variant:"secondary",className:"font-mono text-(length:--text-nano)",children:["v",e.version]}),e.overriddenBuiltin&&(0,t.jsx)(ct,{variant:"secondary",className:"text-blue-600 border-blue-400",children:"Overrides built-in"}),m&&(0,t.jsxs)(ct,{variant:"secondary",className:"text-blue-600 border-blue-400",children:["Overridden by ",m]}),e.disabled&&(0,t.jsx)(ct,{variant:"secondary",className:"text-amber-600 border-amber-400",children:f??"Hidden from menus"})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mt-0.5",children:[e.type,e.packageName&&e.packageName!==e.type&&(0,t.jsxs)(t.Fragment,{children:[" · ",e.packageName]})," · ",e.modelsCount," models"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[o&&(0,t.jsx)(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8",title:"Reinstall adapter (pull latest from npm)",disabled:d,onClick:r(()=>o(e.type),"onClick"),children:(0,t.jsx)(zo,{className:z("h-4 w-4",d&&"animate-bounce")})}),i&&(0,t.jsx)(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8",title:"Reload adapter (hot-swap)",disabled:c,onClick:r(()=>i(e.type),"onClick"),children:(0,t.jsx)(Ki,{className:z("h-4 w-4",c&&"animate-spin")})}),(0,t.jsx)(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8",title:e.disabled?h??"Show in agent menus":p??"Hide from agent menus",disabled:l,onClick:r(()=>n(e.type,!e.disabled),"onClick"),children:(0,t.jsx)(_z,{className:z("h-4 w-4",e.disabled?"text-muted-foreground":"text-green-600")})}),s&&(0,t.jsx)(F,{variant:"outline",size:"icon-sm",className:"h-8 w-8 text-destructive hover:text-destructive",title:"Remove adapter",onClick:r(()=>a(e.type),"onClick"),children:(0,t.jsx)(Ia,{className:"h-4 w-4"})})]})]})})}r(K$,"AdapterRow");function rUt(e){return fetch(`https://registry.npmjs.org/${encodeURIComponent(e)}/latest`,{signal:AbortSignal.timeout(5e3)}).then(s=>s.json()).then(s=>typeof s?.version=="string"?s.version:null).catch(()=>null)}r(rUt,"fetchNpmLatestVersion");function aUt({adapter:e,open:s,isReinstalling:n,onConfirm:a,onCancel:i}){const{data:o,isLoading:l}=ee({queryKey:["npm-latest-version",e?.packageName],queryFn:r(()=>e?.packageName?rUt(e.packageName):null,"queryFn"),enabled:s&&!!e?.packageName,staleTime:6e4}),c=e?.version&&o&&e.version===o;return(0,t.jsx)(Js,{open:s,onOpenChange:r(d=>{d||i()},"onOpenChange"),children:(0,t.jsxs)(Zs,{children:[(0,t.jsxs)(Sn,{children:[(0,t.jsx)(rn,{children:"Reinstall Adapter"}),(0,t.jsxs)(Mn,{children:["This will pull the latest version of"," ",(0,t.jsx)("strong",{children:e?.packageName})," from npm and hot-swap the running adapter module. Existing agents will use the new version on their next run."]})]}),(0,t.jsxs)("div",{className:"rounded-md border bg-muted/50 px-4 py-3 text-sm space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Package"}),(0,t.jsx)("span",{className:"font-mono",children:e?.packageName})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Current"}),(0,t.jsx)("span",{className:"font-mono",children:e?.version?`v${e.version}`:"unknown"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Latest on npm"}),(0,t.jsx)("span",{className:"font-mono",children:l?"checking...":o?`v${o}`:"unavailable"})]}),c&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground pt-1",children:"Already on the latest version."})]}),(0,t.jsxs)(br,{children:[(0,t.jsx)(F,{variant:"outline",onClick:i,disabled:n,children:"Cancel"}),(0,t.jsx)(F,{disabled:n,onClick:a,children:n?"Reinstalling...":"Reinstall"})]})]})})}r(aUt,"ReinstallDialog");function Moe(){const{selectedCompany:e}=xs(),{setBreadcrumbs:s}=Ln(),n=Kt(),{pushToast:a}=da(),[i,o]=(0,u.useState)(""),[l,c]=(0,u.useState)(""),[d,m]=(0,u.useState)(!1),[h,p]=(0,u.useState)(!1),[f,g]=(0,u.useState)(null),[v,y]=(0,u.useState)(null);(0,u.useEffect)(()=>{s([{label:e?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Adapters"}])},[e?.name,s]);const{data:w,isLoading:S}=ee({queryKey:P.adapters.all,queryFn:r(()=>Am.list(),"queryFn")}),j=r(()=>{n.invalidateQueries({queryKey:P.adapters.all})},"invalidate"),N=ke({mutationFn:r(E=>Am.install(E),"mutationFn"),onSuccess:r(E=>{j(),p(!1),o(""),c(""),m(!1),a({title:"Adapter installed",body:`Type "${E.type}" registered successfully.${E.version?` (v${E.version})`:""}`,tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Install failed",body:E.message,tone:"error"})},"onError")}),_=ke({mutationFn:r(E=>Am.remove(E),"mutationFn"),onSuccess:r(()=>{j(),a({title:"Adapter removed",tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Removal failed",body:E.message,tone:"error"})},"onError")}),A=ke({mutationFn:r(({type:E,disabled:q})=>Am.setDisabled(E,q),"mutationFn"),onSuccess:r(()=>{j()},"onSuccess"),onError:r(E=>{a({title:"Toggle failed",body:E.message,tone:"error"})},"onError")}),C=ke({mutationFn:r(({type:E,paused:q})=>Am.setOverridePaused(E,q),"mutationFn"),onSuccess:r(()=>{j()},"onSuccess"),onError:r(E=>{a({title:"Override toggle failed",body:E.message,tone:"error"})},"onError")}),I=ke({mutationFn:r(E=>Am.reload(E),"mutationFn"),onSuccess:r(E=>{j(),kF(E.type),mY(E.type),a({title:"Adapter reloaded",body:`Type "${E.type}" reloaded.${E.version?` (v${E.version})`:""}`,tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Reload failed",body:E.message,tone:"error"})},"onError")}),T=ke({mutationFn:r(E=>Am.reinstall(E),"mutationFn"),onSuccess:r(E=>{j(),kF(E.type),mY(E.type),a({title:"Adapter reinstalled",body:`Type "${E.type}" updated from npm.${E.version?` (v${E.version})`:""}`,tone:"success"})},"onSuccess"),onError:r(E=>{a({title:"Reinstall failed",body:E.message,tone:"error"})},"onError")}),R=(w??[]).filter(E=>E.source==="builtin"),L=(w??[]).filter(E=>E.source==="external"),O=(w??[]).filter(E=>E.source==="external"&&E.overriddenBuiltin).filter(E=>!R.some(q=>q.type===E.type)).map(E=>({type:E.type,label:df(E.type),overriddenBy:[E.packageName,E.version?`v${E.version}`:void 0].filter(Boolean).join(" "),overridePaused:!!E.overridePaused,menuDisabled:!!E.disabled}));if(S)return(0,t.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading adapters..."});const $=N.isPending||_.isPending||A.isPending||C.isPending||I.isPending||T.isPending;return(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Lm,{className:"h-6 w-6 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Adapters"}),(0,t.jsx)(ct,{variant:"outline",className:"text-amber-600 border-amber-400",children:"Alpha"})]}),(0,t.jsxs)(Js,{open:h,onOpenChange:p,children:[(0,t.jsx)(zw,{asChild:!0,children:(0,t.jsxs)(F,{size:"sm",className:"gap-2",children:[(0,t.jsx)(yn,{className:"h-4 w-4"}),"Install Adapter"]})}),(0,t.jsxs)(Zs,{children:[(0,t.jsxs)(Sn,{children:[(0,t.jsx)(rn,{children:"Install External Adapter"}),(0,t.jsxs)(Mn,{children:["Add an adapter from npm or a local path. The adapter package must export ",(0,t.jsx)("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:"createServerAdapter()"}),"."]})]}),(0,t.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",className:z("inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs transition-colors",d?"border-border text-muted-foreground hover:text-foreground hover:bg-accent/50":"border-foreground bg-accent text-foreground"),onClick:r(()=>m(!1),"onClick"),children:[(0,t.jsx)(Eh,{className:"h-3.5 w-3.5"}),"npm package"]}),(0,t.jsxs)("button",{type:"button",className:z("inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs transition-colors",d?"border-foreground bg-accent text-foreground":"border-border text-muted-foreground hover:text-foreground hover:bg-accent/50"),onClick:r(()=>m(!0),"onClick"),children:[(0,t.jsx)(Io,{className:"h-3.5 w-3.5"}),"Local path"]})]}),d?(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(Ws,{htmlFor:"adapterLocalPath",children:"Path to adapter package"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(_t,{id:"adapterLocalPath",className:"flex-1 font-mono text-xs",placeholder:"/mnt/e/Projects/my-adapter or E:\\Projects\\my-adapter",value:i,onChange:r(E=>o(E.target.value),"onChange")}),(0,t.jsx)(hd,{})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Accepts Linux, WSL, and Windows paths. Windows paths are auto-converted."})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(Ws,{htmlFor:"adapterPackageName",children:"Package Name"}),(0,t.jsx)(_t,{id:"adapterPackageName",placeholder:"my-paperclip-adapter",value:i,onChange:r(E=>o(E.target.value),"onChange")})]}),(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(Ws,{htmlFor:"adapterVersion",children:"Version (optional)"}),(0,t.jsx)(_t,{id:"adapterVersion",placeholder:"latest",value:l,onChange:r(E=>c(E.target.value),"onChange")})]})]})]}),(0,t.jsxs)(br,{children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>p(!1),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{onClick:r(()=>N.mutate({packageName:i,version:l||void 0,isLocalPath:d}),"onClick"),disabled:!i||N.isPending,children:N.isPending?"Installing...":"Install"})]})]})]})]}),(0,t.jsx)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(Rs,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,t.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,t.jsx)("p",{className:"font-medium text-foreground",children:"External adapters are alpha."}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"The adapter plugin system is under active development. APIs and storage format may change. Use the power icon to hide adapters from agent menus without removing them."})]})]})}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Lm,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"External Adapters"})]}),L.length===0?(0,t.jsx)(Xs,{className:"bg-muted/30",children:(0,t.jsxs)(Qa,{className:"flex flex-col items-center justify-center py-10",children:[(0,t.jsx)(Lm,{className:"h-10 w-10 text-muted-foreground mb-4"}),(0,t.jsx)("p",{className:"text-sm font-medium",children:"No external adapters installed"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Install an adapter package to extend model support."})]})}):(0,t.jsx)(Xs,{className:"block py-0",children:(0,t.jsx)("ul",{className:"divide-y",children:L.map(E=>{const q=E.overriddenBuiltin,B=q&&!!E.overridePaused,K=q?{...E,disabled:B??!1}:E;return(0,t.jsx)(K$,{adapter:K,canRemove:!0,onToggle:q?(U,D)=>C.mutate({type:U,paused:D}):(U,D)=>A.mutate({type:U,disabled:D}),onRemove:r(U=>g(U),"onRemove"),onReload:r(U=>I.mutate(U),"onReload"),onReinstall:E.isLocalPath?void 0:U=>y(E),isToggling:q?C.isPending:A.isPending,isReloading:I.isPending,isReinstalling:T.isPending,toggleTitleDisabled:q?"Pause external override":void 0,toggleTitleEnabled:q?"Resume external override":void 0,disabledBadgeLabel:q?"Override paused":void 0},E.type)})})})]}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Lm,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Built-in Adapters"})]}),R.length===0&&O.length===0?(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"No built-in adapters found."}):(0,t.jsx)(Xs,{className:"block py-0",children:(0,t.jsxs)("ul",{className:"divide-y",children:[R.map(E=>(0,t.jsx)(K$,{adapter:E,canRemove:!1,onToggle:r((q,B)=>A.mutate({type:q,disabled:B}),"onToggle"),onRemove:r(()=>{},"onRemove"),isToggling:$},E.type)),O.map(E=>(0,t.jsx)(K$,{adapter:{type:E.type,label:E.label,source:"builtin",modelsCount:0,loaded:!0,disabled:E.menuDisabled,capabilities:{supportsInstructionsBundle:!1,supportsSkills:!1,supportsLocalAgentJwt:!1,requiresMaterializedRuntimeSkills:!1,supportsAcp:!1}},canRemove:!1,onToggle:r((q,B)=>A.mutate({type:q,disabled:B}),"onToggle"),onRemove:r(()=>{},"onRemove"),isToggling:$,overriddenBy:E.overridePaused?void 0:E.overriddenBy},E.type))]})})]}),(0,t.jsx)(Js,{open:f!==null,onOpenChange:r(E=>{E||g(null)},"onOpenChange"),children:(0,t.jsxs)(Zs,{children:[(0,t.jsxs)(Sn,{children:[(0,t.jsx)(rn,{children:"Remove Adapter"}),(0,t.jsxs)(Mn,{children:["Are you sure you want to remove the ",(0,t.jsx)("strong",{children:f})," adapter? It will be unregistered and removed from the adapter store.",f&&w?.find(E=>E.type===f)?.packageName&&(0,t.jsx)(t.Fragment,{children:" npm packages will be cleaned up from disk."})," ","This action cannot be undone."]})]}),(0,t.jsxs)(br,{children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>g(null),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{variant:"destructive",disabled:_.isPending,onClick:r(()=>{f&&_.mutate(f,{onSettled:r(()=>g(null),"onSettled")})},"onClick"),children:_.isPending?"Removing...":"Remove"})]})]})}),(0,t.jsx)(aUt,{adapter:v,open:v!==null,isReinstalling:T.isPending,onConfirm:r(()=>{v&&T.mutate(v.type,{onSettled:r(()=>y(null),"onSettled")})},"onConfirm"),onCancel:r(()=>y(null),"onCancel")})]})}r(Moe,"AdapterManager");function Doe(){const e=ka(),{companyPrefix:s,pluginId:n,pluginRoutePath:a}=e,i=e["*"],{companies:o,selectedCompanyId:l}=xs(),{setBreadcrumbs:c}=Ln(),d=(0,u.useMemo)(()=>{if(!s)return null;const w=s.toUpperCase();return o.find(S=>S.issuePrefix.toUpperCase()===w)??null},[o,s]),m=!!s&&!d,h=(0,u.useMemo)(()=>d?d.id:s?null:l??null,[d,s,l]),p=(0,u.useMemo)(()=>h?o.find(w=>w.id===h)?.issuePrefix??null:null,[o,h]),{data:f}=ee({queryKey:P.plugins.uiContributions,queryFn:r(()=>Jo.listUiContributions(),"queryFn"),enabled:!!h&&(!!n||!!a)}),g=(0,u.useMemo)(()=>{if(!f)return null;if(n){const S=f.find(N=>N.pluginId===n);if(!S)return null;const j=S.slots.find(N=>N.type==="page");return j?{...j,pluginId:S.pluginId,pluginKey:S.pluginKey,pluginDisplayName:S.displayName,pluginVersion:S.version}:null}if(!a)return null;const w=f.flatMap(S=>{const j=S.slots.find(N=>N.type==="page"&&N.routePath===a);return j?[{...j,pluginId:S.pluginId,pluginKey:S.pluginKey,pluginDisplayName:S.displayName,pluginVersion:S.version}]:[]});return w.length!==1?null:w[0]??null},[n,a,f]),v=(0,u.useMemo)(()=>({companyId:h??null,companyPrefix:p}),[h,p]),y=(0,u.useMemo)(()=>{if(!a||!f)return!1;const w=f.flatMap(S=>S.slots.map(j=>({...j,pluginId:S.pluginId,pluginKey:S.pluginKey,pluginDisplayName:S.displayName,pluginVersion:S.version})));return Vz(w,a)!==null},[f,a]);if((0,u.useEffect)(()=>{if(g){if(y){c([{label:iUt(g,i)}]);return}c([{label:"Plugins",href:"/company/settings/instance/plugins"},{label:g.pluginDisplayName}])}},[g,i,c,y]),!h)return m?(0,t.jsx)(xu,{scope:"invalid_company_prefix",requestedPrefix:s}):(0,t.jsx)("div",{className:"space-y-4",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select an organization to view this page."})});if(!f)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading…"});if(!n&&a&&f.filter(w=>w.slots.some(S=>S.type==="page"&&S.routePath===a)).length>1)return(0,t.jsxs)("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:["Multiple plugins declare the route ",(0,t.jsx)("code",{children:a}),". Use the plugin-id route until the conflict is resolved."]});if(!g){if(a)return(0,t.jsx)(xu,{scope:"board"});const w=n?`/company/settings/instance/plugins/${n}`:"/company/settings/instance/plugins";return(0,t.jsx)(wn,{to:w,replace:!0})}return(0,t.jsxs)("div",{className:"space-y-4",children:[!y&&(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsx)(F,{variant:"ghost",size:"sm",asChild:!0,children:(0,t.jsxs)(Ge,{to:p?`/${p}/dashboard`:"/dashboard",children:[(0,t.jsx)(ic,{className:"h-4 w-4 mr-1"}),"Back"]})})}),(0,t.jsx)(yu,{slot:g,context:v,className:"min-h-(--sz-200px)",missingBehavior:"placeholder"})]})}r(Doe,"PluginPage");function iUt(e,s){return oUt(s)??e.displayName??e.pluginDisplayName}r(iUt,"resolveRouteSidebarPageTitle");function oUt(e){const s=(e??"").split("/").filter(Boolean).map(lUt);return s.length===0?null:s[0]==="page"&&s.length>1?Loe(s.slice(1).join("/"),{preserveCase:!0}):Loe(s[0]??null)}r(oUt,"titleFromRouteSplat");function Loe(e,s={}){const n=e?.trim();if(!n)return null;const a=n.split("/").filter(Boolean).at(-1)??n,i=(a.split("::").at(-1)??a).replace(/\.[^.]+$/,"").replace(/[-_]+/g," ").trim();return i?s.preserveCase?i:i.replace(/\b\w/g,o=>o.toUpperCase()):null}r(Loe,"titleFromPath");function lUt(e){try{return decodeURIComponent(e)}catch{return e}}r(lUt,"decodeRouteSegment");var JA="w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-sm leading-5 outline-none focus-visible:ring-2 focus-visible:ring-ring",$oe=r(e=>e.status==="fail"||e.checks.some(s=>s.code==="adapter_auth_missing"),"blocking");function cUt(){const{selectedCompanyId:e}=xs(),[s]=Ri();return e?(0,t.jsx)(dUt,{companyId:e,name:s.get("name")??"",adapterType:s.get("adapterType")??"",runnerProvider:s.get("runnerProvider")??"codex",createdAgentId:s.get("createdAgentId")},`${e}:${s.get("name")}:${s.get("adapterType")}:${s.get("runnerProvider")}`):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select an organization to create an agent."})}r(cUt,"NewAgentSetup");function dUt({companyId:e,name:s,adapterType:n,runnerProvider:a,createdAgentId:i}){const o=Hn(),l=Kt(),{openNewIssue:c}=$o(),d=uxe(`${e}:new-agent`),m=n==="paperclip_runner",h=m?a==="claude"?"claude_local":a==="opencode"?"opencode_local":"codex_local":n,p=h==="claude_local"||h==="codex_local"||h==="grok_local"?h:null,f=h==="opencode_local"||h==="pi_local",g=s7e(h),v=f||h==="hermes_local",y=v||!!lY[n],w=!["cursor_cloud","hermes_gateway"].includes(n),[S,j]=(0,u.useState)(""),[N,_]=(0,u.useState)(""),[A,C]=(0,u.useState)(""),[I,T]=(0,u.useState)("kimi"),[R,L]=(0,u.useState)(i?"saved":p?"connect":"runtime"),[O,$]=(0,u.useState)(""),E=m?[]:kT(n,O),[q,B]=(0,u.useState)(""),[K,U]=(0,u.useState)(!1),[D,V]=(0,u.useState)(""),[H,J]=(0,u.useState)("openrouter"),[X,le]=(0,u.useState)(""),[ce,te]=(0,u.useState)(null),[re,de]=(0,u.useState)(()=>h==="opencode_local"?{provider:"openrouter",method:"api_key",mode:"responsible_user"}:void 0),[Z,Y]=(0,u.useState)(null),G=re??Z?.aiConnection,[fe,se]=(0,u.useState)(""),[ae,ie]=(0,u.useState)(""),[ue,pe]=(0,u.useState)(null),be=ee({queryKey:P.agents.detail(i??"new"),queryFn:r(()=>zt.get(i,e),"queryFn"),enabled:!!i,retry:!1}),oe=ue??(be.data?.companyId===e?be.data:null),[je,_e]=(0,u.useState)(!1),[xe,Ae]=(0,u.useState)("idle"),[Ye,Oe]=(0,u.useState)(null),[Xe,me]=(0,u.useState)(null),Le=(0,u.useRef)(0),mt=(0,u.useRef)(!1);(0,u.useEffect)(()=>()=>{Le.current++},[]);const We=r(()=>{Le.current++,Oe(null),Ae("idle"),me(null)},"resetTest"),ze=ee({queryKey:P.adapters.all,queryFn:Am.list}),st=ee({queryKey:P.agents.list(e),queryFn:r(()=>zt.list(e),"queryFn")}),pt=ee({queryKey:P.environments.list(e),queryFn:r(()=>Ci.list(e),"queryFn")}),Pt=ee({queryKey:P.instance.settings,queryFn:Ir.get}),tt=ee({queryKey:P.instance.experimentalSettings,queryFn:Ir.getExperimental}),ht=ee({queryKey:P.instance.generalSettings,queryFn:Ir.getGeneral}),et=ee({queryKey:P.environments.capabilities(e),queryFn:r(()=>Ci.capabilities(e),"queryFn")}),Ie=ee({queryKey:P.agents.adapterModels(e,h,null,G?.provider),queryFn:r(()=>zt.adapterModels(e,h,{provider:G?.provider}),"queryFn"),enabled:!!h&&w,retry:!1}),Ne=ee({queryKey:P.secrets.list(e),queryFn:r(()=>hr.list(e),"queryFn"),enabled:y&&n!=="cursor_cloud"}),Je=ee({queryKey:P.secrets.myUserSecrets(e),queryFn:r(()=>hr.listMyUserSecrets(e),"queryFn"),enabled:y&&n!=="cursor_cloud",retry:!1}),ft=iK(ht.data?.executionMode,pt.data??[]),Ot=tt.data?.enableManagedSandboxOnly===!0;let es=null,bs=null;try{es=ft.forced?ft.kubernetesEnvironment?.id??null:cw({agentDefaultEnvironmentId:D||null,instanceDefaultEnvironmentId:Pt.data?.defaultEnvironmentId??null,localDefaultEnvironmentId:uw(pt.data??[]),managedSandboxOnly:Ot,managedSandboxEnvironmentId:dw(pt.data??[]),visibleEnvironmentIds:(pt.data??[]).map(Me=>Me.id)})}catch(Me){bs=Me instanceof Error?Me.message:"Could not resolve the environment."}const Ke=pt.data?.find(Me=>Me.id===es),Ve=typeof Ke?.config?.provider=="string"?Ke.config.provider:"",dt=Ke?.driver==="sandbox"&&et.data?.sandboxProviders?.[Ve]?.supportsLoginPty===!0,Be=lY[n]??g[H]??"API_KEY",as=Je.data?.find(Me=>Me.definition.key===Be&&Me.secret),Fe=Ne.data?.find(Me=>Me.key===Be&&Me.status==="active"),Ut=n==="cursor_cloud"?null:ce??(Fe?{type:"secret_ref",secretId:Fe.id,version:"latest"}:as?{type:"user_secret_ref",key:Be,version:"latest"}:null),At=n==="kimi_local"&&!!(X.trim()||Ut),Ls=!!Qc(),qe=mxe(n,{cloud:Ls,nativeRunnerEnabled:tt.data?.enableNativeRunner===!0})&&ze.data?.some(Me=>Me.type===n&&Me.loaded&&!Me.disabled&&!zm(n).comingSoon),ut=!!(qe&&!bs&&!pt.isPending&&!Pt.isPending&&!tt.isPending&&!ht.isPending&&!st.isPending&&!et.isPending&&!pt.error&&!Pt.error&&!tt.error&&!ht.error&&!st.error&&!et.error&&(!(Ot||ft.forced)||es)),Dt=xe==="running"||je;function is(Me=Z,Ee=Ut){const He={...Zg,adapterType:n,model:O||(h==="codex_local"?rw:""),thinkingEffort:q,dangerouslyBypassSandbox:n==="codex_local",envBindings:Me?.env??{},...m?{adapterSchemaValues:{provider:a==="claude"?"acpx":a,...a==="claude"?{acpxAgent:"claude"}:{}}}:{}},Ue=tN(n).buildAdapterConfig(He);return m&&Object.assign(Ue,{provider:a==="claude"?"acpx":a,...a==="claude"?{acpxAgent:"claude"}:{},...O?{model:O}:{}}),!G&&!Me?.aiConnection&&y&&Ee&&(n==="hermes_gateway"?Ue.apiKey=Ee:Ue.env={...Ue.env??{},[Be]:Ee}),n==="cursor_cloud"&&Object.assign(Ue,{repoUrl:fe.trim(),...ae.trim()?{repoStartingRef:ae.trim()}:{}}),n==="hermes_gateway"&&(Ue.apiBaseUrl=S.trim()),At&&(delete Ue.model,Ue.env={...Ue.env??{},KIMI_MODEL_NAME:{type:"plain",value:N.trim()},KIMI_MODEL_PROVIDER_TYPE:{type:"plain",value:I},...A.trim()?{KIMI_MODEL_BASE_URL:{type:"plain",value:A.trim()}}:{}}),Ue}r(is,"buildConfig");function Ts(Me=Z){if(f&&(!O.trim()||!O.includes("/")))throw new Error("Choose or enter a model in provider/model format.");if(n==="cursor_cloud"&&!/^https:\/\/github\.com\/[^/]+\/[^/]+/.test(fe.trim()))throw new Error("Enter a GitHub repository URL.");if(["cursor_cloud","hermes_gateway"].includes(n)&&!X.trim()&&!Ut)throw new Error(n==="cursor_cloud"?"Enter a Cursor API key.":`Enter ${Be} or select an organization secret.`);if(n==="hermes_gateway")try{const Ee=new URL(S.trim());if(!["https:","http:"].includes(Ee.protocol))throw new Error}catch{throw new Error("Enter the Hermes API base URL.")}if(At&&!N.trim())throw new Error("Enter the Kimi API model name.");return is(Me)}r(Ts,"preparedConfig");function jt(Me=Z){return G||Me?.aiConnection?{}:{...Me?.credentials,...y&&X.trim()?{[Be]:X.trim()}:{}}}r(jt,"pendingCredentials");async function we(Me=Z){if(!ut)return!1;const Ee=++Le.current;Ae("running"),Oe(null),me(null);try{const He=await Ts(Me),Ue=await rfe({companyId:e,adapterType:n,providerAdapter:h,adapterConfig:He,testCredentials:jt(Me),aiConnection:re??Me?.aiConnection,environmentId:es});return Ee!==Le.current?!1:(Oe(Ue),Ae($oe(Ue)?"fail":Ue.status),!$oe(Ue)&&(!p||Ue.checks.some(Gt=>Gt.code.endsWith("hello_probe_passed"))))}catch(He){return Ee===Le.current&&(me(He instanceof Error?He.message:"Could not test the agent."),Ae("fail")),!1}}r(we,"runTest");async function Pe(){if(mt.current||i||oe||!ut||!s.trim()||xe==="running"||xe==="fail"||p&&!Z)return;mt.current=!0,_e(!0),me(null);const Me=[];let Ee=!1;try{const He=Ts(),Ue=jt();if(Object.keys(Ue).length&&!await we())return;for(const[ls,Tt]of Object.entries(Ue)){const ys=await(p?ife:e7e)(e,ls,Tt);Me.push(ys),n==="hermes_gateway"&&ls==="API_SERVER_KEY"?He.apiKey=ys.binding:He.env={...He.env??{},[ls]:ys.binding}}const Gt=st.data??[],Nt=Gt.find(ls=>ls.role==="ceo"&&ls.status!=="terminated"),ts=await zt.hire(e,{name:s.trim(),appearance:d.appearance,role:Gt.length?"general":"ceo",...Nt?{reportsTo:Nt.id}:{},adapterType:n,adapterConfig:He,defaultEnvironmentId:D||(ft.forced||Ot?es:null),runtimeConfig:{...obe({heartbeatEnabled:!1}),...G?{aiConnection:G}:{}},budgetMonthlyCents:0,...Z?.storedSessionId?{storedSessionId:Z.storedSessionId}:{},...Z?.applyStoredClaudeLogin?{applyStoredClaudeLogin:!0}:{}});Ee=!0,le(""),Y(null),pe(ts.agent),d.clear(),L("saved"),o(`/agents/new?${new URLSearchParams({name:ts.agent.name,adapterType:n,runnerProvider:a,createdAgentId:ts.agent.id})}`,{replace:!0}),l.setQueryData(P.agents.detail(ts.agent.id),ts.agent),await Promise.all([l.invalidateQueries({queryKey:P.agents.list(e)}),l.invalidateQueries({queryKey:P.approvals.list(e)})])}catch(He){me(He instanceof Error?He.message:"Could not create the agent.")}finally{if(!Ee)try{await Promise.all(Me.map(He=>He.remove()))}catch{me(He=>`${He?`${He} `:""}Could not remove an unused setup credential. Remove it from Secrets before retrying.`)}l.invalidateQueries({queryKey:P.secrets.myUserSecrets(e)}),l.invalidateQueries({queryKey:P.secrets.list(e)}),mt.current=!1,_e(!1)}}if(r(Pe,"finish"),i&&!oe)return(0,t.jsx)("p",{role:be.error?"alert":"status",className:"text-sm text-muted-foreground",children:be.error?"Could not load the created agent. Return to Agents to view it.":"Loading your agent…"});if(!s||!n)return(0,t.jsx)(hxe,{open:!0,initialAdapter:n,onClose:r(()=>o("/agents/all"),"onClose"),onContinue:r(Me=>o(`/agents/new?${new URLSearchParams(Me)}`,{replace:!0}),"onContinue")});const at=[...p?["connect"]:[],"runtime","saved"],Mt={connect:"Connect",runtime:"Configure",saved:"Confirmation"},kt=oe?.defaultEnvironmentId?pt.data?.find(Me=>Me.id===oe.defaultEnvironmentId):Ke,hs=oe?.adapterConfig?.env?.KIMI_MODEL_NAME,bt=oe?.adapterConfig?.model||(typeof hs=="string"?hs:hs?.value)||O||"Default",Vt=n==="cursor_cloud"?"Cursor Cloud":n==="hermes_gateway"?"Hermes Gateway":kt?mw(kt):"Local machine",Wt=ze.error??pt.error??Pt.error??tt.error??ht.error??st.error??et.error;return(0,t.jsx)(Upe,{reducedMotion:"user",children:(0,t.jsxs)("div",{className:"mx-auto flex max-w-5xl flex-col gap-8 py-6",children:[(0,t.jsxs)("header",{className:"flex items-center gap-4",children:[(0,t.jsx)(uC,{appearance:oe?.appearance??d.appearance,size:256,className:"size-48",trackingScope:"page",state:oe||xe==="pass"?"success":xe==="running"?"loading":"sleepy",muted:!oe&&xe!=="pass"}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:s}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(cK,{type:h}),(0,t.jsx)("span",{children:zm(h).label}),m&&(0,t.jsxs)("span",{children:["·"," ",a==="codex"?"Native app server runner":"Paperclip Runner"]})]})]})]}),bs&&!pt.isPending&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:bs}),Wt&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:Wt.message}),ze.data&&!qe&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"This adapter is unavailable. Choose an enabled adapter."}),(Ot||ft.forced)&&!pt.isPending&&!es&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"No managed environment is available. Configure an environment before continuing."}),(0,t.jsxs)("div",{className:"flex flex-col gap-8 md:flex-row",children:[(0,t.jsx)("nav",{"aria-label":"Agent setup steps",className:"shrink-0 md:w-44",children:(0,t.jsx)("ol",{className:"flex flex-wrap gap-2 md:flex-col",children:at.map((Me,Ee)=>(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button","aria-current":Me===R?"step":void 0,disabled:Dt||!!oe||Ee>at.indexOf(R),onClick:r(()=>L(Me),"onClick"),className:z("flex w-full items-center gap-3 rounded-md px-3 py-3 text-left text-sm",Me===R?"bg-accent font-medium":"text-muted-foreground"),children:[(0,t.jsx)("span",{className:z("flex size-6 shrink-0 items-center justify-center rounded-full border text-xs",Me===R?"border-foreground bg-foreground text-background":"border-border"),children:Ee+1}),Mt[Me]]})},Me))})}),(0,t.jsx)("div",{className:"min-w-0 flex-1",children:(0,t.jsx)(eN,{mode:"wait",initial:!1,children:(0,t.jsx)(Yo.div,{...b7e,children:R==="connect"&&p?(0,t.jsxs)(lrt,{className:"mx-auto",children:[(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(lbe,{title:"Connect a model",lede:`Connect ${s} to ${p==="claude_local"?"Claude":p==="grok_local"?"Grok":"OpenAI"}.`,center:!0})}),(0,t.jsx)(gxe,{companyId:e,adapterType:p,environmentId:es,canLogin:dt,localEnvironment:Ke?.driver==="local",onBack:r(()=>o("/agents/all"),"onBack"),testConnection:we,testError:Xe??(Ye?.checks.find(Me=>Me.level==="error")??Ye?.checks.find(Me=>Me.code.includes("hello_probe")&&Me.level==="warn"))?.message,onConnected:r(Me=>{Y(Me),We(),L("runtime")},"onConnected")},es??"local")]}):R==="saved"&&oe?(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-6 rounded-lg border border-border p-6",children:[(0,t.jsxs)("h2",{className:"flex items-center gap-3 text-lg font-semibold",children:[(0,t.jsx)(fs,{className:"size-5"}),oe.status==="pending_approval"?"Agent submitted for approval":"Your agent is ready"]}),(0,t.jsxs)("dl",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:"Adapter"}),(0,t.jsx)("dd",{children:zm(n).label}),w&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:"Model"}),(0,t.jsx)("dd",{className:"break-all",children:String(bt)})]}),(0,t.jsx)("dt",{className:"text-muted-foreground",children:"Environment"}),(0,t.jsx)("dd",{children:Vt})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:oe.status==="pending_approval"?"An organization administrator must approve this agent before it can work.":"Assign a task when you’re ready for this agent to work."})]}),(0,t.jsxs)("div",{className:"flex flex-wrap justify-between gap-3",children:[(0,t.jsxs)(F,{variant:"outline",onClick:r(()=>o(`${Qu(oe)}/runtime`),"onClick"),children:[(0,t.jsx)(Iz,{className:"size-4"}),"Edit configuration"]}),(0,t.jsxs)(F,{disabled:oe.status==="pending_approval",onClick:r(()=>c({assigneeAgentId:oe.id,status:"todo"}),"onClick"),children:["Assign ",oe.name," a Task",(0,t.jsx)(Zo,{className:"size-4"})]})]})]}):(0,t.jsxs)("form",{className:"space-y-8",onSubmit:r(Me=>{Me.preventDefault(),Pe()},"onSubmit"),children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:"Configure your agent"}),(0,t.jsxs)("fieldset",{disabled:Dt,className:"space-y-8",children:[(0,t.jsxs)("section",{className:"space-y-5",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:"Runtime"}),HU(h)&&(Z&&!G?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Using the connection selected in the Connect step."}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>L("connect"),"onClick"),children:"Change connection"})]}):(0,t.jsx)(nfe,{companyId:e,agentName:s,adapterType:h,model:O,environmentId:es??void 0,value:G,onChange:r(Me=>{de(Me),We()},"onChange")})),Ie.error&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"Could not load models. Retry or enter a model ID manually."}),(w&&!At||E.length>0)&&(0,t.jsxs)("div",{className:"grid items-start gap-5 sm:grid-cols-2",children:[w&&!At&&(0,t.jsx)(lK,{models:Ie.data??[],value:O,onChange:r(Me=>{$(Me),q&&!kT(n,Me).includes(q)&&B("");const Ee=Me.split("/")[0];f&&afe[Ee]&&Ee!==H&&(J(Ee),le(""),te(null)),We()},"onChange"),open:K,onOpenChange:U,allowDefault:!f,required:f,creatable:!0,groupByProvider:f}),E.length>0&&(0,t.jsx)(ws,{label:"Thinking effort",children:(0,t.jsxs)("select",{"aria-label":"Thinking effort",className:JA,value:q,onChange:r(Me=>{B(Me.target.value),We()},"onChange"),children:[(0,t.jsx)("option",{value:"",children:"Auto"}),E.map(Me=>(0,t.jsx)("option",{value:Me,children:Me},Me))]})})]}),cY[n]&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:cY[n]}),w&&Ie.error&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Couldn’t load models. You can enter a model ID manually."}),y&&!G&&(0,t.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[v&&(0,t.jsx)(ws,{label:"API key provider",children:(0,t.jsx)("select",{"aria-label":"API key provider",className:JA,value:H,onChange:r(Me=>{J(Me.target.value),$(""),le(""),te(null),We()},"onChange"),children:Object.keys(g).map(Me=>(0,t.jsx)("option",{value:Me,children:Me==="openrouter"?"OpenRouter":Me==="openai"?"OpenAI":Me==="anthropic"?"Anthropic":{google:"Google",xai:"xAI",groq:"Groq",opencode:"OpenCode"}[Me]??Me},Me))})}),(0,t.jsx)("div",{className:n==="cursor_cloud"?"sm:col-span-2":void 0,children:(0,t.jsx)(ws,{label:Be,children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(_t,{"aria-label":Be,type:"password",autoComplete:"off",value:X,onChange:r(Me=>{le(Me.target.value),te(null),We()},"onChange"),placeholder:Ut?"Using saved key":["cursor_cloud","hermes_gateway"].includes(n)?"Required":"Optional if already configured"}),n==="cursor_cloud"&&(0,t.jsx)("a",{href:"https://cursor.com/dashboard/api?section=user-keys#user-api-keys",target:"_blank",rel:"noopener noreferrer",className:"shrink-0 text-xs text-muted-foreground underline underline-offset-4 hover:text-foreground",children:"get api key"})]})})}),n!=="cursor_cloud"&&(0,t.jsx)("div",{className:v?"sm:col-span-2":void 0,children:(0,t.jsx)(ws,{label:"Or use an organization secret",children:(0,t.jsx)(tK,{secretId:Ut&&typeof Ut=="object"&&Ut.type==="secret_ref"?Ut.secretId:"",secrets:Ne.data??[],disabled:Dt,onSelect:r(Me=>{te({type:"secret_ref",secretId:Me,version:"latest"}),le(""),We()},"onSelect")})})}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground sm:col-span-2",children:["New keys are saved as organization secrets when you finish setup.",f&&` Use a ${H}/model ID.`]})]}),n==="hermes_gateway"&&(0,t.jsx)(ws,{label:"Hermes API base URL",children:(0,t.jsx)(_t,{"aria-label":"Hermes API base URL",value:S,onChange:r(Me=>{j(Me.target.value),We()},"onChange"),placeholder:"https://hermes.example.com"})}),At&&(0,t.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[(0,t.jsx)(ws,{label:"Kimi API model name",children:(0,t.jsx)(_t,{"aria-label":"Kimi API model name",value:N,onChange:r(Me=>{_(Me.target.value),We()},"onChange"),placeholder:"kimi-for-coding"})}),(0,t.jsx)(ws,{label:"Kimi API protocol",children:(0,t.jsx)("select",{"aria-label":"Kimi API protocol",className:JA,value:I,onChange:r(Me=>{T(Me.target.value),We()},"onChange"),children:["kimi","anthropic","openai"].map(Me=>(0,t.jsx)("option",{children:Me},Me))})}),(0,t.jsx)(ws,{label:"Kimi API base URL",hint:"Optional override for your provider endpoint.",children:(0,t.jsx)(_t,{"aria-label":"Kimi API base URL",value:A,onChange:r(Me=>{C(Me.target.value),We()},"onChange"),placeholder:"Provider default"})})]}),n==="cursor_cloud"&&(0,t.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[(0,t.jsx)(ws,{label:"GitHub repository",children:(0,t.jsx)(_t,{"aria-label":"GitHub repository",value:fe,onChange:r(Me=>{se(Me.target.value),We()},"onChange"),placeholder:"https://github.com/your-org/repo"})}),(0,t.jsx)(ws,{label:"Branch",children:(0,t.jsx)(_t,{"aria-label":"Branch",placeholder:"Repository default",value:ae,onChange:r(Me=>{ie(Me.target.value),We()},"onChange")})})]})]}),!["cursor_cloud","hermes_gateway"].includes(n)&&(0,t.jsxs)("section",{className:"space-y-5",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold",children:"Environment"}),(0,t.jsxs)("select",{"aria-label":"Environment",className:JA,value:D,disabled:ft.forced||Ot,onChange:r(Me=>{V(Me.target.value),Y(null),We(),p&&L("connect")},"onChange"),children:[(0,t.jsxs)("option",{value:"",children:["Default: ",Vt]}),(pt.data??[]).filter(Me=>Me.status==="active").map(Me=>(0,t.jsx)("option",{value:Me.id,children:mw(Me)},Me.id))]})]})]}),(0,t.jsx)(ofe,{state:xe,result:Ye,error:Xe,disabled:!ut||Dt,onTest:r(()=>{we()},"onTest")}),Xe&&xe!=="fail"&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:Xe}),(0,t.jsxs)("div",{className:"flex justify-between border-t border-border py-5",children:[p?(0,t.jsxs)(F,{type:"button",variant:"ghost",disabled:Dt,onClick:r(()=>L("connect"),"onClick"),children:[(0,t.jsx)(ic,{className:"size-4"}),"Connection"]}):(0,t.jsx)("span",{}),(0,t.jsxs)(F,{type:"submit",disabled:!ut||Dt||xe==="fail"||!!(p&&!Z),children:[je?"Creating…":"Finish setup",(0,t.jsx)(fs,{className:"size-4"})]})]})]})},R)})})]})]})})}r(dUt,"Setup");function uUt(){const{setBreadcrumbs:e}=Ln();return(0,u.useEffect)(()=>{e([{label:"Agents",href:"/agents"},{label:"New agent"}])},[e]),(0,t.jsx)(cUt,{})}r(uUt,"NewAgent");var H3="paperclip:pending-invite-token";function Y7(){return typeof window<"u"&&typeof window.localStorage<"u"}r(Y7,"canUseStorage");function Ooe(e){const s=e.trim();if(!(!s||!Y7()))try{window.localStorage.setItem(H3,s)}catch{}}r(Ooe,"rememberPendingInviteToken");function XA(e){if(Y7())try{const s=window.localStorage.getItem(H3);if(e&&s!==e.trim())return;window.localStorage.removeItem(H3)}catch{}}r(XA,"clearPendingInviteToken");function mUt(){if(!Y7())return null;try{const e=window.localStorage.getItem(H3)?.trim();return e?`/invite/${e}`:null}catch{return null}}r(mUt,"getRememberedInvitePath");var Foe=[" ",".","·","▪","▫","○"],hUt=1e3/24,ZA=[[" ╭────╮ "," ╭╯╭──╮│ "," │ │ ││ "," │ │ ││ "," │ │ ││ "," │ │ ││ "," │ ╰──╯│ "," ╰─────╯ "],[" ╭─────╮ "," │╭──╮╰╮ "," ││ │ │ "," ││ │ │ "," ││ │ │ "," ││ │ │ "," │╰──╯ │ "," ╰────╯ "]];function Boe(e){const s=document.createElement("span");s.textContent="M",s.style.cssText="position:absolute;visibility:hidden;white-space:pre;font-size:11px;font-family:monospace;line-height:1;",e.appendChild(s);const n=s.getBoundingClientRect();return e.removeChild(s),{w:n.width,h:n.height}}r(Boe,"measureChar");function pUt(e){let s=0;for(const n of e)s=Math.max(s,n.length);return{width:s,height:e.length}}r(pUt,"spriteSize");function fUt(){const e=(0,u.useRef)(null),s=(0,u.useRef)(null);return(0,u.useEffect)(()=>{if(!e.current)return;const n=e.current,a=window.matchMedia("(prefers-reduced-motion: reduce)");let i=document.visibilityState!=="hidden",o=!1,l=0,c=0,d=0,m=0,h=7,p=11,f=new Float32Array(0),g=new Float32Array(0),v=new Float32Array(0),y=new Uint16Array(0),w=[],S="";function j(E){const q=Math.floor(Math.max(0,Math.min(.999,E))*Foe.length);return Foe[q]??" "}r(j,"toGlyph");function N(){const E=Math.max(0,Math.ceil(n.clientWidth/Math.max(1,h))),q=Math.max(0,Math.ceil(n.clientHeight/Math.max(1,p)));if(E===d&&q===m)return;d=E,m=q;const B=d*m;f=new Float32Array(B),g=new Float32Array(d),v=new Float32Array(m),y=new Uint16Array(B),w=w.filter(K=>K.x>-K.width-2&&K.x<d+2&&K.y>-K.height-2&&K.y<m+2),S=""}r(N,"rebuildGrid");function _(){if(d<=0||m<=0){n.textContent="";return}const E=Array.from({length:m},()=>Array.from({length:d},()=>" "));for(let U=0;U<m;U++)for(let D=0;D<d;D++){const V=(Math.sin(D*.11+U*.04)+Math.cos(U*.08-D*.02))*.18+.22;E[U][D]=j(V)}const q=18,B=13;for(let U=1;U<m-9;U+=B){const D=Math.floor(U/B)%2===0?2:10;for(let V=D;V<d-10;V+=q){const H=ZA[(V+U)%ZA.length];for(let J=0;J<H.length;J++){const X=H[J];for(let le=0;le<X.length;le++){const ce=X[le]??" ";if(ce===" ")continue;const te=U+J,re=V+le;te<0||te>=m||re<0||re>=d||(E[te][re]=ce)}}}}const K=E.map(U=>U.join("")).join(`
724
724
  `);n.textContent=K,S=K}r(_,"drawStaticFrame");function A(){const E=ZA[Math.floor(Math.random()*ZA.length)],q=pUt(E),B=Math.random();let K=0,U=0,D=0,V=0;B<.68?(K=Math.random()<.5?-q.width-1:d+1,U=Math.random()*Math.max(1,m-q.height),D=K<0?.04+Math.random()*.05:-(.04+Math.random()*.05),V=(Math.random()-.5)*.014):(K=Math.random()*Math.max(1,d-q.width),U=Math.random()<.5?-q.height-1:m+1,D=(Math.random()-.5)*.014,V=U<0?.028+Math.random()*.034:-(.028+Math.random()*.034)),w.push({x:K,y:U,vx:D,vy:V,life:0,maxLife:260+Math.random()*220,drift:(Math.random()-.5)*1.2,sprite:E,width:q.width,height:q.height})}r(A,"spawnClip");function C(E,q){const B=Math.round(E.x),K=Math.round(E.y);for(let U=0;U<E.sprite.length;U++){const D=E.sprite[U],V=K+U;if(!(V<0||V>=m))for(let H=0;H<D.length;H++){const J=D[H]??" ";if(J===" ")continue;const X=B+H;if(X<0||X>=d)continue;const le=V*d+X,ce=J==="│"||J==="─"?.8:.92;f[le]=Math.max(f[le]??0,q*ce),y[le]=J.charCodeAt(0)}}}r(C,"stampClip");function I(E){if(!o||(s.current=requestAnimationFrame(I),E-l<hUt||d<=0||m<=0))return;const q=Math.min(2,l===0?1:(E-l)/16.6667);l=E,c+=q;const B=d*m,K=Math.max(3,Math.floor(B/2200));for(;w.length<K;)A();for(let D=0;D<f.length;D++)f[D]*=.92;y.fill(0);for(let D=w.length-1;D>=0;D--){const V=w[D];V.life+=q;const H=Math.sin((V.y+V.drift+c*.12)*.09)*.0018,J=Math.cos((V.x-V.drift-c*.09)*.08)*.0014;if(V.vx=(V.vx+H)*.998,V.vy=(V.vy+J)*.998,V.x+=V.vx*q,V.y+=V.vy*q,V.life>=V.maxLife||V.x<-V.width-2||V.x>d+2||V.y<-V.height-2||V.y>m+2){w.splice(D,1);continue}const X=V.life/V.maxLife;C(V,X<.12?X/.12:X>.88?(1-X)/.12:1)}for(let D=0;D<d;D++)g[D]=Math.sin(D*.08+c*.06);for(let D=0;D<m;D++)v[D]=Math.cos(D*.1-c*.05);let U="";for(let D=0;D<m;D++){for(let V=0;V<d;V++){const H=D*d+V,J=y[H];if(J>0){U+=String.fromCharCode(J);continue}const X=(g[V]+v[D])*.08+.1,le=Math.max(f[H]??0,X*.45);U+=j(le)}D<m-1&&(U+=`
725
- `)}U!==S&&(n.textContent=U,S=U)}r(I,"step");function T(){const E=d>0&&m>0;if(a.matches){o&&(o=!1,s.current!==null&&cancelAnimationFrame(s.current),s.current=null),E&&_();return}if(!i||!E){o&&(o=!1,s.current!==null&&cancelAnimationFrame(s.current),s.current=null);return}o||(o=!0,l=0,s.current=requestAnimationFrame(I))}r(T,"syncLoop");const R=new ResizeObserver(()=>{const E=Boe(n);h=E.w,p=E.h,N(),T()});R.observe(n);const L=r(()=>{i=document.visibilityState!=="hidden",T()},"onVisibilityChange");document.addEventListener("visibilitychange",L);const O=r(()=>{T()},"onMotionChange");a.addEventListener("change",O);const $=Boe(n);return h=$.w,p=$.h,N(),T(),()=>{o=!1,s.current!==null&&cancelAnimationFrame(s.current),R.disconnect(),document.removeEventListener("visibilitychange",L),a.removeEventListener("change",O)}},[]),(0,t.jsx)("pre",{ref:e,className:"w-full h-full m-0 p-0 overflow-hidden text-muted-foreground/60 select-none leading-none",style:{fontSize:"var(--text-micro)",fontFamily:"monospace"},"aria-hidden":"true"})}r(fUt,"AsciiArtAnimation");function xUt({decorative:e=!1,title:s="Paperclip",className:n,...a}){return(0,t.jsxs)("svg",{...a,className:n,viewBox:"22.5 22.5 121 27",fill:"currentColor",role:e?void 0:"img","aria-hidden":e?!0:void 0,"aria-label":e?void 0:s,focusable:"false",children:[(0,t.jsx)("path",{d:"M131.15 48.4902V31.9902H133.922V33.9775H134.094C134.237 33.6911 134.441 33.3831 134.706 33.0537C134.971 32.7171 135.329 32.4307 135.78 32.1943C136.239 31.958 136.822 31.8398 137.531 31.8398C138.455 31.8398 139.289 32.0762 140.034 32.5488C140.779 33.0215 141.37 33.7161 141.807 34.6328C142.251 35.5495 142.473 36.6774 142.473 38.0166C142.473 39.3343 142.258 40.4551 141.828 41.3789C141.398 42.3027 140.808 43.0081 140.056 43.4951C139.311 43.9749 138.466 44.2148 137.521 44.2148C136.84 44.2148 136.271 44.1003 135.812 43.8711C135.361 43.6348 134.996 43.3555 134.717 43.0332C134.445 42.7038 134.237 42.3923 134.094 42.0986H133.976V48.4902H131.15ZM136.747 41.8945C137.37 41.8945 137.889 41.7262 138.305 41.3896C138.727 41.0531 139.046 40.5911 139.261 40.0039C139.476 39.4167 139.583 38.7507 139.583 38.0059C139.583 37.2611 139.476 36.5986 139.261 36.0186C139.046 35.4385 138.731 34.9837 138.315 34.6543C137.9 34.3249 137.377 34.1602 136.747 34.1602C136.138 34.1602 135.623 34.3177 135.2 34.6328C134.785 34.9479 134.466 35.3955 134.244 35.9756C134.029 36.5485 133.922 37.2253 133.922 38.0059C133.922 38.7793 134.029 39.4596 134.244 40.0469C134.466 40.627 134.788 41.0817 135.211 41.4111C135.633 41.7334 136.146 41.8945 136.747 41.8945Z"}),(0,t.jsx)("path",{d:"M126.451 44V31.9902H129.276V44H126.451ZM127.869 30.3037C127.417 30.3037 127.031 30.1533 126.708 29.8525C126.386 29.5518 126.225 29.1901 126.225 28.7676C126.225 28.3379 126.386 27.9727 126.708 27.6719C127.031 27.3711 127.417 27.2207 127.869 27.2207C128.313 27.2207 128.696 27.3711 129.018 27.6719C129.34 27.9727 129.501 28.3343 129.501 28.7568C129.501 29.1865 129.34 29.5518 129.018 29.8525C128.696 30.1533 128.313 30.3037 127.869 30.3037Z"}),(0,t.jsx)("path",{d:"M124.576 27.9941V44H121.75V27.9941H124.576Z"}),(0,t.jsx)("path",{d:"M115.3 44.2363C114.104 44.2363 113.076 43.9749 112.217 43.4521C111.357 42.9222 110.699 42.1917 110.24 41.2607C109.782 40.3298 109.553 39.2591 109.553 38.0488C109.553 36.8242 109.785 35.7464 110.251 34.8154C110.716 33.8844 111.379 33.1576 112.238 32.6348C113.098 32.1048 114.111 31.8398 115.278 31.8398C116.259 31.8398 117.126 32.0189 117.878 32.377C118.63 32.735 119.228 33.2399 119.672 33.8916C120.123 34.5361 120.381 35.2917 120.445 36.1582H117.738C117.667 35.7715 117.527 35.4242 117.319 35.1162C117.112 34.8083 116.84 34.5648 116.503 34.3857C116.174 34.2067 115.78 34.1172 115.321 34.1172C114.741 34.1172 114.233 34.2747 113.796 34.5898C113.366 34.8978 113.03 35.3418 112.786 35.9219C112.543 36.502 112.421 37.1966 112.421 38.0059C112.421 38.8223 112.539 39.5277 112.775 40.1221C113.012 40.7093 113.348 41.1641 113.785 41.4863C114.222 41.8014 114.734 41.959 115.321 41.959C115.944 41.959 116.471 41.7764 116.9 41.4111C117.337 41.0459 117.617 40.541 117.738 39.8965H120.445C120.381 40.7487 120.13 41.5007 119.693 42.1523C119.257 42.804 118.666 43.3161 117.921 43.6885C117.176 44.0537 116.302 44.2363 115.3 44.2363Z"}),(0,t.jsx)("path",{d:"M102.876 44V31.9902H105.615V34.0098H105.744C105.959 33.3079 106.335 32.7708 106.872 32.3984C107.409 32.0189 108.021 31.8291 108.709 31.8291C108.859 31.8291 109.031 31.8363 109.225 31.8506C109.425 31.8649 109.59 31.8828 109.719 31.9043V34.5039C109.597 34.4609 109.407 34.4251 109.149 34.3965C108.892 34.3678 108.645 34.3535 108.408 34.3535C107.885 34.3535 107.42 34.4645 107.012 34.6865C106.604 34.9085 106.281 35.2129 106.045 35.5996C105.816 35.9863 105.701 36.4375 105.701 36.9531V44H102.876Z"}),(0,t.jsx)("path",{d:"M96.2319 44.2363C95.0288 44.2363 93.9904 43.9857 93.1167 43.4844C92.243 42.9759 91.5698 42.2598 91.0972 41.3359C90.6317 40.4121 90.3989 39.3236 90.3989 38.0703C90.3989 36.8314 90.6317 35.7464 91.0972 34.8154C91.5627 33.8773 92.2179 33.1468 93.063 32.624C93.908 32.1012 94.9035 31.8398 96.0493 31.8398C96.7869 31.8398 97.4852 31.958 98.144 32.1943C98.8101 32.4307 99.3973 32.7959 99.9058 33.29C100.421 33.7842 100.826 34.4144 101.12 35.1807C101.413 35.9398 101.56 36.8457 101.56 37.8984V38.7793H91.7202V36.8779H100.153L98.8315 37.4365C98.8315 36.7562 98.7277 36.1654 98.52 35.6641C98.3123 35.1556 98.0044 34.7581 97.5962 34.4717C97.188 34.1852 96.6795 34.042 96.0708 34.042C95.4621 34.042 94.9429 34.1852 94.5132 34.4717C94.0835 34.7581 93.7576 35.1449 93.5356 35.6318C93.3136 36.1117 93.2026 36.6488 93.2026 37.2432V38.5645C93.2026 39.2949 93.328 39.9215 93.5786 40.4443C93.8364 40.96 94.1945 41.3538 94.6528 41.626C95.1183 41.8981 95.659 42.0342 96.2749 42.0342C96.6759 42.0342 97.0412 41.9769 97.3706 41.8623C97.7072 41.7477 97.9937 41.5758 98.23 41.3467C98.4735 41.1104 98.6597 40.8203 98.7886 40.4766L101.431 40.7881C101.259 41.4827 100.941 42.0915 100.475 42.6143C100.017 43.1299 99.4259 43.5309 98.7026 43.8174C97.9865 44.0967 97.1629 44.2363 96.2319 44.2363Z"}),(0,t.jsx)("path",{d:"M78.2437 48.4902V31.9902H81.0151V33.9775H81.187C81.3302 33.6911 81.5343 33.3831 81.7993 33.0537C82.0643 32.7171 82.4224 32.4307 82.8735 32.1943C83.3319 31.958 83.9155 31.8398 84.6245 31.8398C85.5483 31.8398 86.3826 32.0762 87.1274 32.5488C87.8722 33.0215 88.4631 33.7161 88.8999 34.6328C89.3439 35.5495 89.5659 36.6774 89.5659 38.0166C89.5659 39.3343 89.3511 40.4551 88.9214 41.3789C88.4917 42.3027 87.9009 43.0081 87.1489 43.4951C86.4041 43.9749 85.5591 44.2148 84.6138 44.2148C83.9334 44.2148 83.3641 44.1003 82.9058 43.8711C82.4546 43.6348 82.0894 43.3555 81.8101 43.0332C81.5379 42.7038 81.3302 42.3923 81.187 42.0986H81.0688V48.4902H78.2437ZM83.8403 41.8945C84.4634 41.8945 84.9826 41.7262 85.3979 41.3896C85.8205 41.0531 86.1392 40.5911 86.354 40.0039C86.5688 39.4167 86.6763 38.7507 86.6763 38.0059C86.6763 37.2611 86.5688 36.5986 86.354 36.0186C86.1392 35.4385 85.8241 34.9837 85.4087 34.6543C84.9933 34.3249 84.4705 34.1602 83.8403 34.1602C83.2316 34.1602 82.716 34.3177 82.2935 34.6328C81.8781 34.9479 81.5594 35.3955 81.3374 35.9756C81.1226 36.5485 81.0151 37.2253 81.0151 38.0059C81.0151 38.7793 81.1226 39.4596 81.3374 40.0469C81.5594 40.627 81.8817 41.0817 82.3042 41.4111C82.7267 41.7334 83.2388 41.8945 83.8403 41.8945Z"}),(0,t.jsx)("path",{d:"M70.042 44.2471C69.2757 44.2471 68.5882 44.111 67.9795 43.8389C67.3708 43.5596 66.891 43.1514 66.54 42.6143C66.1891 42.0771 66.0137 41.4147 66.0137 40.627C66.0137 39.9538 66.139 39.3952 66.3896 38.9512C66.6403 38.5072 66.9805 38.1527 67.4102 37.8877C67.847 37.6227 68.3376 37.4222 68.8818 37.2861C69.4261 37.1429 69.9883 37.0426 70.5684 36.9854C71.2773 36.9066 71.8503 36.8385 72.2871 36.7812C72.724 36.724 73.0391 36.6309 73.2324 36.502C73.4329 36.373 73.5332 36.1725 73.5332 35.9004V35.8467C73.5332 35.2666 73.3613 34.8154 73.0176 34.4932C72.6738 34.1709 72.1725 34.0098 71.5137 34.0098C70.819 34.0098 70.2676 34.1602 69.8594 34.4609C69.4583 34.7617 69.1862 35.1162 69.043 35.5244L66.4111 35.1484C66.6188 34.418 66.9626 33.8092 67.4424 33.3223C67.9222 32.8281 68.5059 32.4593 69.1934 32.2158C69.888 31.9652 70.6543 31.8398 71.4922 31.8398C72.0651 31.8398 72.638 31.9079 73.2109 32.0439C73.7839 32.1729 74.3102 32.3949 74.79 32.71C75.2699 33.0251 75.653 33.4476 75.9395 33.9775C76.2259 34.5075 76.3691 35.1699 76.3691 35.9648V44H73.6514V42.3457H73.5654C73.3936 42.6751 73.1501 42.9867 72.835 43.2803C72.527 43.5667 72.1403 43.7995 71.6748 43.9785C71.2165 44.1576 70.6722 44.2471 70.042 44.2471ZM70.7617 42.1631C71.3346 42.1631 71.8288 42.0521 72.2441 41.8301C72.6595 41.6009 72.9818 41.3001 73.2109 40.9277C73.4401 40.5482 73.5547 40.1364 73.5547 39.6924V38.2852C73.4616 38.3568 73.3112 38.4248 73.1035 38.4893C72.8958 38.5465 72.6595 38.6003 72.3945 38.6504C72.1296 38.7005 71.8682 38.7435 71.6104 38.7793C71.3597 38.8151 71.1413 38.8438 70.9551 38.8652C70.5326 38.9225 70.153 39.0192 69.8164 39.1553C69.487 39.2842 69.2256 39.4632 69.0322 39.6924C68.8389 39.9215 68.7422 40.2188 68.7422 40.584C68.7422 41.1068 68.932 41.5007 69.3115 41.7656C69.6911 42.0306 70.1745 42.1631 70.7617 42.1631Z"}),(0,t.jsx)("path",{d:"M53.7939 44V27.9941H59.7988C61.0306 27.9941 62.0618 28.2233 62.8926 28.6816C63.7305 29.14 64.3643 29.7702 64.7939 30.5723C65.2236 31.3743 65.4385 32.2839 65.4385 33.3008C65.4385 34.3249 65.2201 35.238 64.7832 36.04C64.3535 36.835 63.7161 37.4616 62.8711 37.9199C62.026 38.3711 60.9876 38.5967 59.7559 38.5967H55.7812V36.2119H59.3584C60.0817 36.2119 60.6725 36.0902 61.1309 35.8467C61.5964 35.596 61.9365 35.2523 62.1514 34.8154C62.3734 34.3714 62.4844 33.8665 62.4844 33.3008C62.4844 32.7279 62.3734 32.2266 62.1514 31.7969C61.9365 31.36 61.5964 31.0234 61.1309 30.7871C60.6725 30.5436 60.0781 30.4219 59.3477 30.4219H56.6943V44H53.7939Z"}),(0,t.jsx)("path",{d:"M46.2611 33.6556L34.7307 44.6408C32.7445 46.5331 29.5205 46.5323 27.5303 44.6361C25.5404 42.74 25.54 39.669 27.5261 37.7768L39.0565 26.7916C40.2474 25.657 42.1811 25.6567 43.3752 26.7943C44.5693 27.9319 44.5689 29.7742 43.378 30.9088L31.849 41.8954C31.4528 42.2728 30.8077 42.273 30.4092 41.8933C30.011 41.5136 30.0117 40.8996 30.4078 40.5223L41.9382 29.5371C42.336 29.1581 42.336 28.5437 41.9382 28.1647C41.5404 27.786 40.8954 27.7858 40.4977 28.1647L28.9673 39.1499C27.7742 40.2866 27.7764 42.1295 28.9687 43.2657C30.1613 44.402 32.0963 44.4046 33.2895 43.2678L44.8192 32.2805C46.8068 30.3865 46.8038 27.3159 44.8157 25.4219C42.8275 23.5277 39.6039 23.5253 37.616 25.4192L26.0856 36.4044C23.3024 39.056 23.3058 43.3558 26.0898 46.0085C28.8741 48.6612 33.388 48.6649 36.1712 46.0132L47.7017 35.028C48.0994 34.649 48.0994 34.0346 47.7017 33.6556C47.3039 33.2766 46.6589 33.2766 46.2611 33.6556Z"})]})}r(xUt,"PaperclipLockup");function gUt(){const e=Kt(),s=Hn(),[n]=Ri(),[a,i]=(0,u.useState)("sign_in"),[o,l]=(0,u.useState)(""),[c,d]=(0,u.useState)(""),[m,h]=(0,u.useState)(""),[p,f]=(0,u.useState)(null),g="auth-error",v=(0,u.useMemo)(()=>n.get("next")||mUt()||"/",[n]),{data:y,isLoading:w}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1});(0,u.useEffect)(()=>{y&&s(v,{replace:!0})},[y,s,v]);const S=ke({mutationFn:r(async()=>{if(a==="sign_in"){await Fa.signInEmail({email:c.trim(),password:m});return}await Fa.signUpEmail({name:o.trim(),email:c.trim(),password:m})},"mutationFn"),onSuccess:r(async()=>{f(null),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.resetQueries({queryKey:P.companies.all}),s(v,{replace:!0})},"onSuccess"),onError:r(N=>{f(N instanceof Error?N.message:"Authentication failed")},"onError")}),j=c.trim().length>0&&m.trim().length>0&&(a==="sign_in"||o.trim().length>0&&m.trim().length>=8);return w?(0,t.jsx)("div",{className:"fixed inset-0 flex items-center justify-center",children:(0,t.jsx)(Jm,{className:"min-h-0"})}):(0,t.jsxs)("div",{className:"fixed inset-0 flex bg-background",children:[(0,t.jsx)("div",{className:"absolute top-4 right-4 z-10",children:(0,t.jsx)(Aj,{})}),(0,t.jsx)("div",{className:"w-full md:w-1/2 flex flex-col overflow-y-auto",children:(0,t.jsxs)("div",{className:"w-full max-w-md mx-auto my-auto px-8 py-12",children:[(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(xUt,{className:"h-5 w-auto"})}),(0,t.jsx)("h1",{className:"text-xl font-semibold",children:a==="sign_in"?"Sign in to Paperclip":"Create your Paperclip account"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:a==="sign_in"?"Use your email and password to access this instance.":"Create an account for this instance. Email confirmation is not required in v1."}),(0,t.jsxs)("form",{className:"mt-6 space-y-4",method:"post",action:a==="sign_up"?"/api/auth/sign-up/email":"/api/auth/sign-in/email",onSubmit:r(N=>{if(N.preventDefault(),!S.isPending){if(!j){f("Please fill in all required fields.");return}S.mutate()}},"onSubmit"),children:[a==="sign_up"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"name",className:"text-xs text-muted-foreground mb-1 block",children:"Name"}),(0,t.jsx)("input",{id:"name",name:"name",className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",value:o,onChange:r(N=>l(N.target.value),"onChange"),autoComplete:"name",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0,autoFocus:!0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"email",className:"text-xs text-muted-foreground mb-1 block",children:"Email"}),(0,t.jsx)("input",{id:"email",name:"email",className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",type:"email",value:c,onChange:r(N=>d(N.target.value),"onChange"),autoComplete:"username",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0,autoFocus:a==="sign_in"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"password",className:"text-xs text-muted-foreground mb-1 block",children:"Password"}),(0,t.jsx)("input",{id:"password",name:"password",className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",type:"password",value:m,onChange:r(N=>h(N.target.value),"onChange"),autoComplete:a==="sign_in"?"current-password":"new-password",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0})]}),p&&(0,t.jsx)("p",{id:g,role:"alert",className:"text-xs text-destructive",children:p}),(0,t.jsx)(F,{type:"submit",disabled:S.isPending,"aria-disabled":!j||S.isPending,className:`w-full ${!j&&!S.isPending?"opacity-50":""}`,children:S.isPending?"Working…":a==="sign_in"?"Sign In":"Create Account"})]}),(0,t.jsxs)("div",{className:"mt-5 text-sm text-muted-foreground",children:[a==="sign_in"?"Need an account?":"Already have an account?"," ",(0,t.jsx)("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:r(()=>{f(null),i(a==="sign_in"?"sign_up":"sign_in")},"onClick"),children:a==="sign_in"?"Create one":"Sign in"})]})]})}),(0,t.jsx)("div",{className:"hidden md:block w-1/2 overflow-hidden",children:(0,t.jsx)(fUt,{})})]})}r(gUt,"AuthPage");function bUt(){const e=Kt(),s=ka(),[n]=Ri(),a=(s.token??"").trim(),i=(n.get("code")??"").trim(),o=(0,u.useMemo)(()=>`/board-claim/${encodeURIComponent(a)}${i?`?code=${encodeURIComponent(i)}`:""}`,[a,i]),l=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),c=ee({queryKey:["board-claim",a,i],queryFn:r(()=>ur.getBoardClaimStatus(a,i),"queryFn"),enabled:a.length>0&&i.length>0,retry:!1}),d=ke({mutationFn:r(()=>ur.claimBoard(a,i),"mutationFn"),onSuccess:r(async()=>{await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.invalidateQueries({queryKey:P.companies.all}),await e.invalidateQueries({queryKey:P.companies.stats}),await c.refetch()},"onSuccess")});if(!a||!i)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid board claim URL."});if(c.isLoading||l.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading claim challenge..."});if(c.error)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Claim challenge unavailable"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:c.error instanceof Error?c.error.message:"Challenge is invalid or expired."})]})});const m=c.data;return m?m.status==="claimed"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Board ownership claimed"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This instance is now linked to your authenticated user."}),(0,t.jsx)(F,{asChild:!0,className:"mt-4",children:(0,t.jsx)(Ge,{to:"/",children:"Open board"})})]})}):l.data?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Claim Board ownership"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This will promote your user to instance admin and migrate organization ownership access from local trusted mode."}),d.error&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive",children:d.error instanceof Error?d.error.message:"Failed to claim board ownership"}),(0,t.jsx)(F,{className:"mt-5",onClick:r(()=>d.mutate(),"onClick"),disabled:d.isPending,children:d.isPending?"Claiming…":"Claim ownership"})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Sign in required"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Sign in or create an account, then return to this page to claim Board ownership."}),(0,t.jsx)(F,{asChild:!0,className:"mt-4",children:(0,t.jsx)(Ge,{to:`/auth?next=${encodeURIComponent(o)}`,children:"Sign in / Create account"})})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Claim challenge unavailable."})}r(bUt,"BoardClaimPage");function vUt(){const e=Kt(),s=ka(),[n]=Ri(),a=(s.id??"").trim(),i=(n.get("token")??"").trim(),o=(0,u.useMemo)(()=>`/cli-auth/${encodeURIComponent(a)}${i?`?token=${encodeURIComponent(i)}`:""}`,[a,i]),l=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),c=ee({queryKey:["cli-auth-challenge",a,i],queryFn:r(()=>ur.getCliAuthChallenge(a,i),"queryFn"),enabled:a.length>0&&i.length>0,retry:!1}),d=ke({mutationFn:r(()=>ur.approveCliAuthChallenge(a,i),"mutationFn"),onSuccess:r(async()=>{await e.invalidateQueries({queryKey:P.auth.session}),await c.refetch()},"onSuccess")}),m=ke({mutationFn:r(()=>ur.cancelCliAuthChallenge(a,i),"mutationFn"),onSuccess:r(async()=>{await c.refetch()},"onSuccess")});if(!a||!i)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid CLI auth URL."});if(l.isLoading||c.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading CLI auth challenge..."});if(c.error)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"CLI auth challenge unavailable"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:c.error instanceof Error?c.error.message:"Challenge is invalid or expired."})]})});const h=c.data;return h?h.status==="approved"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"CLI access approved"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"The Paperclip CLI can now finish authentication on the requesting machine."}),(0,t.jsxs)("p",{className:"mt-4 text-sm text-muted-foreground",children:["Command: ",(0,t.jsx)("span",{className:"font-mono text-foreground",children:h.command})]})]})}):h.status==="cancelled"||h.status==="expired"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:h.status==="expired"?"CLI auth challenge expired":"CLI auth challenge cancelled"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Start the CLI auth flow again from your terminal to generate a new approval request."})]})}):h.requiresSignIn||!l.data?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Sign in required"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Sign in or create an account, then return to this page to approve the CLI access request."}),(0,t.jsx)(F,{asChild:!0,className:"mt-4",children:(0,t.jsx)(Ge,{to:`/auth?next=${encodeURIComponent(o)}`,children:"Sign in / Create account"})})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Approve Paperclip CLI access"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"A local Paperclip CLI process is requesting board access to this instance."}),(0,t.jsxs)("div",{className:"mt-5 space-y-3 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Command"}),(0,t.jsx)("div",{className:"font-mono text-foreground",children:h.command})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Client"}),(0,t.jsx)("div",{className:"text-foreground",children:h.clientName??"paperclip-pro cli"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Requested access"}),(0,t.jsx)("div",{className:"text-foreground",children:h.requestedAccess==="instance_admin_required"?"Instance admin":"Board"})]}),h.requestedCompanyName&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Requested organization"}),(0,t.jsx)("div",{className:"text-foreground",children:h.requestedCompanyName})]})]}),(d.error||m.error)&&(0,t.jsx)("p",{className:"mt-4 text-sm text-destructive",children:(d.error??m.error)instanceof Error?(d.error??m.error).message:"Failed to update CLI auth challenge"}),!h.canApprove&&(0,t.jsx)("p",{className:"mt-4 text-sm text-destructive",children:"This challenge requires instance-admin access. Sign in with an instance admin account to approve it."}),(0,t.jsxs)("div",{className:"mt-5 flex gap-3",children:[(0,t.jsx)(F,{onClick:r(()=>d.mutate(),"onClick"),disabled:!h.canApprove||d.isPending||m.isPending,children:d.isPending?"Approving...":"Approve CLI access"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>m.mutate(),"onClick"),disabled:d.isPending||m.isPending,children:m.isPending?"Cancelling...":"Cancel"})]})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"CLI auth challenge unavailable."})}r(vUt,"CliAuthPage");var yUt=MIe.filter(e=>e!=="paperclip_runner"),qoe=new Set(["claude_local","codex_local","gemini_local","kimi_local","opencode_local","pi_local","cursor"]);function jUt(e,s){let n=e;for(const a of s){if(!n||typeof n!="object")return null;n=n[a]}return typeof n=="string"&&n.trim().length>0?n:null}r(jUt,"readNestedString");var By="w-full border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-zinc-500",zoe="border border-zinc-800 bg-zinc-950/95 p-6",Uoe="flex-1 border px-3 py-2 text-sm transition-colors";function wUt(e){return e?e.charAt(0).toUpperCase()+e.slice(1):null}r(wUt,"formatHumanRole");function c1e(e){if(!e||typeof e!="object")return null;const s=e.code;return typeof s=="string"&&s.trim().length>0?s:null}r(c1e,"getAuthErrorCode");function NUt(e){if(!(e instanceof Error))return null;const s=e.message.trim();return s.length>0?s:null}r(NUt,"getAuthErrorMessage");function kUt(e,s,n){const a=c1e(e),i=NUt(e),o=n.trim().length>0?n.trim():"that email";return a==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"?{tone:"info",message:`An account already exists for ${o}. Sign in below to continue with this invite.`}:a==="INVALID_EMAIL_OR_PASSWORD"?{tone:"error",message:"That email and password did not match an existing Paperclip account. Check both fields, or create an account first if you are new here."}:s==="sign_in"&&i==="Request failed: 401"?{tone:"error",message:"That email and password did not match an existing Paperclip account. Check both fields, or create an account first if you are new here."}:s==="sign_up"&&i==="Request failed: 422"?{tone:"info",message:`An account may already exist for ${o}. Try signing in instead.`}:{tone:"error",message:i??"Authentication failed"}}r(kUt,"mapInviteAuthFeedback");function Koe(e){return!!(e&&typeof e=="object"&&"bootstrapAccepted"in e)}r(Koe,"isBootstrapAcceptancePayload");function SUt(e,s){return!e||typeof e!="object"||s?!1:e.status==="approved"}r(SUt,"isApprovedHumanJoinPayload");function W6({companyDisplayName:e,companyLogoUrl:s,className:n}){return(0,t.jsx)(Dx,{companyName:e,logoUrl:s,logoFit:"contain",className:n})}r(W6,"InviteCompanyLogo");function Voe({companyDisplayName:e,companyLogoUrl:s,invitedByUserName:n,claimSecret:a=null,claimApiKeyPath:i=null,onboardingTextUrl:o=null}){return(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6","data-testid":"invite-pending-approval",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(W6,{companyDisplayName:e,companyLogoUrl:s,className:"h-12 w-12 border border-zinc-800 rounded-none"}),(0,t.jsxs)("h1",{className:"text-lg font-semibold",children:["Request to join ",e]})]}),(0,t.jsxs)("div",{className:"mt-4 space-y-3",children:[(0,t.jsxs)("p",{className:"text-sm text-zinc-400",children:["Your request is still awaiting approval. ",n??"An organization admin"," must approve your request to join."]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("p",{className:"text-xs text-zinc-500 mb-1",children:"Approval page"}),(0,t.jsx)("p",{className:"text-sm text-zinc-200",children:"Settings → Members"})]}),(0,t.jsxs)("p",{className:"text-sm text-zinc-400",children:["Ask them to visit ",(0,t.jsx)("span",{className:"text-zinc-200",children:"Settings → Members"})," to approve your request."]}),(0,t.jsx)("p",{className:"text-xs text-zinc-500",children:"Refresh this page after you've been approved — you'll be redirected automatically."})]}),a&&i?(0,t.jsxs)("div",{className:"mt-4 space-y-1 border border-zinc-800 p-3 text-xs text-zinc-400",children:[(0,t.jsx)("div",{className:"text-zinc-200",children:"Claim secret"}),(0,t.jsx)("div",{className:"font-mono break-all",children:a}),(0,t.jsxs)("div",{className:"font-mono break-all",children:["POST ",i]})]}):null,o?(0,t.jsxs)("div",{className:"mt-4 text-xs text-zinc-400",children:["Onboarding: ",(0,t.jsx)("span",{className:"font-mono break-all",children:o})]}):null]})})}r(Voe,"AwaitingJoinApprovalPanel");function CUt(){const e=Kt(),s=Hn(),{setSelectedCompanyId:n}=xs(),a=(ka().token??"").trim(),[i,o]=(0,u.useState)("sign_up"),[l,c]=(0,u.useState)(""),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(""),[f,g]=(0,u.useState)(""),[v,y]=(0,u.useState)("claude_local"),[w,S]=(0,u.useState)(""),[j,N]=(0,u.useState)(null),[_,A]=(0,u.useState)(null),[C,I]=(0,u.useState)(null),[T,R]=(0,u.useState)(!1),L="invite-auth-error",O=ee({queryKey:P.health,queryFn:r(()=>tm.get(),"queryFn"),retry:!1}),$=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),E=ee({queryKey:P.access.invite(a),queryFn:r(()=>ur.getInvite(a),"queryFn"),enabled:a.length>0,retry:!1}),q=Q6({enabled:!!$.data&&!!E.data?.companyId,staleTime:0}),B=O.data?.deploymentMode!=="local_trusted"?q.isFetchedAfterMount:!0,K=B?q.data?.companies??[]:[];(0,u.useEffect)(()=>{a&&Ooe(a)},[a]),(0,u.useEffect)(()=>{R(!1)},[a]),(0,u.useEffect)(()=>{if(!B)return;const pe=q.data?.companies;!pe||!E.data?.companyId||pe.some(be=>be.id===E.data.companyId)&&XA(a)},[q.data,E.data,B,a]);const U=E.data,D=!!$.data&&!!U?.companyId&&!B,V=!!U?.companyId&&K.some(pe=>pe.id===U?.companyId),H=U?.companyName?.trim()||"this Paperclip company",J=U?.companyLogoUrl?.trim()||null,X=U?.invitedByUserName?.trim()||null,le=U?.inviteMessage?.trim()||null,ce=wUt(U?.humanRole),te=U?.joinRequestStatus??null,re=U?.joinRequestType??null,de=re==="human"&&(te==="pending_approval"||te==="approved"),Z=O.data?.deploymentMode==="authenticated"&&!$.data&&U?.allowedJoinTypes!=="agent",Y=U?.inviteType!=="bootstrap_ceo"&&U?.allowedJoinTypes==="agent",G=!!$.data&&!Y&&U?.inviteType!=="bootstrap_ceo"&&(!te||de)&&!D&&!V&&!j&&_===null,fe=$.data?.user.name?.trim()||$.data?.user.email?.trim()||"this account",se=d.trim().length>0&&h.trim().length>0&&(i==="sign_in"||l.trim().length>0&&h.trim().length>=8),ae=ke({mutationFn:r(async()=>{if(!U)throw new Error("Invite not found");if(D)throw new Error("Checking your organization access. Try again in a moment.");if(V)throw new Error("This account already belongs to the organization.");return U.inviteType==="bootstrap_ceo"||U.allowedJoinTypes!=="agent"?ur.acceptInvite(a,{requestType:"human"}):ur.acceptInvite(a,{requestType:"agent",agentName:f.trim(),adapterType:v,capabilities:w.trim()||null})},"mutationFn"),onSuccess:r(async pe=>{A(null),XA(a);const be=Koe(pe);N({kind:be?"bootstrap":"join",payload:pe}),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.access.currentBoardAccess}),await e.invalidateQueries({queryKey:P.companies.all}),U?.companyId&&SUt(pe,Y)&&(n(U.companyId,{source:"manual"}),s("/",{replace:!0}))},"onSuccess"),onError:r(pe=>{A(pe instanceof Error?pe.message:"Failed to accept invite")},"onError")});(0,u.useEffect)(()=>{!G||T||ae.isPending||(R(!0),A(null),ae.mutate())},[ae,T,G]);const ie=ke({mutationFn:r(async()=>{if(i==="sign_in"){await Fa.signInEmail({email:d.trim(),password:h});return}await Fa.signUpEmail({name:l.trim(),email:d.trim(),password:h})},"mutationFn"),onSuccess:r(async()=>{I(null),Ooe(a),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.invalidateQueries({queryKey:P.access.currentBoardAccess});const{companies:pe}=await V_e(e);if(U?.companyId&&pe.some(be=>be.id===U.companyId)){XA(a),n(U.companyId,{source:"manual"}),s("/",{replace:!0});return}if(!(!U||U.inviteType!=="bootstrap_ceo"))try{Koe(await ae.mutateAsync())&&s("/",{replace:!0})}catch{return}},"onSuccess"),onError:r(pe=>{const be=kUt(pe,i,d);c1e(pe)==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"&&(o("sign_in"),p("")),I(be)},"onError")}),ue=(0,u.useMemo)(()=>U?V?"Open organization":U.inviteType==="bootstrap_ceo"?"Accept invite":Y?"Submit request":$.data?"Accept invite":"Continue":"Continue",[U,V,$.data,Y]);if(!a)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid invite token."});if(E.isLoading||O.isLoading||$.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading invite..."});if(D)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Checking your access..."});if(E.error||!U)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"border border-border bg-card p-6","data-testid":"invite-error",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Invite not available"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This invite may be expired, revoked, or already used."})]})});if(te==="approved"&&re==="human"&&V)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Opening organization..."});if(te==="pending_approval"&&!de)return(0,t.jsx)(Voe,{companyDisplayName:H,companyLogoUrl:J,invitedByUserName:X});if(te&&!de)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"border border-border bg-card p-6","data-testid":"invite-error",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Invite not available"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:te==="rejected"?"This join request was not approved.":"This invite has already been used."})]})});if(j?.kind==="bootstrap")return(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Bootstrap complete"}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(F,{asChild:!0,className:"rounded-none",children:(0,t.jsx)(Ge,{to:"/",children:"Open board"})})})]})});if(j?.kind==="join"){const pe=j.payload,be=typeof pe.claimSecret=="string"?pe.claimSecret:null,oe=typeof pe.claimApiKeyPath=="string"?pe.claimApiKeyPath:null,je=jUt(pe.onboarding,["textInstructions","url"]);return!Y&&pe.status==="approved"?(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(W6,{companyDisplayName:H,companyLogoUrl:J,className:"h-12 w-12 border border-zinc-800 rounded-none"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"You joined the organization"})]}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(F,{asChild:!0,className:"w-full rounded-none",children:(0,t.jsx)(Ge,{to:"/",children:"Open board"})})})]})}):(0,t.jsx)(Voe,{companyDisplayName:H,companyLogoUrl:J,invitedByUserName:X,claimSecret:be,claimApiKeyPath:oe,onboardingTextUrl:je})}return(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsx)("div",{className:"mx-auto max-w-5xl",children:(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-(--gtc-36)",children:[(0,t.jsxs)("section",{className:`${zoe} space-y-6`,children:[(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[(0,t.jsx)(W6,{companyDisplayName:H,companyLogoUrl:J,className:"h-16 w-16 rounded-none border border-zinc-800"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"You've been invited to join Paperclip"}),(0,t.jsx)("h1",{className:"mt-2 text-2xl font-semibold",children:U.inviteType==="bootstrap_ceo"?"Set up Paperclip":`Join ${H}`}),(0,t.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-zinc-300",children:Y?"Review the invite details, then submit the agent information below to start the join request.":Z?"Create your Paperclip account first. If you already have one, switch to sign in and continue the invite with the same email.":"Your account is ready. Review the invite details, then accept it to continue."})]})]}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Organization"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:H})]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Invited by"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:X??"Paperclip board"})]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Requested access"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:Y?"Agent join request":ce??"Organization access"})]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Invite expires"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:pu(U.expiresAt)})]})]}),le?(0,t.jsxs)("div",{className:"border border-amber-500/40 bg-amber-500/10 p-4",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-amber-200/80",children:"Message from inviter"}),(0,t.jsx)("p",{className:"mt-2 text-sm leading-6 text-amber-50",children:le})]}):null,$.data?(0,t.jsxs)("div",{className:"border border-emerald-500/40 bg-emerald-500/10 p-4 text-sm text-emerald-50",children:["Signed in as ",(0,t.jsx)("span",{className:"font-medium",children:fe}),"."]}):null]}),(0,t.jsx)("section",{className:`${zoe} h-fit`,children:Y?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:"Submit agent details"}),(0,t.jsxs)("p",{className:"mt-1 text-sm text-zinc-400",children:["This invite will create an approval request for a new agent in ",H,"."]})]}),(0,t.jsxs)("label",{className:"block text-sm",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Agent name"}),(0,t.jsx)("input",{className:By,value:f,onChange:r(pe=>g(pe.target.value),"onChange")})]}),(0,t.jsxs)("label",{className:"block text-sm",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Adapter type"}),(0,t.jsx)("select",{className:By,value:v,onChange:r(pe=>y(pe.target.value),"onChange"),children:yUt.map(pe=>(0,t.jsxs)("option",{value:pe,disabled:!qoe.has(pe),children:[df(pe),qoe.has(pe)?"":" (Coming soon)"]},pe))})]}),(0,t.jsxs)("label",{className:"block text-sm",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Capabilities"}),(0,t.jsx)("textarea",{className:By,rows:4,value:w,onChange:r(pe=>S(pe.target.value),"onChange")})]}),_?(0,t.jsx)("p",{className:"text-xs text-red-400",children:_}):null,(0,t.jsx)(F,{className:"w-full rounded-none",disabled:ae.isPending||f.trim().length===0,onClick:r(()=>ae.mutate(),"onClick"),children:ae.isPending?"Working...":ue})]}):Z?(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:i==="sign_up"?"Create your account":"Sign in to continue"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:i==="sign_up"?`Start with a Paperclip account. After that, you'll come right back here to accept the invite for ${H}.`:"Use the Paperclip account that already matches this invite. If you do not have one yet, switch back to create account."})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{type:"button",className:`${Uoe} ${i==="sign_up"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:r(()=>{I(null),o("sign_up")},"onClick"),children:"Create account"}),(0,t.jsx)("button",{type:"button",className:`${Uoe} ${i==="sign_in"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:r(()=>{I(null),o("sign_in")},"onClick"),children:"I already have an account"})]}),(0,t.jsxs)("form",{className:"space-y-4",method:"post",action:i==="sign_up"?"/api/auth/sign-up/email":"/api/auth/sign-in/email",onSubmit:r(pe=>{if(pe.preventDefault(),!ie.isPending){if(!se){I({tone:"error",message:"Please fill in all required fields."});return}ie.mutate()}},"onSubmit"),"data-testid":"invite-inline-auth",children:[i==="sign_up"?(0,t.jsxs)("label",{className:"block text-sm",htmlFor:"invite-name",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Name"}),(0,t.jsx)("input",{id:"invite-name",name:"name",className:By,value:l,onChange:r(pe=>{c(pe.target.value),I(null)},"onChange"),autoComplete:"name",required:!0,"aria-required":"true","aria-invalid":C?.tone==="error"?!0:void 0,"aria-describedby":C?L:void 0,autoFocus:!0})]}):null,(0,t.jsxs)("label",{className:"block text-sm",htmlFor:"invite-email",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Email"}),(0,t.jsx)("input",{id:"invite-email",name:"email",type:"email",className:By,value:d,onChange:r(pe=>{m(pe.target.value),I(null)},"onChange"),autoComplete:"username",required:!0,"aria-required":"true","aria-invalid":C?.tone==="error"?!0:void 0,"aria-describedby":C?L:void 0,autoFocus:i==="sign_in"})]}),(0,t.jsxs)("label",{className:"block text-sm",htmlFor:"invite-password",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Password"}),(0,t.jsx)("input",{id:"invite-password",name:"password",type:"password",className:By,value:h,onChange:r(pe=>{p(pe.target.value),I(null)},"onChange"),autoComplete:i==="sign_in"?"current-password":"new-password",required:!0,"aria-required":"true","aria-invalid":C?.tone==="error"?!0:void 0,"aria-describedby":C?L:void 0})]}),C?(0,t.jsx)("p",{id:L,role:"alert",className:`text-xs ${C.tone==="info"?"text-amber-300":"text-red-400"}`,children:C.message}):null,(0,t.jsx)(F,{type:"submit",className:"w-full rounded-none",disabled:ie.isPending,"aria-disabled":!se||ie.isPending,children:ie.isPending?"Working...":i==="sign_in"?"Sign in and continue":"Create account and continue"})]}),(0,t.jsx)("p",{className:"text-xs leading-5 text-zinc-500",children:i==="sign_up"?"Already signed up before? Use the existing-account option instead so the invite lands on the right Paperclip user.":"No account yet? Switch back to create account so you can accept the invite with a new login."})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:V?"Already in this organization":G?"Completing organization access":U.inviteType==="bootstrap_ceo"?"Accept bootstrap invite":"Accept organization invite"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:G?`Granting your access to ${H}.`:V?`This account already belongs to ${H}.`:`This will ${U.inviteType==="bootstrap_ceo"?"finish setting up Paperclip":`grant or complete your access to ${H}`}.`})]}),_?(0,t.jsx)("p",{className:"text-xs text-red-400",children:_}):null,G?(0,t.jsx)("div",{className:"text-sm text-zinc-400",children:ae.isPending?"Submitting request...":"Finishing sign-in..."}):(0,t.jsx)(F,{className:"w-full rounded-none",disabled:ae.isPending,onClick:r(()=>{if(V&&U.companyId){XA(a),n(U.companyId,{source:"manual"}),s("/",{replace:!0});return}ae.mutate()},"onClick"),children:ae.isPending?"Working...":ue})]})})]})})})}r(CUt,"InviteLandingPage");function _Ut(){const{selectedCompany:e,selectedCompanyId:s}=xs(),{setBreadcrumbs:n}=Ln(),{pushToast:a}=Pi(),i=Kt(),[o,l]=(0,u.useState)("pending_approval"),[c,d]=(0,u.useState)("all");(0,u.useEffect)(()=>{n([{label:e?.name??"Organization",href:"/dashboard"},{label:"Inbox",href:"/inbox"},{label:"Join Requests"}])},[e?.name,n]);const m=ee({queryKey:P.access.joinRequests(s??"",`${o}:${c}`),queryFn:r(()=>ur.listJoinRequests(s,o,c==="all"?void 0:c),"queryFn"),enabled:!!s}),h=ke({mutationFn:r(f=>ur.approveJoinRequest(s,f),"mutationFn"),onSuccess:r(async()=>{await i.invalidateQueries({queryKey:P.access.joinRequests(s,`${o}:${c}`)}),await i.invalidateQueries({queryKey:P.access.companyMembers(s)}),await i.invalidateQueries({queryKey:P.access.companyUserDirectory(s)}),a({title:"Join request approved",tone:"success"})},"onSuccess")}),p=ke({mutationFn:r(f=>ur.rejectJoinRequest(s,f),"mutationFn"),onSuccess:r(async()=>{await i.invalidateQueries({queryKey:P.access.joinRequests(s,`${o}:${c}`)}),a({title:"Join request rejected",tone:"success"})},"onSuccess")});if(!s)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Select an organization to review join requests."});if(m.isLoading)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading join requests…"});if(m.error){const f=m.error instanceof vn&&m.error.status===403?"You do not have permission to review join requests for this organization.":m.error instanceof Error?m.error.message:"Failed to load join requests.";return(0,t.jsx)("div",{className:"text-sm text-destructive",children:f})}return(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(xPe,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Join Request Queue"})]}),(0,t.jsx)("p",{className:"max-w-3xl text-sm text-muted-foreground",children:"Review human and agent join requests outside the mixed inbox feed. This queue uses the same approval mutations as the inline inbox cards."})]}),(0,t.jsxs)(Xs,{className:"flex-row flex-wrap gap-3 p-4",children:[(0,t.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,t.jsx)("span",{className:"font-medium",children:"Status"}),(0,t.jsxs)("select",{className:"rounded-md border border-border bg-background px-3 py-2",value:o,onChange:r(f=>l(f.target.value),"onChange"),children:[(0,t.jsx)("option",{value:"pending_approval",children:"Pending approval"}),(0,t.jsx)("option",{value:"approved",children:"Approved"}),(0,t.jsx)("option",{value:"rejected",children:"Rejected"})]})]}),(0,t.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,t.jsx)("span",{className:"font-medium",children:"Request type"}),(0,t.jsxs)("select",{className:"rounded-md border border-border bg-background px-3 py-2",value:c,onChange:r(f=>d(f.target.value),"onChange"),children:[(0,t.jsx)("option",{value:"all",children:"All"}),(0,t.jsx)("option",{value:"human",children:"Human"}),(0,t.jsx)("option",{value:"agent",children:"Agent"})]})]})]}),(0,t.jsx)("div",{className:"space-y-4",children:(m.data??[]).length===0?(0,t.jsx)("div",{className:"rounded-xl border border-dashed border-border px-4 py-8 text-sm text-muted-foreground",children:"No join requests match the current filters."}):m.data.map(f=>(0,t.jsxs)(Xs,{className:"block p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(ct,{variant:f.status==="pending_approval"?"secondary":f.status==="approved"?"outline":"destructive",children:f.status.replace("_"," ")}),(0,t.jsx)(ct,{variant:"outline",children:f.requestType}),f.adapterType?(0,t.jsx)(ct,{variant:"outline",children:f.adapterType}):null]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-base font-medium",children:f.requestType==="human"?f.requesterUser?.name||f.requestEmailSnapshot||f.requestingUserId||"Unknown human requester":f.agentName||"Unknown agent requester"}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:f.requestType==="human"?f.requesterUser?.email||f.requestEmailSnapshot||f.requestingUserId:f.capabilities||f.requestIp})]})]}),f.status==="pending_approval"?(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>p.mutate(f.id),"onClick"),disabled:p.isPending,children:"Reject"}),(0,t.jsx)(F,{onClick:r(()=>h.mutate(f.id),"onClick"),disabled:h.isPending,children:"Approve"})]}):null]}),(0,t.jsxs)("div",{className:"mt-4 grid gap-3 text-sm text-muted-foreground md:grid-cols-2",children:[(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-background px-3 py-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide",children:"Invite context"}),(0,t.jsx)("div",{className:"mt-2",children:f.invite?`${f.invite.allowedJoinTypes} join invite${f.invite.humanRole?` • default role ${f.invite.humanRole}`:""}`:"Invite metadata unavailable"}),f.invite?.inviteMessage?(0,t.jsx)("div",{className:"mt-2 text-foreground",children:f.invite.inviteMessage}):null]}),(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-background px-3 py-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide",children:"Request details"}),(0,t.jsxs)("div",{className:"mt-2",children:["Submitted ",new Date(f.createdAt).toLocaleString()]}),(0,t.jsxs)("div",{children:["Source IP ",f.requestIp]}),f.requestType==="agent"&&f.capabilities?(0,t.jsx)("div",{children:f.capabilities}):null]})]})]},f.id))})]})}r(_Ut,"JoinRequestQueue");var IUt=(0,u.lazy)(()=>vc(()=>import("./CompanyExport-CWmvCY4A.js").then(e=>({default:e.CompanyExport})),__vite__mapDeps([6,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]))),AUt=(0,u.lazy)(()=>vc(()=>import("./Agents.production-Cj5rZo69.js").then(e=>({default:e.Agents})),__vite__mapDeps([26,5,7,9,8,10,11,12,13,27,28,29,15,30,31,32,33,24,25]))),RUt=(0,u.lazy)(()=>vc(()=>import("./Routines.production-VhYuO012.js").then(e=>({default:e.Routines})),__vite__mapDeps([34,5,7,8,9,10,11,12,13,35,14,15,36,37,29,27,38,39,40,21,41,42,16,17,18,19,43,44,30,45,46,23,31,47,33,48,49,50,51,24,25,28]))),Woe=(0,u.lazy)(()=>vc(()=>import("./RoutineDetail.production-DJe0NpxJ.js").then(e=>({default:e.RoutineDetail})),__vite__mapDeps([52,5,7,8,9,10,11,12,13,35,14,15,36,37,29,27,38,39,40,21,41,42,16,17,18,19,43,44,30,45,46,23,31,47,33,48,49,50,51,24,25,53]))),TUt=(0,u.lazy)(()=>vc(()=>import("./CompanySkills.production-BGtfN-3A.js").then(e=>({default:e.CompanySkills})),__vite__mapDeps([54,5,7,8,9,10,11,12,13,14,15,36,37,29,27,38,39,40,21,41,28,16,17,18,19,55,53,31,44,22,20,56,47,48,50,24,25]))),EUt=(0,u.lazy)(()=>vc(()=>import("./CompanyActivity.production-BsesMNQp.js").then(e=>({default:e.CompanyActivity})),__vite__mapDeps([57,5,7,8,9,10,11,12,13,27,28,29,43,37,21,44,48,49,51]))),PUt=(0,u.lazy)(()=>vc(()=>import("./Costs.production-84DycSrt.js").then(e=>({default:e.Costs})),__vite__mapDeps([58,5,7,28,29,13,12,44,41,50,27,51,24,25]))),MUt=(0,u.lazy)(()=>vc(()=>import("./OrgChart.production-D_VwOg1Z.js").then(e=>({default:e.OrgChart})),__vite__mapDeps([59,5,7,8,9,10,11,12,13,27,45,46,51,24,25])));function fg({children:e}){return(0,t.jsx)(u.Suspense,{fallback:(0,t.jsx)(Jm,{}),children:e})}r(fg,"ProductionSurface");function DUt(e){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{index:!0,element:(0,t.jsx)(wn,{to:"dashboard",replace:!0})}),(0,t.jsx)(ot,{path:"dashboard",element:(0,t.jsx)(mpt,{})}),(0,t.jsx)(ot,{path:"dashboard/live",element:(0,t.jsx)(hpt,{})}),(0,t.jsx)(ot,{path:"timeline",element:e?(0,t.jsx)(yp,{to:"/activity/timeline"}):(0,t.jsx)(Yye,{})}),(0,t.jsx)(ot,{path:"onboarding",element:(0,t.jsx)(m1e,{})}),(0,t.jsx)(ot,{path:"companies",element:(0,t.jsx)(Zpt,{})}),(0,t.jsx)(ot,{path:"company/settings",element:(0,t.jsx)(h3t,{})}),(0,t.jsx)(ot,{path:"company/settings/environments",element:(0,t.jsx)(wn,{to:"/company/settings/instance/environments",replace:!0})}),(0,t.jsx)(ot,{path:"company/settings/cloud-upstream",element:(0,t.jsx)(wn,{to:"/company/export",replace:!0})}),(0,t.jsxs)(ot,{element:(0,t.jsx)(ch,{pageKey:"company.members"}),children:[(0,t.jsx)(ot,{path:"company/settings/members",element:(0,t.jsx)(DMt,{})}),(0,t.jsx)(ot,{path:"company/settings/access",element:(0,t.jsx)(LMt,{})})]}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"company.invites"}),children:(0,t.jsx)(ot,{path:"company/settings/invites",element:(0,t.jsx)(wn,{to:"/company/settings/members?tab=invites",replace:!0})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"company.export"}),children:(0,t.jsx)(ot,{path:"company/export/*",element:(0,t.jsx)(u.Suspense,{fallback:(0,t.jsx)(Jm,{}),children:(0,t.jsx)(IUt,{})})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(rtt,{}),children:(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"company.import"}),children:(0,t.jsx)(ot,{path:"company/import",element:(0,t.jsx)(K6t,{})})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"company.secrets"}),children:(0,t.jsx)(ot,{path:"company/settings/secrets",element:(0,t.jsx)(Fqt,{})})}),(0,t.jsx)(ot,{path:"company/settings/tools",element:(0,t.jsx)(Qoe,{})}),(0,t.jsx)(ot,{path:"company/settings/tools/:tab",element:(0,t.jsx)(Qoe,{})}),(0,t.jsx)(ot,{path:"tools",element:(0,t.jsx)(Goe,{})}),(0,t.jsx)(ot,{path:"tools/:tab",element:(0,t.jsx)(Goe,{})}),(0,t.jsx)(ot,{path:"apps",element:(0,t.jsx)(vDt,{})}),(0,t.jsx)(ot,{path:"apps/browse",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/connections",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/byo",element:(0,t.jsx)(FSe,{byoOnly:!0})}),(0,t.jsx)(ot,{path:"apps/vercel-connect",element:(0,t.jsx)(Hoe,{credentialSource:"vercel_connect"})}),(0,t.jsx)(ot,{path:"apps/connect",element:(0,t.jsx)(Hoe,{})}),(0,t.jsx)(ot,{path:"apps/chat/connect",element:(0,t.jsx)(v$,{children:(0,t.jsx)(WDt,{})})}),(0,t.jsx)(ot,{path:"apps/chat/:endpointId",element:(0,t.jsx)(v$,{children:(0,t.jsx)(wn,{to:"settings",replace:!0})})}),(0,t.jsx)(ot,{path:"apps/chat/:endpointId/:tab",element:(0,t.jsx)(v$,{children:(0,t.jsx)(dLt,{})})}),(0,t.jsx)(ot,{path:"apps/connect/:appKey",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/connect/:appKey/:stage",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/review",element:(0,t.jsx)(gLt,{})}),(0,t.jsx)(ot,{path:"apps/attention",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/gateways",element:(0,t.jsx)(nie,{})}),(0,t.jsx)(ot,{path:"apps/gateways/:gatewayId",element:(0,t.jsx)(wn,{to:"overview",replace:!0})}),(0,t.jsx)(ot,{path:"apps/gateways/:gatewayId/:tab",element:(0,t.jsx)(u$t,{})}),(0,t.jsx)(ot,{path:"apps/advanced",element:(0,t.jsx)(Fae,{})}),(0,t.jsx)(ot,{path:"apps/advanced/gateways",element:(0,t.jsx)(nie,{})}),(0,t.jsx)(ot,{path:"apps/advanced/profiles/new",element:(0,t.jsx)(Kae,{mode:"new"})}),(0,t.jsx)(ot,{path:"apps/advanced/profiles/:profileId/edit",element:(0,t.jsx)(Kae,{mode:"edit"})}),(0,t.jsx)(ot,{path:"apps/advanced/profiles/:profileId",element:(0,t.jsx)(sDt,{})}),(0,t.jsx)(ot,{path:"apps/advanced/audit",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/advanced/run-your-own",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/advanced/:tab",element:(0,t.jsx)(Fae,{})}),(0,t.jsx)(ot,{path:"apps/app/:applicationId",element:(0,t.jsx)(eie,{})}),(0,t.jsx)(ot,{path:"apps/app/:applicationId/:tab",element:(0,t.jsx)(eie,{})}),(0,t.jsx)(ot,{path:"apps/:connectionId",element:(0,t.jsx)(wn,{to:"permissions",replace:!0})}),(0,t.jsx)(ot,{path:"apps/:connectionId/:tab",element:(0,t.jsx)(SLt,{})}),(0,t.jsx)(ot,{path:"company/settings/instance",element:(0,t.jsx)(wn,{to:"/company/settings",replace:!0})}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"instance.profile"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/profile",element:(0,t.jsx)(Kzt,{})})}),(0,t.jsx)(ot,{path:"company/settings/instance/general",element:(0,t.jsx)(wn,{to:"/company/settings",replace:!0})}),(0,t.jsx)(ot,{path:"company/settings/instance/heartbeats",element:(0,t.jsx)(wn,{to:"/company/settings",replace:!0})}),(0,t.jsxs)(ot,{element:(0,t.jsx)(ch,{pageKey:"instance.environments"}),children:[(0,t.jsx)(ot,{path:"company/settings/instance/environments",element:(0,t.jsx)(l$,{})}),(0,t.jsx)(ot,{path:"company/settings/instance/environments/new",element:(0,t.jsx)(l$,{mode:"create"})}),(0,t.jsx)(ot,{path:"company/settings/instance/environments/:environmentId/edit",element:(0,t.jsx)(l$,{mode:"edit"})})]}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"instance.access"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/access",element:(0,t.jsx)(Bzt,{})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"instance.experimental"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/experimental",element:(0,t.jsx)(Fzt,{})})}),(0,t.jsxs)(ot,{element:(0,t.jsx)(ch,{pageKey:"instance.plugins"}),children:[(0,t.jsx)(ot,{path:"company/settings/instance/plugins",element:(0,t.jsx)(Wzt,{})}),(0,t.jsx)(ot,{path:"company/settings/instance/plugins/:pluginId",element:(0,t.jsx)(Hzt,{})})]}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"instance.adapters"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/adapters",element:(0,t.jsx)(Moe,{})})}),(0,t.jsx)(ot,{path:"company/settings/:settingsRoutePath/*",element:(0,t.jsx)(IMt,{})}),(0,t.jsx)(ot,{path:"skills/studio",element:(0,t.jsx)(P$,{})}),(0,t.jsx)(ot,{path:"skills/studio/new",element:(0,t.jsx)(P$,{})}),(0,t.jsx)(ot,{path:"skills/studio/:skillId",element:(0,t.jsx)(P$,{})}),(0,t.jsx)(ot,{path:"skills/:skillId/studio",element:(0,t.jsx)(d1e,{})}),(0,t.jsx)(ot,{path:"skills/*",element:e?(0,t.jsx)(COt,{}):(0,t.jsx)(fg,{children:(0,t.jsx)(TUt,{})})}),(0,t.jsx)(ot,{path:"settings",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"settings/*",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"plugins/:pluginId",element:(0,t.jsx)(Doe,{})}),(0,t.jsx)(ot,{path:"org",element:e?(0,t.jsx)(wn,{to:"/agents/all",replace:!0}):(0,t.jsx)(fg,{children:(0,t.jsx)(MUt,{})})}),(0,t.jsx)(ot,{path:"agents",element:(0,t.jsx)(wn,{to:"/agents/all",replace:!0})}),S8.map(s=>(0,t.jsx)(ot,{path:`agents/${s}`,element:e?(0,t.jsx)(Cft,{}):(0,t.jsx)(fg,{children:(0,t.jsx)(AUt,{})})},s)),(0,t.jsx)(ot,{path:"agents/new",element:(0,t.jsx)(uUt,{})}),(0,t.jsx)(ot,{path:"agents/:agentId",element:(0,t.jsx)(QD,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/:tab",element:(0,t.jsx)(QD,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/runs/:runId",element:(0,t.jsx)(QD,{})}),(0,t.jsx)(ot,{path:"projects",element:(0,t.jsx)(O0t,{})}),(0,t.jsx)(ot,{path:"projects/:projectId",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/overview",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues/:filter",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{element:(0,t.jsx)(X4,{}),children:(0,t.jsx)(ot,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,t.jsx)(Pvt,{})})}),(0,t.jsx)(ot,{path:"projects/:projectId/workspaces",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/configuration",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/budget",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{element:(0,t.jsx)(X4,{}),children:(0,t.jsx)(ot,{path:"workspaces",element:(0,t.jsx)(Lvt,{})})}),(0,t.jsx)(ot,{path:"issues",element:(0,t.jsx)(Kvt,{})}),(0,t.jsx)(ot,{path:"tasks",element:(0,t.jsx)(wn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"search",element:(0,t.jsx)(xyt,{})}),(0,t.jsx)(ot,{path:"issues/all",element:(0,t.jsx)(wn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/active",element:(0,t.jsx)(wn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/backlog",element:(0,t.jsx)(wn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/done",element:(0,t.jsx)(wn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/recent",element:(0,t.jsx)(wn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"chats/:agentRef",element:(0,t.jsx)(Lkt,{})}),(0,t.jsx)(ot,{path:"issues/:issueId",element:(0,t.jsx)(Mkt,{})}),null,(0,t.jsx)(ot,{path:"routines",element:e?(0,t.jsx)(fSt,{}):(0,t.jsx)(fg,{children:(0,t.jsx)(RUt,{})})}),(0,t.jsx)(ot,{path:"cases",element:(0,t.jsx)(aX,{children:(0,t.jsx)(ktt,{})})}),(0,t.jsx)(ot,{path:"cases/:caseIdentifier",element:(0,t.jsx)(aX,{children:(0,t.jsx)(Hnt,{})})}),(0,t.jsx)(ot,{path:"status",element:(0,t.jsx)(iX,{children:(0,t.jsx)(xne,{})})}),(0,t.jsx)(ot,{path:"status/:cardId",element:(0,t.jsx)(iX,{children:(0,t.jsx)(xne,{})})}),(0,t.jsx)(ot,{path:"status-cards",element:(0,t.jsx)(Yoe,{})}),(0,t.jsx)(ot,{path:"status-cards/:cardId",element:(0,t.jsx)(Yoe,{})}),(0,t.jsx)(ot,{path:"review-queue",element:(0,t.jsx)(rg,{children:(0,t.jsx)(P1t,{})})}),(0,t.jsx)(ot,{path:"learnings",element:(0,t.jsx)(rg,{children:(0,t.jsx)(D1t,{})})}),(0,t.jsx)(ot,{path:"pipelines",element:(0,t.jsx)(rg,{children:(0,t.jsx)(AL,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId",element:(0,t.jsx)(rg,{children:(0,t.jsx)(AL,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/add",element:(0,t.jsx)(rg,{children:(0,t.jsx)(AL,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/settings",element:(0,t.jsx)(rg,{children:(0,t.jsx)(I_t,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/items/:caseId",element:(0,t.jsx)(rg,{children:(0,t.jsx)(ZCt,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,t.jsx)(rg,{children:(0,t.jsx)(YCt,{})})}),(0,t.jsx)(ot,{path:"routines/:routineId",element:e?(0,t.jsx)(Rne,{}):(0,t.jsx)(fg,{children:(0,t.jsx)(Woe,{})})}),(0,t.jsx)(ot,{path:"routines/:routineId/:section",element:e?(0,t.jsx)(Rne,{}):(0,t.jsx)(fg,{children:(0,t.jsx)(Woe,{})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(X4,{}),children:(0,t.jsxs)(ot,{element:(0,t.jsx)(itt,{}),children:[(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId",element:(0,t.jsx)(My,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/services",element:(0,t.jsx)(My,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/configuration",element:(0,t.jsx)(My,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,t.jsx)(My,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/issues",element:(0,t.jsx)(My,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/routines",element:(0,t.jsx)(My,{})})]})}),(0,t.jsx)(ot,{path:"goals",element:(0,t.jsx)(WAt,{})}),(0,t.jsx)(ot,{path:"goals/:goalId",element:(0,t.jsx)(i2t,{})}),(0,t.jsx)(ot,{path:"artifacts",element:(0,t.jsx)(Mne,{})}),(0,t.jsx)(ot,{path:"approvals",element:(0,t.jsx)(wn,{to:"/approvals/pending",replace:!0})}),(0,t.jsx)(ot,{path:"approvals/pending",element:(0,t.jsx)(Lne,{})}),(0,t.jsx)(ot,{path:"approvals/all",element:(0,t.jsx)(Lne,{})}),(0,t.jsx)(ot,{path:"approvals/:approvalId",element:(0,t.jsx)(o2t,{})}),(0,t.jsx)(ot,{path:"activity",element:e?(0,t.jsx)(Q2t,{}):(0,t.jsx)(fg,{children:(0,t.jsx)(EUt,{})})}),e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{path:"activity/runs",element:(0,t.jsx)(Vk,{section:"runs"})}),(0,t.jsx)(ot,{path:"activity/costs",element:(0,t.jsx)(Vk,{section:"costs"})}),(0,t.jsx)(ot,{path:"activity/budgets",element:(0,t.jsx)(Vk,{section:"budgets"})}),(0,t.jsx)(ot,{path:"activity/timeline",element:(0,t.jsx)(Vk,{section:"timeline"})}),(0,t.jsx)(ot,{path:"audit",element:(0,t.jsx)(yp,{to:"/activity",forceAgentMode:!0})}),(0,t.jsx)(ot,{path:"audit/activity",element:(0,t.jsx)(yp,{to:"/activity"})}),(0,t.jsx)(ot,{path:"audit/runs",element:(0,t.jsx)(yp,{to:"/activity/runs"})}),(0,t.jsx)(ot,{path:"audit/costs",element:(0,t.jsx)(yp,{to:"/activity/costs"})}),(0,t.jsx)(ot,{path:"audit/budgets",element:(0,t.jsx)(yp,{to:"/activity/budgets"})}),(0,t.jsx)(ot,{path:"audit/timeline",element:(0,t.jsx)(yp,{to:"/activity/timeline"})}),(0,t.jsx)(ot,{path:"runs",element:(0,t.jsx)(yp,{to:"/activity/runs"})}),(0,t.jsx)(ot,{path:"costs",element:(0,t.jsx)(yp,{to:"/activity/costs"})}),(0,t.jsx)(ot,{path:"budgets",element:(0,t.jsx)(yp,{to:"/activity/budgets"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{path:"costs",element:(0,t.jsx)(fg,{children:(0,t.jsx)(PUt,{})})}),(0,t.jsx)(ot,{path:"audit",element:(0,t.jsx)(wn,{to:"/activity?mode=agents",replace:!0})})]}),(0,t.jsxs)(ot,{element:(0,t.jsx)(KJe,{}),children:[(0,t.jsx)(ot,{path:"board-chat",element:(0,t.jsx)(t3t,{})}),(0,t.jsx)(ot,{path:"artifacts",element:(0,t.jsx)(Mne,{})})]}),null,(0,t.jsx)(ot,{path:"decisions",element:(0,t.jsx)(CTt,{})}),(0,t.jsx)(ot,{path:"decisions/queues/:key",element:(0,t.jsx)(RTt,{})}),(0,t.jsx)(ot,{path:"inbox",element:(0,t.jsx)(LUt,{})}),(0,t.jsx)(ot,{path:"inbox/mine",element:(0,t.jsx)(pk,{})}),(0,t.jsx)(ot,{path:"inbox/recent",element:(0,t.jsx)(pk,{})}),(0,t.jsx)(ot,{path:"inbox/unread",element:(0,t.jsx)(pk,{})}),(0,t.jsx)(ot,{path:"inbox/blocked",element:(0,t.jsx)(pk,{})}),(0,t.jsx)(ot,{path:"inbox/all",element:(0,t.jsx)(pk,{})}),(0,t.jsx)(ot,{path:"inbox/requests",element:(0,t.jsx)(_Ut,{})}),(0,t.jsx)(ot,{path:"inbox/new",element:(0,t.jsx)(wn,{to:"/inbox/mine",replace:!0})}),(0,t.jsx)(ot,{path:"u/:userSlug",element:(0,t.jsx)(yAt,{})}),(0,t.jsx)(ot,{path:"design-guide",element:(0,t.jsx)(Lzt,{})}),(0,t.jsx)(ot,{path:"instance/settings/adapters",element:(0,t.jsx)(Moe,{})}),(0,t.jsx)(ot,{path:":pluginRoutePath/*",element:(0,t.jsx)(Doe,{})}),(0,t.jsx)(ot,{path:"*",element:(0,t.jsx)(xu,{scope:"board"})})]})}r(DUt,"boardRoutes");function Hoe({credentialSource:e="paperclip_vault"}={}){const s=ea(),n=new URLSearchParams(s.search),{enabled:a}=Lx();return pGe(n,{chatConnectorsEnabled:a})?(0,t.jsx)(FSe,{credentialSource:e}):(0,t.jsx)(wn,{to:"/apps",replace:!0})}r(Hoe,"AppsConnectEntryRoute");function LUt(){return(0,t.jsx)(wn,{to:`/inbox/${qAe()}`,replace:!0})}r(LUt,"InboxRootRedirect");function d1e(){const e=ea(),{companies:s,selectedCompany:n,loading:a}=xs(),{companyPrefix:i,skillId:o}=ka();if(a)return null;const l=(i?s.find(c=>c.issuePrefix.toUpperCase()===i.toUpperCase()):null)??n??s[0]??null;return!l||!o?(0,t.jsx)(wn,{to:"/skills/studio",replace:!0}):(0,t.jsx)(wn,{to:`/${l.issuePrefix}/skills/studio/${encodeURIComponent(o)}${e.search}${e.hash}`,replace:!0})}r(d1e,"LegacySkillStudioRedirect");function db(){const e=ea(),{companies:s,selectedCompany:n,loading:a}=xs(),{companyPrefix:i}=ka(),{hidden:o}=Zm();if(a)return(0,t.jsx)(Jm,{});const l=(i?s.find(d=>d.issuePrefix.toUpperCase()===i.toUpperCase()):null)??n??s[0]??null;if(!l)return pK({pathname:e.pathname,hasCompanies:!1})?(0,t.jsx)(wn,{to:"/onboarding",replace:!0}):(0,t.jsx)(J7,{});const c=ZDe(bue(`${e.pathname}${e.search}${e.hash}`),o);return(0,t.jsx)(wn,{to:`/${l.issuePrefix}${c}`,replace:!0})}r(db,"LegacySettingsRedirect");function Qoe(){const{tab:e}=ka();return(0,t.jsx)(wn,{to:u1e(e),replace:!0})}r(Qoe,"LegacyToolsSettingsRedirect");function Goe(){const{tab:e}=ka();return(0,t.jsx)(wn,{to:u1e(e),replace:!0})}r(Goe,"LegacyToolsRedirect");function u1e(e){return e?e==="applications"||e==="connections"||e==="overview"||e==="examples"||e==="runtime"||e==="audit"?"/apps":e==="policies"?"/apps/advanced/profiles":`/apps/advanced/${e}`:"/apps/advanced/profiles"}r(u1e,"legacyToolsRedirectTarget");function m1e(){const{companies:e}=xs(),{openOnboarding:s}=$o(),{t:n}=Wde(),a=Qc(),i=R5(a?.cloudBaseUrl??null),{onboardingOpen:o,onboardingRouteDismissed:l}=h5(),{companyPrefix:c}=ka(),d=c?e.find(p=>p.issuePrefix.toUpperCase()===c.toUpperCase())??null:null;if(bYe({onboardingOpen:o,routeDismissed:l}))return null;const m=d?`Add another agent to ${d.name}`:e.length>0?"Create another organization":"Create your first organization",h=d?"Run onboarding again to add an agent and a starter task for this organization.":e.length>0?"Run onboarding again to create another organization and seed its first agent.":"Get started by creating an organization and your first agent.";return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-card p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:m}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:h}),(0,t.jsx)("div",{className:"mt-4",children:!d&&a&&!i?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("app.cloudCreateUnavailable",{defaultValue:"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio."})}):(0,t.jsx)(F,{onClick:r(()=>d?s({initialStep:PT(),companyId:d.id}):a&&i?Nc(i):s(),"onClick"),children:d?"Add Agent":"Start Onboarding"})})]})})}r(m1e,"OnboardingRoutePage");function $Ut(){const{companies:e,selectedCompany:s,loading:n}=xs(),a=ea();if(n)return(0,t.jsx)(Jm,{});const i=s??e[0]??null;return i?(0,t.jsx)(wn,{to:`/${i.issuePrefix}/dashboard`,replace:!0}):pK({pathname:a.pathname,hasCompanies:!1})?(0,t.jsx)(wn,{to:"/onboarding",replace:!0}):(0,t.jsx)(J7,{})}r($Ut,"CompanyRootRedirect");function Yoe(){const{cardId:e}=ka(),s=YIe(),n=s?`/${s}`:"";return(0,t.jsx)(wn,{to:`${n}/status${e?`/${e}`:""}`,replace:!0})}r(Yoe,"StatusCardsLegacyRedirect");function yp({to:e,forceAgentMode:s=!1}){const n=ea(),a=new URLSearchParams(n.search);s&&a.set("mode","agents");const i=a.toString();return(0,t.jsx)(wn,{to:`${e}${i?`?${i}`:""}${n.hash}`,replace:!0})}r(yp,"AuditCompatibilityRedirect");function va(){const e=ea(),{companies:s,selectedCompany:n,loading:a}=xs();if(a)return(0,t.jsx)(Jm,{});const i=n??s[0]??null;return i?(0,t.jsx)(wn,{to:`/${i.issuePrefix}${e.pathname}${e.search}${e.hash}`,replace:!0}):pK({pathname:e.pathname,hasCompanies:!1})?(0,t.jsx)(wn,{to:"/onboarding",replace:!0}):(0,t.jsx)(J7,{})}r(va,"UnprefixedBoardRedirect");function J7(){const{openOnboarding:e}=$o(),{t:s}=Wde(),n=Qc(),a=R5(n?.cloudBaseUrl??null);return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-card p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:s("app.noCompanies.title",{defaultValue:"Create your first organization"})}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:s("app.noCompanies.description",{defaultValue:"Get started by creating an organization."})}),(0,t.jsx)("div",{className:"mt-4",children:n&&!a?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("app.cloudCreateUnavailable",{defaultValue:"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio."})}):(0,t.jsx)(F,{onClick:r(()=>n&&a?Nc(a):e(),"onClick"),children:s("app.noCompanies.newCompany",{defaultValue:"New Organization"})})})]})})}r(J7,"NoCompaniesStartPage");function OUt(){const{enabled:e,loaded:s}=kc();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(ZIe,{children:[(0,t.jsx)(ot,{path:"oauth-handoff",element:(0,t.jsx)(ULt,{})}),(0,t.jsx)(ot,{path:"auth",element:(0,t.jsx)(gUt,{})}),(0,t.jsx)(ot,{path:"board-claim/:token",element:(0,t.jsx)(bUt,{})}),(0,t.jsx)(ot,{path:"cli-auth/:id",element:(0,t.jsx)(vUt,{})}),(0,t.jsx)(ot,{path:"invite/:token",element:(0,t.jsx)(CUt,{})}),(0,t.jsx)(ot,{element:s?(0,t.jsx)(XX,{allowMembershipRequest:!0}):(0,t.jsx)(Jm,{}),children:(0,t.jsx)(ot,{path:"chat-identity/confirm",element:(0,t.jsx)(fLt,{})})}),(0,t.jsx)(ot,{path:"tests/perf/long-thread",element:(0,t.jsx)(Hkt,{})}),(0,t.jsx)(ot,{path:"ux-lab/bootstrap-setup",element:(0,t.jsx)(kMt,{})}),(0,t.jsx)(ot,{path:"ux-lab/responsible-user-denial",element:(0,t.jsx)(SMt,{})}),(0,t.jsx)(ot,{path:"ux-lab/cross-issue-collaboration",element:(0,t.jsx)(_Mt,{})}),(0,t.jsxs)(ot,{element:s?(0,t.jsx)(XX,{}):(0,t.jsx)(Jm,{}),children:[(0,t.jsx)(ot,{index:!0,element:(0,t.jsx)($Ut,{})}),(0,t.jsx)(ot,{path:"onboarding",element:(0,t.jsx)(m1e,{})}),(0,t.jsx)(ot,{path:"instance",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"instance/settings",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"instance/settings/*",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"companies",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"issues",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"tasks",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"issues/:issueId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"routines",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"routines/:routineId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"review-queue",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"learnings",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"cases",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"cases/:caseIdentifier",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"status",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"status/:cardId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"status-cards",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"status-cards/:cardId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"pipelines",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/add",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/settings",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/items/:caseId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"artifacts",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"audit",element:(0,t.jsx)(va,{})}),e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{path:"audit/*",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"activity",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"activity/*",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"runs",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"costs",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"budgets",element:(0,t.jsx)(va,{})})]}):null,(0,t.jsx)(ot,{path:"decisions",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"u/:userSlug",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"skills/studio",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"skills/studio/new",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"skills/studio/:skillId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"skills/:skillId/studio",element:(0,t.jsx)(d1e,{})}),(0,t.jsx)(ot,{path:"skills/*",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"settings",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"settings/*",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"agents",element:(0,t.jsx)(va,{})}),S8.map(n=>(0,t.jsx)(ot,{path:`agents/${n}`,element:(0,t.jsx)(va,{})},n)),(0,t.jsx)(ot,{path:"agents/new",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"agents/:agentId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/:tab",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/runs/:runId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/overview",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues/:filter",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/workspaces",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/configuration",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"workspaces",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId",element:(0,t.jsx)(by,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/services",element:(0,t.jsx)(by,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/configuration",element:(0,t.jsx)(by,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,t.jsx)(by,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/issues",element:(0,t.jsx)(by,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/routines",element:(0,t.jsx)(by,{})}),(0,t.jsx)(ot,{path:":companyPrefix",element:e?(0,t.jsx)(oJe,{}):(0,t.jsx)(qJe,{}),children:DUt(e)}),(0,t.jsx)(ot,{path:"*",element:(0,t.jsx)(xu,{scope:"global"})})]})]}),(0,t.jsx)(wrt,{})]})}r(OUt,"App");var FUt=class extends u.Component{static{r(this,"AppErrorBoundary")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,s){Bxe(e,{boundary:"app",componentStack:s.componentStack})}render(){const{error:e}=this.state;return e?(0,t.jsxs)("div",{className:"mx-auto flex min-h-screen max-w-2xl flex-col justify-center space-y-4 px-4 py-10",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Paperclip hit an error"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Something went wrong while running the app. Reloading usually fixes this."})]}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive whitespace-pre-wrap",children:e.message}),(0,t.jsx)("div",{children:(0,t.jsx)("button",{type:"button",className:"inline-flex items-center rounded-md border border-input bg-background px-3 py-1.5 text-sm font-medium shadow-sm hover:bg-accent hover:text-accent-foreground",onClick:r(()=>window.location.reload(),"onClick"),children:"Reload page"})})]}):this.props.children}};function BUt(){const{data:e}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),s=e?.sentryDsn,n=e?.sentryEnvironment??void 0;return(0,u.useEffect)(()=>{if(s)return MYe(s,n),()=>{DYe()}},[s,n]),null}r(BUt,"SentryGate");function qUt(e){return{id:e.key,title:e.title,status:e.status,projectId:e.projectId??null,assigneeAgentId:e.assigneeAgentId??null,lastRun:e.lastRunAt||e.lastRunStatus?{triggeredAt:e.lastRunAt??null,status:e.lastRunStatus??null}:null}}r(qUt,"managedRoutineToRow");function zUt({routines:e,agents:s=[],projects:n=[],pluginDisplayName:a=null,emptyMessage:i="No managed routines.",runningRoutineKey:o=null,statusMutationRoutineKey:l=null,reconcilingRoutineKey:c=null,resettingRoutineKey:d=null,onRunNow:m,onToggleEnabled:h,onReconcile:p,onReset:f}){const g=new Map(s.map(y=>[y.id,y])),v=new Map(n.map(y=>[y.id,{name:y.name,color:y.color}]));return e.length===0?(0,t.jsx)("div",{className:"rounded-lg border border-border px-3 py-8 text-center text-sm text-muted-foreground",children:i}):(0,t.jsx)("div",{className:"rounded-lg border border-border",children:e.map(y=>{const w=qUt(y),S=y.href??(y.routineId?`/routines/${y.routineId}`:"/routines"),j=y.missingRefs??[],N=!!(y.routineId&&y.resourceKey&&j.length===0),_=y.managedByPluginDisplayName??a,A=!!(p||f);return(0,t.jsxs)("div",{className:"last:[&_a]:border-b-0",children:[(0,t.jsx)(Gwe,{routine:w,projectById:v,agentById:g,runningRoutineId:o,statusMutationRoutineId:l,href:S,configureLabel:"Configure",managedByLabel:_?`Managed by ${_}`:null,runNowButton:!0,hideArchiveAction:!0,disableRunNow:!N,disableToggle:!N,secondaryDetails:(0,t.jsxs)("span",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[y.resourceKey?(0,t.jsx)("span",{children:y.resourceKey}):null,y.cronExpression?(0,t.jsxs)("span",{children:["Schedule ",y.cronExpression]}):null]}),onRunNow:r(()=>m?.(y),"onRunNow"),onToggleEnabled:r(()=>h?.(y,w.status==="active"),"onToggleEnabled")}),A?(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 pb-3 text-xs text-muted-foreground last:border-b-0",onClick:r(C=>{C.preventDefault(),C.stopPropagation()},"onClick"),children:[(0,t.jsx)("span",{children:j.length?`Missing ${j.map(C=>`${C.resourceKind}:${C.resourceKey}`).join(", ")}`:"Routine defaults can be repaired."}),(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[p?(0,t.jsx)(F,{size:"sm",variant:"ghost",disabled:c===y.key,onClick:r(()=>p(y),"onClick"),children:c===y.key?"Reconciling...":"Reconcile"}):null,f?(0,t.jsx)(F,{size:"sm",variant:"ghost",disabled:d===y.key,onClick:r(()=>f(y),"onClick"),children:d===y.key?"Resetting...":"Reset"}):null]})]}):null]},y.key)})})}r(zUt,"ManagedRoutinesList");function Joe(e){return new Set(e??[])}r(Joe,"toPathSet");function UUt({expandedPaths:e,checkedPaths:s,selectedFile:n=null,showCheckboxes:a=!1,onToggleDir:i,onSelectFile:o,...l}){return(0,u.createElement)(V1,{...l,selectedFile:n,expandedDirs:Joe(e),checkedFiles:s?Joe(s):void 0,showCheckboxes:a,onToggleDir:i??(()=>{}),onSelectFile:o??(()=>{})})}r(UUt,"PluginSdkFileTree");function KUt(e){const[s,n]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let a=!1;return vc(()=>import("./MarkdownEditor-DfrwLv1M.js").then(i=>i.n).then(i=>{a||n(()=>i.MarkdownEditor)}),__vite__mapDeps([36,5,7,9,14,10,15,37,29,27,38])),()=>{a=!0}},[]),s?(0,u.createElement)(s,e):(0,u.createElement)("textarea",{className:e.className,value:e.value,placeholder:e.placeholder,readOnly:e.readOnly,onBlur:e.onBlur,onChange:r(a=>e.onChange(a.currentTarget.value),"onChange")})}r(KUt,"PluginSdkMarkdownEditor");function VUt(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!=null&&s!==""&&s!==!1))}r(VUt,"compactIssueFilters");function WUt({companyId:e,projectId:s=null,filters:n,viewStateKey:a="paperclip:plugin-issues-view",initialSearch:i,createIssueLabel:o,searchWithinLoadedIssues:l=!0}){const c=Kt(),d=(0,u.useMemo)(()=>VUt({...n??{},projectId:n?.projectId??s??void 0}),[n,s]),m=d.originKindPrefix??null,h=d.projectId??s??null,p=(0,u.useMemo)(()=>["plugins","sdk-ui","issues-list",e??"__no-company__",d],[e,d]),{data:f}=ee({queryKey:P.agents.list(e??"__no-company__"),queryFn:r(()=>zt.list(e),"queryFn"),enabled:!!e}),{data:g}=ee({queryKey:P.projects.list(e??"__no-company__",{includeArchived:!0}),queryFn:r(()=>ia.list(e,{includeArchived:!0}),"queryFn"),enabled:!!e}),v=P.liveRuns(e??"__no-company__"),y=mo({companyId:e,resourceKey:"live-runs",queryKey:v,enabled:!!e,refetchInterval:!1,leaderOnly:!0}),{data:w,dataUpdatedAt:S}=ee({queryKey:v,queryFn:r(()=>Zr.liveRunsForCompany(e),"queryFn"),enabled:y.enabled,refetchInterval:y.refetchInterval});ho(y,w,S);const{data:j,isLoading:N,error:_}=ee({queryKey:p,queryFn:r(()=>Rt.list(e,d),"queryFn"),enabled:!!e}),A=(0,u.useMemo)(()=>Rx(w,j),[j,w]),C=ke({mutationFn:r(({id:I,data:T})=>Rt.update(I,T),"mutationFn"),onSuccess:r(()=>{e&&(c.invalidateQueries({queryKey:["plugins","sdk-ui","issues-list",e]}),c.invalidateQueries({queryKey:P.issues.list(e)}),h&&(c.invalidateQueries({queryKey:P.issues.listByProject(e,h)}),m&&c.invalidateQueries({queryKey:P.issues.listPluginOperationsByProject(e,h,m)})))},"onSuccess")});return e?(0,u.createElement)(bx,{issues:j??[],isLoading:N,error:_,agents:f,projects:g,liveIssueIds:A,projectId:h??void 0,viewStateKey:a,initialSearch:i,createIssueLabel:o,searchWithinLoadedIssues:l,onUpdateIssue:r((I,T)=>C.mutate({id:I,data:T}),"onUpdateIssue")}):(0,u.createElement)("div",{className:"text-sm text-muted-foreground"},"Select an organization to view tasks.")}r(WUt,"PluginSdkIssuesList");function HUt({companyId:e,value:s,onChange:n,placeholder:a="Responsible",noneLabel:i="No responsible",searchPlaceholder:o="Search responsible...",emptyMessage:l="No responsible found.",includeUsers:c=!0,includeTerminatedAgents:d=!1,className:m,onConfirm:h}){const p=Kz(),f=e??p.companyId??null,{data:g}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),enabled:c}),v=g?.user?.id??g?.session?.userId??null,{data:y}=ee({queryKey:P.agents.list(f??"__no-company__"),queryFn:r(()=>zt.list(f),"queryFn"),enabled:!!f}),{data:w}=ee({queryKey:P.access.companyUserDirectory(f??"__no-company__"),queryFn:r(()=>ur.listUserDirectory(f),"queryFn"),enabled:!!f&&c}),S=(0,u.useMemo)(()=>wAe(),[]),j=(0,u.useMemo)(()=>S.map(I=>I.startsWith("agent:")?I.slice(6):null).filter(I=>!!I),[S]),N=(0,u.useMemo)(()=>Kg((y??[]).filter(I=>d||I.status!=="terminated"),j),[y,d,j]),_=(0,u.useMemo)(()=>[...c?dce(v):[],...c?Vw(w?.users,{excludeUserIds:[v]}):[],...N.map(I=>({id:Pm({assigneeAgentId:I.id}),label:I.name,searchText:`${I.name} ${I.role} ${I.title??""}`}))],[w?.users,v,c,N]),A=Lc(s),C=A.assigneeAgentId?N.find(I=>I.id===A.assigneeAgentId):null;return(0,u.createElement)(Bl,{value:s,options:_,recentOptionIds:S,placeholder:a,noneLabel:i,searchPlaceholder:o,emptyMessage:l,className:m,onConfirm:h,onChange:r(I=>{const T=Lc(I);T.assigneeAgentId&&e1(T.assigneeAgentId),T.assigneeUserId&&Kle(T.assigneeUserId),n(I,T)},"onChange"),renderTriggerValue:r(I=>I?C?(0,u.createElement)(Q3,null,(0,u.createElement)(nw,{icon:C.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,u.createElement)("span",{className:"truncate"},I.label)):(0,u.createElement)("span",{className:"truncate"},I.label):(0,u.createElement)("span",{className:"text-muted-foreground"},a),"renderTriggerValue"),renderOption:r(I=>{if(!I.id)return(0,u.createElement)("span",{className:"truncate"},I.label);const T=Lc(I.id),R=T.assigneeAgentId?N.find(L=>L.id===T.assigneeAgentId):null;return(0,u.createElement)(Q3,null,R?(0,u.createElement)(nw,{icon:R.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,u.createElement)(bc,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,u.createElement)("span",{className:"truncate"},I.label))},"renderOption")})}r(HUt,"PluginSdkAssigneePicker");function QUt({companyId:e,value:s,onChange:n,placeholder:a="Project",noneLabel:i="No project",searchPlaceholder:o="Search projects...",emptyMessage:l="No projects found.",includeArchived:c=!1,className:d,onConfirm:m}){const h=Kz(),p=e??h.companyId??null,{data:f}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn")}),g=f?.user?.id??f?.session?.userId??null,{data:v}=ee({queryKey:P.projects.list(p??"__no-company__",{includeArchived:c}),queryFn:r(()=>ia.list(p,{includeArchived:c}),"queryFn"),enabled:!!p}),y=(0,u.useMemo)(()=>(v??[]).filter(_=>c||!_.archivedAt),[c,v]),{orderedProjects:w}=Nv({projects:y,companyId:p,userId:g}),S=(0,u.useMemo)(()=>Bw(),[]),j=(0,u.useMemo)(()=>w.map(_=>({id:_.id,label:_.name,searchText:_.description??""})),[w]),N=w.find(_=>_.id===s)??null;return(0,u.createElement)(Bl,{value:s,options:j,recentOptionIds:S,placeholder:a,noneLabel:i,searchPlaceholder:o,emptyMessage:l,className:d,onConfirm:m,onChange:r(_=>{_&&$w(_),n(_)},"onChange"),renderTriggerValue:r(_=>!_||!N?(0,u.createElement)("span",{className:"text-muted-foreground"},a):(0,u.createElement)(Q3,null,(0,u.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:N.color??"#6366f1"}}),(0,u.createElement)("span",{className:"truncate"},_.label)),"renderTriggerValue"),renderOption:r(_=>{if(!_.id)return(0,u.createElement)("span",{className:"truncate"},_.label);const A=w.find(C=>C.id===_.id);return(0,u.createElement)(Q3,null,(0,u.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:A?.color??"#6366f1"}}),(0,u.createElement)("span",{className:"truncate"},_.label))},"renderOption")})}r(QUt,"PluginSdkProjectPicker");function Q3({children:e}){return(0,u.createElement)("span",{className:"contents"},e)}r(Q3,"FragmentSafe");function GUt({label:e,status:s}){const n={ok:"border-emerald-300 bg-emerald-50 text-emerald-700",warning:"border-amber-300 bg-amber-50 text-amber-800",error:"border-red-300 bg-red-50 text-red-700",info:"border-slate-300 bg-slate-50 text-slate-700",pending:"border-slate-300 bg-slate-50 text-slate-600"}[s];return(0,u.createElement)("span",{className:`inline-flex w-fit items-center rounded-full border px-2 py-0.5 text-xs font-medium ${n}`},e)}r(GUt,"PluginSdkStatusBadge");function YUt({columns:e,rows:s,loading:n,emptyMessage:a="No rows."}){if(n)return(0,u.createElement)("div",{className:"text-sm text-muted-foreground"},"Loading...");if(!s.length)return(0,u.createElement)("div",{className:"text-sm text-muted-foreground"},a);const i=e.map(o=>o.width??"minmax(0, 1fr)").join(" ");return(0,u.createElement)("div",{className:"overflow-hidden rounded-md border"},(0,u.createElement)("div",{className:"hidden border-b bg-muted/35 px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground md:grid md:[grid-template-columns:var(--plugin-grid-cols)]",style:{"--plugin-grid-cols":i}},e.map(o=>(0,u.createElement)("div",{key:o.key},o.header))),(0,u.createElement)("div",{className:"divide-y"},s.map((o,l)=>(0,u.createElement)("div",{key:String(o.id??l),className:"grid gap-2 px-3 py-3 md:items-center md:[grid-template-columns:var(--plugin-grid-cols)]",style:{"--plugin-grid-cols":i}},e.map(c=>(0,u.createElement)("div",{key:c.key,className:"min-w-0 text-sm"},(0,u.createElement)("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground md:hidden"},c.header),c.render?c.render(o[c.key],o):String(o[c.key]??"")))))))}r(YUt,"PluginSdkDataTable");function JUt({pairs:e}){return(0,u.createElement)("dl",{className:"grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[max-content_minmax(0,1fr)]"},e.flatMap(s=>[(0,u.createElement)("dt",{key:`${s.label}:label`,className:"text-muted-foreground"},s.label),(0,u.createElement)("dd",{key:`${s.label}:value`,className:"min-w-0"},s.value)]))}r(JUt,"PluginSdkKeyValueList");function XUt({label:e,value:s,unit:n}){return(0,u.createElement)("div",{className:"rounded-md border bg-card p-3"},(0,u.createElement)("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground"},e),(0,u.createElement)("div",{className:"mt-1 text-lg font-semibold"},`${s}${n??""}`))}r(XUt,"PluginSdkMetricCard");function ZUt({data:e}){return(0,u.createElement)("pre",{className:"max-h-80 overflow-auto rounded-md border bg-muted/30 p-2 text-xs"},JSON.stringify(e,null,2))}r(ZUt,"PluginSdkJsonTree");function eKt({label:e="Loading"}){return(0,u.createElement)("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-muted-foreground/30 border-t-foreground align-middle",role:"status","aria-label":e})}r(eKt,"PluginSdkSpinner");var tKt=class extends u.Component{static{r(this,"PluginSdkErrorBoundary")}state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??(0,u.createElement)("div",{className:"rounded-md border border-destructive/30 p-3 text-sm text-destructive"},"Plugin UI failed to render."):this.props.children}};function sKt(e,s){globalThis.__paperclipPluginBridge__={react:e,reactJsxRuntime:t,reactDom:s,sdkUi:{usePluginData:lLe,usePluginAction:cLe,useHostContext:Kz,useHostLocation:uLe,useHostNavigation:dLe,usePluginStream:hLe,usePluginToast:mLe,copyTextToClipboard:Hr,MarkdownBlock:r(({content:n,className:a,enableWikiLinks:i,wikiLinkRoot:o,resolveWikiLinkHref:l})=>(0,u.createElement)(Pn,{className:a,softBreaks:!1,enableWikiLinks:i,wikiLinkRoot:o,resolveWikiLinkHref:l,children:n}),"MarkdownBlock"),MetricCard:XUt,StatusBadge:GUt,DataTable:YUt,KeyValueList:JUt,JsonTree:ZUt,Spinner:eKt,ErrorBoundary:tKt,MarkdownEditor:KUt,FileTree:UUt,IssuesList:WUt,AssigneePicker:HUt,ProjectPicker:QUt,ManagedRoutinesList:zUt}}}r(sKt,"initPluginBridge");var nKt=1e4;function rKt(e=nKt){if(typeof performance>"u"||typeof performance.clearMeasures!="function")return()=>{};const n=setInterval(r(()=>{globalThis.__paperclipKeepPerfMeasures||performance.clearMeasures()},"reap"),e);return()=>clearInterval(n)}r(rKt,"startPerfMeasureReaper");var aKt=pv((e=>{function s(K,U){var D=K.length;K.push(U);e:for(;0<D;){var V=D-1>>>1,H=K[V];if(0<i(H,U))K[V]=U,K[D]=H,D=V;else break e}}r(s,"push");function n(K){return K.length===0?null:K[0]}r(n,"peek");function a(K){if(K.length===0)return null;var U=K[0],D=K.pop();if(D!==U){K[0]=D;e:for(var V=0,H=K.length,J=H>>>1;V<J;){var X=2*(V+1)-1,le=K[X],ce=X+1,te=K[ce];if(0>i(le,D))ce<H&&0>i(te,le)?(K[V]=te,K[ce]=D,V=ce):(K[V]=le,K[X]=D,V=X);else if(ce<H&&0>i(te,D))K[V]=te,K[ce]=D,V=ce;else break e}}return U}r(a,"pop");function i(K,U){var D=K.sortIndex-U.sortIndex;return D!==0?D:K.id-U.id}if(r(i,"compare"),e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var d=[],m=[],h=1,p=null,f=3,g=!1,v=!1,y=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function _(K){for(var U=n(m);U!==null;){if(U.callback===null)a(m);else if(U.startTime<=K)a(m),U.sortIndex=U.expirationTime,s(d,U);else break;U=n(m)}}r(_,"advanceTimers");function A(K){if(y=!1,_(K),!v)if(n(d)!==null)v=!0,C||(C=!0,$());else{var U=n(m);U!==null&&B(A,U.startTime-K)}}r(A,"handleTimeout");var C=!1,I=-1,T=5,R=-1;function L(){return w?!0:!(e.unstable_now()-R<T)}r(L,"shouldYieldToHost");function O(){if(w=!1,C){var K=e.unstable_now();R=K;var U=!0;try{e:{v=!1,y&&(y=!1,j(I),I=-1),g=!0;var D=f;try{t:{for(_(K),p=n(d);p!==null&&!(p.expirationTime>K&&L());){var V=p.callback;if(typeof V=="function"){p.callback=null,f=p.priorityLevel;var H=V(p.expirationTime<=K);if(K=e.unstable_now(),typeof H=="function"){p.callback=H,_(K),U=!0;break t}p===n(d)&&a(d),_(K)}else a(d);p=n(d)}if(p!==null)U=!0;else{var J=n(m);J!==null&&B(A,J.startTime-K),U=!1}}break e}finally{p=null,f=D,g=!1}U=void 0}}finally{U?$():C=!1}}}r(O,"performWorkUntilDeadline");var $;if(typeof N=="function")$=r(function(){N(O)},"schedulePerformWorkUntilDeadline");else if(typeof MessageChannel<"u"){var E=new MessageChannel,q=E.port2;E.port1.onmessage=O,$=r(function(){q.postMessage(null)},"schedulePerformWorkUntilDeadline")}else $=r(function(){S(O,0)},"schedulePerformWorkUntilDeadline");function B(K,U){I=S(function(){K(e.unstable_now())},U)}r(B,"requestHostTimeout"),e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_forceFrameRate=function(K){0>K||125<K||(T=0<K?Math.floor(1e3/K):5)},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(K){switch(f){case 1:case 2:case 3:var U=3;break;default:U=f}var D=f;f=U;try{return K()}finally{f=D}},e.unstable_requestPaint=function(){w=!0},e.unstable_runWithPriority=function(K,U){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var D=f;f=K;try{return U()}finally{f=D}},e.unstable_scheduleCallback=function(K,U,D){var V=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?V+D:V):D=V,K){case 1:var H=-1;break;case 2:H=250;break;case 5:H=1073741823;break;case 4:H=1e4;break;default:H=5e3}return H=D+H,K={id:h++,callback:U,priorityLevel:K,startTime:D,expirationTime:H,sortIndex:-1},D>V?(K.sortIndex=D,s(m,K),n(d)===null&&K===n(m)&&(y?(j(I),I=-1):y=!0,B(A,D-V))):(K.sortIndex=H,s(d,K),v||g||(v=!0,C||(C=!0,$()))),K},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(K){var U=f;return function(){var D=f;f=U;try{return K.apply(this,arguments)}finally{f=D}}}})),iKt=pv(((e,s)=>{s.exports=aKt()})),oKt=pv((e=>{var s=iKt(),n=G6(),a=ole();function i(x){var b="https://react.dev/errors/"+x;if(1<arguments.length){b+="?args[]="+encodeURIComponent(arguments[1]);for(var k=2;k<arguments.length;k++)b+="&args[]="+encodeURIComponent(arguments[k])}return"Minified React error #"+x+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}r(i,"formatProdErrorMessage");function o(x){return!(!x||x.nodeType!==1&&x.nodeType!==9&&x.nodeType!==11)}r(o,"isValidContainer");function l(x){var b=x,k=x;if(x.alternate)for(;b.return;)b=b.return;else{x=b;do b=x,(b.flags&4098)!==0&&(k=b.return),x=b.return;while(x)}return b.tag===3?k:null}r(l,"getNearestMountedFiber");function c(x){if(x.tag===13){var b=x.memoizedState;if(b===null&&(x=x.alternate,x!==null&&(b=x.memoizedState)),b!==null)return b.dehydrated}return null}r(c,"getSuspenseInstanceFromFiber");function d(x){if(x.tag===31){var b=x.memoizedState;if(b===null&&(x=x.alternate,x!==null&&(b=x.memoizedState)),b!==null)return b.dehydrated}return null}r(d,"getActivityInstanceFromFiber");function m(x){if(l(x)!==x)throw Error(i(188))}r(m,"assertIsMounted");function h(x){var b=x.alternate;if(!b){if(b=l(x),b===null)throw Error(i(188));return b!==x?null:x}for(var k=x,M=b;;){var W=k.return;if(W===null)break;var Q=W.alternate;if(Q===null){if(M=W.return,M!==null){k=M;continue}break}if(W.child===Q.child){for(Q=W.child;Q;){if(Q===k)return m(W),x;if(Q===M)return m(W),b;Q=Q.sibling}throw Error(i(188))}if(k.return!==M.return)k=W,M=Q;else{for(var ge=!1,De=W.child;De;){if(De===k){ge=!0,k=W,M=Q;break}if(De===M){ge=!0,M=W,k=Q;break}De=De.sibling}if(!ge){for(De=Q.child;De;){if(De===k){ge=!0,k=Q,M=W;break}if(De===M){ge=!0,M=Q,k=W;break}De=De.sibling}if(!ge)throw Error(i(189))}}if(k.alternate!==M)throw Error(i(190))}if(k.tag!==3)throw Error(i(188));return k.stateNode.current===k?x:b}r(h,"findCurrentFiberUsingSlowPath");function p(x){var b=x.tag;if(b===5||b===26||b===27||b===6)return x;for(x=x.child;x!==null;){if(b=p(x),b!==null)return b;x=x.sibling}return null}r(p,"findCurrentHostFiberImpl");var f=Object.assign,g=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),_=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),O=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function E(x){return x===null||typeof x!="object"?null:(x=$&&x[$]||x["@@iterator"],typeof x=="function"?x:null)}r(E,"getIteratorFn");var q=Symbol.for("react.client.reference");function B(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===q?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case w:return"Fragment";case j:return"Profiler";case S:return"StrictMode";case C:return"Suspense";case I:return"SuspenseList";case L:return"Activity"}if(typeof x=="object")switch(x.$$typeof){case y:return"Portal";case _:return x.displayName||"Context";case N:return(x._context.displayName||"Context")+".Consumer";case A:var b=x.render;return x=x.displayName,x||(x=b.displayName||b.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case T:return b=x.displayName||null,b!==null?b:B(x.type)||"Memo";case R:b=x._payload,x=x._init;try{return B(x(b))}catch{}}return null}r(B,"getComponentNameFromType");var K=Array.isArray,U=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V={pending:!1,data:null,method:null,action:null},H=[],J=-1;function X(x){return{current:x}}r(X,"createCursor");function le(x){0>J||(x.current=H[J],H[J]=null,J--)}r(le,"pop");function ce(x,b){J++,H[J]=x.current,x.current=b}r(ce,"push");var te=X(null),re=X(null),de=X(null),Z=X(null);function Y(x,b){switch(ce(de,b),ce(re,x),ce(te,null),b.nodeType){case 9:case 11:x=(x=b.documentElement)&&(x=x.namespaceURI)?nW(x):0;break;default:if(x=b.tagName,b=b.namespaceURI)b=nW(b),x=rW(b,x);else switch(x){case"svg":x=1;break;case"math":x=2;break;default:x=0}}le(te),ce(te,x)}r(Y,"pushHostContainer");function G(){le(te),le(re),le(de)}r(G,"popHostContainer");function fe(x){x.memoizedState!==null&&ce(Z,x);var b=te.current,k=rW(b,x.type);b!==k&&(ce(re,x),ce(te,k))}r(fe,"pushHostContext");function se(x){re.current===x&&(le(te),le(re)),Z.current===x&&(le(Z),$N._currentValue=V)}r(se,"popHostContext");var ae,ie;function ue(x){if(ae===void 0)try{throw Error()}catch(k){var b=k.stack.trim().match(/\n( *(at )?)/);ae=b&&b[1]||"",ie=-1<k.stack.indexOf(`
725
+ `)}U!==S&&(n.textContent=U,S=U)}r(I,"step");function T(){const E=d>0&&m>0;if(a.matches){o&&(o=!1,s.current!==null&&cancelAnimationFrame(s.current),s.current=null),E&&_();return}if(!i||!E){o&&(o=!1,s.current!==null&&cancelAnimationFrame(s.current),s.current=null);return}o||(o=!0,l=0,s.current=requestAnimationFrame(I))}r(T,"syncLoop");const R=new ResizeObserver(()=>{const E=Boe(n);h=E.w,p=E.h,N(),T()});R.observe(n);const L=r(()=>{i=document.visibilityState!=="hidden",T()},"onVisibilityChange");document.addEventListener("visibilitychange",L);const O=r(()=>{T()},"onMotionChange");a.addEventListener("change",O);const $=Boe(n);return h=$.w,p=$.h,N(),T(),()=>{o=!1,s.current!==null&&cancelAnimationFrame(s.current),R.disconnect(),document.removeEventListener("visibilitychange",L),a.removeEventListener("change",O)}},[]),(0,t.jsx)("pre",{ref:e,className:"w-full h-full m-0 p-0 overflow-hidden text-muted-foreground/60 select-none leading-none",style:{fontSize:"var(--text-micro)",fontFamily:"monospace"},"aria-hidden":"true"})}r(fUt,"AsciiArtAnimation");function xUt({decorative:e=!1,title:s="Paperclip",className:n,...a}){return(0,t.jsxs)("svg",{...a,className:n,viewBox:"22.5 22.5 121 27",fill:"currentColor",role:e?void 0:"img","aria-hidden":e?!0:void 0,"aria-label":e?void 0:s,focusable:"false",children:[(0,t.jsx)("path",{d:"M131.15 48.4902V31.9902H133.922V33.9775H134.094C134.237 33.6911 134.441 33.3831 134.706 33.0537C134.971 32.7171 135.329 32.4307 135.78 32.1943C136.239 31.958 136.822 31.8398 137.531 31.8398C138.455 31.8398 139.289 32.0762 140.034 32.5488C140.779 33.0215 141.37 33.7161 141.807 34.6328C142.251 35.5495 142.473 36.6774 142.473 38.0166C142.473 39.3343 142.258 40.4551 141.828 41.3789C141.398 42.3027 140.808 43.0081 140.056 43.4951C139.311 43.9749 138.466 44.2148 137.521 44.2148C136.84 44.2148 136.271 44.1003 135.812 43.8711C135.361 43.6348 134.996 43.3555 134.717 43.0332C134.445 42.7038 134.237 42.3923 134.094 42.0986H133.976V48.4902H131.15ZM136.747 41.8945C137.37 41.8945 137.889 41.7262 138.305 41.3896C138.727 41.0531 139.046 40.5911 139.261 40.0039C139.476 39.4167 139.583 38.7507 139.583 38.0059C139.583 37.2611 139.476 36.5986 139.261 36.0186C139.046 35.4385 138.731 34.9837 138.315 34.6543C137.9 34.3249 137.377 34.1602 136.747 34.1602C136.138 34.1602 135.623 34.3177 135.2 34.6328C134.785 34.9479 134.466 35.3955 134.244 35.9756C134.029 36.5485 133.922 37.2253 133.922 38.0059C133.922 38.7793 134.029 39.4596 134.244 40.0469C134.466 40.627 134.788 41.0817 135.211 41.4111C135.633 41.7334 136.146 41.8945 136.747 41.8945Z"}),(0,t.jsx)("path",{d:"M126.451 44V31.9902H129.276V44H126.451ZM127.869 30.3037C127.417 30.3037 127.031 30.1533 126.708 29.8525C126.386 29.5518 126.225 29.1901 126.225 28.7676C126.225 28.3379 126.386 27.9727 126.708 27.6719C127.031 27.3711 127.417 27.2207 127.869 27.2207C128.313 27.2207 128.696 27.3711 129.018 27.6719C129.34 27.9727 129.501 28.3343 129.501 28.7568C129.501 29.1865 129.34 29.5518 129.018 29.8525C128.696 30.1533 128.313 30.3037 127.869 30.3037Z"}),(0,t.jsx)("path",{d:"M124.576 27.9941V44H121.75V27.9941H124.576Z"}),(0,t.jsx)("path",{d:"M115.3 44.2363C114.104 44.2363 113.076 43.9749 112.217 43.4521C111.357 42.9222 110.699 42.1917 110.24 41.2607C109.782 40.3298 109.553 39.2591 109.553 38.0488C109.553 36.8242 109.785 35.7464 110.251 34.8154C110.716 33.8844 111.379 33.1576 112.238 32.6348C113.098 32.1048 114.111 31.8398 115.278 31.8398C116.259 31.8398 117.126 32.0189 117.878 32.377C118.63 32.735 119.228 33.2399 119.672 33.8916C120.123 34.5361 120.381 35.2917 120.445 36.1582H117.738C117.667 35.7715 117.527 35.4242 117.319 35.1162C117.112 34.8083 116.84 34.5648 116.503 34.3857C116.174 34.2067 115.78 34.1172 115.321 34.1172C114.741 34.1172 114.233 34.2747 113.796 34.5898C113.366 34.8978 113.03 35.3418 112.786 35.9219C112.543 36.502 112.421 37.1966 112.421 38.0059C112.421 38.8223 112.539 39.5277 112.775 40.1221C113.012 40.7093 113.348 41.1641 113.785 41.4863C114.222 41.8014 114.734 41.959 115.321 41.959C115.944 41.959 116.471 41.7764 116.9 41.4111C117.337 41.0459 117.617 40.541 117.738 39.8965H120.445C120.381 40.7487 120.13 41.5007 119.693 42.1523C119.257 42.804 118.666 43.3161 117.921 43.6885C117.176 44.0537 116.302 44.2363 115.3 44.2363Z"}),(0,t.jsx)("path",{d:"M102.876 44V31.9902H105.615V34.0098H105.744C105.959 33.3079 106.335 32.7708 106.872 32.3984C107.409 32.0189 108.021 31.8291 108.709 31.8291C108.859 31.8291 109.031 31.8363 109.225 31.8506C109.425 31.8649 109.59 31.8828 109.719 31.9043V34.5039C109.597 34.4609 109.407 34.4251 109.149 34.3965C108.892 34.3678 108.645 34.3535 108.408 34.3535C107.885 34.3535 107.42 34.4645 107.012 34.6865C106.604 34.9085 106.281 35.2129 106.045 35.5996C105.816 35.9863 105.701 36.4375 105.701 36.9531V44H102.876Z"}),(0,t.jsx)("path",{d:"M96.2319 44.2363C95.0288 44.2363 93.9904 43.9857 93.1167 43.4844C92.243 42.9759 91.5698 42.2598 91.0972 41.3359C90.6317 40.4121 90.3989 39.3236 90.3989 38.0703C90.3989 36.8314 90.6317 35.7464 91.0972 34.8154C91.5627 33.8773 92.2179 33.1468 93.063 32.624C93.908 32.1012 94.9035 31.8398 96.0493 31.8398C96.7869 31.8398 97.4852 31.958 98.144 32.1943C98.8101 32.4307 99.3973 32.7959 99.9058 33.29C100.421 33.7842 100.826 34.4144 101.12 35.1807C101.413 35.9398 101.56 36.8457 101.56 37.8984V38.7793H91.7202V36.8779H100.153L98.8315 37.4365C98.8315 36.7562 98.7277 36.1654 98.52 35.6641C98.3123 35.1556 98.0044 34.7581 97.5962 34.4717C97.188 34.1852 96.6795 34.042 96.0708 34.042C95.4621 34.042 94.9429 34.1852 94.5132 34.4717C94.0835 34.7581 93.7576 35.1449 93.5356 35.6318C93.3136 36.1117 93.2026 36.6488 93.2026 37.2432V38.5645C93.2026 39.2949 93.328 39.9215 93.5786 40.4443C93.8364 40.96 94.1945 41.3538 94.6528 41.626C95.1183 41.8981 95.659 42.0342 96.2749 42.0342C96.6759 42.0342 97.0412 41.9769 97.3706 41.8623C97.7072 41.7477 97.9937 41.5758 98.23 41.3467C98.4735 41.1104 98.6597 40.8203 98.7886 40.4766L101.431 40.7881C101.259 41.4827 100.941 42.0915 100.475 42.6143C100.017 43.1299 99.4259 43.5309 98.7026 43.8174C97.9865 44.0967 97.1629 44.2363 96.2319 44.2363Z"}),(0,t.jsx)("path",{d:"M78.2437 48.4902V31.9902H81.0151V33.9775H81.187C81.3302 33.6911 81.5343 33.3831 81.7993 33.0537C82.0643 32.7171 82.4224 32.4307 82.8735 32.1943C83.3319 31.958 83.9155 31.8398 84.6245 31.8398C85.5483 31.8398 86.3826 32.0762 87.1274 32.5488C87.8722 33.0215 88.4631 33.7161 88.8999 34.6328C89.3439 35.5495 89.5659 36.6774 89.5659 38.0166C89.5659 39.3343 89.3511 40.4551 88.9214 41.3789C88.4917 42.3027 87.9009 43.0081 87.1489 43.4951C86.4041 43.9749 85.5591 44.2148 84.6138 44.2148C83.9334 44.2148 83.3641 44.1003 82.9058 43.8711C82.4546 43.6348 82.0894 43.3555 81.8101 43.0332C81.5379 42.7038 81.3302 42.3923 81.187 42.0986H81.0688V48.4902H78.2437ZM83.8403 41.8945C84.4634 41.8945 84.9826 41.7262 85.3979 41.3896C85.8205 41.0531 86.1392 40.5911 86.354 40.0039C86.5688 39.4167 86.6763 38.7507 86.6763 38.0059C86.6763 37.2611 86.5688 36.5986 86.354 36.0186C86.1392 35.4385 85.8241 34.9837 85.4087 34.6543C84.9933 34.3249 84.4705 34.1602 83.8403 34.1602C83.2316 34.1602 82.716 34.3177 82.2935 34.6328C81.8781 34.9479 81.5594 35.3955 81.3374 35.9756C81.1226 36.5485 81.0151 37.2253 81.0151 38.0059C81.0151 38.7793 81.1226 39.4596 81.3374 40.0469C81.5594 40.627 81.8817 41.0817 82.3042 41.4111C82.7267 41.7334 83.2388 41.8945 83.8403 41.8945Z"}),(0,t.jsx)("path",{d:"M70.042 44.2471C69.2757 44.2471 68.5882 44.111 67.9795 43.8389C67.3708 43.5596 66.891 43.1514 66.54 42.6143C66.1891 42.0771 66.0137 41.4147 66.0137 40.627C66.0137 39.9538 66.139 39.3952 66.3896 38.9512C66.6403 38.5072 66.9805 38.1527 67.4102 37.8877C67.847 37.6227 68.3376 37.4222 68.8818 37.2861C69.4261 37.1429 69.9883 37.0426 70.5684 36.9854C71.2773 36.9066 71.8503 36.8385 72.2871 36.7812C72.724 36.724 73.0391 36.6309 73.2324 36.502C73.4329 36.373 73.5332 36.1725 73.5332 35.9004V35.8467C73.5332 35.2666 73.3613 34.8154 73.0176 34.4932C72.6738 34.1709 72.1725 34.0098 71.5137 34.0098C70.819 34.0098 70.2676 34.1602 69.8594 34.4609C69.4583 34.7617 69.1862 35.1162 69.043 35.5244L66.4111 35.1484C66.6188 34.418 66.9626 33.8092 67.4424 33.3223C67.9222 32.8281 68.5059 32.4593 69.1934 32.2158C69.888 31.9652 70.6543 31.8398 71.4922 31.8398C72.0651 31.8398 72.638 31.9079 73.2109 32.0439C73.7839 32.1729 74.3102 32.3949 74.79 32.71C75.2699 33.0251 75.653 33.4476 75.9395 33.9775C76.2259 34.5075 76.3691 35.1699 76.3691 35.9648V44H73.6514V42.3457H73.5654C73.3936 42.6751 73.1501 42.9867 72.835 43.2803C72.527 43.5667 72.1403 43.7995 71.6748 43.9785C71.2165 44.1576 70.6722 44.2471 70.042 44.2471ZM70.7617 42.1631C71.3346 42.1631 71.8288 42.0521 72.2441 41.8301C72.6595 41.6009 72.9818 41.3001 73.2109 40.9277C73.4401 40.5482 73.5547 40.1364 73.5547 39.6924V38.2852C73.4616 38.3568 73.3112 38.4248 73.1035 38.4893C72.8958 38.5465 72.6595 38.6003 72.3945 38.6504C72.1296 38.7005 71.8682 38.7435 71.6104 38.7793C71.3597 38.8151 71.1413 38.8438 70.9551 38.8652C70.5326 38.9225 70.153 39.0192 69.8164 39.1553C69.487 39.2842 69.2256 39.4632 69.0322 39.6924C68.8389 39.9215 68.7422 40.2188 68.7422 40.584C68.7422 41.1068 68.932 41.5007 69.3115 41.7656C69.6911 42.0306 70.1745 42.1631 70.7617 42.1631Z"}),(0,t.jsx)("path",{d:"M53.7939 44V27.9941H59.7988C61.0306 27.9941 62.0618 28.2233 62.8926 28.6816C63.7305 29.14 64.3643 29.7702 64.7939 30.5723C65.2236 31.3743 65.4385 32.2839 65.4385 33.3008C65.4385 34.3249 65.2201 35.238 64.7832 36.04C64.3535 36.835 63.7161 37.4616 62.8711 37.9199C62.026 38.3711 60.9876 38.5967 59.7559 38.5967H55.7812V36.2119H59.3584C60.0817 36.2119 60.6725 36.0902 61.1309 35.8467C61.5964 35.596 61.9365 35.2523 62.1514 34.8154C62.3734 34.3714 62.4844 33.8665 62.4844 33.3008C62.4844 32.7279 62.3734 32.2266 62.1514 31.7969C61.9365 31.36 61.5964 31.0234 61.1309 30.7871C60.6725 30.5436 60.0781 30.4219 59.3477 30.4219H56.6943V44H53.7939Z"}),(0,t.jsx)("path",{d:"M46.2611 33.6556L34.7307 44.6408C32.7445 46.5331 29.5205 46.5323 27.5303 44.6361C25.5404 42.74 25.54 39.669 27.5261 37.7768L39.0565 26.7916C40.2474 25.657 42.1811 25.6567 43.3752 26.7943C44.5693 27.9319 44.5689 29.7742 43.378 30.9088L31.849 41.8954C31.4528 42.2728 30.8077 42.273 30.4092 41.8933C30.011 41.5136 30.0117 40.8996 30.4078 40.5223L41.9382 29.5371C42.336 29.1581 42.336 28.5437 41.9382 28.1647C41.5404 27.786 40.8954 27.7858 40.4977 28.1647L28.9673 39.1499C27.7742 40.2866 27.7764 42.1295 28.9687 43.2657C30.1613 44.402 32.0963 44.4046 33.2895 43.2678L44.8192 32.2805C46.8068 30.3865 46.8038 27.3159 44.8157 25.4219C42.8275 23.5277 39.6039 23.5253 37.616 25.4192L26.0856 36.4044C23.3024 39.056 23.3058 43.3558 26.0898 46.0085C28.8741 48.6612 33.388 48.6649 36.1712 46.0132L47.7017 35.028C48.0994 34.649 48.0994 34.0346 47.7017 33.6556C47.3039 33.2766 46.6589 33.2766 46.2611 33.6556Z"})]})}r(xUt,"PaperclipLockup");function gUt(){const e=Kt(),s=Hn(),[n]=Ri(),[a,i]=(0,u.useState)("sign_in"),[o,l]=(0,u.useState)(""),[c,d]=(0,u.useState)(""),[m,h]=(0,u.useState)(""),[p,f]=(0,u.useState)(null),g="auth-error",v=(0,u.useMemo)(()=>n.get("next")||mUt()||"/",[n]),{data:y,isLoading:w}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1});(0,u.useEffect)(()=>{y&&s(v,{replace:!0})},[y,s,v]);const S=ke({mutationFn:r(async()=>{if(a==="sign_in"){await Fa.signInEmail({email:c.trim(),password:m});return}await Fa.signUpEmail({name:o.trim(),email:c.trim(),password:m})},"mutationFn"),onSuccess:r(async()=>{f(null),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.resetQueries({queryKey:P.companies.all}),s(v,{replace:!0})},"onSuccess"),onError:r(N=>{f(N instanceof Error?N.message:"Authentication failed")},"onError")}),j=c.trim().length>0&&m.trim().length>0&&(a==="sign_in"||o.trim().length>0&&m.trim().length>=8);return w?(0,t.jsx)("div",{className:"fixed inset-0 flex items-center justify-center",children:(0,t.jsx)(Jm,{className:"min-h-0"})}):(0,t.jsxs)("div",{className:"fixed inset-0 flex bg-background",children:[(0,t.jsx)("div",{className:"absolute top-4 right-4 z-10",children:(0,t.jsx)(Aj,{})}),(0,t.jsx)("div",{className:"w-full md:w-1/2 flex flex-col overflow-y-auto",children:(0,t.jsxs)("div",{className:"w-full max-w-md mx-auto my-auto px-8 py-12",children:[(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(xUt,{className:"h-5 w-auto"})}),(0,t.jsx)("h1",{className:"text-xl font-semibold",children:a==="sign_in"?"Sign in to Paperclip":"Create your Paperclip account"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:a==="sign_in"?"Use your email and password to access this instance.":"Create an account for this instance. Email confirmation is not required in v1."}),(0,t.jsxs)("form",{className:"mt-6 space-y-4",method:"post",action:a==="sign_up"?"/api/auth/sign-up/email":"/api/auth/sign-in/email",onSubmit:r(N=>{if(N.preventDefault(),!S.isPending){if(!j){f("Please fill in all required fields.");return}S.mutate()}},"onSubmit"),children:[a==="sign_up"&&(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"name",className:"text-xs text-muted-foreground mb-1 block",children:"Name"}),(0,t.jsx)("input",{id:"name",name:"name",className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",value:o,onChange:r(N=>l(N.target.value),"onChange"),autoComplete:"name",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0,autoFocus:!0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"email",className:"text-xs text-muted-foreground mb-1 block",children:"Email"}),(0,t.jsx)("input",{id:"email",name:"email",className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",type:"email",value:c,onChange:r(N=>d(N.target.value),"onChange"),autoComplete:"username",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0,autoFocus:a==="sign_in"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"password",className:"text-xs text-muted-foreground mb-1 block",children:"Password"}),(0,t.jsx)("input",{id:"password",name:"password",className:"w-full rounded-md border border-border bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50",type:"password",value:m,onChange:r(N=>h(N.target.value),"onChange"),autoComplete:a==="sign_in"?"current-password":"new-password",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0})]}),p&&(0,t.jsx)("p",{id:g,role:"alert",className:"text-xs text-destructive",children:p}),(0,t.jsx)(F,{type:"submit",disabled:S.isPending,"aria-disabled":!j||S.isPending,className:`w-full ${!j&&!S.isPending?"opacity-50":""}`,children:S.isPending?"Working…":a==="sign_in"?"Sign In":"Create Account"})]}),(0,t.jsxs)("div",{className:"mt-5 text-sm text-muted-foreground",children:[a==="sign_in"?"Need an account?":"Already have an account?"," ",(0,t.jsx)("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:r(()=>{f(null),i(a==="sign_in"?"sign_up":"sign_in")},"onClick"),children:a==="sign_in"?"Create one":"Sign in"})]})]})}),(0,t.jsx)("div",{className:"hidden md:block w-1/2 overflow-hidden",children:(0,t.jsx)(fUt,{})})]})}r(gUt,"AuthPage");function bUt(){const e=Kt(),s=ka(),[n]=Ri(),a=(s.token??"").trim(),i=(n.get("code")??"").trim(),o=(0,u.useMemo)(()=>`/board-claim/${encodeURIComponent(a)}${i?`?code=${encodeURIComponent(i)}`:""}`,[a,i]),l=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),c=ee({queryKey:["board-claim",a,i],queryFn:r(()=>ur.getBoardClaimStatus(a,i),"queryFn"),enabled:a.length>0&&i.length>0,retry:!1}),d=ke({mutationFn:r(()=>ur.claimBoard(a,i),"mutationFn"),onSuccess:r(async()=>{await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.invalidateQueries({queryKey:P.companies.all}),await e.invalidateQueries({queryKey:P.companies.stats}),await c.refetch()},"onSuccess")});if(!a||!i)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid board claim URL."});if(c.isLoading||l.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading claim challenge..."});if(c.error)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Claim challenge unavailable"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:c.error instanceof Error?c.error.message:"Challenge is invalid or expired."})]})});const m=c.data;return m?m.status==="claimed"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Board ownership claimed"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This instance is now linked to your authenticated user."}),(0,t.jsx)(F,{asChild:!0,className:"mt-4",children:(0,t.jsx)(Ge,{to:"/",children:"Open board"})})]})}):l.data?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Claim Board ownership"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This will promote your user to instance admin and migrate organization ownership access from local trusted mode."}),d.error&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive",children:d.error instanceof Error?d.error.message:"Failed to claim board ownership"}),(0,t.jsx)(F,{className:"mt-5",onClick:r(()=>d.mutate(),"onClick"),disabled:d.isPending,children:d.isPending?"Claiming…":"Claim ownership"})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Sign in required"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Sign in or create an account, then return to this page to claim Board ownership."}),(0,t.jsx)(F,{asChild:!0,className:"mt-4",children:(0,t.jsx)(Ge,{to:`/auth?next=${encodeURIComponent(o)}`,children:"Sign in / Create account"})})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Claim challenge unavailable."})}r(bUt,"BoardClaimPage");function vUt(){const e=Kt(),s=ka(),[n]=Ri(),a=(s.id??"").trim(),i=(n.get("token")??"").trim(),o=(0,u.useMemo)(()=>`/cli-auth/${encodeURIComponent(a)}${i?`?token=${encodeURIComponent(i)}`:""}`,[a,i]),l=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),c=ee({queryKey:["cli-auth-challenge",a,i],queryFn:r(()=>ur.getCliAuthChallenge(a,i),"queryFn"),enabled:a.length>0&&i.length>0,retry:!1}),d=ke({mutationFn:r(()=>ur.approveCliAuthChallenge(a,i),"mutationFn"),onSuccess:r(async()=>{await e.invalidateQueries({queryKey:P.auth.session}),await c.refetch()},"onSuccess")}),m=ke({mutationFn:r(()=>ur.cancelCliAuthChallenge(a,i),"mutationFn"),onSuccess:r(async()=>{await c.refetch()},"onSuccess")});if(!a||!i)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid CLI auth URL."});if(l.isLoading||c.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading CLI auth challenge..."});if(c.error)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"CLI auth challenge unavailable"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:c.error instanceof Error?c.error.message:"Challenge is invalid or expired."})]})});const h=c.data;return h?h.status==="approved"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"CLI access approved"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"The Paperclip CLI can now finish authentication on the requesting machine."}),(0,t.jsxs)("p",{className:"mt-4 text-sm text-muted-foreground",children:["Command: ",(0,t.jsx)("span",{className:"font-mono text-foreground",children:h.command})]})]})}):h.status==="cancelled"||h.status==="expired"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:h.status==="expired"?"CLI auth challenge expired":"CLI auth challenge cancelled"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Start the CLI auth flow again from your terminal to generate a new approval request."})]})}):h.requiresSignIn||!l.data?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Sign in required"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Sign in or create an account, then return to this page to approve the CLI access request."}),(0,t.jsx)(F,{asChild:!0,className:"mt-4",children:(0,t.jsx)(Ge,{to:`/auth?next=${encodeURIComponent(o)}`,children:"Sign in / Create account"})})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Xs,{className:"block p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Approve Paperclip CLI access"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"A local Paperclip CLI process is requesting board access to this instance."}),(0,t.jsxs)("div",{className:"mt-5 space-y-3 text-sm",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Command"}),(0,t.jsx)("div",{className:"font-mono text-foreground",children:h.command})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Client"}),(0,t.jsx)("div",{className:"text-foreground",children:h.clientName??"paperclip-pro cli"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Requested access"}),(0,t.jsx)("div",{className:"text-foreground",children:h.requestedAccess==="instance_admin_required"?"Instance admin":"Board"})]}),h.requestedCompanyName&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-muted-foreground",children:"Requested organization"}),(0,t.jsx)("div",{className:"text-foreground",children:h.requestedCompanyName})]})]}),(d.error||m.error)&&(0,t.jsx)("p",{className:"mt-4 text-sm text-destructive",children:(d.error??m.error)instanceof Error?(d.error??m.error).message:"Failed to update CLI auth challenge"}),!h.canApprove&&(0,t.jsx)("p",{className:"mt-4 text-sm text-destructive",children:"This challenge requires instance-admin access. Sign in with an instance admin account to approve it."}),(0,t.jsxs)("div",{className:"mt-5 flex gap-3",children:[(0,t.jsx)(F,{onClick:r(()=>d.mutate(),"onClick"),disabled:!h.canApprove||d.isPending||m.isPending,children:d.isPending?"Approving...":"Approve CLI access"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>m.mutate(),"onClick"),disabled:d.isPending||m.isPending,children:m.isPending?"Cancelling...":"Cancel"})]})]})}):(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"CLI auth challenge unavailable."})}r(vUt,"CliAuthPage");var yUt=MIe.filter(e=>e!=="paperclip_runner"),qoe=new Set(["claude_local","codex_local","gemini_local","kimi_local","opencode_local","pi_local","cursor"]);function jUt(e,s){let n=e;for(const a of s){if(!n||typeof n!="object")return null;n=n[a]}return typeof n=="string"&&n.trim().length>0?n:null}r(jUt,"readNestedString");var By="w-full border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-zinc-500",zoe="border border-zinc-800 bg-zinc-950/95 p-6",Uoe="flex-1 border px-3 py-2 text-sm transition-colors";function wUt(e){return e?e.charAt(0).toUpperCase()+e.slice(1):null}r(wUt,"formatHumanRole");function c1e(e){if(!e||typeof e!="object")return null;const s=e.code;return typeof s=="string"&&s.trim().length>0?s:null}r(c1e,"getAuthErrorCode");function NUt(e){if(!(e instanceof Error))return null;const s=e.message.trim();return s.length>0?s:null}r(NUt,"getAuthErrorMessage");function kUt(e,s,n){const a=c1e(e),i=NUt(e),o=n.trim().length>0?n.trim():"that email";return a==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"?{tone:"info",message:`An account already exists for ${o}. Sign in below to continue with this invite.`}:a==="INVALID_EMAIL_OR_PASSWORD"?{tone:"error",message:"That email and password did not match an existing Paperclip account. Check both fields, or create an account first if you are new here."}:s==="sign_in"&&i==="Request failed: 401"?{tone:"error",message:"That email and password did not match an existing Paperclip account. Check both fields, or create an account first if you are new here."}:s==="sign_up"&&i==="Request failed: 422"?{tone:"info",message:`An account may already exist for ${o}. Try signing in instead.`}:{tone:"error",message:i??"Authentication failed"}}r(kUt,"mapInviteAuthFeedback");function Koe(e){return!!(e&&typeof e=="object"&&"bootstrapAccepted"in e)}r(Koe,"isBootstrapAcceptancePayload");function SUt(e,s){return!e||typeof e!="object"||s?!1:e.status==="approved"}r(SUt,"isApprovedHumanJoinPayload");function W6({companyDisplayName:e,companyLogoUrl:s,className:n}){return(0,t.jsx)(Dx,{companyName:e,logoUrl:s,logoFit:"contain",className:n})}r(W6,"InviteCompanyLogo");function Voe({companyDisplayName:e,companyLogoUrl:s,invitedByUserName:n,claimSecret:a=null,claimApiKeyPath:i=null,onboardingTextUrl:o=null}){return(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6","data-testid":"invite-pending-approval",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(W6,{companyDisplayName:e,companyLogoUrl:s,className:"h-12 w-12 border border-zinc-800 rounded-none"}),(0,t.jsxs)("h1",{className:"text-lg font-semibold",children:["Request to join ",e]})]}),(0,t.jsxs)("div",{className:"mt-4 space-y-3",children:[(0,t.jsxs)("p",{className:"text-sm text-zinc-400",children:["Your request is still awaiting approval. ",n??"An organization admin"," must approve your request to join."]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("p",{className:"text-xs text-zinc-500 mb-1",children:"Approval page"}),(0,t.jsx)("p",{className:"text-sm text-zinc-200",children:"Settings → Members"})]}),(0,t.jsxs)("p",{className:"text-sm text-zinc-400",children:["Ask them to visit ",(0,t.jsx)("span",{className:"text-zinc-200",children:"Settings → Members"})," to approve your request."]}),(0,t.jsx)("p",{className:"text-xs text-zinc-500",children:"Refresh this page after you've been approved — you'll be redirected automatically."})]}),a&&i?(0,t.jsxs)("div",{className:"mt-4 space-y-1 border border-zinc-800 p-3 text-xs text-zinc-400",children:[(0,t.jsx)("div",{className:"text-zinc-200",children:"Claim secret"}),(0,t.jsx)("div",{className:"font-mono break-all",children:a}),(0,t.jsxs)("div",{className:"font-mono break-all",children:["POST ",i]})]}):null,o?(0,t.jsxs)("div",{className:"mt-4 text-xs text-zinc-400",children:["Onboarding: ",(0,t.jsx)("span",{className:"font-mono break-all",children:o})]}):null]})})}r(Voe,"AwaitingJoinApprovalPanel");function CUt(){const e=Kt(),s=Hn(),{setSelectedCompanyId:n}=xs(),a=(ka().token??"").trim(),[i,o]=(0,u.useState)("sign_up"),[l,c]=(0,u.useState)(""),[d,m]=(0,u.useState)(""),[h,p]=(0,u.useState)(""),[f,g]=(0,u.useState)(""),[v,y]=(0,u.useState)("claude_local"),[w,S]=(0,u.useState)(""),[j,N]=(0,u.useState)(null),[_,A]=(0,u.useState)(null),[C,I]=(0,u.useState)(null),[T,R]=(0,u.useState)(!1),L="invite-auth-error",O=ee({queryKey:P.health,queryFn:r(()=>tm.get(),"queryFn"),retry:!1}),$=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),E=ee({queryKey:P.access.invite(a),queryFn:r(()=>ur.getInvite(a),"queryFn"),enabled:a.length>0,retry:!1}),q=Q6({enabled:!!$.data&&!!E.data?.companyId,staleTime:0}),B=O.data?.deploymentMode!=="local_trusted"?q.isFetchedAfterMount:!0,K=B?q.data?.companies??[]:[];(0,u.useEffect)(()=>{a&&Ooe(a)},[a]),(0,u.useEffect)(()=>{R(!1)},[a]),(0,u.useEffect)(()=>{if(!B)return;const pe=q.data?.companies;!pe||!E.data?.companyId||pe.some(be=>be.id===E.data.companyId)&&XA(a)},[q.data,E.data,B,a]);const U=E.data,D=!!$.data&&!!U?.companyId&&!B,V=!!U?.companyId&&K.some(pe=>pe.id===U?.companyId),H=U?.companyName?.trim()||"this Paperclip company",J=U?.companyLogoUrl?.trim()||null,X=U?.invitedByUserName?.trim()||null,le=U?.inviteMessage?.trim()||null,ce=wUt(U?.humanRole),te=U?.joinRequestStatus??null,re=U?.joinRequestType??null,de=re==="human"&&(te==="pending_approval"||te==="approved"),Z=O.data?.deploymentMode==="authenticated"&&!$.data&&U?.allowedJoinTypes!=="agent",Y=U?.inviteType!=="bootstrap_ceo"&&U?.allowedJoinTypes==="agent",G=!!$.data&&!Y&&U?.inviteType!=="bootstrap_ceo"&&(!te||de)&&!D&&!V&&!j&&_===null,fe=$.data?.user.name?.trim()||$.data?.user.email?.trim()||"this account",se=d.trim().length>0&&h.trim().length>0&&(i==="sign_in"||l.trim().length>0&&h.trim().length>=8),ae=ke({mutationFn:r(async()=>{if(!U)throw new Error("Invite not found");if(D)throw new Error("Checking your organization access. Try again in a moment.");if(V)throw new Error("This account already belongs to the organization.");return U.inviteType==="bootstrap_ceo"||U.allowedJoinTypes!=="agent"?ur.acceptInvite(a,{requestType:"human"}):ur.acceptInvite(a,{requestType:"agent",agentName:f.trim(),adapterType:v,capabilities:w.trim()||null})},"mutationFn"),onSuccess:r(async pe=>{A(null),XA(a);const be=Koe(pe);N({kind:be?"bootstrap":"join",payload:pe}),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.access.currentBoardAccess}),await e.invalidateQueries({queryKey:P.companies.all}),U?.companyId&&SUt(pe,Y)&&(n(U.companyId,{source:"manual"}),s("/",{replace:!0}))},"onSuccess"),onError:r(pe=>{A(pe instanceof Error?pe.message:"Failed to accept invite")},"onError")});(0,u.useEffect)(()=>{!G||T||ae.isPending||(R(!0),A(null),ae.mutate())},[ae,T,G]);const ie=ke({mutationFn:r(async()=>{if(i==="sign_in"){await Fa.signInEmail({email:d.trim(),password:h});return}await Fa.signUpEmail({name:l.trim(),email:d.trim(),password:h})},"mutationFn"),onSuccess:r(async()=>{I(null),Ooe(a),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.invalidateQueries({queryKey:P.access.currentBoardAccess});const{companies:pe}=await V_e(e);if(U?.companyId&&pe.some(be=>be.id===U.companyId)){XA(a),n(U.companyId,{source:"manual"}),s("/",{replace:!0});return}if(!(!U||U.inviteType!=="bootstrap_ceo"))try{Koe(await ae.mutateAsync())&&s("/",{replace:!0})}catch{return}},"onSuccess"),onError:r(pe=>{const be=kUt(pe,i,d);c1e(pe)==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"&&(o("sign_in"),p("")),I(be)},"onError")}),ue=(0,u.useMemo)(()=>U?V?"Open organization":U.inviteType==="bootstrap_ceo"?"Accept invite":Y?"Submit request":$.data?"Accept invite":"Continue":"Continue",[U,V,$.data,Y]);if(!a)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-destructive",children:"Invalid invite token."});if(E.isLoading||O.isLoading||$.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading invite..."});if(D)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Checking your access..."});if(E.error||!U)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"border border-border bg-card p-6","data-testid":"invite-error",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Invite not available"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"This invite may be expired, revoked, or already used."})]})});if(te==="approved"&&re==="human"&&V)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Opening organization..."});if(te==="pending_approval"&&!de)return(0,t.jsx)(Voe,{companyDisplayName:H,companyLogoUrl:J,invitedByUserName:X});if(te&&!de)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"border border-border bg-card p-6","data-testid":"invite-error",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Invite not available"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:te==="rejected"?"This join request was not approved.":"This invite has already been used."})]})});if(j?.kind==="bootstrap")return(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6",children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Bootstrap complete"}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(F,{asChild:!0,className:"rounded-none",children:(0,t.jsx)(Ge,{to:"/",children:"Open board"})})})]})});if(j?.kind==="join"){const pe=j.payload,be=typeof pe.claimSecret=="string"?pe.claimSecret:null,oe=typeof pe.claimApiKeyPath=="string"?pe.claimApiKeyPath:null,je=jUt(pe.onboarding,["textInstructions","url"]);return!Y&&pe.status==="approved"?(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(W6,{companyDisplayName:H,companyLogoUrl:J,className:"h-12 w-12 border border-zinc-800 rounded-none"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"You joined the organization"})]}),(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(F,{asChild:!0,className:"w-full rounded-none",children:(0,t.jsx)(Ge,{to:"/",children:"Open board"})})})]})}):(0,t.jsx)(Voe,{companyDisplayName:H,companyLogoUrl:J,invitedByUserName:X,claimSecret:be,claimApiKeyPath:oe,onboardingTextUrl:je})}return(0,t.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,t.jsx)("div",{className:"mx-auto max-w-5xl",children:(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-(--gtc-36)",children:[(0,t.jsxs)("section",{className:`${zoe} space-y-6`,children:[(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[(0,t.jsx)(W6,{companyDisplayName:H,companyLogoUrl:J,className:"h-16 w-16 rounded-none border border-zinc-800"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"You've been invited to join Paperclip"}),(0,t.jsx)("h1",{className:"mt-2 text-2xl font-semibold",children:U.inviteType==="bootstrap_ceo"?"Set up Paperclip":`Join ${H}`}),(0,t.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-zinc-300",children:Y?"Review the invite details, then submit the agent information below to start the join request.":Z?"Create your Paperclip account first. If you already have one, switch to sign in and continue the invite with the same email.":"Your account is ready. Review the invite details, then accept it to continue."})]})]}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Organization"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:H})]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Invited by"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:X??"Paperclip board"})]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Requested access"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:Y?"Agent join request":ce??"Organization access"})]}),(0,t.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Invite expires"}),(0,t.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:pu(U.expiresAt)})]})]}),le?(0,t.jsxs)("div",{className:"border border-amber-500/40 bg-amber-500/10 p-4",children:[(0,t.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-amber-200/80",children:"Message from inviter"}),(0,t.jsx)("p",{className:"mt-2 text-sm leading-6 text-amber-50",children:le})]}):null,$.data?(0,t.jsxs)("div",{className:"border border-emerald-500/40 bg-emerald-500/10 p-4 text-sm text-emerald-50",children:["Signed in as ",(0,t.jsx)("span",{className:"font-medium",children:fe}),"."]}):null]}),(0,t.jsx)("section",{className:`${zoe} h-fit`,children:Y?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:"Submit agent details"}),(0,t.jsxs)("p",{className:"mt-1 text-sm text-zinc-400",children:["This invite will create an approval request for a new agent in ",H,"."]})]}),(0,t.jsxs)("label",{className:"block text-sm",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Agent name"}),(0,t.jsx)("input",{className:By,value:f,onChange:r(pe=>g(pe.target.value),"onChange")})]}),(0,t.jsxs)("label",{className:"block text-sm",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Adapter type"}),(0,t.jsx)("select",{className:By,value:v,onChange:r(pe=>y(pe.target.value),"onChange"),children:yUt.map(pe=>(0,t.jsxs)("option",{value:pe,disabled:!qoe.has(pe),children:[df(pe),qoe.has(pe)?"":" (Coming soon)"]},pe))})]}),(0,t.jsxs)("label",{className:"block text-sm",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Capabilities"}),(0,t.jsx)("textarea",{className:By,rows:4,value:w,onChange:r(pe=>S(pe.target.value),"onChange")})]}),_?(0,t.jsx)("p",{className:"text-xs text-red-400",children:_}):null,(0,t.jsx)(F,{className:"w-full rounded-none",disabled:ae.isPending||f.trim().length===0,onClick:r(()=>ae.mutate(),"onClick"),children:ae.isPending?"Working...":ue})]}):Z?(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:i==="sign_up"?"Create your account":"Sign in to continue"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:i==="sign_up"?`Start with a Paperclip account. After that, you'll come right back here to accept the invite for ${H}.`:"Use the Paperclip account that already matches this invite. If you do not have one yet, switch back to create account."})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{type:"button",className:`${Uoe} ${i==="sign_up"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:r(()=>{I(null),o("sign_up")},"onClick"),children:"Create account"}),(0,t.jsx)("button",{type:"button",className:`${Uoe} ${i==="sign_in"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:r(()=>{I(null),o("sign_in")},"onClick"),children:"I already have an account"})]}),(0,t.jsxs)("form",{className:"space-y-4",method:"post",action:i==="sign_up"?"/api/auth/sign-up/email":"/api/auth/sign-in/email",onSubmit:r(pe=>{if(pe.preventDefault(),!ie.isPending){if(!se){I({tone:"error",message:"Please fill in all required fields."});return}ie.mutate()}},"onSubmit"),"data-testid":"invite-inline-auth",children:[i==="sign_up"?(0,t.jsxs)("label",{className:"block text-sm",htmlFor:"invite-name",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Name"}),(0,t.jsx)("input",{id:"invite-name",name:"name",className:By,value:l,onChange:r(pe=>{c(pe.target.value),I(null)},"onChange"),autoComplete:"name",required:!0,"aria-required":"true","aria-invalid":C?.tone==="error"?!0:void 0,"aria-describedby":C?L:void 0,autoFocus:!0})]}):null,(0,t.jsxs)("label",{className:"block text-sm",htmlFor:"invite-email",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Email"}),(0,t.jsx)("input",{id:"invite-email",name:"email",type:"email",className:By,value:d,onChange:r(pe=>{m(pe.target.value),I(null)},"onChange"),autoComplete:"username",required:!0,"aria-required":"true","aria-invalid":C?.tone==="error"?!0:void 0,"aria-describedby":C?L:void 0,autoFocus:i==="sign_in"})]}),(0,t.jsxs)("label",{className:"block text-sm",htmlFor:"invite-password",children:[(0,t.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Password"}),(0,t.jsx)("input",{id:"invite-password",name:"password",type:"password",className:By,value:h,onChange:r(pe=>{p(pe.target.value),I(null)},"onChange"),autoComplete:i==="sign_in"?"current-password":"new-password",required:!0,"aria-required":"true","aria-invalid":C?.tone==="error"?!0:void 0,"aria-describedby":C?L:void 0})]}),C?(0,t.jsx)("p",{id:L,role:"alert",className:`text-xs ${C.tone==="info"?"text-amber-300":"text-red-400"}`,children:C.message}):null,(0,t.jsx)(F,{type:"submit",className:"w-full rounded-none",disabled:ie.isPending,"aria-disabled":!se||ie.isPending,children:ie.isPending?"Working...":i==="sign_in"?"Sign in and continue":"Create account and continue"})]}),(0,t.jsx)("p",{className:"text-xs leading-5 text-zinc-500",children:i==="sign_up"?"Already signed up before? Use the existing-account option instead so the invite lands on the right Paperclip user.":"No account yet? Switch back to create account so you can accept the invite with a new login."})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:V?"Already in this organization":G?"Completing organization access":U.inviteType==="bootstrap_ceo"?"Accept bootstrap invite":"Accept organization invite"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:G?`Granting your access to ${H}.`:V?`This account already belongs to ${H}.`:`This will ${U.inviteType==="bootstrap_ceo"?"finish setting up Paperclip":`grant or complete your access to ${H}`}.`})]}),_?(0,t.jsx)("p",{className:"text-xs text-red-400",children:_}):null,G?(0,t.jsx)("div",{className:"text-sm text-zinc-400",children:ae.isPending?"Submitting request...":"Finishing sign-in..."}):(0,t.jsx)(F,{className:"w-full rounded-none",disabled:ae.isPending,onClick:r(()=>{if(V&&U.companyId){XA(a),n(U.companyId,{source:"manual"}),s("/",{replace:!0});return}ae.mutate()},"onClick"),children:ae.isPending?"Working...":ue})]})})]})})})}r(CUt,"InviteLandingPage");function _Ut(){const{selectedCompany:e,selectedCompanyId:s}=xs(),{setBreadcrumbs:n}=Ln(),{pushToast:a}=Pi(),i=Kt(),[o,l]=(0,u.useState)("pending_approval"),[c,d]=(0,u.useState)("all");(0,u.useEffect)(()=>{n([{label:e?.name??"Organization",href:"/dashboard"},{label:"Inbox",href:"/inbox"},{label:"Join Requests"}])},[e?.name,n]);const m=ee({queryKey:P.access.joinRequests(s??"",`${o}:${c}`),queryFn:r(()=>ur.listJoinRequests(s,o,c==="all"?void 0:c),"queryFn"),enabled:!!s}),h=ke({mutationFn:r(f=>ur.approveJoinRequest(s,f),"mutationFn"),onSuccess:r(async()=>{await i.invalidateQueries({queryKey:P.access.joinRequests(s,`${o}:${c}`)}),await i.invalidateQueries({queryKey:P.access.companyMembers(s)}),await i.invalidateQueries({queryKey:P.access.companyUserDirectory(s)}),a({title:"Join request approved",tone:"success"})},"onSuccess")}),p=ke({mutationFn:r(f=>ur.rejectJoinRequest(s,f),"mutationFn"),onSuccess:r(async()=>{await i.invalidateQueries({queryKey:P.access.joinRequests(s,`${o}:${c}`)}),a({title:"Join request rejected",tone:"success"})},"onSuccess")});if(!s)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Select an organization to review join requests."});if(m.isLoading)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading join requests…"});if(m.error){const f=m.error instanceof vn&&m.error.status===403?"You do not have permission to review join requests for this organization.":m.error instanceof Error?m.error.message:"Failed to load join requests.";return(0,t.jsx)("div",{className:"text-sm text-destructive",children:f})}return(0,t.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(xPe,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Join Request Queue"})]}),(0,t.jsx)("p",{className:"max-w-3xl text-sm text-muted-foreground",children:"Review human and agent join requests outside the mixed inbox feed. This queue uses the same approval mutations as the inline inbox cards."})]}),(0,t.jsxs)(Xs,{className:"flex-row flex-wrap gap-3 p-4",children:[(0,t.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,t.jsx)("span",{className:"font-medium",children:"Status"}),(0,t.jsxs)("select",{className:"rounded-md border border-border bg-background px-3 py-2",value:o,onChange:r(f=>l(f.target.value),"onChange"),children:[(0,t.jsx)("option",{value:"pending_approval",children:"Pending approval"}),(0,t.jsx)("option",{value:"approved",children:"Approved"}),(0,t.jsx)("option",{value:"rejected",children:"Rejected"})]})]}),(0,t.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,t.jsx)("span",{className:"font-medium",children:"Request type"}),(0,t.jsxs)("select",{className:"rounded-md border border-border bg-background px-3 py-2",value:c,onChange:r(f=>d(f.target.value),"onChange"),children:[(0,t.jsx)("option",{value:"all",children:"All"}),(0,t.jsx)("option",{value:"human",children:"Human"}),(0,t.jsx)("option",{value:"agent",children:"Agent"})]})]})]}),(0,t.jsx)("div",{className:"space-y-4",children:(m.data??[]).length===0?(0,t.jsx)("div",{className:"rounded-xl border border-dashed border-border px-4 py-8 text-sm text-muted-foreground",children:"No join requests match the current filters."}):m.data.map(f=>(0,t.jsxs)(Xs,{className:"block p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(ct,{variant:f.status==="pending_approval"?"secondary":f.status==="approved"?"outline":"destructive",children:f.status.replace("_"," ")}),(0,t.jsx)(ct,{variant:"outline",children:f.requestType}),f.adapterType?(0,t.jsx)(ct,{variant:"outline",children:f.adapterType}):null]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-base font-medium",children:f.requestType==="human"?f.requesterUser?.name||f.requestEmailSnapshot||f.requestingUserId||"Unknown human requester":f.agentName||"Unknown agent requester"}),(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:f.requestType==="human"?f.requesterUser?.email||f.requestEmailSnapshot||f.requestingUserId:f.capabilities||f.requestIp})]})]}),f.status==="pending_approval"?(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>p.mutate(f.id),"onClick"),disabled:p.isPending,children:"Reject"}),(0,t.jsx)(F,{onClick:r(()=>h.mutate(f.id),"onClick"),disabled:h.isPending,children:"Approve"})]}):null]}),(0,t.jsxs)("div",{className:"mt-4 grid gap-3 text-sm text-muted-foreground md:grid-cols-2",children:[(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-background px-3 py-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide",children:"Invite context"}),(0,t.jsx)("div",{className:"mt-2",children:f.invite?`${f.invite.allowedJoinTypes} join invite${f.invite.humanRole?` • default role ${f.invite.humanRole}`:""}`:"Invite metadata unavailable"}),f.invite?.inviteMessage?(0,t.jsx)("div",{className:"mt-2 text-foreground",children:f.invite.inviteMessage}):null]}),(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-background px-3 py-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide",children:"Request details"}),(0,t.jsxs)("div",{className:"mt-2",children:["Submitted ",new Date(f.createdAt).toLocaleString()]}),(0,t.jsxs)("div",{children:["Source IP ",f.requestIp]}),f.requestType==="agent"&&f.capabilities?(0,t.jsx)("div",{children:f.capabilities}):null]})]})]},f.id))})]})}r(_Ut,"JoinRequestQueue");var IUt=(0,u.lazy)(()=>vc(()=>import("./CompanyExport-VHEmaNC_.js").then(e=>({default:e.CompanyExport})),__vite__mapDeps([6,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]))),AUt=(0,u.lazy)(()=>vc(()=>import("./Agents.production-Ou10IBgG.js").then(e=>({default:e.Agents})),__vite__mapDeps([26,5,7,9,8,10,11,12,13,27,28,29,15,30,31,32,33,24,25]))),RUt=(0,u.lazy)(()=>vc(()=>import("./Routines.production-CGNSsZDr.js").then(e=>({default:e.Routines})),__vite__mapDeps([34,5,7,8,9,10,11,12,13,35,14,15,36,37,29,27,38,39,40,21,41,42,16,17,18,19,43,44,30,45,46,23,31,47,33,48,49,50,51,24,25,28]))),Woe=(0,u.lazy)(()=>vc(()=>import("./RoutineDetail.production-B2lkeY8y.js").then(e=>({default:e.RoutineDetail})),__vite__mapDeps([52,5,7,8,9,10,11,12,13,35,14,15,36,37,29,27,38,39,40,21,41,42,16,17,18,19,43,44,30,45,46,23,31,47,33,48,49,50,51,24,25,53]))),TUt=(0,u.lazy)(()=>vc(()=>import("./CompanySkills.production-DuSUb8DQ.js").then(e=>({default:e.CompanySkills})),__vite__mapDeps([54,5,7,8,9,10,11,12,13,14,15,36,37,29,27,38,39,40,21,41,28,16,17,18,19,55,53,31,44,22,20,56,47,48,50,24,25]))),EUt=(0,u.lazy)(()=>vc(()=>import("./CompanyActivity.production-dbz2o26S.js").then(e=>({default:e.CompanyActivity})),__vite__mapDeps([57,5,7,8,9,10,11,12,13,27,28,29,43,37,21,44,48,49,51]))),PUt=(0,u.lazy)(()=>vc(()=>import("./Costs.production-BRz8Rn3s.js").then(e=>({default:e.Costs})),__vite__mapDeps([58,5,7,28,29,13,12,44,41,50,27,51,24,25]))),MUt=(0,u.lazy)(()=>vc(()=>import("./OrgChart.production-Dgq5pMMa.js").then(e=>({default:e.OrgChart})),__vite__mapDeps([59,5,7,8,9,10,11,12,13,27,45,46,51,24,25])));function fg({children:e}){return(0,t.jsx)(u.Suspense,{fallback:(0,t.jsx)(Jm,{}),children:e})}r(fg,"ProductionSurface");function DUt(e){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{index:!0,element:(0,t.jsx)(wn,{to:"dashboard",replace:!0})}),(0,t.jsx)(ot,{path:"dashboard",element:(0,t.jsx)(mpt,{})}),(0,t.jsx)(ot,{path:"dashboard/live",element:(0,t.jsx)(hpt,{})}),(0,t.jsx)(ot,{path:"timeline",element:e?(0,t.jsx)(yp,{to:"/activity/timeline"}):(0,t.jsx)(Yye,{})}),(0,t.jsx)(ot,{path:"onboarding",element:(0,t.jsx)(m1e,{})}),(0,t.jsx)(ot,{path:"companies",element:(0,t.jsx)(Zpt,{})}),(0,t.jsx)(ot,{path:"company/settings",element:(0,t.jsx)(h3t,{})}),(0,t.jsx)(ot,{path:"company/settings/environments",element:(0,t.jsx)(wn,{to:"/company/settings/instance/environments",replace:!0})}),(0,t.jsx)(ot,{path:"company/settings/cloud-upstream",element:(0,t.jsx)(wn,{to:"/company/export",replace:!0})}),(0,t.jsxs)(ot,{element:(0,t.jsx)(ch,{pageKey:"company.members"}),children:[(0,t.jsx)(ot,{path:"company/settings/members",element:(0,t.jsx)(DMt,{})}),(0,t.jsx)(ot,{path:"company/settings/access",element:(0,t.jsx)(LMt,{})})]}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"company.invites"}),children:(0,t.jsx)(ot,{path:"company/settings/invites",element:(0,t.jsx)(wn,{to:"/company/settings/members?tab=invites",replace:!0})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"company.export"}),children:(0,t.jsx)(ot,{path:"company/export/*",element:(0,t.jsx)(u.Suspense,{fallback:(0,t.jsx)(Jm,{}),children:(0,t.jsx)(IUt,{})})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(rtt,{}),children:(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"company.import"}),children:(0,t.jsx)(ot,{path:"company/import",element:(0,t.jsx)(K6t,{})})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"company.secrets"}),children:(0,t.jsx)(ot,{path:"company/settings/secrets",element:(0,t.jsx)(Fqt,{})})}),(0,t.jsx)(ot,{path:"company/settings/tools",element:(0,t.jsx)(Qoe,{})}),(0,t.jsx)(ot,{path:"company/settings/tools/:tab",element:(0,t.jsx)(Qoe,{})}),(0,t.jsx)(ot,{path:"tools",element:(0,t.jsx)(Goe,{})}),(0,t.jsx)(ot,{path:"tools/:tab",element:(0,t.jsx)(Goe,{})}),(0,t.jsx)(ot,{path:"apps",element:(0,t.jsx)(vDt,{})}),(0,t.jsx)(ot,{path:"apps/browse",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/connections",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/byo",element:(0,t.jsx)(FSe,{byoOnly:!0})}),(0,t.jsx)(ot,{path:"apps/vercel-connect",element:(0,t.jsx)(Hoe,{credentialSource:"vercel_connect"})}),(0,t.jsx)(ot,{path:"apps/connect",element:(0,t.jsx)(Hoe,{})}),(0,t.jsx)(ot,{path:"apps/chat/connect",element:(0,t.jsx)(v$,{children:(0,t.jsx)(WDt,{})})}),(0,t.jsx)(ot,{path:"apps/chat/:endpointId",element:(0,t.jsx)(v$,{children:(0,t.jsx)(wn,{to:"settings",replace:!0})})}),(0,t.jsx)(ot,{path:"apps/chat/:endpointId/:tab",element:(0,t.jsx)(v$,{children:(0,t.jsx)(dLt,{})})}),(0,t.jsx)(ot,{path:"apps/connect/:appKey",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/connect/:appKey/:stage",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/review",element:(0,t.jsx)(gLt,{})}),(0,t.jsx)(ot,{path:"apps/attention",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/gateways",element:(0,t.jsx)(nie,{})}),(0,t.jsx)(ot,{path:"apps/gateways/:gatewayId",element:(0,t.jsx)(wn,{to:"overview",replace:!0})}),(0,t.jsx)(ot,{path:"apps/gateways/:gatewayId/:tab",element:(0,t.jsx)(u$t,{})}),(0,t.jsx)(ot,{path:"apps/advanced",element:(0,t.jsx)(Fae,{})}),(0,t.jsx)(ot,{path:"apps/advanced/gateways",element:(0,t.jsx)(nie,{})}),(0,t.jsx)(ot,{path:"apps/advanced/profiles/new",element:(0,t.jsx)(Kae,{mode:"new"})}),(0,t.jsx)(ot,{path:"apps/advanced/profiles/:profileId/edit",element:(0,t.jsx)(Kae,{mode:"edit"})}),(0,t.jsx)(ot,{path:"apps/advanced/profiles/:profileId",element:(0,t.jsx)(sDt,{})}),(0,t.jsx)(ot,{path:"apps/advanced/audit",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/advanced/run-your-own",element:(0,t.jsx)(wn,{to:"/apps",replace:!0})}),(0,t.jsx)(ot,{path:"apps/advanced/:tab",element:(0,t.jsx)(Fae,{})}),(0,t.jsx)(ot,{path:"apps/app/:applicationId",element:(0,t.jsx)(eie,{})}),(0,t.jsx)(ot,{path:"apps/app/:applicationId/:tab",element:(0,t.jsx)(eie,{})}),(0,t.jsx)(ot,{path:"apps/:connectionId",element:(0,t.jsx)(wn,{to:"permissions",replace:!0})}),(0,t.jsx)(ot,{path:"apps/:connectionId/:tab",element:(0,t.jsx)(SLt,{})}),(0,t.jsx)(ot,{path:"company/settings/instance",element:(0,t.jsx)(wn,{to:"/company/settings",replace:!0})}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"instance.profile"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/profile",element:(0,t.jsx)(Kzt,{})})}),(0,t.jsx)(ot,{path:"company/settings/instance/general",element:(0,t.jsx)(wn,{to:"/company/settings",replace:!0})}),(0,t.jsx)(ot,{path:"company/settings/instance/heartbeats",element:(0,t.jsx)(wn,{to:"/company/settings",replace:!0})}),(0,t.jsxs)(ot,{element:(0,t.jsx)(ch,{pageKey:"instance.environments"}),children:[(0,t.jsx)(ot,{path:"company/settings/instance/environments",element:(0,t.jsx)(l$,{})}),(0,t.jsx)(ot,{path:"company/settings/instance/environments/new",element:(0,t.jsx)(l$,{mode:"create"})}),(0,t.jsx)(ot,{path:"company/settings/instance/environments/:environmentId/edit",element:(0,t.jsx)(l$,{mode:"edit"})})]}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"instance.access"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/access",element:(0,t.jsx)(Bzt,{})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"instance.experimental"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/experimental",element:(0,t.jsx)(Fzt,{})})}),(0,t.jsxs)(ot,{element:(0,t.jsx)(ch,{pageKey:"instance.plugins"}),children:[(0,t.jsx)(ot,{path:"company/settings/instance/plugins",element:(0,t.jsx)(Wzt,{})}),(0,t.jsx)(ot,{path:"company/settings/instance/plugins/:pluginId",element:(0,t.jsx)(Hzt,{})})]}),(0,t.jsx)(ot,{element:(0,t.jsx)(ch,{pageKey:"instance.adapters"}),children:(0,t.jsx)(ot,{path:"company/settings/instance/adapters",element:(0,t.jsx)(Moe,{})})}),(0,t.jsx)(ot,{path:"company/settings/:settingsRoutePath/*",element:(0,t.jsx)(IMt,{})}),(0,t.jsx)(ot,{path:"skills/studio",element:(0,t.jsx)(P$,{})}),(0,t.jsx)(ot,{path:"skills/studio/new",element:(0,t.jsx)(P$,{})}),(0,t.jsx)(ot,{path:"skills/studio/:skillId",element:(0,t.jsx)(P$,{})}),(0,t.jsx)(ot,{path:"skills/:skillId/studio",element:(0,t.jsx)(d1e,{})}),(0,t.jsx)(ot,{path:"skills/*",element:e?(0,t.jsx)(COt,{}):(0,t.jsx)(fg,{children:(0,t.jsx)(TUt,{})})}),(0,t.jsx)(ot,{path:"settings",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"settings/*",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"plugins/:pluginId",element:(0,t.jsx)(Doe,{})}),(0,t.jsx)(ot,{path:"org",element:e?(0,t.jsx)(wn,{to:"/agents/all",replace:!0}):(0,t.jsx)(fg,{children:(0,t.jsx)(MUt,{})})}),(0,t.jsx)(ot,{path:"agents",element:(0,t.jsx)(wn,{to:"/agents/all",replace:!0})}),S8.map(s=>(0,t.jsx)(ot,{path:`agents/${s}`,element:e?(0,t.jsx)(Cft,{}):(0,t.jsx)(fg,{children:(0,t.jsx)(AUt,{})})},s)),(0,t.jsx)(ot,{path:"agents/new",element:(0,t.jsx)(uUt,{})}),(0,t.jsx)(ot,{path:"agents/:agentId",element:(0,t.jsx)(QD,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/:tab",element:(0,t.jsx)(QD,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/runs/:runId",element:(0,t.jsx)(QD,{})}),(0,t.jsx)(ot,{path:"projects",element:(0,t.jsx)(O0t,{})}),(0,t.jsx)(ot,{path:"projects/:projectId",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/overview",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues/:filter",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{element:(0,t.jsx)(X4,{}),children:(0,t.jsx)(ot,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,t.jsx)(Pvt,{})})}),(0,t.jsx)(ot,{path:"projects/:projectId/workspaces",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/configuration",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/budget",element:(0,t.jsx)(L0,{})}),(0,t.jsx)(ot,{element:(0,t.jsx)(X4,{}),children:(0,t.jsx)(ot,{path:"workspaces",element:(0,t.jsx)(Lvt,{})})}),(0,t.jsx)(ot,{path:"issues",element:(0,t.jsx)(Kvt,{})}),(0,t.jsx)(ot,{path:"tasks",element:(0,t.jsx)(wn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"search",element:(0,t.jsx)(xyt,{})}),(0,t.jsx)(ot,{path:"issues/all",element:(0,t.jsx)(wn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/active",element:(0,t.jsx)(wn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/backlog",element:(0,t.jsx)(wn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/done",element:(0,t.jsx)(wn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"issues/recent",element:(0,t.jsx)(wn,{to:"/issues",replace:!0})}),(0,t.jsx)(ot,{path:"chats/:agentRef",element:(0,t.jsx)(Lkt,{})}),(0,t.jsx)(ot,{path:"issues/:issueId",element:(0,t.jsx)(Mkt,{})}),null,(0,t.jsx)(ot,{path:"routines",element:e?(0,t.jsx)(fSt,{}):(0,t.jsx)(fg,{children:(0,t.jsx)(RUt,{})})}),(0,t.jsx)(ot,{path:"cases",element:(0,t.jsx)(aX,{children:(0,t.jsx)(ktt,{})})}),(0,t.jsx)(ot,{path:"cases/:caseIdentifier",element:(0,t.jsx)(aX,{children:(0,t.jsx)(Hnt,{})})}),(0,t.jsx)(ot,{path:"status",element:(0,t.jsx)(iX,{children:(0,t.jsx)(xne,{})})}),(0,t.jsx)(ot,{path:"status/:cardId",element:(0,t.jsx)(iX,{children:(0,t.jsx)(xne,{})})}),(0,t.jsx)(ot,{path:"status-cards",element:(0,t.jsx)(Yoe,{})}),(0,t.jsx)(ot,{path:"status-cards/:cardId",element:(0,t.jsx)(Yoe,{})}),(0,t.jsx)(ot,{path:"review-queue",element:(0,t.jsx)(rg,{children:(0,t.jsx)(P1t,{})})}),(0,t.jsx)(ot,{path:"learnings",element:(0,t.jsx)(rg,{children:(0,t.jsx)(D1t,{})})}),(0,t.jsx)(ot,{path:"pipelines",element:(0,t.jsx)(rg,{children:(0,t.jsx)(AL,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId",element:(0,t.jsx)(rg,{children:(0,t.jsx)(AL,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/add",element:(0,t.jsx)(rg,{children:(0,t.jsx)(AL,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/settings",element:(0,t.jsx)(rg,{children:(0,t.jsx)(I_t,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/items/:caseId",element:(0,t.jsx)(rg,{children:(0,t.jsx)(ZCt,{})})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,t.jsx)(rg,{children:(0,t.jsx)(YCt,{})})}),(0,t.jsx)(ot,{path:"routines/:routineId",element:e?(0,t.jsx)(Rne,{}):(0,t.jsx)(fg,{children:(0,t.jsx)(Woe,{})})}),(0,t.jsx)(ot,{path:"routines/:routineId/:section",element:e?(0,t.jsx)(Rne,{}):(0,t.jsx)(fg,{children:(0,t.jsx)(Woe,{})})}),(0,t.jsx)(ot,{element:(0,t.jsx)(X4,{}),children:(0,t.jsxs)(ot,{element:(0,t.jsx)(itt,{}),children:[(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId",element:(0,t.jsx)(My,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/services",element:(0,t.jsx)(My,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/configuration",element:(0,t.jsx)(My,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,t.jsx)(My,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/issues",element:(0,t.jsx)(My,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/routines",element:(0,t.jsx)(My,{})})]})}),(0,t.jsx)(ot,{path:"goals",element:(0,t.jsx)(WAt,{})}),(0,t.jsx)(ot,{path:"goals/:goalId",element:(0,t.jsx)(i2t,{})}),(0,t.jsx)(ot,{path:"artifacts",element:(0,t.jsx)(Mne,{})}),(0,t.jsx)(ot,{path:"approvals",element:(0,t.jsx)(wn,{to:"/approvals/pending",replace:!0})}),(0,t.jsx)(ot,{path:"approvals/pending",element:(0,t.jsx)(Lne,{})}),(0,t.jsx)(ot,{path:"approvals/all",element:(0,t.jsx)(Lne,{})}),(0,t.jsx)(ot,{path:"approvals/:approvalId",element:(0,t.jsx)(o2t,{})}),(0,t.jsx)(ot,{path:"activity",element:e?(0,t.jsx)(Q2t,{}):(0,t.jsx)(fg,{children:(0,t.jsx)(EUt,{})})}),e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{path:"activity/runs",element:(0,t.jsx)(Vk,{section:"runs"})}),(0,t.jsx)(ot,{path:"activity/costs",element:(0,t.jsx)(Vk,{section:"costs"})}),(0,t.jsx)(ot,{path:"activity/budgets",element:(0,t.jsx)(Vk,{section:"budgets"})}),(0,t.jsx)(ot,{path:"activity/timeline",element:(0,t.jsx)(Vk,{section:"timeline"})}),(0,t.jsx)(ot,{path:"audit",element:(0,t.jsx)(yp,{to:"/activity",forceAgentMode:!0})}),(0,t.jsx)(ot,{path:"audit/activity",element:(0,t.jsx)(yp,{to:"/activity"})}),(0,t.jsx)(ot,{path:"audit/runs",element:(0,t.jsx)(yp,{to:"/activity/runs"})}),(0,t.jsx)(ot,{path:"audit/costs",element:(0,t.jsx)(yp,{to:"/activity/costs"})}),(0,t.jsx)(ot,{path:"audit/budgets",element:(0,t.jsx)(yp,{to:"/activity/budgets"})}),(0,t.jsx)(ot,{path:"audit/timeline",element:(0,t.jsx)(yp,{to:"/activity/timeline"})}),(0,t.jsx)(ot,{path:"runs",element:(0,t.jsx)(yp,{to:"/activity/runs"})}),(0,t.jsx)(ot,{path:"costs",element:(0,t.jsx)(yp,{to:"/activity/costs"})}),(0,t.jsx)(ot,{path:"budgets",element:(0,t.jsx)(yp,{to:"/activity/budgets"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{path:"costs",element:(0,t.jsx)(fg,{children:(0,t.jsx)(PUt,{})})}),(0,t.jsx)(ot,{path:"audit",element:(0,t.jsx)(wn,{to:"/activity?mode=agents",replace:!0})})]}),(0,t.jsxs)(ot,{element:(0,t.jsx)(KJe,{}),children:[(0,t.jsx)(ot,{path:"board-chat",element:(0,t.jsx)(t3t,{})}),(0,t.jsx)(ot,{path:"artifacts",element:(0,t.jsx)(Mne,{})})]}),null,(0,t.jsx)(ot,{path:"decisions",element:(0,t.jsx)(CTt,{})}),(0,t.jsx)(ot,{path:"decisions/queues/:key",element:(0,t.jsx)(RTt,{})}),(0,t.jsx)(ot,{path:"inbox",element:(0,t.jsx)(LUt,{})}),(0,t.jsx)(ot,{path:"inbox/mine",element:(0,t.jsx)(pk,{})}),(0,t.jsx)(ot,{path:"inbox/recent",element:(0,t.jsx)(pk,{})}),(0,t.jsx)(ot,{path:"inbox/unread",element:(0,t.jsx)(pk,{})}),(0,t.jsx)(ot,{path:"inbox/blocked",element:(0,t.jsx)(pk,{})}),(0,t.jsx)(ot,{path:"inbox/all",element:(0,t.jsx)(pk,{})}),(0,t.jsx)(ot,{path:"inbox/requests",element:(0,t.jsx)(_Ut,{})}),(0,t.jsx)(ot,{path:"inbox/new",element:(0,t.jsx)(wn,{to:"/inbox/mine",replace:!0})}),(0,t.jsx)(ot,{path:"u/:userSlug",element:(0,t.jsx)(yAt,{})}),(0,t.jsx)(ot,{path:"design-guide",element:(0,t.jsx)(Lzt,{})}),(0,t.jsx)(ot,{path:"instance/settings/adapters",element:(0,t.jsx)(Moe,{})}),(0,t.jsx)(ot,{path:":pluginRoutePath/*",element:(0,t.jsx)(Doe,{})}),(0,t.jsx)(ot,{path:"*",element:(0,t.jsx)(xu,{scope:"board"})})]})}r(DUt,"boardRoutes");function Hoe({credentialSource:e="paperclip_vault"}={}){const s=ea(),n=new URLSearchParams(s.search),{enabled:a}=Lx();return pGe(n,{chatConnectorsEnabled:a})?(0,t.jsx)(FSe,{credentialSource:e}):(0,t.jsx)(wn,{to:"/apps",replace:!0})}r(Hoe,"AppsConnectEntryRoute");function LUt(){return(0,t.jsx)(wn,{to:`/inbox/${qAe()}`,replace:!0})}r(LUt,"InboxRootRedirect");function d1e(){const e=ea(),{companies:s,selectedCompany:n,loading:a}=xs(),{companyPrefix:i,skillId:o}=ka();if(a)return null;const l=(i?s.find(c=>c.issuePrefix.toUpperCase()===i.toUpperCase()):null)??n??s[0]??null;return!l||!o?(0,t.jsx)(wn,{to:"/skills/studio",replace:!0}):(0,t.jsx)(wn,{to:`/${l.issuePrefix}/skills/studio/${encodeURIComponent(o)}${e.search}${e.hash}`,replace:!0})}r(d1e,"LegacySkillStudioRedirect");function db(){const e=ea(),{companies:s,selectedCompany:n,loading:a}=xs(),{companyPrefix:i}=ka(),{hidden:o}=Zm();if(a)return(0,t.jsx)(Jm,{});const l=(i?s.find(d=>d.issuePrefix.toUpperCase()===i.toUpperCase()):null)??n??s[0]??null;if(!l)return pK({pathname:e.pathname,hasCompanies:!1})?(0,t.jsx)(wn,{to:"/onboarding",replace:!0}):(0,t.jsx)(J7,{});const c=ZDe(bue(`${e.pathname}${e.search}${e.hash}`),o);return(0,t.jsx)(wn,{to:`/${l.issuePrefix}${c}`,replace:!0})}r(db,"LegacySettingsRedirect");function Qoe(){const{tab:e}=ka();return(0,t.jsx)(wn,{to:u1e(e),replace:!0})}r(Qoe,"LegacyToolsSettingsRedirect");function Goe(){const{tab:e}=ka();return(0,t.jsx)(wn,{to:u1e(e),replace:!0})}r(Goe,"LegacyToolsRedirect");function u1e(e){return e?e==="applications"||e==="connections"||e==="overview"||e==="examples"||e==="runtime"||e==="audit"?"/apps":e==="policies"?"/apps/advanced/profiles":`/apps/advanced/${e}`:"/apps/advanced/profiles"}r(u1e,"legacyToolsRedirectTarget");function m1e(){const{companies:e}=xs(),{openOnboarding:s}=$o(),{t:n}=Wde(),a=Qc(),i=R5(a?.cloudBaseUrl??null),{onboardingOpen:o,onboardingRouteDismissed:l}=h5(),{companyPrefix:c}=ka(),d=c?e.find(p=>p.issuePrefix.toUpperCase()===c.toUpperCase())??null:null;if(bYe({onboardingOpen:o,routeDismissed:l}))return null;const m=d?`Add another agent to ${d.name}`:e.length>0?"Create another organization":"Create your first organization",h=d?"Run onboarding again to add an agent and a starter task for this organization.":e.length>0?"Run onboarding again to create another organization and seed its first agent.":"Get started by creating an organization and your first agent.";return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-card p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:m}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:h}),(0,t.jsx)("div",{className:"mt-4",children:!d&&a&&!i?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("app.cloudCreateUnavailable",{defaultValue:"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio."})}):(0,t.jsx)(F,{onClick:r(()=>d?s({initialStep:PT(),companyId:d.id}):a&&i?Nc(i):s(),"onClick"),children:d?"Add Agent":"Start Onboarding"})})]})})}r(m1e,"OnboardingRoutePage");function $Ut(){const{companies:e,selectedCompany:s,loading:n}=xs(),a=ea();if(n)return(0,t.jsx)(Jm,{});const i=s??e[0]??null;return i?(0,t.jsx)(wn,{to:`/${i.issuePrefix}/dashboard`,replace:!0}):pK({pathname:a.pathname,hasCompanies:!1})?(0,t.jsx)(wn,{to:"/onboarding",replace:!0}):(0,t.jsx)(J7,{})}r($Ut,"CompanyRootRedirect");function Yoe(){const{cardId:e}=ka(),s=YIe(),n=s?`/${s}`:"";return(0,t.jsx)(wn,{to:`${n}/status${e?`/${e}`:""}`,replace:!0})}r(Yoe,"StatusCardsLegacyRedirect");function yp({to:e,forceAgentMode:s=!1}){const n=ea(),a=new URLSearchParams(n.search);s&&a.set("mode","agents");const i=a.toString();return(0,t.jsx)(wn,{to:`${e}${i?`?${i}`:""}${n.hash}`,replace:!0})}r(yp,"AuditCompatibilityRedirect");function va(){const e=ea(),{companies:s,selectedCompany:n,loading:a}=xs();if(a)return(0,t.jsx)(Jm,{});const i=n??s[0]??null;return i?(0,t.jsx)(wn,{to:`/${i.issuePrefix}${e.pathname}${e.search}${e.hash}`,replace:!0}):pK({pathname:e.pathname,hasCompanies:!1})?(0,t.jsx)(wn,{to:"/onboarding",replace:!0}):(0,t.jsx)(J7,{})}r(va,"UnprefixedBoardRedirect");function J7(){const{openOnboarding:e}=$o(),{t:s}=Wde(),n=Qc(),a=R5(n?.cloudBaseUrl??null);return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-card p-6",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold",children:s("app.noCompanies.title",{defaultValue:"Create your first organization"})}),(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:s("app.noCompanies.description",{defaultValue:"Get started by creating an organization."})}),(0,t.jsx)("div",{className:"mt-4",children:n&&!a?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("app.cloudCreateUnavailable",{defaultValue:"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio."})}):(0,t.jsx)(F,{onClick:r(()=>n&&a?Nc(a):e(),"onClick"),children:s("app.noCompanies.newCompany",{defaultValue:"New Organization"})})})]})})}r(J7,"NoCompaniesStartPage");function OUt(){const{enabled:e,loaded:s}=kc();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(ZIe,{children:[(0,t.jsx)(ot,{path:"oauth-handoff",element:(0,t.jsx)(ULt,{})}),(0,t.jsx)(ot,{path:"auth",element:(0,t.jsx)(gUt,{})}),(0,t.jsx)(ot,{path:"board-claim/:token",element:(0,t.jsx)(bUt,{})}),(0,t.jsx)(ot,{path:"cli-auth/:id",element:(0,t.jsx)(vUt,{})}),(0,t.jsx)(ot,{path:"invite/:token",element:(0,t.jsx)(CUt,{})}),(0,t.jsx)(ot,{element:s?(0,t.jsx)(XX,{allowMembershipRequest:!0}):(0,t.jsx)(Jm,{}),children:(0,t.jsx)(ot,{path:"chat-identity/confirm",element:(0,t.jsx)(fLt,{})})}),(0,t.jsx)(ot,{path:"tests/perf/long-thread",element:(0,t.jsx)(Hkt,{})}),(0,t.jsx)(ot,{path:"ux-lab/bootstrap-setup",element:(0,t.jsx)(kMt,{})}),(0,t.jsx)(ot,{path:"ux-lab/responsible-user-denial",element:(0,t.jsx)(SMt,{})}),(0,t.jsx)(ot,{path:"ux-lab/cross-issue-collaboration",element:(0,t.jsx)(_Mt,{})}),(0,t.jsxs)(ot,{element:s?(0,t.jsx)(XX,{}):(0,t.jsx)(Jm,{}),children:[(0,t.jsx)(ot,{index:!0,element:(0,t.jsx)($Ut,{})}),(0,t.jsx)(ot,{path:"onboarding",element:(0,t.jsx)(m1e,{})}),(0,t.jsx)(ot,{path:"instance",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"instance/settings",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"instance/settings/*",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"companies",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"issues",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"tasks",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"issues/:issueId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"routines",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"routines/:routineId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"review-queue",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"learnings",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"cases",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"cases/:caseIdentifier",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"status",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"status/:cardId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"status-cards",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"status-cards/:cardId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"pipelines",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/add",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/settings",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/items/:caseId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"artifacts",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"audit",element:(0,t.jsx)(va,{})}),e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ot,{path:"audit/*",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"activity",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"activity/*",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"runs",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"costs",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"budgets",element:(0,t.jsx)(va,{})})]}):null,(0,t.jsx)(ot,{path:"decisions",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"u/:userSlug",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"skills/studio",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"skills/studio/new",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"skills/studio/:skillId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"skills/:skillId/studio",element:(0,t.jsx)(d1e,{})}),(0,t.jsx)(ot,{path:"skills/*",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"settings",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"settings/*",element:(0,t.jsx)(db,{})}),(0,t.jsx)(ot,{path:"agents",element:(0,t.jsx)(va,{})}),S8.map(n=>(0,t.jsx)(ot,{path:`agents/${n}`,element:(0,t.jsx)(va,{})},n)),(0,t.jsx)(ot,{path:"agents/new",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"agents/:agentId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/:tab",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"agents/:agentId/runs/:runId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/overview",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/issues/:filter",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/workspaces",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"projects/:projectId/configuration",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"workspaces",element:(0,t.jsx)(va,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId",element:(0,t.jsx)(by,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/services",element:(0,t.jsx)(by,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/configuration",element:(0,t.jsx)(by,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,t.jsx)(by,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/issues",element:(0,t.jsx)(by,{})}),(0,t.jsx)(ot,{path:"execution-workspaces/:workspaceId/routines",element:(0,t.jsx)(by,{})}),(0,t.jsx)(ot,{path:":companyPrefix",element:e?(0,t.jsx)(oJe,{}):(0,t.jsx)(qJe,{}),children:DUt(e)}),(0,t.jsx)(ot,{path:"*",element:(0,t.jsx)(xu,{scope:"global"})})]})]}),(0,t.jsx)(wrt,{})]})}r(OUt,"App");var FUt=class extends u.Component{static{r(this,"AppErrorBoundary")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,s){Bxe(e,{boundary:"app",componentStack:s.componentStack})}render(){const{error:e}=this.state;return e?(0,t.jsxs)("div",{className:"mx-auto flex min-h-screen max-w-2xl flex-col justify-center space-y-4 px-4 py-10",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-lg font-semibold",children:"Paperclip hit an error"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Something went wrong while running the app. Reloading usually fixes this."})]}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive whitespace-pre-wrap",children:e.message}),(0,t.jsx)("div",{children:(0,t.jsx)("button",{type:"button",className:"inline-flex items-center rounded-md border border-input bg-background px-3 py-1.5 text-sm font-medium shadow-sm hover:bg-accent hover:text-accent-foreground",onClick:r(()=>window.location.reload(),"onClick"),children:"Reload page"})})]}):this.props.children}};function BUt(){const{data:e}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),retry:!1}),s=e?.sentryDsn,n=e?.sentryEnvironment??void 0;return(0,u.useEffect)(()=>{if(s)return MYe(s,n),()=>{DYe()}},[s,n]),null}r(BUt,"SentryGate");function qUt(e){return{id:e.key,title:e.title,status:e.status,projectId:e.projectId??null,assigneeAgentId:e.assigneeAgentId??null,lastRun:e.lastRunAt||e.lastRunStatus?{triggeredAt:e.lastRunAt??null,status:e.lastRunStatus??null}:null}}r(qUt,"managedRoutineToRow");function zUt({routines:e,agents:s=[],projects:n=[],pluginDisplayName:a=null,emptyMessage:i="No managed routines.",runningRoutineKey:o=null,statusMutationRoutineKey:l=null,reconcilingRoutineKey:c=null,resettingRoutineKey:d=null,onRunNow:m,onToggleEnabled:h,onReconcile:p,onReset:f}){const g=new Map(s.map(y=>[y.id,y])),v=new Map(n.map(y=>[y.id,{name:y.name,color:y.color}]));return e.length===0?(0,t.jsx)("div",{className:"rounded-lg border border-border px-3 py-8 text-center text-sm text-muted-foreground",children:i}):(0,t.jsx)("div",{className:"rounded-lg border border-border",children:e.map(y=>{const w=qUt(y),S=y.href??(y.routineId?`/routines/${y.routineId}`:"/routines"),j=y.missingRefs??[],N=!!(y.routineId&&y.resourceKey&&j.length===0),_=y.managedByPluginDisplayName??a,A=!!(p||f);return(0,t.jsxs)("div",{className:"last:[&_a]:border-b-0",children:[(0,t.jsx)(Gwe,{routine:w,projectById:v,agentById:g,runningRoutineId:o,statusMutationRoutineId:l,href:S,configureLabel:"Configure",managedByLabel:_?`Managed by ${_}`:null,runNowButton:!0,hideArchiveAction:!0,disableRunNow:!N,disableToggle:!N,secondaryDetails:(0,t.jsxs)("span",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[y.resourceKey?(0,t.jsx)("span",{children:y.resourceKey}):null,y.cronExpression?(0,t.jsxs)("span",{children:["Schedule ",y.cronExpression]}):null]}),onRunNow:r(()=>m?.(y),"onRunNow"),onToggleEnabled:r(()=>h?.(y,w.status==="active"),"onToggleEnabled")}),A?(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 pb-3 text-xs text-muted-foreground last:border-b-0",onClick:r(C=>{C.preventDefault(),C.stopPropagation()},"onClick"),children:[(0,t.jsx)("span",{children:j.length?`Missing ${j.map(C=>`${C.resourceKind}:${C.resourceKey}`).join(", ")}`:"Routine defaults can be repaired."}),(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[p?(0,t.jsx)(F,{size:"sm",variant:"ghost",disabled:c===y.key,onClick:r(()=>p(y),"onClick"),children:c===y.key?"Reconciling...":"Reconcile"}):null,f?(0,t.jsx)(F,{size:"sm",variant:"ghost",disabled:d===y.key,onClick:r(()=>f(y),"onClick"),children:d===y.key?"Resetting...":"Reset"}):null]})]}):null]},y.key)})})}r(zUt,"ManagedRoutinesList");function Joe(e){return new Set(e??[])}r(Joe,"toPathSet");function UUt({expandedPaths:e,checkedPaths:s,selectedFile:n=null,showCheckboxes:a=!1,onToggleDir:i,onSelectFile:o,...l}){return(0,u.createElement)(V1,{...l,selectedFile:n,expandedDirs:Joe(e),checkedFiles:s?Joe(s):void 0,showCheckboxes:a,onToggleDir:i??(()=>{}),onSelectFile:o??(()=>{})})}r(UUt,"PluginSdkFileTree");function KUt(e){const[s,n]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let a=!1;return vc(()=>import("./MarkdownEditor-DfrwLv1M.js").then(i=>i.n).then(i=>{a||n(()=>i.MarkdownEditor)}),__vite__mapDeps([36,5,7,9,14,10,15,37,29,27,38])),()=>{a=!0}},[]),s?(0,u.createElement)(s,e):(0,u.createElement)("textarea",{className:e.className,value:e.value,placeholder:e.placeholder,readOnly:e.readOnly,onBlur:e.onBlur,onChange:r(a=>e.onChange(a.currentTarget.value),"onChange")})}r(KUt,"PluginSdkMarkdownEditor");function VUt(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!=null&&s!==""&&s!==!1))}r(VUt,"compactIssueFilters");function WUt({companyId:e,projectId:s=null,filters:n,viewStateKey:a="paperclip:plugin-issues-view",initialSearch:i,createIssueLabel:o,searchWithinLoadedIssues:l=!0}){const c=Kt(),d=(0,u.useMemo)(()=>VUt({...n??{},projectId:n?.projectId??s??void 0}),[n,s]),m=d.originKindPrefix??null,h=d.projectId??s??null,p=(0,u.useMemo)(()=>["plugins","sdk-ui","issues-list",e??"__no-company__",d],[e,d]),{data:f}=ee({queryKey:P.agents.list(e??"__no-company__"),queryFn:r(()=>zt.list(e),"queryFn"),enabled:!!e}),{data:g}=ee({queryKey:P.projects.list(e??"__no-company__",{includeArchived:!0}),queryFn:r(()=>ia.list(e,{includeArchived:!0}),"queryFn"),enabled:!!e}),v=P.liveRuns(e??"__no-company__"),y=mo({companyId:e,resourceKey:"live-runs",queryKey:v,enabled:!!e,refetchInterval:!1,leaderOnly:!0}),{data:w,dataUpdatedAt:S}=ee({queryKey:v,queryFn:r(()=>Zr.liveRunsForCompany(e),"queryFn"),enabled:y.enabled,refetchInterval:y.refetchInterval});ho(y,w,S);const{data:j,isLoading:N,error:_}=ee({queryKey:p,queryFn:r(()=>Rt.list(e,d),"queryFn"),enabled:!!e}),A=(0,u.useMemo)(()=>Rx(w,j),[j,w]),C=ke({mutationFn:r(({id:I,data:T})=>Rt.update(I,T),"mutationFn"),onSuccess:r(()=>{e&&(c.invalidateQueries({queryKey:["plugins","sdk-ui","issues-list",e]}),c.invalidateQueries({queryKey:P.issues.list(e)}),h&&(c.invalidateQueries({queryKey:P.issues.listByProject(e,h)}),m&&c.invalidateQueries({queryKey:P.issues.listPluginOperationsByProject(e,h,m)})))},"onSuccess")});return e?(0,u.createElement)(bx,{issues:j??[],isLoading:N,error:_,agents:f,projects:g,liveIssueIds:A,projectId:h??void 0,viewStateKey:a,initialSearch:i,createIssueLabel:o,searchWithinLoadedIssues:l,onUpdateIssue:r((I,T)=>C.mutate({id:I,data:T}),"onUpdateIssue")}):(0,u.createElement)("div",{className:"text-sm text-muted-foreground"},"Select an organization to view tasks.")}r(WUt,"PluginSdkIssuesList");function HUt({companyId:e,value:s,onChange:n,placeholder:a="Responsible",noneLabel:i="No responsible",searchPlaceholder:o="Search responsible...",emptyMessage:l="No responsible found.",includeUsers:c=!0,includeTerminatedAgents:d=!1,className:m,onConfirm:h}){const p=Kz(),f=e??p.companyId??null,{data:g}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn"),enabled:c}),v=g?.user?.id??g?.session?.userId??null,{data:y}=ee({queryKey:P.agents.list(f??"__no-company__"),queryFn:r(()=>zt.list(f),"queryFn"),enabled:!!f}),{data:w}=ee({queryKey:P.access.companyUserDirectory(f??"__no-company__"),queryFn:r(()=>ur.listUserDirectory(f),"queryFn"),enabled:!!f&&c}),S=(0,u.useMemo)(()=>wAe(),[]),j=(0,u.useMemo)(()=>S.map(I=>I.startsWith("agent:")?I.slice(6):null).filter(I=>!!I),[S]),N=(0,u.useMemo)(()=>Kg((y??[]).filter(I=>d||I.status!=="terminated"),j),[y,d,j]),_=(0,u.useMemo)(()=>[...c?dce(v):[],...c?Vw(w?.users,{excludeUserIds:[v]}):[],...N.map(I=>({id:Pm({assigneeAgentId:I.id}),label:I.name,searchText:`${I.name} ${I.role} ${I.title??""}`}))],[w?.users,v,c,N]),A=Lc(s),C=A.assigneeAgentId?N.find(I=>I.id===A.assigneeAgentId):null;return(0,u.createElement)(Bl,{value:s,options:_,recentOptionIds:S,placeholder:a,noneLabel:i,searchPlaceholder:o,emptyMessage:l,className:m,onConfirm:h,onChange:r(I=>{const T=Lc(I);T.assigneeAgentId&&e1(T.assigneeAgentId),T.assigneeUserId&&Kle(T.assigneeUserId),n(I,T)},"onChange"),renderTriggerValue:r(I=>I?C?(0,u.createElement)(Q3,null,(0,u.createElement)(nw,{icon:C.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,u.createElement)("span",{className:"truncate"},I.label)):(0,u.createElement)("span",{className:"truncate"},I.label):(0,u.createElement)("span",{className:"text-muted-foreground"},a),"renderTriggerValue"),renderOption:r(I=>{if(!I.id)return(0,u.createElement)("span",{className:"truncate"},I.label);const T=Lc(I.id),R=T.assigneeAgentId?N.find(L=>L.id===T.assigneeAgentId):null;return(0,u.createElement)(Q3,null,R?(0,u.createElement)(nw,{icon:R.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,u.createElement)(bc,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,u.createElement)("span",{className:"truncate"},I.label))},"renderOption")})}r(HUt,"PluginSdkAssigneePicker");function QUt({companyId:e,value:s,onChange:n,placeholder:a="Project",noneLabel:i="No project",searchPlaceholder:o="Search projects...",emptyMessage:l="No projects found.",includeArchived:c=!1,className:d,onConfirm:m}){const h=Kz(),p=e??h.companyId??null,{data:f}=ee({queryKey:P.auth.session,queryFn:r(()=>Fa.getSession(),"queryFn")}),g=f?.user?.id??f?.session?.userId??null,{data:v}=ee({queryKey:P.projects.list(p??"__no-company__",{includeArchived:c}),queryFn:r(()=>ia.list(p,{includeArchived:c}),"queryFn"),enabled:!!p}),y=(0,u.useMemo)(()=>(v??[]).filter(_=>c||!_.archivedAt),[c,v]),{orderedProjects:w}=Nv({projects:y,companyId:p,userId:g}),S=(0,u.useMemo)(()=>Bw(),[]),j=(0,u.useMemo)(()=>w.map(_=>({id:_.id,label:_.name,searchText:_.description??""})),[w]),N=w.find(_=>_.id===s)??null;return(0,u.createElement)(Bl,{value:s,options:j,recentOptionIds:S,placeholder:a,noneLabel:i,searchPlaceholder:o,emptyMessage:l,className:d,onConfirm:m,onChange:r(_=>{_&&$w(_),n(_)},"onChange"),renderTriggerValue:r(_=>!_||!N?(0,u.createElement)("span",{className:"text-muted-foreground"},a):(0,u.createElement)(Q3,null,(0,u.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:N.color??"#6366f1"}}),(0,u.createElement)("span",{className:"truncate"},_.label)),"renderTriggerValue"),renderOption:r(_=>{if(!_.id)return(0,u.createElement)("span",{className:"truncate"},_.label);const A=w.find(C=>C.id===_.id);return(0,u.createElement)(Q3,null,(0,u.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:A?.color??"#6366f1"}}),(0,u.createElement)("span",{className:"truncate"},_.label))},"renderOption")})}r(QUt,"PluginSdkProjectPicker");function Q3({children:e}){return(0,u.createElement)("span",{className:"contents"},e)}r(Q3,"FragmentSafe");function GUt({label:e,status:s}){const n={ok:"border-emerald-300 bg-emerald-50 text-emerald-700",warning:"border-amber-300 bg-amber-50 text-amber-800",error:"border-red-300 bg-red-50 text-red-700",info:"border-slate-300 bg-slate-50 text-slate-700",pending:"border-slate-300 bg-slate-50 text-slate-600"}[s];return(0,u.createElement)("span",{className:`inline-flex w-fit items-center rounded-full border px-2 py-0.5 text-xs font-medium ${n}`},e)}r(GUt,"PluginSdkStatusBadge");function YUt({columns:e,rows:s,loading:n,emptyMessage:a="No rows."}){if(n)return(0,u.createElement)("div",{className:"text-sm text-muted-foreground"},"Loading...");if(!s.length)return(0,u.createElement)("div",{className:"text-sm text-muted-foreground"},a);const i=e.map(o=>o.width??"minmax(0, 1fr)").join(" ");return(0,u.createElement)("div",{className:"overflow-hidden rounded-md border"},(0,u.createElement)("div",{className:"hidden border-b bg-muted/35 px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground md:grid md:[grid-template-columns:var(--plugin-grid-cols)]",style:{"--plugin-grid-cols":i}},e.map(o=>(0,u.createElement)("div",{key:o.key},o.header))),(0,u.createElement)("div",{className:"divide-y"},s.map((o,l)=>(0,u.createElement)("div",{key:String(o.id??l),className:"grid gap-2 px-3 py-3 md:items-center md:[grid-template-columns:var(--plugin-grid-cols)]",style:{"--plugin-grid-cols":i}},e.map(c=>(0,u.createElement)("div",{key:c.key,className:"min-w-0 text-sm"},(0,u.createElement)("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground md:hidden"},c.header),c.render?c.render(o[c.key],o):String(o[c.key]??"")))))))}r(YUt,"PluginSdkDataTable");function JUt({pairs:e}){return(0,u.createElement)("dl",{className:"grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[max-content_minmax(0,1fr)]"},e.flatMap(s=>[(0,u.createElement)("dt",{key:`${s.label}:label`,className:"text-muted-foreground"},s.label),(0,u.createElement)("dd",{key:`${s.label}:value`,className:"min-w-0"},s.value)]))}r(JUt,"PluginSdkKeyValueList");function XUt({label:e,value:s,unit:n}){return(0,u.createElement)("div",{className:"rounded-md border bg-card p-3"},(0,u.createElement)("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground"},e),(0,u.createElement)("div",{className:"mt-1 text-lg font-semibold"},`${s}${n??""}`))}r(XUt,"PluginSdkMetricCard");function ZUt({data:e}){return(0,u.createElement)("pre",{className:"max-h-80 overflow-auto rounded-md border bg-muted/30 p-2 text-xs"},JSON.stringify(e,null,2))}r(ZUt,"PluginSdkJsonTree");function eKt({label:e="Loading"}){return(0,u.createElement)("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-muted-foreground/30 border-t-foreground align-middle",role:"status","aria-label":e})}r(eKt,"PluginSdkSpinner");var tKt=class extends u.Component{static{r(this,"PluginSdkErrorBoundary")}state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??(0,u.createElement)("div",{className:"rounded-md border border-destructive/30 p-3 text-sm text-destructive"},"Plugin UI failed to render."):this.props.children}};function sKt(e,s){globalThis.__paperclipPluginBridge__={react:e,reactJsxRuntime:t,reactDom:s,sdkUi:{usePluginData:lLe,usePluginAction:cLe,useHostContext:Kz,useHostLocation:uLe,useHostNavigation:dLe,usePluginStream:hLe,usePluginToast:mLe,copyTextToClipboard:Hr,MarkdownBlock:r(({content:n,className:a,enableWikiLinks:i,wikiLinkRoot:o,resolveWikiLinkHref:l})=>(0,u.createElement)(Pn,{className:a,softBreaks:!1,enableWikiLinks:i,wikiLinkRoot:o,resolveWikiLinkHref:l,children:n}),"MarkdownBlock"),MetricCard:XUt,StatusBadge:GUt,DataTable:YUt,KeyValueList:JUt,JsonTree:ZUt,Spinner:eKt,ErrorBoundary:tKt,MarkdownEditor:KUt,FileTree:UUt,IssuesList:WUt,AssigneePicker:HUt,ProjectPicker:QUt,ManagedRoutinesList:zUt}}}r(sKt,"initPluginBridge");var nKt=1e4;function rKt(e=nKt){if(typeof performance>"u"||typeof performance.clearMeasures!="function")return()=>{};const n=setInterval(r(()=>{globalThis.__paperclipKeepPerfMeasures||performance.clearMeasures()},"reap"),e);return()=>clearInterval(n)}r(rKt,"startPerfMeasureReaper");var aKt=pv((e=>{function s(K,U){var D=K.length;K.push(U);e:for(;0<D;){var V=D-1>>>1,H=K[V];if(0<i(H,U))K[V]=U,K[D]=H,D=V;else break e}}r(s,"push");function n(K){return K.length===0?null:K[0]}r(n,"peek");function a(K){if(K.length===0)return null;var U=K[0],D=K.pop();if(D!==U){K[0]=D;e:for(var V=0,H=K.length,J=H>>>1;V<J;){var X=2*(V+1)-1,le=K[X],ce=X+1,te=K[ce];if(0>i(le,D))ce<H&&0>i(te,le)?(K[V]=te,K[ce]=D,V=ce):(K[V]=le,K[X]=D,V=X);else if(ce<H&&0>i(te,D))K[V]=te,K[ce]=D,V=ce;else break e}}return U}r(a,"pop");function i(K,U){var D=K.sortIndex-U.sortIndex;return D!==0?D:K.id-U.id}if(r(i,"compare"),e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var d=[],m=[],h=1,p=null,f=3,g=!1,v=!1,y=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function _(K){for(var U=n(m);U!==null;){if(U.callback===null)a(m);else if(U.startTime<=K)a(m),U.sortIndex=U.expirationTime,s(d,U);else break;U=n(m)}}r(_,"advanceTimers");function A(K){if(y=!1,_(K),!v)if(n(d)!==null)v=!0,C||(C=!0,$());else{var U=n(m);U!==null&&B(A,U.startTime-K)}}r(A,"handleTimeout");var C=!1,I=-1,T=5,R=-1;function L(){return w?!0:!(e.unstable_now()-R<T)}r(L,"shouldYieldToHost");function O(){if(w=!1,C){var K=e.unstable_now();R=K;var U=!0;try{e:{v=!1,y&&(y=!1,j(I),I=-1),g=!0;var D=f;try{t:{for(_(K),p=n(d);p!==null&&!(p.expirationTime>K&&L());){var V=p.callback;if(typeof V=="function"){p.callback=null,f=p.priorityLevel;var H=V(p.expirationTime<=K);if(K=e.unstable_now(),typeof H=="function"){p.callback=H,_(K),U=!0;break t}p===n(d)&&a(d),_(K)}else a(d);p=n(d)}if(p!==null)U=!0;else{var J=n(m);J!==null&&B(A,J.startTime-K),U=!1}}break e}finally{p=null,f=D,g=!1}U=void 0}}finally{U?$():C=!1}}}r(O,"performWorkUntilDeadline");var $;if(typeof N=="function")$=r(function(){N(O)},"schedulePerformWorkUntilDeadline");else if(typeof MessageChannel<"u"){var E=new MessageChannel,q=E.port2;E.port1.onmessage=O,$=r(function(){q.postMessage(null)},"schedulePerformWorkUntilDeadline")}else $=r(function(){S(O,0)},"schedulePerformWorkUntilDeadline");function B(K,U){I=S(function(){K(e.unstable_now())},U)}r(B,"requestHostTimeout"),e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_forceFrameRate=function(K){0>K||125<K||(T=0<K?Math.floor(1e3/K):5)},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(K){switch(f){case 1:case 2:case 3:var U=3;break;default:U=f}var D=f;f=U;try{return K()}finally{f=D}},e.unstable_requestPaint=function(){w=!0},e.unstable_runWithPriority=function(K,U){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var D=f;f=K;try{return U()}finally{f=D}},e.unstable_scheduleCallback=function(K,U,D){var V=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?V+D:V):D=V,K){case 1:var H=-1;break;case 2:H=250;break;case 5:H=1073741823;break;case 4:H=1e4;break;default:H=5e3}return H=D+H,K={id:h++,callback:U,priorityLevel:K,startTime:D,expirationTime:H,sortIndex:-1},D>V?(K.sortIndex=D,s(m,K),n(d)===null&&K===n(m)&&(y?(j(I),I=-1):y=!0,B(A,D-V))):(K.sortIndex=H,s(d,K),v||g||(v=!0,C||(C=!0,$()))),K},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(K){var U=f;return function(){var D=f;f=U;try{return K.apply(this,arguments)}finally{f=D}}}})),iKt=pv(((e,s)=>{s.exports=aKt()})),oKt=pv((e=>{var s=iKt(),n=G6(),a=ole();function i(x){var b="https://react.dev/errors/"+x;if(1<arguments.length){b+="?args[]="+encodeURIComponent(arguments[1]);for(var k=2;k<arguments.length;k++)b+="&args[]="+encodeURIComponent(arguments[k])}return"Minified React error #"+x+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}r(i,"formatProdErrorMessage");function o(x){return!(!x||x.nodeType!==1&&x.nodeType!==9&&x.nodeType!==11)}r(o,"isValidContainer");function l(x){var b=x,k=x;if(x.alternate)for(;b.return;)b=b.return;else{x=b;do b=x,(b.flags&4098)!==0&&(k=b.return),x=b.return;while(x)}return b.tag===3?k:null}r(l,"getNearestMountedFiber");function c(x){if(x.tag===13){var b=x.memoizedState;if(b===null&&(x=x.alternate,x!==null&&(b=x.memoizedState)),b!==null)return b.dehydrated}return null}r(c,"getSuspenseInstanceFromFiber");function d(x){if(x.tag===31){var b=x.memoizedState;if(b===null&&(x=x.alternate,x!==null&&(b=x.memoizedState)),b!==null)return b.dehydrated}return null}r(d,"getActivityInstanceFromFiber");function m(x){if(l(x)!==x)throw Error(i(188))}r(m,"assertIsMounted");function h(x){var b=x.alternate;if(!b){if(b=l(x),b===null)throw Error(i(188));return b!==x?null:x}for(var k=x,M=b;;){var W=k.return;if(W===null)break;var Q=W.alternate;if(Q===null){if(M=W.return,M!==null){k=M;continue}break}if(W.child===Q.child){for(Q=W.child;Q;){if(Q===k)return m(W),x;if(Q===M)return m(W),b;Q=Q.sibling}throw Error(i(188))}if(k.return!==M.return)k=W,M=Q;else{for(var ge=!1,De=W.child;De;){if(De===k){ge=!0,k=W,M=Q;break}if(De===M){ge=!0,M=W,k=Q;break}De=De.sibling}if(!ge){for(De=Q.child;De;){if(De===k){ge=!0,k=Q,M=W;break}if(De===M){ge=!0,M=Q,k=W;break}De=De.sibling}if(!ge)throw Error(i(189))}}if(k.alternate!==M)throw Error(i(190))}if(k.tag!==3)throw Error(i(188));return k.stateNode.current===k?x:b}r(h,"findCurrentFiberUsingSlowPath");function p(x){var b=x.tag;if(b===5||b===26||b===27||b===6)return x;for(x=x.child;x!==null;){if(b=p(x),b!==null)return b;x=x.sibling}return null}r(p,"findCurrentHostFiberImpl");var f=Object.assign,g=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),_=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),O=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function E(x){return x===null||typeof x!="object"?null:(x=$&&x[$]||x["@@iterator"],typeof x=="function"?x:null)}r(E,"getIteratorFn");var q=Symbol.for("react.client.reference");function B(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===q?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case w:return"Fragment";case j:return"Profiler";case S:return"StrictMode";case C:return"Suspense";case I:return"SuspenseList";case L:return"Activity"}if(typeof x=="object")switch(x.$$typeof){case y:return"Portal";case _:return x.displayName||"Context";case N:return(x._context.displayName||"Context")+".Consumer";case A:var b=x.render;return x=x.displayName,x||(x=b.displayName||b.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case T:return b=x.displayName||null,b!==null?b:B(x.type)||"Memo";case R:b=x._payload,x=x._init;try{return B(x(b))}catch{}}return null}r(B,"getComponentNameFromType");var K=Array.isArray,U=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V={pending:!1,data:null,method:null,action:null},H=[],J=-1;function X(x){return{current:x}}r(X,"createCursor");function le(x){0>J||(x.current=H[J],H[J]=null,J--)}r(le,"pop");function ce(x,b){J++,H[J]=x.current,x.current=b}r(ce,"push");var te=X(null),re=X(null),de=X(null),Z=X(null);function Y(x,b){switch(ce(de,b),ce(re,x),ce(te,null),b.nodeType){case 9:case 11:x=(x=b.documentElement)&&(x=x.namespaceURI)?nW(x):0;break;default:if(x=b.tagName,b=b.namespaceURI)b=nW(b),x=rW(b,x);else switch(x){case"svg":x=1;break;case"math":x=2;break;default:x=0}}le(te),ce(te,x)}r(Y,"pushHostContainer");function G(){le(te),le(re),le(de)}r(G,"popHostContainer");function fe(x){x.memoizedState!==null&&ce(Z,x);var b=te.current,k=rW(b,x.type);b!==k&&(ce(re,x),ce(te,k))}r(fe,"pushHostContext");function se(x){re.current===x&&(le(te),le(re)),Z.current===x&&(le(Z),$N._currentValue=V)}r(se,"popHostContext");var ae,ie;function ue(x){if(ae===void 0)try{throw Error()}catch(k){var b=k.stack.trim().match(/\n( *(at )?)/);ae=b&&b[1]||"",ie=-1<k.stack.indexOf(`
726
726
  at`)?" (<anonymous>)":-1<k.stack.indexOf("@")?"@unknown:0:0":""}return`
727
727
  `+ae+x+ie}r(ue,"describeBuiltInComponentFrame");var pe=!1;function be(x,b){if(!x||pe)return"";pe=!0;var k=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:r(function(){try{if(b){var Ps=r(function(){throw Error()},"Fake");if(Object.defineProperty(Ps.prototype,"props",{set:r(function(){throw Error()},"set")}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ps,[])}catch(cs){var ss=cs}Reflect.construct(x,[],Ps)}else{try{Ps.call()}catch(cs){ss=cs}x.call(Ps.prototype)}}else{try{throw Error()}catch(cs){ss=cs}(Ps=x())&&typeof Ps.catch=="function"&&Ps.catch(function(){})}}catch(cs){if(cs&&ss&&typeof cs.stack=="string")return[cs.stack,ss.stack]}return[null,null]},"DetermineComponentFrameRoot")};M.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var W=Object.getOwnPropertyDescriptor(M.DetermineComponentFrameRoot,"name");W&&W.configurable&&Object.defineProperty(M.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var Q=M.DetermineComponentFrameRoot(),ge=Q[0],De=Q[1];if(ge&&De){var vt=ge.split(`
728
728
  `),Zt=De.split(`