@tickernelz/paperclip-pro-ui 2026.1004.10 → 2026.1004.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{Agents.production-JxKz0JXx.js → Agents.production-CsT8F2HV.js} +2 -2
- package/dist/assets/{CompanyActivity.production-Dr3ODOqW.js → CompanyActivity.production-7Z8RokE5.js} +1 -1
- package/dist/assets/{CompanyExport-BPSpRY83.js → CompanyExport-D292Sl0q.js} +1 -1
- package/dist/assets/{CompanySkills.production-QuhKpjUZ.js → CompanySkills.production-DsyMs6yM.js} +1 -1
- package/dist/assets/{Costs.production-C_6rqSBB.js → Costs.production-DdMJsdPe.js} +1 -1
- package/dist/assets/{OrgChart.production-_dYTeNBw.js → OrgChart.production-DdTAZv-5.js} +1 -1
- package/dist/assets/{RoutineDetail.production-CLjPte-l.js → RoutineDetail.production-D5NesMYZ.js} +1 -1
- package/dist/assets/{Routines.production-Cqmj3iUl.js → Routines.production-CFwud8fp.js} +1 -1
- package/dist/assets/{definition-BlT4dP_G.js → definition-DjhwsOcy.js} +1 -1
- package/dist/assets/{index-DGYA11x7.js → index-SYD3887m.js} +4 -4
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +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-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/runtime-IAg0vdY9.js","assets/model-DL5biheO.js","assets/definition-DjhwsOcy.js","assets/character-CguPM7IG.js","assets/prod-COP_vZWu.js","assets/rolldown-runtime-ZpX3ckPj.js","assets/CompanyExport-D292Sl0q.js","assets/createLucideIcon-CyNmb-lh.js","assets/router-CQ6BmqLK.js","assets/preload-helper-CceJXRIF.js","assets/zap-SCVTK-ma.js","assets/agents-D_LH8E_I.js","assets/EmptyState-TrxpxKhQ.js","assets/button-BkeuJp7k.js","assets/mention-chips-CdRHxK9H.js","assets/bot-zqteqJnP.js","assets/StatusIcon-CWHgXBkX.js","assets/clipboard-B0Nf-fdu.js","assets/loader-circle-CwtPxA_n.js","assets/octagon-alert-CCpFDRSf.js","assets/MarkdownBody-7SdsVDkP.js","assets/check-B0QXikc7.js","assets/external-link-z81jazua.js","assets/rotate-ccw-nROdTOPn.js","assets/PageSkeleton-CYPsMFsM.js","assets/skeleton-DOrq5sF4.js","assets/Agents.production-CsT8F2HV.js","assets/AgentAvatar-pewOXOPY.js","assets/tabs-CiCMgccR.js","assets/dist-m1FA4izX.js","assets/heartbeats-BrsusSPB.js","assets/triangle-alert-C4ARdDYp.js","assets/SidebarContext-BJdVSZaX.js","assets/environments-W2uJFT14.js","assets/Routines.production-CFwud8fp.js","assets/RoutineRunVariablesDialog-C8pk6EH7.js","assets/MarkdownEditor-BXxDMPIh.js","assets/dist-CYA7LF0Y.js","assets/dist-DCJXgQu0.js","assets/sheet-qyj2cFrA.js","assets/checkbox-CLTjQudf.js","assets/chevron-right-BM1KeY7q.js","assets/label-ly5pQrL-.js","assets/select-Be6thkcr.js","assets/chevron-down-DbhFfBO9.js","assets/useHiddenSettings-BfdTOT6k.js","assets/health-_0py5W3M.js","assets/badge-DU1L45MA.js","assets/input-DTxvGjVe.js","assets/company-members-DCan5GtU.js","assets/AgentIdentity-D-mYc7hi.js","assets/card-BZHZYmJ0.js","assets/RoutineDetail.production-D5NesMYZ.js","assets/save-ChEUMCgI.js","assets/CompanySkills.production-DsyMs6yM.js","assets/use-adapter-capabilities-B8cJZGLq.js","assets/file-text-CMgTJP01.js","assets/CompanyActivity.production-7Z8RokE5.js","assets/Costs.production-DdMJsdPe.js","assets/OrgChart.production-DdTAZv-5.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var cTe=Object.defineProperty;var r=(e,s)=>cTe(e,"name",{value:s,configurable:!0});import{i as o3,n as dTe,t as Gv}from"./rolldown-runtime-ZpX3ckPj.js";import{$ as uTe,$r as EU,$t as mTe,A as hTe,An as pTe,At as fTe,B as Ude,Bn as xTe,Bt as gTe,C as bTe,Cn as Kde,Ct as vTe,D as la,Dn as yTe,Dt as jTe,E as vu,En as IG,Et as Wde,F as $C,Fn as l3,Ft as wTe,G as NTe,Gn as AG,Gt as TG,H as kTe,Hn as H1,Ht as Vde,I as sC,In as STe,It as CTe,J as PU,Jn as c3,Jr as d3,Jt as lT,K as _Te,Kn as AR,Kt as ITe,L as am,Ln as ATe,Lt as Hde,M as Wa,Mn as TTe,Mr as RTe,Mt as ETe,N as TR,Nn as MU,Nt as PTe,O as RG,On as MTe,Ot as LTe,P as S0,Pn as DTe,Pt as $Te,Q as OTe,Qn as FTe,Qr as Gde,Qt as BTe,R as LU,Rn as qTe,Rt as zTe,S as W,Sn as EG,St as UTe,T as Jr,Tn as Qde,Tt as KTe,U as ps,Un as Yde,Ut as WTe,Vt as VTe,Wn as Xde,Wt as HTe,X as za,Xn as G1,Xr as Ut,Xt as PG,Y as P,Yn as GTe,Yr as QTe,Yt as cT,Z as Jde,Zn as YTe,Zr as XTe,Zt as Zde,_ as tm,_n as DU,_r as Ne,_t as JTe,an as ZTe,ar as eRe,at as MG,b as LG,bn as Jp,bt as tRe,c as sRe,cn as RR,cr as DG,ct as nRe,d as rRe,dn as eue,dr as cn,dt as aRe,en as xF,er as ER,et as tue,fn as PR,fr as Te,ft as iRe,g as _c,gn as $U,gr as oRe,gt as lRe,h as Qv,hn as sue,hr as C0,ht as cRe,i as u3,in as nue,ir as dRe,it as OC,j as Rh,jn as uRe,jr as mRe,jt as hRe,k as Ui,kn as B4,kr as pRe,kt as $G,l as Q1,ln as fRe,lr as rue,lt as aue,m as NN,mn as iue,mr as MR,mt as kN,n as Ab,nn as oue,nr as xRe,nt as gRe,o as bRe,on as vRe,or as q4,ot as lue,pn as Y1,pr as yRe,pt as dT,q as m3,qn as gF,qt as rw,rn as gv,rr as cue,rt as due,s as Jb,sn as uue,sr as OU,st as jRe,t as Ht,tn as FU,tr as OG,tt as wRe,un as Zp,ur as pl,ut as BU,v as NRe,vn as kRe,vr as J,vt as SRe,w as mue,wn as CRe,wt as _Re,x as qU,xn as hue,xt as pue,y as FG,yn as fue,yr as IRe,yt as ARe,z as fr,zn as TRe,zt as xue}from"./createLucideIcon-CyNmb-lh.js";import{t as Sc}from"./preload-helper-CceJXRIF.js";import{$ as Rd,A as RRe,B as _t,C as ERe,D as PRe,E as BG,F as qG,G as zG,H as LR,I as gue,J as UG,K as MRe,L as LRe,M as bue,N as DRe,O as $Re,P as QI,Q as ORe,R as FRe,S as DR,T as vue,U as SN,V as $R,W as xl,X as d0,Y as bv,Z as go,_ as BRe,a as CN,at as yue,b as bl,ct as Ei,d as qRe,et as _0,f as vv,g as zRe,h as URe,i as KRe,it as ra,j as WRe,k as KG,l as VRe,m as jue,n as I0,nt as HRe,o as Xn,ot as h3,p as p3,q as z4,r as bn,rt as GRe,st as Ia,t as Qe,tt as it,u as zU,v as nh,w as OR,x as FR,y as QRe,z as Aj}from"./router-CQ6BmqLK.js";import{$ as UU,$n as KU,$t as FC,A as zw,An as sm,At as Mg,B as YRe,Bn as wue,Bt as aw,Cn as Nue,Ct as u0,D as XRe,Dn as kue,Dt as JRe,E as ZRe,En as Sue,Et as e5e,F as t5e,Fn as Cue,Ft as _ue,G as s5e,Gn as n5e,Gt as Iue,H as r5e,Hn as a5e,Ht as Aue,I as Tue,In as i5e,It as Uw,J as bF,Jn as X1,Jt as BR,K as o5e,Kn as Rue,Kt as Eue,L as l5e,Ln as WG,Lt as c5e,M as _N,Mn as zc,Mt as Vl,N as Yv,Nn as Pue,Nt as IN,O as Kx,On as Um,Ot as d5e,P as u5e,Pn as BC,Pt as Tc,Q as m5e,Qn as WU,Qt as Mue,R as h5e,Rn as p5e,Rt as f5e,Sn as qR,Sr as J1,St as x5e,T as g5e,Tn as Lue,Tt as Due,U as b5e,Un as AN,Ut as $ue,V as v5e,Vn as y5e,Vt as j5e,W as Oue,Wn as f3,Wt as w5e,X as VG,Xn as N5e,Xt as jx,Y as Fue,Yn as TN,Yt as Bue,Z as que,Zn as zue,Zt as iw,_ as Uue,_n as zR,_r as gf,_t as k5e,a as S5e,an as HG,ar as RN,at as C5e,b as _5e,bn as I5e,br as x3,bt as EN,c as U4,cn as Kue,cr as Yl,ct as Wue,d as UR,dn as Vue,dr as Wx,dt as Hue,en as ow,er as Gue,et as Que,f as Yue,fn as VU,fr as A5e,ft as HU,g as GG,gn as KR,gr as Xue,gt as T5e,h as R5e,hn as Jue,hr as E5e,ht as P5e,i as M5e,in as QG,ir as PN,it as Z1,j as YG,jn as vF,jt as Zue,k as eme,kn as tme,kt as lw,l as L5e,ln as D5e,lr as XG,lt as yF,m as WR,mn as VR,mr as $5e,mt as O5e,n as F5e,nn as HR,nr as B5e,nt as q5e,o as z5e,on as U5e,or as il,ot as K5e,p as sme,pn as nme,pr as rme,pt as W5e,q as V5e,qn as MN,qt as ame,r as Px,rn as GR,rr as bf,rt as Uh,s as JG,sn as ime,sr as ol,st as ome,t as GU,tn as lme,tr as e_,tt as Xv,u as cme,un as ZG,ur as yu,ut as jF,v as K4,vn as H5e,vr as g3,vt as oc,w as dme,wn as eQ,wt as t_,x as G5e,xn as ume,xr as m0,xt as s_,y as Q5e,yn as Y5e,yr as QR,yt as LN,z as X5e,zn as J5e}from"./RoutineRunVariablesDialog-C8pk6EH7.js";import{$ as mme,Q as sr,Z as Z5e,a as eEe,ct as tEe,et as tQ,lt as sEe,o as nEe,rt as hme,s as rEe,tt as bd}from"./mention-chips-CdRHxK9H.js";import{g as aEe}from"./dist-CYA7LF0Y.js";import{i as iEe}from"./dist-m1FA4izX.js";import{A as oEe,C as lEe,D as cEe,E as b3,M as Jg,N as Hl,O as Vm,S as Bo,T as Cl,_ as v3,a as vf,b as QU,c as y3,f as Zg,g as Bd,h as pme,j as cw,k as dEe,l as ha,m as e0,n as Mx,o as Kh,p as Wh,r as yv,s as yf,t as wF,v as $d,x as j3,y as YI}from"./zap-SCVTK-ma.js";import{D as uEe,E as mEe,S as hEe,a as fme,c as Qr,d as kc,f as xme,i as pEe,l as di,m as h0,o as fEe,p as Vx,r as xEe,s as gme,t as Ic,u as rh,w as gEe,x as bEe}from"./MarkdownEditor-BXxDMPIh.js";import{_ as YU,a as bme,b as w3,c as vme,d as Vh,f as Hh,g as Gh,h as Qh,i as qC,l as Yh,m as Xh,n as vEe,o as Jh,p as Zh,r as lh,s as im,t as ch,u as ep,v as Bi,y as Gl}from"./sheet-qyj2cFrA.js";import{a as Xi,c as yEe,i as n_,l as Jc,n as jEe,o as Ji,r as Kl,s as yme,t as yr}from"./AgentAvatar-pewOXOPY.js";import{A as Mi,C as mi,D as jme,E as wme,O as ya,S as gx,T as Nme,_ as XU,a as Xs,b as DN,c as kn,d as Jv,f as Kn,g as ja,h as Wn,i as wEe,k as Sa,l as NEe,m as vd,n as _n,o as Ln,p as Vn,r as Qs,s as jr,t as Fi,u as en,v as wa,w as kEe,x as Zb,y as hs}from"./checkbox-CLTjQudf.js";import{_ as so,a as JU,c as N3,d as Gu,f as r_,g as SEe,h as hx,l as CEe,m as a_,n as Zv,o as k3,p as Lo,r as _Ee,s as yi,t as Gs,u as i_,v as S3}from"./label-ly5pQrL-.js";import{i as Ma,n as ma,r as Qc,t as Ci}from"./tabs-CiCMgccR.js";import{a as Qn,c as pr,i as NF,n as Yc,o as IEe,r as tr,s as AEe,t as Vt}from"./agents-D_LH8E_I.js";import{S as fu,a as kme,b as no,d as Sme,f as YR,g as pa,l as Cme,m as Ed,n as TEe,o as _me,p as Ime,t as Yi,u as REe,v as Ame,x as lc,y as EEe}from"./StatusIcon-CWHgXBkX.js";import{a as vl,i as Lx,n as Fm,r as Ya,t as ey}from"./use-adapter-capabilities-B8cJZGLq.js";import{a as ty,c as Xu,i as o_,n as PEe,o as hd,r as Bn,s as C3,t as Dn}from"./EmptyState-TrxpxKhQ.js";import{t as Zi}from"./bot-zqteqJnP.js";import{t as ds}from"./check-B0QXikc7.js";import{t as sn}from"./chevron-down-DbhFfBO9.js";import{t as En}from"./chevron-right-BM1KeY7q.js";import{a as MEe,c as La,i as Cn,l as l_,n as Da,o as Tme,r as LEe,s as $a,t as Oa}from"./select-Be6thkcr.js";import{n as Xc,r as Ki,t as of}from"./save-ChEUMCgI.js";import{A as Dx,C as kF,D as DEe,_ as ZU,b as XI,c as $Ee,h as OEe,i as FEe,j as ca,k as vn,l as Bg,n as BEe,o as qEe,p as SF,r as eK,t as F,u as zEe,y as UEe}from"./button-BkeuJp7k.js";import{i as kr,n as ji,r as Ao,t as Xr}from"./clipboard-B0Nf-fdu.js";import{t as gr}from"./external-link-z81jazua.js";import{_ as KEe,a as WEe,b as dh,c as Rme,d as Eme,f as VEe,g as HEe,h as lf,i as GEe,l as QEe,m as YEe,n as Pme,o as XEe,p as sQ,r as Mme,s as JEe,t as $n,u as Lme,v as ZEe,y as e3e}from"./MarkdownBody-7SdsVDkP.js";import{t as vi}from"./file-text-CMgTJP01.js";import{a as _3,i as zo,n as t3e,o as Dme,r as c_,t as Yr}from"./heartbeats-BrsusSPB.js";import{t as rt}from"./loader-circle-CwtPxA_n.js";import{n as $N,t as uh}from"./useHiddenSettings-BfdTOT6k.js";import{t as Kw}from"./octagon-alert-CCpFDRSf.js";import{t as _i}from"./rotate-ccw-nROdTOPn.js";import{t as _s}from"./triangle-alert-C4ARdDYp.js";import{n as Ua,t as s3e}from"./SidebarContext-BJdVSZaX.js";import{n as n3e,t as ot}from"./badge-DU1L45MA.js";import{n as Tr,t as Ri}from"./environments-W2uJFT14.js";import{t as jt}from"./input-DTxvGjVe.js";import{a as jf,i as d_,n as u_,o as ur,r as Hx,t as ON}from"./company-members-DCan5GtU.js";import{t as cm}from"./health-_0py5W3M.js";import{t as Nn}from"./skeleton-DOrq5sF4.js";import{t as qd}from"./AgentIdentity-D-mYc7hi.js";import{a as r3e,i as Il,n as a3e,o as eo,r as Ha,s as po,t as Js}from"./card-BZHZYmJ0.js";import{t as Ca}from"./PageSkeleton-CYPsMFsM.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 i3e=class extends pRe{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,u=l&&d==="forward",h=i&&d==="forward",p=l&&d==="backward",f=i&&d==="backward";return{...a,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:mRe(s,n.data),hasPreviousPage:RTe(s,n.data),isFetchNextPageError:u,isFetchingNextPage:h,isFetchPreviousPageError:p,isFetchingPreviousPage:f,isRefetchError:c&&!u&&!p,isRefetching:o&&!h&&!f}}};function sy(e,s){return IRe(e,i3e,s)}r(sy,"useInfiniteQuery");var o3e="adapter_auth_missing",l3e="document",c3e=80,d3e={markdown:"md",html:"html",json:"json",text:"txt"};function u3e(e){return e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,c3e).replace(/-+$/g,"")||l3e}r(u3e,"documentExportSlug");function m3e(e){return d3e[(e??"").trim().toLowerCase()]??"md"}r(m3e,"documentExportExtension");function nQ(e,s){const n=s.replace(/^\.+/,"").toLowerCase()||"md";return`${u3e(e)}.${n}`}r(nQ,"documentExportFileName");function CF(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(CF,"decisionEffectTargetIssueIds");var h3e=new Set(["terminated","pending_approval","paused"]),p3e=new Set(["active","idle","running","error"]);function f3e(e){return p3e.has(e)&&!h3e.has(e)}r(f3e,"isAgentStatusInvokable");function Dk(e){return e==="done"||e==="cancelled"}r(Dk,"isPipelineTerminalStageKind");function $me(e){const s={};for(const n of e)(s[n.stageId]??=[]).push(n);return s}r($me,"groupWarningsByStage");function Ome(e){return e==="RESPONSIBLE_USER_UNAUTHORIZED"||e==="RESPONSIBLE_USER_UNAVAILABLE"}r(Ome,"isResponsibleUserDenialCode");function m_(e){const s=e?.trim();return s&&s.length>0?s:"the responsible user"}r(m_,"responsibleUserLabel");function _F(e,s={}){const n=m_(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(_F,"describeResponsibleUserDenial");var x3e=["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 g3e(e){const s=e?.trim();return s&&s.length>0?s:"this task"}r(g3e,"issueLabel$2");function b3e(e){const s=e?.trim();return s&&s.length>0?s:"the current assignee"}r(b3e,"assigneeLabel");function v3e(e){const s=e?.trim();return s&&s.length>0?s:"this agent"}r(v3e,"actorLabel$1");var y3e="create a child issue with the request in its description (issue creation is a separate, open write path) and let its assignee act";function j3e(e,s={}){const n=g3e(s.issueIdentifier),a=v3e(s.actorLabel),i=b3e(s.assigneeLabel),o=m_(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 ${y3e}.`};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=_F("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=_F("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(j3e,"describeIssueWriteDenial");function Fme(e){return(typeof e=="string"?e:e?.name??"").trim()}r(Fme,"rawNameOf");function Bme(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(Bme,"looksLikeNetworkAddress");function IF(e){return e.split(/[\s._-]+/).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()).join(" ")}r(IF,"titleCaseIdentifier");function w3e(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,""),IF(n)||"Custom app"}r(w3e,"pluginPackageLabel");function wf(e,s={}){const n=s.title?.trim();if(n)return n;const a=Fme(e);if(!a||Bme(a))return"Custom app";const i=w3e(a);if(i)return i;if(a.includes(":")&&!a.includes("://")){const o=a.slice(a.lastIndexOf(":")+1).trim();if(o)return IF(o)}return/\s/.test(a)||/[A-Z]/.test(a)?a:/[._-]/.test(a)?IF(a):a}r(wf,"humanizeConnectionDisplayName");function rQ(e){const s=Fme(e);return s&&Bme(s)?`hosted at ${s}`:null}r(rQ,"connectionDisplaySecondaryHint");var aQ=`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 gXe(){const e=new Blob([xXe],{type:"application/javascript"}),s=URL.createObjectURL(e);try{return new Worker(s)}finally{URL.revokeObjectURL(s)}}r(gXe,"createSandboxedWorker");var HB=new Map,O5=new Map,TT=new Set,RT=new Map,_0e=null;function bXe(e){_0e=e}r(bXe,"setDynamicParserResultNotifier");function I0e(e,s){e.worker.postMessage(s)}r(I0e,"sendToWorker");function vXe(e){return e.nextId++}r(vXe,"nextRequestId");function yXe(e,s){return`${s}\0${e}`}r(yXe,"lineCacheKey");function jXe(){_0e?.()}r(jXe,"notifyResultReady");function wXe(e,s,n){return new Promise(a=>{const i=vXe(e);e.pendingResolves.set(i,a),I0e(e,{type:"parse",id:i,line:s,ts:n})})}r(wXe,"parseLineAsync");function AS(e){for(const s of e.pendingResolves.values())s([]);e.pendingResolves.clear()}r(AS,"drainPendingRequests");function NXe(e){return new Promise((s,n)=>{const a=gXe(),i={worker:a,ready:!1,nextId:1,pendingResolves:new Map},o=setTimeout(()=>{AS(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 u=d.data;if(u.type==="result"){const h=i.pendingResolves.get(u.id);h&&(i.pendingResolves.delete(u.id),h(u.entries))}else u.type==="error"&&AS(i)},s(i);return}if(c.type==="error"){clearTimeout(o),AS(i),a.terminate(),n(new Error(c.message));return}},a.onerror=l=>{clearTimeout(o),AS(i),a.terminate(),n(new Error(`Worker error: ${l.message}`))},I0e(i,{type:"init",source:e})})}r(NXe,"initSandboxedWorker");function kXe(e){const s=new Map,n=new Set;return{parseStdoutLine:r((i,o)=>{const l=yXe(i,o),c=s.get(l);return c?c.slice():(n.has(l)||(n.add(l),wXe(e,i,o).then(d=>{n.delete(l),s.set(l,d),jXe()})),[])},"parseStdoutLine")}}r(kXe,"buildParserModule");async function GB(e){const s=O5.get(e);if(s)return s;if(TT.has(e))return null;const n=RT.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 TT.add(e),null;const o=await NXe(await i.text());HB.set(e,o);const l=kXe(o);return O5.set(e,l),l}catch{return TT.add(e),null}finally{RT.delete(e)}})();return RT.set(e,a),a}r(GB,"loadDynamicParser");function QB(e){const s=O5.has(e);O5.delete(e),TT.delete(e),RT.delete(e);const n=HB.get(e);return n&&(AS(n),n.worker.terminate(),HB.delete(e)),s}r(QB,"invalidateDynamicParser");var ET=[],mP=new Map,YB=new Set,A0e=new Map,zL=new Set,mA=new Map,XB=new Set;function T0e(e){return XB.add(e),()=>XB.delete(e)}r(T0e,"onAdapterChange");function R0e(){for(const e of XB)e()}r(R0e,"notifyAdapterChange");bXe(R0e);function SXe(){for(const e of[cGe,NGe,zGe,GGe,gQe,TQe,zQe,XQe,lYe,bYe,zYe,LYe,oQe,rXe,$5,fXe])YB.add(e.type),A0e.set(e.type,e),Eb(e)}r(SXe,"registerBuiltInUIAdapters");function Eb(e){const s=ET.findIndex(n=>n.type===e.type);s>=0?ET.splice(s,1,e):ET.push(e),mP.set(e.type,e),R0e()}r(Eb,"registerUIAdapter");function E0e(e){return mP.get(e)??null}r(E0e,"findUIAdapter");SXe();function YN(e){const s=mP.get(e);if(!s){let n=!1;return{type:e,label:e,parseStdoutLine:r((a,i)=>(n||(n=!0,GB(e).then(o=>{o&&Eb({type:e,label:e,parseStdoutLine:o.parseStdoutLine,createStdoutParser:o.createStdoutParser,ConfigFields:Av,buildAdapterConfig:tN})})),$5.parseStdoutLine(a,i)),"parseStdoutLine"),ConfigFields:Av,buildAdapterConfig:tN}}return s}r(YN,"getUIAdapter");function CXe(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 YB){const i=A0e.get(a);if(!i)continue;const o=n.has(a),l=s.has(a),c=zL.has(a);if(o&&l&&!c){zL.add(a);const d=(mA.get(a)??0)+1;mA.set(a,d);let u=!1;const h=i.parseStdoutLine,p=e.find(f=>f.type===a)?.label??a;Eb({type:a,label:p,parseStdoutLine:r((f,g)=>(u||(u=!0,GB(a).then(v=>{v&&mA.get(a)===d&&Eb({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&&(zL.delete(a),mA.delete(a),QB(a),Eb(i))}for(const{type:a,label:i}of e){if(YB.has(a))continue;const o=mP.get(a);if(o&&o!==$5)continue;let l=!1;const c=o?.parseStdoutLine??$5.parseStdoutLine;Eb({type:a,label:i,parseStdoutLine:r((d,u)=>(l||(l=!0,GB(a).then(h=>{h&&Eb({type:a,label:i,parseStdoutLine:h.parseStdoutLine,createStdoutParser:h.createStdoutParser,ConfigFields:o?.ConfigFields??Av,buildAdapterConfig:o?.buildAdapterConfig??tN})})),c(d,u)),"parseStdoutLine"),ConfigFields:o?.ConfigFields??Av,buildAdapterConfig:o?.buildAdapterConfig??tN})}}r(CXe,"syncExternalAdapters");function q8(){return[...ET]}r(q8,"listUIAdapters");function JB(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(JB,"resolveStdoutParser");function P0e(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(P0e,"appendTranscriptEntry");function _Xe(e,s){for(const n of s)P0e(e,n)}r(_Xe,"appendTranscriptEntries");function IXe(e,s=160){return e.length<=s?e:`${e.slice(0,s-3)}...`}r(IXe,"truncateTranscriptLine");function AXe(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(AXe,"formatTranscriptParserError");function TXe(e,s,n,a){const i=AXe(n)||"unknown parser error",o=IXe(e);return{kind:"result",ts:s,text:Qu(`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(TXe,"createTranscriptParseErrorEntry");function z8(e){const{entries:s,line:n,ts:a,parseLine:i,reset:o,redactionOptions:l}=e;try{_Xe(s,i(n,a).map(c=>tUe(c,l)))}catch(c){o?.(),P0e(s,TXe(n,a,c,l))}}r(z8,"appendParsedTranscriptLine");function M0e(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 u=n[d];if(u.stream==="stderr"){s.push({kind:"stderr",ts:u.ts,text:Qu(u.chunk,l)});continue}if(u.stream==="system"){s.push({kind:"system",ts:u.ts,text:Qu(u.chunk,l)});continue}const h=(c+u.chunk).split(/\r?\n/);c=h.pop()??"";for(const p of h){const f=p.trim();f&&z8({entries:s,line:f,ts:u.ts,parseLine:i,reset:o,redactionOptions:l})}}return c}r(M0e,"foldTranscriptChunks");function L0e(e,s,n){const a=[],i={enabled:n?.censorUsernameInLogs??!1},{parseLine:o,reset:l}=JB(s),c=M0e({entries:a,chunks:e,from:0,stdoutBuffer:"",parseLine:o,reset:l,redactionOptions:i}).trim();return c&&z8({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(L0e,"buildTranscript");var AJ=[];function RXe(e,s){const n={enabled:s?.censorUsernameInLogs??!1},a=typeof e!="function"&&typeof e.createStdoutParser=="function";let i=JB(e),o=[],l="",c=AJ,d=[];const u=r(()=>{i=JB(e),o=[],l="",c=AJ},"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 L0e(f,e,s);const v=o.slice(),y=v.length-1;return y>=0&&(v[y]={...v[y]}),g&&z8({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)||u(),l=M0e({entries:o,chunks:f,from:c.length,stdoutBuffer:l,parseLine:i.parseLine,reset:i.reset,redactionOptions:n}),c=f,d=p(f)),d}}}r(RXe,"createIncrementalTranscript");function EXe({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,m.useState)(!1),u=new Set(i),h=e.filter(v=>v.status!=="terminated"&&!u.has(v.id)),p=s?e.find(v=>v.id===s):null,f=p?.status==="terminated",g=!!(s&&!p);return(0,t.jsxs)(tr,{open:c,onOpenChange:d,children:[(0,t.jsx)(pr,{asChild:!0,children:(0,t.jsx)("button",{type:"button",className:W("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)(kc,{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)(yr,{agent:p,size:16,className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:W("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)(kc,{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)(Qn,{className:"w-48 p-1",align:"start",children:[(0,t.jsx)("button",{type:"button",className:W("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)(yr,{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:W("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)(yr,{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:$8[v.role]??v.role})]},v.id))]})]})}r(EXe,"ReportsToPicker");var PXe="__secret_folder__:";function MXe(e){return!e||e==="active"?null:(0,t.jsx)(ot,{variant:"outline",className:"ml-auto text-(length:--text-nano) font-normal text-muted-foreground",children:e})}r(MXe,"statusBadge");function D0e(e){return e.split("/").filter(s=>s.length>0)}r(D0e,"splitSecretPath$1");function PT(e){return e.join("/")}r(PT,"pathKey$1");function zk(e){return e.length>0?`/${e.join("/")}`:"/"}r(zk,"pathLabel");function LXe(e,s){return e.length<s.length?!1:s.every((n,a)=>e[a]===n)}r(LXe,"pathStartsWith");function TJ(e){return`${PXe}${PT(e)}`}r(TJ,"folderValue");function DXe(e,s,n){const a=s.length,i=new Map,o=[];for(const c of e){const d=D0e(c.name);if(LXe(d,s)){if(d.length>a+1){const u=d.slice(0,a+1),h=PT(u);if(!i.has(h)){const p=u[u.length-1]??"/",f=zk(u);i.set(h,{key:`folder-${h||"root"}`,value:TJ(u),label:p,title:f,searchText:f,kind:"folder",folderPath:h,pathHint:f})}continue}if(d.length===a+1||a===0&&d.length===0){const u=d.at(-1)??c.name;o.push({key:`browse-${c.id}`,value:c.id,label:u,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-${PT(s)}`,value:TJ(c),label:"Up one folder",title:zk(c),searchText:zk(c),kind:"back",folderPath:PT(c),pathHint:zk(c)})}return l.push(...i.values(),...o),{id:"browse-secrets",label:s.length>0?zk(s):"Browse secrets",options:l}}r(DXe,"buildFolderGroup");function U8({secretId:e,secrets:s,recentlyUsedSecrets:n,disabled:a,onSelect:i,onCreateNew:o,triggerClassName:l,disablePortal:c}){const[d,u]=(0,m.useState)(""),h=(0,m.useMemo)(()=>s.find(w=>w.id===e)??null,[s,e]),p=!!e&&!h,f=(0,m.useMemo)(()=>d?d.split("/"):[],[d]),g=(0,m.useMemo)(()=>s.some(w=>D0e(w.name).length>1),[s]),v=(0,m.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 k=(n??[]).filter(j=>j.status==="active"&&j.id!==e);return k.length>0&&w.push({id:"recently-used",label:"Recently used",options:k.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:k.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,m.useCallback)((w,k)=>{if(!g||_Ee(w))return k;const j=DXe(s,f,e),N=k.filter(_=>_.id==="current-missing"||_.id==="recently-used");return j.options.length>0?[...N,j]:N},[f,g,e,s]);return(0,t.jsx)(Zv,{value:e||"",groups:v,onValueChange:r((w,k)=>{if(k.folderPath!==void 0)return u(k.folderPath),!1;u(""),i(w)},"onValueChange"),deriveGroups:y,disabled:a,disablePortal:c,placeholder:"Select secret…",searchPlaceholder:"Search secrets…",emptyMessage:"No matching secrets",triggerClassName:W("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)(ji,{className:"size-3.5 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:w.label})]});const k=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)(ji,{className:W("size-3.5 shrink-0",k?"text-amber-600":"text-muted-foreground")}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:w.label}),k?(0,t.jsxs)("span",{className:"text-amber-600",children:["(",w.status,")"]}):null]})},"renderValue"),renderOption:r((w,{selected:k})=>{if(w.kind==="folder"||w.kind==="back"){const j=w.kind==="back"?pMe:Yc;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:W("truncate text-sm",k&&"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:W("flex min-w-0 flex-1 items-center gap-1.5",w.disabled&&"opacity-60"),title:w.title??w.label,children:[(0,t.jsx)(ji,{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:W("min-w-0 truncate font-mono text-sm",k&&"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]}),MXe(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)(vn,{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(U8,"SecretPicker");var $Xe=/^[a-z][a-z0-9_]*$/,RJ="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 $0e({mode:e,initialName:s,initialValue:n,existingSecretNames:a,onCancel:i,onSubmit:o}){const[l,c]=(0,m.useState)(s),[d,u]=(0,m.useState)(n),[h,p]=(0,m.useState)(!1),[f,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(null),[w,k]=(0,m.useState)(!1),j=l.trim(),N=j?$Xe.test(j)?a?.some(R=>R.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,I=!f&&j.length>0&&d.length>0&&!N;async function C(){if(k(!0),!!I){g(!0),y(null);try{await o(j,d)}catch(R){y(R instanceof Error?R.message:"Failed to create secret"),g(!1)}}}r(C,"handleSubmit");const T=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)(AEe,{className:"text-sm font-medium",children:e==="create"?"Create secret":"Store value as secret"}),e==="store"?(0,t.jsxs)(IEe,{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:W(RJ,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(R=>c(R.target.value),"onChange"),onBlur:r(()=>k(!0),"onBlur"),onKeyDown:r(R=>{R.key==="Enter"&&(R.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:W(RJ,"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"?R=>u(R.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(R=>!R),"onClick"),children:h?(0,t.jsx)(ah,{className:"h-3.5 w-3.5"}):(0,t.jsx)(bd,{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:!I,children:[f?(0,t.jsx)(rt,{className:"h-3.5 w-3.5 animate-spin"}):null,T]})]})]})}r($0e,"SecretPopoverForm");function O0e(e){return(0,t.jsx)($0e,{mode:"create",...e})}r(O0e,"CreateSecretPopover");function OXe(e){return(0,t.jsx)($0e,{mode:"store",...e})}r(OXe,"ConvertToSecretPopover");var FXe=/(api[-_]?key|access[-_]?token|auth(?:_?token)?|authorization|bearer|secret|passwd|password|credential|jwt|private[-_]?key|cookie|connectionstring)/i,BXe=[/^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 qXe(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(qXe,"looksHighEntropy");function zXe(e,s){return s?FXe.test(e)||BXe.some(n=>n.test(s))?!0:qXe(s):!1}r(zXe,"isSensitiveEnv");var EJ=0;function UXe(){return EJ+=1,`env-row-${EJ}`}r(UXe,"nextRowId");function bx(e="text"){return{id:UXe(),name:"",source:e,textValue:"",secretId:"",userSecretKey:"",required:!0,version:"latest"}}r(bx,"emptyRow");function KXe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="secret_ref"}r(KXe,"isSecretRef");function WXe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="plain"}r(WXe,"isPlainObj");function VXe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="user_secret_ref"}r(VXe,"isUserSecretRef");function UL(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([s,n])=>{if(typeof n=="string")return{...bx(),name:s,textValue:n};if(KXe(n)){const a=typeof n.version=="number"?n.version:"latest";return{...bx(),name:s,source:"secret",secretId:typeof n.secretId=="string"?n.secretId:"",version:a}}if(VXe(n)){const a=typeof n.version=="number"?n.version:"latest";return{...bx(),name:s,source:"user_secret",userSecretKey:typeof n.key=="string"?n.key:"",required:n.required!==!1,version:a}}return WXe(n)?{...bx(),name:s,source:"text",textValue:typeof n.value=="string"?n.value:""}:{...bx(),name:s}})}r(UL,"rowsFromValue");function MT(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(MT,"valueFromRows");var PJ="CLAUDE_CODE_OAUTH_TOKEN";function Gj(){return MT([{...bx("user_secret"),name:"CLAUDE_CODE_OAUTH_TOKEN",userSecretKey:"CLAUDE_CODE_OAUTH_TOKEN",required:!0,version:"latest"}])??{}}r(Gj,"buildFixedClaudeOAuthBinding");var HXe=/^[A-Za-z_][A-Za-z0-9_]*$/;function GXe(e,s,n){const a=e.trim();if(!a)return null;if(!HXe.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(GXe,"validateName");function QXe(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(QXe,"computeDuplicateNames");function YXe(e,s){return s===e.source?{kind:"noop"}:s==="secret"?e.textValue.trim()?{kind:"open-store",name:F5(e.name)||"secret",value:e.textValue}:{kind:"to-secret"}:{kind:"to-text",undoFrom:e.secretId?{...e}:null}}r(YXe,"planSourceSwitch");function F0e(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(F0e,"computeRowHealth");function B0e(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(B0e,"computeUserSecretRowHealth");function F5(e){return e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}r(F5,"secretNameFromKey");function fC(e){return e.trim().toUpperCase().replace(/[^A-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}r(fC,"envKeyFromSecretName");var XXe="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",MJ="min-w-0 flex-1 bg-transparent px-2 py-1.5 text-sm font-mono outline-none placeholder:text-muted-foreground/40";function JXe({row:e,isLast:s,secrets:n,userSecretDefinitions:a,recentlyUsedSecrets:i,disabled:o,nameIssue:l,showNameIssue:c,dirtyFields:d,onPatch:u,onRemove:h,onNameBlur:p,onNamePaste:f,onEnterInValueLast:g,onCreateSecret:v,onToast:y,focusRequest:w,onFocusConsumed:k}){const j=(0,m.useRef)(null),N=(0,m.useRef)(null),_=(0,m.useRef)(null),[I,C]=(0,m.useState)(null),[T,R]=(0,m.useState)(!1),[A,L]=(0,m.useState)(null),D=F0e(e,n)??B0e(e,a),O=e.source==="secret"?n.find(Y=>Y.id===e.secretId)??null:null,E=(a?.length??0)>0,q=e.source==="text"&&!e.sensitiveDismissed&&zXe(e.name,e.textValue);(0,m.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(),k())},[w,k,e.source]),(0,m.useEffect)(()=>{if(!A)return;const Y=window.setTimeout(()=>L(null),5e3);return()=>window.clearTimeout(Y)},[A]);function B(Y){if(Y==="user_secret"){if(e.source==="user_secret")return;u({source:"user_secret",secretId:"",version:"latest"}),window.setTimeout(()=>_.current?.querySelector("select,input")?.focus(),0);return}const ne=YXe(e,Y);switch(ne.kind){case"noop":return;case"open-store":{const{name:de,value:ee}=ne;window.setTimeout(()=>C({mode:"store",name:de,value:ee}),0);return}case"to-secret":u({source:"secret",userSecretKey:"",required:!0}),window.setTimeout(()=>{_.current?.querySelector("[role=combobox]")?.focus()},0);return;case"to-text":ne.undoFrom&&L(ne.undoFrom),u({source:"text",secretId:"",userSecretKey:"",required:!0,version:"latest"}),window.setTimeout(()=>N.current?.focus(),0);return}}r(B,"switchSource");async function U(Y,ne){const de=await v(Y,ne);u({source:"secret",secretId:de.id,userSecretKey:"",required:!0,version:"latest",textValue:""}),y(`Secret ${de.name} created`),C(null)}r(U,"submitSecretPopover");function z(){const Y=F5(e.name)||"secret",{textValue:ne}=e;window.setTimeout(()=>C({mode:"store",name:Y,value:ne}),0)}r(z,"openStoreAsSecret");const $=e.source==="text"?"Text value":e.source==="secret"?"Organization secret reference":"User secret reference",K=`${e.id}-name-error`,H=`${e.id}-health`,se=d.name||d.value,Z=O?Math.max(0,O.latestVersion):0,ie=e.version==="latest"?"latest":`v${e.version}`,oe=e.version!=="latest";return(0,t.jsxs)("div",{className:W("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",se&&"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:W(XXe,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?K:void 0,onChange:r(Y=>u({name:Y.target.value}),"onChange"),onBlur:p,onPaste:r(Y=>{e.name||f(Y.clipboardData.getData("text"))&&Y.preventDefault()},"onPaste"),onKeyDown:r(Y=>{Y.key==="Enter"&&(Y.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)(tr,{open:I!==null,onOpenChange:r(Y=>{Y||C(null)},"onOpenChange"),children:[(0,t.jsx)(NF,{asChild:!0,children:(0,t.jsxs)("div",{ref:_,className:W("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)(ja,{children:[(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)(ya,{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)(rDe,{className:"size-3.5"}):e.source==="secret"?(0,t.jsx)(ji,{className:"size-3.5"}):(0,t.jsx)(ku,{className:"size-3.5"}),(0,t.jsx)(sn,{className:"size-3 opacity-60"})]})})}),(0,t.jsx)(Vn,{side:"top",children:$})]}),(0,t.jsxs)(wa,{align:"start",className:"w-56",children:[(0,t.jsxs)(hs,{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)(hs,{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)(hs,{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:MJ,placeholder:"value",value:e.textValue,type:q?"password":"text",spellCheck:!1,disabled:o,"aria-label":"Variable value",onChange:r(Y=>u({textValue:Y.target.value}),"onChange"),onKeyDown:r(Y=>{Y.key==="Enter"&&s&&(Y.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:z,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)(Al,{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(()=>u({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)(sr,{className:"size-3"})})]}):null]}):e.source==="secret"?(0,t.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,t.jsx)(U8,{secretId:e.secretId,secrets:n,recentlyUsedSecrets:i,disabled:o,onSelect:r(Y=>u({secretId:Y,version:"latest"}),"onSelect"),onCreateNew:r(Y=>C({mode:"create",name:F5(Y)||Y.trim(),value:""}),"onCreateNew"),triggerClassName:W("rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0",O&&O.status==="active"&&"pr-24 has-[>svg]:!pr-24")}),O&&O.status==="active"?(0,t.jsxs)(tr,{open:T,onOpenChange:R,children:[(0,t.jsx)(NF,{asChild:!0,children:(0,t.jsx)("button",{type:"button",disabled:o,onClick:r(Y=>{Y.preventDefault(),Y.stopPropagation(),R(ne=>!ne)},"onClick"),"aria-label":"Version",className:W("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",oe?"bg-amber-500/15 text-amber-700 dark:text-amber-400":"text-muted-foreground hover:bg-accent"),children:ie})}),(0,t.jsxs)(Qn,{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(()=>{u({version:"latest"}),R(!1)},"onClick"),className:W("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:Z},(Y,ne)=>Z-ne).filter(Y=>Y>0).map(Y=>(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":e.version===Y,onClick:r(()=>{u({version:Y}),R(!1)},"onClick"),className:W("flex w-full items-center rounded px-2 py-1.5 text-sm hover:bg-accent",e.version===Y&&"font-medium text-amber-700 dark:text-amber-400"),children:["v",Y]},Y))]})]}):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(Y=>{const ne=Y.target.value,de=a?.find(ee=>ee.key===ne);u({userSecretKey:ne,...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(Y=>Y.key===e.userSecretKey)?(0,t.jsxs)("option",{value:e.userSecretKey,children:["Unknown (",e.userSecretKey,")"]}):null,(a??[]).map(Y=>(0,t.jsxs)("option",{value:Y.key,children:[Y.name,Y.status!=="active"?` (${Y.status})`:""]},Y.id))]}):(0,t.jsx)("input",{className:MJ,placeholder:"user-secret key",value:e.userSecretKey,spellCheck:!1,disabled:o,"aria-label":"User secret key",onChange:r(Y=>u({userSecretKey:Y.target.value}),"onChange")}),(0,t.jsxs)("select",{"aria-label":"Requirement",value:e.required?"required":"optional",disabled:o,onChange:r(Y=>u({required:Y.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)(Qn,{align:"start",className:"w-auto p-3",onInteractOutside:r(Y=>{const ne=Y.detail.originalEvent.target;ne&&_.current?.contains(ne)&&Y.preventDefault()},"onInteractOutside"),children:I?.mode==="store"?(0,t.jsx)(OXe,{initialName:I.name,initialValue:I.value,existingSecretNames:n.map(Y=>Y.name),onCancel:r(()=>C(null),"onCancel"),onSubmit:U}):I?.mode==="create"?(0,t.jsx)(O0e,{initialName:I.name,initialValue:I.value,existingSecretNames:n.map(Y=>Y.name),onCancel:r(()=>C(null),"onCancel"),onSubmit:U}):null})]}),D?(0,t.jsx)("p",{id:H,role:"status",className:W("mt-0.5 text-(length:--text-micro)",D.level==="error"?"text-destructive":"text-amber-600 dark:text-amber-400"),children:D.message}):null,A?(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(()=>{u({source:"secret",secretId:A.secretId,version:A.version,textValue:""}),L(null)},"onClick"),children:"Undo"})]}):null]}),c&&l?(0,t.jsx)("p",{id:K,className:W("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)(ja,{children:[(0,t.jsx)(ya,{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)(Mi,{className:"size-4"})})}),(0,t.jsx)(wa,{align:"end",children:(0,t.jsx)(hs,{onSelect:r(()=>{window.setTimeout(z,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)(sr,{className:"size-4"})})]})]})}r(JXe,"EnvironmentVariableRow");var ZXe=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)$/;function eJe(e){const s=e.indexOf(" #");return s>=0?e.slice(0,s):e}r(eJe,"stripInlineComment");function tJe(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 eJe(s).trim()}r(tJe,"unquote");function sJe(e){const s=[];for(const n of e.split(/\r?\n/)){const a=n.trim();if(!a||a.startsWith("#"))continue;const i=ZXe.exec(a);if(!i)continue;const o=i[1],l=tJe(i[2]);s.push({key:o,value:l})}return s}r(sJe,"parseDotenv");var nJe=["PAPERCLIP_"],rJe="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 ZB(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(ZB,"normalizedEnvEntries");function Uk(e){return JSON.stringify(ZB(e))}r(Uk,"normalizedEnvKey");var KL=3;function WL(e){const s=e.slice(0,KL).join(", ");return e.length>KL?`${s} +${e.length-KL} more`:s}r(WL,"formatChangedNames");function LJ(e){return e.map(s=>({...s}))}r(LJ,"cloneRows");function aJe(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(aJe,"rowDirtyFields");var Tv=(0,m.forwardRef)(r(function({value:s,onChange:n,secrets:a,userSecretDefinitions:i,onCreateSecret:o,recentlyUsedSecrets:l,disabled:c,reservedPrefixes:d=nJe,footerHint:u,onDirtyChange:h,hideDraftActions:p=!1},f){const g=Rc(),v=(0,m.useRef)(null),[y,w]=(0,m.useState)(()=>UL(s)),k=(0,m.useRef)(y),[j,N]=(0,m.useState)(()=>LJ(y)),_=(0,m.useMemo)(()=>Uk(s),[]),I=(0,m.useRef)(_),C=(0,m.useRef)(_),T=(0,m.useRef)(null),[R,A]=(0,m.useState)(_),[L,D]=(0,m.useState)(()=>new Set(UL(s).map(pe=>pe.name.trim()).filter(Boolean))),[O,E]=(0,m.useState)(null);(0,m.useEffect)(()=>{k.current=y},[y]);function q(pe,xe=k.current){I.current=pe,A(pe),N(LJ(xe))}r(q,"markCommitted");function B(pe){D(xe=>{const _e=new Set(xe);for(const ge of pe){const Ie=ge.name.trim();Ie&&_e.add(Ie)}return _e})}r(B,"touchCommittedNames");function U(pe){const xe=UL(pe);return w(xe),B(xe),xe}r(U,"adoptExternalValue"),(0,m.useEffect)(()=>{const pe=Uk(s);if(pe===C.current)return;C.current=pe;const xe=Uk(MT(k.current)),_e=xe!==I.current,ge=T.current===pe;if(ge&&(T.current=null),!_e){q(pe,U(s));return}(ge||xe===pe)&&(B(k.current),q(pe))},[s]);const z=(0,m.useMemo)(()=>MT(y),[y]),$=(0,m.useMemo)(()=>Uk(z),[z]),K=$!==R;(0,m.useEffect)(()=>{h?.(!c&&K)},[c,K,h]);const H=(0,m.useMemo)(()=>{const pe=new Map(ZB(MT(j)).map(([Ie,Ye])=>[Ie,JSON.stringify(Ye)])),xe=new Map(ZB(z).map(([Ie,Ye])=>[Ie,JSON.stringify(Ye)])),_e=[],ge=[];for(const[Ie,Ye]of xe)pe.has(Ie)?pe.get(Ie)!==Ye&&ge.push(Ie):_e.push(Ie);return{added:_e,changed:ge,removed:[...pe.keys()].filter(Ie=>!xe.has(Ie))}},[j,z]),se=(0,m.useMemo)(()=>{const pe=[];return H.added.length>0&&pe.push(`New: ${WL(H.added)}`),H.changed.length>0&&pe.push(`Edited: ${WL(H.changed)}`),H.removed.length>0&&pe.push(`Removed: ${WL(H.removed)}`),pe.join(" · ")},[H]);(0,m.useEffect)(()=>{if(c||!K)return;function pe(xe){xe.preventDefault(),xe.returnValue=""}return r(pe,"handleBeforeUnload"),window.addEventListener("beforeunload",pe),()=>window.removeEventListener("beforeunload",pe)},[c,K]);const Z=(0,m.useCallback)(()=>c||!K?null:(T.current=$,(0,df.flushSync)(()=>{n(z)}),z??{}),[c,z,$,K,n]);(0,m.useImperativeHandle)(f,()=>({flushPendingDraft:Z}),[Z]),(0,m.useEffect)(()=>{const pe=v.current?.closest("form");if(!pe)return;function xe(){Z()}return r(xe,"handleSubmit"),pe.addEventListener("submit",xe,!0),()=>pe.removeEventListener("submit",xe,!0)},[Z]),(0,m.useEffect)(()=>{const pe=v.current;if(!pe)return;const xe=pe;function _e(ge){const Ie=ge.target;if(!(Ie instanceof Element)||xe.contains(Ie))return;const Ye=Ie.closest("button");if(!Ye||Ye.disabled)return;const $e=`${Ye.getAttribute("aria-label")??""} ${Ye.textContent??""}`;(Ye.type==="submit"||/\b(save|create|update|test|import)\b/i.test($e))&&Z()}return r(_e,"handleDocumentClick"),document.addEventListener("click",_e,!0),()=>document.removeEventListener("click",_e,!0)},[Z]);function ie(pe){w(pe)}r(ie,"updateDraft");function oe(pe,xe){ie(y.map(_e=>_e.id===pe?{..._e,...xe}:_e))}r(oe,"patchRow");function Y(pe){ie(y.filter(xe=>xe.id!==pe))}r(Y,"removeRow");function ne(){const pe=bx();w([...y,pe]),E({rowId:pe.id,field:"name"})}r(ne,"addRow");function de(pe){const xe=y.find(_e=>_e.id===pe)?.name.trim();xe&&D(_e=>{if(_e.has(xe))return _e;const ge=new Set(_e);return ge.add(xe),ge})}r(de,"markTouched");function ee(pe,xe){const _e=sJe(pe);if(_e.length===0)return!1;const ge=y.filter(Ie=>Ie.id!==xe).map(Ie=>({...Ie}));for(const{key:Ie,value:Ye}of _e){const $e=ge.find(Xe=>Xe.name.trim()===Ie);$e?($e.name=Ie,$e.source="text",$e.textValue=Ye,$e.secretId="",$e.sensitiveDismissed=!1,$e.userSecretKey="",$e.required=!0):ge.push({...bx(),name:Ie,textValue:Ye})}return ie(ge),g?.pushToast({title:`Imported ${_e.length} variable${_e.length===1?"":"s"}`,tone:"success"}),!0}r(ee,"bulkImport");function X(pe){const xe=y.map(Ie=>({...Ie})),_e=xe[xe.length-1];let ge;_e&&!_e.name&&!_e.textValue&&!_e.secretId&&!_e.userSecretKey?ge=_e:(ge=bx(),xe.push(ge)),ge.source="secret",ge.secretId=pe.id,ge.version="latest",ge.name||(ge.name=fC(pe.name)),ie(xe)}r(X,"bindRecentSecret");function Q(){K&&(T.current=$,n(z))}r(Q,"saveDraft");function fe(){T.current=null,C.current=Uk(s);const pe=U(s);q(C.current,pe)}r(fe,"revertDraft");const te=(0,m.useMemo)(()=>QXe(y),[y]),ae=(0,m.useMemo)(()=>y.reduce((pe,xe)=>F0e(xe,a)||B0e(xe,i)?pe+1:pe,0),[y,a,i]),le=(0,m.useMemo)(()=>{const pe=new Set(y.filter(xe=>xe.source==="secret"&&xe.secretId).map(xe=>xe.secretId));return(l??[]).filter(xe=>xe.status==="active"&&!pe.has(xe.id)).slice(0,8)},[l,y]),ce=y.length>0,he=u===void 0?rJe:u,ve=(0,m.useMemo)(()=>new Map(j.map(pe=>[pe.id,pe])),[j]);return(0,t.jsx)(vd,{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)(Ki,{className:"size-3.5"}),ae," bindings need attention"]}):null,ce?(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((pe,xe)=>{const _e=GXe(pe.name,te,d),ge=L.has(pe.name.trim());return(0,t.jsx)(JXe,{row:pe,isLast:xe===y.length-1,secrets:a,userSecretDefinitions:i,recentlyUsedSecrets:l,disabled:c,nameIssue:_e,showNameIssue:ge,dirtyFields:aJe(pe,ve.get(pe.id)),onPatch:r(Ie=>oe(pe.id,Ie),"onPatch"),onRemove:r(()=>Y(pe.id),"onRemove"),onNameBlur:r(()=>de(pe.id),"onNameBlur"),onNamePaste:r(Ie=>ee(Ie,pe.id),"onNamePaste"),onEnterInValueLast:ne,onCreateSecret:o,onToast:r(Ie=>g?.pushToast({title:Ie,tone:"success"}),"onToast"),focusRequest:O?.rowId===pe.id?O.field:null,onFocusConsumed:r(()=>E(null),"onFocusConsumed")},pe.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:ne,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)(vn,{className:"size-3.5"}),"Add variable"]}),le.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)(ji,{className:"size-3"}),"Recently used:"]}),le.map(pe=>(0,t.jsxs)("button",{type:"button",onClick:r(()=>X(pe),"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 ${pe.name}`,children:["+ ",pe.name]},pe.id))]}):null]}),K&&!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"})]}),se?(0,t.jsx)("p",{className:"min-w-0 truncate pl-4 text-xs text-amber-950/80 dark:text-amber-100/80",title:se,children:se}):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)(_i,{className:"size-4"}),"Revert"]}),(0,t.jsxs)("button",{type:"button",onClick:Q,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)(of,{className:"size-4"}),"Save"]})]})]}):null,he?(0,t.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground/70",children:he}):null,y.some(pe=>pe.source==="user_secret"&&pe.userSecretKey)?(0,t.jsxs)("p",{className:"inline-flex items-start gap-1 text-(length:--text-micro) text-muted-foreground/70",children:[(0,t.jsx)(ku,{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")),iJe="env.",P_="access.",e6=/^[A-Za-z_][A-Za-z0-9_]*$/;function q0e(e){return e?e.startsWith("access.")?"api":e.startsWith("env.")?"env":"config":"config"}r(q0e,"deliveryModeForConfigPath");function z0e(e){switch(e){case"env":return"Env var";case"api":return"API access";default:return"Config"}}r(z0e,"deliveryModeLabel");function oJe(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(oJe,"deliveryModeDescription");function U0e(e){return e?e.startsWith("access.")?e.slice(7):e.startsWith("env.")?e.slice(4):e:""}r(U0e,"aliasFromConfigPath");function lJe(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(lJe,"consumerTypeLabel");var cJe={numeric:!0,sensitivity:"base"};function TS(e){return e.kind==="company"?e.secret.name:e.definition.name}r(TS,"getSecretPathRowName");function iN(e){return e.split("/").filter(s=>s.length>0)}r(iN,"splitSecretPath");function VL(e){return iN(e).join("/")}r(VL,"normalizeSecretPath");function DJ(e,s){return s.every((n,a)=>e[a]===n)}r(DJ,"startsWithSegments");function $J(e,s){return e.localeCompare(s,void 0,cJe)}r($J,"compareNames");function dJe(e,s){const n=iN(s),a=e.map(c=>({row:c,name:TS(c),segments:iN(TS(c))})),i=new Set,o=[];for(const c of a){if(!DJ(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],u=new Set;let h=0;for(const p of a){if(!DJ(p.segments,d))continue;const f=p.segments.length-d.length;if(!(f<1)){h+=1;for(let g=1;g<f;g+=1)u.add(p.segments.slice(d.length,d.length+g).join("/"))}}return{name:c,path:d.join("/"),secretCount:h,folderCount:u.size}});return l.sort((c,d)=>$J(c.name,d.name)),o.sort((c,d)=>$J(TS(c),TS(d))),{folders:l,secrets:o}}r(dJe,"buildSecretPathListing");function uJe(e){const s=iN(e);return s.map((n,a)=>({name:n,path:s.slice(0,a+1).join("/")}))}r(uJe,"buildSecretPathBreadcrumbs");function mJe(e){return e.trim()?e.includes("/")?"Folder name cannot contain slashes.":null:"Folder name is required."}r(mJe,"validateSecretFolderSegment");function c1({name:e,basePath:s="",className:n,leafClassName:a}){const i=iN(e),o=iN(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],u=c.slice(0,-1).join("/");return(0,t.jsxs)("span",{className:W("min-w-0 truncate",n),children:[u?(0,t.jsxs)("span",{className:"text-muted-foreground",children:[u,"/"]}):null,(0,t.jsx)("span",{className:W("font-medium text-foreground",a),children:d})]})}r(c1,"SecretPathName");function hJe(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(hJe,"fingerprintLabel");function K0e({fingerprint:e,length:s,className:n}){const{pushToast:a}=fa(),i=hJe(e,s);if(!e)return(0,t.jsxs)("span",{className:W("inline-flex items-center gap-1 font-mono",n),children:[(0,t.jsx)(tQ,{className:"size-3 shrink-0"}),i]});const o=`sha256:${e}`;return(0,t.jsxs)("button",{type:"button",onClick:r(()=>{Xr(o).then(()=>a({title:"Fingerprint copied",tone:"success"})).catch(()=>a({title:"Couldn’t copy fingerprint",tone:"error"}))},"onClick"),title:`Copy full digest — ${o}`,className:W("inline-flex items-center gap-1 font-mono hover:text-foreground",n),children:[(0,t.jsx)(tQ,{className:"size-3 shrink-0"}),i,(0,t.jsx)(kr,{className:"size-3 shrink-0 opacity-60"})]})}r(K0e,"FingerprintChip");function K8({justification:e,className:s}){return(0,t.jsxs)("div",{className:W("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(K8,"ProposalJustification");function d1({agent:e,className:s}){return(0,t.jsxs)("span",{className:W("inline-flex min-w-0 items-center gap-1",s),children:[(0,t.jsx)(yr,{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(d1,"AgentRefChip");function W8({configPath:e}){const s=q0e(e),n=s==="env",a=s==="api";return(0,t.jsxs)(ot,{variant:"outline",className:W("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)(The,{className:"size-3"}):a?(0,t.jsx)(M3,{className:"size-3"}):null,z0e(s)]})}r(W8,"DeliveryBadge$1");function V8({className:e}){return(0,t.jsxs)(ot,{variant:"outline",className:W("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)(Al,{className:"size-3"})," Proposed"]})}r(V8,"ProposedBadge");function hP(e){return U0e(e.configPath)}r(hP,"bindingEnvKey");function H8(e){return e.secretProposalId?{name:e.secretProposalName??"proposed secret",pending:!0}:{name:e.secretName??"secret",pending:!1}}r(H8,"bindingSecretLabel");function OJ(e){return e instanceof cn?e.message||`Request failed: ${e.status}`:e instanceof Error?e.message:"Something went wrong. Try again."}r(OJ,"readableError");function W0e(e,s=[]){const n=Ut(),{pushToast:a}=fa(),[i,o]=(0,m.useState)(null),[l,c]=(0,m.useState)(null),[d,u]=(0,m.useState)(""),[h,p]=(0,m.useState)(null),f=(0,m.useCallback)(()=>{e&&(n.invalidateQueries({queryKey:["secret-proposals",e]}),n.invalidateQueries({queryKey:P.secrets.list(e)}))},[e,n]),g=Ne({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 vr.approveProposal(e,N.id,{overrides:{name:_,description:j.description.trim()||null,providerConfigId:j.providerConfigId||null}})}return vr.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"} · ${hP(j)||"binding"}`,tone:"success"}),o(null),p(null),f()},"onSuccess"),onError:r(j=>p(OJ(j)),"onError")}),v=Ne({mutationFn:r(({proposal:j,reason:N})=>vr.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),u(""),p(null),f()},"onSuccess"),onError:r(j=>p(OJ(j)),"onError")}),y=(0,m.useCallback)(j=>{p(null);const N=(j.proposedName??"").split("/"),_=N.pop()??"";o({proposal:j,folder:N.join("/"),leaf:_,description:j.proposedDescription??"",providerConfigId:s.find(I=>I.provider==="local_encrypted"&&I.isDefault)?.id??"",cascade:!!j.secretProposalId})},[s]),w=(0,m.useCallback)(j=>{p(null),u(""),c(j)},[]),k=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(pJe,{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)(xJe,{proposal:l,reason:d,error:h,pending:v.isPending,onReasonChange:u,onCancel:r(()=>{c(null),u(""),p(null)},"onCancel"),onConfirm:r(()=>l&&v.mutate({proposal:l,reason:d}),"onConfirm")})]});return{requestApprove:y,requestReject:w,isBusy:g.isPending||v.isPending,dialogs:k}}r(W0e,"useProposalReview");function pJe({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():"",u=a.filter(p=>p.provider==="local_encrypted"),h=c?!!(e&&e.leaf.trim()):!0;return(0,t.jsx)(Qs,{open:!!e,onOpenChange:r(p=>!p&&o(),"onOpenChange"),children:(0,t.jsx)(Xs,{className:"sm:max-w-lg",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:c?"Approve & create secret":"Approve binding"}),(0,t.jsx)(Ln,{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)(d1,{agent:e.proposal.proposedBy,className:"font-medium text-foreground"})]}),(0,t.jsx)(K8,{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)(Gs,{htmlFor:"approve-folder",children:"Folder"}),(0,t.jsx)(jt,{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)(Gs,{htmlFor:"approve-name",children:"Name"}),(0,t.jsx)(jt,{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)(c1,{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)(Gs,{htmlFor:"approve-description",children:"Description"}),(0,t.jsx)(jt,{id:"approve-description",value:e.description,onChange:r(p=>i({...e,description:p.target.value}),"onChange"),placeholder:"Optional"})]}),u.length>0?(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Gs,{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"}),u.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)(K0e,{fingerprint:e.proposal.valueFingerprintSha256,length:e.proposal.valueLength})})]}):(0,t.jsx)(fJe,{draft:e,onChange:i}),s?(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:s}):null,(0,t.jsxs)(jr,{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(pJe,"ApproveDialog");function fJe({draft:e,onChange:s}){const{proposal:n}=e,a=H8(n),i=hP(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)(d1,{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)(W8,{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)(ji,{className:"size-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:a.name}),a.pending?(0,t.jsx)(V8,{}):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(fJe,"BindingApproveBody");function xJe({proposal:e,reason:s,error:n,pending:a,onReasonChange:i,onCancel:o,onConfirm:l}){const c=s.trim().length>0;return(0,t.jsx)(Qs,{open:!!e,onOpenChange:r(d=>!d&&o(),"onOpenChange"),children:(0,t.jsx)(Xs,{className:"sm:max-w-md",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:"Reject proposal"}),(0,t.jsxs)(Ln,{children:["The reason is sent back to"," ",(0,t.jsx)(d1,{agent:e.proposedBy,className:"text-foreground"}),". Dependent bindings are rejected too."]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Gs,{htmlFor:"reject-reason",children:"Reason"}),(0,t.jsx)(_n,{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)(jr,{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(xJe,"RejectDialog");function V0e({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)(vd,{children:(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)("span",{tabIndex:0,children:c})}),(0,t.jsx)(Vn,{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(V0e,"ProposalActions");function H0e(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}r(H0e,"asRecord$15");function G0e(e){const s=H0e(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(G0e,"readSecretRef");function gJe(e){const s=H0e(e?.env);if(!s)return[];const n=[];for(const[a,i]of Object.entries(s)){const o=G0e(i);o&&n.push({name:a,...o})}return n}r(gJe,"parseEnvSecretRefs");function bJe(e){if(!e)return[];const s=[];for(const[n,a]of Object.entries(e)){if(!n.startsWith("access."))continue;const i=G0e(a);i&&s.push({name:n.slice(P_.length),...i})}return s}r(bJe,"parseAccessGrants");function vJe(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(vJe,"summarizeAgentBindings");var FJ=0;function Q0e(){return FJ+=1,`access-row-${FJ}`}r(Q0e,"nextAccessRowId");function HL(e){return e.map(s=>({id:Q0e(),alias:s.name,secretId:s.secretId,version:s.version}))}r(HL,"entriesToRows");function BJ(e){const s={};for(const n of e){const a=n.alias.trim();!a||!e6.test(a)||!n.secretId||(s[a]={type:"secret_ref",secretId:n.secretId,version:n.version})}return s}r(BJ,"rowsToAccessMap");function qJ(e){return JSON.stringify(Object.keys(e).sort().map(s=>{const n=e[s];return[s,n.secretId,n.version??"latest"]}))}r(qJ,"normalizeAccessMapKey");function zJ({mode:e}){return e==="env"?(0,t.jsxs)(ot,{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)(The,{className:"size-3"})," Env var"]}):(0,t.jsxs)(ot,{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)(M3,{className:"size-3"})," API access"]})}r(zJ,"DeliveryBadge");function yJe({config:e,secrets:s,onChange:n,onCreateSecret:a,disabled:i,proposals:o,onApproveProposal:l,onRejectProposal:c}){const d=(0,m.useMemo)(()=>(o??[]).filter(O=>O.kind==="binding"),[o]),u=(0,m.useMemo)(()=>gJe(e),[e]),h=(0,m.useMemo)(()=>bJe(e),[e]),p=(0,m.useMemo)(()=>vJe(u,h),[u,h]),f=(0,m.useMemo)(()=>BJ(HL(h)),[h]),g=(0,m.useMemo)(()=>qJ(f),[f]),[v,y]=(0,m.useState)(()=>HL(h)),[w,k]=(0,m.useState)(null),j=(0,m.useRef)(new Map),N=(0,m.useRef)(g),_=(0,m.useRef)(g);(0,m.useEffect)(()=>{g!==_.current&&(_.current=g,g!==N.current&&y(HL(h)))},[g,h]);const I=r(O=>s.find(E=>E.id===O)?.name??`${O.slice(0,8)}…`,"secretName");function C(O){y(O);const E=BJ(O);N.current=qJ(E),n(E)}r(C,"emit");function T(O,E){C(v.map(q=>q.id===O?{...q,...E}:q))}r(T,"patchRow");function R(O){C(v.filter(E=>E.id!==O))}r(R,"removeRow");function A(){y(O=>[...O,{id:Q0e(),alias:"",secretId:"",version:"latest"}])}r(A,"addRow");const L=(0,m.useMemo)(()=>{const O=new Map;for(const E of v){const q=E.alias.trim();q&&O.set(q,(O.get(q)??0)+1)}return O},[v]),D=p.length>0;return(0,t.jsxs)("div",{className:"space-y-3",children:[D?(0,t.jsx)("div",{className:"space-y-1.5",children:p.map(O=>(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)(ji,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:I(O.secretId)}),O.envKeys.length>0?(0,t.jsx)(zJ,{mode:"env"}):null,O.apiAliases.length>0?(0,t.jsx)(zJ,{mode:"api"}):null,(0,t.jsx)("span",{className:"min-w-0 truncate font-mono text-(length:--text-micro) text-muted-foreground",children:[...O.envKeys.map(E=>`${iJe}${E}`),...O.apiAliases.map(E=>`${P_}${E}`)].join(" · ")})]},O.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(O=>{const E=H8(O),q=hP(O);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)(W8,{configPath:O.configPath}),(0,t.jsx)("code",{className:"font-mono",children:q||O.configPath}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"→"}),(0,t.jsx)(ji,{className:"size-3 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:E.name}),E.pending?(0,t.jsx)(V8,{}):null]}),(0,t.jsxs)("p",{className:"flex flex-wrap items-center gap-1 text-muted-foreground",children:[(0,t.jsxs)("span",{children:["proposed by ",O.proposedBy.name]}),(0,t.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,t.jsxs)("span",{className:"truncate italic",children:["“",O.justification,"”"]})]})]}),(0,t.jsx)(V0e,{proposal:O,onApprove:l,onReject:c,disabled:i,size:"xs"})]},O.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(O=>{const E=O.alias.trim(),q=!!E&&!e6.test(E),B=!!E&&(L.get(E)??0)>1,U=s.find(z=>z.id===O.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)(jt,{value:O.alias,onChange:r(z=>T(O.id,{alias:z.target.value}),"onChange"),onBlur:r(z=>{const $=z.target.value.trim();if($&&!e6.test($)){const K=fC($);K&&K!==$&&T(O.id,{alias:K})}},"onBlur"),placeholder:"ALIAS","aria-label":"Access alias",disabled:i,className:W("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)(tr,{open:w?.rowId===O.id,onOpenChange:r(z=>{!z&&w?.rowId===O.id&&k(null)},"onOpenChange"),children:[(0,t.jsx)(NF,{asChild:!0,children:(0,t.jsx)("div",{ref:r(z=>{z?j.current.set(O.id,z):j.current.delete(O.id)},"ref"),className:"min-w-0 flex-1",children:(0,t.jsx)(U8,{secretId:O.secretId,secrets:s,onSelect:r(z=>T(O.id,{secretId:z,version:"latest",alias:!O.alias.trim()&&z?fC(I(z)):O.alias}),"onSelect"),onCreateNew:a?z=>{window.setTimeout(()=>{k({rowId:O.id,name:F5(z)||z.trim()})},0)}:void 0,disabled:i,triggerClassName:"h-9 min-h-9"})})}),(0,t.jsx)(Qn,{align:"start",className:"w-auto p-3",onInteractOutside:r(z=>{const $=z.detail.originalEvent.target;$&&j.current.get(O.id)?.contains($)&&z.preventDefault()},"onInteractOutside"),children:w?.rowId===O.id&&a?(0,t.jsx)(O0e,{initialName:w.name,initialValue:"",existingSecretNames:s.map(z=>z.name),onCancel:r(()=>k(null),"onCancel"),onSubmit:r(async(z,$)=>{const K=await a(z,$);T(O.id,{secretId:K.id,version:"latest",alias:O.alias.trim()||fC(K.name)}),k(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:O.version===void 0?"latest":String(O.version),onChange:r(z=>{const $=z.target.value;T(O.id,{version:$==="latest"?"latest":Number.parseInt($,10)})},"onChange"),disabled:i||!U,"aria-label":"Version",children:[(0,t.jsx)("option",{value:"latest",children:"latest"}),U?Array.from({length:Math.max(0,U.latestVersion)},(z,$)=>{const K=U.latestVersion-$;return K<=0?null:(0,t.jsxs)("option",{value:K,children:["v",K]},K)}):null]})]}),(0,t.jsx)("button",{type:"button",onClick:r(()=>R(O.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)(Sa,{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]},O.id)})}):null,(0,t.jsxs)("button",{type:"button",onClick:A,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)(vn,{className:"size-3.5"}),"Add API access"]})]}),(0,t.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground/70",children:[oJe("api")," The agent reads them by alias through ",(0,t.jsx)("code",{children:"GET /agents/me/secrets"}),"."]})]})}r(yJe,"AgentSecretAccessEditor");function jJe(e){if(typeof e!="string")return null;const s=e.trim();return s.length>0?s:null}r(jJe,"asNonEmptyString$3");function wJe(e){return jJe(e)!==null}r(wJe,"hasLegacyWorkingDirectory");function NJe(e){return e.isCreate?!1:wJe(e.adapterConfig?.cwd)}r(NJe,"shouldShowLegacyWorkingDirectoryField");var Y0e=new Set;function kJe(e){return Y0e.has(e)}r(kJe,"isAdapterTypeHidden");function SJe(e){Y0e=new Set(e)}r(SJe,"setDisabledAdapterTypes");function CJe(e){return!Jm(e).hideFromVisualSelection}r(CJe,"isVisualAdapterChoice");function X0e(e,s=q8()){const n=e??kf;return s.map(a=>({value:a.type,label:n(a.type),comingSoon:!!Jm(a.type).comingSoon,hidden:kJe(a.type),experimental:!!Jm(a.type).experimental}))}r(X0e,"listAdapterOptions");function J0e(e={}){const s=e.enabled??!0,{data:n}=J({queryKey:P.adapters.all,queryFn:r(()=>Fm.list(),"queryFn"),enabled:s,staleTime:3e5});return n&&CXe(n.filter(a=>a.source==="external").map(a=>({type:a.type,label:a.label,disabled:a.disabled,overrideDisabled:a.overridePaused}))),(0,m.useEffect)(()=>{n&&SJe(n.filter(a=>a.disabled).map(a=>a.type))},[n]),(0,m.useMemo)(()=>new Set(n?.filter(a=>a.disabled).map(a=>a.type)??[]),[n])}r(J0e,"useDisabledAdaptersSync");function _Je(e={}){const s=e.enabled??!0,{data:n}=J({queryKey:P.adapters.all,queryFn:r(()=>Fm.list(),"queryFn"),enabled:s,staleTime:3e5});return n!==void 0}r(_Je,"useAdapterRegistryLoaded");function B5(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))}r(B5,"omitUndefinedEntries");function hA(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=B5(s.adapterType!==void 0?{...Object.fromEntries(TRe.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=B5({...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(hA,"buildAgentUpdatePatch");var IJe="kubernetes";function AJe(e){return e.driver!=="sandbox"?!1:e.config?.provider===IJe}r(AJe,"isKubernetesSandboxEnvironment");function G8(e,s){return e!=="kubernetes"?{forced:!1,kubernetesEnvironment:null}:{forced:!0,kubernetesEnvironment:s.find(n=>AJe(n))??null}}r(G8,"resolveForcedKubernetesEnvironment");var GL={identity:{},adapterConfig:{},heartbeat:{},debug:{},runtime:{}},Kk={};function TJe(e){return e==="claude_local"||e==="codex_local"||e==="paperclip_runner"||e==="opencode_local"}r(TJe,"supportsAdapterModelRefresh");function RJe(e,s){return Rfe(e,s).model}r(RJe,"resolvePaperclipRunnerTransitionModel");function UJ(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(UJ,"isOverlayDirty");function t6(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)=>t6(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&&t6(o,a[i]))}return!1}r(t6,"overlayValuesEqual");function EJe(e,s){const n=r((a,i)=>Object.fromEntries(Object.entries(a).filter(([o,l])=>!(o in i)||!t6(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(EJe,"subtractPersistedOverlay");var _m="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 PJe(e){return e.split(",").map(s=>s.trim()).filter(Boolean)}r(PJe,"parseCommaArgs");function MJe(e){return Array.isArray(e)?e.filter(s=>typeof s=="string").join(", "):typeof e=="string"?e:""}r(MJe,"formatArgList");var LJe=[{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"}],DJe=[{id:"",label:"Auto"},{id:"plan",label:"Plan"},{id:"ask",label:"Ask"}],$Je=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"}],OJe=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"high",label:"High"},{id:"max",label:"Max"}],FJe=2,KJ=10,BJe=1,Z0e=300;function LT(e,s,n){return Math.max(s,Math.min(n,Math.floor(e)))}r(LT,"clampInteger");function qJe(e){return LT(e,0,Z0e)*1e3}r(qJe,"clampDelayMsFromSeconds");function zJe({order:e,className:s,children:n}){if(!e)return(0,t.jsx)("div",{className:s,children:n});const a=r(o=>{const l=(0,m.isValidElement)(o)?o.props["data-config-section"]:void 0,c=l?e.indexOf(l):-1;return c<0?e.length:c},"rank"),i=m.Children.toArray(n).sort((o,l)=>a(o)-a(l));return(0,t.jsx)("div",{className:s,children:i})}r(zJe,"ConfigSections");function ebe(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,u=e.showCreateRunPolicySection??!0,h=e.hideInstructionsFile??!1,p=e.canConfigureProviderTrace===!0,{selectedCompanyId:f}=ps(),g=Ut(),v=(0,m.useRef)(null),y=J0e(),{data:w=[]}=J({queryKey:f?P.secrets.list(f):["secrets","none"],queryFn:r(()=>vr.list(f),"queryFn"),enabled:!!f}),{data:k=[]}=J({queryKey:f?P.secrets.userDefinitions(f):["user-secret-definitions","none"],queryFn:r(()=>vr.listUserSecretDefinitions(f),"queryFn"),enabled:!!f,retry:!1}),j=a?null:e.agent.id,{data:N=[]}=J({queryKey:f?P.secrets.proposals(f,"pending"):["secret-proposals","none"],queryFn:r(()=>vr.listProposals(f,"pending"),"queryFn"),enabled:!!f&&!a,retry:!1}),_=(0,m.useMemo)(()=>N.filter(et=>et.kind==="binding"&&et.target?.id===j),[N,j]),I=W0e(f,[]),{data:C}=J({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn"),retry:!1}),T=(0,m.useMemo)(()=>{const et=new Set(y);return C?.enableNativeRunner!==!0&&et.add("paperclip_runner"),et},[y,C?.enableNativeRunner]),R=C?.enableEnvironments===!0,A=C?.enableManagedSandboxOnly===!0,L=C===void 0||A,{data:D}=J({queryKey:P.instance.generalSettings,queryFn:r(()=>Tr.getGeneral(),"queryFn"),retry:!1}),{data:O}=J({queryKey:P.instance.settings,queryFn:r(()=>Tr.get(),"queryFn"),retry:!1}),{data:E=[]}=J({queryKey:f?P.environments.list(f):["environments","none"],queryFn:r(()=>Ri.list(f),"queryFn"),enabled:!!f&&(R||D?.executionMode==="kubernetes")}),{forced:q,kubernetesEnvironment:B}=(0,m.useMemo)(()=>G8(D?.executionMode,E),[D?.executionMode,E]),U=Ne({mutationFn:r(et=>{if(!f)throw new Error("Select an organization to create secrets");return vr.create(f,et)},"mutationFn"),onSuccess:r(()=>{f&&g.invalidateQueries({queryKey:P.secrets.list(f)})},"onSuccess")}),z=Ne({mutationFn:r(async({file:et,namespace:Gt})=>{if(!f)throw new Error("Select an organization to upload images");return P0.uploadImage(f,et,Gt)},"mutationFn")}),[$,K]=(0,m.useState)(GL),[H,se]=(0,m.useState)(!1),[Z,ie]=(0,m.useState)(0),oe=(0,m.useRef)(null),Y=(0,m.useRef)(null),ne=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!a){if(oe.current!==null&&e.agent!==oe.current&&!ne.current){const et=Y.current;Y.current=null,K(Gt=>et?EJe(Gt,et):{...GL})}oe.current=e.agent}},[a,a?void 0:e.agent]);const de=!a&&(UJ($)||H);function ee(et,Gt,mn){const Os=$[et];return Gt in Os?Os[Gt]:mn}r(ee,"eff");function X(et,Gt,mn){K(Os=>({...Os,[et]:{...Os[et],[Gt]:mn}}))}r(X,"mark");function Q(){return v.current?.flushPendingDraft()??null}r(Q,"flushEnvironmentDraft");const fe=(0,m.useCallback)(et=>{a||K(Gt=>{const mn={...e.agent.adapterConfig??{},...Gt.adapterConfig},Os={...Gt.adapterConfig};for(const[Jn,Nr]of Object.entries(et))Os[`${P_}${Jn}`]=Nr;for(const Jn of Object.keys(mn))Jn.startsWith("access.")&&(Jn.slice(7)in et||(Os[Jn]=void 0));return{...Gt,adapterConfig:Os}})},[a,a?void 0:e.agent]),te=(0,m.useCallback)(()=>{K({...GL}),se(!1),ie(et=>et+1)},[]),ae=(0,m.useCallback)(async()=>{if(a)return;const et=Q(),Gt=et?{...$,adapterConfig:{...$.adapterConfig,env:et}}:$;UJ(Gt)&&await e.onSave(hA(e.agent,Gt))},[a,de,$,e]);(0,m.useEffect)(()=>{a||(e.onDirtyChange?.(de),e.onSaveActionChange?.(ae),e.onCancelActionChange?.(te))},[a,de,e.onDirtyChange,e.onSaveActionChange,e.onCancelActionChange,ae,te]),(0,m.useEffect)(()=>{if(!a)return()=>{e.onSaveActionChange?.(null),e.onCancelActionChange?.(null),e.onDirtyChange?.(!1)}},[a,e.onDirtyChange,e.onSaveActionChange,e.onCancelActionChange]);const le=a?{}:e.agent.adapterConfig??{},ce=a?{}:e.agent.runtimeConfig??{},he=a?{}:ce.heartbeat??{},ve=a?{}:ce.debug??{},pe=a?e.values.adapterType:$.adapterType??e.agent.adapterType,xe=ey(),_e=xe(pe),ge=_e.supportsInstructionsBundle||_e.supportsSkills||_e.supportsLocalAgentJwt,Ie=ge&&!L&&NJe({isCreate:a,adapterConfig:le}),Ye=(0,m.useMemo)(()=>YN(pe),[pe]),$e=(0,m.useMemo)(()=>new Set(J3e(pe)),[pe]),Xe=a?e.values:null,ue=a?et=>e.onChange(et):null;a&&Xe.claudeStoredSessionId;const Oe=r(()=>{f&&g.invalidateQueries({queryKey:P.secrets.userDefinitions(f)})},"invalidateUserSecretDefinitions"),dt=r(et=>{if(!a||!ue)return;const Gt=Xe.envBindings??{};ue({envBindings:{...Gt,...Gj()},claudeStoredSessionId:et}),Oe()},"handleClaudeLoginStored"),xt=r(async()=>{if(a)return;const et={...Q()??ee("adapterConfig","env",le.env??Kk),...Gj()},Gt={...$,adapterConfig:{...$.adapterConfig,env:et}};K(Gt),await e.onSave({...hA(e.agent,Gt),applyStoredClaudeLogin:!0}),Oe()},"handleClaudeLoginStoredEdit"),Le=r(async et=>{if(a||!et.companyIdentityDiffers)return;const Gt={...Q()??ee("adapterConfig","env",le.env??Kk),CODEX_HOME:{type:"secret_ref",secretId:et.secretId,version:"latest"}},mn={...$,adapterConfig:{...$.adapterConfig,env:Gt}};K(mn),Y.current=mn,ne.current=!0;try{await e.onSave(hA(e.agent,mn))}catch(Os){throw Y.current=null,Os}finally{ne.current=!1}Oe()},"handleCodexAccountBindingEdit"),Ge=r(()=>{if(!a||!ue)return;const et=Xe.envBindings??{};ue({envBindings:{...et,...Gj()},claudeApplyStoredLogin:!0}),Oe()},"handleApplyStoredClaudeLogin"),ht=r(async()=>{if(a)return;const et={...Q()??ee("adapterConfig","env",le.env??Kk),...Gj()},Gt={...$,adapterConfig:{...$.adapterConfig,env:et}};K(Gt),await e.onSave({...hA(e.agent,Gt),applyStoredClaudeLogin:!0}),Oe()},"handleApplyStoredClaudeLoginEdit"),Ve=a?Xe.defaultEnvironmentId??"":ee("identity","defaultEnvironmentId",e.agent.defaultEnvironmentId??""),Ke=(0,m.useMemo)(()=>Ve?(E.find(et=>et.id===Ve)??null)?.driver==="local"?"":Ve:"",[E,Ve]),gt=(0,m.useMemo)(()=>E.find(et=>et.id===Ke)??null,[Ke,E]),tt=(0,m.useMemo)(()=>{const et=O?.defaultEnvironmentId??null;return et?(E.find(Gt=>Gt.id===et)??null)?.driver==="local"?"":et:""},[E,O?.defaultEnvironmentId]),Se=(0,m.useMemo)(()=>E.find(et=>et.id===tt)??null,[E,tt]),ke=(0,m.useMemo)(()=>{try{return sN({agentDefaultEnvironmentId:Ve||null,instanceDefaultEnvironmentId:O?.defaultEnvironmentId??null,localDefaultEnvironmentId:rN(E),managedSandboxOnly:C?.enableManagedSandboxOnly===!0,managedSandboxEnvironmentId:nN(E),visibleEnvironmentIds:E.map(et=>et.id)})}catch{return null}},[Ve,O?.defaultEnvironmentId,E,C?.enableManagedSandboxOnly]),Je=(0,m.useMemo)(()=>E.find(et=>et.id===ke)??null,[E,ke]),{data:ut}=J({queryKey:f?P.environments.capabilities(f):["environment-capabilities","none"],queryFn:r(()=>Ri.capabilities(f),"queryFn"),enabled:!!f&&_e.login!=null});(0,m.useEffect)(()=>{!a||!ue||!q||!B||Ke!==B.id&&ue({defaultEnvironmentId:B.id})},[a,ue,q,B,Ke]);const Dt=(0,m.useMemo)(()=>E.filter(et=>{if(!$e.has(et.driver)||et.driver==="local")return!1;if(et.driver!=="sandbox")return!0;const Gt=typeof et.config?.provider=="string"?et.config.provider:null;return Gt!==null&&Gt!=="fake"}),[E,$e]),Jt=(0,m.useMemo)(()=>!gt||Dt.some(et=>et.id===gt.id)?Dt:[...Dt,gt],[gt,Dt]),fs=R&&(q||Ke.length>0||Dt.length>=1),We=Se?aN(Se):A?"Paperclip Computer":"Local",He=pe==="paperclip_runner"?String(a?e.values.adapterSchemaValues?.provider??"codex":ee("adapterConfig","provider",le.provider==="acpx"&&le.acpxAgent==="codex"?"codex":le.provider??"codex")):void 0,ct=pe==="opencode_local"&&cT.safeParse($.runtime.runtimeConfig?.aiConnection??ce.aiConnection).data?.provider==="openrouter"?"openrouter":He,ze=f?P.agents.adapterModels(f,pe,Ke||null,ct):["agents","none","adapter-models",pe],{data:is,error:Fe}=J({queryKey:ze,queryFn:r(()=>Vt.adapterModels(f,pe,{environmentId:Ke||null,provider:ct}),"queryFn"),enabled:!!f}),[Qt,Tt]=(0,m.useState)(null),[Ms,Ue]=(0,m.useState)(!1),pt=is??n??[],$t="command",{data:gs,refetch:Rs}=J({queryKey:f?P.agents.detectModel(f,pe):["agents","none","detect-model",pe],queryFn:r(()=>{if(!f)throw new Error("Select an organization to detect the model");return Vt.detectModel(f,pe)},"queryFn"),enabled:!!(f&&ge&&pe!=="opencode_local"&&pe!=="paperclip_runner")}),Ct=gs?.model??null;gs?.candidates;const{data:we=[]}=J({queryKey:f?P.agents.list(f):["agents","none","list"],queryFn:r(()=>Vt.list(f),"queryFn"),enabled:!!(!a&&f)}),Pe={mode:s,isCreate:a,adapterType:pe,values:a?e.values:null,set:a?et=>e.onChange(et):null,config:le,eff:ee,mark:X,models:pt,hideInstructionsFile:h||L,managedSandboxOnly:L},[lt,Ot]=(0,m.useState)(!1),[ft,us]=(0,m.useState)(!1),dn=r0e(pe),xs=r(et=>(0,t.jsxs)(t.Fragment,{children:[pe==="claude_local"&&(0,t.jsx)(lGe,{...Pe,section:et}),(0,t.jsx)(Ye.ConfigFields,{...Pe,section:et,hideModel:ge})]}),"renderAdapterFields"),[bs,qe]=(0,m.useState)(!1),[Nt,St]=(0,m.useState)(!1);function Ee(et){if(a){const mn=Ye.buildAdapterConfig(Xe);return et&&Object.assign(mn,et),B5(mn)}const Gt={...le,...$.adapterConfig};return et&&Object.assign(Gt,et),B5(Gt)}r(Ee,"buildAdapterConfigForTest");const De=Ne({mutationFn:r(async()=>{if(!f)throw new Error("Select an organization to test adapter environment");const et=Q(),Gt=et?{env:et}:void 0;let mn=O,Os=E,Jn=C?.enableManagedSandboxOnly===!0;if(!Ve)try{const[rs,fn,Hs]=await Promise.all([g.ensureQueryData({queryKey:P.instance.settings,queryFn:r(()=>Tr.get(),"queryFn")}),g.ensureQueryData({queryKey:P.environments.list(f),queryFn:r(()=>Ri.list(f),"queryFn")}),g.ensureQueryData({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn")})]);mn=rs,Os=fn,Jn=Hs?.enableManagedSandboxOnly===!0}catch{throw new Error("Could not load environment settings to determine which environment to test in. Retry the test.")}const Nr=sN({agentDefaultEnvironmentId:Ve||null,instanceDefaultEnvironmentId:mn?.defaultEnvironmentId??null,localDefaultEnvironmentId:rN(Os),managedSandboxOnly:Jn,managedSandboxEnvironmentId:nN(Os),visibleEnvironmentIds:Os.map(rs=>rs.id)}),_a=Ee(Gt),Un=a?void 0:e.agent.id,Zn=a?void 0:cT.safeParse($.runtime.runtimeConfig?.aiConnection??e.agent.runtimeConfig.aiConnection).data;if(e.compactTestFeedback){const rs=pe==="paperclip_runner"?_a.provider==="codex"?"codex_local":_a.provider==="acpx"&&_a.acpxAgent==="claude"?"claude_local":pe:pe;return Yge({companyId:f,adapterType:pe,providerAdapter:rs,adapterConfig:_a,agentId:Un,aiConnection:Zn,environmentId:Nr})}return Vt.testEnvironment(f,pe,{adapterConfig:_a,agentId:Un,aiConnection:Zn,environmentId:Nr})},"mutationFn")}),[Ze,kt]=(0,m.useState)(!1),[Kt,Lt]=(0,m.useState)(null),Ft="Test",Yt=!a&&!!e.isSaving,Vs=Ze||Yt||!f,In=(0,m.useRef)(De.reset);In.current=De.reset;const An=(0,m.useRef)(()=>{});An.current=()=>{if(!a||!ue)return;const et=Xe.envBindings??{},Gt=Xe.claudeStoredSessionId!=null||Xe.claudeApplyStoredLogin===!0,mn=PJ in et;if(!Gt&&!mn)return;const Os={...et};delete Os[PJ],ue({envBindings:Os,claudeStoredSessionId:null,claudeApplyStoredLogin:!1})},(0,m.useEffect)(()=>{In.current(),Lt(null),An.current()},[pe,ke]);const tn=_e.login!=null,Us=De.data,ws=Us!=null&&xe(Us.adapterType).login!=null,nn=Us&&ws?Us.checks.find(et=>et.code==="adapter_auth_missing")??null:null,zs=typeof Je?.config?.provider=="string"?Je.config.provider:null,Tn=zs!=null&&ut?.sandboxProviders?.[zs]?.supportsLoginPty===!0,pn=_e.login!=null,rn=(a||!($.runtime.runtimeConfig?.aiConnection??ce.aiConnection))&&tn&&Je?.driver==="sandbox"&&!!ke&&!!f&&!!nn&&(!pn||Tn),br=(0,m.useCallback)(async()=>{if(!f)throw new Error("Select an organization to test adapter environment");kt(!0),Lt(null),De.reset();try{return await De.mutateAsync()}catch(et){throw Lt(et instanceof Error?et.message:"Environment test failed"),et}finally{kt(!1)}},[f,De]),Zs=(0,m.useRef)(()=>{});(0,m.useEffect)(()=>{Zs.current=()=>{Vs||br().catch(()=>{})}},[br,Vs]);const nr=(0,m.useCallback)(()=>{Zs.current()},[]);(0,m.useEffect)(()=>{if(!(!l||!e.onTestActionChange))return e.onTestActionChange(nr),()=>{e.onTestActionChange?.(null)}},[l,e.onTestActionChange,nr]),(0,m.useEffect)(()=>{if(!(!l||!e.onTestActionStateChange))return e.onTestActionStateChange({disabled:Vs,pending:Ze}),()=>{e.onTestActionStateChange?.({disabled:!0,pending:!1})}},[l,e.onTestActionStateChange,Vs,Ze]),(0,m.useEffect)(()=>{if(e.onTestFeedbackChange)return e.onTestFeedbackChange({errorMessage:Kt??(De.error instanceof Error?De.error.message:De.error?"Environment test failed":null),result:De.data??null,login:rn&&f&&ke?{companyId:f,adapterType:pe,environmentId:ke}:null}),()=>{e.onTestFeedbackChange?.({errorMessage:null,result:null,login:null})}},[e.onTestFeedbackChange,Kt,De.data,De.error,rn,f,pe,ke]);const rr=a?Xe.model??"":ee("adapterConfig","model",String(le.model??"")),Wr=typeof rr=="string"?rr:"";async function xr(){if(f){Ue(!0),Tt(null);try{const et=await Vt.adapterModels(f,pe,{refresh:!0,environmentId:Ke||null,provider:ct});g.setQueryData(ze,et)}catch(et){Tt(et instanceof Error?et.message:"Failed to refresh adapter models.")}finally{Ue(!1)}}}r(xr,"handleRefreshModels");const wr=pe==="codex_local"?"modelReasoningEffort":pe==="cursor"?"mode":pe==="opencode_local"?"variant":pe==="grok_local"?"reasoningEffort":pe==="pi_local"?"thinking":"effort",ar=pe==="codex_local"?t1(Wr,"Auto").map(et=>({id:et.value,label:et.label})):pe==="cursor"?DJe:pe==="opencode_local"?LJe:pe==="kimi_local"?OJe:pe==="pi_local"?[{id:"",label:"Auto"},...["off","minimal","low","medium","high","xhigh"].map(et=>({id:et,label:et}))]:pe==="claude_local"||pe==="grok_local"?[{id:"",label:"Auto"},...M5(pe,Wr).map(et=>({id:et,label:et==="xhigh"?"X-High":et[0].toUpperCase()+et.slice(1)}))]:$Je,aa=a?Xe.thinkingEffort:pe==="codex_local"?ee("adapterConfig","modelReasoningEffort",String(le.modelReasoningEffort??le.reasoningEffort??"")):pe==="cursor"?ee("adapterConfig","mode",String(le.mode??"")):pe==="opencode_local"?ee("adapterConfig","variant",String(le.variant??"")):ee("adapterConfig",wr,String(le[wr]??"")),qn=pe!=="gemini_local"&&pe!=="cursor_cloud"&&pe!=="paperclip_runner",Rr=pe==="codex_local"?a?!!Xe.search:ee("adapterConfig","search",!!le.search):!1,Na=(0,m.useMemo)(()=>{if(a)return{heartbeat:{enabled:Xe.heartbeatEnabled,intervalSec:Xe.intervalSec}};const et={...ce.heartbeat&&typeof ce.heartbeat=="object"?ce.heartbeat:{},...$.heartbeat};return{...ce,heartbeat:et}},[a,$.heartbeat,ce,Xe]),Sn=LG(Na.heartbeat),On=LG(Sn.maxTurnContinuation),on=NRe(On.enabled,!0),mr=LT(FG(On.maxAttempts,FJe),0,KJ),bt=LT(FG(On.delayMs,BJe*1e3)/1e3,0,Z0e);function Ls(et){X("heartbeat","maxTurnContinuation",{...On,...et})}r(Ls,"updateMaxTurnContinuation");const Fs=(0,t.jsx)(Tv,{ref:v,onDirtyChange:se,hideDraftActions:!a&&e.hideInlineSave,value:a?Xe.envBindings??Kk:ee("adapterConfig","env",le.env??Kk),secrets:w,userSecretDefinitions:k,onCreateSecret:r(async(et,Gt)=>await U.mutateAsync({name:et,value:Gt}),"onCreateSecret"),onChange:r(et=>a?ue({envBindings:et??{},envVars:""}):X("adapterConfig","env",et),"onChange")},Z);return!a&&e.content==="secrets"?(0,t.jsxs)("div",{className:W("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:W(!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:W(i?"rounded-lg border border-border p-4":"px-4 pb-3"),children:Fs})]}),(0,t.jsxs)("div",{"data-config-section":"secrets",className:W(!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:W(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:gi.secretAccess}),(0,t.jsx)(yJe,{config:{...le,...$.adapterConfig},secrets:w,onChange:fe,onCreateSecret:r((et,Gt)=>U.mutateAsync({name:et,value:Gt}),"onCreateSecret"),proposals:_,onApproveProposal:I.requestApprove,onRejectProposal:I.requestReject}),I.dialogs]})]})]}):(0,t.jsxs)(zJe,{order:e.sectionOrder,className:W("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:W(!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:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[(0,t.jsx)(ys,{label:"Name",hint:gi.name,children:(0,t.jsx)(qa,{value:ee("identity","name",e.agent.name),onCommit:r(et=>X("identity","name",et),"onCommit"),immediate:!0,className:_m,placeholder:"Agent name"})}),(0,t.jsx)(ys,{label:"Title",hint:gi.title,children:(0,t.jsx)(qa,{value:ee("identity","title",e.agent.title??""),onCommit:r(et=>X("identity","title",et||null),"onCommit"),immediate:!0,className:_m,placeholder:"e.g. VP of Engineering"})}),(0,t.jsx)(ys,{label:"Reports to",hint:gi.reportsTo,children:(0,t.jsx)(EXe,{agents:we,value:ee("identity","reportsTo",e.agent.reportsTo??null),onChange:r(et=>X("identity","reportsTo",et),"onChange"),excludeAgentIds:[e.agent.id],chooseLabel:"Choose manager…"})}),ge&&!e.hidePromptTemplate&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ys,{label:"Prompt Template",hint:gi.promptTemplate,children:(0,t.jsx)(Ic,{value:ee("adapterConfig","promptTemplate",String(le.promptTemplate??"")),onChange:r(et=>X("adapterConfig","promptTemplate",et??""),"onChange"),placeholder:"You are agent {{ agent.name }}. Your role is {{ agent.role }}...",contentClassName:"min-h-(--sz-88px) text-sm font-mono",imageUploadHandler:r(async et=>{const Gt=`agents/${e.agent.id}/prompt-template`;return(await z.mutateAsync({file:et,namespace:Gt})).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:W(!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:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(ys,{label:"Default environment",hint:"This instance runs all agents in the Kubernetes sandbox. Local execution is disabled.",children:B?(0,t.jsxs)("div",{className:W(_m,"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."})})})]}):fs?(0,t.jsxs)("div",{"data-config-section":"environment",className:W(!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:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(ys,{label:"Environment override",children:(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsxs)("select",{className:_m,value:Ke,onChange:r(et=>{const Gt=et.target.value;if(a){ue({defaultEnvironmentId:Gt});return}X("identity","defaultEnvironmentId",Gt||null)},"onChange"),children:[(0,t.jsxs)("option",{value:"",children:["Default: ",We]}),Jt.map(et=>(0,t.jsx)("option",{value:et.id,children:aN(et)},et.id))]})})})})]}):null,(0,t.jsxs)("div",{"data-config-section":"adapter",className:W(!i&&(a?"border-t border-border":"border-b border-border")),children:[(0,t.jsxs)("div",{className:W(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:nr,disabled:Vs,children:Ze?`${Ft}...`:Ft})]}),(0,t.jsxs)("div",{className:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[o&&(0,t.jsx)(ys,{label:"Adapter type",hint:gi.adapterType,children:(0,t.jsx)(sbe,{value:pe,disabledTypes:T,onChange:r(et=>{if(a){const{adapterType:Gt,...mn}=j0,Os={...mn,adapterType:et};et==="codex_local"?Os.dangerouslyBypassSandbox=!0:et==="gemini_local"?Os.model="auto":et==="kimi_local"?Os.model="kimi-code/kimi-for-coding":et==="cursor"?Os.model="auto":et==="opencode_local"?Os.model="openai/gpt-5.2-codex":et==="paperclip_runner"&&(Os.model=Xw),ue(Os)}else K(Gt=>({...Gt,adapterType:et,adapterConfig:{model:et==="gemini_local"?"auto":et==="kimi_local"?"kimi-code/kimi-for-coding":et==="opencode_local"?"openai/gpt-5.2-codex":et==="cursor"?"auto":et==="paperclip_runner"?RJe(pe,le.model):"",effort:"",modelReasoningEffort:"",variant:"",mode:"",...et==="codex_local"?{dangerouslyBypassApprovalsAndSandbox:!0}:et==="paperclip_runner"?{...Rfe(pe,ee("adapterConfig","model",le.model))}:{}}}))},"onChange")})}),!a&&f&&(0,t.jsx)(Qge,{companyId:f,agentId:e.agent.id,agentName:e.agent.name,adapterType:pe==="paperclip_runner"?ee("adapterConfig","provider",le.provider)==="codex"?"codex_local":ee("adapterConfig","provider",le.provider)==="opencode"?"opencode_local":ee("adapterConfig","provider",le.provider)==="acpx"&&ee("adapterConfig","acpxAgent",le.acpxAgent)==="claude"?"claude_local":pe:pe,value:cT.safeParse($.runtime.runtimeConfig?.aiConnection??ce.aiConnection).data,model:String(ee("adapterConfig","model",le.model)??""),environmentId:Ke||void 0,legacy:!0,onChange:r(et=>X("runtime","runtimeConfig",{...ce,aiConnection:et}),"onChange")}),d&&!e.compactTestFeedback&&(Kt||De.error)&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:Kt??(De.error instanceof Error?De.error.message:"Environment test failed")}),d&&!e.compactTestFeedback&&De.data&&(0,t.jsx)(QJe,{result:De.data}),d&&rn&&(0,t.jsx)(Q8,{companyId:f,adapterType:pe,environmentId:ke,onStored:a?dt:xt,onApplyStored:a?Ge:ht,onAccountBinding:a?void 0:Le},`${pe}:${ke}`),Ie&&(0,t.jsx)(ys,{label:"Working directory (deprecated)",hint:gi.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)(Ao,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)(qa,{value:a?Xe.cwd:ee("adapterConfig","cwd",String(le.cwd??"")),onCommit:r(et=>a?ue({cwd:et}):X("adapterConfig","cwd",et||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)(yd,{})]})}),xs("adapter"),ge&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y8,{models:pt,value:Wr,onChange:r(et=>{const Gt=M5(pe,et),mn=["codex_local","claude_local","grok_local"].includes(pe)&&!!aa&&!Gt.includes(String(aa));if(a){ue({model:et,...mn?{thinkingEffort:""}:{}});return}X("adapterConfig","model",et||void 0),mn&&(X("adapterConfig",wr,void 0),X("adapterConfig","reasoningEffort",void 0))},"onChange"),open:bs,onOpenChange:qe,defaultLabel:pe==="claude_local"?"Default (claude-opus-5)":void 0,allowDefault:pe!=="opencode_local"&&pe!=="pi_local"&&pe!=="paperclip_runner",required:pe==="opencode_local"||pe==="pi_local",groupByProvider:pe==="opencode_local"||pe==="pi_local",creatable:!0,detectedModel:Ct,detectedModelCandidates:[],onDetectModel:pe==="opencode_local"||pe==="paperclip_runner"?void 0:async()=>(await Rs()).data?.model??null,onRefreshModels:TJe(pe)?xr:void 0,refreshingModels:Ms,detectModelLabel:"Detect model",emptyDetectHint:"No model detected. Select or enter one manually."}),(Qt||Fe)&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:Qt??(Fe instanceof Error?Fe.message:"Failed to load adapter models.")}),pe==="opencode_local"&>&>.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 ",gt.name,"."]}),qn&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(YJe,{value:aa,options:ar,onChange:r(et=>a?ue({thinkingEffort:et}):X("adapterConfig",wr,et||void 0),"onChange"),open:Nt,onOpenChange:St}),pe==="codex_local"&&Rr&&aa==="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:W(!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:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[!a&&typeof le.bootstrapPromptTemplate=="string"&&le.bootstrapPromptTemplate&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ys,{label:"Bootstrap prompt (legacy)",hint:gi.bootstrapPrompt,children:(0,t.jsx)(Ic,{value:ee("adapterConfig","bootstrapPromptTemplate",String(le.bootstrapPromptTemplate??"")),onChange:r(et=>X("adapterConfig","bootstrapPromptTemplate",et||void 0),"onChange"),placeholder:"Optional initial setup prompt for the first run",contentClassName:"min-h-(--sz-44px) text-sm font-mono",imageUploadHandler:r(async et=>{const Gt=`agents/${e.agent.id}/bootstrap-prompt`;return(await z.mutateAsync({file:et,namespace:Gt})).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."})]}),xs("configuration"),(ge||pe==="process"||dn?.fields.some(et=>FB(et.key)==="advanced"))&&(0,t.jsx)(IT,{title:"Advanced",open:ft,onToggle:r(()=>us(!ft),"onToggle"),children:(0,t.jsxs)("div",{className:"space-y-3",children:[ge&&(0,t.jsxs)(t.Fragment,{children:[" ",!L&&(0,t.jsx)(ys,{label:"Command",hint:gi.localCommand,children:(0,t.jsx)(qa,{value:a?Xe.command:ee("adapterConfig",$t,String(le.command??"")),onCommit:r(et=>a?ue({command:et}):X("adapterConfig",$t,et||null),"onCommit"),immediate:!0,className:_m,placeholder:{claude_local:"claude",codex_local:"codex",gemini_local:"gemini",kimi_local:"kimi",pi_local:"pi",cursor:"agent",opencode_local:"opencode"}[pe]??pe.replace(/_local$/,"")})}),(0,t.jsx)(ys,{label:"Extra args (comma-separated)",hint:gi.extraArgs,children:(0,t.jsx)(qa,{value:a?Xe.extraArgs:ee("adapterConfig","extraArgs",MJe(le.extraArgs)),onCommit:r(et=>a?ue({extraArgs:et}):X("adapterConfig","extraArgs",et?.trim()?PJe(et):null),"onCommit"),className:_m,placeholder:"e.g. --verbose, --foo=bar"})})]}),xs("advanced")]})})]})]}),e.environmentVariablesPlacement!=="secrets"&&(ge||dn?.fields.some(et=>FB(et.key)==="environment"))&&(0,t.jsxs)("div",{"data-config-section":"environment-variables",className:W(!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:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:ge?Fs:xs("environment")})]}),a&&u?(0,t.jsxs)("div",{"data-config-section":"run-policy",className:W(!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)(YI,{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)(YI,{className:"h-3 w-3"})," Run Policy"]}),(0,t.jsxs)("div",{className:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[(0,t.jsx)(iJ,{label:"Heartbeat on interval",hint:gi.heartbeatInterval,checked:Xe.heartbeatEnabled,onCheckedChange:r(et=>ue({heartbeatEnabled:et}),"onCheckedChange"),number:Xe.intervalSec,onNumberChange:r(et=>ue({intervalSec:et}),"onNumberChange"),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:gi.intervalSec,showNumber:Xe.heartbeatEnabled}),(0,t.jsx)(IT,{title:"Advanced Run Policy",open:lt,onToggle:r(()=>Ot(!lt),"onToggle"),children:(0,t.jsx)("div",{className:"space-y-3",children:xs("runPolicy")})})]})]}):a?null:(0,t.jsxs)("div",{"data-config-section":"run-policy",className:W(!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)(YI,{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)(YI,{className:"h-3 w-3"})," Run Policy"]}),(0,t.jsxs)("div",{className:W(i?"border border-border rounded-lg overflow-hidden":""),children:[(0,t.jsx)("div",{className:W(i?"p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(iJ,{label:"Heartbeat on interval",hint:gi.heartbeatInterval,checked:ee("heartbeat","enabled",he.enabled===!0),onCheckedChange:r(et=>X("heartbeat","enabled",et),"onCheckedChange"),number:ee("heartbeat","intervalSec",Number(he.intervalSec??300)),onNumberChange:r(et=>X("heartbeat","intervalSec",et),"onNumberChange"),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:gi.intervalSec,showNumber:ee("heartbeat","enabled",he.enabled===!0)})}),(0,t.jsx)(IT,{title:"Advanced Run Policy",bordered:i,open:lt,onToggle:r(()=>Ot(!lt),"onToggle"),children:(0,t.jsxs)("div",{className:"space-y-3",children:[xs("runPolicy"),ge&&(0,t.jsx)(t.Fragment,{children:!a&&(0,t.jsxs)(t.Fragment,{children:[!dn?.fields.some(et=>et.key==="timeoutSec")&&(0,t.jsx)(ys,{label:"Timeout (sec)",hint:gi.timeoutSec,children:(0,t.jsx)(ic,{value:ee("adapterConfig","timeoutSec",Number(le.timeoutSec??0)),onCommit:r(et=>X("adapterConfig","timeoutSec",et),"onCommit"),immediate:!0,className:_m})}),!dn?.fields.some(et=>et.key==="graceSec")&&(0,t.jsx)(ys,{label:"Interrupt grace period (sec)",hint:gi.graceSec,children:(0,t.jsx)(ic,{value:ee("adapterConfig","graceSec",Number(le.graceSec??15)),onCommit:r(et=>X("adapterConfig","graceSec",et),"onCommit"),immediate:!0,className:_m})})]})}),(0,t.jsx)(md,{label:"Wake on demand",hint:gi.wakeOnDemand,checked:ee("heartbeat","wakeOnDemand",he.wakeOnDemand!==!1),onChange:r(et=>X("heartbeat","wakeOnDemand",et),"onChange")}),(0,t.jsx)(ys,{label:"Cooldown (sec)",hint:gi.cooldownSec,children:(0,t.jsx)(ic,{value:ee("heartbeat","cooldownSec",Number(he.cooldownSec??10)),onCommit:r(et=>X("heartbeat","cooldownSec",et),"onCommit"),immediate:!0,className:_m})}),(0,t.jsx)(ys,{label:"Max concurrent runs",hint:gi.maxConcurrentRuns,children:(0,t.jsx)(ic,{value:ee("heartbeat","maxConcurrentRuns",Number(he.maxConcurrentRuns??20)),onCommit:r(et=>X("heartbeat","maxConcurrentRuns",et),"onCommit"),immediate:!0,className:_m})}),(0,t.jsxs)("div",{className:"rounded-md border border-border/70 px-3 py-2",children:[(0,t.jsx)(md,{label:"Continue after max-turn stop",hint:gi.maxTurnContinuationEnabled,checked:on,onChange:r(et=>Ls({enabled:et}),"onChange")}),on?(0,t.jsxs)("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[(0,t.jsx)(ys,{label:"Continuation attempts",hint:gi.maxTurnContinuationMaxAttempts,children:(0,t.jsx)(ic,{value:mr,onCommit:r(et=>Ls({maxAttempts:LT(et,0,KJ)}),"onCommit"),immediate:!0,className:_m})}),(0,t.jsx)(ys,{label:"Continuation delay (sec)",hint:gi.maxTurnContinuationDelaySec,children:(0,t.jsx)(ic,{value:bt,onCommit:r(et=>Ls({delayMs:qJe(et)}),"onCommit"),immediate:!0,className:_m})})]}):null]})]})})]})]}),!a&&p?(0,t.jsxs)("div",{className:W(!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)(cw,{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)(cw,{className:"h-3 w-3"})," Debugging"]}),(0,t.jsxs)("div",{className:W("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)(md,{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:ee("debug","providerTrace",ve.providerTrace)==="raw",onChange:r(et=>X("debug","providerTrace",et?"raw":void 0),"onChange")}),ee("debug","providerTrace",ve.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)(cw,{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)(Zge,{state:Ze?"running":Kt||De.error?"fail":Us?.status??"idle",result:Us??null,error:Kt??(De.error instanceof Error?De.error.message:null),onTest:nr,disabled:Vs})]})}r(ebe,"AgentConfigForm");var s6=new Set(["authenticated","failed","timed_out","cancelled"]),n6=2e3;function r6({value:e,label:s}){const[n,a]=(0,m.useState)(!1),i=(0,m.useRef)(null);return(0,m.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 Xr(e),a(!0)}catch{a(!1)}i.current&&clearTimeout(i.current),i.current=setTimeout(()=>a(!1),1500)},"onClick"),children:n?(0,t.jsx)(ds,{className:"size-3"}):(0,t.jsx)(kr,{className:"size-3"})})}r(r6,"AdapterLoginCopyButton");function UJe({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)(ds,{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)(_s,{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(UJe,"AdapterLoginTerminalState");var KJe={claude_local:"Anthropic",codex_local:"OpenAI"};function tbe(e){const s=KJe[e];return s?`Sign in to ${s}`:"Sign in to the environment"}r(tbe,"adapterLoginTitle");function Q8(e){return ey()(e.adapterType).login?.panelMode==="submitted_browser_code"?(0,t.jsx)(GJe,{...e}):(0,t.jsx)(WJe,{...e})}r(Q8,"AdapterLoginPanel");function WJe({companyId:e,adapterType:s,environmentId:n,autoStart:a,onConnected:i,onAccountBinding:o,chrome:l="panel",aiConnection:c,onPromptReady:d}){const[u,h]=(0,m.useState)(null),[p,f]=(0,m.useState)(null),[g,v]=(0,m.useState)(null),[y,w]=(0,m.useState)("idle"),k=(0,m.useRef)(!1),j=Ne({mutationFn:r(()=>Vt.startAdapterAuthLogin(e,s,{environmentId:n,aiConnection:c}),"mutationFn"),onSuccess:r(Y=>{k.current=!1,f(null),v(null),w("idle"),h(Y.sessionId)},"onSuccess"),onError:r(Y=>{f(Y instanceof Error?Y.message:"Could not start the login.")},"onError")}),N=(0,m.useCallback)(()=>{k.current=!1,h(null),v(null),f(null)},[]),_=Ne({mutationFn:r(()=>Vt.cancelAdapterAuthLogin(e,s,u),"mutationFn"),onSuccess:N,onError:r(Y=>{f(Y instanceof Error?Y.message:"Could not cancel the login.")},"onError")}),I=J({queryKey:["adapter-login-active-session",e,s],queryFn:r(async()=>{try{const Y=await Vt.getActiveAdapterAuthLoginSession(e,s);if(!Y)return null;if(c&&Y.environmentId!==n||!!Y.aiConnection!=!!c||c&&(Y.aiConnection?.provider!==c.provider||Y.aiConnection?.method!==c.method||Y.aiConnection?.connectionId!==c.connectionId||Y.aiConnection?.ownership!==c.ownership||Y.aiConnection?.allAgents!==c.allAgents||JSON.stringify(Y.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 Y}catch(Y){if(Y instanceof cn&&Y.status===404)return null;throw Y}},"queryFn"),retry:!1,gcTime:0,staleTime:0}),[C,T]=(0,m.useState)(!1),R=J({queryKey:["adapter-login-status",e,s,u],queryFn:r(()=>Vt.getAdapterAuthLoginStatus(e,s,u),"queryFn"),enabled:!!u&&!C,retry:r((Y,ne)=>ne instanceof cn&&ne.status===404?!1:Y<3,"retry"),refetchInterval:r(Y=>{const ne=Y.state.data?.status;return ne&&s6.has(ne)?!1:n6},"refetchInterval")});(0,m.useEffect)(()=>{const Y=R.data?.prompt??null;Y&&v(Y)},[R.data]);const A=R.data??j.data??null,L=A?.status??null,D=g,O=L?s6.has(L):!1,E=!!u&&!O,q=j.isPending||E||y==="saving",B=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(B.current||!I.isFetched)return;B.current=!0;const Y=I.data;Y&&(k.current=!0,f(null),v(Y.prompt??null),h(Y.sessionId))},[I.isFetched,I.data]),(0,m.useEffect)(()=>{const Y=R.error;if(!(Y instanceof cn&&Y.status===404)||!k.current||C)return;T(!0);const ne=u;(async()=>(ne&&await Vt.cancelAdapterAuthLogin(e,s,ne).catch(()=>{}),T(!1),N()))()},[R.error,C,u,e,s,N]);const U=(0,m.useRef)(!1),z=(0,m.useRef)(j.mutate);z.current=j.mutate,(0,m.useEffect)(()=>{if(!(!a||U.current)){if(I.isError){U.current=!0,f(I.error instanceof Error?I.error.message:"Could not check for an active login.");return}I.isSuccess&&(U.current=!0,!I.data&&z.current())}},[a,I.isSuccess,I.isError,I.data,I.error]);const $=(0,m.useRef)(!1),K=(0,m.useRef)(i);K.current=i,(0,m.useEffect)(()=>{L!=="authenticated"||$.current||($.current=!0,K.current?.(u??void 0))},[L]);const H=(0,m.useRef)(null),se=(0,m.useRef)(o);se.current=o;const Z=R.data?.codexAccountBinding??null,ie=(0,m.useCallback)(async Y=>{const ne=se.current;if(ne){w("saving");try{await ne(Y),w("bound")}catch{w("failed")}}},[]);(0,m.useEffect)(()=>{L!=="authenticated"||!u||H.current!==u&&(!Z||!Z.companyIdentityDiffers||!se.current||(H.current=u,ie(Z)))},[L,u,Z,ie]);const oe=(0,m.useRef)(d);if(oe.current=d,(0,m.useEffect)(()=>{oe.current?.(D?.url??null)},[D]),l==="onboarding"){const Y=O&&L&&L!=="authenticated";return(0,t.jsx)(d0e,{loading:!D&&!p&&!Y,providerName:l0e(s),authorizationUrl:D?.url,mode:"displayed_code",children:p?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:p}):Y?(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)(UHe,{code:D?.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:tbe(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&&!D&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(rt,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Preparing..."})]}),E&&D&&(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:D.code})]}),(0,t.jsx)(r6,{value:D.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:D.url})]}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(r6,{value:D.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:D.url,target:"_blank",rel:"noreferrer noopener",children:(0,t.jsx)(gr,{className:"size-3"})})})]})]})]}),O&&L&&(0,t.jsx)(UJe,{status:L,message:A?.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)(rt,{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)(ds,{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)(_s,{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(()=>{Z&&ie(Z)},"onClick"),children:"Retry"})]})]})]})}r(WJe,"DisplayedCodeLoginPanel");var VJe=new Set(["failed","timed_out","cancelled"]),WJ="The login did not finish. Start the login again.",HJe=9e5,VJ="The login timed out. Start the login again.";function GJe({companyId:e,adapterType:s,environmentId:n,onStored:a,onApplyStored:i,autoStart:o,onConnected:l,onCodeSubmitted:c,onSubmitFailed:d,chrome:u="panel",aiConnection:h,onPromptReady:p}){const[f,g]=(0,m.useState)(null),[v,y]=(0,m.useState)(null),[w,k]=(0,m.useState)(null),[j,N]=(0,m.useState)(!1),[_,I]=(0,m.useState)(""),[C,T]=(0,m.useState)(null),[R,A]=(0,m.useState)(!1),[L,D]=(0,m.useState)(!1),[O,E]=(0,m.useState)(!1),[q,B]=(0,m.useState)(!1),U=(0,m.useRef)(!1),[z,$]=(0,m.useState)(!1),K=(0,m.useRef)(!1),H=r(()=>{y(null),k(null),N(!1),I(""),T(null),A(!1),D(!1),B(!1),E(!1),U.current=!1},"resetLocalState"),se=J({queryKey:["claude-oauth-token-status",e],queryFn:r(async()=>{try{return await Vt.getClaudeOAuthTokenStatus(e)}catch(tt){if(tt instanceof cn&&tt.status===404)return null;throw tt}},"queryFn"),retry:r((tt,Se)=>Se instanceof cn&&Se.status===404?!1:tt<2,"retry")}).data??null,Z=Ne({mutationFn:r(()=>Vt.startClaudeSetupTokenLogin(e,{environmentId:n,aiConnection:h,...se&&!h?{overwrite:{expectedSecretId:se.secretId,expectedLatestVersion:se.latestVersion}}:{}}),"mutationFn"),onSuccess:r(tt=>{K.current=!1,H(),g(tt.sessionId)},"onSuccess"),onError:r(tt=>{y(tt instanceof Error?tt.message:"Could not start the login.")},"onError")}),ie=r(()=>{K.current=!1,g(null),H()},"clearActiveSession"),oe=Ne({mutationFn:r(()=>Vt.cancelClaudeSetupTokenLogin(e,f),"mutationFn"),onSuccess:r(()=>{ie()},"onSuccess"),onError:r(tt=>{if(tt instanceof cn&&tt.status===404){ie();return}y(tt instanceof Error?tt.message:"Could not cancel the login.")},"onError")}),Y=(0,m.useCallback)(tt=>{Vt.cancelClaudeSetupTokenLogin(e,tt).catch(()=>{})},[e]),ne=J({queryKey:["claude-setup-token-active-session",e],queryFn:r(async()=>{try{const tt=await Vt.getActiveClaudeSetupTokenLoginSession(e);if(!tt)return null;if(h&&tt.environmentId!==n||!!tt.aiConnection!=!!h||h&&(tt.aiConnection?.provider!==h.provider||tt.aiConnection?.method!==h.method||tt.aiConnection?.connectionId!==h.connectionId||tt.aiConnection?.ownership!==h.ownership||tt.aiConnection?.allAgents!==h.allAgents||JSON.stringify(tt.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 tt}catch(tt){if(tt instanceof cn&&tt.status===404)return null;throw tt}},"queryFn"),retry:!1,gcTime:0,staleTime:0}),[de,ee]=(0,m.useState)(!1),X=!!f&&!L&&!q&&!de,Q=J({queryKey:["claude-setup-token-status",e,f],queryFn:r(()=>Vt.getClaudeSetupTokenLoginStatus(e,f),"queryFn"),enabled:X,retry:r((tt,Se)=>Se instanceof cn&&Se.status===404?!1:tt<3,"retry"),refetchInterval:r(tt=>{if(L||q)return!1;const Se=tt.state.data?.status;return Se&&s6.has(Se)?!1:n6},"refetchInterval")});(0,m.useEffect)(()=>{const tt=Q.error;if(tt instanceof cn&&tt.status===404){if(K.current){if(de)return;ee(!0);const Se=f;(async()=>(Se&&await Vt.cancelClaudeSetupTokenLogin(e,Se).catch(()=>{}),ee(!1),ie()))();return}B(!0)}},[Q.error,de,f,e]);const fe=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(fe.current||!ne.isFetched)return;fe.current=!0;const tt=ne.data;tt&&(K.current=!0,H(),g(tt.sessionId),tt.prompt&&(k(tt.prompt.authorizationUrl),tt.prompt.transportAdvisory&&N(!0)))},[ne.isFetched,ne.data]);const te=J({queryKey:["claude-setup-token-prompt",e,f],enabled:X&&!w,queryFn:r(async()=>{try{return await Vt.getClaudeSetupTokenLoginPrompt(e,f)}catch(tt){if(tt instanceof cn&&tt.status===404)return null;throw tt}},"queryFn"),refetchInterval:r(tt=>L||tt.state.data?.authorizationUrl?!1:n6,"refetchInterval")});(0,m.useEffect)(()=>{const tt=te.data?.authorizationUrl??null;tt&&k(tt),te.data?.transportAdvisory&&N(!0)},[te.data]);const ae=Ne({mutationFn:r(tt=>Vt.submitClaudeSetupTokenBrowserCode(e,f,tt),"mutationFn"),onError:r(tt=>{y(tt instanceof Error?tt.message:"Could not submit the browser code.")},"onError")}),le=Ne({mutationFn:r(()=>Vt.completeClaudeSetupTokenLogin(e,f),"mutationFn"),onSuccess:r(tt=>{T(tt.storedSessionId),a?.(tt.storedSessionId)},"onSuccess"),onError:r(()=>{A(!0)},"onError")}),ce=Q.data?.status??Z.data?.status??null,he=Q.data?.expiresAt??Z.data?.expiresAt??null,ve=(0,m.useRef)(le.mutate);ve.current=le.mutate,(0,m.useEffect)(()=>{ce==="authenticated"&&!U.current&&(U.current=!0,ve.current())},[ce]);const pe=C!==null,xe=R||q||!!(ce&&VJe.has(ce)),_e=ce==="authenticated"&&!pe&&!R,ge=!!f&&!pe&&!xe&&!L,Ie=Z.isPending||ge;(0,m.useEffect)(()=>{if(!ge)return;const tt=he!==null?new Date(he).getTime():NaN,Se=Number.isFinite(tt)?Math.max(0,tt-Date.now()):HJe,ke=setTimeout(()=>{f&&Y(f),D(!0)},Se);return()=>clearTimeout(ke)},[ge,he,f,Y]);const Ye=_.trim(),$e=ge&&!!w&&!_e&&cRe(Ye)&&!ae.isPending&&!O,Xe=(0,m.useRef)(c);Xe.current=c;const ue=(0,m.useRef)(d);ue.current=d;const Oe=r(()=>{$e&&(y(null),ae.mutate(Ye),E(!0),Xe.current?.(),u!=="onboarding"&&I(""))},"handleSubmit"),dt=(0,m.useRef)(!1),xt=(0,m.useRef)(Z.mutate);xt.current=Z.mutate,(0,m.useEffect)(()=>{if(!(!o||dt.current)){if(ne.isError){dt.current=!0,y(ne.error instanceof Error?ne.error.message:"Could not check for an active login.");return}ne.isSuccess&&(dt.current=!0,!ne.data&&xt.current())}},[o,ne.isSuccess,ne.isError,ne.data,ne.error]);const Le=(0,m.useRef)(Oe);Le.current=Oe;const Ge=u==="onboarding",ht=(0,m.useRef)(!1);(0,m.useEffect)(()=>{!Ge||!ht.current||(ht.current=!1,$e&&Le.current())},[Ge,$e,_]);const Ve=(0,m.useRef)(!1),Ke=(0,m.useRef)(l);Ke.current=l,(0,m.useEffect)(()=>{!pe||Ve.current||(Ve.current=!0,Ke.current?.(f??void 0))},[pe]),(0,m.useEffect)(()=>{O&&(!v&&!xe&&!L||(E(!1),ue.current?.()))},[O,v,xe,L]);const gt=(0,m.useRef)(p);if(gt.current=p,(0,m.useEffect)(()=>{gt.current?.(w)},[w]),u==="onboarding"){const tt=xe||L;return(0,t.jsxs)(d0e,{loading:!w&&!v&&!tt,providerName:l0e(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)(_s,{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}):tt?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:L&&!xe?VJ:WJ}):(0,t.jsx)(cP,{value:_,onChange:I,onSubmit:Oe,onPaste:r(()=>{ht.current=!0},"onPaste"),masked:!0,disabled:ae.isPending||_e||O})]})}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:tbe(s)}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[ge&&(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:oe.isPending,onClick:r(()=>oe.mutate(),"onClick"),children:"Cancel"}),i&&se&&!ge&&!pe&&!z&&(0,t.jsx)(F,{type:"button",variant:"default",size:"sm",className:"h-7 px-2.5 text-xs",onClick:r(()=>{i(),$(!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:Ie,onClick:r(()=>Z.mutate(),"onClick"),children:se&&!ge&&!pe?"Sign in to replace":"Sign in"})]})]}),se&&!ge&&!pe&&!z&&(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."}),z&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(ds,{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:[ge&&!w&&!_e&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(rt,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Preparing..."})]}),ge&&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)(_s,{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)(r6,{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)(gr,{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(tt=>I(tt.target.value),"onChange"),onKeyDown:r(tt=>{tt.key==="Enter"&&(tt.preventDefault(),Oe())},"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:!$e,onClick:Oe,children:"Submit"})]})]})]}),_e&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(rt,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Completing the login…"})]}),pe&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(ds,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Authenticated. The environment has credentials now."})]}),xe&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(_s,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:WJ})]}),L&&!xe&&!pe&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(_s,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:VJ})]})]})]})}r(GJe,"SubmittedBrowserCodeLoginPanel");function QJe({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(QJe,"AdapterEnvironmentResult$1");function sbe({value:e,onChange:s,disabledTypes:n}){const[a,i]=(0,m.useState)(!1),o=Jm(e),l=(0,m.useMemo)(()=>X0e(c=>eN[c]??kf(c)).filter(c=>!n.has(c.value)),[n]);return(0,t.jsxs)(tr,{open:a,onOpenChange:i,children:[(0,t.jsx)(pr,{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)(BB,{className:"h-3.5 w-3.5"}):null,(0,t.jsx)("span",{className:"truncate",children:eN[e]??kf(e)}),o.experimental&&(0,t.jsx)(HJ,{})]}),(0,t.jsx)(sn,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsx)(Qn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:l.map(c=>(0,t.jsxs)("button",{disabled:c.comingSoon,className:W("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)(BB,{className:"h-3.5 w-3.5"}):null,(0,t.jsx)("span",{children:c.label}),c.experimental&&(0,t.jsx)(HJ,{})]}),c.comingSoon&&(0,t.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground",children:"Coming soon"})]},c.value))})]})}r(sbe,"AdapterTypeDropdown");function HJ(){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(HJ,"ExperimentalBadge$1");function Y8({models:e,value:s,onChange:n,open:a,onOpenChange:i,allowDefault:o,required:l,groupByProvider:c,creatable:d,detectedModel:u,detectedModelCandidates:h,onDetectModel:p,onRefreshModels:f,refreshingModels:g,detectModelLabel:v,emptyDetectHint:y,defaultLabel:w}){const[k,j]=(0,m.useState)(""),[N,_]=(0,m.useState)(!1),I=e.find(O=>O.id===s),C=k.trim(),T=!!(d&&C&&!e.some(O=>O.id.toLowerCase()===C.toLowerCase())),R=(0,m.useMemo)(()=>{const O=new Set;u&&O.add(u);for(const E of h??[])E&&O.add(E);return O},[u,h]),A=(0,m.useMemo)(()=>e.filter(O=>{if(R.has(O.id))return!1;if(!k.trim())return!0;const E=k.toLowerCase(),q=lB(O.id)??"";return O.id.toLowerCase().includes(E)||O.label.toLowerCase().includes(E)||q.toLowerCase().includes(E)}),[e,k,R]),L=(0,m.useMemo)(()=>{if(!c)return[{provider:"models",entries:[...A].sort((E,q)=>E.id.localeCompare(q.id))}];const O=new Map;for(const E of A){const q=lB(E.id)??"other",B=O.get(q)??[];B.push(E),O.set(q,B)}return Array.from(O.entries()).sort(([E],[q])=>E.localeCompare(q)).map(([E,q])=>({provider:E,entries:[...q].sort((B,U)=>B.id.localeCompare(U.id))}))},[A,c]);async function D(){if(p){_(!0);try{const O=await p();O&&(n(O),i(!1),j(""))}finally{_(!1)}}}return r(D,"handleDetectModel"),(0,t.jsx)(ys,{label:"Model",hint:gi.model,children:(0,t.jsxs)(tr,{open:a,onOpenChange:r(O=>{i(O),O||j("")},"onOpenChange"),children:[(0,t.jsx)(pr,{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:W(!s&&"text-muted-foreground"),children:I?I.label:s||(o?w??"Default":l?"Select model (required)":"Select model")}),(0,t.jsx)(sn,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsxs)(Qn,{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:k,onChange:r(O=>j(O.target.value),"onChange"),autoFocus:!0}),k&&(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&&!k.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(()=>{D()},"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...":u?v?.replace(/^Detect\b/,"Re-detect")??"Re-detect from config":v??"Detect from config"]}),f&&!k.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(O=>O.id===s)||R.has(s))&&(0,t.jsxs)("button",{type:"button",className:W("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(O=>O.id===s)?.label??s}),(0,t.jsx)(ot,{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"})]}),u&&u!==s&&(0,t.jsxs)("button",{type:"button",className:W("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50"),onClick:r(()=>{n(u),i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:u,children:e.find(O=>O.id===u)?.label??u}),(0,t.jsx)(ot,{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(O=>O&&O!==u&&O!==s).map(O=>{const E=e.find(q=>q.id===O);return(0,t.jsxs)("button",{type:"button",className:W("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50"),onClick:r(()=>{n(O),i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:O,children:E?.label??O}),(0,t.jsx)(ot,{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-${O}`)}),(0,t.jsxs)("div",{className:"max-h-(--sz-240px) overflow-y-auto",children:[o&&(0,t.jsx)("button",{type:"button",className:W("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"}),T&&(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(O=>(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:[O.provider," (",O.entries.length,")"]}),O.entries.map(E=>(0,t.jsx)("button",{type:"button",className:W("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?PUe(E.id):E.label})},E.id))]},O.provider)),A.length===0&&!T&&R.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(Y8,"ModelDropdown");function YJe({value:e,options:s,onChange:n,open:a,onOpenChange:i}){const o=s.find(l=>l.id===e)??s[0];return(0,t.jsx)(ys,{label:"Thinking effort",hint:gi.thinkingEffort,children:(0,t.jsxs)(tr,{open:a,onOpenChange:i,children:[(0,t.jsx)(pr,{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:W(!e&&"text-muted-foreground"),children:o?.label??"Auto"}),(0,t.jsx)(sn,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsx)(Qn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:s.map(l=>(0,t.jsxs)("button",{className:W("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(YJe,"ThinkingEffortDropdown");function nbe(e){const s=`paperclip.agent-appearance.${e}`;function n(){try{const l=aue.safeParse(JSON.parse(sessionStorage.getItem(s)??"null"));if(l.success)return l.data}catch{}const o=dT();try{sessionStorage.setItem(s,JSON.stringify(o))}catch{}return o}r(n,"readDraft");const[a,i]=(0,m.useState)(()=>({key:s,appearance:n()}));return a.key!==s&&i({key:s,appearance:n()}),{appearance:a.appearance,clear(){try{sessionStorage.removeItem(s)}catch{}}}}r(nbe,"useAgentAppearanceDraft");var Wk=null,pA=new Set,Vk={subscribe(e){return pA.add(e),()=>{pA.delete(e)}},getSnapshot(){return Wk},acquire(e){if(Wk)return!1;Wk=e;for(const s of pA)s();return!0},release(e){if(Wk===e){Wk=null;for(const s of pA)s()}}};function u1({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:u=!0,className:h,label:p,name:f}){const g=(0,m.useMemo)(()=>kN(s??e?.appearance,e?.id),[s,e?.appearance,e?.id]),v=(0,m.useRef)(null),y=(0,m.useRef)(null),w=(0,m.useRef)(null),k=(0,m.useRef)(Symbol("agent-character")),j=(0,m.useSyncExternalStore)(Vk.subscribe,Vk.getSnapshot,()=>null),[N,_]=(0,m.useState)(!1),[I,C]=(0,m.useState)(!0),[T,R]=(0,m.useState)(!1),[A,L]=(0,m.useState)(!1),D=N&&!I&&!T&&o==="auto"&&a!=="rest";return(0,m.useEffect)(()=>{if(typeof matchMedia!="function"||typeof IntersectionObserver!="function")return;const O=matchMedia("(prefers-reduced-motion: reduce)"),E=r(()=>C(O.matches),"change");E(),O.addEventListener("change",E);const q=new IntersectionObserver(B=>_(B[0]?.isIntersecting??!1));return v.current&&q.observe(v.current),()=>{q.disconnect(),O.removeEventListener("change",E)}},[]),(0,m.useEffect)(()=>{D&&j===null&&Vk.acquire(k.current),D||Vk.release(k.current)},[D,j]),(0,m.useEffect)(()=>()=>Vk.release(k.current),[]),(0,m.useEffect)(()=>{if(!D||j!==k.current)return;let O=!1;return L(!1),Promise.all([Sc(()=>import("./runtime-IAg0vdY9.js"),__vite__mapDeps([0,1])),Sc(()=>import("./definition-BlT4dP_G.js"),__vite__mapDeps([2,3,1]))]).then(([E,q])=>{O||!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:u,trackingScope:c,displaySize:n,onError:r(()=>R(!0),"onError")}),L(!0))}).catch(()=>{O||R(!0)}),()=>{O=!0,w.current?.destroy(),w.current=null,L(!1)}},[D,j,l,c,n,d,u]),(0,m.useEffect)(()=>{w.current&&Sc(()=>import("./definition-BlT4dP_G.js").then(O=>{w.current?.setDefinition(O.characterDefinition(g,i)),w.current?.setAnimation(O.animationId(a))}),__vite__mapDeps([2,3,1]))},[g,i,a,A]),(0,t.jsxs)("span",{ref:v,role:p?"img":void 0,"aria-label":p,"aria-hidden":p?void 0:!0,className:W("relative inline-block shrink-0",jEe[n],h),children:[(0,t.jsx)(yr,{agent:e,appearance:g,size:n<256?256:n,name:f,pose:a,muted:i,className:W("size-full",A&&"invisible")}),(0,t.jsx)("span",{ref:y,className:"absolute inset-0"})]})}r(u1,"AgentCharacter");var XJe=new Set(["claude_local","codex_local","opencode_local","grok_local"]);function rbe(e,{cloud:s,nativeRunnerEnabled:n}){return s?XJe.has(e):e!=="paperclip_runner"||n}r(rbe,"isNewAgentAdapterAllowed");var JJe={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 X8({type:e,className:s="size-6"}){const n=Jm(e).icon,a=JJe[e];return a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("img",{src:a.src,className:W("shrink-0 object-contain",a.dark&&"dark:hidden",s),alt:""}),a.dark&&(0,t.jsx)("img",{src:a.dark,className:W("hidden shrink-0 object-contain dark:block",s),alt:""})]}):(0,t.jsx)(n,{className:s})}r(X8,"AdapterMark");function ZJe(){const{selectedCompanyId:e}=ps(),{appearance:s}=nbe(`${e}:new-agent`);return(0,t.jsx)(u1,{appearance:s,state:"sleepy",muted:!0,size:256,className:"size-48",trackingScope:"page"})}r(ZJe,"AgentBasicsCharacter");function abe({open:e,onClose:s,onContinue:n,initialAdapter:a="",onInvite:i}){const o=(0,m.useId)(),l=!!td(),c=J({queryKey:P.instance.experimentalSettings,queryFn:Tr.getExperimental,enabled:e,retry:!1}),[d,u]=(0,m.useState)(""),[h,p]=(0,m.useState)(a),[f,g]=(0,m.useState)("codex"),[v,y]=(0,m.useState)("name"),{data:w,isPending:k,error:j}=J({queryKey:P.adapters.all,queryFn:Fm.list,enabled:e}),N=(w??[]).filter(I=>I.loaded&&!I.disabled&&rbe(I.type,{cloud:l,nativeRunnerEnabled:c.data?.enableNativeRunner===!0})&&!["process","http"].includes(I.type)&&!Jm(I.type).comingSoon),_=N.some(I=>I.type===h);return(0,t.jsx)(Qs,{open:e,onOpenChange:r(I=>{I||s()},"onOpenChange"),children:(0,t.jsxs)(Xs,{className:W("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:W(v==="name"&&"font-medium text-foreground"),children:"1. Name"}),(0,t.jsx)(En,{className:"size-3"}),(0,t.jsx)("span",{className:W(v==="adapter"&&"font-medium text-foreground"),children:"2. Adapter"})]}),(0,t.jsxs)("form",{className:"flex min-h-0 flex-col",onSubmit:r(I=>{I.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)(ZJe,{}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(en,{className:"text-3xl font-semibold tracking-tight",children:v==="name"?"Meet your next agent":"Choose an adapter"}),(0,t.jsx)(Ln,{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)(jt,{id:o,autoFocus:!0,maxLength:100,placeholder:"e.g. Darnold",value:d,onChange:r(I=>u(I.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"}),k&&(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:W("grid grid-cols-2 gap-3",N.length!==4&&"sm:grid-cols-3"),children:N.map(I=>{const C=Jm(I.type);return(0,t.jsxs)("label",{className:"relative cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",name:"new-agent-adapter",value:I.type,checked:h===I.type,onChange:r(()=>p(I.type),"onChange"),className:"peer sr-only"}),(0,t.jsxs)("span",{className:W("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===I.type?"border-foreground/40 bg-accent":"border-border bg-card"),children:[(0,t.jsx)(X8,{type:I.type}),(0,t.jsx)("span",{className:"text-sm font-medium",children:C.label}),h===I.type&&(0,t.jsx)(ds,{className:"absolute right-2 top-2 size-3.5"})]})]},I.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(I=>g(I.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)(vl,{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)(Ho,{className:"size-4"})]})]})]})]})})}r(abe,"AgentBasicsDialog");var eZe={subscription:"Subscription",api:"API"};function tZe({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)(QN,{initial:!1,mode:"sync",children:(0,t.jsx)(nl.span,{className:"absolute inset-0 flex items-center justify-center whitespace-nowrap",initial:{opacity:0,y:cJ},animate:{opacity:1,y:0,transition:CHe},exit:{opacity:0,y:cJ,transition:_He},children:eZe[e]},e)})})}r(tZe,"CredentialTag");function sZe({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:W("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)(tZe,{mode:s})]})}r(sZe,"ModelSourceTile");function ibe({sources:e,mode:s,selectedId:n,onSelect:a,label:i,collapsed:o=!1,settling:l=!1}){const c=(0,m.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"),u=o?e.filter(h=>h.id===n):e;return(0,t.jsx)("div",{role:"radiogroup","aria-label":i,className:W("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)(QN,{initial:!1,mode:"popLayout",children:u.map(h=>(0,t.jsx)(nl.div,{layout:!0,transition:o0e,exit:{opacity:0,transition:$He},className:W("flex min-w-0",o?"w-(--sz-source-tile-two-up)":"flex-1"),children:(0,t.jsx)(sZe,{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(ibe,"ModelSourceTiles");var QL={subscription:"Use API key instead",api:"Use subscription instead"},nZe={subscription:"api",api:"subscription"};function obe({mode:e,onChange:s}){return(0,t.jsxs)("button",{type:"button",onClick:r(()=>s(nZe[e]),"onClick"),className:W("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(QL).map(n=>(0,t.jsx)("span",{"aria-hidden":!0,className:"invisible col-start-1 row-start-1 whitespace-nowrap",children:QL[n]},n)),(0,t.jsx)(QN,{initial:!1,mode:"sync",children:(0,t.jsx)(nl.span,{className:W("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:F8},exit:{opacity:0,transition:IHe},children:QL[e]},e)})]})}r(obe,"CredentialModeLink");function lbe({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)(vl,{className:"mr-1 size-3.5"}),"Back"]}):(0,t.jsx)("span",{}),(0,t.jsx)(nl.div,{layout:!0,transition:RHe,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)(nl.span,{className:"flex items-center whitespace-nowrap",initial:{opacity:0},animate:{opacity:1},transition:EHe,children:[d==="spinner"?(0,t.jsx)(rt,{className:"mr-1 size-4 animate-spin"}):null,c,d==="arrow"?(0,t.jsx)(Ho,{className:"ml-1 size-3.5"}):null]},`${c}:${d}`)})})]})}r(lbe,"FooterNav");function cbe({companyId:e,adapterType:s,environmentId:n,canLogin:a,localEnvironment:i=!1,onConnected:o,onBack:l,testConnection:c,testError:d,managedAccount:u}){const h=J({queryKey:P.health,queryFn:cm.get,enabled:i}),p=i&&(h.data?.localAiLoginSupported??h.data?.deploymentMode==="local_trusted"),f=(0,m.useRef)(0);(0,m.useEffect)(()=>()=>{f.current++},[]);const g=r(()=>{f.current++,L(!1),k(!1),N(null),I("preparing")},"cancel"),[v,y]=(0,m.useState)(u?.initialMethod==="api_key"?"api":u?"subscription":null),[w,k]=(0,m.useState)(!1),[j,N]=(0,m.useState)(null),[_,I]=(0,m.useState)("preparing"),C=(0,m.useRef)("ready"),[T,R]=(0,m.useState)(""),[A,L]=(0,m.useState)(!1),[D,O]=(0,m.useState)(null),[E,q]=(0,m.useState)(null),B=s==="claude_local"?"Claude":s==="grok_local"?"Grok":"OpenAI",U=s==="claude_local"?"ANTHROPIC_API_KEY":s==="grok_local"?"XAI_API_KEY":"OPENAI_API_KEY",z=s==="claude_local"?"anthropic":s==="grok_local"?"xai":"openai",$=Vge(e,U),K=u?{...$,options:[],subscriptions:[],loading:!1}:$,[H,se]=(0,m.useState)(null),Z=K.subscriptions.length?K.subscriptions.find(ae=>ae.id===(H??K.subscriptions[0]?.id)):void 0,[ie,oe]=(0,m.useState)(null),Y=K.options.find(ae=>ae.id===(ie??K.options[0]?.id)),ne=u?{...K.storedLogin,data:void 0,isPending:!1,isError:!1}:K.storedLogin,de=(0,m.useRef)(null),ee=v??(K.subscriptions.length>0||s==="claude_local"&&!Z&&ne.data?"subscription":K.options.length?"api":"subscription"),X=dxe(e,u?.intent??{provider:z,method:"subscription",name:`My ${B} subscription`,ownership:"personal",agentIds:[],allAgents:!0},p&&ee==="subscription"&&!Z&&!ne.data,{allowHostClaude:h.data?.deploymentMode==="local_trusted"}),Q=J({queryKey:P.agents.authSignal(e,s,n),queryFn:r(()=>Vt.getAdapterAuthSignal(e,s,n??void 0),"queryFn"),retry:!1,enabled:!u});async function fe(){if(A||u?.disabled)return;const ae=++f.current;L(!0),O(null);try{if(u){if(ee==="subscription"&&!p)return;const he=de.current??await(ee==="api"?gu.create(e,{...u.intent,method:"api_key",apiKey:T.trim()}):X.connect(u.intent));de.current=he,R(""),ae===f.current&&u.onComplete({...he,method:ee==="api"?"api_key":"subscription"});return}let le=ee==="api"?Y?Y.aiConnection?{env:{},aiConnection:Y.aiConnection}:{env:{[U]:Y.binding}}:E??{env:{},credentials:{[U]:T.trim()}}:{...Z?.aiConnection?{aiConnection:Z.aiConnection}:{},env:Z?.binding?{CODEX_HOME:Z.binding}:{},...s==="claude_local"&&!Z&&ne.data?{env:Gj(),applyStoredClaudeLogin:!0}:{}};if(ee==="subscription"&&p&&!Z&&!ne.data&&(de.current??=await X.connect(),le={env:{},aiConnection:{provider:z,method:"subscription",mode:"responsible_user"}}),le.credentials&&(await gu.create(e,{provider:z,method:"api_key",name:`My ${B} API`,ownership:"personal",apiKey:le.credentials[U],agentIds:[],allAgents:!0}),le={env:{},aiConnection:{provider:z,method:"api_key",mode:"responsible_user"}}),ae!==f.current)return;ee==="api"&&(R(""),Y||q(le));const ce=await c(le);if(ae!==f.current)return;ce?o(le):O("The provider did not respond. Check the connection and try again.")}catch(le){if(ae!==f.current)return;u&&R(""),O(le instanceof Error?le.message:"Could not connect to the provider.")}finally{ae===f.current&&L(!1)}}r(fe,"connect");const te=ee==="subscription"&&a&&n&&!Z&&!K.loading&&!ne.data&&(!!u||Q.data?.status!=="present"||H==="");return(0,t.jsxs)("div",{className:"min-w-0 max-w-full",children:[(0,t.jsx)(ibe,{label:"Connect your model provider",sources:[{id:s,label:B,icon:(0,t.jsx)(X8,{type:s})}],mode:ee,selectedId:w?s:null,collapsed:w,onSelect:r(()=>{u?.disabled||k(!0)},"onSelect")}),!w&&!u?.fixedMethod&&(0,t.jsx)("div",{className:"-ml-3 mt-1",children:(0,t.jsx)(obe,{mode:ee,onChange:r(ae=>{de.current=null,y(ae),O(null)},"onChange")})}),!w&&K.options.length>0&&(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:[K.options.length," saved API"," ",K.options.length===1?"key available":"keys available","."]}),ee==="subscription"&&K.subscriptions.length>0&&(0,t.jsx)(gw,{options:K.subscriptions,value:Z?.id??"",onChange:se,loading:!1,error:!1,kind:"subscription",disabled:A}),(0,t.jsx)(nl.div,{initial:!1,animate:{height:w?"auto":0,opacity:w?1:0},transition:{height:pd,opacity:oP},className:"overflow-hidden",children:w&&(0,t.jsx)("div",{className:"pt-5",children:ee==="api"?(0,t.jsxs)(lP,{instruction:K.options.length?"Choose a saved API key or enter a new one":`Provide your ${B} API key to connect`,children:[(0,t.jsx)(gw,{...K,value:Y?.id??"",disabled:A,onChange:r(ae=>{oe(ae),R(""),q(null),O(null)},"onChange")}),!Y&&(0,t.jsx)(cP,{label:"API key",masked:!0,autoFocus:!0,value:T,placeholder:E?"Key entered. Retry the connection.":"Enter API key here",onChange:r(ae=>{oe(""),R(ae),q(null)},"onChange"),onSubmit:r(()=>{fe()},"onSubmit"),disabled:A})]}):te?(0,t.jsx)(Q8,{companyId:e,adapterType:s,environmentId:n,chrome:"onboarding",aiConnection:u?.intent??{provider:z,method:"subscription",name:`My ${B} subscription`,ownership:"personal",agentIds:[],allAgents:!0},autoStart:!0,onStored:r(()=>{},"onStored"),onPromptReady:r(ae=>{N(ae),I(le=>ae?le==="preparing"?"ready":le:"preparing")},"onPromptReady"),onCodeSubmitted:r(()=>{C.current=_==="waiting"?"waiting":"ready",I("connecting")},"onCodeSubmitted"),onSubmitFailed:r(()=>{I(ae=>ae==="connecting"?C.current:ae)},"onSubmitFailed"),onConnected:r(ae=>{if(u){if(!ae){O("The login did not return a saved connection. Try again.");return}const ce=f.current;I("connecting"),gu.loginResult(e,ae).then(he=>{ce===f.current&&u.onComplete({...he,method:"subscription"})}).catch(()=>{ce===f.current&&(I("ready"),O("Could not retrieve the saved connection. Go back and retry."))});return}const le={env:{},aiConnection:{provider:z,method:"subscription",mode:"responsible_user"}};q(le),o(le)},"onConnected")}):Z?null:p&&!ne.data?(0,t.jsx)(B8,{adapterType:s,login:{...X,retry:r(()=>{O(null),X.retry()},"retry")}}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:ne.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."})})}),ee==="subscription"&&ne.isError&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:"Could not check your saved Claude subscription. Try again."}),D&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:d??D}),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)(lbe,{onBack:r(()=>{w?g():l()},"onBack"),primaryLabel:w&&te?_==="waiting"?"Waiting for code":_==="connecting"?"Connecting":`Sign in to ${B}`:A?"Connecting":ee==="subscription"&&(ne.data||Z)?"Use saved subscription":ee==="api"&&Y?"Use saved API key":"Connect",primaryDisabled:u?.disabled||!!u&&ee==="subscription"&&!a&&!p||i&&h.isPending||X.preparing||!!X.error||!u&&Q.isPending||K.loading||s==="claude_local"&&ne.isPending||!w||!!te&&(!j||_!=="ready")||ee==="api"&&!T.trim()&&!E&&!Y,loading:A,primaryIcon:w&&te?_==="ready"?"none":"spinner":void 0,onPrimary:r(()=>{if(te){if(!j||_!=="ready")return;window.open(j,"_blank","noreferrer,noopener"),I("waiting")}else fe()},"onPrimary")})]})}r(cbe,"AgentProviderConnection");function q5(e){return e.provider==="openrouter"?(0,t.jsx)(aZe,{...e}):(0,t.jsx)(rZe,{...e})}r(q5,"AiConnectionCredentialStep");function rZe({companyId:e,provider:s,initialMethod:n,fixedMethod:a,connectionId:i,name:o,ownership:l,agentIds:c,allAgents:d,environmentId:u,onComplete:h,onCancel:p}){const[f,g]=(0,m.useState)(o),[v,y]=(0,m.useState)(),w=Ut(),k=J({queryKey:P.environments.list(e),queryFn:r(()=>Ri.list(e),"queryFn")}),j=J({queryKey:P.environments.capabilities(e),queryFn:r(()=>Ri.capabilities(e),"queryFn")}),N=J({queryKey:P.instance.settings,queryFn:Tr.get}),_=J({queryKey:P.instance.experimentalSettings,queryFn:Tr.getExperimental}),I=J({queryKey:P.instance.generalSettings,queryFn:Tr.getGeneral}),C=G8(I.data?.executionMode,k.data??[]);let T=null,R;try{T=C.forced?C.kubernetesEnvironment?.id??null:sN({agentDefaultEnvironmentId:u??v,instanceDefaultEnvironmentId:N.data?.defaultEnvironmentId,localDefaultEnvironmentId:rN(k.data),managedSandboxOnly:_.data?.enableManagedSandboxOnly,managedSandboxEnvironmentId:nN(k.data),visibleEnvironmentIds:k.data?.map(U=>U.id)})}catch(U){R=U instanceof Error?U.message:"Could not resolve the sign-in environment."}const A=(k.data??[]).filter(U=>U.status==="active"&&(U.driver==="local"||U.driver==="sandbox"&&typeof U.config.provider=="string"&&j.data?.sandboxProviders?.[U.config.provider]?.supportsLoginPty===!0));!C.forced&&!u&&!v&&!A.some(U=>U.id===T)&&(T=A[0]?.id??null);const L=k.data?.find(U=>U.id===T),D=typeof L?.config.provider=="string"?L.config.provider:"",O=L?.driver==="sandbox"&&j.data?.sandboxProviders?.[D]?.supportsLoginPty===!0,E=[k,j,N,_,I].some(U=>U.isPending),q=R??[k,j,N,_,I].find(U=>U.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)(jt,{value:f,onChange:r(U=>g(U.target.value),"onChange"),disabled:!!i})]}),!u&&!C.forced&&A.length>1&&(0,t.jsxs)(Oa,{value:T??"",onValueChange:y,children:[(0,t.jsx)($a,{"aria-label":"Sign-in environment",children:(0,t.jsx)(La,{placeholder:"Sign-in environment"})}),(0,t.jsx)(Da,{children:A.map(U=>(0,t.jsx)(Cn,{value:U.id,children:U.name},U.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)(cbe,{companyId:e,adapterType:s==="anthropic"?"claude_local":s==="xai"?"grok_local":"codex_local",environmentId:T,canLogin:O,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(U=>{w.invalidateQueries({queryKey:["ai-connections",e]}),h(U)},"onComplete")}},T??"local")]})}r(rZe,"SubscriptionConnectionStep");function aZe({companyId:e,provider:s,connectionId:n,name:a,ownership:i,agentIds:o,allAgents:l,onComplete:c,onCancel:d}){const[u,h]=(0,m.useState)(a),[p,f]=(0,m.useState)(""),g=Ut(),v=Ne({mutationFn:r(()=>gu.create(e,{provider:s,method:"api_key",name:u,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)(jt,{value:u,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)(u0e,{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:!u.trim()||!p.trim()||v.isPending,onClick:r(()=>v.mutate(),"onClick"),children:v.isPending?"Connecting…":"Connect"})]})]})}r(aZe,"ApiKeyConnectionStep");var iZe=new RegExp(`\\b(${["mcp","server","profile","policy","gateway","transport","stdio","endpoint"].join("|")})s?\\b`,"gi");function dbe(e){return e.replace(iZe,"").replace(/\s{2,}/g," ").replace(/\s+([.,])/g,"$1").trim()}r(dbe,"sanitizeProsumerCopy");var oZe={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."}},lZe={tagline:"Give your agents access to this app.",short:"Give your agents access to this app."};function ube(e,s){const n=oZe[e];if(n)return n;if(s){const a=dbe(s);if(a)return{tagline:a,short:a}}return lZe}r(ube,"appCopyFor");function GJ(e,s,n){return n<=1?`Your ${e} key`:dbe(s)||`Your ${e} key`}r(GJ,"credentialFieldLabel");var cZe=1500;function Sf(e=cZe){const[s,n]=(0,m.useState)("idle"),a=(0,m.useRef)(null),i=(0,m.useRef)(0);(0,m.useEffect)(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const o=(0,m.useCallback)(async l=>{const c=++i.current;let d="copied";try{await Xr(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(Sf,"useCopyAction");function J8(){const e=Rc()?.pushToast;return(0,m.useCallback)(async(s,n="Copied")=>{try{return await Xr(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(J8,"useCopyToast");var dZe="/cloud/connections/handoff",uZe="/cloud/connections/reauth",z5="paperclip.cloud-oauth-handoff.v1",Ax=class extends Error{static{r(this,"OAuthHandoffError")}code;constructor(e,s){super(e),this.code=s,this.name="OAuthHandoffError"}};function Z8(e){if(e===void 0)return null;if(!e||typeof e!="object"||Array.isArray(e))throw new Ax("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 Ax("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");return{kind:"paperclip_cloud",session:s.session}}r(Z8,"parseHandoff");function mZe(e,s){return e===404||s==="SESSION_NOT_AVAILABLE"?new Ax("This sign-in expired. Start the connection again.","expired"):e===401||e===403?new Ax("Paperclip Cloud could not authorize this connection for your account.","forbidden"):new Ax("Paperclip Cloud couldn’t prepare secure sign-in. Try again.","unavailable")}r(mZe,"handoffFailure");async function hZe(e,s){const n=s.request??fetch;let a,i;for(let o=0;o<2;o+=1)try{if(a=await n(dZe,{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 Ax(i instanceof Error?i.message:"Paperclip Cloud couldn’t prepare secure sign-in. Try again.","unavailable")}r(hZe,"postCloudHandoff");function pZe(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!==uZe||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(pZe,"exactReauthenticationTarget");async function oN(e,s={}){const n=Z8(e.handoff);if(!n){const l=v5(e.authorizationUrl);if(!l.ok)throw new Ax(l.message,"invalid_handoff");return{kind:"authorization",url:l.url,host:l.host}}const a=await hZe(n.session,s),i=await a.json().catch(()=>null);if(!a.ok){if(i?.error==="RECENT_LOGIN_REQUIRED"){const l=pZe(i.reauthenticationUrl,n.session);if(l)return l}throw mZe(a.status,i?.error)}const o=v5(typeof i?.authorizationUrl=="string"?i.authorizationUrl:void 0);if(!o.ok)throw new Ax("Paperclip Cloud returned an invalid provider sign-in address.","invalid_handoff");return{kind:"authorization",url:o.url,host:o.host}}r(oN,"prepareOAuthNavigation");function m1(e,s=window.sessionStorage){const n=Z8({kind:"paperclip_cloud",session:e});if(!n)throw new Ax("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");const a={version:1,session:n.session,savedAt:Date.now()};s.setItem(z5,JSON.stringify(a))}r(m1,"savePendingCloudHandoff");function fZe(e=window.sessionStorage){const s=e.getItem(z5);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 Z8({kind:"paperclip_cloud",session:n.session})}catch{return e.removeItem(z5),null}}r(fZe,"readPendingCloudHandoff");function QJ(e=window.sessionStorage){e.removeItem(z5)}r(QJ,"clearPendingCloudHandoff");function pP({host:e,className:s}){return(0,t.jsxs)("div",{className:W("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)(Al,{className:"h-3 w-3"}),"Unverified server"]}),e?(0,t.jsx)("span",{className:"font-mono text-muted-foreground",children:e}):null]})}r(pP,"UnverifiedServerBadge");function fP(e){return!!(e&&uue({...e,methods:e.methods.filter(s=>(s.purpose??"tool")!=="channel"&&s.transport!=="chat_sdk")}))}r(fP,"appSupportsToolCatalogSetup");var xZe=vRe.filter(e=>sue(e).some(s=>Zp(s))).map(e=>e.slug);function gZe(e){return xZe.some(s=>s===e)}r(gZe,"isMcpDirectOAuthConnectSlug");function a6(e,s){const n=new URLSearchParams({source:e});return s&&n.set("intent",s),`/apps/connect?${n.toString()}`}r(a6,"appSourceConnectHref");function bZe(e,s){return`/apps/connect?${new URLSearchParams({source:e,resume:s}).toString()}`}r(bZe,"appSourceResumeHref");function YL(e){return e?`/apps/vercel-connect?${new URLSearchParams({source:e}).toString()}`:"/apps/vercel-connect"}r(YL,"vercelConnectSourceHref");function vZe(e){return e.serviceSlug??e.appKey??e.sourceSlug??void 0}r(vZe,"resolveAppsConnectRouteKey");function yZe(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=Y1(n);return!s&&a?.methods.some(i=>i.transport==="chat_sdk")&&!a.methods.some(i=>(i.purpose??"tool")!=="channel"&&i.transport!=="chat_sdk")?!1:$U(n)&&e.get("reconnect")?.trim()?!0:s?uue(a):fP(a)}r(yZe,"canEnterAppsConnect");var XL=" for the organization",jZe=" for the company";function YJ(e,s){const n=e.trim();if(s!=="organization")return n;const a=n.toLocaleLowerCase();return a.endsWith(XL)?n:a.endsWith(jZe)?`${n.slice(0,n.length-16).trimEnd()}${XL}`:`${n}${XL}`}r(YJ,"connectionNameForGrantKind");function wZe(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(wZe,"grantStatusLabel");function NZe(e){switch(e){case"active":return"connected";case"needs_reauthorization":case"expired":return"attention";case"revoked":return"inactive";default:return"missing"}}r(NZe,"grantStatusTone");function kZe(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(kZe,"grantAccountLabel");function SZe(e){return new Set((e?.members??[]).filter(s=>s.subjectType==="user").map(s=>s.subjectId))}r(SZe,"audienceUserIds");function CZe(e){return e.find(s=>s.kind==="organization"&&s.isDefault)??e.find(s=>s.kind==="organization")??null}r(CZe,"organizationGrant");function _Ze(e,s){return s?e.find(n=>n.kind==="user"&&n.subjectUserId===s)??null:null}r(_Ze,"personalGrantFor");function IZe(e,s){if(!s)return null;const n=e.find(a=>a.userId===s);return n&&(n.name?.trim()||n.email?.trim())||null}r(IZe,"memberLabel");var XJ=0;function i6(){return XJ+=1,{id:`header-${XJ}`,name:"",value:""}}r(i6,"newCustomHeaderRow");function xC(e){try{return new URL(e).host||null}catch{return null}}r(xC,"endpointHost");function AZe(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(AZe,"oauthCallbackUrlForBrowser");function JL(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(JL,"defaultGenericMcpName");function JJ(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(JJ,"genericConnectGuidance");function mbe(e){const s=new Set;for(const n of e){const a=n.name.trim();if(!a&&!n.value.trim())continue;const i=WTe(a);if(!i.ok)return TG(a,i.reason);const o=HTe(n.value);if(!o.ok)return TG(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(mbe,"customHeaderError");function TZe(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(TZe,"genericConnectPayload");function RZe(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&&mbe(e.headers)===null:!0:!1}r(RZe,"canSubmitGenericConnect");function lN(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(lN,"installStateFrom");function hbe(e,s){return e.onAll||e.agentIds.has(s)}r(hbe,"isAgentInstalled");function pbe(e,s){return s.onAll?[{targetType:"company",targetId:e}]:[...s.agentIds].map(n=>({targetType:"agent",targetId:n}))}r(pbe,"installPayload");var EZe="Has access — tick to load its tools into this agent's context.";function fbe(e){return`paperclip.connector-enrollment-access:${e}`}r(fbe,"enrollmentAccessStorageKey");function PZe(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(PZe,"validEnrollmentAccessState");function MZe(e,s,n){try{window.sessionStorage.setItem(fbe(s),JSON.stringify({...n,companyId:e}))}catch{}}r(MZe,"saveEnrollmentAccessState");function LZe(e){const s=fbe(e);try{const n=window.sessionStorage.getItem(s);if(window.sessionStorage.removeItem(s),!n)return null;const a=JSON.parse(n);return PZe(a)?a:null}catch{return null}}r(LZe,"consumeEnrollmentAccessState");function ZJ(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(ZJ,"githubRecoveryUrl");function eZ(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(eZ,"oauthCallbackErrorMessage");var DZe={access:"access",key:"setup",success:"complete"};function tZ(e){return e.requestedAppKey?e.resumeConnectionId||e.routeStage==="setup"?"key":"access":e.hasPrefilledLink||e.zapierSource?"access":"gallery"}r(tZ,"requestedConnectionInitialStep");function $Ze(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 Fx(n)!==e.requestedAppKey?null:$U(e.requestedAppKey)}r($Ze,"requestedConnectionEntry");function OZe(e){return!e.reconnectConnection||!e.reconnectApplication||e.reconnectConnection.applicationId!==e.reconnectApplication.id?!1:e.requestedAppKey?Fx(e.reconnectApplication)===e.requestedAppKey:e.byo&&e.applicationId===e.reconnectApplication.id}r(OZe,"retainedReconnectMatches");function FZe(e){return e.credentialSource==="vercel_connect"&&!e.available&&!e.retainedReconnectMatches}r(FZe,"isVercelConnectUnavailable");function BZe(e){return e.available===!1&&!(e.reconnectConnectionId&&e.reconnectSourceMatches)}r(BZe,"isConnectionDefinitionUnavailable");function qZe(e){return!e.hasRequestedEntry||e.supportedMethodCount===0||e.unsupportedOAuth||e.vercelUnavailable||e.definitionUnavailable?e.reconnectConnectionId?"reconnect_unavailable":"fallback":"ready"}r(qZe,"requestedConnectionSetupResolution");function sZ(e,s,n,a){const i=DZe[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(sZ,"appConnectHref");function fA(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(fA,"withConnectionIntent");var nZ=["Pick app","Access","Add your key"],rZ={gallery:0,access:1,key:2},zZe={access:0,key:1},UZe=["Access","Add MCP URL"],KZe=["Access","Sign in"];function ZL(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(ZL,"defaultGrantKindFor");function WZe(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(WZe,"configuredAgentIdentity");function RS(e,s){const n=typeof s=="string"?s:s?.key;return e?.slug==="google-sheets"&&n==="local"}r(RS,"isGoogleSheetsRobotMethod");function Hk(e){return e?Object.fromEntries([...e.tenantFields??[],...e.extensionFields??[]].filter(s=>s.defaultValue!==void 0).map(s=>[s.key,s.defaultValue])):{}}r(Hk,"defaultMethodConfig");function Ej(e,s){if(!e)return[];const n=M_(e);return s==="vercel_connect"?n.filter(a=>!!a.credentialSources?.vercelConnect):n}r(Ej,"connectionMethodsForCredentialSource");function M_(e){return sue(e).filter(s=>(s.purpose??"tool")!=="channel")}r(M_,"availableToolConnectionMethods");function xA(e,s){const n=M_(e);return s?n.find(a=>a.key===s)??null:DU(n)}r(xA,"availableToolConnectionMethod");function vw(e){const s=DU(e);return e.length===1||s?.capabilityProfile||s?.grantKinds?.includes("agent")?s:null}r(vw,"recommendedSetupConnectionMethod");function aZ(e){return vw(e?e.methods.filter(s=>(s.purpose??"tool")==="tool"&&(s.oauthStrategy==="paperclip_cloud_connector"||s.oauthStrategy==="paperclip_id_connector")):[])}r(aZ,"recommendedManagedConnectorMethod");function iZ(e){if(!e)return!1;const s=M_(e),n=s.length===1?s[0]:null;return!!(n&&Zp(n)&&!fRe(n))}r(iZ,"canUseAutomaticOAuthFastPath");function oZ(e){if(!e)return null;const s=M_(e),n=s.length===1?s[0]:null;return n&&Zp(n)?n:null}r(oZ,"automaticOAuthMethod");function VZe(e){const s=e.metadata;if(!s)return null;const n=s.sourceTemplateKey??s.galleryKey;return typeof n=="string"?n:null}r(VZe,"appSourceSlug");function HZe(e){const s=e.config?.sourceTemplateKey??e.transportConfig.sourceTemplateKey;return typeof s=="string"?s:null}r(HZe,"connectionSourceSlug");function lZ(e,s,n,a={}){if(!e)return null;const i=new Set(s.filter(o=>o.status!=="archived"&&VZe(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)||HZe(o)===e;return o.status!=="archived"&&(!a.draftOnly||o.status==="draft")&&o.authKind==="oauth"&&l})??null}r(lZ,"reusableOAuthConnection");function xbe(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(xbe,"readConnectionIntentOAuthOutcome");function xP(e={}){const[s]=Ei(),n=Ia(),{selectedCompanyId:a}=ps(),i=cxe(),o=e.interactionId||s.get("intent")||void 0,l=e.serviceSlug||s.get("source")||n.appKey||s.get("appKey"),c=(0,m.useMemo)(()=>{if(o&&rw(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,u=!!(d&&(!l||rw(l))),h=J({queryKey:["tools","connection",d],queryFn:r(()=>cs.getConnection(d),"queryFn"),enabled:u}),p=l||h.data?.config?.sourceTemplateKey,f=s.get("method")||h.data?.config?.connectionMethodKey;return u&&h.isPending?(0,t.jsx)("p",{className:"p-6 text-sm text-muted-foreground",children:"Loading connection…"}):u&&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"&&rw(p)&&(!f||lT(p,f))?i.loaded?i.enabled?(0,t.jsx)(JKe,{...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)(GZe,{...e})}r(xP,"ConnectionSetupFlow");function GZe({byoOnly:e=!1,credentialSource:s="paperclip_vault",host:n="page",serviceSlug:a,requestedAgentId:i,interactionId:o,forceNewConnection:l=!1,existingConnections:c=[],configuredConnection:d,onUseExisting:u,onComplete:h,onOAuthDeclined:p,aiConnection:f,onPhaseChange:g,onCancel:v,renderCredentialStep:y}={}){const w=Xn(),k=(0,m.useCallback)((Be,Et)=>{n==="page"&&(Et?w(Be,Et):w(Be))},[n,w]),j=Ia(),{selectedCompany:N,selectedCompanyId:_}=ps(),{enabled:I}=Yx(),{setBreadcrumbs:C}=Bn(),{pushToast:T}=Ai(),[R]=Ei(),A=o?.trim()||R.get("intent")?.trim()||null,L=j.appKey??R.get("appKey")??void 0,D=R.get("source")?.trim()||null,O=l||R.get("new")==="1",E=R.get("stage")?.trim()||null,q=R.get("method")?.trim()||null,B=R.get("resume")?.trim()||null,U=R.get("oauth"),z=R.get("code"),$=ZJ(R.get("installation_url")),K=ZJ(R.get("management_url")),H=d?.id??(R.get("reconnect")?.trim()||null),se=R.get("identity")==="user"?"user":R.get("identity")==="organization"?"organization":null,Z=s==="vercel_connect",ie=a??D,oe=s==="paperclip_vault"&&gZe(ie)?ie:null,Y=vZe({serviceSlug:a,appKey:L,sourceSlug:D}),ne=(a??D??L)==="zapier",de=ne?void 0:Y,ee=!!d||n==="page"&&(e||R.get("byo")==="1"),[X]=(0,m.useState)(()=>n==="page"&&R.get("cloud_connector")==="enrolled"&&de?LZe(de):null),[Q]=(0,m.useState)(()=>{const Be=R.get("link")?.trim()??"";return{link:/^https?:\/\//i.test(Be)?Be:"",name:d?.name??R.get("name")?.trim()??"",applicationId:d?.applicationId??(R.get("applicationId")?.trim()||void 0)}}),[fe,te]=(0,m.useState)(()=>tZ({requestedAppKey:de,routeStage:E,resumeConnectionId:B,hasPrefilledLink:!!Q.link,zapierSource:ne})),[ae,le]=(0,m.useState)(null),[ce,he]=(0,m.useState)(""),[ve,pe]=(0,m.useState)(Q.link),[xe,_e]=(0,m.useState)(Q.name||(ne?"Zapier":"")),[ge,Ie]=(0,m.useState)(!1),[Ye,$e]=(0,m.useState)(""),[Xe,ue]=(0,m.useState)("auto"),[Oe,dt]=(0,m.useState)(()=>[i6()]),[xt,Le]=(0,m.useState)(""),[Ge,ht]=(0,m.useState)(""),[Ve,Ke]=(0,m.useState)(!1),[gt,tt]=(0,m.useState)(null),[Se,ke]=(0,m.useState)(!1),[Je,ut]=(0,m.useState)({}),[Dt,Jt]=(0,m.useState)(""),[fs,We]=(0,m.useState)(""),[He,ct]=(0,m.useState)(""),[ze,is]=(0,m.useState)(f&&f.mode!=="responsible_user"?`ai-${f.method}`:""),[Fe,Qt]=(0,m.useState)({}),[Tt,Ms]=(0,m.useState)(""),[Ue,pt]=(0,m.useState)(null),[$t,gs]=(0,m.useState)(null),[Rs,Ct]=(0,m.useState)({}),[we,Pe]=(0,m.useState)("all"),[lt,Ot]=(0,m.useState)(new Set),[ft,us]=(0,m.useState)(()=>new Set(X?.agentIds??(i?[i]:[]))),[dn,xs]=(0,m.useState)(X?.grantKind??se??(i?"user":"organization")),[bs,qe]=(0,m.useState)(X?.installChoice??(i?"specific":"all")),Nt=!!(B&&(U==="failed"||U==="denied")),[St,Ee]=(0,m.useState)(Nt?"error":"entry"),[De,Ze]=(0,m.useState)(()=>Nt?eZ(U,z):null),[kt,Kt]=(0,m.useState)(null),Lt=(0,m.useRef)(!1),Ft=(0,m.useRef)(!1),Yt=(0,m.useRef)(null),[Vs,In]=(0,m.useState)(null),An=(0,m.useRef)(null),[tn,Us]=(0,m.useState)(null),[ws,nn]=(0,m.useState)(null),zs=(0,m.useRef)(null),[Tn,pn]=(0,m.useState)(c.length>0&&!!u),[rn,br]=(0,m.useState)(null),[Zs,nr]=(0,m.useState)(null),[rr,Wr]=(0,m.useState)(null),xr=(0,m.useCallback)(()=>{n!=="dialog"||An.current?.closed===!1||(An.current=window.open("about:blank","paperclip-connection-oauth","popup,width=720,height=760,resizable=yes,scrollbars=yes"))},[n]),wr=(0,m.useCallback)(Be=>{if(n!=="dialog"){Ac(Be);return}nn(Be);const Et=An.current;if(!Et||Et.closed){Ee("error"),Ze("Paperclip couldn’t open the sign-in window. Open sign-in in a new tab to continue."),g?.("needs_retry");return}Et.location.assign(Be),Et.focus()},[n,g]),ar=(0,m.useCallback)(()=>{An.current=null,Ze(null),Ee("redirecting"),g?.("authorizing")},[g]);(0,m.useEffect)(()=>{if(n!=="dialog"||St!=="redirecting")return;const Be=window.setInterval(()=>{An.current?.closed&&(Ee("error"),Ze("The sign-in window closed. If authorization did not finish, try again."),nn(null),g?.("needs_retry"))},1e3);return()=>window.clearInterval(Be)},[n,St,g]);const aa=(0,m.useCallback)(async Be=>{zs.current?.abort();const Et=new AbortController;zs.current=Et;try{const Ps=await oN(Be,{signal:Et.signal});if(Ps.kind==="reauthentication"){const Rn=n==="dialog"?An.current:window;if(!Rn||Rn.closed||!Be.handoff)throw new Error("Paperclip couldn’t preserve this sign-in while refreshing your account.");m1(Be.handoff.session,Rn.sessionStorage),Ee("starting")}else Kt(Ps.host),Ee("redirecting");wr(Ps.url)}catch(Ps){if(Et.signal.aborted)return;Ee("error"),Ze(Ps instanceof Error?Ps.message:"Paperclip couldn’t start secure sign-in. Try again."),g?.("needs_retry")}finally{zs.current===Et&&(zs.current=null)}},[n,g,wr]);(0,m.useEffect)(()=>()=>zs.current?.abort(),[]),(0,m.useEffect)(()=>{if(n!=="dialog"||!A)return;const Be=r(Et=>{const Ps=xbe(Et,window.location.origin,A);if(Ps==="connected"){Ee("entry"),nn(null),h?.({resolvedByCallback:!0});return}if(Ps==="declined"){Ee("error"),Ze("Authorization was cancelled. You can try again."),g?.("needs_retry");return}Ps==="failed"&&(Ee("error"),Ze("Authorization did not complete. Try again when you’re ready."))},"receiveOAuthOutcome");return window.addEventListener("message",Be),()=>window.removeEventListener("message",Be)},[A,n,h,p]),(0,m.useEffect)(()=>{if(n!=="dialog"||A||!tn)return;let Be=!1,Et=!1;const Ps=window.setInterval(async()=>{if(Et||Be)return;const Rn=An.current;if(!Rn||Rn.closed){Us(null),Ee("error"),Ze("The sign-in window closed. Try again to finish connecting GitHub.");return}let Er;try{Er=new URL(Rn.location.href)}catch{return}if(!(Er.origin!==window.location.origin||!Er.pathname.includes(tn))){if(Er.searchParams.has("oauth")){Us(null),Ee("error"),Ze("Authorization did not complete. Finish setup in the sign-in window or try again.");return}if(Er.searchParams.get("success")==="1"){Et=!0;try{const Ka=await cs.getConnection(tn);!Be&&Ka.status==="active"&&(Us(null),Rn.close(),h?.({connectionId:Ka.id}))}catch{Be||(Us(null),Ee("error"),Ze("Could not confirm the connection. Try again."))}finally{Et=!1}}}},1e3);return()=>{Be=!0,window.clearInterval(Ps)}},[A,tn,n,h]);const qn=r(()=>{ue("auto"),dt([i6()]),Le(""),ht(""),Ke(!1),tt(null),ke(!1)},"resetGenericAuthState"),Rr=r(Be=>{if(n==="page"&&!A&&s==="paperclip_vault"&&rw(Be.slug)){k(`/apps/connect?source=${Be.slug}`);return}if(Be.slug==="zapier"){le(null),he(""),pe(""),_e("Zapier"),Ie(!1),$e(""),qn(),ut({}),gs(null),te("access"),k(fA("/apps/connect?source=zapier",A));return}if(s==="paperclip_vault"&&iZ(Be)){k(a6(Be.slug,A));return}le(Be),he(Be.name),pe(""),_e(""),Ie(!1),$e(""),qn(),ut({}),Jt(""),We(""),ct("");const Et=vw(Ej(Be,s));is(Et?.key??""),Qt(Hk(Et)),Ms(""),pt(null),gs(null),us(new Set(i?[i]:[])),qe(i?"specific":"all"),xs(cr??ZL(Et,!!i)),te("access"),k(s==="vercel_connect"?fA(YL(Be.slug),A):a6(Be.slug,A))},"useMatchedGalleryEntry"),Na=r(()=>{te("gallery"),k(fA(s==="vercel_connect"?YL():e?"/apps/byo":"/apps",A))},"backToGallery");(0,m.useEffect)(()=>{if(n==="page")return C([{label:"Connectors",href:"/apps"},{label:Z?"Vercel Connect":e?"Connect your own tool":"Connect an app"}]),()=>C([])},[e,n,C,Z]);const Sn=J({queryKey:P.apps.gallery(_??"__none__"),queryFn:r(()=>cs.listGallery(_),"queryFn"),select:(0,m.useCallback)(Be=>A?{...Be,apps:Be.apps.map(Et=>({...Et,methods:Et.methods.filter(Ps=>f?Ps.ai?.provider===f.provider&&(f.mode==="responsible_user"||Ps.ai.method===f.method):Ps.transport!=="runtime_auth")})).filter(Et=>Et.methods.length>0)}:Be,[A,f?.provider,f?.method,f?.mode]),enabled:!!_}),On=(0,m.useMemo)(()=>(Sn.data?.apps??[]).filter(Be=>I||!Be.methods.some(Et=>Et.transport==="chat_sdk")||fP(Be)),[Sn.data,I]),on=de?$U(de):null,mr=!!on?.methods.some(Be=>Be.oauthStrategy==="paperclip_cloud_connector"||Be.oauthStrategy==="paperclip_id_connector"),bt=!!ae?.methods.some(Be=>Be.oauthStrategy==="paperclip_cloud_connector"||Be.oauthStrategy==="paperclip_id_connector"),Ls=ae&&mr&&!bt?aZ(on):null,[Fs,et]=(0,m.useState)(null),Gt=J({queryKey:["cloud-connector","enrollment"],queryFn:r(()=>cs.getCloudConnectorEnrollment(),"queryFn"),refetchInterval:Fs?2e3:!1,enabled:!!(_&&mr&&!bt)}),[mn,Os]=(0,m.useState)(null),Jn=(0,m.useCallback)(()=>{An.current?.close(),An.current=null,et(null)},[]),Nr=(0,m.useCallback)(()=>{!_||!de||MZe(_,de,{grantKind:dn,installChoice:bs,agentIds:bs==="specific"?[...ft]:[]})},[dn,ft,bs,de,_]),_a=(0,m.useCallback)(Be=>{const Et=v5(Be);if(!Et.ok){Jn(),Os(Et.message);return}if(n==="dialog"){et(Et.url);const Ps=An.current;Ps&&!Ps.closed?(Ps.location.assign(Et.url),Ps.focus()):Os("Open authorization in a new tab to continue.");return}Ac(Et.url)},[n,Jn]);(0,m.useEffect)(()=>{!Fs||Gt.data?.status!=="active"||(Jn(),Os(null),Sn.refetch())},[Fs,Gt.data?.status,Sn.refetch,Jn]);const Un=Ne({mutationFn:r(()=>cs.startCloudConnectorEnrollment(_,N?.name,de?sZ(de,"key",s,{resumeConnectionId:B,reconnectConnectionId:H,interactionId:A})+(n==="dialog"?"&enrollment_host=dialog":""):void 0),"mutationFn"),onSuccess:r(Be=>{if(!Be.verificationUrl){Jn(),Os("Paperclip Cloud did not return an enrollment link. Try again.");return}_a(Be.verificationUrl)},"onSuccess"),onError:r(Be=>{Jn(),Os(Be instanceof Error?Be.message:"Paperclip couldn’t reach Paperclip Cloud. Try again.")},"onError")}),Zn=J({queryKey:P.tools.applications(_??"__none__"),queryFn:r(()=>cs.listApplications(_),"queryFn"),enabled:!!_&&(!!oe||!!B||!!H),refetchOnMount:"always"}),rs=J({queryKey:P.tools.connections(_??"__none__"),queryFn:r(()=>cs.listConnections(_),"queryFn"),enabled:!!_&&(!!oe||!!B||!!H),refetchOnMount:"always"}),fn=(0,m.useMemo)(()=>l?null:lZ(oe,Zn.data?.applications??[],rs.data?.connections??[],O?{applicationId:Q.applicationId,draftOnly:!0}:{}),[Zn.data,rs.data,O,oe,Q.applicationId,l]),Hs=(0,m.useMemo)(()=>H?(rs.data?.connections??[]).find(Be=>Be.id===H)??null:null,[rs.data,H]),Zt=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!d||!rs.isFetchedAfterMount||!Hs||Zt.current===Hs.id)return;const Be=Hs.config?.url??Hs.transportConfig?.url??Hs.transportConfig?.serverUrl??Hs.config?.serverUrl;typeof Be!="string"||!/^https?:\/\//i.test(Be)||(Zt.current=Hs.id,pe(Et=>Et||Be))},[d,rs.isFetchedAfterMount,Hs]);const ks=(0,m.useMemo)(()=>Hs?(Zn.data?.applications??[]).find(Be=>Be.id===Hs.applicationId)??null:null,[Zn.data,Hs]),Hn=OZe({requestedAppKey:de,byo:ee,applicationId:Q.applicationId,reconnectConnection:Hs,reconnectApplication:ks}),Pn=(0,m.useMemo)(()=>B?(rs.data?.connections??[]).find(Be=>Be.id===B)??null:null,[rs.data,B]),hr=Pn??Hs,cr=hr?hr.credentialPolicy==="per_user"?"user":hr.credentialPolicy==="per_agent"?"agent":"organization":se,ia=Pn?.authKind==="oauth"?Pn:fn,ls=fn?fn.credentialPolicy==="per_user"?"user":fn.credentialPolicy==="per_agent"?"agent":"organization":null,Ds=cr??ls;(0,m.useEffect)(()=>{Ds&&xs(Ds)},[Ds]);const hn=(0,m.useMemo)(()=>ve&&!ae?PR(ve,On):null,[ae,On,ve]),Fn=ae?xA(ae,ze||null):null,Vr=Fn&&Zp(Fn)?Fn:oZ(ae),_r=s==="paperclip_vault"&&Vr?ae:null,$r=s==="paperclip_vault"&&iZ(ae)?ae:null,Zr=!!oe&&(!Zn.isFetchedAfterMount||!rs.isFetchedAfterMount),je=r(Be=>{te(Be),ae&&k(sZ(ae.slug,Be,s,{connectionMethodKey:ae.methods.find(Et=>Et.key===ze)?.ai?ze:void 0,resumeConnectionId:B,reconnectConnectionId:H,interactionId:A}))},"setAppStep"),qt=Ne({mutationFn:r(Be=>cs.startOAuth(Be.id,{asCurrentUser:Be.credentialPolicy==="per_user",...Be.credentialPolicy==="per_agent"?{asAgentId:WZe(Be)??[...ft][0]}:{},...A?{interactionId:A}:{}}),"mutationFn"),onSuccess:r(Be=>{aa(Be)},"onSuccess"),onError:r(Be=>{const Et=Be instanceof cn&&Be.body&&typeof Be.body=="object"?Be.body.details:null;Ee("error"),g?.("needs_retry"),Ze(Et?.code==="invalid_grant"?"Your authorization expired or was revoked. Reconnect to continue.":Be instanceof Error?Be.message:"Paperclip couldn’t start secure sign-in. Try again.")},"onError")}),yn=qt.mutate,Yn=(0,m.useCallback)(Be=>{g?.("authorizing"),xr(),n==="dialog"&&!A&&Us(Be.id),yn(Be)},[yn,g,xr,n,A]),zr=r(async Be=>{if(i)return;const Et=pbe(_,(Ds??dn)!=="agent"&&bs==="all"?{onAll:!0,agentIds:new Set}:{onAll:!1,agentIds:ft});await cs.putConnectionInstalls(Be,Et)},"applyAccessInstalls"),ir=Ds??dn,Fa=Ne({mutationFn:r(async Be=>{const Et=Be??ae;let Ps;if(Et){const Rn=Ds??dn,Er=xA(Et,ze||null),Ka=RS(Et,Er)?mB(Tt).ids:[],sa=ce.trim(),Wi=YJ(sa||Et.name,Rn);Ps=await cs.connectApp(_,{galleryKey:Et.slug,...ze?{connectionMethodKey:ze}:{},name:Wi,credentialSource:s,...s==="paperclip_vault"?{credentialValues:Je}:{},...s==="vercel_connect"?{vercelConnect:{connector:He.trim()}}:{},...Dt.trim()?{oauthClient:{clientId:Dt.trim(),...fs?{clientSecret:fs}:{}}}:{},configValues:RS(Et,Er)?{allowedSpreadsheetIds:Ka}:Object.keys(Fe).length>0?Fe:void 0,applicationId:Q.applicationId,...B?{resumeConnectionId:B}:H?{reconnectConnectionId:H}:{},...Rn!=="organization"?{grantKind:Rn}:{},...Rn==="agent"?{subjectAgentId:[...ft][0]}:{}})}else{const Rn=TZe({link:ve,name:xe,authMode:Xe,needsKey:ge,keyValue:Ye,headers:Oe,oauthClientId:xt,oauthClientSecret:Ge}),Er=YJ(Rn.name??JL(ve)??"Custom app",ir);Ps=await cs.connectApp(_,{...Rn,...H?{reconnectConnectionId:H}:{},...ne||hn?.slug==="zapier"?{galleryKey:"zapier",connectionMethodKey:"generated-url"}:{},name:Er,applicationId:Q.applicationId,...ir!=="organization"?{grantKind:ir}:{},...ir==="agent"?{subjectAgentId:[...ft][0]}:{}})}return Ps.auth?.kind==="oauth"&&!B&&!H&&await zr(Ps.connectionId),Ps},"mutationFn"),onSuccess:r(Be=>{if(Be.auth?.kind==="oauth"){if(gs(Be),Be.auth.manualClientRequired){tt(JJ("oauth_manual_client_required",null)),ue("oauth"),Ke(!0),ke(!1);return}if(n==="dialog"||A){Ee("starting"),ke(!ae),Yn(Be.connection);return}const Ps=Be.auth.startUrl?.trim();if(!Ps){Ee("starting"),ke(!0),Yn(Be.connection);return}ke(!0),aa({authorizationUrl:Ps,handoff:Be.auth.handoff});return}tt(null),gs(Be);const Et={};for(const Ps of Be.actions.readOnly)Et[Ps.catalogEntryId]=!0;for(const Ps of Be.actions.canMakeChanges)Et[Ps.catalogEntryId]=!0;Ct(Et),Rt.mutate({result:Be,enabled:Et})},"onSuccess"),onError:r(Be=>{const Et=Be instanceof cn&&Be.body&&typeof Be.body=="object"?Be.body.details:null;if(_r){Ee("error"),g?.("needs_retry"),Ze(Et?.code==="invalid_grant"?"Your authorization expired or was revoked. Reconnect to continue.":Be instanceof Error?Be.message:"Paperclip couldn’t start secure sign-in. Try again.");return}if(!ae&&ve){const Ps=typeof Et?.code=="string"?Et.code:null,Rn=JJ(Ps,Be instanceof Error?Be.message:null);tt(Rn),ke(!1),Rn.focus==="credentials"&&Ke(!0);return}T({title:"Couldn’t connect",body:Be instanceof Error?Be.message:"Please check your key and try again.",tone:"error"})},"onError")}),re=Fa.mutate,at=(0,m.useCallback)(Be=>{const Et=Be??ae;(Et?xA(Et,ze||null):null)?.auth==="oauth"&&xr(),re(Be)},[ze,ae,re,xr]);(0,m.useEffect)(()=>{if(!de||Sn.isLoading||!Sn.data||H&&(!rs.isFetchedAfterMount||!Zn.isFetchedAfterMount))return;const Be=$Ze({requestedAppKey:de,galleryApps:Sn.data.apps,reconnectConnection:Hs,applications:Zn.data?.applications??[]}),Et=!!Be?.methods.some(ai=>ai.oauthStrategy==="paperclip_cloud_connector"||ai.oauthStrategy==="paperclip_id_connector");if(mr&&!Et&&Gt.isLoading)return;const Ps=Ej(Be,s),Rn=f??(Hs?.connectionPurpose==="ai"?PG.safeParse(Hs.config?.ai).data:void 0),Er=Ps.find(ai=>Rn?ai.ai?.provider===Rn.provider&&(!("mode"in Rn)||Rn.mode!=="responsible_user")&&ai.ai.method===Rn.method:ai.key===q)??(mr&&!Et?aZ(on):null)??vw(Ps),Ka=Ps.length===1?Ps[0]:null,sa=s==="paperclip_vault"&&!!oZ(Be),Wi=FZe({credentialSource:s,available:Sn.data.credentialSources?.vercelConnect.available===!0,retainedReconnectMatches:!!(H&&Hn)}),Pr=Ps.length===1&&Ka?.auth==="oauth"&&!Zp(Ka)&&!RR(Ka),bo=BZe({available:Be?.availability?.available,reconnectConnectionId:H,reconnectSourceMatches:Hn}),Ro=qZe({reconnectConnectionId:H,hasRequestedEntry:!!Be,supportedMethodCount:Ps.length,unsupportedOAuth:Pr,vercelUnavailable:Wi,definitionUnavailable:bo});if(Ro!=="ready"){if(le(null),te("gallery"),Ro==="reconnect_unavailable"&&H){Wr(H);return}k(fA(s==="vercel_connect"?YL():"/apps/connect",A),{replace:!0});return}if(Wr(null),!!Be){if(ae?.slug!==Be.slug){le(Be),he(Be.name),pe(""),_e(""),Ie(!1),$e(""),ut({}),Jt(""),We(""),ct(""),is(Er?.key??""),Qt(Hk(Er)),Ms(""),pt(null),gs(null);const ai=X?.companyId===_?X:null;xs(cr??ai?.grantKind??ZL(Er,!!i)),us(new Set(ai?.agentIds??(i?[i]:[]))),qe(ai?.installChoice??(i?"specific":"all")),te(tZ({requestedAppKey:de,routeStage:E,resumeConnectionId:B,hasPrefilledLink:!!Q.link,zapierSource:ne}))}else bt!==Et&&(le(Be),is(Er?.key??""),Qt(Hk(Er)));if(!(sa&&(!Zn.isFetchedAfterMount||!rs.isFetchedAfterMount))&&!(sa&&Ft.current)&&sa&&(Zn.isError||rs.isError)){Ee("error"),Ze("Paperclip couldn’t check for an existing connection. Try again."),te("key");return}}},[f,q,Zn.isError,Zn.isFetchedAfterMount,Zn.data,rs.isError,rs.isFetchedAfterMount,Gt.data?.configured,Gt.isLoading,ze,s,ae?.slug,bt,Sn.data,Sn.isLoading,k,cr,Hs,H,Hn,B,on,de,i,X,E,ne]),(0,m.useEffect)(()=>{Hs?.connectionPurpose==="ai"&&fe==="access"&&te("key")},[Hs?.connectionPurpose,fe]),(0,m.useEffect)(()=>{Yt.current=null,In(null)},[B]),(0,m.useEffect)(()=>{if(!Pn||!ae||Pn.status!=="draft"||Yt.current===Pn.id)return;const Be=Pn.config&&typeof Pn.config=="object"?Pn.config:{},Et=typeof Be.sourceTemplateKey=="string"?Be.sourceTemplateKey:null;if(Et&&Et!==ae.slug)return;const Ps=typeof Be.connectionMethodKey=="string"?Be.connectionMethodKey:null,Rn=Ps?Ej(ae,s).find(Ka=>Ka.key===Ps)??null:null;if(he(Pn.name||ae.name),Rn){is(Rn.key);const Ka=Be.methodConfig&&typeof Be.methodConfig=="object"?Be.methodConfig:{};Qt({...Hk(Rn),...Object.fromEntries(Object.entries(Ka).filter(sa=>typeof sa[1]=="string"||typeof sa[1]=="boolean"))})}const Er=Be.oauth&&typeof Be.oauth=="object"?Be.oauth:null;Er?.clientRegistrationSource==="manual"&&typeof Er.clientId=="string"&&Jt(Er.clientId),U==="failed"||U==="denied"?(Ee("error"),Ze(eZ(U,z))):(Ee("entry"),Ze(null)),te("key"),Yt.current=Pn.id,In(Pn.id)},[s,ae,z,U,Pn]);const Rt=Ne({mutationFn:r(async Be=>{const{result:Et,enabled:Ps}=Be,Rn=Object.entries(Ps).filter(([,Pr])=>Pr).map(([Pr])=>Pr),Er=new Set(Array.isArray(Et.suggestedDefaults.askFirstRiskLevels)?Et.suggestedDefaults.askFirstRiskLevels.filter(Pr=>typeof Pr=="string"):[]),Ka=Et.actions.canMakeChanges.filter(Pr=>Ps[Pr.catalogEntryId]&&Er.has(Pr.riskLevel)).map(Pr=>Pr.catalogEntryId),sa=bs==="all"?"all_agents":{agentIds:Array.from(ft)},Wi=await cs.finishApp(_,Et.connectionId,{enabledCatalogEntryIds:Rn,askFirstCatalogEntryIds:Ka,access:sa,...i?{preserveExistingAccess:!0}:{}});return await zr(Et.connectionId),Wi},"mutationFn"),onSuccess:r((Be,Et)=>{je("success"),h?.({connectionId:Et.result.connectionId})},"onSuccess"),onError:r(Be=>{je("access"),T({title:"Couldn’t finish setup",body:Be instanceof Error?Be.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)&&(rs.isError||Zn.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[Be,Et]=await Promise.all([rs.refetch(),Zn.refetch()]);!Be.isError&&!Et.isError&&(Ze(null),Ee("entry"))},"onClick"),children:"Try again"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>k("/apps"),"onClick"),children:"Back to apps"})]})]});if(B&&rs.isFetchedAfterMount&&!Pn)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(()=>k("/apps"),"onClick"),children:"Back to apps"})]});if(H&&rs.isFetchedAfterMount&&Zn.isFetchedAfterMount&&(!Hs||!Hn))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(()=>k("/apps"),"onClick"),children:"Back to apps"})]});if((B||H)&&Sn.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(()=>{Sn.refetch()},"onClick"),children:"Try again"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>k("/apps"),"onClick"),children:"Back to apps"})]})]});if(H&&rr===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(()=>k("/apps"),"onClick"),children:"Back to apps"})]});if(B&&(!rs.isFetchedAfterMount||Sn.isLoading||!ae||Vs!==Pn?.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)(Nn,{className:"h-8 w-48"}),(0,t.jsx)(Nn,{className:"h-40 w-full rounded-xl"})]});if(H&&(!rs.isFetchedAfterMount||!Zn.isFetchedAfterMount||Sn.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)(Nn,{className:"h-8 w-48"}),(0,t.jsx)(Nn,{className:"h-40 w-full rounded-xl"})]});if(Tn&&u)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)(s8,{choices:c.map(Be=>({id:Be.id,name:Be.name,description:Be.status==="active"&&Be.enabled?"Ready to use":"Setup needs attention"})),pendingId:rn,onSelect:r(async Be=>{br(Be),nr(null);try{await u(Be)}catch(Et){nr(Et instanceof Error?Et.message:"Couldn’t use this connection."),br(null)}},"onSelect")}),Zs?(0,t.jsx)(Ya,{tone:"danger",className:"mt-4",children:Zs}):null,(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>pn(!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=!!(_r&&fe==="key"&&($r||St!=="entry")),Ys=!!(fe==="key"&&ae&&mr&&!bt&&Gt.data?.configured===!0),an=!!(fe==="key"&&ae&&mr&&!bt&&(Gt.isLoading||Gt.isError||Gt.data?.configured!==!0));if(Ns&&_r)return(0,t.jsx)(o6,{entry:_r,resuming:!!B,phase:St,error:De,recoveryActions:z==="github_installation_required"?{installationUrl:$,managementUrl:K}:void 0,authorizationHost:kt,authorizationUrl:ws,onOpenAuthorization:ar,onRetry:r(async()=>{Ze(null),Ee("starting");const Be=$t?.connection??ia;if(Be){Yn(Be);return}Ft.current=!0;try{const[Et,Ps]=await Promise.all([Zn.refetch(),rs.refetch()]);if(Et.isError||Ps.isError){Ee("error"),Ze("Paperclip couldn’t check for an existing connection. Try again.");return}const Rn=(B?(Ps.data?.connections??[]).find(Er=>Er.id===B&&Er.authKind==="oauth")??null:null)??lZ(oe,Et.data?.applications??[],Ps.data?.connections??[],O?{applicationId:Q.applicationId,draftOnly:!0}:{});if(!Lt.current&&!B){Rn&&xs(Rn.credentialPolicy==="per_user"?"user":Rn.credentialPolicy==="per_agent"?"agent":"organization"),Ee("entry"),Ze(null),te("access");return}Rn?Yn(Rn):Fa.mutate(_r)}finally{Ft.current=!1}},"onRetry"),onBack:r(()=>{zs.current?.abort(),Ee("entry"),Ze(null),je("access")},"onBack"),onCancel:r(()=>{zs.current?.abort(),(v??(()=>k("/apps")))()},"onCancel")});if(Se&&!ae&&ve&&fe==="key")return(0,t.jsx)(o6,{identity:{name:xe.trim()||xC(ve)||"this server",unverifiedHost:xC(ve)},steps:{labels:nZ,activeIndex:rZ.key},phase:St,error:De,authorizationHost:kt,authorizationUrl:ws,onOpenAuthorization:ar,onRetry:r(()=>{Ze(null);const Be=$t?.connection;if(Be){Ee("starting"),Yn(Be);return}ke(!1),Ee("entry")},"onRetry"),onBack:r(()=>{zs.current?.abort(),ke(!1),Ee("entry"),Ze(null)},"onBack"),onCancel:r(()=>{zs.current?.abort(),(v??(()=>k("/apps")))()},"onCancel")});const ea=$t?.application.name??ae?.name??(xe.trim()||JL(ve)||"this app"),zt=Ej(ae,s),ns=Ls?[Ls]:zt,ln=Z?On.filter(Be=>Ej(Be,s).length>0):On,ta=ne?Sn.data?.apps.find(Be=>Be.slug==="zapier")??null:null,Gn=(Hs?.connectionPurpose==="ai"?PG.safeParse(Hs.config?.ai).data:void 0)??ae?.methods.find(Be=>Be.key===ze)?.ai??(!ze&&ae?.methods.every(Be=>Be.ai)?ae.methods[0]?.ai:void 0),Ba=ae?y?.({app:ae,name:ce||ae.name,grantKind:ir,agentIds:[...ft],allAgents:bs==="all",onBack:r(()=>je("access"),"onBack")})??(Gn&&_?(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(q5,{companyId:_,provider:Gn.provider,fixedMethod:!!(f&&f.mode!=="responsible_user"),initialMethod:Hs?.connectionPurpose==="ai"?(Hs.config?.ai).method:Gn.method,connectionId:Hs?.connectionPurpose==="ai"?Hs.id:void 0,name:Hs?.connectionPurpose==="ai"?Hs.name:ce||`My ${ae.name} ${Gn.method==="subscription"?"subscription":"API"}`,ownership:(Hs?.connectionPurpose==="ai"?Hs.credentialPolicy==="shared":ir==="organization")?"shared":"personal",agentIds:[...ft],allAgents:bs==="all",onCancel:r(()=>v?v():k("/apps"),"onCancel"),onComplete:r(Be=>{h?.({connectionId:Be.connectionId}),h||k(`/apps/${Be.connectionId}/permissions`)},"onComplete")})}):void 0):void 0,ni=Hs?.connectionPurpose==="ai"?["Reconnect account"]:Ba!==void 0?["Access","Connect account"]:ne?UZe:ae&&ns.length>1?["Access","Choose connection"]:ae&&ns[0]?.auth==="oauth"?["Access","Sign in"]:RS(ae,ze)?["Access","Share sheet"]:ae?["Access","Add your key"]:nZ,Ni=ae?ze?ns.find(Be=>Be.key===ze)??null:ns[0]??null:null,Ti=ae?Ni?.auth??"none":Xe==="none"?"none":Xe==="oauth"?"oauth":"api_key",ro=!!$r,ei=ro?`Continue to ${ae?.name??"sign-in"}`:Ti==="oauth"?"Continue":"Save and continue",Re=Hs?.connectionPurpose==="ai"?0:(ne||ae)&&fe!=="gallery"&&fe!=="success"?zZe[fe]:fe==="success"?ni.length:rZ[fe];return(0,t.jsxs)("div",{className:"max-w-5xl",children:[fe!=="success"&&!(e&&fe==="gallery")&&(0,t.jsx)(e7,{subtitle:fe==="gallery"?Z?"Choose a reviewed app to connect through Vercel.":"Pick the app you want your agents to use.":`Step ${Re+1} of ${ni.length}`,step:fe,activeIndex:Re,labels:ni,appIdentity:ne?{name:"Zapier",logoUrl:ta?.branding.logoUrl??null,darkLogoUrl:ta?.branding.darkLogoUrl??null}:ae&&fe!=="gallery"?{name:ae.name,logoUrl:ae.branding.logoUrl,darkLogoUrl:ae.branding.darkLogoUrl??null}:void 0,unverifiedHost:!ae&&!ne&&fe!=="gallery"?xC(ve):null,onCancel:v??(()=>k("/apps"))}),fe==="gallery"&&(0,t.jsx)(YZe,{loading:Sn.isLoading,initialLink:ve,apps:ln,vercelConnect:Z,vercelConnectAvailability:Sn.data?.credentialSources?.vercelConnect??null,byo:ee,byoOnly:e,source:R.get("source"),onPick:Rr,onUseLink:r(Be=>{const Et=PR(Be,On);le(null),he(""),pe(Be),_e(Et?.name??JL(Be)??""),Ie(!1),$e(""),ut({}),Ms(""),pt(null),us(new Set(i?[i]:[])),qe(i?"specific":"all"),xs(cr??(i?"user":"organization")),te("access")},"onUseLink")}),Ys&&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(()=>je("access"),"onClick"),children:"Back"}),(0,t.jsxs)(F,{type:"button",disabled:Sn.isFetching,onClick:r(()=>{Sn.refetch()},"onClick"),children:[Sn.isFetching?(0,t.jsx)(rt,{className:"h-4 w-4 animate-spin"}):null,"Try again"]})]})]}):fe==="key"&&ae&&an?(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)(p0,{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)."]})]})]}),Gt.isError||mn?(0,t.jsx)(Ya,{tone:"danger",className:"mt-4",children:mn??"Paperclip couldn’t check Cloud registration. Try again."}):null,Fs?(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:Fs,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(()=>je("access"),"onClick"),children:"Back"}),(0,t.jsxs)(F,{type:"button",disabled:Gt.isLoading||Un.isPending,onClick:r(()=>{Os(null),xr(),Nr(),Un.mutate()},"onClick"),children:[Un.isPending?(0,t.jsx)(rt,{className:"h-4 w-4 animate-spin"}):null,Gt.data?.status==="pending"?"Continue":"Connect with Paperclip"]})]})]})}):fe==="key"&&ae&&Ba!==void 0?Ba:fe==="key"&&ae?(0,t.jsx)(JZe,{entry:ae,error:Fa.isError?Fa.error instanceof Error?Fa.error.message:"Please check your key and try again.":null,values:Je,onChange:ut,oauthClientId:Dt,onOAuthClientIdChange:Jt,oauthClientSecret:fs,onOAuthClientSecretChange:We,credentialSource:s,vercelConnector:He,onVercelConnectorChange:ct,vercelConnectAvailability:Sn.data?.credentialSources?.vercelConnect??null,methodKey:ze,onMethodChange:r(Be=>{is(Be?.key??""),!cr&&Be?.grantKinds&&!Be.grantKinds.includes(dn)&&xs(ZL(Be,!!i)),ut({}),Jt(""),We(""),ct(""),Qt(Hk(Be))},"onMethodChange"),configValues:Fe,onConfigChange:Qt,googleSheetsLinks:Tt,googleSheetsError:Ue,onGoogleSheetsLinksChange:r(Be=>{Ms(Be),pt(null)},"onGoogleSheetsLinksChange"),submitting:Fa.isPending,onBack:r(()=>je("access"),"onBack"),onConnect:r(()=>{if(RS(ae,ze)){const Ps=mB(Tt);if(Ps.invalidCount>0){pt("That doesn't look like a Google Sheets link.");return}if(Ps.ids.length===0){pt("Paste at least one Google Sheets link.");return}}const Be=xA(ae,ze||null),Et=!!(Be?.credentialFields?.length||Be?.tenantFields?.some(Ps=>!Ps.hidden)||Be?.extensionFields?.some(Ps=>!Ps.hidden));if(Be&&Zp(Be)&&ia&&!Et&&!Dt.trim()){Lt.current=!0,Ze(null),Ee("starting"),Yn(ia);return}Be&&Zp(Be)&&(Lt.current=!0,Ze(null),Ee("starting")),at()},"onConnect")}):null,fe==="key"&&!ae&&ve&&!ne&&(0,t.jsx)(XZe,{link:ve,name:xe,needsKey:ge,onNeedsKeyChange:r(Be=>{Ie(Be),Be||$e("")},"onNeedsKeyChange"),keyValue:Ye,onKeyChange:$e,authMode:Xe,onAuthModeChange:r(Be=>{ue(Be),tt(null),Be!=="auto"&&Ie(!1),Be!=="bearer"&&Be!=="auto"&&$e("")},"onAuthModeChange"),headers:Oe,onHeadersChange:r(Be=>{dt(Be),tt(null)},"onHeadersChange"),oauthClientId:xt,onOAuthClientIdChange:Le,oauthClientSecret:Ge,onOAuthClientSecretChange:ht,advancedOpen:Ve,onAdvancedOpenChange:Ke,guidance:gt,matchedEntry:hn,onUseMatchedEntry:hn?()=>Rr(hn):void 0,submitting:Fa.isPending||Se,onBack:r(()=>te("access"),"onBack"),onConnect:r(()=>{tt(null),Fa.mutate(void 0)},"onConnect")}),fe==="key"&&!ae&&ne&&(0,t.jsx)(QZe,{link:ve,onLinkChange:pe,submitting:Fa.isPending,onBack:r(()=>te("access"),"onBack"),onConnect:r(()=>Fa.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:Ni?.guidanceMd}),(0,t.jsx)("ul",{className:"list-disc space-y-2 pl-5",children:Ni?.warnings?.map(Be=>(0,t.jsx)("li",{children:Be},Be))})]}),(0,t.jsx)(bbe,{companyId:_,authKind:Ti,grantKinds:Ds?[Ds]:Ni?.grantKinds,grantKind:ir,setGrantKind:xs,installChoice:bs,setInstallChoice:qe,installAgentIds:ft,setInstallAgentIds:us,lockedAgentId:i,capabilities:Sn.data?.capabilities,githubIdentity:ae?.slug==="github",submitLabel:ei,continuesToProvider:ro,identityLoading:!!_r&&Zr,preserveAgentAccess:!!(_r&&(ia||Hs)),pending:Fa.isPending||qt.isPending||!!(de&&!ae),onBack:Na,onContinue:r(()=>{if($r){Lt.current=!0,Ze(null),Ee("starting"),je("key"),ia?Yn(ia):at($r);return}ae?je("key"):te("key")},"onContinue")})]}),fe==="success"&&(0,t.jsx)(tet,{appName:ea,logoUrl:ae?.branding.logoUrl,darkLogoUrl:ae?.branding.darkLogoUrl,summary:eet({grantKind:ir,authKind:Ti,installChoice:bs,installCount:ft.size,enabledCount:Object.values(Rs).filter(Boolean).length}),onDone:v??(()=>k("/apps"))})]})}r(GZe,"StandardConnectionSetupFlow");function e7({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)(Cc,{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)(pP,{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((u,h)=>(0,t.jsx)("li",{"data-testid":"wizard-step-dot","data-step-active":h===i?"true":void 0,className:W("h-1 w-20 rounded-full",h<=i?"bg-foreground":"bg-border")},u))}),(0,t.jsx)("div",{className:"mt-2 text-xs text-muted-foreground","data-testid":"wizard-step-labels",children:o.join(" · ")})]})]})}r(e7,"StepHeader");function o6({entry:e,identity:s,resuming:n=!1,phase:a,error:i,recoveryActions:o,authorizationHost:l,authorizationUrl:c,steps:d={labels:KZe,activeIndex:1},onRetry:u,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)(e7,{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)(dc,{className:"h-5 w-5 text-destructive"}):a==="entry"?(0,t.jsx)(Bd,{className:"h-5 w-5 text-muted-foreground"}):(0,t.jsx)(rt,{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)(pP,{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)(to,{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:u,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(o6,"OAuthConnectStateScreen");function QZe({link:e,onLinkChange:s,submitting:n,onBack:a,onConnect:i}){const o=l6(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)(jt,{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)(rt,{className:"mr-2 h-4 w-4 animate-spin"}),n?"Checking…":"Check link"]})]})]})}r(QZe,"ZapierConnectStep");function YZe({loading:e,initialLink:s="",apps:n,byo:a=!1,byoOnly:i=!1,vercelConnect:o=!1,vercelConnectAvailability:l=null,source:c=null,onPick:d,onUseLink:u}){const[h,p]=(0,m.useState)(""),[f,g]=(0,m.useState)(s),v=(0,m.useRef)(!1);(0,m.useEffect)(()=>{v.current||g(s)},[s]);const[y,w]=(0,m.useState)(null),k=(0,m.useRef)(null),j=(0,m.useRef)(null),N=(0,m.useRef)(!1);(0,m.useEffect)(()=>{!a||e&&!i||N.current||(i||k.current?.scrollIntoView?.({block:"center"}),j.current?.focus(),j.current?.select(),N.current=!0)},[a,i,e]);const _=(0,m.useMemo)(()=>{const A=h.trim().toLowerCase();return n.filter(L=>!A||L.name.toLowerCase().includes(A))},[n,h]),I=l6(f),C=I?PR(I,n):null,T=c==="zapier",R=r(()=>{const A=l6(f);if(!A){w("Paste a full http or https link.");return}w(null),u(A)},"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((A,L)=>(0,t.jsx)(Nn,{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)(to,{className:"ml-2 h-3.5 w-3.5"})]})}):null]}),l?.available===!1?(0,t.jsx)(Ya,{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)(jt,{value:h,onChange:r(A=>p(A.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(A=>{const L=ube(A.slug,A.description),D=M_(A),O=D.length===0||D.every(q=>q.auth==="oauth"&&!Zp(q)&&!RR(q)),E=A.availability?.available===!1||o&&l?.available!==!0;return(0,t.jsxs)("button",{type:"button",disabled:O||E,title:E?A.availability?.reason??l?.reason??void 0:void 0,onClick:r(()=>d(A),"onClick"),className:W("flex flex-col rounded-xl border border-border bg-card p-4 text-left transition-colors",O||E?"cursor-not-allowed opacity-60":"hover:border-foreground/30 hover:bg-accent/40"),children:[(0,t.jsx)(Cc,{name:A.name,logoUrl:A.branding.logoUrl,darkLogoUrl:A.branding.darkLogoUrl,size:36}),(0,t.jsx)("div",{className:"mt-3 text-sm font-bold text-foreground",children:A.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:A.availability?.reason??l?.reason??"Unavailable on this instance."}):O?(0,t.jsx)("span",{className:"text-muted-foreground",children:"Unavailable"}):(0,t.jsx)("span",{children:"Connect →"})})]},A.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:k,className:W("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)(dc,{className:"h-4 w-4 text-muted-foreground"}),T?"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:T?"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."}),!T&&(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)(Cc,{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"){R();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)(jt,{ref:j,type:T||C?.slug==="zapier"?"password":"url",autoComplete:"off",spellCheck:!1,"aria-label":"MCP server URL",value:f,onChange:r(A=>{v.current=!0,g(A.target.value),w(null)},"onChange"),onKeyDown:r(A=>{A.key==="Enter"&&R()},"onKeyDown"),placeholder:T?"https://mcp.zapier.com/api/v1/connect?token=…":"https://example.com/actions",className:"h-10"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:R,children:"Continue"})]}),y&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:y})]})]})]})}r(YZe,"GalleryStep");function l6(e){try{const s=new URL(e.trim());return s.protocol!=="http:"&&s.protocol!=="https:"?null:s.toString()}catch{return null}}r(l6,"normalizeAppLink");function XZe({link:e,name:s,needsKey:n,onNeedsKeyChange:a,keyValue:i,onKeyChange:o,authMode:l,onAuthModeChange:c,headers:d,onHeadersChange:u,oauthClientId:h,onOAuthClientIdChange:p,oauthClientSecret:f,onOAuthClientSecretChange:g,advancedOpen:v,onAdvancedOpenChange:y,guidance:w,matchedEntry:k,onUseMatchedEntry:j,submitting:N,onBack:_,onConnect:I}){const C=xC(e),T=l==="custom_headers"?mbe(d):null,R=RZe({link:e,name:s,authMode:l,needsKey:n,keyValue:i,headers:d,oauthClientId:h,oauthClientSecret:f}),A=l==="auto",L=k?.slug==="zapier"?Jde(e):e,D=r((O,E)=>{u(d.map(q=>q.id===O?{...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)(pP,{host:C})]}),k&&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)(Cc,{name:k.name,logoUrl:k.branding.logoUrl,darkLogoUrl:k.branding.darkLogoUrl,size:24}),(0,t.jsxs)("span",{className:"truncate",children:["Paperclip has a guided setup for ",k.name,"."]})]}),(0,t.jsxs)(F,{type:"button",size:"sm",variant:"outline",onClick:j,children:["Use ",k.name]})]}):null,w?(0,t.jsx)("div",{className:"mt-6",children:(0,t.jsx)(Ya,{tone:"warning",title:w.title,children:w.body})}):null,(0,t.jsxs)("div",{className:"mt-6 space-y-6",children:[A&&(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)(eD,{label:"No",selected:!n,onClick:r(()=>a(!1),"onClick")}),(0,t.jsx)(eD,{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."})]}),A&&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)(jt,{id:"generic-mcp-key",type:"password",autoComplete:"off",value:i,onChange:r(O=>o(O.target.value),"onChange"),placeholder:"••••••••••••••••",className:"mt-2 h-11 font-mono"})]})}):null,(0,t.jsxs)(il,{open:v,onOpenChange:y,children:[(0,t.jsxs)(Yl,{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)(sn,{className:W("h-4 w-4 text-muted-foreground transition-transform",v&&"rotate-180")})]}),(0,t.jsxs)(ol,{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:cZ.map(O=>(0,t.jsx)(eD,{label:O.label,selected:l===O.mode,onClick:r(()=>c(O.mode),"onClick")},O.mode))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:cZ.find(O=>O.mode===l)?.hint}),l==="custom_headers"?(0,t.jsxs)("div",{className:"space-y-3",children:[d.map(O=>(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(jt,{value:O.name,onChange:r(E=>D(O.id,{name:E.target.value}),"onChange"),placeholder:"Header name","aria-label":"Header name",className:"h-10 font-mono"}),(0,t.jsx)(jt,{type:"password",autoComplete:"off",value:O.value,onChange:r(E=>D(O.id,{value:E.target.value}),"onChange"),placeholder:"Value","aria-label":O.name.trim()?`Value for ${O.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(()=>u(d.filter(E=>E.id!==O.id)),"onClick"),disabled:d.length===1,children:"Remove"})]},O.id)),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",onClick:r(()=>u([...d,i6()]),"onClick"),children:"Add another header"}),T?(0,t.jsx)("p",{className:"text-xs text-destructive",children:T}):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)(jt,{id:"generic-mcp-client-id",value:h,onChange:r(O=>p(O.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)(jt,{id:"generic-mcp-client-secret",type:"password",autoComplete:"off",value:f,onChange:r(O=>g(O.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:I,disabled:N||!R||!!T,children:[N&&(0,t.jsx)(rt,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":"Check link"]})]})]})}r(XZe,"LinkConnectStep");var cZ=[{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 eD({label:e,selected:s,onClick:n}){return(0,t.jsx)("button",{type:"button",onClick:n,"aria-pressed":s,className:W("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(eD,"SegmentedOption");function JZe({entry:e,error:s,values:n,onChange:a,oauthClientId:i,onOAuthClientIdChange:o,oauthClientSecret:l,onOAuthClientSecretChange:c,credentialSource:d,vercelConnector:u,onVercelConnectorChange:h,vercelConnectAvailability:p,methodKey:f,onMethodChange:g,configValues:v,onConfigChange:y,googleSheetsLinks:w,googleSheetsError:k,onGoogleSheetsLinksChange:j,submitting:N,onBack:_,onConnect:I}){const C=(0,m.useMemo)(()=>Ej(e,d),[d,e]),T=f?C.find($e=>$e.key===f)??null:vw(C),R=(0,m.useMemo)(()=>C.some($e=>$e.capabilityProfile)?Array.from(C.reduce(($e,Xe)=>{const ue=Xe.capabilityProfile.key,Oe=$e.get(ue);return Oe?Oe.methods.push(Xe):$e.set(ue,{key:ue,label:Xe.capabilityProfile?.label??Xe.label??Xe.key,description:Xe.capabilityProfile?.description??Xe.whenToUse,methods:[Xe]}),$e},new Map)).map(([,$e])=>$e):[],[C]),A=T?.capabilityProfile?.key??T?.key??"",L=R.map($e=>$e.key).join("|"),[D,O]=(0,m.useState)(A||vw(C)?.capabilityProfile?.key||(R.length===1?R[0].key:""));(0,m.useEffect)(()=>{if(A){O(A);return}O($e=>R.some(Xe=>Xe.key===$e)?$e:vw(C)?.capabilityProfile?.key||(R.length===1?R[0].key:""))},[L,R,C,A]);const E=R.length>1?R.find($e=>$e.key===D)?.methods??[]:C,q=(T?.credentialFields??[]).map($e=>({...$e,configPath:eue($e),helpUrl:T?.consoleLinks?.keys??T?.consoleLinks?.docs??""})),B=T?.credentialSources?.vercelConnect??null,U=d==="vercel_connect",z=U||q.every($e=>$e.required===!1||(n[$e.configPath]?.trim().length??0)>0),$=RR(T),K=$&&!Zp(T),H=U||!K||i.trim().length>0,se=!U||u.trim().length>0,Z=T?.auth==="oauth"&&$?AZe():null,ie=[...T?.tenantFields??[],...T?.extensionFields??[]],oe=ie.filter($e=>!$e.hidden),Y=oe.filter($e=>$e.advanced!==!0),ne=oe.filter($e=>$e.advanced===!0),[de,ee]=(0,m.useState)(!1),X=ie.every($e=>{if(!$e.required)return!0;const Xe=v[$e.key];return typeof Xe=="boolean"||typeof Xe=="string"&&Xe.trim().length>0}),Q=T?.configRequirements?.atLeastOneOf??[],fe=Q.length===0||Q.some($e=>{const Xe=v[$e];return typeof Xe=="string"&&Xe.trim().length>0}),te=(R.length<=1||!!D)&&(E.length<=1?!!T:!!f),ae=e.availability?.robotEmail??null,le=e.availability?.available===!1,ce=!U&&$&&!K,he=ne.length>0||ce,ve=R.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)(xu,{ariaLabel:`Access level for ${e.name}`,className:"mt-2",value:D,onValueChange:r($e=>{const Xe=R.find(ue=>ue.key===$e);Xe&&(O($e),g(DU(Xe.methods)))},"onValueChange"),options:R.map($e=>({value:$e.key,title:$e.label,description:$e.description}))}),!D&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Choose an access level to continue."})]}):null,pe=E.find($e=>$e.oauthStrategy==="paperclip_cloud_connector"&&ZTe($e.connectorProfile??"")),xe=pe&&E.find($e=>RR($e)&&!Zp($e)),_e=T?.key===xe?.key,ge=(0,m.useId)(),Ie=pe&&xe&&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":ge,disabled:N,onClick:r(()=>g(_e?pe:xe),"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)(xu,{ariaLabel:`How to connect ${e.name}`,className:"mt-2",value:f,onValueChange:r($e=>{const Xe=E.find(ue=>ue.key===$e);Xe&&g(Xe)},"onValueChange"),options:E.map($e=>({value:$e.key,title:$e.label??($e.auth==="oauth"?`Sign in with ${e.name}`:"Use an API key")}))}),!T&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Choose a connection method to continue."})]}):null;if(RS(e,T)){const $e=mB(w),Xe=!le&&!!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:[ve,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)(gbe,{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)(_n,{value:w,onChange:r(ue=>j(ue.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:$e.ids.length>0?`${$e.ids.length} ${$e.ids.length===1?"sheet":"sheets"} ready to connect.`:"Paste one link per line. Both .../edit and .../edit#gid=... links work."}),k&&(0,t.jsx)("div",{className:"mt-2 text-xs text-destructive",children:k})]})]}),(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:I,disabled:N||!Xe,children:[N&&(0,t.jsx)(rt,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":"Connect"]})]})]})}const Ye=T?.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)(to,{className:"h-3 w-3"})]})}):null,(0,t.jsxs)("div",{className:"space-y-6",children:[ve,Ie,U&&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)(to,{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)(jt,{id:"vercel-connect-connector",value:u,onChange:r($e=>h($e.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)(Ya,{tone:"danger",children:s})}):null,Y.map($e=>(0,t.jsx)(uZ,{field:$e,value:v[$e.key],onChange:r(Xe=>y({...v,[$e.key]:Xe}),"onChange")},$e.key)),he&&(0,t.jsxs)(il,{open:de,onOpenChange:ee,children:[(0,t.jsxs)(Yl,{className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[(0,t.jsx)(sn,{className:W("h-4 w-4 transition-transform",de&&"rotate-180")}),"Advanced"]}),(0,t.jsx)(ol,{className:"pt-4",children:(0,t.jsxs)("div",{className:"space-y-6",children:[ne.map($e=>(0,t.jsx)(uZ,{field:$e,value:v[$e.key],onChange:r(Xe=>y({...v,[$e.key]:Xe}),"onChange")},$e.key)),ce?(0,t.jsx)(dZ,{entry:e,method:T,callbackUrl:Z,clientId:i,onClientIdChange:o,clientSecret:l,onClientSecretChange:c,required:!1}):null]})})]}),!U&&T?.auth==="oauth"&&K?(0,t.jsx)("div",{id:ge,role:"region","aria-label":"Your OAuth app",children:(0,t.jsx)(dZ,{entry:e,method:T,callbackUrl:Z,clientId:i,onClientIdChange:o,clientSecret:l,onClientSecretChange:c,required:!0})}):null,U||!T||q.length===0?null:q.map($e=>(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:GJ(e.name,$e.label,q.length)}),(0,t.jsx)(jt,{type:"password","aria-label":GJ(e.name,$e.label,q.length),autoComplete:"off",value:n[$e.configPath]??"",onChange:r(Xe=>a({...n,[$e.configPath]:Xe.target.value}),"onChange"),placeholder:"••••••••••••••••",className:"mt-2 h-11 font-mono"}),$e.helpUrl&&(0,t.jsxs)("a",{href:$e.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)(to,{className:"h-3 w-3"})]})]},$e.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:I,disabled:N||!te||!z||!H||!se||!X||!fe,children:[N&&(0,t.jsx)(rt,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":U?T?.auth==="oauth"?"Validate and continue":"Validate and connect":T?.auth==="oauth"?e.slug==="github"?"Continue to GitHub":"Continue to sign in":"Connect"]})]})]})}r(JZe,"KeyStep");function gbe({value:e,ariaLabel:s}){const{copied:n,failed:a,copy:i}=Sf();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)(ds,{className:"mr-2 h-4 w-4"}):(0,t.jsx)(kr,{className:"mr-2 h-4 w-4"}),n?"Copied":a?"Copy failed":"Copy"]})}r(gbe,"CopyValueButton");function dZ({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)(to,{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)(gbe,{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)(jt,{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)(jt,{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(dZ,"OAuthClientFields");function uZ({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)(yi,{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)(_n,{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)(jt,{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(uZ,"MethodConfigField");function bbe({companyId:e,...s}){const n=J({queryKey:P.agents.list(e),queryFn:r(()=>Vt.list(e),"queryFn")});return(0,t.jsx)(vbe,{...s,agents:(n.data??[]).filter(a=>a.status!=="terminated"),agentsLoading:n.isLoading})}r(bbe,"AccessStep");function vbe({agents:e,agentsLoading:s=!1,authKind:n,grantKinds:a,grantKind:i,setGrantKind:o,installChoice:l,setInstallChoice:c,installAgentIds:d,setInstallAgentIds:u,lockedAgentId:h,capabilities:p,githubIdentity:f=!1,submitLabel:g,continuesToProvider:v=!1,identityLoading:y=!1,preserveAgentAccess:w=!1,pending:k=!1,onBack:j,onContinue:N}){const _=p?.editableAgentIds,I=_?e.filter(B=>_.includes(B.id)):e,C=p?.canSetCompanyInstall??!0,T=p?.canCreateOrganizationGrant??!0,R=n!=="none",A=a??["user","organization"],L=(!R||i==="user"||i==="agent"||T)&&(w?!0:h?d.has(h):i==="agent"?l==="specific"&&d.size===1:l==="all"?C:d.size>0),D=h?e.find(B=>B.id===h)?.name??"the requesting agent":null,O=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:O}),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)(Nn,{className:"h-20 w-full rounded-md"}),(0,t.jsx)(Nn,{className:"h-20 w-full rounded-md"})]}):R&&A.length===1?(0,t.jsxs)("div",{className:"mt-4 flex items-center gap-3 rounded-md border border-border p-4",children:[A[0]==="user"?(0,t.jsx)(ku,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):A[0]==="agent"?(0,t.jsx)(Zi,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):(0,t.jsx)(dw,{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:A[0]==="user"?f?"My GitHub account":"Just me":A[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:A[0]==="user"?"Agents use it only for runs where you are the responsible person.":A[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]})]}):R?(0,t.jsx)(xu,{ariaLabel:f?O:"Which humans can use this credential?",className:"mt-4 sm:grid-cols-2",value:i,onValueChange:r(B=>{const U=B;o(U),U==="agent"&&(c("specific"),d.size>1&&u(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)(ku,{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)(Zi,{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)(dw,{className:"h-4 w-4","aria-hidden":"true"}),accessibleLabel:T?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:T?void 0:p?.organizationGrantReason??"Only a connection manager can share this credential with the organization.",disabled:!T}].filter(B=>A.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)(dw,{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:D}),". 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)(xu,{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)(Zi,{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)(ZZe,{}),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)(iy,{agents:I,selectedAgentIds:d,onChange:r(B=>u(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:k,children:"Back"}),(0,t.jsxs)(F,{className:"w-full sm:w-auto",onClick:N,disabled:!L||y||k,children:[k?(0,t.jsx)(rt,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):null,g,!k&&v?(0,t.jsx)(to,{className:"h-4 w-4","aria-hidden":"true"}):null]})]})]})}r(vbe,"AccessStepContent");function ZZe(){return(0,t.jsxs)("span",{className:"relative block h-4 w-5","aria-hidden":"true",children:[(0,t.jsx)(Zi,{className:"absolute left-0 top-0 h-3.5 w-3.5"}),(0,t.jsx)(Zi,{className:"absolute bottom-0 right-0 h-3.5 w-3.5"})]})}r(ZZe,"BotGroupIcon");function eet(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(eet,"accessSummaryLines");function tet({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)(ds,{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)(Cc,{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(tet,"ConnectionSetupCompletionScreen");function ybe(){const{newProjectOpen:e,closeNewProject:s}=c_(),{selectedCompanyId:n}=ps();return n&&e?(0,t.jsx)(set,{companyId:n,onClose:s},n):null}r(ybe,"NewProjectDialog");function set({companyId:e,onClose:s}){const n=Ut(),[a,i]=(0,m.useState)(""),[o,l]=(0,m.useState)([]),[c,d]=(0,m.useState)(!1),u=(0,m.useRef)(null),h=Ne({mutationFn:r(()=>pa.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)(Qs,{open:!0,onOpenChange:r(p=>{!p&&!h.isPending&&s()},"onOpenChange"),children:(0,t.jsx)(Xs,{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(),u.current?.focus()},"onOpenAutoFocus"),children:c?(0,t.jsxs)("div",{className:"min-h-0 overflow-y-auto p-5",children:[(0,t.jsx)(en,{className:"sr-only",children:"Connect GitHub"}),(0,t.jsx)(xP,{host:"dialog",serviceSlug:"github",forceNewConnection:!0,onCancel:r(()=>d(!1),"onCancel"),onComplete:r(()=>{n.invalidateQueries({queryKey:t8(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)(en,{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)(sr,{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)(Yc,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,t.jsx)("input",{ref:u,"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)(Bfe,{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(set,"NewProjectForm");var Tx={list:r(e=>Te.get(`/companies/${e}/goals`),"list"),get:r(e=>Te.get(`/goals/${e}`),"get"),create:r((e,s)=>Te.post(`/companies/${e}/goals`,s),"create"),update:r((e,s)=>Te.patch(`/goals/${e}`,s),"update"),remove:r(e=>Te.delete(`/goals/${e}`),"remove")};function jbe(e){return{"--sc":`var(${e})`}}r(jbe,"scStyle");function net(e){const s=e.replace(/_/g," ");return s.charAt(0).toUpperCase()+s.slice(1)}r(net,"sentenceCaseStatus");function Ja({status:e,label:s}){return(0,t.jsx)("span",{className:W("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap shrink-0",kF[e]??"bg-muted text-muted-foreground"),children:s??e.replace(/[_-]/g," ")})}r(Ja,"StatusBadge$5");function wbe({status:e}){const s=qEe[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:jbe(s),children:n.replace(/_/g," ")})}r(wbe,"AgentStatusBadge");function Up({status:e,externalConversationState:s}){const n=e==="in_review"&&s==="waiting"?"idle":e,a=DEe[n]??"--status-task-backlog";return(0,t.jsxs)("span",{className:W("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:jbe(a),children:[(0,t.jsx)(o_,{status:n,size:"sm"}),net(n)]})}r(Up,"IssueStatusBadge");var mZ={company:"Organization",team:"Team",agent:"Agent",task:"Task"};function Nbe(){const{newGoalOpen:e,newGoalDefaults:s,closeNewGoal:n}=c_(),{selectedCompanyId:a,selectedCompany:i}=ps(),o=Ut(),[l,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(""),[h,p]=(0,m.useState)("planned"),[f,g]=(0,m.useState)("task"),[v,y]=(0,m.useState)(""),[w,k]=(0,m.useState)(!1),[j,N]=(0,m.useState)(!1),[_,I]=(0,m.useState)(!1),[C,T]=(0,m.useState)(!1),R=(0,m.useRef)(null),A=v||s.parentId||"",{data:L}=J({queryKey:P.goals.list(a),queryFn:r(()=>Tx.list(a),"queryFn"),enabled:!!a&&e}),D=Ne({mutationFn:r(z=>Tx.create(a,z),"mutationFn"),onSuccess:r(()=>{o.invalidateQueries({queryKey:P.goals.list(a)}),E(),n()},"onSuccess")}),O=Ne({mutationFn:r(async z=>{if(!a)throw new Error("No organization selected");return P0.uploadImage(a,z,"goals/drafts")},"mutationFn")});function E(){c(""),u(""),p("planned"),g("task"),y(""),k(!1)}r(E,"reset");function q(){!a||!l.trim()||D.mutate({title:l.trim(),description:d.trim()||void 0,status:h,level:f,...A?{parentId:A}:{}})}r(q,"handleSubmit");function B(z){z.key==="Enter"&&(z.metaKey||z.ctrlKey)&&(z.preventDefault(),q())}r(B,"handleKeyDown");const U=(L??[]).find(z=>z.id===A);return(0,t.jsx)(Qs,{open:e,onOpenChange:r(z=>{z||(E(),n())},"onOpenChange"),children:(0,t.jsxs)(Xs,{showCloseButton:!1,className:W("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(()=>k(!w),"onClick"),children:w?(0,t.jsx)(uK,{className:"h-3.5 w-3.5"}):(0,t.jsx)(A0,{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(z=>c(z.target.value),"onChange"),onKeyDown:r(z=>{z.key==="Tab"&&!z.shiftKey&&(z.preventDefault(),R.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)(Ic,{ref:R,value:d,onChange:u,placeholder:"Add description...",bordered:!1,contentClassName:W("text-sm text-muted-foreground",w?"min-h-(--sz-220px)":"min-h-(--sz-120px)"),imageUploadHandler:r(async z=>(await O.mutateAsync(z)).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)(tr,{open:j,onOpenChange:N,children:[(0,t.jsx)(pr,{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)(Ja,{status:h})})}),(0,t.jsx)(Qn,{className:"w-40 p-1",align:"start",children:Xde.map(z=>(0,t.jsx)("button",{className:W("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 capitalize",z===h&&"bg-accent"),onClick:r(()=>{p(z),N(!1)},"onClick"),children:z},z))})]}),(0,t.jsxs)(tr,{open:_,onOpenChange:I,children:[(0,t.jsx)(pr,{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)(bl,{className:"h-3 w-3 text-muted-foreground"}),mZ[f]??f]})}),(0,t.jsx)(Qn,{className:"w-40 p-1",align:"start",children:Yde.map(z=>(0,t.jsx)("button",{className:W("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",z===f&&"bg-accent"),onClick:r(()=>{g(z),I(!1)},"onClick"),children:mZ[z]??z},z))})]}),(0,t.jsxs)(tr,{open:C,onOpenChange:T,children:[(0,t.jsx)(pr,{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)(vf,{className:"h-3 w-3 text-muted-foreground"}),U?U.title:"Parent goal"]})}),(0,t.jsxs)(Qn,{className:"w-48 p-1",align:"start",children:[(0,t.jsx)("button",{className:W("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",!A&&"bg-accent"),onClick:r(()=>{y(""),T(!1)},"onClick"),children:"No parent"}),(L??[]).map(z=>(0,t.jsx)("button",{className:W("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 truncate",z.id===A&&"bg-accent"),onClick:r(()=>{y(z.id),T(!1)},"onClick"),children:z.title},z.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()||D.isPending,onClick:q,children:D.isPending?"Creating…":s.parentId?"Create sub-goal":"Create goal"})})]})})}r(Nbe,"NewGoalDialog");function ret(e){const s=aet(e),n=iet(e);return`You're invited to join a Paperclip company as an agent.
|
|
287
|
+
`;function gXe(){const e=new Blob([xXe],{type:"application/javascript"}),s=URL.createObjectURL(e);try{return new Worker(s)}finally{URL.revokeObjectURL(s)}}r(gXe,"createSandboxedWorker");var HB=new Map,O5=new Map,TT=new Set,RT=new Map,_0e=null;function bXe(e){_0e=e}r(bXe,"setDynamicParserResultNotifier");function I0e(e,s){e.worker.postMessage(s)}r(I0e,"sendToWorker");function vXe(e){return e.nextId++}r(vXe,"nextRequestId");function yXe(e,s){return`${s}\0${e}`}r(yXe,"lineCacheKey");function jXe(){_0e?.()}r(jXe,"notifyResultReady");function wXe(e,s,n){return new Promise(a=>{const i=vXe(e);e.pendingResolves.set(i,a),I0e(e,{type:"parse",id:i,line:s,ts:n})})}r(wXe,"parseLineAsync");function AS(e){for(const s of e.pendingResolves.values())s([]);e.pendingResolves.clear()}r(AS,"drainPendingRequests");function NXe(e){return new Promise((s,n)=>{const a=gXe(),i={worker:a,ready:!1,nextId:1,pendingResolves:new Map},o=setTimeout(()=>{AS(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 u=d.data;if(u.type==="result"){const h=i.pendingResolves.get(u.id);h&&(i.pendingResolves.delete(u.id),h(u.entries))}else u.type==="error"&&AS(i)},s(i);return}if(c.type==="error"){clearTimeout(o),AS(i),a.terminate(),n(new Error(c.message));return}},a.onerror=l=>{clearTimeout(o),AS(i),a.terminate(),n(new Error(`Worker error: ${l.message}`))},I0e(i,{type:"init",source:e})})}r(NXe,"initSandboxedWorker");function kXe(e){const s=new Map,n=new Set;return{parseStdoutLine:r((i,o)=>{const l=yXe(i,o),c=s.get(l);return c?c.slice():(n.has(l)||(n.add(l),wXe(e,i,o).then(d=>{n.delete(l),s.set(l,d),jXe()})),[])},"parseStdoutLine")}}r(kXe,"buildParserModule");async function GB(e){const s=O5.get(e);if(s)return s;if(TT.has(e))return null;const n=RT.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 TT.add(e),null;const o=await NXe(await i.text());HB.set(e,o);const l=kXe(o);return O5.set(e,l),l}catch{return TT.add(e),null}finally{RT.delete(e)}})();return RT.set(e,a),a}r(GB,"loadDynamicParser");function QB(e){const s=O5.has(e);O5.delete(e),TT.delete(e),RT.delete(e);const n=HB.get(e);return n&&(AS(n),n.worker.terminate(),HB.delete(e)),s}r(QB,"invalidateDynamicParser");var ET=[],mP=new Map,YB=new Set,A0e=new Map,zL=new Set,mA=new Map,XB=new Set;function T0e(e){return XB.add(e),()=>XB.delete(e)}r(T0e,"onAdapterChange");function R0e(){for(const e of XB)e()}r(R0e,"notifyAdapterChange");bXe(R0e);function SXe(){for(const e of[cGe,NGe,zGe,GGe,gQe,TQe,zQe,XQe,lYe,bYe,zYe,LYe,oQe,rXe,$5,fXe])YB.add(e.type),A0e.set(e.type,e),Eb(e)}r(SXe,"registerBuiltInUIAdapters");function Eb(e){const s=ET.findIndex(n=>n.type===e.type);s>=0?ET.splice(s,1,e):ET.push(e),mP.set(e.type,e),R0e()}r(Eb,"registerUIAdapter");function E0e(e){return mP.get(e)??null}r(E0e,"findUIAdapter");SXe();function YN(e){const s=mP.get(e);if(!s){let n=!1;return{type:e,label:e,parseStdoutLine:r((a,i)=>(n||(n=!0,GB(e).then(o=>{o&&Eb({type:e,label:e,parseStdoutLine:o.parseStdoutLine,createStdoutParser:o.createStdoutParser,ConfigFields:Av,buildAdapterConfig:tN})})),$5.parseStdoutLine(a,i)),"parseStdoutLine"),ConfigFields:Av,buildAdapterConfig:tN}}return s}r(YN,"getUIAdapter");function CXe(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 YB){const i=A0e.get(a);if(!i)continue;const o=n.has(a),l=s.has(a),c=zL.has(a);if(o&&l&&!c){zL.add(a);const d=(mA.get(a)??0)+1;mA.set(a,d);let u=!1;const h=i.parseStdoutLine,p=e.find(f=>f.type===a)?.label??a;Eb({type:a,label:p,parseStdoutLine:r((f,g)=>(u||(u=!0,GB(a).then(v=>{v&&mA.get(a)===d&&Eb({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&&(zL.delete(a),mA.delete(a),QB(a),Eb(i))}for(const{type:a,label:i}of e){if(YB.has(a))continue;const o=mP.get(a);if(o&&o!==$5)continue;let l=!1;const c=o?.parseStdoutLine??$5.parseStdoutLine;Eb({type:a,label:i,parseStdoutLine:r((d,u)=>(l||(l=!0,GB(a).then(h=>{h&&Eb({type:a,label:i,parseStdoutLine:h.parseStdoutLine,createStdoutParser:h.createStdoutParser,ConfigFields:o?.ConfigFields??Av,buildAdapterConfig:o?.buildAdapterConfig??tN})})),c(d,u)),"parseStdoutLine"),ConfigFields:o?.ConfigFields??Av,buildAdapterConfig:o?.buildAdapterConfig??tN})}}r(CXe,"syncExternalAdapters");function q8(){return[...ET]}r(q8,"listUIAdapters");function JB(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(JB,"resolveStdoutParser");function P0e(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(P0e,"appendTranscriptEntry");function _Xe(e,s){for(const n of s)P0e(e,n)}r(_Xe,"appendTranscriptEntries");function IXe(e,s=160){return e.length<=s?e:`${e.slice(0,s-3)}...`}r(IXe,"truncateTranscriptLine");function AXe(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(AXe,"formatTranscriptParserError");function TXe(e,s,n,a){const i=AXe(n)||"unknown parser error",o=IXe(e);return{kind:"result",ts:s,text:Qu(`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(TXe,"createTranscriptParseErrorEntry");function z8(e){const{entries:s,line:n,ts:a,parseLine:i,reset:o,redactionOptions:l}=e;try{_Xe(s,i(n,a).map(c=>tUe(c,l)))}catch(c){o?.(),P0e(s,TXe(n,a,c,l))}}r(z8,"appendParsedTranscriptLine");function M0e(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 u=n[d];if(u.stream==="stderr"){s.push({kind:"stderr",ts:u.ts,text:Qu(u.chunk,l)});continue}if(u.stream==="system"){s.push({kind:"system",ts:u.ts,text:Qu(u.chunk,l)});continue}const h=(c+u.chunk).split(/\r?\n/);c=h.pop()??"";for(const p of h){const f=p.trim();f&&z8({entries:s,line:f,ts:u.ts,parseLine:i,reset:o,redactionOptions:l})}}return c}r(M0e,"foldTranscriptChunks");function L0e(e,s,n){const a=[],i={enabled:n?.censorUsernameInLogs??!1},{parseLine:o,reset:l}=JB(s),c=M0e({entries:a,chunks:e,from:0,stdoutBuffer:"",parseLine:o,reset:l,redactionOptions:i}).trim();return c&&z8({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(L0e,"buildTranscript");var AJ=[];function RXe(e,s){const n={enabled:s?.censorUsernameInLogs??!1},a=typeof e!="function"&&typeof e.createStdoutParser=="function";let i=JB(e),o=[],l="",c=AJ,d=[];const u=r(()=>{i=JB(e),o=[],l="",c=AJ},"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 L0e(f,e,s);const v=o.slice(),y=v.length-1;return y>=0&&(v[y]={...v[y]}),g&&z8({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)||u(),l=M0e({entries:o,chunks:f,from:c.length,stdoutBuffer:l,parseLine:i.parseLine,reset:i.reset,redactionOptions:n}),c=f,d=p(f)),d}}}r(RXe,"createIncrementalTranscript");function EXe({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,m.useState)(!1),u=new Set(i),h=e.filter(v=>v.status!=="terminated"&&!u.has(v.id)),p=s?e.find(v=>v.id===s):null,f=p?.status==="terminated",g=!!(s&&!p);return(0,t.jsxs)(tr,{open:c,onOpenChange:d,children:[(0,t.jsx)(pr,{asChild:!0,children:(0,t.jsx)("button",{type:"button",className:W("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)(kc,{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)(yr,{agent:p,size:16,className:"h-3 w-3 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:W("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)(kc,{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)(Qn,{className:"w-48 p-1",align:"start",children:[(0,t.jsx)("button",{type:"button",className:W("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)(yr,{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:W("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)(yr,{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:$8[v.role]??v.role})]},v.id))]})]})}r(EXe,"ReportsToPicker");var PXe="__secret_folder__:";function MXe(e){return!e||e==="active"?null:(0,t.jsx)(ot,{variant:"outline",className:"ml-auto text-(length:--text-nano) font-normal text-muted-foreground",children:e})}r(MXe,"statusBadge");function D0e(e){return e.split("/").filter(s=>s.length>0)}r(D0e,"splitSecretPath$1");function PT(e){return e.join("/")}r(PT,"pathKey$1");function zk(e){return e.length>0?`/${e.join("/")}`:"/"}r(zk,"pathLabel");function LXe(e,s){return e.length<s.length?!1:s.every((n,a)=>e[a]===n)}r(LXe,"pathStartsWith");function TJ(e){return`${PXe}${PT(e)}`}r(TJ,"folderValue");function DXe(e,s,n){const a=s.length,i=new Map,o=[];for(const c of e){const d=D0e(c.name);if(LXe(d,s)){if(d.length>a+1){const u=d.slice(0,a+1),h=PT(u);if(!i.has(h)){const p=u[u.length-1]??"/",f=zk(u);i.set(h,{key:`folder-${h||"root"}`,value:TJ(u),label:p,title:f,searchText:f,kind:"folder",folderPath:h,pathHint:f})}continue}if(d.length===a+1||a===0&&d.length===0){const u=d.at(-1)??c.name;o.push({key:`browse-${c.id}`,value:c.id,label:u,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-${PT(s)}`,value:TJ(c),label:"Up one folder",title:zk(c),searchText:zk(c),kind:"back",folderPath:PT(c),pathHint:zk(c)})}return l.push(...i.values(),...o),{id:"browse-secrets",label:s.length>0?zk(s):"Browse secrets",options:l}}r(DXe,"buildFolderGroup");function U8({secretId:e,secrets:s,recentlyUsedSecrets:n,disabled:a,onSelect:i,onCreateNew:o,triggerClassName:l,disablePortal:c}){const[d,u]=(0,m.useState)(""),h=(0,m.useMemo)(()=>s.find(w=>w.id===e)??null,[s,e]),p=!!e&&!h,f=(0,m.useMemo)(()=>d?d.split("/"):[],[d]),g=(0,m.useMemo)(()=>s.some(w=>D0e(w.name).length>1),[s]),v=(0,m.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 k=(n??[]).filter(j=>j.status==="active"&&j.id!==e);return k.length>0&&w.push({id:"recently-used",label:"Recently used",options:k.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:k.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,m.useCallback)((w,k)=>{if(!g||_Ee(w))return k;const j=DXe(s,f,e),N=k.filter(_=>_.id==="current-missing"||_.id==="recently-used");return j.options.length>0?[...N,j]:N},[f,g,e,s]);return(0,t.jsx)(Zv,{value:e||"",groups:v,onValueChange:r((w,k)=>{if(k.folderPath!==void 0)return u(k.folderPath),!1;u(""),i(w)},"onValueChange"),deriveGroups:y,disabled:a,disablePortal:c,placeholder:"Select secret…",searchPlaceholder:"Search secrets…",emptyMessage:"No matching secrets",triggerClassName:W("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)(ji,{className:"size-3.5 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:w.label})]});const k=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)(ji,{className:W("size-3.5 shrink-0",k?"text-amber-600":"text-muted-foreground")}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:w.label}),k?(0,t.jsxs)("span",{className:"text-amber-600",children:["(",w.status,")"]}):null]})},"renderValue"),renderOption:r((w,{selected:k})=>{if(w.kind==="folder"||w.kind==="back"){const j=w.kind==="back"?pMe:Yc;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:W("truncate text-sm",k&&"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:W("flex min-w-0 flex-1 items-center gap-1.5",w.disabled&&"opacity-60"),title:w.title??w.label,children:[(0,t.jsx)(ji,{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:W("min-w-0 truncate font-mono text-sm",k&&"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]}),MXe(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)(vn,{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(U8,"SecretPicker");var $Xe=/^[a-z][a-z0-9_]*$/,RJ="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 $0e({mode:e,initialName:s,initialValue:n,existingSecretNames:a,onCancel:i,onSubmit:o}){const[l,c]=(0,m.useState)(s),[d,u]=(0,m.useState)(n),[h,p]=(0,m.useState)(!1),[f,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(null),[w,k]=(0,m.useState)(!1),j=l.trim(),N=j?$Xe.test(j)?a?.some(R=>R.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,I=!f&&j.length>0&&d.length>0&&!N;async function C(){if(k(!0),!!I){g(!0),y(null);try{await o(j,d)}catch(R){y(R instanceof Error?R.message:"Failed to create secret"),g(!1)}}}r(C,"handleSubmit");const T=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)(AEe,{className:"text-sm font-medium",children:e==="create"?"Create secret":"Store value as secret"}),e==="store"?(0,t.jsxs)(IEe,{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:W(RJ,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(R=>c(R.target.value),"onChange"),onBlur:r(()=>k(!0),"onBlur"),onKeyDown:r(R=>{R.key==="Enter"&&(R.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:W(RJ,"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"?R=>u(R.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(R=>!R),"onClick"),children:h?(0,t.jsx)(ah,{className:"h-3.5 w-3.5"}):(0,t.jsx)(bd,{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:!I,children:[f?(0,t.jsx)(rt,{className:"h-3.5 w-3.5 animate-spin"}):null,T]})]})]})}r($0e,"SecretPopoverForm");function O0e(e){return(0,t.jsx)($0e,{mode:"create",...e})}r(O0e,"CreateSecretPopover");function OXe(e){return(0,t.jsx)($0e,{mode:"store",...e})}r(OXe,"ConvertToSecretPopover");var FXe=/(api[-_]?key|access[-_]?token|auth(?:_?token)?|authorization|bearer|secret|passwd|password|credential|jwt|private[-_]?key|cookie|connectionstring)/i,BXe=[/^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 qXe(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(qXe,"looksHighEntropy");function zXe(e,s){return s?FXe.test(e)||BXe.some(n=>n.test(s))?!0:qXe(s):!1}r(zXe,"isSensitiveEnv");var EJ=0;function UXe(){return EJ+=1,`env-row-${EJ}`}r(UXe,"nextRowId");function bx(e="text"){return{id:UXe(),name:"",source:e,textValue:"",secretId:"",userSecretKey:"",required:!0,version:"latest"}}r(bx,"emptyRow");function KXe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="secret_ref"}r(KXe,"isSecretRef");function WXe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="plain"}r(WXe,"isPlainObj");function VXe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="user_secret_ref"}r(VXe,"isUserSecretRef");function UL(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([s,n])=>{if(typeof n=="string")return{...bx(),name:s,textValue:n};if(KXe(n)){const a=typeof n.version=="number"?n.version:"latest";return{...bx(),name:s,source:"secret",secretId:typeof n.secretId=="string"?n.secretId:"",version:a}}if(VXe(n)){const a=typeof n.version=="number"?n.version:"latest";return{...bx(),name:s,source:"user_secret",userSecretKey:typeof n.key=="string"?n.key:"",required:n.required!==!1,version:a}}return WXe(n)?{...bx(),name:s,source:"text",textValue:typeof n.value=="string"?n.value:""}:{...bx(),name:s}})}r(UL,"rowsFromValue");function MT(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(MT,"valueFromRows");var PJ="CLAUDE_CODE_OAUTH_TOKEN";function Gj(){return MT([{...bx("user_secret"),name:"CLAUDE_CODE_OAUTH_TOKEN",userSecretKey:"CLAUDE_CODE_OAUTH_TOKEN",required:!0,version:"latest"}])??{}}r(Gj,"buildFixedClaudeOAuthBinding");var HXe=/^[A-Za-z_][A-Za-z0-9_]*$/;function GXe(e,s,n){const a=e.trim();if(!a)return null;if(!HXe.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(GXe,"validateName");function QXe(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(QXe,"computeDuplicateNames");function YXe(e,s){return s===e.source?{kind:"noop"}:s==="secret"?e.textValue.trim()?{kind:"open-store",name:F5(e.name)||"secret",value:e.textValue}:{kind:"to-secret"}:{kind:"to-text",undoFrom:e.secretId?{...e}:null}}r(YXe,"planSourceSwitch");function F0e(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(F0e,"computeRowHealth");function B0e(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(B0e,"computeUserSecretRowHealth");function F5(e){return e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}r(F5,"secretNameFromKey");function fC(e){return e.trim().toUpperCase().replace(/[^A-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64)}r(fC,"envKeyFromSecretName");var XXe="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",MJ="min-w-0 flex-1 bg-transparent px-2 py-1.5 text-sm font-mono outline-none placeholder:text-muted-foreground/40";function JXe({row:e,isLast:s,secrets:n,userSecretDefinitions:a,recentlyUsedSecrets:i,disabled:o,nameIssue:l,showNameIssue:c,dirtyFields:d,onPatch:u,onRemove:h,onNameBlur:p,onNamePaste:f,onEnterInValueLast:g,onCreateSecret:v,onToast:y,focusRequest:w,onFocusConsumed:k}){const j=(0,m.useRef)(null),N=(0,m.useRef)(null),_=(0,m.useRef)(null),[I,C]=(0,m.useState)(null),[T,R]=(0,m.useState)(!1),[A,L]=(0,m.useState)(null),D=F0e(e,n)??B0e(e,a),O=e.source==="secret"?n.find(Y=>Y.id===e.secretId)??null:null,E=(a?.length??0)>0,q=e.source==="text"&&!e.sensitiveDismissed&&zXe(e.name,e.textValue);(0,m.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(),k())},[w,k,e.source]),(0,m.useEffect)(()=>{if(!A)return;const Y=window.setTimeout(()=>L(null),5e3);return()=>window.clearTimeout(Y)},[A]);function B(Y){if(Y==="user_secret"){if(e.source==="user_secret")return;u({source:"user_secret",secretId:"",version:"latest"}),window.setTimeout(()=>_.current?.querySelector("select,input")?.focus(),0);return}const ne=YXe(e,Y);switch(ne.kind){case"noop":return;case"open-store":{const{name:de,value:ee}=ne;window.setTimeout(()=>C({mode:"store",name:de,value:ee}),0);return}case"to-secret":u({source:"secret",userSecretKey:"",required:!0}),window.setTimeout(()=>{_.current?.querySelector("[role=combobox]")?.focus()},0);return;case"to-text":ne.undoFrom&&L(ne.undoFrom),u({source:"text",secretId:"",userSecretKey:"",required:!0,version:"latest"}),window.setTimeout(()=>N.current?.focus(),0);return}}r(B,"switchSource");async function U(Y,ne){const de=await v(Y,ne);u({source:"secret",secretId:de.id,userSecretKey:"",required:!0,version:"latest",textValue:""}),y(`Secret ${de.name} created`),C(null)}r(U,"submitSecretPopover");function z(){const Y=F5(e.name)||"secret",{textValue:ne}=e;window.setTimeout(()=>C({mode:"store",name:Y,value:ne}),0)}r(z,"openStoreAsSecret");const $=e.source==="text"?"Text value":e.source==="secret"?"Organization secret reference":"User secret reference",K=`${e.id}-name-error`,H=`${e.id}-health`,se=d.name||d.value,Z=O?Math.max(0,O.latestVersion):0,ie=e.version==="latest"?"latest":`v${e.version}`,oe=e.version!=="latest";return(0,t.jsxs)("div",{className:W("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",se&&"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:W(XXe,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?K:void 0,onChange:r(Y=>u({name:Y.target.value}),"onChange"),onBlur:p,onPaste:r(Y=>{e.name||f(Y.clipboardData.getData("text"))&&Y.preventDefault()},"onPaste"),onKeyDown:r(Y=>{Y.key==="Enter"&&(Y.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)(tr,{open:I!==null,onOpenChange:r(Y=>{Y||C(null)},"onOpenChange"),children:[(0,t.jsx)(NF,{asChild:!0,children:(0,t.jsxs)("div",{ref:_,className:W("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)(ja,{children:[(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)(ya,{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)(rDe,{className:"size-3.5"}):e.source==="secret"?(0,t.jsx)(ji,{className:"size-3.5"}):(0,t.jsx)(ku,{className:"size-3.5"}),(0,t.jsx)(sn,{className:"size-3 opacity-60"})]})})}),(0,t.jsx)(Vn,{side:"top",children:$})]}),(0,t.jsxs)(wa,{align:"start",className:"w-56",children:[(0,t.jsxs)(hs,{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)(hs,{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)(hs,{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:MJ,placeholder:"value",value:e.textValue,type:q?"password":"text",spellCheck:!1,disabled:o,"aria-label":"Variable value",onChange:r(Y=>u({textValue:Y.target.value}),"onChange"),onKeyDown:r(Y=>{Y.key==="Enter"&&s&&(Y.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:z,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)(Al,{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(()=>u({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)(sr,{className:"size-3"})})]}):null]}):e.source==="secret"?(0,t.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,t.jsx)(U8,{secretId:e.secretId,secrets:n,recentlyUsedSecrets:i,disabled:o,onSelect:r(Y=>u({secretId:Y,version:"latest"}),"onSelect"),onCreateNew:r(Y=>C({mode:"create",name:F5(Y)||Y.trim(),value:""}),"onCreateNew"),triggerClassName:W("rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0",O&&O.status==="active"&&"pr-24 has-[>svg]:!pr-24")}),O&&O.status==="active"?(0,t.jsxs)(tr,{open:T,onOpenChange:R,children:[(0,t.jsx)(NF,{asChild:!0,children:(0,t.jsx)("button",{type:"button",disabled:o,onClick:r(Y=>{Y.preventDefault(),Y.stopPropagation(),R(ne=>!ne)},"onClick"),"aria-label":"Version",className:W("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",oe?"bg-amber-500/15 text-amber-700 dark:text-amber-400":"text-muted-foreground hover:bg-accent"),children:ie})}),(0,t.jsxs)(Qn,{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(()=>{u({version:"latest"}),R(!1)},"onClick"),className:W("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:Z},(Y,ne)=>Z-ne).filter(Y=>Y>0).map(Y=>(0,t.jsxs)("button",{type:"button",role:"radio","aria-checked":e.version===Y,onClick:r(()=>{u({version:Y}),R(!1)},"onClick"),className:W("flex w-full items-center rounded px-2 py-1.5 text-sm hover:bg-accent",e.version===Y&&"font-medium text-amber-700 dark:text-amber-400"),children:["v",Y]},Y))]})]}):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(Y=>{const ne=Y.target.value,de=a?.find(ee=>ee.key===ne);u({userSecretKey:ne,...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(Y=>Y.key===e.userSecretKey)?(0,t.jsxs)("option",{value:e.userSecretKey,children:["Unknown (",e.userSecretKey,")"]}):null,(a??[]).map(Y=>(0,t.jsxs)("option",{value:Y.key,children:[Y.name,Y.status!=="active"?` (${Y.status})`:""]},Y.id))]}):(0,t.jsx)("input",{className:MJ,placeholder:"user-secret key",value:e.userSecretKey,spellCheck:!1,disabled:o,"aria-label":"User secret key",onChange:r(Y=>u({userSecretKey:Y.target.value}),"onChange")}),(0,t.jsxs)("select",{"aria-label":"Requirement",value:e.required?"required":"optional",disabled:o,onChange:r(Y=>u({required:Y.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)(Qn,{align:"start",className:"w-auto p-3",onInteractOutside:r(Y=>{const ne=Y.detail.originalEvent.target;ne&&_.current?.contains(ne)&&Y.preventDefault()},"onInteractOutside"),children:I?.mode==="store"?(0,t.jsx)(OXe,{initialName:I.name,initialValue:I.value,existingSecretNames:n.map(Y=>Y.name),onCancel:r(()=>C(null),"onCancel"),onSubmit:U}):I?.mode==="create"?(0,t.jsx)(O0e,{initialName:I.name,initialValue:I.value,existingSecretNames:n.map(Y=>Y.name),onCancel:r(()=>C(null),"onCancel"),onSubmit:U}):null})]}),D?(0,t.jsx)("p",{id:H,role:"status",className:W("mt-0.5 text-(length:--text-micro)",D.level==="error"?"text-destructive":"text-amber-600 dark:text-amber-400"),children:D.message}):null,A?(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(()=>{u({source:"secret",secretId:A.secretId,version:A.version,textValue:""}),L(null)},"onClick"),children:"Undo"})]}):null]}),c&&l?(0,t.jsx)("p",{id:K,className:W("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)(ja,{children:[(0,t.jsx)(ya,{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)(Mi,{className:"size-4"})})}),(0,t.jsx)(wa,{align:"end",children:(0,t.jsx)(hs,{onSelect:r(()=>{window.setTimeout(z,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)(sr,{className:"size-4"})})]})]})}r(JXe,"EnvironmentVariableRow");var ZXe=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)$/;function eJe(e){const s=e.indexOf(" #");return s>=0?e.slice(0,s):e}r(eJe,"stripInlineComment");function tJe(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 eJe(s).trim()}r(tJe,"unquote");function sJe(e){const s=[];for(const n of e.split(/\r?\n/)){const a=n.trim();if(!a||a.startsWith("#"))continue;const i=ZXe.exec(a);if(!i)continue;const o=i[1],l=tJe(i[2]);s.push({key:o,value:l})}return s}r(sJe,"parseDotenv");var nJe=["PAPERCLIP_"],rJe="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 ZB(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(ZB,"normalizedEnvEntries");function Uk(e){return JSON.stringify(ZB(e))}r(Uk,"normalizedEnvKey");var KL=3;function WL(e){const s=e.slice(0,KL).join(", ");return e.length>KL?`${s} +${e.length-KL} more`:s}r(WL,"formatChangedNames");function LJ(e){return e.map(s=>({...s}))}r(LJ,"cloneRows");function aJe(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(aJe,"rowDirtyFields");var Tv=(0,m.forwardRef)(r(function({value:s,onChange:n,secrets:a,userSecretDefinitions:i,onCreateSecret:o,recentlyUsedSecrets:l,disabled:c,reservedPrefixes:d=nJe,footerHint:u,onDirtyChange:h,hideDraftActions:p=!1},f){const g=Rc(),v=(0,m.useRef)(null),[y,w]=(0,m.useState)(()=>UL(s)),k=(0,m.useRef)(y),[j,N]=(0,m.useState)(()=>LJ(y)),_=(0,m.useMemo)(()=>Uk(s),[]),I=(0,m.useRef)(_),C=(0,m.useRef)(_),T=(0,m.useRef)(null),[R,A]=(0,m.useState)(_),[L,D]=(0,m.useState)(()=>new Set(UL(s).map(pe=>pe.name.trim()).filter(Boolean))),[O,E]=(0,m.useState)(null);(0,m.useEffect)(()=>{k.current=y},[y]);function q(pe,xe=k.current){I.current=pe,A(pe),N(LJ(xe))}r(q,"markCommitted");function B(pe){D(xe=>{const _e=new Set(xe);for(const ge of pe){const Ie=ge.name.trim();Ie&&_e.add(Ie)}return _e})}r(B,"touchCommittedNames");function U(pe){const xe=UL(pe);return w(xe),B(xe),xe}r(U,"adoptExternalValue"),(0,m.useEffect)(()=>{const pe=Uk(s);if(pe===C.current)return;C.current=pe;const xe=Uk(MT(k.current)),_e=xe!==I.current,ge=T.current===pe;if(ge&&(T.current=null),!_e){q(pe,U(s));return}(ge||xe===pe)&&(B(k.current),q(pe))},[s]);const z=(0,m.useMemo)(()=>MT(y),[y]),$=(0,m.useMemo)(()=>Uk(z),[z]),K=$!==R;(0,m.useEffect)(()=>{h?.(!c&&K)},[c,K,h]);const H=(0,m.useMemo)(()=>{const pe=new Map(ZB(MT(j)).map(([Ie,Ye])=>[Ie,JSON.stringify(Ye)])),xe=new Map(ZB(z).map(([Ie,Ye])=>[Ie,JSON.stringify(Ye)])),_e=[],ge=[];for(const[Ie,Ye]of xe)pe.has(Ie)?pe.get(Ie)!==Ye&&ge.push(Ie):_e.push(Ie);return{added:_e,changed:ge,removed:[...pe.keys()].filter(Ie=>!xe.has(Ie))}},[j,z]),se=(0,m.useMemo)(()=>{const pe=[];return H.added.length>0&&pe.push(`New: ${WL(H.added)}`),H.changed.length>0&&pe.push(`Edited: ${WL(H.changed)}`),H.removed.length>0&&pe.push(`Removed: ${WL(H.removed)}`),pe.join(" · ")},[H]);(0,m.useEffect)(()=>{if(c||!K)return;function pe(xe){xe.preventDefault(),xe.returnValue=""}return r(pe,"handleBeforeUnload"),window.addEventListener("beforeunload",pe),()=>window.removeEventListener("beforeunload",pe)},[c,K]);const Z=(0,m.useCallback)(()=>c||!K?null:(T.current=$,(0,df.flushSync)(()=>{n(z)}),z??{}),[c,z,$,K,n]);(0,m.useImperativeHandle)(f,()=>({flushPendingDraft:Z}),[Z]),(0,m.useEffect)(()=>{const pe=v.current?.closest("form");if(!pe)return;function xe(){Z()}return r(xe,"handleSubmit"),pe.addEventListener("submit",xe,!0),()=>pe.removeEventListener("submit",xe,!0)},[Z]),(0,m.useEffect)(()=>{const pe=v.current;if(!pe)return;const xe=pe;function _e(ge){const Ie=ge.target;if(!(Ie instanceof Element)||xe.contains(Ie))return;const Ye=Ie.closest("button");if(!Ye||Ye.disabled)return;const $e=`${Ye.getAttribute("aria-label")??""} ${Ye.textContent??""}`;(Ye.type==="submit"||/\b(save|create|update|test|import)\b/i.test($e))&&Z()}return r(_e,"handleDocumentClick"),document.addEventListener("click",_e,!0),()=>document.removeEventListener("click",_e,!0)},[Z]);function ie(pe){w(pe)}r(ie,"updateDraft");function oe(pe,xe){ie(y.map(_e=>_e.id===pe?{..._e,...xe}:_e))}r(oe,"patchRow");function Y(pe){ie(y.filter(xe=>xe.id!==pe))}r(Y,"removeRow");function ne(){const pe=bx();w([...y,pe]),E({rowId:pe.id,field:"name"})}r(ne,"addRow");function de(pe){const xe=y.find(_e=>_e.id===pe)?.name.trim();xe&&D(_e=>{if(_e.has(xe))return _e;const ge=new Set(_e);return ge.add(xe),ge})}r(de,"markTouched");function ee(pe,xe){const _e=sJe(pe);if(_e.length===0)return!1;const ge=y.filter(Ie=>Ie.id!==xe).map(Ie=>({...Ie}));for(const{key:Ie,value:Ye}of _e){const $e=ge.find(Xe=>Xe.name.trim()===Ie);$e?($e.name=Ie,$e.source="text",$e.textValue=Ye,$e.secretId="",$e.sensitiveDismissed=!1,$e.userSecretKey="",$e.required=!0):ge.push({...bx(),name:Ie,textValue:Ye})}return ie(ge),g?.pushToast({title:`Imported ${_e.length} variable${_e.length===1?"":"s"}`,tone:"success"}),!0}r(ee,"bulkImport");function X(pe){const xe=y.map(Ie=>({...Ie})),_e=xe[xe.length-1];let ge;_e&&!_e.name&&!_e.textValue&&!_e.secretId&&!_e.userSecretKey?ge=_e:(ge=bx(),xe.push(ge)),ge.source="secret",ge.secretId=pe.id,ge.version="latest",ge.name||(ge.name=fC(pe.name)),ie(xe)}r(X,"bindRecentSecret");function Q(){K&&(T.current=$,n(z))}r(Q,"saveDraft");function fe(){T.current=null,C.current=Uk(s);const pe=U(s);q(C.current,pe)}r(fe,"revertDraft");const te=(0,m.useMemo)(()=>QXe(y),[y]),ae=(0,m.useMemo)(()=>y.reduce((pe,xe)=>F0e(xe,a)||B0e(xe,i)?pe+1:pe,0),[y,a,i]),le=(0,m.useMemo)(()=>{const pe=new Set(y.filter(xe=>xe.source==="secret"&&xe.secretId).map(xe=>xe.secretId));return(l??[]).filter(xe=>xe.status==="active"&&!pe.has(xe.id)).slice(0,8)},[l,y]),ce=y.length>0,he=u===void 0?rJe:u,ve=(0,m.useMemo)(()=>new Map(j.map(pe=>[pe.id,pe])),[j]);return(0,t.jsx)(vd,{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)(Ki,{className:"size-3.5"}),ae," bindings need attention"]}):null,ce?(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((pe,xe)=>{const _e=GXe(pe.name,te,d),ge=L.has(pe.name.trim());return(0,t.jsx)(JXe,{row:pe,isLast:xe===y.length-1,secrets:a,userSecretDefinitions:i,recentlyUsedSecrets:l,disabled:c,nameIssue:_e,showNameIssue:ge,dirtyFields:aJe(pe,ve.get(pe.id)),onPatch:r(Ie=>oe(pe.id,Ie),"onPatch"),onRemove:r(()=>Y(pe.id),"onRemove"),onNameBlur:r(()=>de(pe.id),"onNameBlur"),onNamePaste:r(Ie=>ee(Ie,pe.id),"onNamePaste"),onEnterInValueLast:ne,onCreateSecret:o,onToast:r(Ie=>g?.pushToast({title:Ie,tone:"success"}),"onToast"),focusRequest:O?.rowId===pe.id?O.field:null,onFocusConsumed:r(()=>E(null),"onFocusConsumed")},pe.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:ne,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)(vn,{className:"size-3.5"}),"Add variable"]}),le.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)(ji,{className:"size-3"}),"Recently used:"]}),le.map(pe=>(0,t.jsxs)("button",{type:"button",onClick:r(()=>X(pe),"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 ${pe.name}`,children:["+ ",pe.name]},pe.id))]}):null]}),K&&!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"})]}),se?(0,t.jsx)("p",{className:"min-w-0 truncate pl-4 text-xs text-amber-950/80 dark:text-amber-100/80",title:se,children:se}):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)(_i,{className:"size-4"}),"Revert"]}),(0,t.jsxs)("button",{type:"button",onClick:Q,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)(of,{className:"size-4"}),"Save"]})]})]}):null,he?(0,t.jsx)("p",{className:"text-(length:--text-micro) text-muted-foreground/70",children:he}):null,y.some(pe=>pe.source==="user_secret"&&pe.userSecretKey)?(0,t.jsxs)("p",{className:"inline-flex items-start gap-1 text-(length:--text-micro) text-muted-foreground/70",children:[(0,t.jsx)(ku,{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")),iJe="env.",P_="access.",e6=/^[A-Za-z_][A-Za-z0-9_]*$/;function q0e(e){return e?e.startsWith("access.")?"api":e.startsWith("env.")?"env":"config":"config"}r(q0e,"deliveryModeForConfigPath");function z0e(e){switch(e){case"env":return"Env var";case"api":return"API access";default:return"Config"}}r(z0e,"deliveryModeLabel");function oJe(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(oJe,"deliveryModeDescription");function U0e(e){return e?e.startsWith("access.")?e.slice(7):e.startsWith("env.")?e.slice(4):e:""}r(U0e,"aliasFromConfigPath");function lJe(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(lJe,"consumerTypeLabel");var cJe={numeric:!0,sensitivity:"base"};function TS(e){return e.kind==="company"?e.secret.name:e.definition.name}r(TS,"getSecretPathRowName");function iN(e){return e.split("/").filter(s=>s.length>0)}r(iN,"splitSecretPath");function VL(e){return iN(e).join("/")}r(VL,"normalizeSecretPath");function DJ(e,s){return s.every((n,a)=>e[a]===n)}r(DJ,"startsWithSegments");function $J(e,s){return e.localeCompare(s,void 0,cJe)}r($J,"compareNames");function dJe(e,s){const n=iN(s),a=e.map(c=>({row:c,name:TS(c),segments:iN(TS(c))})),i=new Set,o=[];for(const c of a){if(!DJ(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],u=new Set;let h=0;for(const p of a){if(!DJ(p.segments,d))continue;const f=p.segments.length-d.length;if(!(f<1)){h+=1;for(let g=1;g<f;g+=1)u.add(p.segments.slice(d.length,d.length+g).join("/"))}}return{name:c,path:d.join("/"),secretCount:h,folderCount:u.size}});return l.sort((c,d)=>$J(c.name,d.name)),o.sort((c,d)=>$J(TS(c),TS(d))),{folders:l,secrets:o}}r(dJe,"buildSecretPathListing");function uJe(e){const s=iN(e);return s.map((n,a)=>({name:n,path:s.slice(0,a+1).join("/")}))}r(uJe,"buildSecretPathBreadcrumbs");function mJe(e){return e.trim()?e.includes("/")?"Folder name cannot contain slashes.":null:"Folder name is required."}r(mJe,"validateSecretFolderSegment");function c1({name:e,basePath:s="",className:n,leafClassName:a}){const i=iN(e),o=iN(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],u=c.slice(0,-1).join("/");return(0,t.jsxs)("span",{className:W("min-w-0 truncate",n),children:[u?(0,t.jsxs)("span",{className:"text-muted-foreground",children:[u,"/"]}):null,(0,t.jsx)("span",{className:W("font-medium text-foreground",a),children:d})]})}r(c1,"SecretPathName");function hJe(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(hJe,"fingerprintLabel");function K0e({fingerprint:e,length:s,className:n}){const{pushToast:a}=fa(),i=hJe(e,s);if(!e)return(0,t.jsxs)("span",{className:W("inline-flex items-center gap-1 font-mono",n),children:[(0,t.jsx)(tQ,{className:"size-3 shrink-0"}),i]});const o=`sha256:${e}`;return(0,t.jsxs)("button",{type:"button",onClick:r(()=>{Xr(o).then(()=>a({title:"Fingerprint copied",tone:"success"})).catch(()=>a({title:"Couldn’t copy fingerprint",tone:"error"}))},"onClick"),title:`Copy full digest — ${o}`,className:W("inline-flex items-center gap-1 font-mono hover:text-foreground",n),children:[(0,t.jsx)(tQ,{className:"size-3 shrink-0"}),i,(0,t.jsx)(kr,{className:"size-3 shrink-0 opacity-60"})]})}r(K0e,"FingerprintChip");function K8({justification:e,className:s}){return(0,t.jsxs)("div",{className:W("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(K8,"ProposalJustification");function d1({agent:e,className:s}){return(0,t.jsxs)("span",{className:W("inline-flex min-w-0 items-center gap-1",s),children:[(0,t.jsx)(yr,{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(d1,"AgentRefChip");function W8({configPath:e}){const s=q0e(e),n=s==="env",a=s==="api";return(0,t.jsxs)(ot,{variant:"outline",className:W("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)(The,{className:"size-3"}):a?(0,t.jsx)(M3,{className:"size-3"}):null,z0e(s)]})}r(W8,"DeliveryBadge$1");function V8({className:e}){return(0,t.jsxs)(ot,{variant:"outline",className:W("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)(Al,{className:"size-3"})," Proposed"]})}r(V8,"ProposedBadge");function hP(e){return U0e(e.configPath)}r(hP,"bindingEnvKey");function H8(e){return e.secretProposalId?{name:e.secretProposalName??"proposed secret",pending:!0}:{name:e.secretName??"secret",pending:!1}}r(H8,"bindingSecretLabel");function OJ(e){return e instanceof cn?e.message||`Request failed: ${e.status}`:e instanceof Error?e.message:"Something went wrong. Try again."}r(OJ,"readableError");function W0e(e,s=[]){const n=Ut(),{pushToast:a}=fa(),[i,o]=(0,m.useState)(null),[l,c]=(0,m.useState)(null),[d,u]=(0,m.useState)(""),[h,p]=(0,m.useState)(null),f=(0,m.useCallback)(()=>{e&&(n.invalidateQueries({queryKey:["secret-proposals",e]}),n.invalidateQueries({queryKey:P.secrets.list(e)}))},[e,n]),g=Ne({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 vr.approveProposal(e,N.id,{overrides:{name:_,description:j.description.trim()||null,providerConfigId:j.providerConfigId||null}})}return vr.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"} · ${hP(j)||"binding"}`,tone:"success"}),o(null),p(null),f()},"onSuccess"),onError:r(j=>p(OJ(j)),"onError")}),v=Ne({mutationFn:r(({proposal:j,reason:N})=>vr.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),u(""),p(null),f()},"onSuccess"),onError:r(j=>p(OJ(j)),"onError")}),y=(0,m.useCallback)(j=>{p(null);const N=(j.proposedName??"").split("/"),_=N.pop()??"";o({proposal:j,folder:N.join("/"),leaf:_,description:j.proposedDescription??"",providerConfigId:s.find(I=>I.provider==="local_encrypted"&&I.isDefault)?.id??"",cascade:!!j.secretProposalId})},[s]),w=(0,m.useCallback)(j=>{p(null),u(""),c(j)},[]),k=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(pJe,{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)(xJe,{proposal:l,reason:d,error:h,pending:v.isPending,onReasonChange:u,onCancel:r(()=>{c(null),u(""),p(null)},"onCancel"),onConfirm:r(()=>l&&v.mutate({proposal:l,reason:d}),"onConfirm")})]});return{requestApprove:y,requestReject:w,isBusy:g.isPending||v.isPending,dialogs:k}}r(W0e,"useProposalReview");function pJe({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():"",u=a.filter(p=>p.provider==="local_encrypted"),h=c?!!(e&&e.leaf.trim()):!0;return(0,t.jsx)(Qs,{open:!!e,onOpenChange:r(p=>!p&&o(),"onOpenChange"),children:(0,t.jsx)(Xs,{className:"sm:max-w-lg",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:c?"Approve & create secret":"Approve binding"}),(0,t.jsx)(Ln,{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)(d1,{agent:e.proposal.proposedBy,className:"font-medium text-foreground"})]}),(0,t.jsx)(K8,{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)(Gs,{htmlFor:"approve-folder",children:"Folder"}),(0,t.jsx)(jt,{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)(Gs,{htmlFor:"approve-name",children:"Name"}),(0,t.jsx)(jt,{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)(c1,{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)(Gs,{htmlFor:"approve-description",children:"Description"}),(0,t.jsx)(jt,{id:"approve-description",value:e.description,onChange:r(p=>i({...e,description:p.target.value}),"onChange"),placeholder:"Optional"})]}),u.length>0?(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Gs,{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"}),u.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)(K0e,{fingerprint:e.proposal.valueFingerprintSha256,length:e.proposal.valueLength})})]}):(0,t.jsx)(fJe,{draft:e,onChange:i}),s?(0,t.jsx)("p",{className:"text-xs text-destructive",role:"alert",children:s}):null,(0,t.jsxs)(jr,{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(pJe,"ApproveDialog");function fJe({draft:e,onChange:s}){const{proposal:n}=e,a=H8(n),i=hP(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)(d1,{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)(W8,{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)(ji,{className:"size-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:a.name}),a.pending?(0,t.jsx)(V8,{}):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(fJe,"BindingApproveBody");function xJe({proposal:e,reason:s,error:n,pending:a,onReasonChange:i,onCancel:o,onConfirm:l}){const c=s.trim().length>0;return(0,t.jsx)(Qs,{open:!!e,onOpenChange:r(d=>!d&&o(),"onOpenChange"),children:(0,t.jsx)(Xs,{className:"sm:max-w-md",children:e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:"Reject proposal"}),(0,t.jsxs)(Ln,{children:["The reason is sent back to"," ",(0,t.jsx)(d1,{agent:e.proposedBy,className:"text-foreground"}),". Dependent bindings are rejected too."]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Gs,{htmlFor:"reject-reason",children:"Reason"}),(0,t.jsx)(_n,{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)(jr,{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(xJe,"RejectDialog");function V0e({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)(vd,{children:(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)("span",{tabIndex:0,children:c})}),(0,t.jsx)(Vn,{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(V0e,"ProposalActions");function H0e(e){return typeof e!="object"||e===null||Array.isArray(e)?null:e}r(H0e,"asRecord$15");function G0e(e){const s=H0e(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(G0e,"readSecretRef");function gJe(e){const s=H0e(e?.env);if(!s)return[];const n=[];for(const[a,i]of Object.entries(s)){const o=G0e(i);o&&n.push({name:a,...o})}return n}r(gJe,"parseEnvSecretRefs");function bJe(e){if(!e)return[];const s=[];for(const[n,a]of Object.entries(e)){if(!n.startsWith("access."))continue;const i=G0e(a);i&&s.push({name:n.slice(P_.length),...i})}return s}r(bJe,"parseAccessGrants");function vJe(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(vJe,"summarizeAgentBindings");var FJ=0;function Q0e(){return FJ+=1,`access-row-${FJ}`}r(Q0e,"nextAccessRowId");function HL(e){return e.map(s=>({id:Q0e(),alias:s.name,secretId:s.secretId,version:s.version}))}r(HL,"entriesToRows");function BJ(e){const s={};for(const n of e){const a=n.alias.trim();!a||!e6.test(a)||!n.secretId||(s[a]={type:"secret_ref",secretId:n.secretId,version:n.version})}return s}r(BJ,"rowsToAccessMap");function qJ(e){return JSON.stringify(Object.keys(e).sort().map(s=>{const n=e[s];return[s,n.secretId,n.version??"latest"]}))}r(qJ,"normalizeAccessMapKey");function zJ({mode:e}){return e==="env"?(0,t.jsxs)(ot,{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)(The,{className:"size-3"})," Env var"]}):(0,t.jsxs)(ot,{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)(M3,{className:"size-3"})," API access"]})}r(zJ,"DeliveryBadge");function yJe({config:e,secrets:s,onChange:n,onCreateSecret:a,disabled:i,proposals:o,onApproveProposal:l,onRejectProposal:c}){const d=(0,m.useMemo)(()=>(o??[]).filter(O=>O.kind==="binding"),[o]),u=(0,m.useMemo)(()=>gJe(e),[e]),h=(0,m.useMemo)(()=>bJe(e),[e]),p=(0,m.useMemo)(()=>vJe(u,h),[u,h]),f=(0,m.useMemo)(()=>BJ(HL(h)),[h]),g=(0,m.useMemo)(()=>qJ(f),[f]),[v,y]=(0,m.useState)(()=>HL(h)),[w,k]=(0,m.useState)(null),j=(0,m.useRef)(new Map),N=(0,m.useRef)(g),_=(0,m.useRef)(g);(0,m.useEffect)(()=>{g!==_.current&&(_.current=g,g!==N.current&&y(HL(h)))},[g,h]);const I=r(O=>s.find(E=>E.id===O)?.name??`${O.slice(0,8)}…`,"secretName");function C(O){y(O);const E=BJ(O);N.current=qJ(E),n(E)}r(C,"emit");function T(O,E){C(v.map(q=>q.id===O?{...q,...E}:q))}r(T,"patchRow");function R(O){C(v.filter(E=>E.id!==O))}r(R,"removeRow");function A(){y(O=>[...O,{id:Q0e(),alias:"",secretId:"",version:"latest"}])}r(A,"addRow");const L=(0,m.useMemo)(()=>{const O=new Map;for(const E of v){const q=E.alias.trim();q&&O.set(q,(O.get(q)??0)+1)}return O},[v]),D=p.length>0;return(0,t.jsxs)("div",{className:"space-y-3",children:[D?(0,t.jsx)("div",{className:"space-y-1.5",children:p.map(O=>(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)(ji,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:I(O.secretId)}),O.envKeys.length>0?(0,t.jsx)(zJ,{mode:"env"}):null,O.apiAliases.length>0?(0,t.jsx)(zJ,{mode:"api"}):null,(0,t.jsx)("span",{className:"min-w-0 truncate font-mono text-(length:--text-micro) text-muted-foreground",children:[...O.envKeys.map(E=>`${iJe}${E}`),...O.apiAliases.map(E=>`${P_}${E}`)].join(" · ")})]},O.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(O=>{const E=H8(O),q=hP(O);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)(W8,{configPath:O.configPath}),(0,t.jsx)("code",{className:"font-mono",children:q||O.configPath}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"→"}),(0,t.jsx)(ji,{className:"size-3 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium",children:E.name}),E.pending?(0,t.jsx)(V8,{}):null]}),(0,t.jsxs)("p",{className:"flex flex-wrap items-center gap-1 text-muted-foreground",children:[(0,t.jsxs)("span",{children:["proposed by ",O.proposedBy.name]}),(0,t.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,t.jsxs)("span",{className:"truncate italic",children:["“",O.justification,"”"]})]})]}),(0,t.jsx)(V0e,{proposal:O,onApprove:l,onReject:c,disabled:i,size:"xs"})]},O.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(O=>{const E=O.alias.trim(),q=!!E&&!e6.test(E),B=!!E&&(L.get(E)??0)>1,U=s.find(z=>z.id===O.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)(jt,{value:O.alias,onChange:r(z=>T(O.id,{alias:z.target.value}),"onChange"),onBlur:r(z=>{const $=z.target.value.trim();if($&&!e6.test($)){const K=fC($);K&&K!==$&&T(O.id,{alias:K})}},"onBlur"),placeholder:"ALIAS","aria-label":"Access alias",disabled:i,className:W("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)(tr,{open:w?.rowId===O.id,onOpenChange:r(z=>{!z&&w?.rowId===O.id&&k(null)},"onOpenChange"),children:[(0,t.jsx)(NF,{asChild:!0,children:(0,t.jsx)("div",{ref:r(z=>{z?j.current.set(O.id,z):j.current.delete(O.id)},"ref"),className:"min-w-0 flex-1",children:(0,t.jsx)(U8,{secretId:O.secretId,secrets:s,onSelect:r(z=>T(O.id,{secretId:z,version:"latest",alias:!O.alias.trim()&&z?fC(I(z)):O.alias}),"onSelect"),onCreateNew:a?z=>{window.setTimeout(()=>{k({rowId:O.id,name:F5(z)||z.trim()})},0)}:void 0,disabled:i,triggerClassName:"h-9 min-h-9"})})}),(0,t.jsx)(Qn,{align:"start",className:"w-auto p-3",onInteractOutside:r(z=>{const $=z.detail.originalEvent.target;$&&j.current.get(O.id)?.contains($)&&z.preventDefault()},"onInteractOutside"),children:w?.rowId===O.id&&a?(0,t.jsx)(O0e,{initialName:w.name,initialValue:"",existingSecretNames:s.map(z=>z.name),onCancel:r(()=>k(null),"onCancel"),onSubmit:r(async(z,$)=>{const K=await a(z,$);T(O.id,{secretId:K.id,version:"latest",alias:O.alias.trim()||fC(K.name)}),k(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:O.version===void 0?"latest":String(O.version),onChange:r(z=>{const $=z.target.value;T(O.id,{version:$==="latest"?"latest":Number.parseInt($,10)})},"onChange"),disabled:i||!U,"aria-label":"Version",children:[(0,t.jsx)("option",{value:"latest",children:"latest"}),U?Array.from({length:Math.max(0,U.latestVersion)},(z,$)=>{const K=U.latestVersion-$;return K<=0?null:(0,t.jsxs)("option",{value:K,children:["v",K]},K)}):null]})]}),(0,t.jsx)("button",{type:"button",onClick:r(()=>R(O.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)(Sa,{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]},O.id)})}):null,(0,t.jsxs)("button",{type:"button",onClick:A,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)(vn,{className:"size-3.5"}),"Add API access"]})]}),(0,t.jsxs)("p",{className:"text-(length:--text-micro) text-muted-foreground/70",children:[oJe("api")," The agent reads them by alias through ",(0,t.jsx)("code",{children:"GET /agents/me/secrets"}),"."]})]})}r(yJe,"AgentSecretAccessEditor");function jJe(e){if(typeof e!="string")return null;const s=e.trim();return s.length>0?s:null}r(jJe,"asNonEmptyString$3");function wJe(e){return jJe(e)!==null}r(wJe,"hasLegacyWorkingDirectory");function NJe(e){return e.isCreate?!1:wJe(e.adapterConfig?.cwd)}r(NJe,"shouldShowLegacyWorkingDirectoryField");var Y0e=new Set;function kJe(e){return Y0e.has(e)}r(kJe,"isAdapterTypeHidden");function SJe(e){Y0e=new Set(e)}r(SJe,"setDisabledAdapterTypes");function CJe(e){return!Jm(e).hideFromVisualSelection}r(CJe,"isVisualAdapterChoice");function X0e(e,s=q8()){const n=e??kf;return s.map(a=>({value:a.type,label:n(a.type),comingSoon:!!Jm(a.type).comingSoon,hidden:kJe(a.type),experimental:!!Jm(a.type).experimental}))}r(X0e,"listAdapterOptions");function J0e(e={}){const s=e.enabled??!0,{data:n}=J({queryKey:P.adapters.all,queryFn:r(()=>Fm.list(),"queryFn"),enabled:s,staleTime:3e5});return n&&CXe(n.filter(a=>a.source==="external").map(a=>({type:a.type,label:a.label,disabled:a.disabled,overrideDisabled:a.overridePaused}))),(0,m.useEffect)(()=>{n&&SJe(n.filter(a=>a.disabled).map(a=>a.type))},[n]),(0,m.useMemo)(()=>new Set(n?.filter(a=>a.disabled).map(a=>a.type)??[]),[n])}r(J0e,"useDisabledAdaptersSync");function _Je(e={}){const s=e.enabled??!0,{data:n}=J({queryKey:P.adapters.all,queryFn:r(()=>Fm.list(),"queryFn"),enabled:s,staleTime:3e5});return n!==void 0}r(_Je,"useAdapterRegistryLoaded");function B5(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))}r(B5,"omitUndefinedEntries");function hA(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=B5(s.adapterType!==void 0?{...Object.fromEntries(TRe.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=B5({...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(hA,"buildAgentUpdatePatch");var IJe="kubernetes";function AJe(e){return e.driver!=="sandbox"?!1:e.config?.provider===IJe}r(AJe,"isKubernetesSandboxEnvironment");function G8(e,s){return e!=="kubernetes"?{forced:!1,kubernetesEnvironment:null}:{forced:!0,kubernetesEnvironment:s.find(n=>AJe(n))??null}}r(G8,"resolveForcedKubernetesEnvironment");var GL={identity:{},adapterConfig:{},heartbeat:{},debug:{},runtime:{}},Kk={};function TJe(e){return e==="claude_local"||e==="codex_local"||e==="paperclip_runner"||e==="opencode_local"}r(TJe,"supportsAdapterModelRefresh");function RJe(e,s){return Rfe(e,s).model}r(RJe,"resolvePaperclipRunnerTransitionModel");function UJ(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(UJ,"isOverlayDirty");function t6(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)=>t6(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&&t6(o,a[i]))}return!1}r(t6,"overlayValuesEqual");function EJe(e,s){const n=r((a,i)=>Object.fromEntries(Object.entries(a).filter(([o,l])=>!(o in i)||!t6(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(EJe,"subtractPersistedOverlay");var _m="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 PJe(e){return e.split(",").map(s=>s.trim()).filter(Boolean)}r(PJe,"parseCommaArgs");function MJe(e){return Array.isArray(e)?e.filter(s=>typeof s=="string").join(", "):typeof e=="string"?e:""}r(MJe,"formatArgList");var LJe=[{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"}],DJe=[{id:"",label:"Auto"},{id:"plan",label:"Plan"},{id:"ask",label:"Ask"}],$Je=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"medium",label:"Medium"},{id:"high",label:"High"}],OJe=[{id:"",label:"Auto"},{id:"low",label:"Low"},{id:"high",label:"High"},{id:"max",label:"Max"}],FJe=2,KJ=10,BJe=1,Z0e=300;function LT(e,s,n){return Math.max(s,Math.min(n,Math.floor(e)))}r(LT,"clampInteger");function qJe(e){return LT(e,0,Z0e)*1e3}r(qJe,"clampDelayMsFromSeconds");function zJe({order:e,className:s,children:n}){if(!e)return(0,t.jsx)("div",{className:s,children:n});const a=r(o=>{const l=(0,m.isValidElement)(o)?o.props["data-config-section"]:void 0,c=l?e.indexOf(l):-1;return c<0?e.length:c},"rank"),i=m.Children.toArray(n).sort((o,l)=>a(o)-a(l));return(0,t.jsx)("div",{className:s,children:i})}r(zJe,"ConfigSections");function ebe(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,u=e.showCreateRunPolicySection??!0,h=e.hideInstructionsFile??!1,p=e.canConfigureProviderTrace===!0,{selectedCompanyId:f}=ps(),g=Ut(),v=(0,m.useRef)(null),y=J0e(),{data:w=[]}=J({queryKey:f?P.secrets.list(f):["secrets","none"],queryFn:r(()=>vr.list(f),"queryFn"),enabled:!!f}),{data:k=[]}=J({queryKey:f?P.secrets.userDefinitions(f):["user-secret-definitions","none"],queryFn:r(()=>vr.listUserSecretDefinitions(f),"queryFn"),enabled:!!f,retry:!1}),j=a?null:e.agent.id,{data:N=[]}=J({queryKey:f?P.secrets.proposals(f,"pending"):["secret-proposals","none"],queryFn:r(()=>vr.listProposals(f,"pending"),"queryFn"),enabled:!!f&&!a,retry:!1}),_=(0,m.useMemo)(()=>N.filter(et=>et.kind==="binding"&&et.target?.id===j),[N,j]),I=W0e(f,[]),{data:C}=J({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn"),retry:!1}),T=(0,m.useMemo)(()=>{const et=new Set(y);return C?.enableNativeRunner!==!0&&et.add("paperclip_runner"),et},[y,C?.enableNativeRunner]),R=C?.enableEnvironments===!0,A=C?.enableManagedSandboxOnly===!0,L=C===void 0||A,{data:D}=J({queryKey:P.instance.generalSettings,queryFn:r(()=>Tr.getGeneral(),"queryFn"),retry:!1}),{data:O}=J({queryKey:P.instance.settings,queryFn:r(()=>Tr.get(),"queryFn"),retry:!1}),{data:E=[]}=J({queryKey:f?P.environments.list(f):["environments","none"],queryFn:r(()=>Ri.list(f),"queryFn"),enabled:!!f&&(R||D?.executionMode==="kubernetes")}),{forced:q,kubernetesEnvironment:B}=(0,m.useMemo)(()=>G8(D?.executionMode,E),[D?.executionMode,E]),U=Ne({mutationFn:r(et=>{if(!f)throw new Error("Select an organization to create secrets");return vr.create(f,et)},"mutationFn"),onSuccess:r(()=>{f&&g.invalidateQueries({queryKey:P.secrets.list(f)})},"onSuccess")}),z=Ne({mutationFn:r(async({file:et,namespace:Gt})=>{if(!f)throw new Error("Select an organization to upload images");return P0.uploadImage(f,et,Gt)},"mutationFn")}),[$,K]=(0,m.useState)(GL),[H,se]=(0,m.useState)(!1),[Z,ie]=(0,m.useState)(0),oe=(0,m.useRef)(null),Y=(0,m.useRef)(null),ne=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!a){if(oe.current!==null&&e.agent!==oe.current&&!ne.current){const et=Y.current;Y.current=null,K(Gt=>et?EJe(Gt,et):{...GL})}oe.current=e.agent}},[a,a?void 0:e.agent]);const de=!a&&(UJ($)||H);function ee(et,Gt,mn){const Os=$[et];return Gt in Os?Os[Gt]:mn}r(ee,"eff");function X(et,Gt,mn){K(Os=>({...Os,[et]:{...Os[et],[Gt]:mn}}))}r(X,"mark");function Q(){return v.current?.flushPendingDraft()??null}r(Q,"flushEnvironmentDraft");const fe=(0,m.useCallback)(et=>{a||K(Gt=>{const mn={...e.agent.adapterConfig??{},...Gt.adapterConfig},Os={...Gt.adapterConfig};for(const[Jn,Nr]of Object.entries(et))Os[`${P_}${Jn}`]=Nr;for(const Jn of Object.keys(mn))Jn.startsWith("access.")&&(Jn.slice(7)in et||(Os[Jn]=void 0));return{...Gt,adapterConfig:Os}})},[a,a?void 0:e.agent]),te=(0,m.useCallback)(()=>{K({...GL}),se(!1),ie(et=>et+1)},[]),ae=(0,m.useCallback)(async()=>{if(a)return;const et=Q(),Gt=et?{...$,adapterConfig:{...$.adapterConfig,env:et}}:$;UJ(Gt)&&await e.onSave(hA(e.agent,Gt))},[a,de,$,e]);(0,m.useEffect)(()=>{a||(e.onDirtyChange?.(de),e.onSaveActionChange?.(ae),e.onCancelActionChange?.(te))},[a,de,e.onDirtyChange,e.onSaveActionChange,e.onCancelActionChange,ae,te]),(0,m.useEffect)(()=>{if(!a)return()=>{e.onSaveActionChange?.(null),e.onCancelActionChange?.(null),e.onDirtyChange?.(!1)}},[a,e.onDirtyChange,e.onSaveActionChange,e.onCancelActionChange]);const le=a?{}:e.agent.adapterConfig??{},ce=a?{}:e.agent.runtimeConfig??{},he=a?{}:ce.heartbeat??{},ve=a?{}:ce.debug??{},pe=a?e.values.adapterType:$.adapterType??e.agent.adapterType,xe=ey(),_e=xe(pe),ge=_e.supportsInstructionsBundle||_e.supportsSkills||_e.supportsLocalAgentJwt,Ie=ge&&!L&&NJe({isCreate:a,adapterConfig:le}),Ye=(0,m.useMemo)(()=>YN(pe),[pe]),$e=(0,m.useMemo)(()=>new Set(J3e(pe)),[pe]),Xe=a?e.values:null,ue=a?et=>e.onChange(et):null;a&&Xe.claudeStoredSessionId;const Oe=r(()=>{f&&g.invalidateQueries({queryKey:P.secrets.userDefinitions(f)})},"invalidateUserSecretDefinitions"),dt=r(et=>{if(!a||!ue)return;const Gt=Xe.envBindings??{};ue({envBindings:{...Gt,...Gj()},claudeStoredSessionId:et}),Oe()},"handleClaudeLoginStored"),xt=r(async()=>{if(a)return;const et={...Q()??ee("adapterConfig","env",le.env??Kk),...Gj()},Gt={...$,adapterConfig:{...$.adapterConfig,env:et}};K(Gt),await e.onSave({...hA(e.agent,Gt),applyStoredClaudeLogin:!0}),Oe()},"handleClaudeLoginStoredEdit"),Le=r(async et=>{if(a||!et.companyIdentityDiffers)return;const Gt={...Q()??ee("adapterConfig","env",le.env??Kk),CODEX_HOME:{type:"secret_ref",secretId:et.secretId,version:"latest"}},mn={...$,adapterConfig:{...$.adapterConfig,env:Gt}};K(mn),Y.current=mn,ne.current=!0;try{await e.onSave(hA(e.agent,mn))}catch(Os){throw Y.current=null,Os}finally{ne.current=!1}Oe()},"handleCodexAccountBindingEdit"),Ge=r(()=>{if(!a||!ue)return;const et=Xe.envBindings??{};ue({envBindings:{...et,...Gj()},claudeApplyStoredLogin:!0}),Oe()},"handleApplyStoredClaudeLogin"),ht=r(async()=>{if(a)return;const et={...Q()??ee("adapterConfig","env",le.env??Kk),...Gj()},Gt={...$,adapterConfig:{...$.adapterConfig,env:et}};K(Gt),await e.onSave({...hA(e.agent,Gt),applyStoredClaudeLogin:!0}),Oe()},"handleApplyStoredClaudeLoginEdit"),Ve=a?Xe.defaultEnvironmentId??"":ee("identity","defaultEnvironmentId",e.agent.defaultEnvironmentId??""),Ke=(0,m.useMemo)(()=>Ve?(E.find(et=>et.id===Ve)??null)?.driver==="local"?"":Ve:"",[E,Ve]),gt=(0,m.useMemo)(()=>E.find(et=>et.id===Ke)??null,[Ke,E]),tt=(0,m.useMemo)(()=>{const et=O?.defaultEnvironmentId??null;return et?(E.find(Gt=>Gt.id===et)??null)?.driver==="local"?"":et:""},[E,O?.defaultEnvironmentId]),Se=(0,m.useMemo)(()=>E.find(et=>et.id===tt)??null,[E,tt]),ke=(0,m.useMemo)(()=>{try{return sN({agentDefaultEnvironmentId:Ve||null,instanceDefaultEnvironmentId:O?.defaultEnvironmentId??null,localDefaultEnvironmentId:rN(E),managedSandboxOnly:C?.enableManagedSandboxOnly===!0,managedSandboxEnvironmentId:nN(E),visibleEnvironmentIds:E.map(et=>et.id)})}catch{return null}},[Ve,O?.defaultEnvironmentId,E,C?.enableManagedSandboxOnly]),Je=(0,m.useMemo)(()=>E.find(et=>et.id===ke)??null,[E,ke]),{data:ut}=J({queryKey:f?P.environments.capabilities(f):["environment-capabilities","none"],queryFn:r(()=>Ri.capabilities(f),"queryFn"),enabled:!!f&&_e.login!=null});(0,m.useEffect)(()=>{!a||!ue||!q||!B||Ke!==B.id&&ue({defaultEnvironmentId:B.id})},[a,ue,q,B,Ke]);const Dt=(0,m.useMemo)(()=>E.filter(et=>{if(!$e.has(et.driver)||et.driver==="local")return!1;if(et.driver!=="sandbox")return!0;const Gt=typeof et.config?.provider=="string"?et.config.provider:null;return Gt!==null&&Gt!=="fake"}),[E,$e]),Jt=(0,m.useMemo)(()=>!gt||Dt.some(et=>et.id===gt.id)?Dt:[...Dt,gt],[gt,Dt]),fs=R&&(q||Ke.length>0||Dt.length>=1),We=Se?aN(Se):A?"Paperclip Computer":"Local",He=pe==="paperclip_runner"?String(a?e.values.adapterSchemaValues?.provider??"codex":ee("adapterConfig","provider",le.provider==="acpx"&&le.acpxAgent==="codex"?"codex":le.provider??"codex")):void 0,ct=pe==="opencode_local"&&cT.safeParse($.runtime.runtimeConfig?.aiConnection??ce.aiConnection).data?.provider==="openrouter"?"openrouter":He,ze=f?P.agents.adapterModels(f,pe,Ke||null,ct):["agents","none","adapter-models",pe],{data:is,error:Fe}=J({queryKey:ze,queryFn:r(()=>Vt.adapterModels(f,pe,{environmentId:Ke||null,provider:ct}),"queryFn"),enabled:!!f}),[Qt,Tt]=(0,m.useState)(null),[Ms,Ue]=(0,m.useState)(!1),pt=is??n??[],$t="command",{data:gs,refetch:Rs}=J({queryKey:f?P.agents.detectModel(f,pe):["agents","none","detect-model",pe],queryFn:r(()=>{if(!f)throw new Error("Select an organization to detect the model");return Vt.detectModel(f,pe)},"queryFn"),enabled:!!(f&&ge&&pe!=="opencode_local"&&pe!=="paperclip_runner")}),Ct=gs?.model??null;gs?.candidates;const{data:we=[]}=J({queryKey:f?P.agents.list(f):["agents","none","list"],queryFn:r(()=>Vt.list(f),"queryFn"),enabled:!!(!a&&f)}),Pe={mode:s,isCreate:a,adapterType:pe,values:a?e.values:null,set:a?et=>e.onChange(et):null,config:le,eff:ee,mark:X,models:pt,hideInstructionsFile:h||L,managedSandboxOnly:L},[lt,Ot]=(0,m.useState)(!1),[ft,us]=(0,m.useState)(!1),dn=r0e(pe),xs=r(et=>(0,t.jsxs)(t.Fragment,{children:[pe==="claude_local"&&(0,t.jsx)(lGe,{...Pe,section:et}),(0,t.jsx)(Ye.ConfigFields,{...Pe,section:et,hideModel:ge})]}),"renderAdapterFields"),[bs,qe]=(0,m.useState)(!1),[Nt,St]=(0,m.useState)(!1);function Ee(et){if(a){const mn=Ye.buildAdapterConfig(Xe);return et&&Object.assign(mn,et),B5(mn)}const Gt={...le,...$.adapterConfig};return et&&Object.assign(Gt,et),B5(Gt)}r(Ee,"buildAdapterConfigForTest");const De=Ne({mutationFn:r(async()=>{if(!f)throw new Error("Select an organization to test adapter environment");const et=Q(),Gt=et?{env:et}:void 0;let mn=O,Os=E,Jn=C?.enableManagedSandboxOnly===!0;if(!Ve)try{const[rs,fn,Hs]=await Promise.all([g.ensureQueryData({queryKey:P.instance.settings,queryFn:r(()=>Tr.get(),"queryFn")}),g.ensureQueryData({queryKey:P.environments.list(f),queryFn:r(()=>Ri.list(f),"queryFn")}),g.ensureQueryData({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn")})]);mn=rs,Os=fn,Jn=Hs?.enableManagedSandboxOnly===!0}catch{throw new Error("Could not load environment settings to determine which environment to test in. Retry the test.")}const Nr=sN({agentDefaultEnvironmentId:Ve||null,instanceDefaultEnvironmentId:mn?.defaultEnvironmentId??null,localDefaultEnvironmentId:rN(Os),managedSandboxOnly:Jn,managedSandboxEnvironmentId:nN(Os),visibleEnvironmentIds:Os.map(rs=>rs.id)}),_a=Ee(Gt),Un=a?void 0:e.agent.id,Zn=a?void 0:cT.safeParse($.runtime.runtimeConfig?.aiConnection??e.agent.runtimeConfig.aiConnection).data;if(e.compactTestFeedback){const rs=pe==="paperclip_runner"?_a.provider==="codex"?"codex_local":_a.provider==="acpx"&&_a.acpxAgent==="claude"?"claude_local":pe:pe;return Yge({companyId:f,adapterType:pe,providerAdapter:rs,adapterConfig:_a,agentId:Un,aiConnection:Zn,environmentId:Nr})}return Vt.testEnvironment(f,pe,{adapterConfig:_a,agentId:Un,aiConnection:Zn,environmentId:Nr})},"mutationFn")}),[Ze,kt]=(0,m.useState)(!1),[Kt,Lt]=(0,m.useState)(null),Ft="Test",Yt=!a&&!!e.isSaving,Vs=Ze||Yt||!f,In=(0,m.useRef)(De.reset);In.current=De.reset;const An=(0,m.useRef)(()=>{});An.current=()=>{if(!a||!ue)return;const et=Xe.envBindings??{},Gt=Xe.claudeStoredSessionId!=null||Xe.claudeApplyStoredLogin===!0,mn=PJ in et;if(!Gt&&!mn)return;const Os={...et};delete Os[PJ],ue({envBindings:Os,claudeStoredSessionId:null,claudeApplyStoredLogin:!1})},(0,m.useEffect)(()=>{In.current(),Lt(null),An.current()},[pe,ke]);const tn=_e.login!=null,Us=De.data,ws=Us!=null&&xe(Us.adapterType).login!=null,nn=Us&&ws?Us.checks.find(et=>et.code==="adapter_auth_missing")??null:null,zs=typeof Je?.config?.provider=="string"?Je.config.provider:null,Tn=zs!=null&&ut?.sandboxProviders?.[zs]?.supportsLoginPty===!0,pn=_e.login!=null,rn=(a||!($.runtime.runtimeConfig?.aiConnection??ce.aiConnection))&&tn&&Je?.driver==="sandbox"&&!!ke&&!!f&&!!nn&&(!pn||Tn),br=(0,m.useCallback)(async()=>{if(!f)throw new Error("Select an organization to test adapter environment");kt(!0),Lt(null),De.reset();try{return await De.mutateAsync()}catch(et){throw Lt(et instanceof Error?et.message:"Environment test failed"),et}finally{kt(!1)}},[f,De]),Zs=(0,m.useRef)(()=>{});(0,m.useEffect)(()=>{Zs.current=()=>{Vs||br().catch(()=>{})}},[br,Vs]);const nr=(0,m.useCallback)(()=>{Zs.current()},[]);(0,m.useEffect)(()=>{if(!(!l||!e.onTestActionChange))return e.onTestActionChange(nr),()=>{e.onTestActionChange?.(null)}},[l,e.onTestActionChange,nr]),(0,m.useEffect)(()=>{if(!(!l||!e.onTestActionStateChange))return e.onTestActionStateChange({disabled:Vs,pending:Ze}),()=>{e.onTestActionStateChange?.({disabled:!0,pending:!1})}},[l,e.onTestActionStateChange,Vs,Ze]),(0,m.useEffect)(()=>{if(e.onTestFeedbackChange)return e.onTestFeedbackChange({errorMessage:Kt??(De.error instanceof Error?De.error.message:De.error?"Environment test failed":null),result:De.data??null,login:rn&&f&&ke?{companyId:f,adapterType:pe,environmentId:ke}:null}),()=>{e.onTestFeedbackChange?.({errorMessage:null,result:null,login:null})}},[e.onTestFeedbackChange,Kt,De.data,De.error,rn,f,pe,ke]);const rr=a?Xe.model??"":ee("adapterConfig","model",String(le.model??"")),Wr=typeof rr=="string"?rr:"";async function xr(){if(f){Ue(!0),Tt(null);try{const et=await Vt.adapterModels(f,pe,{refresh:!0,environmentId:Ke||null,provider:ct});g.setQueryData(ze,et)}catch(et){Tt(et instanceof Error?et.message:"Failed to refresh adapter models.")}finally{Ue(!1)}}}r(xr,"handleRefreshModels");const wr=pe==="codex_local"?"modelReasoningEffort":pe==="cursor"?"mode":pe==="opencode_local"?"variant":pe==="grok_local"?"reasoningEffort":pe==="pi_local"?"thinking":"effort",ar=pe==="codex_local"?t1(Wr,"Auto").map(et=>({id:et.value,label:et.label})):pe==="cursor"?DJe:pe==="opencode_local"?LJe:pe==="kimi_local"?OJe:pe==="pi_local"?[{id:"",label:"Auto"},...["off","minimal","low","medium","high","xhigh"].map(et=>({id:et,label:et}))]:pe==="claude_local"||pe==="grok_local"?[{id:"",label:"Auto"},...M5(pe,Wr).map(et=>({id:et,label:et==="xhigh"?"X-High":et[0].toUpperCase()+et.slice(1)}))]:$Je,aa=a?Xe.thinkingEffort:pe==="codex_local"?ee("adapterConfig","modelReasoningEffort",String(le.modelReasoningEffort??le.reasoningEffort??"")):pe==="cursor"?ee("adapterConfig","mode",String(le.mode??"")):pe==="opencode_local"?ee("adapterConfig","variant",String(le.variant??"")):ee("adapterConfig",wr,String(le[wr]??"")),qn=pe!=="gemini_local"&&pe!=="cursor_cloud"&&pe!=="paperclip_runner",Rr=pe==="codex_local"?a?!!Xe.search:ee("adapterConfig","search",!!le.search):!1,Na=(0,m.useMemo)(()=>{if(a)return{heartbeat:{enabled:Xe.heartbeatEnabled,intervalSec:Xe.intervalSec}};const et={...ce.heartbeat&&typeof ce.heartbeat=="object"?ce.heartbeat:{},...$.heartbeat};return{...ce,heartbeat:et}},[a,$.heartbeat,ce,Xe]),Sn=LG(Na.heartbeat),On=LG(Sn.maxTurnContinuation),on=NRe(On.enabled,!0),mr=LT(FG(On.maxAttempts,FJe),0,KJ),bt=LT(FG(On.delayMs,BJe*1e3)/1e3,0,Z0e);function Ls(et){X("heartbeat","maxTurnContinuation",{...On,...et})}r(Ls,"updateMaxTurnContinuation");const Fs=(0,t.jsx)(Tv,{ref:v,onDirtyChange:se,hideDraftActions:!a&&e.hideInlineSave,value:a?Xe.envBindings??Kk:ee("adapterConfig","env",le.env??Kk),secrets:w,userSecretDefinitions:k,onCreateSecret:r(async(et,Gt)=>await U.mutateAsync({name:et,value:Gt}),"onCreateSecret"),onChange:r(et=>a?ue({envBindings:et??{},envVars:""}):X("adapterConfig","env",et),"onChange")},Z);return!a&&e.content==="secrets"?(0,t.jsxs)("div",{className:W("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:W(!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:W(i?"rounded-lg border border-border p-4":"px-4 pb-3"),children:Fs})]}),(0,t.jsxs)("div",{"data-config-section":"secrets",className:W(!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:W(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:gi.secretAccess}),(0,t.jsx)(yJe,{config:{...le,...$.adapterConfig},secrets:w,onChange:fe,onCreateSecret:r((et,Gt)=>U.mutateAsync({name:et,value:Gt}),"onCreateSecret"),proposals:_,onApproveProposal:I.requestApprove,onRejectProposal:I.requestReject}),I.dialogs]})]})]}):(0,t.jsxs)(zJe,{order:e.sectionOrder,className:W("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:W(!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:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[(0,t.jsx)(ys,{label:"Name",hint:gi.name,children:(0,t.jsx)(qa,{value:ee("identity","name",e.agent.name),onCommit:r(et=>X("identity","name",et),"onCommit"),immediate:!0,className:_m,placeholder:"Agent name"})}),(0,t.jsx)(ys,{label:"Title",hint:gi.title,children:(0,t.jsx)(qa,{value:ee("identity","title",e.agent.title??""),onCommit:r(et=>X("identity","title",et||null),"onCommit"),immediate:!0,className:_m,placeholder:"e.g. VP of Engineering"})}),(0,t.jsx)(ys,{label:"Reports to",hint:gi.reportsTo,children:(0,t.jsx)(EXe,{agents:we,value:ee("identity","reportsTo",e.agent.reportsTo??null),onChange:r(et=>X("identity","reportsTo",et),"onChange"),excludeAgentIds:[e.agent.id],chooseLabel:"Choose manager…"})}),ge&&!e.hidePromptTemplate&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ys,{label:"Prompt Template",hint:gi.promptTemplate,children:(0,t.jsx)(Ic,{value:ee("adapterConfig","promptTemplate",String(le.promptTemplate??"")),onChange:r(et=>X("adapterConfig","promptTemplate",et??""),"onChange"),placeholder:"You are agent {{ agent.name }}. Your role is {{ agent.role }}...",contentClassName:"min-h-(--sz-88px) text-sm font-mono",imageUploadHandler:r(async et=>{const Gt=`agents/${e.agent.id}/prompt-template`;return(await z.mutateAsync({file:et,namespace:Gt})).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:W(!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:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(ys,{label:"Default environment",hint:"This instance runs all agents in the Kubernetes sandbox. Local execution is disabled.",children:B?(0,t.jsxs)("div",{className:W(_m,"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."})})})]}):fs?(0,t.jsxs)("div",{"data-config-section":"environment",className:W(!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:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(ys,{label:"Environment override",children:(0,t.jsx)("div",{className:"space-y-2",children:(0,t.jsxs)("select",{className:_m,value:Ke,onChange:r(et=>{const Gt=et.target.value;if(a){ue({defaultEnvironmentId:Gt});return}X("identity","defaultEnvironmentId",Gt||null)},"onChange"),children:[(0,t.jsxs)("option",{value:"",children:["Default: ",We]}),Jt.map(et=>(0,t.jsx)("option",{value:et.id,children:aN(et)},et.id))]})})})})]}):null,(0,t.jsxs)("div",{"data-config-section":"adapter",className:W(!i&&(a?"border-t border-border":"border-b border-border")),children:[(0,t.jsxs)("div",{className:W(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:nr,disabled:Vs,children:Ze?`${Ft}...`:Ft})]}),(0,t.jsxs)("div",{className:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[o&&(0,t.jsx)(ys,{label:"Adapter type",hint:gi.adapterType,children:(0,t.jsx)(sbe,{value:pe,disabledTypes:T,onChange:r(et=>{if(a){const{adapterType:Gt,...mn}=j0,Os={...mn,adapterType:et};et==="codex_local"?Os.dangerouslyBypassSandbox=!0:et==="gemini_local"?Os.model="auto":et==="kimi_local"?Os.model="kimi-code/kimi-for-coding":et==="cursor"?Os.model="auto":et==="opencode_local"?Os.model="openai/gpt-5.2-codex":et==="paperclip_runner"&&(Os.model=Xw),ue(Os)}else K(Gt=>({...Gt,adapterType:et,adapterConfig:{model:et==="gemini_local"?"auto":et==="kimi_local"?"kimi-code/kimi-for-coding":et==="opencode_local"?"openai/gpt-5.2-codex":et==="cursor"?"auto":et==="paperclip_runner"?RJe(pe,le.model):"",effort:"",modelReasoningEffort:"",variant:"",mode:"",...et==="codex_local"?{dangerouslyBypassApprovalsAndSandbox:!0}:et==="paperclip_runner"?{...Rfe(pe,ee("adapterConfig","model",le.model))}:{}}}))},"onChange")})}),!a&&f&&(0,t.jsx)(Qge,{companyId:f,agentId:e.agent.id,agentName:e.agent.name,adapterType:pe==="paperclip_runner"?ee("adapterConfig","provider",le.provider)==="codex"?"codex_local":ee("adapterConfig","provider",le.provider)==="opencode"?"opencode_local":ee("adapterConfig","provider",le.provider)==="acpx"&&ee("adapterConfig","acpxAgent",le.acpxAgent)==="claude"?"claude_local":pe:pe,value:cT.safeParse($.runtime.runtimeConfig?.aiConnection??ce.aiConnection).data,model:String(ee("adapterConfig","model",le.model)??""),environmentId:Ke||void 0,legacy:!0,onChange:r(et=>X("runtime","runtimeConfig",{...ce,aiConnection:et}),"onChange")}),d&&!e.compactTestFeedback&&(Kt||De.error)&&(0,t.jsx)("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:Kt??(De.error instanceof Error?De.error.message:"Environment test failed")}),d&&!e.compactTestFeedback&&De.data&&(0,t.jsx)(QJe,{result:De.data}),d&&rn&&(0,t.jsx)(Q8,{companyId:f,adapterType:pe,environmentId:ke,onStored:a?dt:xt,onApplyStored:a?Ge:ht,onAccountBinding:a?void 0:Le},`${pe}:${ke}`),Ie&&(0,t.jsx)(ys,{label:"Working directory (deprecated)",hint:gi.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)(Ao,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)(qa,{value:a?Xe.cwd:ee("adapterConfig","cwd",String(le.cwd??"")),onCommit:r(et=>a?ue({cwd:et}):X("adapterConfig","cwd",et||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)(yd,{})]})}),xs("adapter"),ge&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y8,{models:pt,value:Wr,onChange:r(et=>{const Gt=M5(pe,et),mn=["codex_local","claude_local","grok_local"].includes(pe)&&!!aa&&!Gt.includes(String(aa));if(a){ue({model:et,...mn?{thinkingEffort:""}:{}});return}X("adapterConfig","model",et||void 0),mn&&(X("adapterConfig",wr,void 0),X("adapterConfig","reasoningEffort",void 0))},"onChange"),open:bs,onOpenChange:qe,defaultLabel:pe==="claude_local"?"Default (claude-opus-5)":void 0,allowDefault:pe!=="opencode_local"&&pe!=="pi_local"&&pe!=="paperclip_runner",required:pe==="opencode_local"||pe==="pi_local",groupByProvider:pe==="opencode_local"||pe==="pi_local",creatable:!0,detectedModel:Ct,detectedModelCandidates:[],onDetectModel:pe==="opencode_local"||pe==="paperclip_runner"?void 0:async()=>(await Rs()).data?.model??null,onRefreshModels:TJe(pe)?xr:void 0,refreshingModels:Ms,detectModelLabel:"Detect model",emptyDetectHint:"No model detected. Select or enter one manually."}),(Qt||Fe)&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:Qt??(Fe instanceof Error?Fe.message:"Failed to load adapter models.")}),pe==="opencode_local"&>&>.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 ",gt.name,"."]}),qn&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(YJe,{value:aa,options:ar,onChange:r(et=>a?ue({thinkingEffort:et}):X("adapterConfig",wr,et||void 0),"onChange"),open:Nt,onOpenChange:St}),pe==="codex_local"&&Rr&&aa==="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:W(!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:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[!a&&typeof le.bootstrapPromptTemplate=="string"&&le.bootstrapPromptTemplate&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ys,{label:"Bootstrap prompt (legacy)",hint:gi.bootstrapPrompt,children:(0,t.jsx)(Ic,{value:ee("adapterConfig","bootstrapPromptTemplate",String(le.bootstrapPromptTemplate??"")),onChange:r(et=>X("adapterConfig","bootstrapPromptTemplate",et||void 0),"onChange"),placeholder:"Optional initial setup prompt for the first run",contentClassName:"min-h-(--sz-44px) text-sm font-mono",imageUploadHandler:r(async et=>{const Gt=`agents/${e.agent.id}/bootstrap-prompt`;return(await z.mutateAsync({file:et,namespace:Gt})).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."})]}),xs("configuration"),(ge||pe==="process"||dn?.fields.some(et=>FB(et.key)==="advanced"))&&(0,t.jsx)(IT,{title:"Advanced",open:ft,onToggle:r(()=>us(!ft),"onToggle"),children:(0,t.jsxs)("div",{className:"space-y-3",children:[ge&&(0,t.jsxs)(t.Fragment,{children:[" ",!L&&(0,t.jsx)(ys,{label:"Command",hint:gi.localCommand,children:(0,t.jsx)(qa,{value:a?Xe.command:ee("adapterConfig",$t,String(le.command??"")),onCommit:r(et=>a?ue({command:et}):X("adapterConfig",$t,et||null),"onCommit"),immediate:!0,className:_m,placeholder:{claude_local:"claude",codex_local:"codex",gemini_local:"gemini",kimi_local:"kimi",pi_local:"pi",cursor:"agent",opencode_local:"opencode"}[pe]??pe.replace(/_local$/,"")})}),(0,t.jsx)(ys,{label:"Extra args (comma-separated)",hint:gi.extraArgs,children:(0,t.jsx)(qa,{value:a?Xe.extraArgs:ee("adapterConfig","extraArgs",MJe(le.extraArgs)),onCommit:r(et=>a?ue({extraArgs:et}):X("adapterConfig","extraArgs",et?.trim()?PJe(et):null),"onCommit"),className:_m,placeholder:"e.g. --verbose, --foo=bar"})})]}),xs("advanced")]})})]})]}),e.environmentVariablesPlacement!=="secrets"&&(ge||dn?.fields.some(et=>FB(et.key)==="environment"))&&(0,t.jsxs)("div",{"data-config-section":"environment-variables",className:W(!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:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:ge?Fs:xs("environment")})]}),a&&u?(0,t.jsxs)("div",{"data-config-section":"run-policy",className:W(!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)(YI,{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)(YI,{className:"h-3 w-3"})," Run Policy"]}),(0,t.jsxs)("div",{className:W(i?"border border-border rounded-lg p-4 space-y-3":"px-4 pb-3 space-y-3"),children:[(0,t.jsx)(iJ,{label:"Heartbeat on interval",hint:gi.heartbeatInterval,checked:Xe.heartbeatEnabled,onCheckedChange:r(et=>ue({heartbeatEnabled:et}),"onCheckedChange"),number:Xe.intervalSec,onNumberChange:r(et=>ue({intervalSec:et}),"onNumberChange"),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:gi.intervalSec,showNumber:Xe.heartbeatEnabled}),(0,t.jsx)(IT,{title:"Advanced Run Policy",open:lt,onToggle:r(()=>Ot(!lt),"onToggle"),children:(0,t.jsx)("div",{className:"space-y-3",children:xs("runPolicy")})})]})]}):a?null:(0,t.jsxs)("div",{"data-config-section":"run-policy",className:W(!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)(YI,{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)(YI,{className:"h-3 w-3"})," Run Policy"]}),(0,t.jsxs)("div",{className:W(i?"border border-border rounded-lg overflow-hidden":""),children:[(0,t.jsx)("div",{className:W(i?"p-4 space-y-3":"px-4 pb-3 space-y-3"),children:(0,t.jsx)(iJ,{label:"Heartbeat on interval",hint:gi.heartbeatInterval,checked:ee("heartbeat","enabled",he.enabled===!0),onCheckedChange:r(et=>X("heartbeat","enabled",et),"onCheckedChange"),number:ee("heartbeat","intervalSec",Number(he.intervalSec??300)),onNumberChange:r(et=>X("heartbeat","intervalSec",et),"onNumberChange"),numberLabel:"sec",numberPrefix:"Run heartbeat every",numberHint:gi.intervalSec,showNumber:ee("heartbeat","enabled",he.enabled===!0)})}),(0,t.jsx)(IT,{title:"Advanced Run Policy",bordered:i,open:lt,onToggle:r(()=>Ot(!lt),"onToggle"),children:(0,t.jsxs)("div",{className:"space-y-3",children:[xs("runPolicy"),ge&&(0,t.jsx)(t.Fragment,{children:!a&&(0,t.jsxs)(t.Fragment,{children:[!dn?.fields.some(et=>et.key==="timeoutSec")&&(0,t.jsx)(ys,{label:"Timeout (sec)",hint:gi.timeoutSec,children:(0,t.jsx)(ic,{value:ee("adapterConfig","timeoutSec",Number(le.timeoutSec??0)),onCommit:r(et=>X("adapterConfig","timeoutSec",et),"onCommit"),immediate:!0,className:_m})}),!dn?.fields.some(et=>et.key==="graceSec")&&(0,t.jsx)(ys,{label:"Interrupt grace period (sec)",hint:gi.graceSec,children:(0,t.jsx)(ic,{value:ee("adapterConfig","graceSec",Number(le.graceSec??15)),onCommit:r(et=>X("adapterConfig","graceSec",et),"onCommit"),immediate:!0,className:_m})})]})}),(0,t.jsx)(md,{label:"Wake on demand",hint:gi.wakeOnDemand,checked:ee("heartbeat","wakeOnDemand",he.wakeOnDemand!==!1),onChange:r(et=>X("heartbeat","wakeOnDemand",et),"onChange")}),(0,t.jsx)(ys,{label:"Cooldown (sec)",hint:gi.cooldownSec,children:(0,t.jsx)(ic,{value:ee("heartbeat","cooldownSec",Number(he.cooldownSec??10)),onCommit:r(et=>X("heartbeat","cooldownSec",et),"onCommit"),immediate:!0,className:_m})}),(0,t.jsx)(ys,{label:"Max concurrent runs",hint:gi.maxConcurrentRuns,children:(0,t.jsx)(ic,{value:ee("heartbeat","maxConcurrentRuns",Number(he.maxConcurrentRuns??20)),onCommit:r(et=>X("heartbeat","maxConcurrentRuns",et),"onCommit"),immediate:!0,className:_m})}),(0,t.jsxs)("div",{className:"rounded-md border border-border/70 px-3 py-2",children:[(0,t.jsx)(md,{label:"Continue after max-turn stop",hint:gi.maxTurnContinuationEnabled,checked:on,onChange:r(et=>Ls({enabled:et}),"onChange")}),on?(0,t.jsxs)("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[(0,t.jsx)(ys,{label:"Continuation attempts",hint:gi.maxTurnContinuationMaxAttempts,children:(0,t.jsx)(ic,{value:mr,onCommit:r(et=>Ls({maxAttempts:LT(et,0,KJ)}),"onCommit"),immediate:!0,className:_m})}),(0,t.jsx)(ys,{label:"Continuation delay (sec)",hint:gi.maxTurnContinuationDelaySec,children:(0,t.jsx)(ic,{value:bt,onCommit:r(et=>Ls({delayMs:qJe(et)}),"onCommit"),immediate:!0,className:_m})})]}):null]})]})})]})]}),!a&&p?(0,t.jsxs)("div",{className:W(!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)(cw,{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)(cw,{className:"h-3 w-3"})," Debugging"]}),(0,t.jsxs)("div",{className:W("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)(md,{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:ee("debug","providerTrace",ve.providerTrace)==="raw",onChange:r(et=>X("debug","providerTrace",et?"raw":void 0),"onChange")}),ee("debug","providerTrace",ve.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)(cw,{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)(Zge,{state:Ze?"running":Kt||De.error?"fail":Us?.status??"idle",result:Us??null,error:Kt??(De.error instanceof Error?De.error.message:null),onTest:nr,disabled:Vs})]})}r(ebe,"AgentConfigForm");var s6=new Set(["authenticated","failed","timed_out","cancelled"]),n6=2e3;function r6({value:e,label:s}){const[n,a]=(0,m.useState)(!1),i=(0,m.useRef)(null);return(0,m.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 Xr(e),a(!0)}catch{a(!1)}i.current&&clearTimeout(i.current),i.current=setTimeout(()=>a(!1),1500)},"onClick"),children:n?(0,t.jsx)(ds,{className:"size-3"}):(0,t.jsx)(kr,{className:"size-3"})})}r(r6,"AdapterLoginCopyButton");function UJe({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)(ds,{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)(_s,{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(UJe,"AdapterLoginTerminalState");var KJe={claude_local:"Anthropic",codex_local:"OpenAI"};function tbe(e){const s=KJe[e];return s?`Sign in to ${s}`:"Sign in to the environment"}r(tbe,"adapterLoginTitle");function Q8(e){return ey()(e.adapterType).login?.panelMode==="submitted_browser_code"?(0,t.jsx)(GJe,{...e}):(0,t.jsx)(WJe,{...e})}r(Q8,"AdapterLoginPanel");function WJe({companyId:e,adapterType:s,environmentId:n,autoStart:a,onConnected:i,onAccountBinding:o,chrome:l="panel",aiConnection:c,onPromptReady:d}){const[u,h]=(0,m.useState)(null),[p,f]=(0,m.useState)(null),[g,v]=(0,m.useState)(null),[y,w]=(0,m.useState)("idle"),k=(0,m.useRef)(!1),j=Ne({mutationFn:r(()=>Vt.startAdapterAuthLogin(e,s,{environmentId:n,aiConnection:c}),"mutationFn"),onSuccess:r(Y=>{k.current=!1,f(null),v(null),w("idle"),h(Y.sessionId)},"onSuccess"),onError:r(Y=>{f(Y instanceof Error?Y.message:"Could not start the login.")},"onError")}),N=(0,m.useCallback)(()=>{k.current=!1,h(null),v(null),f(null)},[]),_=Ne({mutationFn:r(()=>Vt.cancelAdapterAuthLogin(e,s,u),"mutationFn"),onSuccess:N,onError:r(Y=>{f(Y instanceof Error?Y.message:"Could not cancel the login.")},"onError")}),I=J({queryKey:["adapter-login-active-session",e,s],queryFn:r(async()=>{try{const Y=await Vt.getActiveAdapterAuthLoginSession(e,s);if(!Y)return null;if(c&&Y.environmentId!==n||!!Y.aiConnection!=!!c||c&&(Y.aiConnection?.provider!==c.provider||Y.aiConnection?.method!==c.method||Y.aiConnection?.connectionId!==c.connectionId||Y.aiConnection?.ownership!==c.ownership||Y.aiConnection?.allAgents!==c.allAgents||JSON.stringify(Y.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 Y}catch(Y){if(Y instanceof cn&&Y.status===404)return null;throw Y}},"queryFn"),retry:!1,gcTime:0,staleTime:0}),[C,T]=(0,m.useState)(!1),R=J({queryKey:["adapter-login-status",e,s,u],queryFn:r(()=>Vt.getAdapterAuthLoginStatus(e,s,u),"queryFn"),enabled:!!u&&!C,retry:r((Y,ne)=>ne instanceof cn&&ne.status===404?!1:Y<3,"retry"),refetchInterval:r(Y=>{const ne=Y.state.data?.status;return ne&&s6.has(ne)?!1:n6},"refetchInterval")});(0,m.useEffect)(()=>{const Y=R.data?.prompt??null;Y&&v(Y)},[R.data]);const A=R.data??j.data??null,L=A?.status??null,D=g,O=L?s6.has(L):!1,E=!!u&&!O,q=j.isPending||E||y==="saving",B=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(B.current||!I.isFetched)return;B.current=!0;const Y=I.data;Y&&(k.current=!0,f(null),v(Y.prompt??null),h(Y.sessionId))},[I.isFetched,I.data]),(0,m.useEffect)(()=>{const Y=R.error;if(!(Y instanceof cn&&Y.status===404)||!k.current||C)return;T(!0);const ne=u;(async()=>(ne&&await Vt.cancelAdapterAuthLogin(e,s,ne).catch(()=>{}),T(!1),N()))()},[R.error,C,u,e,s,N]);const U=(0,m.useRef)(!1),z=(0,m.useRef)(j.mutate);z.current=j.mutate,(0,m.useEffect)(()=>{if(!(!a||U.current)){if(I.isError){U.current=!0,f(I.error instanceof Error?I.error.message:"Could not check for an active login.");return}I.isSuccess&&(U.current=!0,!I.data&&z.current())}},[a,I.isSuccess,I.isError,I.data,I.error]);const $=(0,m.useRef)(!1),K=(0,m.useRef)(i);K.current=i,(0,m.useEffect)(()=>{L!=="authenticated"||$.current||($.current=!0,K.current?.(u??void 0))},[L]);const H=(0,m.useRef)(null),se=(0,m.useRef)(o);se.current=o;const Z=R.data?.codexAccountBinding??null,ie=(0,m.useCallback)(async Y=>{const ne=se.current;if(ne){w("saving");try{await ne(Y),w("bound")}catch{w("failed")}}},[]);(0,m.useEffect)(()=>{L!=="authenticated"||!u||H.current!==u&&(!Z||!Z.companyIdentityDiffers||!se.current||(H.current=u,ie(Z)))},[L,u,Z,ie]);const oe=(0,m.useRef)(d);if(oe.current=d,(0,m.useEffect)(()=>{oe.current?.(D?.url??null)},[D]),l==="onboarding"){const Y=O&&L&&L!=="authenticated";return(0,t.jsx)(d0e,{loading:!D&&!p&&!Y,providerName:l0e(s),authorizationUrl:D?.url,mode:"displayed_code",children:p?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:p}):Y?(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)(UHe,{code:D?.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:tbe(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&&!D&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(rt,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Preparing..."})]}),E&&D&&(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:D.code})]}),(0,t.jsx)(r6,{value:D.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:D.url})]}),(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)(r6,{value:D.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:D.url,target:"_blank",rel:"noreferrer noopener",children:(0,t.jsx)(gr,{className:"size-3"})})})]})]})]}),O&&L&&(0,t.jsx)(UJe,{status:L,message:A?.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)(rt,{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)(ds,{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)(_s,{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(()=>{Z&&ie(Z)},"onClick"),children:"Retry"})]})]})]})}r(WJe,"DisplayedCodeLoginPanel");var VJe=new Set(["failed","timed_out","cancelled"]),WJ="The login did not finish. Start the login again.",HJe=9e5,VJ="The login timed out. Start the login again.";function GJe({companyId:e,adapterType:s,environmentId:n,onStored:a,onApplyStored:i,autoStart:o,onConnected:l,onCodeSubmitted:c,onSubmitFailed:d,chrome:u="panel",aiConnection:h,onPromptReady:p}){const[f,g]=(0,m.useState)(null),[v,y]=(0,m.useState)(null),[w,k]=(0,m.useState)(null),[j,N]=(0,m.useState)(!1),[_,I]=(0,m.useState)(""),[C,T]=(0,m.useState)(null),[R,A]=(0,m.useState)(!1),[L,D]=(0,m.useState)(!1),[O,E]=(0,m.useState)(!1),[q,B]=(0,m.useState)(!1),U=(0,m.useRef)(!1),[z,$]=(0,m.useState)(!1),K=(0,m.useRef)(!1),H=r(()=>{y(null),k(null),N(!1),I(""),T(null),A(!1),D(!1),B(!1),E(!1),U.current=!1},"resetLocalState"),se=J({queryKey:["claude-oauth-token-status",e],queryFn:r(async()=>{try{return await Vt.getClaudeOAuthTokenStatus(e)}catch(tt){if(tt instanceof cn&&tt.status===404)return null;throw tt}},"queryFn"),retry:r((tt,Se)=>Se instanceof cn&&Se.status===404?!1:tt<2,"retry")}).data??null,Z=Ne({mutationFn:r(()=>Vt.startClaudeSetupTokenLogin(e,{environmentId:n,aiConnection:h,...se&&!h?{overwrite:{expectedSecretId:se.secretId,expectedLatestVersion:se.latestVersion}}:{}}),"mutationFn"),onSuccess:r(tt=>{K.current=!1,H(),g(tt.sessionId)},"onSuccess"),onError:r(tt=>{y(tt instanceof Error?tt.message:"Could not start the login.")},"onError")}),ie=r(()=>{K.current=!1,g(null),H()},"clearActiveSession"),oe=Ne({mutationFn:r(()=>Vt.cancelClaudeSetupTokenLogin(e,f),"mutationFn"),onSuccess:r(()=>{ie()},"onSuccess"),onError:r(tt=>{if(tt instanceof cn&&tt.status===404){ie();return}y(tt instanceof Error?tt.message:"Could not cancel the login.")},"onError")}),Y=(0,m.useCallback)(tt=>{Vt.cancelClaudeSetupTokenLogin(e,tt).catch(()=>{})},[e]),ne=J({queryKey:["claude-setup-token-active-session",e],queryFn:r(async()=>{try{const tt=await Vt.getActiveClaudeSetupTokenLoginSession(e);if(!tt)return null;if(h&&tt.environmentId!==n||!!tt.aiConnection!=!!h||h&&(tt.aiConnection?.provider!==h.provider||tt.aiConnection?.method!==h.method||tt.aiConnection?.connectionId!==h.connectionId||tt.aiConnection?.ownership!==h.ownership||tt.aiConnection?.allAgents!==h.allAgents||JSON.stringify(tt.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 tt}catch(tt){if(tt instanceof cn&&tt.status===404)return null;throw tt}},"queryFn"),retry:!1,gcTime:0,staleTime:0}),[de,ee]=(0,m.useState)(!1),X=!!f&&!L&&!q&&!de,Q=J({queryKey:["claude-setup-token-status",e,f],queryFn:r(()=>Vt.getClaudeSetupTokenLoginStatus(e,f),"queryFn"),enabled:X,retry:r((tt,Se)=>Se instanceof cn&&Se.status===404?!1:tt<3,"retry"),refetchInterval:r(tt=>{if(L||q)return!1;const Se=tt.state.data?.status;return Se&&s6.has(Se)?!1:n6},"refetchInterval")});(0,m.useEffect)(()=>{const tt=Q.error;if(tt instanceof cn&&tt.status===404){if(K.current){if(de)return;ee(!0);const Se=f;(async()=>(Se&&await Vt.cancelClaudeSetupTokenLogin(e,Se).catch(()=>{}),ee(!1),ie()))();return}B(!0)}},[Q.error,de,f,e]);const fe=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(fe.current||!ne.isFetched)return;fe.current=!0;const tt=ne.data;tt&&(K.current=!0,H(),g(tt.sessionId),tt.prompt&&(k(tt.prompt.authorizationUrl),tt.prompt.transportAdvisory&&N(!0)))},[ne.isFetched,ne.data]);const te=J({queryKey:["claude-setup-token-prompt",e,f],enabled:X&&!w,queryFn:r(async()=>{try{return await Vt.getClaudeSetupTokenLoginPrompt(e,f)}catch(tt){if(tt instanceof cn&&tt.status===404)return null;throw tt}},"queryFn"),refetchInterval:r(tt=>L||tt.state.data?.authorizationUrl?!1:n6,"refetchInterval")});(0,m.useEffect)(()=>{const tt=te.data?.authorizationUrl??null;tt&&k(tt),te.data?.transportAdvisory&&N(!0)},[te.data]);const ae=Ne({mutationFn:r(tt=>Vt.submitClaudeSetupTokenBrowserCode(e,f,tt),"mutationFn"),onError:r(tt=>{y(tt instanceof Error?tt.message:"Could not submit the browser code.")},"onError")}),le=Ne({mutationFn:r(()=>Vt.completeClaudeSetupTokenLogin(e,f),"mutationFn"),onSuccess:r(tt=>{T(tt.storedSessionId),a?.(tt.storedSessionId)},"onSuccess"),onError:r(()=>{A(!0)},"onError")}),ce=Q.data?.status??Z.data?.status??null,he=Q.data?.expiresAt??Z.data?.expiresAt??null,ve=(0,m.useRef)(le.mutate);ve.current=le.mutate,(0,m.useEffect)(()=>{ce==="authenticated"&&!U.current&&(U.current=!0,ve.current())},[ce]);const pe=C!==null,xe=R||q||!!(ce&&VJe.has(ce)),_e=ce==="authenticated"&&!pe&&!R,ge=!!f&&!pe&&!xe&&!L,Ie=Z.isPending||ge;(0,m.useEffect)(()=>{if(!ge)return;const tt=he!==null?new Date(he).getTime():NaN,Se=Number.isFinite(tt)?Math.max(0,tt-Date.now()):HJe,ke=setTimeout(()=>{f&&Y(f),D(!0)},Se);return()=>clearTimeout(ke)},[ge,he,f,Y]);const Ye=_.trim(),$e=ge&&!!w&&!_e&&cRe(Ye)&&!ae.isPending&&!O,Xe=(0,m.useRef)(c);Xe.current=c;const ue=(0,m.useRef)(d);ue.current=d;const Oe=r(()=>{$e&&(y(null),ae.mutate(Ye),E(!0),Xe.current?.(),u!=="onboarding"&&I(""))},"handleSubmit"),dt=(0,m.useRef)(!1),xt=(0,m.useRef)(Z.mutate);xt.current=Z.mutate,(0,m.useEffect)(()=>{if(!(!o||dt.current)){if(ne.isError){dt.current=!0,y(ne.error instanceof Error?ne.error.message:"Could not check for an active login.");return}ne.isSuccess&&(dt.current=!0,!ne.data&&xt.current())}},[o,ne.isSuccess,ne.isError,ne.data,ne.error]);const Le=(0,m.useRef)(Oe);Le.current=Oe;const Ge=u==="onboarding",ht=(0,m.useRef)(!1);(0,m.useEffect)(()=>{!Ge||!ht.current||(ht.current=!1,$e&&Le.current())},[Ge,$e,_]);const Ve=(0,m.useRef)(!1),Ke=(0,m.useRef)(l);Ke.current=l,(0,m.useEffect)(()=>{!pe||Ve.current||(Ve.current=!0,Ke.current?.(f??void 0))},[pe]),(0,m.useEffect)(()=>{O&&(!v&&!xe&&!L||(E(!1),ue.current?.()))},[O,v,xe,L]);const gt=(0,m.useRef)(p);if(gt.current=p,(0,m.useEffect)(()=>{gt.current?.(w)},[w]),u==="onboarding"){const tt=xe||L;return(0,t.jsxs)(d0e,{loading:!w&&!v&&!tt,providerName:l0e(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)(_s,{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}):tt?(0,t.jsx)("p",{role:"alert",className:"pl-2 text-xs text-destructive",children:L&&!xe?VJ:WJ}):(0,t.jsx)(cP,{value:_,onChange:I,onSubmit:Oe,onPaste:r(()=>{ht.current=!0},"onPaste"),masked:!0,disabled:ae.isPending||_e||O})]})}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:tbe(s)}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[ge&&(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:oe.isPending,onClick:r(()=>oe.mutate(),"onClick"),children:"Cancel"}),i&&se&&!ge&&!pe&&!z&&(0,t.jsx)(F,{type:"button",variant:"default",size:"sm",className:"h-7 px-2.5 text-xs",onClick:r(()=>{i(),$(!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:Ie,onClick:r(()=>Z.mutate(),"onClick"),children:se&&!ge&&!pe?"Sign in to replace":"Sign in"})]})]}),se&&!ge&&!pe&&!z&&(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."}),z&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(ds,{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:[ge&&!w&&!_e&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(rt,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Preparing..."})]}),ge&&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)(_s,{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)(r6,{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)(gr,{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(tt=>I(tt.target.value),"onChange"),onKeyDown:r(tt=>{tt.key==="Enter"&&(tt.preventDefault(),Oe())},"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:!$e,onClick:Oe,children:"Submit"})]})]})]}),_e&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,t.jsx)(rt,{className:"size-3 animate-spin shrink-0"}),(0,t.jsx)("span",{children:"Completing the login…"})]}),pe&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-foreground",children:[(0,t.jsx)(ds,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Authenticated. The environment has credentials now."})]}),xe&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(_s,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:WJ})]}),L&&!xe&&!pe&&(0,t.jsxs)("div",{className:"flex items-start gap-2 text-(length:--text-micro) text-destructive",children:[(0,t.jsx)(_s,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:VJ})]})]})]})}r(GJe,"SubmittedBrowserCodeLoginPanel");function QJe({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(QJe,"AdapterEnvironmentResult$1");function sbe({value:e,onChange:s,disabledTypes:n}){const[a,i]=(0,m.useState)(!1),o=Jm(e),l=(0,m.useMemo)(()=>X0e(c=>eN[c]??kf(c)).filter(c=>!n.has(c.value)),[n]);return(0,t.jsxs)(tr,{open:a,onOpenChange:i,children:[(0,t.jsx)(pr,{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)(BB,{className:"h-3.5 w-3.5"}):null,(0,t.jsx)("span",{className:"truncate",children:eN[e]??kf(e)}),o.experimental&&(0,t.jsx)(HJ,{})]}),(0,t.jsx)(sn,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsx)(Qn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:l.map(c=>(0,t.jsxs)("button",{disabled:c.comingSoon,className:W("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)(BB,{className:"h-3.5 w-3.5"}):null,(0,t.jsx)("span",{children:c.label}),c.experimental&&(0,t.jsx)(HJ,{})]}),c.comingSoon&&(0,t.jsx)("span",{className:"text-(length:--text-nano) text-muted-foreground",children:"Coming soon"})]},c.value))})]})}r(sbe,"AdapterTypeDropdown");function HJ(){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(HJ,"ExperimentalBadge$1");function Y8({models:e,value:s,onChange:n,open:a,onOpenChange:i,allowDefault:o,required:l,groupByProvider:c,creatable:d,detectedModel:u,detectedModelCandidates:h,onDetectModel:p,onRefreshModels:f,refreshingModels:g,detectModelLabel:v,emptyDetectHint:y,defaultLabel:w}){const[k,j]=(0,m.useState)(""),[N,_]=(0,m.useState)(!1),I=e.find(O=>O.id===s),C=k.trim(),T=!!(d&&C&&!e.some(O=>O.id.toLowerCase()===C.toLowerCase())),R=(0,m.useMemo)(()=>{const O=new Set;u&&O.add(u);for(const E of h??[])E&&O.add(E);return O},[u,h]),A=(0,m.useMemo)(()=>e.filter(O=>{if(R.has(O.id))return!1;if(!k.trim())return!0;const E=k.toLowerCase(),q=lB(O.id)??"";return O.id.toLowerCase().includes(E)||O.label.toLowerCase().includes(E)||q.toLowerCase().includes(E)}),[e,k,R]),L=(0,m.useMemo)(()=>{if(!c)return[{provider:"models",entries:[...A].sort((E,q)=>E.id.localeCompare(q.id))}];const O=new Map;for(const E of A){const q=lB(E.id)??"other",B=O.get(q)??[];B.push(E),O.set(q,B)}return Array.from(O.entries()).sort(([E],[q])=>E.localeCompare(q)).map(([E,q])=>({provider:E,entries:[...q].sort((B,U)=>B.id.localeCompare(U.id))}))},[A,c]);async function D(){if(p){_(!0);try{const O=await p();O&&(n(O),i(!1),j(""))}finally{_(!1)}}}return r(D,"handleDetectModel"),(0,t.jsx)(ys,{label:"Model",hint:gi.model,children:(0,t.jsxs)(tr,{open:a,onOpenChange:r(O=>{i(O),O||j("")},"onOpenChange"),children:[(0,t.jsx)(pr,{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:W(!s&&"text-muted-foreground"),children:I?I.label:s||(o?w??"Default":l?"Select model (required)":"Select model")}),(0,t.jsx)(sn,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsxs)(Qn,{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:k,onChange:r(O=>j(O.target.value),"onChange"),autoFocus:!0}),k&&(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&&!k.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(()=>{D()},"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...":u?v?.replace(/^Detect\b/,"Re-detect")??"Re-detect from config":v??"Detect from config"]}),f&&!k.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(O=>O.id===s)||R.has(s))&&(0,t.jsxs)("button",{type:"button",className:W("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(O=>O.id===s)?.label??s}),(0,t.jsx)(ot,{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"})]}),u&&u!==s&&(0,t.jsxs)("button",{type:"button",className:W("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50"),onClick:r(()=>{n(u),i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:u,children:e.find(O=>O.id===u)?.label??u}),(0,t.jsx)(ot,{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(O=>O&&O!==u&&O!==s).map(O=>{const E=e.find(q=>q.id===O);return(0,t.jsxs)("button",{type:"button",className:W("flex items-center w-full px-2 py-1.5 text-sm rounded hover:bg-accent/50"),onClick:r(()=>{n(O),i(!1)},"onClick"),children:[(0,t.jsx)("span",{className:"block w-full text-left truncate font-mono text-xs",title:O,children:E?.label??O}),(0,t.jsx)(ot,{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-${O}`)}),(0,t.jsxs)("div",{className:"max-h-(--sz-240px) overflow-y-auto",children:[o&&(0,t.jsx)("button",{type:"button",className:W("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"}),T&&(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(O=>(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:[O.provider," (",O.entries.length,")"]}),O.entries.map(E=>(0,t.jsx)("button",{type:"button",className:W("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?PUe(E.id):E.label})},E.id))]},O.provider)),A.length===0&&!T&&R.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(Y8,"ModelDropdown");function YJe({value:e,options:s,onChange:n,open:a,onOpenChange:i}){const o=s.find(l=>l.id===e)??s[0];return(0,t.jsx)(ys,{label:"Thinking effort",hint:gi.thinkingEffort,children:(0,t.jsxs)(tr,{open:a,onOpenChange:i,children:[(0,t.jsx)(pr,{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:W(!e&&"text-muted-foreground"),children:o?.label??"Auto"}),(0,t.jsx)(sn,{className:"h-3 w-3 text-muted-foreground"})]})}),(0,t.jsx)(Qn,{className:"w-(--radix-popover-trigger-width) p-1",align:"start",children:s.map(l=>(0,t.jsxs)("button",{className:W("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(YJe,"ThinkingEffortDropdown");function nbe(e){const s=`paperclip.agent-appearance.${e}`;function n(){try{const l=aue.safeParse(JSON.parse(sessionStorage.getItem(s)??"null"));if(l.success)return l.data}catch{}const o=dT();try{sessionStorage.setItem(s,JSON.stringify(o))}catch{}return o}r(n,"readDraft");const[a,i]=(0,m.useState)(()=>({key:s,appearance:n()}));return a.key!==s&&i({key:s,appearance:n()}),{appearance:a.appearance,clear(){try{sessionStorage.removeItem(s)}catch{}}}}r(nbe,"useAgentAppearanceDraft");var Wk=null,pA=new Set,Vk={subscribe(e){return pA.add(e),()=>{pA.delete(e)}},getSnapshot(){return Wk},acquire(e){if(Wk)return!1;Wk=e;for(const s of pA)s();return!0},release(e){if(Wk===e){Wk=null;for(const s of pA)s()}}};function u1({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:u=!0,className:h,label:p,name:f}){const g=(0,m.useMemo)(()=>kN(s??e?.appearance,e?.id),[s,e?.appearance,e?.id]),v=(0,m.useRef)(null),y=(0,m.useRef)(null),w=(0,m.useRef)(null),k=(0,m.useRef)(Symbol("agent-character")),j=(0,m.useSyncExternalStore)(Vk.subscribe,Vk.getSnapshot,()=>null),[N,_]=(0,m.useState)(!1),[I,C]=(0,m.useState)(!0),[T,R]=(0,m.useState)(!1),[A,L]=(0,m.useState)(!1),D=N&&!I&&!T&&o==="auto"&&a!=="rest";return(0,m.useEffect)(()=>{if(typeof matchMedia!="function"||typeof IntersectionObserver!="function")return;const O=matchMedia("(prefers-reduced-motion: reduce)"),E=r(()=>C(O.matches),"change");E(),O.addEventListener("change",E);const q=new IntersectionObserver(B=>_(B[0]?.isIntersecting??!1));return v.current&&q.observe(v.current),()=>{q.disconnect(),O.removeEventListener("change",E)}},[]),(0,m.useEffect)(()=>{D&&j===null&&Vk.acquire(k.current),D||Vk.release(k.current)},[D,j]),(0,m.useEffect)(()=>()=>Vk.release(k.current),[]),(0,m.useEffect)(()=>{if(!D||j!==k.current)return;let O=!1;return L(!1),Promise.all([Sc(()=>import("./runtime-IAg0vdY9.js"),__vite__mapDeps([0,1])),Sc(()=>import("./definition-DjhwsOcy.js"),__vite__mapDeps([2,3,1]))]).then(([E,q])=>{O||!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:u,trackingScope:c,displaySize:n,onError:r(()=>R(!0),"onError")}),L(!0))}).catch(()=>{O||R(!0)}),()=>{O=!0,w.current?.destroy(),w.current=null,L(!1)}},[D,j,l,c,n,d,u]),(0,m.useEffect)(()=>{w.current&&Sc(()=>import("./definition-DjhwsOcy.js").then(O=>{w.current?.setDefinition(O.characterDefinition(g,i)),w.current?.setAnimation(O.animationId(a))}),__vite__mapDeps([2,3,1]))},[g,i,a,A]),(0,t.jsxs)("span",{ref:v,role:p?"img":void 0,"aria-label":p,"aria-hidden":p?void 0:!0,className:W("relative inline-block shrink-0",jEe[n],h),children:[(0,t.jsx)(yr,{agent:e,appearance:g,size:n<256?256:n,name:f,pose:a,muted:i,className:W("size-full",A&&"invisible")}),(0,t.jsx)("span",{ref:y,className:"absolute inset-0"})]})}r(u1,"AgentCharacter");var XJe=new Set(["claude_local","codex_local","opencode_local","grok_local"]);function rbe(e,{cloud:s,nativeRunnerEnabled:n}){return s?XJe.has(e):e!=="paperclip_runner"||n}r(rbe,"isNewAgentAdapterAllowed");var JJe={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 X8({type:e,className:s="size-6"}){const n=Jm(e).icon,a=JJe[e];return a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("img",{src:a.src,className:W("shrink-0 object-contain",a.dark&&"dark:hidden",s),alt:""}),a.dark&&(0,t.jsx)("img",{src:a.dark,className:W("hidden shrink-0 object-contain dark:block",s),alt:""})]}):(0,t.jsx)(n,{className:s})}r(X8,"AdapterMark");function ZJe(){const{selectedCompanyId:e}=ps(),{appearance:s}=nbe(`${e}:new-agent`);return(0,t.jsx)(u1,{appearance:s,state:"sleepy",muted:!0,size:256,className:"size-48",trackingScope:"page"})}r(ZJe,"AgentBasicsCharacter");function abe({open:e,onClose:s,onContinue:n,initialAdapter:a="",onInvite:i}){const o=(0,m.useId)(),l=!!td(),c=J({queryKey:P.instance.experimentalSettings,queryFn:Tr.getExperimental,enabled:e,retry:!1}),[d,u]=(0,m.useState)(""),[h,p]=(0,m.useState)(a),[f,g]=(0,m.useState)("codex"),[v,y]=(0,m.useState)("name"),{data:w,isPending:k,error:j}=J({queryKey:P.adapters.all,queryFn:Fm.list,enabled:e}),N=(w??[]).filter(I=>I.loaded&&!I.disabled&&rbe(I.type,{cloud:l,nativeRunnerEnabled:c.data?.enableNativeRunner===!0})&&!["process","http"].includes(I.type)&&!Jm(I.type).comingSoon),_=N.some(I=>I.type===h);return(0,t.jsx)(Qs,{open:e,onOpenChange:r(I=>{I||s()},"onOpenChange"),children:(0,t.jsxs)(Xs,{className:W("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:W(v==="name"&&"font-medium text-foreground"),children:"1. Name"}),(0,t.jsx)(En,{className:"size-3"}),(0,t.jsx)("span",{className:W(v==="adapter"&&"font-medium text-foreground"),children:"2. Adapter"})]}),(0,t.jsxs)("form",{className:"flex min-h-0 flex-col",onSubmit:r(I=>{I.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)(ZJe,{}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(en,{className:"text-3xl font-semibold tracking-tight",children:v==="name"?"Meet your next agent":"Choose an adapter"}),(0,t.jsx)(Ln,{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)(jt,{id:o,autoFocus:!0,maxLength:100,placeholder:"e.g. Darnold",value:d,onChange:r(I=>u(I.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"}),k&&(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:W("grid grid-cols-2 gap-3",N.length!==4&&"sm:grid-cols-3"),children:N.map(I=>{const C=Jm(I.type);return(0,t.jsxs)("label",{className:"relative cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",name:"new-agent-adapter",value:I.type,checked:h===I.type,onChange:r(()=>p(I.type),"onChange"),className:"peer sr-only"}),(0,t.jsxs)("span",{className:W("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===I.type?"border-foreground/40 bg-accent":"border-border bg-card"),children:[(0,t.jsx)(X8,{type:I.type}),(0,t.jsx)("span",{className:"text-sm font-medium",children:C.label}),h===I.type&&(0,t.jsx)(ds,{className:"absolute right-2 top-2 size-3.5"})]})]},I.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(I=>g(I.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)(vl,{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)(Ho,{className:"size-4"})]})]})]})]})})}r(abe,"AgentBasicsDialog");var eZe={subscription:"Subscription",api:"API"};function tZe({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)(QN,{initial:!1,mode:"sync",children:(0,t.jsx)(nl.span,{className:"absolute inset-0 flex items-center justify-center whitespace-nowrap",initial:{opacity:0,y:cJ},animate:{opacity:1,y:0,transition:CHe},exit:{opacity:0,y:cJ,transition:_He},children:eZe[e]},e)})})}r(tZe,"CredentialTag");function sZe({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:W("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)(tZe,{mode:s})]})}r(sZe,"ModelSourceTile");function ibe({sources:e,mode:s,selectedId:n,onSelect:a,label:i,collapsed:o=!1,settling:l=!1}){const c=(0,m.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"),u=o?e.filter(h=>h.id===n):e;return(0,t.jsx)("div",{role:"radiogroup","aria-label":i,className:W("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)(QN,{initial:!1,mode:"popLayout",children:u.map(h=>(0,t.jsx)(nl.div,{layout:!0,transition:o0e,exit:{opacity:0,transition:$He},className:W("flex min-w-0",o?"w-(--sz-source-tile-two-up)":"flex-1"),children:(0,t.jsx)(sZe,{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(ibe,"ModelSourceTiles");var QL={subscription:"Use API key instead",api:"Use subscription instead"},nZe={subscription:"api",api:"subscription"};function obe({mode:e,onChange:s}){return(0,t.jsxs)("button",{type:"button",onClick:r(()=>s(nZe[e]),"onClick"),className:W("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(QL).map(n=>(0,t.jsx)("span",{"aria-hidden":!0,className:"invisible col-start-1 row-start-1 whitespace-nowrap",children:QL[n]},n)),(0,t.jsx)(QN,{initial:!1,mode:"sync",children:(0,t.jsx)(nl.span,{className:W("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:F8},exit:{opacity:0,transition:IHe},children:QL[e]},e)})]})}r(obe,"CredentialModeLink");function lbe({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)(vl,{className:"mr-1 size-3.5"}),"Back"]}):(0,t.jsx)("span",{}),(0,t.jsx)(nl.div,{layout:!0,transition:RHe,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)(nl.span,{className:"flex items-center whitespace-nowrap",initial:{opacity:0},animate:{opacity:1},transition:EHe,children:[d==="spinner"?(0,t.jsx)(rt,{className:"mr-1 size-4 animate-spin"}):null,c,d==="arrow"?(0,t.jsx)(Ho,{className:"ml-1 size-3.5"}):null]},`${c}:${d}`)})})]})}r(lbe,"FooterNav");function cbe({companyId:e,adapterType:s,environmentId:n,canLogin:a,localEnvironment:i=!1,onConnected:o,onBack:l,testConnection:c,testError:d,managedAccount:u}){const h=J({queryKey:P.health,queryFn:cm.get,enabled:i}),p=i&&(h.data?.localAiLoginSupported??h.data?.deploymentMode==="local_trusted"),f=(0,m.useRef)(0);(0,m.useEffect)(()=>()=>{f.current++},[]);const g=r(()=>{f.current++,L(!1),k(!1),N(null),I("preparing")},"cancel"),[v,y]=(0,m.useState)(u?.initialMethod==="api_key"?"api":u?"subscription":null),[w,k]=(0,m.useState)(!1),[j,N]=(0,m.useState)(null),[_,I]=(0,m.useState)("preparing"),C=(0,m.useRef)("ready"),[T,R]=(0,m.useState)(""),[A,L]=(0,m.useState)(!1),[D,O]=(0,m.useState)(null),[E,q]=(0,m.useState)(null),B=s==="claude_local"?"Claude":s==="grok_local"?"Grok":"OpenAI",U=s==="claude_local"?"ANTHROPIC_API_KEY":s==="grok_local"?"XAI_API_KEY":"OPENAI_API_KEY",z=s==="claude_local"?"anthropic":s==="grok_local"?"xai":"openai",$=Vge(e,U),K=u?{...$,options:[],subscriptions:[],loading:!1}:$,[H,se]=(0,m.useState)(null),Z=K.subscriptions.length?K.subscriptions.find(ae=>ae.id===(H??K.subscriptions[0]?.id)):void 0,[ie,oe]=(0,m.useState)(null),Y=K.options.find(ae=>ae.id===(ie??K.options[0]?.id)),ne=u?{...K.storedLogin,data:void 0,isPending:!1,isError:!1}:K.storedLogin,de=(0,m.useRef)(null),ee=v??(K.subscriptions.length>0||s==="claude_local"&&!Z&&ne.data?"subscription":K.options.length?"api":"subscription"),X=dxe(e,u?.intent??{provider:z,method:"subscription",name:`My ${B} subscription`,ownership:"personal",agentIds:[],allAgents:!0},p&&ee==="subscription"&&!Z&&!ne.data,{allowHostClaude:h.data?.deploymentMode==="local_trusted"}),Q=J({queryKey:P.agents.authSignal(e,s,n),queryFn:r(()=>Vt.getAdapterAuthSignal(e,s,n??void 0),"queryFn"),retry:!1,enabled:!u});async function fe(){if(A||u?.disabled)return;const ae=++f.current;L(!0),O(null);try{if(u){if(ee==="subscription"&&!p)return;const he=de.current??await(ee==="api"?gu.create(e,{...u.intent,method:"api_key",apiKey:T.trim()}):X.connect(u.intent));de.current=he,R(""),ae===f.current&&u.onComplete({...he,method:ee==="api"?"api_key":"subscription"});return}let le=ee==="api"?Y?Y.aiConnection?{env:{},aiConnection:Y.aiConnection}:{env:{[U]:Y.binding}}:E??{env:{},credentials:{[U]:T.trim()}}:{...Z?.aiConnection?{aiConnection:Z.aiConnection}:{},env:Z?.binding?{CODEX_HOME:Z.binding}:{},...s==="claude_local"&&!Z&&ne.data?{env:Gj(),applyStoredClaudeLogin:!0}:{}};if(ee==="subscription"&&p&&!Z&&!ne.data&&(de.current??=await X.connect(),le={env:{},aiConnection:{provider:z,method:"subscription",mode:"responsible_user"}}),le.credentials&&(await gu.create(e,{provider:z,method:"api_key",name:`My ${B} API`,ownership:"personal",apiKey:le.credentials[U],agentIds:[],allAgents:!0}),le={env:{},aiConnection:{provider:z,method:"api_key",mode:"responsible_user"}}),ae!==f.current)return;ee==="api"&&(R(""),Y||q(le));const ce=await c(le);if(ae!==f.current)return;ce?o(le):O("The provider did not respond. Check the connection and try again.")}catch(le){if(ae!==f.current)return;u&&R(""),O(le instanceof Error?le.message:"Could not connect to the provider.")}finally{ae===f.current&&L(!1)}}r(fe,"connect");const te=ee==="subscription"&&a&&n&&!Z&&!K.loading&&!ne.data&&(!!u||Q.data?.status!=="present"||H==="");return(0,t.jsxs)("div",{className:"min-w-0 max-w-full",children:[(0,t.jsx)(ibe,{label:"Connect your model provider",sources:[{id:s,label:B,icon:(0,t.jsx)(X8,{type:s})}],mode:ee,selectedId:w?s:null,collapsed:w,onSelect:r(()=>{u?.disabled||k(!0)},"onSelect")}),!w&&!u?.fixedMethod&&(0,t.jsx)("div",{className:"-ml-3 mt-1",children:(0,t.jsx)(obe,{mode:ee,onChange:r(ae=>{de.current=null,y(ae),O(null)},"onChange")})}),!w&&K.options.length>0&&(0,t.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:[K.options.length," saved API"," ",K.options.length===1?"key available":"keys available","."]}),ee==="subscription"&&K.subscriptions.length>0&&(0,t.jsx)(gw,{options:K.subscriptions,value:Z?.id??"",onChange:se,loading:!1,error:!1,kind:"subscription",disabled:A}),(0,t.jsx)(nl.div,{initial:!1,animate:{height:w?"auto":0,opacity:w?1:0},transition:{height:pd,opacity:oP},className:"overflow-hidden",children:w&&(0,t.jsx)("div",{className:"pt-5",children:ee==="api"?(0,t.jsxs)(lP,{instruction:K.options.length?"Choose a saved API key or enter a new one":`Provide your ${B} API key to connect`,children:[(0,t.jsx)(gw,{...K,value:Y?.id??"",disabled:A,onChange:r(ae=>{oe(ae),R(""),q(null),O(null)},"onChange")}),!Y&&(0,t.jsx)(cP,{label:"API key",masked:!0,autoFocus:!0,value:T,placeholder:E?"Key entered. Retry the connection.":"Enter API key here",onChange:r(ae=>{oe(""),R(ae),q(null)},"onChange"),onSubmit:r(()=>{fe()},"onSubmit"),disabled:A})]}):te?(0,t.jsx)(Q8,{companyId:e,adapterType:s,environmentId:n,chrome:"onboarding",aiConnection:u?.intent??{provider:z,method:"subscription",name:`My ${B} subscription`,ownership:"personal",agentIds:[],allAgents:!0},autoStart:!0,onStored:r(()=>{},"onStored"),onPromptReady:r(ae=>{N(ae),I(le=>ae?le==="preparing"?"ready":le:"preparing")},"onPromptReady"),onCodeSubmitted:r(()=>{C.current=_==="waiting"?"waiting":"ready",I("connecting")},"onCodeSubmitted"),onSubmitFailed:r(()=>{I(ae=>ae==="connecting"?C.current:ae)},"onSubmitFailed"),onConnected:r(ae=>{if(u){if(!ae){O("The login did not return a saved connection. Try again.");return}const ce=f.current;I("connecting"),gu.loginResult(e,ae).then(he=>{ce===f.current&&u.onComplete({...he,method:"subscription"})}).catch(()=>{ce===f.current&&(I("ready"),O("Could not retrieve the saved connection. Go back and retry."))});return}const le={env:{},aiConnection:{provider:z,method:"subscription",mode:"responsible_user"}};q(le),o(le)},"onConnected")}):Z?null:p&&!ne.data?(0,t.jsx)(B8,{adapterType:s,login:{...X,retry:r(()=>{O(null),X.retry()},"retry")}}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:ne.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."})})}),ee==="subscription"&&ne.isError&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:"Could not check your saved Claude subscription. Try again."}),D&&(0,t.jsx)("p",{role:"alert",className:"mt-4 text-sm text-destructive",children:d??D}),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)(lbe,{onBack:r(()=>{w?g():l()},"onBack"),primaryLabel:w&&te?_==="waiting"?"Waiting for code":_==="connecting"?"Connecting":`Sign in to ${B}`:A?"Connecting":ee==="subscription"&&(ne.data||Z)?"Use saved subscription":ee==="api"&&Y?"Use saved API key":"Connect",primaryDisabled:u?.disabled||!!u&&ee==="subscription"&&!a&&!p||i&&h.isPending||X.preparing||!!X.error||!u&&Q.isPending||K.loading||s==="claude_local"&&ne.isPending||!w||!!te&&(!j||_!=="ready")||ee==="api"&&!T.trim()&&!E&&!Y,loading:A,primaryIcon:w&&te?_==="ready"?"none":"spinner":void 0,onPrimary:r(()=>{if(te){if(!j||_!=="ready")return;window.open(j,"_blank","noreferrer,noopener"),I("waiting")}else fe()},"onPrimary")})]})}r(cbe,"AgentProviderConnection");function q5(e){return e.provider==="openrouter"?(0,t.jsx)(aZe,{...e}):(0,t.jsx)(rZe,{...e})}r(q5,"AiConnectionCredentialStep");function rZe({companyId:e,provider:s,initialMethod:n,fixedMethod:a,connectionId:i,name:o,ownership:l,agentIds:c,allAgents:d,environmentId:u,onComplete:h,onCancel:p}){const[f,g]=(0,m.useState)(o),[v,y]=(0,m.useState)(),w=Ut(),k=J({queryKey:P.environments.list(e),queryFn:r(()=>Ri.list(e),"queryFn")}),j=J({queryKey:P.environments.capabilities(e),queryFn:r(()=>Ri.capabilities(e),"queryFn")}),N=J({queryKey:P.instance.settings,queryFn:Tr.get}),_=J({queryKey:P.instance.experimentalSettings,queryFn:Tr.getExperimental}),I=J({queryKey:P.instance.generalSettings,queryFn:Tr.getGeneral}),C=G8(I.data?.executionMode,k.data??[]);let T=null,R;try{T=C.forced?C.kubernetesEnvironment?.id??null:sN({agentDefaultEnvironmentId:u??v,instanceDefaultEnvironmentId:N.data?.defaultEnvironmentId,localDefaultEnvironmentId:rN(k.data),managedSandboxOnly:_.data?.enableManagedSandboxOnly,managedSandboxEnvironmentId:nN(k.data),visibleEnvironmentIds:k.data?.map(U=>U.id)})}catch(U){R=U instanceof Error?U.message:"Could not resolve the sign-in environment."}const A=(k.data??[]).filter(U=>U.status==="active"&&(U.driver==="local"||U.driver==="sandbox"&&typeof U.config.provider=="string"&&j.data?.sandboxProviders?.[U.config.provider]?.supportsLoginPty===!0));!C.forced&&!u&&!v&&!A.some(U=>U.id===T)&&(T=A[0]?.id??null);const L=k.data?.find(U=>U.id===T),D=typeof L?.config.provider=="string"?L.config.provider:"",O=L?.driver==="sandbox"&&j.data?.sandboxProviders?.[D]?.supportsLoginPty===!0,E=[k,j,N,_,I].some(U=>U.isPending),q=R??[k,j,N,_,I].find(U=>U.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)(jt,{value:f,onChange:r(U=>g(U.target.value),"onChange"),disabled:!!i})]}),!u&&!C.forced&&A.length>1&&(0,t.jsxs)(Oa,{value:T??"",onValueChange:y,children:[(0,t.jsx)($a,{"aria-label":"Sign-in environment",children:(0,t.jsx)(La,{placeholder:"Sign-in environment"})}),(0,t.jsx)(Da,{children:A.map(U=>(0,t.jsx)(Cn,{value:U.id,children:U.name},U.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)(cbe,{companyId:e,adapterType:s==="anthropic"?"claude_local":s==="xai"?"grok_local":"codex_local",environmentId:T,canLogin:O,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(U=>{w.invalidateQueries({queryKey:["ai-connections",e]}),h(U)},"onComplete")}},T??"local")]})}r(rZe,"SubscriptionConnectionStep");function aZe({companyId:e,provider:s,connectionId:n,name:a,ownership:i,agentIds:o,allAgents:l,onComplete:c,onCancel:d}){const[u,h]=(0,m.useState)(a),[p,f]=(0,m.useState)(""),g=Ut(),v=Ne({mutationFn:r(()=>gu.create(e,{provider:s,method:"api_key",name:u,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)(jt,{value:u,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)(u0e,{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:!u.trim()||!p.trim()||v.isPending,onClick:r(()=>v.mutate(),"onClick"),children:v.isPending?"Connecting…":"Connect"})]})]})}r(aZe,"ApiKeyConnectionStep");var iZe=new RegExp(`\\b(${["mcp","server","profile","policy","gateway","transport","stdio","endpoint"].join("|")})s?\\b`,"gi");function dbe(e){return e.replace(iZe,"").replace(/\s{2,}/g," ").replace(/\s+([.,])/g,"$1").trim()}r(dbe,"sanitizeProsumerCopy");var oZe={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."}},lZe={tagline:"Give your agents access to this app.",short:"Give your agents access to this app."};function ube(e,s){const n=oZe[e];if(n)return n;if(s){const a=dbe(s);if(a)return{tagline:a,short:a}}return lZe}r(ube,"appCopyFor");function GJ(e,s,n){return n<=1?`Your ${e} key`:dbe(s)||`Your ${e} key`}r(GJ,"credentialFieldLabel");var cZe=1500;function Sf(e=cZe){const[s,n]=(0,m.useState)("idle"),a=(0,m.useRef)(null),i=(0,m.useRef)(0);(0,m.useEffect)(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const o=(0,m.useCallback)(async l=>{const c=++i.current;let d="copied";try{await Xr(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(Sf,"useCopyAction");function J8(){const e=Rc()?.pushToast;return(0,m.useCallback)(async(s,n="Copied")=>{try{return await Xr(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(J8,"useCopyToast");var dZe="/cloud/connections/handoff",uZe="/cloud/connections/reauth",z5="paperclip.cloud-oauth-handoff.v1",Ax=class extends Error{static{r(this,"OAuthHandoffError")}code;constructor(e,s){super(e),this.code=s,this.name="OAuthHandoffError"}};function Z8(e){if(e===void 0)return null;if(!e||typeof e!="object"||Array.isArray(e))throw new Ax("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 Ax("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");return{kind:"paperclip_cloud",session:s.session}}r(Z8,"parseHandoff");function mZe(e,s){return e===404||s==="SESSION_NOT_AVAILABLE"?new Ax("This sign-in expired. Start the connection again.","expired"):e===401||e===403?new Ax("Paperclip Cloud could not authorize this connection for your account.","forbidden"):new Ax("Paperclip Cloud couldn’t prepare secure sign-in. Try again.","unavailable")}r(mZe,"handoffFailure");async function hZe(e,s){const n=s.request??fetch;let a,i;for(let o=0;o<2;o+=1)try{if(a=await n(dZe,{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 Ax(i instanceof Error?i.message:"Paperclip Cloud couldn’t prepare secure sign-in. Try again.","unavailable")}r(hZe,"postCloudHandoff");function pZe(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!==uZe||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(pZe,"exactReauthenticationTarget");async function oN(e,s={}){const n=Z8(e.handoff);if(!n){const l=v5(e.authorizationUrl);if(!l.ok)throw new Ax(l.message,"invalid_handoff");return{kind:"authorization",url:l.url,host:l.host}}const a=await hZe(n.session,s),i=await a.json().catch(()=>null);if(!a.ok){if(i?.error==="RECENT_LOGIN_REQUIRED"){const l=pZe(i.reauthenticationUrl,n.session);if(l)return l}throw mZe(a.status,i?.error)}const o=v5(typeof i?.authorizationUrl=="string"?i.authorizationUrl:void 0);if(!o.ok)throw new Ax("Paperclip Cloud returned an invalid provider sign-in address.","invalid_handoff");return{kind:"authorization",url:o.url,host:o.host}}r(oN,"prepareOAuthNavigation");function m1(e,s=window.sessionStorage){const n=Z8({kind:"paperclip_cloud",session:e});if(!n)throw new Ax("Paperclip Cloud returned an invalid sign-in handoff.","invalid_handoff");const a={version:1,session:n.session,savedAt:Date.now()};s.setItem(z5,JSON.stringify(a))}r(m1,"savePendingCloudHandoff");function fZe(e=window.sessionStorage){const s=e.getItem(z5);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 Z8({kind:"paperclip_cloud",session:n.session})}catch{return e.removeItem(z5),null}}r(fZe,"readPendingCloudHandoff");function QJ(e=window.sessionStorage){e.removeItem(z5)}r(QJ,"clearPendingCloudHandoff");function pP({host:e,className:s}){return(0,t.jsxs)("div",{className:W("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)(Al,{className:"h-3 w-3"}),"Unverified server"]}),e?(0,t.jsx)("span",{className:"font-mono text-muted-foreground",children:e}):null]})}r(pP,"UnverifiedServerBadge");function fP(e){return!!(e&&uue({...e,methods:e.methods.filter(s=>(s.purpose??"tool")!=="channel"&&s.transport!=="chat_sdk")}))}r(fP,"appSupportsToolCatalogSetup");var xZe=vRe.filter(e=>sue(e).some(s=>Zp(s))).map(e=>e.slug);function gZe(e){return xZe.some(s=>s===e)}r(gZe,"isMcpDirectOAuthConnectSlug");function a6(e,s){const n=new URLSearchParams({source:e});return s&&n.set("intent",s),`/apps/connect?${n.toString()}`}r(a6,"appSourceConnectHref");function bZe(e,s){return`/apps/connect?${new URLSearchParams({source:e,resume:s}).toString()}`}r(bZe,"appSourceResumeHref");function YL(e){return e?`/apps/vercel-connect?${new URLSearchParams({source:e}).toString()}`:"/apps/vercel-connect"}r(YL,"vercelConnectSourceHref");function vZe(e){return e.serviceSlug??e.appKey??e.sourceSlug??void 0}r(vZe,"resolveAppsConnectRouteKey");function yZe(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=Y1(n);return!s&&a?.methods.some(i=>i.transport==="chat_sdk")&&!a.methods.some(i=>(i.purpose??"tool")!=="channel"&&i.transport!=="chat_sdk")?!1:$U(n)&&e.get("reconnect")?.trim()?!0:s?uue(a):fP(a)}r(yZe,"canEnterAppsConnect");var XL=" for the organization",jZe=" for the company";function YJ(e,s){const n=e.trim();if(s!=="organization")return n;const a=n.toLocaleLowerCase();return a.endsWith(XL)?n:a.endsWith(jZe)?`${n.slice(0,n.length-16).trimEnd()}${XL}`:`${n}${XL}`}r(YJ,"connectionNameForGrantKind");function wZe(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(wZe,"grantStatusLabel");function NZe(e){switch(e){case"active":return"connected";case"needs_reauthorization":case"expired":return"attention";case"revoked":return"inactive";default:return"missing"}}r(NZe,"grantStatusTone");function kZe(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(kZe,"grantAccountLabel");function SZe(e){return new Set((e?.members??[]).filter(s=>s.subjectType==="user").map(s=>s.subjectId))}r(SZe,"audienceUserIds");function CZe(e){return e.find(s=>s.kind==="organization"&&s.isDefault)??e.find(s=>s.kind==="organization")??null}r(CZe,"organizationGrant");function _Ze(e,s){return s?e.find(n=>n.kind==="user"&&n.subjectUserId===s)??null:null}r(_Ze,"personalGrantFor");function IZe(e,s){if(!s)return null;const n=e.find(a=>a.userId===s);return n&&(n.name?.trim()||n.email?.trim())||null}r(IZe,"memberLabel");var XJ=0;function i6(){return XJ+=1,{id:`header-${XJ}`,name:"",value:""}}r(i6,"newCustomHeaderRow");function xC(e){try{return new URL(e).host||null}catch{return null}}r(xC,"endpointHost");function AZe(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(AZe,"oauthCallbackUrlForBrowser");function JL(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(JL,"defaultGenericMcpName");function JJ(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(JJ,"genericConnectGuidance");function mbe(e){const s=new Set;for(const n of e){const a=n.name.trim();if(!a&&!n.value.trim())continue;const i=WTe(a);if(!i.ok)return TG(a,i.reason);const o=HTe(n.value);if(!o.ok)return TG(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(mbe,"customHeaderError");function TZe(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(TZe,"genericConnectPayload");function RZe(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&&mbe(e.headers)===null:!0:!1}r(RZe,"canSubmitGenericConnect");function lN(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(lN,"installStateFrom");function hbe(e,s){return e.onAll||e.agentIds.has(s)}r(hbe,"isAgentInstalled");function pbe(e,s){return s.onAll?[{targetType:"company",targetId:e}]:[...s.agentIds].map(n=>({targetType:"agent",targetId:n}))}r(pbe,"installPayload");var EZe="Has access — tick to load its tools into this agent's context.";function fbe(e){return`paperclip.connector-enrollment-access:${e}`}r(fbe,"enrollmentAccessStorageKey");function PZe(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(PZe,"validEnrollmentAccessState");function MZe(e,s,n){try{window.sessionStorage.setItem(fbe(s),JSON.stringify({...n,companyId:e}))}catch{}}r(MZe,"saveEnrollmentAccessState");function LZe(e){const s=fbe(e);try{const n=window.sessionStorage.getItem(s);if(window.sessionStorage.removeItem(s),!n)return null;const a=JSON.parse(n);return PZe(a)?a:null}catch{return null}}r(LZe,"consumeEnrollmentAccessState");function ZJ(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(ZJ,"githubRecoveryUrl");function eZ(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(eZ,"oauthCallbackErrorMessage");var DZe={access:"access",key:"setup",success:"complete"};function tZ(e){return e.requestedAppKey?e.resumeConnectionId||e.routeStage==="setup"?"key":"access":e.hasPrefilledLink||e.zapierSource?"access":"gallery"}r(tZ,"requestedConnectionInitialStep");function $Ze(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 Fx(n)!==e.requestedAppKey?null:$U(e.requestedAppKey)}r($Ze,"requestedConnectionEntry");function OZe(e){return!e.reconnectConnection||!e.reconnectApplication||e.reconnectConnection.applicationId!==e.reconnectApplication.id?!1:e.requestedAppKey?Fx(e.reconnectApplication)===e.requestedAppKey:e.byo&&e.applicationId===e.reconnectApplication.id}r(OZe,"retainedReconnectMatches");function FZe(e){return e.credentialSource==="vercel_connect"&&!e.available&&!e.retainedReconnectMatches}r(FZe,"isVercelConnectUnavailable");function BZe(e){return e.available===!1&&!(e.reconnectConnectionId&&e.reconnectSourceMatches)}r(BZe,"isConnectionDefinitionUnavailable");function qZe(e){return!e.hasRequestedEntry||e.supportedMethodCount===0||e.unsupportedOAuth||e.vercelUnavailable||e.definitionUnavailable?e.reconnectConnectionId?"reconnect_unavailable":"fallback":"ready"}r(qZe,"requestedConnectionSetupResolution");function sZ(e,s,n,a){const i=DZe[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(sZ,"appConnectHref");function fA(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(fA,"withConnectionIntent");var nZ=["Pick app","Access","Add your key"],rZ={gallery:0,access:1,key:2},zZe={access:0,key:1},UZe=["Access","Add MCP URL"],KZe=["Access","Sign in"];function ZL(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(ZL,"defaultGrantKindFor");function WZe(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(WZe,"configuredAgentIdentity");function RS(e,s){const n=typeof s=="string"?s:s?.key;return e?.slug==="google-sheets"&&n==="local"}r(RS,"isGoogleSheetsRobotMethod");function Hk(e){return e?Object.fromEntries([...e.tenantFields??[],...e.extensionFields??[]].filter(s=>s.defaultValue!==void 0).map(s=>[s.key,s.defaultValue])):{}}r(Hk,"defaultMethodConfig");function Ej(e,s){if(!e)return[];const n=M_(e);return s==="vercel_connect"?n.filter(a=>!!a.credentialSources?.vercelConnect):n}r(Ej,"connectionMethodsForCredentialSource");function M_(e){return sue(e).filter(s=>(s.purpose??"tool")!=="channel")}r(M_,"availableToolConnectionMethods");function xA(e,s){const n=M_(e);return s?n.find(a=>a.key===s)??null:DU(n)}r(xA,"availableToolConnectionMethod");function vw(e){const s=DU(e);return e.length===1||s?.capabilityProfile||s?.grantKinds?.includes("agent")?s:null}r(vw,"recommendedSetupConnectionMethod");function aZ(e){return vw(e?e.methods.filter(s=>(s.purpose??"tool")==="tool"&&(s.oauthStrategy==="paperclip_cloud_connector"||s.oauthStrategy==="paperclip_id_connector")):[])}r(aZ,"recommendedManagedConnectorMethod");function iZ(e){if(!e)return!1;const s=M_(e),n=s.length===1?s[0]:null;return!!(n&&Zp(n)&&!fRe(n))}r(iZ,"canUseAutomaticOAuthFastPath");function oZ(e){if(!e)return null;const s=M_(e),n=s.length===1?s[0]:null;return n&&Zp(n)?n:null}r(oZ,"automaticOAuthMethod");function VZe(e){const s=e.metadata;if(!s)return null;const n=s.sourceTemplateKey??s.galleryKey;return typeof n=="string"?n:null}r(VZe,"appSourceSlug");function HZe(e){const s=e.config?.sourceTemplateKey??e.transportConfig.sourceTemplateKey;return typeof s=="string"?s:null}r(HZe,"connectionSourceSlug");function lZ(e,s,n,a={}){if(!e)return null;const i=new Set(s.filter(o=>o.status!=="archived"&&VZe(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)||HZe(o)===e;return o.status!=="archived"&&(!a.draftOnly||o.status==="draft")&&o.authKind==="oauth"&&l})??null}r(lZ,"reusableOAuthConnection");function xbe(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(xbe,"readConnectionIntentOAuthOutcome");function xP(e={}){const[s]=Ei(),n=Ia(),{selectedCompanyId:a}=ps(),i=cxe(),o=e.interactionId||s.get("intent")||void 0,l=e.serviceSlug||s.get("source")||n.appKey||s.get("appKey"),c=(0,m.useMemo)(()=>{if(o&&rw(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,u=!!(d&&(!l||rw(l))),h=J({queryKey:["tools","connection",d],queryFn:r(()=>cs.getConnection(d),"queryFn"),enabled:u}),p=l||h.data?.config?.sourceTemplateKey,f=s.get("method")||h.data?.config?.connectionMethodKey;return u&&h.isPending?(0,t.jsx)("p",{className:"p-6 text-sm text-muted-foreground",children:"Loading connection…"}):u&&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"&&rw(p)&&(!f||lT(p,f))?i.loaded?i.enabled?(0,t.jsx)(JKe,{...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)(GZe,{...e})}r(xP,"ConnectionSetupFlow");function GZe({byoOnly:e=!1,credentialSource:s="paperclip_vault",host:n="page",serviceSlug:a,requestedAgentId:i,interactionId:o,forceNewConnection:l=!1,existingConnections:c=[],configuredConnection:d,onUseExisting:u,onComplete:h,onOAuthDeclined:p,aiConnection:f,onPhaseChange:g,onCancel:v,renderCredentialStep:y}={}){const w=Xn(),k=(0,m.useCallback)((Be,Et)=>{n==="page"&&(Et?w(Be,Et):w(Be))},[n,w]),j=Ia(),{selectedCompany:N,selectedCompanyId:_}=ps(),{enabled:I}=Yx(),{setBreadcrumbs:C}=Bn(),{pushToast:T}=Ai(),[R]=Ei(),A=o?.trim()||R.get("intent")?.trim()||null,L=j.appKey??R.get("appKey")??void 0,D=R.get("source")?.trim()||null,O=l||R.get("new")==="1",E=R.get("stage")?.trim()||null,q=R.get("method")?.trim()||null,B=R.get("resume")?.trim()||null,U=R.get("oauth"),z=R.get("code"),$=ZJ(R.get("installation_url")),K=ZJ(R.get("management_url")),H=d?.id??(R.get("reconnect")?.trim()||null),se=R.get("identity")==="user"?"user":R.get("identity")==="organization"?"organization":null,Z=s==="vercel_connect",ie=a??D,oe=s==="paperclip_vault"&&gZe(ie)?ie:null,Y=vZe({serviceSlug:a,appKey:L,sourceSlug:D}),ne=(a??D??L)==="zapier",de=ne?void 0:Y,ee=!!d||n==="page"&&(e||R.get("byo")==="1"),[X]=(0,m.useState)(()=>n==="page"&&R.get("cloud_connector")==="enrolled"&&de?LZe(de):null),[Q]=(0,m.useState)(()=>{const Be=R.get("link")?.trim()??"";return{link:/^https?:\/\//i.test(Be)?Be:"",name:d?.name??R.get("name")?.trim()??"",applicationId:d?.applicationId??(R.get("applicationId")?.trim()||void 0)}}),[fe,te]=(0,m.useState)(()=>tZ({requestedAppKey:de,routeStage:E,resumeConnectionId:B,hasPrefilledLink:!!Q.link,zapierSource:ne})),[ae,le]=(0,m.useState)(null),[ce,he]=(0,m.useState)(""),[ve,pe]=(0,m.useState)(Q.link),[xe,_e]=(0,m.useState)(Q.name||(ne?"Zapier":"")),[ge,Ie]=(0,m.useState)(!1),[Ye,$e]=(0,m.useState)(""),[Xe,ue]=(0,m.useState)("auto"),[Oe,dt]=(0,m.useState)(()=>[i6()]),[xt,Le]=(0,m.useState)(""),[Ge,ht]=(0,m.useState)(""),[Ve,Ke]=(0,m.useState)(!1),[gt,tt]=(0,m.useState)(null),[Se,ke]=(0,m.useState)(!1),[Je,ut]=(0,m.useState)({}),[Dt,Jt]=(0,m.useState)(""),[fs,We]=(0,m.useState)(""),[He,ct]=(0,m.useState)(""),[ze,is]=(0,m.useState)(f&&f.mode!=="responsible_user"?`ai-${f.method}`:""),[Fe,Qt]=(0,m.useState)({}),[Tt,Ms]=(0,m.useState)(""),[Ue,pt]=(0,m.useState)(null),[$t,gs]=(0,m.useState)(null),[Rs,Ct]=(0,m.useState)({}),[we,Pe]=(0,m.useState)("all"),[lt,Ot]=(0,m.useState)(new Set),[ft,us]=(0,m.useState)(()=>new Set(X?.agentIds??(i?[i]:[]))),[dn,xs]=(0,m.useState)(X?.grantKind??se??(i?"user":"organization")),[bs,qe]=(0,m.useState)(X?.installChoice??(i?"specific":"all")),Nt=!!(B&&(U==="failed"||U==="denied")),[St,Ee]=(0,m.useState)(Nt?"error":"entry"),[De,Ze]=(0,m.useState)(()=>Nt?eZ(U,z):null),[kt,Kt]=(0,m.useState)(null),Lt=(0,m.useRef)(!1),Ft=(0,m.useRef)(!1),Yt=(0,m.useRef)(null),[Vs,In]=(0,m.useState)(null),An=(0,m.useRef)(null),[tn,Us]=(0,m.useState)(null),[ws,nn]=(0,m.useState)(null),zs=(0,m.useRef)(null),[Tn,pn]=(0,m.useState)(c.length>0&&!!u),[rn,br]=(0,m.useState)(null),[Zs,nr]=(0,m.useState)(null),[rr,Wr]=(0,m.useState)(null),xr=(0,m.useCallback)(()=>{n!=="dialog"||An.current?.closed===!1||(An.current=window.open("about:blank","paperclip-connection-oauth","popup,width=720,height=760,resizable=yes,scrollbars=yes"))},[n]),wr=(0,m.useCallback)(Be=>{if(n!=="dialog"){Ac(Be);return}nn(Be);const Et=An.current;if(!Et||Et.closed){Ee("error"),Ze("Paperclip couldn’t open the sign-in window. Open sign-in in a new tab to continue."),g?.("needs_retry");return}Et.location.assign(Be),Et.focus()},[n,g]),ar=(0,m.useCallback)(()=>{An.current=null,Ze(null),Ee("redirecting"),g?.("authorizing")},[g]);(0,m.useEffect)(()=>{if(n!=="dialog"||St!=="redirecting")return;const Be=window.setInterval(()=>{An.current?.closed&&(Ee("error"),Ze("The sign-in window closed. If authorization did not finish, try again."),nn(null),g?.("needs_retry"))},1e3);return()=>window.clearInterval(Be)},[n,St,g]);const aa=(0,m.useCallback)(async Be=>{zs.current?.abort();const Et=new AbortController;zs.current=Et;try{const Ps=await oN(Be,{signal:Et.signal});if(Ps.kind==="reauthentication"){const Rn=n==="dialog"?An.current:window;if(!Rn||Rn.closed||!Be.handoff)throw new Error("Paperclip couldn’t preserve this sign-in while refreshing your account.");m1(Be.handoff.session,Rn.sessionStorage),Ee("starting")}else Kt(Ps.host),Ee("redirecting");wr(Ps.url)}catch(Ps){if(Et.signal.aborted)return;Ee("error"),Ze(Ps instanceof Error?Ps.message:"Paperclip couldn’t start secure sign-in. Try again."),g?.("needs_retry")}finally{zs.current===Et&&(zs.current=null)}},[n,g,wr]);(0,m.useEffect)(()=>()=>zs.current?.abort(),[]),(0,m.useEffect)(()=>{if(n!=="dialog"||!A)return;const Be=r(Et=>{const Ps=xbe(Et,window.location.origin,A);if(Ps==="connected"){Ee("entry"),nn(null),h?.({resolvedByCallback:!0});return}if(Ps==="declined"){Ee("error"),Ze("Authorization was cancelled. You can try again."),g?.("needs_retry");return}Ps==="failed"&&(Ee("error"),Ze("Authorization did not complete. Try again when you’re ready."))},"receiveOAuthOutcome");return window.addEventListener("message",Be),()=>window.removeEventListener("message",Be)},[A,n,h,p]),(0,m.useEffect)(()=>{if(n!=="dialog"||A||!tn)return;let Be=!1,Et=!1;const Ps=window.setInterval(async()=>{if(Et||Be)return;const Rn=An.current;if(!Rn||Rn.closed){Us(null),Ee("error"),Ze("The sign-in window closed. Try again to finish connecting GitHub.");return}let Er;try{Er=new URL(Rn.location.href)}catch{return}if(!(Er.origin!==window.location.origin||!Er.pathname.includes(tn))){if(Er.searchParams.has("oauth")){Us(null),Ee("error"),Ze("Authorization did not complete. Finish setup in the sign-in window or try again.");return}if(Er.searchParams.get("success")==="1"){Et=!0;try{const Ka=await cs.getConnection(tn);!Be&&Ka.status==="active"&&(Us(null),Rn.close(),h?.({connectionId:Ka.id}))}catch{Be||(Us(null),Ee("error"),Ze("Could not confirm the connection. Try again."))}finally{Et=!1}}}},1e3);return()=>{Be=!0,window.clearInterval(Ps)}},[A,tn,n,h]);const qn=r(()=>{ue("auto"),dt([i6()]),Le(""),ht(""),Ke(!1),tt(null),ke(!1)},"resetGenericAuthState"),Rr=r(Be=>{if(n==="page"&&!A&&s==="paperclip_vault"&&rw(Be.slug)){k(`/apps/connect?source=${Be.slug}`);return}if(Be.slug==="zapier"){le(null),he(""),pe(""),_e("Zapier"),Ie(!1),$e(""),qn(),ut({}),gs(null),te("access"),k(fA("/apps/connect?source=zapier",A));return}if(s==="paperclip_vault"&&iZ(Be)){k(a6(Be.slug,A));return}le(Be),he(Be.name),pe(""),_e(""),Ie(!1),$e(""),qn(),ut({}),Jt(""),We(""),ct("");const Et=vw(Ej(Be,s));is(Et?.key??""),Qt(Hk(Et)),Ms(""),pt(null),gs(null),us(new Set(i?[i]:[])),qe(i?"specific":"all"),xs(cr??ZL(Et,!!i)),te("access"),k(s==="vercel_connect"?fA(YL(Be.slug),A):a6(Be.slug,A))},"useMatchedGalleryEntry"),Na=r(()=>{te("gallery"),k(fA(s==="vercel_connect"?YL():e?"/apps/byo":"/apps",A))},"backToGallery");(0,m.useEffect)(()=>{if(n==="page")return C([{label:"Connectors",href:"/apps"},{label:Z?"Vercel Connect":e?"Connect your own tool":"Connect an app"}]),()=>C([])},[e,n,C,Z]);const Sn=J({queryKey:P.apps.gallery(_??"__none__"),queryFn:r(()=>cs.listGallery(_),"queryFn"),select:(0,m.useCallback)(Be=>A?{...Be,apps:Be.apps.map(Et=>({...Et,methods:Et.methods.filter(Ps=>f?Ps.ai?.provider===f.provider&&(f.mode==="responsible_user"||Ps.ai.method===f.method):Ps.transport!=="runtime_auth")})).filter(Et=>Et.methods.length>0)}:Be,[A,f?.provider,f?.method,f?.mode]),enabled:!!_}),On=(0,m.useMemo)(()=>(Sn.data?.apps??[]).filter(Be=>I||!Be.methods.some(Et=>Et.transport==="chat_sdk")||fP(Be)),[Sn.data,I]),on=de?$U(de):null,mr=!!on?.methods.some(Be=>Be.oauthStrategy==="paperclip_cloud_connector"||Be.oauthStrategy==="paperclip_id_connector"),bt=!!ae?.methods.some(Be=>Be.oauthStrategy==="paperclip_cloud_connector"||Be.oauthStrategy==="paperclip_id_connector"),Ls=ae&&mr&&!bt?aZ(on):null,[Fs,et]=(0,m.useState)(null),Gt=J({queryKey:["cloud-connector","enrollment"],queryFn:r(()=>cs.getCloudConnectorEnrollment(),"queryFn"),refetchInterval:Fs?2e3:!1,enabled:!!(_&&mr&&!bt)}),[mn,Os]=(0,m.useState)(null),Jn=(0,m.useCallback)(()=>{An.current?.close(),An.current=null,et(null)},[]),Nr=(0,m.useCallback)(()=>{!_||!de||MZe(_,de,{grantKind:dn,installChoice:bs,agentIds:bs==="specific"?[...ft]:[]})},[dn,ft,bs,de,_]),_a=(0,m.useCallback)(Be=>{const Et=v5(Be);if(!Et.ok){Jn(),Os(Et.message);return}if(n==="dialog"){et(Et.url);const Ps=An.current;Ps&&!Ps.closed?(Ps.location.assign(Et.url),Ps.focus()):Os("Open authorization in a new tab to continue.");return}Ac(Et.url)},[n,Jn]);(0,m.useEffect)(()=>{!Fs||Gt.data?.status!=="active"||(Jn(),Os(null),Sn.refetch())},[Fs,Gt.data?.status,Sn.refetch,Jn]);const Un=Ne({mutationFn:r(()=>cs.startCloudConnectorEnrollment(_,N?.name,de?sZ(de,"key",s,{resumeConnectionId:B,reconnectConnectionId:H,interactionId:A})+(n==="dialog"?"&enrollment_host=dialog":""):void 0),"mutationFn"),onSuccess:r(Be=>{if(!Be.verificationUrl){Jn(),Os("Paperclip Cloud did not return an enrollment link. Try again.");return}_a(Be.verificationUrl)},"onSuccess"),onError:r(Be=>{Jn(),Os(Be instanceof Error?Be.message:"Paperclip couldn’t reach Paperclip Cloud. Try again.")},"onError")}),Zn=J({queryKey:P.tools.applications(_??"__none__"),queryFn:r(()=>cs.listApplications(_),"queryFn"),enabled:!!_&&(!!oe||!!B||!!H),refetchOnMount:"always"}),rs=J({queryKey:P.tools.connections(_??"__none__"),queryFn:r(()=>cs.listConnections(_),"queryFn"),enabled:!!_&&(!!oe||!!B||!!H),refetchOnMount:"always"}),fn=(0,m.useMemo)(()=>l?null:lZ(oe,Zn.data?.applications??[],rs.data?.connections??[],O?{applicationId:Q.applicationId,draftOnly:!0}:{}),[Zn.data,rs.data,O,oe,Q.applicationId,l]),Hs=(0,m.useMemo)(()=>H?(rs.data?.connections??[]).find(Be=>Be.id===H)??null:null,[rs.data,H]),Zt=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!d||!rs.isFetchedAfterMount||!Hs||Zt.current===Hs.id)return;const Be=Hs.config?.url??Hs.transportConfig?.url??Hs.transportConfig?.serverUrl??Hs.config?.serverUrl;typeof Be!="string"||!/^https?:\/\//i.test(Be)||(Zt.current=Hs.id,pe(Et=>Et||Be))},[d,rs.isFetchedAfterMount,Hs]);const ks=(0,m.useMemo)(()=>Hs?(Zn.data?.applications??[]).find(Be=>Be.id===Hs.applicationId)??null:null,[Zn.data,Hs]),Hn=OZe({requestedAppKey:de,byo:ee,applicationId:Q.applicationId,reconnectConnection:Hs,reconnectApplication:ks}),Pn=(0,m.useMemo)(()=>B?(rs.data?.connections??[]).find(Be=>Be.id===B)??null:null,[rs.data,B]),hr=Pn??Hs,cr=hr?hr.credentialPolicy==="per_user"?"user":hr.credentialPolicy==="per_agent"?"agent":"organization":se,ia=Pn?.authKind==="oauth"?Pn:fn,ls=fn?fn.credentialPolicy==="per_user"?"user":fn.credentialPolicy==="per_agent"?"agent":"organization":null,Ds=cr??ls;(0,m.useEffect)(()=>{Ds&&xs(Ds)},[Ds]);const hn=(0,m.useMemo)(()=>ve&&!ae?PR(ve,On):null,[ae,On,ve]),Fn=ae?xA(ae,ze||null):null,Vr=Fn&&Zp(Fn)?Fn:oZ(ae),_r=s==="paperclip_vault"&&Vr?ae:null,$r=s==="paperclip_vault"&&iZ(ae)?ae:null,Zr=!!oe&&(!Zn.isFetchedAfterMount||!rs.isFetchedAfterMount),je=r(Be=>{te(Be),ae&&k(sZ(ae.slug,Be,s,{connectionMethodKey:ae.methods.find(Et=>Et.key===ze)?.ai?ze:void 0,resumeConnectionId:B,reconnectConnectionId:H,interactionId:A}))},"setAppStep"),qt=Ne({mutationFn:r(Be=>cs.startOAuth(Be.id,{asCurrentUser:Be.credentialPolicy==="per_user",...Be.credentialPolicy==="per_agent"?{asAgentId:WZe(Be)??[...ft][0]}:{},...A?{interactionId:A}:{}}),"mutationFn"),onSuccess:r(Be=>{aa(Be)},"onSuccess"),onError:r(Be=>{const Et=Be instanceof cn&&Be.body&&typeof Be.body=="object"?Be.body.details:null;Ee("error"),g?.("needs_retry"),Ze(Et?.code==="invalid_grant"?"Your authorization expired or was revoked. Reconnect to continue.":Be instanceof Error?Be.message:"Paperclip couldn’t start secure sign-in. Try again.")},"onError")}),yn=qt.mutate,Yn=(0,m.useCallback)(Be=>{g?.("authorizing"),xr(),n==="dialog"&&!A&&Us(Be.id),yn(Be)},[yn,g,xr,n,A]),zr=r(async Be=>{if(i)return;const Et=pbe(_,(Ds??dn)!=="agent"&&bs==="all"?{onAll:!0,agentIds:new Set}:{onAll:!1,agentIds:ft});await cs.putConnectionInstalls(Be,Et)},"applyAccessInstalls"),ir=Ds??dn,Fa=Ne({mutationFn:r(async Be=>{const Et=Be??ae;let Ps;if(Et){const Rn=Ds??dn,Er=xA(Et,ze||null),Ka=RS(Et,Er)?mB(Tt).ids:[],sa=ce.trim(),Wi=YJ(sa||Et.name,Rn);Ps=await cs.connectApp(_,{galleryKey:Et.slug,...ze?{connectionMethodKey:ze}:{},name:Wi,credentialSource:s,...s==="paperclip_vault"?{credentialValues:Je}:{},...s==="vercel_connect"?{vercelConnect:{connector:He.trim()}}:{},...Dt.trim()?{oauthClient:{clientId:Dt.trim(),...fs?{clientSecret:fs}:{}}}:{},configValues:RS(Et,Er)?{allowedSpreadsheetIds:Ka}:Object.keys(Fe).length>0?Fe:void 0,applicationId:Q.applicationId,...B?{resumeConnectionId:B}:H?{reconnectConnectionId:H}:{},...Rn!=="organization"?{grantKind:Rn}:{},...Rn==="agent"?{subjectAgentId:[...ft][0]}:{}})}else{const Rn=TZe({link:ve,name:xe,authMode:Xe,needsKey:ge,keyValue:Ye,headers:Oe,oauthClientId:xt,oauthClientSecret:Ge}),Er=YJ(Rn.name??JL(ve)??"Custom app",ir);Ps=await cs.connectApp(_,{...Rn,...H?{reconnectConnectionId:H}:{},...ne||hn?.slug==="zapier"?{galleryKey:"zapier",connectionMethodKey:"generated-url"}:{},name:Er,applicationId:Q.applicationId,...ir!=="organization"?{grantKind:ir}:{},...ir==="agent"?{subjectAgentId:[...ft][0]}:{}})}return Ps.auth?.kind==="oauth"&&!B&&!H&&await zr(Ps.connectionId),Ps},"mutationFn"),onSuccess:r(Be=>{if(Be.auth?.kind==="oauth"){if(gs(Be),Be.auth.manualClientRequired){tt(JJ("oauth_manual_client_required",null)),ue("oauth"),Ke(!0),ke(!1);return}if(n==="dialog"||A){Ee("starting"),ke(!ae),Yn(Be.connection);return}const Ps=Be.auth.startUrl?.trim();if(!Ps){Ee("starting"),ke(!0),Yn(Be.connection);return}ke(!0),aa({authorizationUrl:Ps,handoff:Be.auth.handoff});return}tt(null),gs(Be);const Et={};for(const Ps of Be.actions.readOnly)Et[Ps.catalogEntryId]=!0;for(const Ps of Be.actions.canMakeChanges)Et[Ps.catalogEntryId]=!0;Ct(Et),Rt.mutate({result:Be,enabled:Et})},"onSuccess"),onError:r(Be=>{const Et=Be instanceof cn&&Be.body&&typeof Be.body=="object"?Be.body.details:null;if(_r){Ee("error"),g?.("needs_retry"),Ze(Et?.code==="invalid_grant"?"Your authorization expired or was revoked. Reconnect to continue.":Be instanceof Error?Be.message:"Paperclip couldn’t start secure sign-in. Try again.");return}if(!ae&&ve){const Ps=typeof Et?.code=="string"?Et.code:null,Rn=JJ(Ps,Be instanceof Error?Be.message:null);tt(Rn),ke(!1),Rn.focus==="credentials"&&Ke(!0);return}T({title:"Couldn’t connect",body:Be instanceof Error?Be.message:"Please check your key and try again.",tone:"error"})},"onError")}),re=Fa.mutate,at=(0,m.useCallback)(Be=>{const Et=Be??ae;(Et?xA(Et,ze||null):null)?.auth==="oauth"&&xr(),re(Be)},[ze,ae,re,xr]);(0,m.useEffect)(()=>{if(!de||Sn.isLoading||!Sn.data||H&&(!rs.isFetchedAfterMount||!Zn.isFetchedAfterMount))return;const Be=$Ze({requestedAppKey:de,galleryApps:Sn.data.apps,reconnectConnection:Hs,applications:Zn.data?.applications??[]}),Et=!!Be?.methods.some(ai=>ai.oauthStrategy==="paperclip_cloud_connector"||ai.oauthStrategy==="paperclip_id_connector");if(mr&&!Et&&Gt.isLoading)return;const Ps=Ej(Be,s),Rn=f??(Hs?.connectionPurpose==="ai"?PG.safeParse(Hs.config?.ai).data:void 0),Er=Ps.find(ai=>Rn?ai.ai?.provider===Rn.provider&&(!("mode"in Rn)||Rn.mode!=="responsible_user")&&ai.ai.method===Rn.method:ai.key===q)??(mr&&!Et?aZ(on):null)??vw(Ps),Ka=Ps.length===1?Ps[0]:null,sa=s==="paperclip_vault"&&!!oZ(Be),Wi=FZe({credentialSource:s,available:Sn.data.credentialSources?.vercelConnect.available===!0,retainedReconnectMatches:!!(H&&Hn)}),Pr=Ps.length===1&&Ka?.auth==="oauth"&&!Zp(Ka)&&!RR(Ka),bo=BZe({available:Be?.availability?.available,reconnectConnectionId:H,reconnectSourceMatches:Hn}),Ro=qZe({reconnectConnectionId:H,hasRequestedEntry:!!Be,supportedMethodCount:Ps.length,unsupportedOAuth:Pr,vercelUnavailable:Wi,definitionUnavailable:bo});if(Ro!=="ready"){if(le(null),te("gallery"),Ro==="reconnect_unavailable"&&H){Wr(H);return}k(fA(s==="vercel_connect"?YL():"/apps/connect",A),{replace:!0});return}if(Wr(null),!!Be){if(ae?.slug!==Be.slug){le(Be),he(Be.name),pe(""),_e(""),Ie(!1),$e(""),ut({}),Jt(""),We(""),ct(""),is(Er?.key??""),Qt(Hk(Er)),Ms(""),pt(null),gs(null);const ai=X?.companyId===_?X:null;xs(cr??ai?.grantKind??ZL(Er,!!i)),us(new Set(ai?.agentIds??(i?[i]:[]))),qe(ai?.installChoice??(i?"specific":"all")),te(tZ({requestedAppKey:de,routeStage:E,resumeConnectionId:B,hasPrefilledLink:!!Q.link,zapierSource:ne}))}else bt!==Et&&(le(Be),is(Er?.key??""),Qt(Hk(Er)));if(!(sa&&(!Zn.isFetchedAfterMount||!rs.isFetchedAfterMount))&&!(sa&&Ft.current)&&sa&&(Zn.isError||rs.isError)){Ee("error"),Ze("Paperclip couldn’t check for an existing connection. Try again."),te("key");return}}},[f,q,Zn.isError,Zn.isFetchedAfterMount,Zn.data,rs.isError,rs.isFetchedAfterMount,Gt.data?.configured,Gt.isLoading,ze,s,ae?.slug,bt,Sn.data,Sn.isLoading,k,cr,Hs,H,Hn,B,on,de,i,X,E,ne]),(0,m.useEffect)(()=>{Hs?.connectionPurpose==="ai"&&fe==="access"&&te("key")},[Hs?.connectionPurpose,fe]),(0,m.useEffect)(()=>{Yt.current=null,In(null)},[B]),(0,m.useEffect)(()=>{if(!Pn||!ae||Pn.status!=="draft"||Yt.current===Pn.id)return;const Be=Pn.config&&typeof Pn.config=="object"?Pn.config:{},Et=typeof Be.sourceTemplateKey=="string"?Be.sourceTemplateKey:null;if(Et&&Et!==ae.slug)return;const Ps=typeof Be.connectionMethodKey=="string"?Be.connectionMethodKey:null,Rn=Ps?Ej(ae,s).find(Ka=>Ka.key===Ps)??null:null;if(he(Pn.name||ae.name),Rn){is(Rn.key);const Ka=Be.methodConfig&&typeof Be.methodConfig=="object"?Be.methodConfig:{};Qt({...Hk(Rn),...Object.fromEntries(Object.entries(Ka).filter(sa=>typeof sa[1]=="string"||typeof sa[1]=="boolean"))})}const Er=Be.oauth&&typeof Be.oauth=="object"?Be.oauth:null;Er?.clientRegistrationSource==="manual"&&typeof Er.clientId=="string"&&Jt(Er.clientId),U==="failed"||U==="denied"?(Ee("error"),Ze(eZ(U,z))):(Ee("entry"),Ze(null)),te("key"),Yt.current=Pn.id,In(Pn.id)},[s,ae,z,U,Pn]);const Rt=Ne({mutationFn:r(async Be=>{const{result:Et,enabled:Ps}=Be,Rn=Object.entries(Ps).filter(([,Pr])=>Pr).map(([Pr])=>Pr),Er=new Set(Array.isArray(Et.suggestedDefaults.askFirstRiskLevels)?Et.suggestedDefaults.askFirstRiskLevels.filter(Pr=>typeof Pr=="string"):[]),Ka=Et.actions.canMakeChanges.filter(Pr=>Ps[Pr.catalogEntryId]&&Er.has(Pr.riskLevel)).map(Pr=>Pr.catalogEntryId),sa=bs==="all"?"all_agents":{agentIds:Array.from(ft)},Wi=await cs.finishApp(_,Et.connectionId,{enabledCatalogEntryIds:Rn,askFirstCatalogEntryIds:Ka,access:sa,...i?{preserveExistingAccess:!0}:{}});return await zr(Et.connectionId),Wi},"mutationFn"),onSuccess:r((Be,Et)=>{je("success"),h?.({connectionId:Et.result.connectionId})},"onSuccess"),onError:r(Be=>{je("access"),T({title:"Couldn’t finish setup",body:Be instanceof Error?Be.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)&&(rs.isError||Zn.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[Be,Et]=await Promise.all([rs.refetch(),Zn.refetch()]);!Be.isError&&!Et.isError&&(Ze(null),Ee("entry"))},"onClick"),children:"Try again"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>k("/apps"),"onClick"),children:"Back to apps"})]})]});if(B&&rs.isFetchedAfterMount&&!Pn)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(()=>k("/apps"),"onClick"),children:"Back to apps"})]});if(H&&rs.isFetchedAfterMount&&Zn.isFetchedAfterMount&&(!Hs||!Hn))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(()=>k("/apps"),"onClick"),children:"Back to apps"})]});if((B||H)&&Sn.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(()=>{Sn.refetch()},"onClick"),children:"Try again"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>k("/apps"),"onClick"),children:"Back to apps"})]})]});if(H&&rr===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(()=>k("/apps"),"onClick"),children:"Back to apps"})]});if(B&&(!rs.isFetchedAfterMount||Sn.isLoading||!ae||Vs!==Pn?.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)(Nn,{className:"h-8 w-48"}),(0,t.jsx)(Nn,{className:"h-40 w-full rounded-xl"})]});if(H&&(!rs.isFetchedAfterMount||!Zn.isFetchedAfterMount||Sn.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)(Nn,{className:"h-8 w-48"}),(0,t.jsx)(Nn,{className:"h-40 w-full rounded-xl"})]});if(Tn&&u)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)(s8,{choices:c.map(Be=>({id:Be.id,name:Be.name,description:Be.status==="active"&&Be.enabled?"Ready to use":"Setup needs attention"})),pendingId:rn,onSelect:r(async Be=>{br(Be),nr(null);try{await u(Be)}catch(Et){nr(Et instanceof Error?Et.message:"Couldn’t use this connection."),br(null)}},"onSelect")}),Zs?(0,t.jsx)(Ya,{tone:"danger",className:"mt-4",children:Zs}):null,(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>pn(!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=!!(_r&&fe==="key"&&($r||St!=="entry")),Ys=!!(fe==="key"&&ae&&mr&&!bt&&Gt.data?.configured===!0),an=!!(fe==="key"&&ae&&mr&&!bt&&(Gt.isLoading||Gt.isError||Gt.data?.configured!==!0));if(Ns&&_r)return(0,t.jsx)(o6,{entry:_r,resuming:!!B,phase:St,error:De,recoveryActions:z==="github_installation_required"?{installationUrl:$,managementUrl:K}:void 0,authorizationHost:kt,authorizationUrl:ws,onOpenAuthorization:ar,onRetry:r(async()=>{Ze(null),Ee("starting");const Be=$t?.connection??ia;if(Be){Yn(Be);return}Ft.current=!0;try{const[Et,Ps]=await Promise.all([Zn.refetch(),rs.refetch()]);if(Et.isError||Ps.isError){Ee("error"),Ze("Paperclip couldn’t check for an existing connection. Try again.");return}const Rn=(B?(Ps.data?.connections??[]).find(Er=>Er.id===B&&Er.authKind==="oauth")??null:null)??lZ(oe,Et.data?.applications??[],Ps.data?.connections??[],O?{applicationId:Q.applicationId,draftOnly:!0}:{});if(!Lt.current&&!B){Rn&&xs(Rn.credentialPolicy==="per_user"?"user":Rn.credentialPolicy==="per_agent"?"agent":"organization"),Ee("entry"),Ze(null),te("access");return}Rn?Yn(Rn):Fa.mutate(_r)}finally{Ft.current=!1}},"onRetry"),onBack:r(()=>{zs.current?.abort(),Ee("entry"),Ze(null),je("access")},"onBack"),onCancel:r(()=>{zs.current?.abort(),(v??(()=>k("/apps")))()},"onCancel")});if(Se&&!ae&&ve&&fe==="key")return(0,t.jsx)(o6,{identity:{name:xe.trim()||xC(ve)||"this server",unverifiedHost:xC(ve)},steps:{labels:nZ,activeIndex:rZ.key},phase:St,error:De,authorizationHost:kt,authorizationUrl:ws,onOpenAuthorization:ar,onRetry:r(()=>{Ze(null);const Be=$t?.connection;if(Be){Ee("starting"),Yn(Be);return}ke(!1),Ee("entry")},"onRetry"),onBack:r(()=>{zs.current?.abort(),ke(!1),Ee("entry"),Ze(null)},"onBack"),onCancel:r(()=>{zs.current?.abort(),(v??(()=>k("/apps")))()},"onCancel")});const ea=$t?.application.name??ae?.name??(xe.trim()||JL(ve)||"this app"),zt=Ej(ae,s),ns=Ls?[Ls]:zt,ln=Z?On.filter(Be=>Ej(Be,s).length>0):On,ta=ne?Sn.data?.apps.find(Be=>Be.slug==="zapier")??null:null,Gn=(Hs?.connectionPurpose==="ai"?PG.safeParse(Hs.config?.ai).data:void 0)??ae?.methods.find(Be=>Be.key===ze)?.ai??(!ze&&ae?.methods.every(Be=>Be.ai)?ae.methods[0]?.ai:void 0),Ba=ae?y?.({app:ae,name:ce||ae.name,grantKind:ir,agentIds:[...ft],allAgents:bs==="all",onBack:r(()=>je("access"),"onBack")})??(Gn&&_?(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(q5,{companyId:_,provider:Gn.provider,fixedMethod:!!(f&&f.mode!=="responsible_user"),initialMethod:Hs?.connectionPurpose==="ai"?(Hs.config?.ai).method:Gn.method,connectionId:Hs?.connectionPurpose==="ai"?Hs.id:void 0,name:Hs?.connectionPurpose==="ai"?Hs.name:ce||`My ${ae.name} ${Gn.method==="subscription"?"subscription":"API"}`,ownership:(Hs?.connectionPurpose==="ai"?Hs.credentialPolicy==="shared":ir==="organization")?"shared":"personal",agentIds:[...ft],allAgents:bs==="all",onCancel:r(()=>v?v():k("/apps"),"onCancel"),onComplete:r(Be=>{h?.({connectionId:Be.connectionId}),h||k(`/apps/${Be.connectionId}/permissions`)},"onComplete")})}):void 0):void 0,ni=Hs?.connectionPurpose==="ai"?["Reconnect account"]:Ba!==void 0?["Access","Connect account"]:ne?UZe:ae&&ns.length>1?["Access","Choose connection"]:ae&&ns[0]?.auth==="oauth"?["Access","Sign in"]:RS(ae,ze)?["Access","Share sheet"]:ae?["Access","Add your key"]:nZ,Ni=ae?ze?ns.find(Be=>Be.key===ze)??null:ns[0]??null:null,Ti=ae?Ni?.auth??"none":Xe==="none"?"none":Xe==="oauth"?"oauth":"api_key",ro=!!$r,ei=ro?`Continue to ${ae?.name??"sign-in"}`:Ti==="oauth"?"Continue":"Save and continue",Re=Hs?.connectionPurpose==="ai"?0:(ne||ae)&&fe!=="gallery"&&fe!=="success"?zZe[fe]:fe==="success"?ni.length:rZ[fe];return(0,t.jsxs)("div",{className:"max-w-5xl",children:[fe!=="success"&&!(e&&fe==="gallery")&&(0,t.jsx)(e7,{subtitle:fe==="gallery"?Z?"Choose a reviewed app to connect through Vercel.":"Pick the app you want your agents to use.":`Step ${Re+1} of ${ni.length}`,step:fe,activeIndex:Re,labels:ni,appIdentity:ne?{name:"Zapier",logoUrl:ta?.branding.logoUrl??null,darkLogoUrl:ta?.branding.darkLogoUrl??null}:ae&&fe!=="gallery"?{name:ae.name,logoUrl:ae.branding.logoUrl,darkLogoUrl:ae.branding.darkLogoUrl??null}:void 0,unverifiedHost:!ae&&!ne&&fe!=="gallery"?xC(ve):null,onCancel:v??(()=>k("/apps"))}),fe==="gallery"&&(0,t.jsx)(YZe,{loading:Sn.isLoading,initialLink:ve,apps:ln,vercelConnect:Z,vercelConnectAvailability:Sn.data?.credentialSources?.vercelConnect??null,byo:ee,byoOnly:e,source:R.get("source"),onPick:Rr,onUseLink:r(Be=>{const Et=PR(Be,On);le(null),he(""),pe(Be),_e(Et?.name??JL(Be)??""),Ie(!1),$e(""),ut({}),Ms(""),pt(null),us(new Set(i?[i]:[])),qe(i?"specific":"all"),xs(cr??(i?"user":"organization")),te("access")},"onUseLink")}),Ys&&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(()=>je("access"),"onClick"),children:"Back"}),(0,t.jsxs)(F,{type:"button",disabled:Sn.isFetching,onClick:r(()=>{Sn.refetch()},"onClick"),children:[Sn.isFetching?(0,t.jsx)(rt,{className:"h-4 w-4 animate-spin"}):null,"Try again"]})]})]}):fe==="key"&&ae&&an?(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)(p0,{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)."]})]})]}),Gt.isError||mn?(0,t.jsx)(Ya,{tone:"danger",className:"mt-4",children:mn??"Paperclip couldn’t check Cloud registration. Try again."}):null,Fs?(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:Fs,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(()=>je("access"),"onClick"),children:"Back"}),(0,t.jsxs)(F,{type:"button",disabled:Gt.isLoading||Un.isPending,onClick:r(()=>{Os(null),xr(),Nr(),Un.mutate()},"onClick"),children:[Un.isPending?(0,t.jsx)(rt,{className:"h-4 w-4 animate-spin"}):null,Gt.data?.status==="pending"?"Continue":"Connect with Paperclip"]})]})]})}):fe==="key"&&ae&&Ba!==void 0?Ba:fe==="key"&&ae?(0,t.jsx)(JZe,{entry:ae,error:Fa.isError?Fa.error instanceof Error?Fa.error.message:"Please check your key and try again.":null,values:Je,onChange:ut,oauthClientId:Dt,onOAuthClientIdChange:Jt,oauthClientSecret:fs,onOAuthClientSecretChange:We,credentialSource:s,vercelConnector:He,onVercelConnectorChange:ct,vercelConnectAvailability:Sn.data?.credentialSources?.vercelConnect??null,methodKey:ze,onMethodChange:r(Be=>{is(Be?.key??""),!cr&&Be?.grantKinds&&!Be.grantKinds.includes(dn)&&xs(ZL(Be,!!i)),ut({}),Jt(""),We(""),ct(""),Qt(Hk(Be))},"onMethodChange"),configValues:Fe,onConfigChange:Qt,googleSheetsLinks:Tt,googleSheetsError:Ue,onGoogleSheetsLinksChange:r(Be=>{Ms(Be),pt(null)},"onGoogleSheetsLinksChange"),submitting:Fa.isPending,onBack:r(()=>je("access"),"onBack"),onConnect:r(()=>{if(RS(ae,ze)){const Ps=mB(Tt);if(Ps.invalidCount>0){pt("That doesn't look like a Google Sheets link.");return}if(Ps.ids.length===0){pt("Paste at least one Google Sheets link.");return}}const Be=xA(ae,ze||null),Et=!!(Be?.credentialFields?.length||Be?.tenantFields?.some(Ps=>!Ps.hidden)||Be?.extensionFields?.some(Ps=>!Ps.hidden));if(Be&&Zp(Be)&&ia&&!Et&&!Dt.trim()){Lt.current=!0,Ze(null),Ee("starting"),Yn(ia);return}Be&&Zp(Be)&&(Lt.current=!0,Ze(null),Ee("starting")),at()},"onConnect")}):null,fe==="key"&&!ae&&ve&&!ne&&(0,t.jsx)(XZe,{link:ve,name:xe,needsKey:ge,onNeedsKeyChange:r(Be=>{Ie(Be),Be||$e("")},"onNeedsKeyChange"),keyValue:Ye,onKeyChange:$e,authMode:Xe,onAuthModeChange:r(Be=>{ue(Be),tt(null),Be!=="auto"&&Ie(!1),Be!=="bearer"&&Be!=="auto"&&$e("")},"onAuthModeChange"),headers:Oe,onHeadersChange:r(Be=>{dt(Be),tt(null)},"onHeadersChange"),oauthClientId:xt,onOAuthClientIdChange:Le,oauthClientSecret:Ge,onOAuthClientSecretChange:ht,advancedOpen:Ve,onAdvancedOpenChange:Ke,guidance:gt,matchedEntry:hn,onUseMatchedEntry:hn?()=>Rr(hn):void 0,submitting:Fa.isPending||Se,onBack:r(()=>te("access"),"onBack"),onConnect:r(()=>{tt(null),Fa.mutate(void 0)},"onConnect")}),fe==="key"&&!ae&&ne&&(0,t.jsx)(QZe,{link:ve,onLinkChange:pe,submitting:Fa.isPending,onBack:r(()=>te("access"),"onBack"),onConnect:r(()=>Fa.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:Ni?.guidanceMd}),(0,t.jsx)("ul",{className:"list-disc space-y-2 pl-5",children:Ni?.warnings?.map(Be=>(0,t.jsx)("li",{children:Be},Be))})]}),(0,t.jsx)(bbe,{companyId:_,authKind:Ti,grantKinds:Ds?[Ds]:Ni?.grantKinds,grantKind:ir,setGrantKind:xs,installChoice:bs,setInstallChoice:qe,installAgentIds:ft,setInstallAgentIds:us,lockedAgentId:i,capabilities:Sn.data?.capabilities,githubIdentity:ae?.slug==="github",submitLabel:ei,continuesToProvider:ro,identityLoading:!!_r&&Zr,preserveAgentAccess:!!(_r&&(ia||Hs)),pending:Fa.isPending||qt.isPending||!!(de&&!ae),onBack:Na,onContinue:r(()=>{if($r){Lt.current=!0,Ze(null),Ee("starting"),je("key"),ia?Yn(ia):at($r);return}ae?je("key"):te("key")},"onContinue")})]}),fe==="success"&&(0,t.jsx)(tet,{appName:ea,logoUrl:ae?.branding.logoUrl,darkLogoUrl:ae?.branding.darkLogoUrl,summary:eet({grantKind:ir,authKind:Ti,installChoice:bs,installCount:ft.size,enabledCount:Object.values(Rs).filter(Boolean).length}),onDone:v??(()=>k("/apps"))})]})}r(GZe,"StandardConnectionSetupFlow");function e7({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)(Cc,{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)(pP,{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((u,h)=>(0,t.jsx)("li",{"data-testid":"wizard-step-dot","data-step-active":h===i?"true":void 0,className:W("h-1 w-20 rounded-full",h<=i?"bg-foreground":"bg-border")},u))}),(0,t.jsx)("div",{className:"mt-2 text-xs text-muted-foreground","data-testid":"wizard-step-labels",children:o.join(" · ")})]})]})}r(e7,"StepHeader");function o6({entry:e,identity:s,resuming:n=!1,phase:a,error:i,recoveryActions:o,authorizationHost:l,authorizationUrl:c,steps:d={labels:KZe,activeIndex:1},onRetry:u,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)(e7,{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)(dc,{className:"h-5 w-5 text-destructive"}):a==="entry"?(0,t.jsx)(Bd,{className:"h-5 w-5 text-muted-foreground"}):(0,t.jsx)(rt,{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)(pP,{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)(to,{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:u,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(o6,"OAuthConnectStateScreen");function QZe({link:e,onLinkChange:s,submitting:n,onBack:a,onConnect:i}){const o=l6(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)(jt,{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)(rt,{className:"mr-2 h-4 w-4 animate-spin"}),n?"Checking…":"Check link"]})]})]})}r(QZe,"ZapierConnectStep");function YZe({loading:e,initialLink:s="",apps:n,byo:a=!1,byoOnly:i=!1,vercelConnect:o=!1,vercelConnectAvailability:l=null,source:c=null,onPick:d,onUseLink:u}){const[h,p]=(0,m.useState)(""),[f,g]=(0,m.useState)(s),v=(0,m.useRef)(!1);(0,m.useEffect)(()=>{v.current||g(s)},[s]);const[y,w]=(0,m.useState)(null),k=(0,m.useRef)(null),j=(0,m.useRef)(null),N=(0,m.useRef)(!1);(0,m.useEffect)(()=>{!a||e&&!i||N.current||(i||k.current?.scrollIntoView?.({block:"center"}),j.current?.focus(),j.current?.select(),N.current=!0)},[a,i,e]);const _=(0,m.useMemo)(()=>{const A=h.trim().toLowerCase();return n.filter(L=>!A||L.name.toLowerCase().includes(A))},[n,h]),I=l6(f),C=I?PR(I,n):null,T=c==="zapier",R=r(()=>{const A=l6(f);if(!A){w("Paste a full http or https link.");return}w(null),u(A)},"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((A,L)=>(0,t.jsx)(Nn,{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)(to,{className:"ml-2 h-3.5 w-3.5"})]})}):null]}),l?.available===!1?(0,t.jsx)(Ya,{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)(jt,{value:h,onChange:r(A=>p(A.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(A=>{const L=ube(A.slug,A.description),D=M_(A),O=D.length===0||D.every(q=>q.auth==="oauth"&&!Zp(q)&&!RR(q)),E=A.availability?.available===!1||o&&l?.available!==!0;return(0,t.jsxs)("button",{type:"button",disabled:O||E,title:E?A.availability?.reason??l?.reason??void 0:void 0,onClick:r(()=>d(A),"onClick"),className:W("flex flex-col rounded-xl border border-border bg-card p-4 text-left transition-colors",O||E?"cursor-not-allowed opacity-60":"hover:border-foreground/30 hover:bg-accent/40"),children:[(0,t.jsx)(Cc,{name:A.name,logoUrl:A.branding.logoUrl,darkLogoUrl:A.branding.darkLogoUrl,size:36}),(0,t.jsx)("div",{className:"mt-3 text-sm font-bold text-foreground",children:A.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:A.availability?.reason??l?.reason??"Unavailable on this instance."}):O?(0,t.jsx)("span",{className:"text-muted-foreground",children:"Unavailable"}):(0,t.jsx)("span",{children:"Connect →"})})]},A.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:k,className:W("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)(dc,{className:"h-4 w-4 text-muted-foreground"}),T?"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:T?"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."}),!T&&(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)(Cc,{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"){R();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)(jt,{ref:j,type:T||C?.slug==="zapier"?"password":"url",autoComplete:"off",spellCheck:!1,"aria-label":"MCP server URL",value:f,onChange:r(A=>{v.current=!0,g(A.target.value),w(null)},"onChange"),onKeyDown:r(A=>{A.key==="Enter"&&R()},"onKeyDown"),placeholder:T?"https://mcp.zapier.com/api/v1/connect?token=…":"https://example.com/actions",className:"h-10"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:R,children:"Continue"})]}),y&&(0,t.jsx)("div",{className:"text-xs text-destructive",children:y})]})]})]})}r(YZe,"GalleryStep");function l6(e){try{const s=new URL(e.trim());return s.protocol!=="http:"&&s.protocol!=="https:"?null:s.toString()}catch{return null}}r(l6,"normalizeAppLink");function XZe({link:e,name:s,needsKey:n,onNeedsKeyChange:a,keyValue:i,onKeyChange:o,authMode:l,onAuthModeChange:c,headers:d,onHeadersChange:u,oauthClientId:h,onOAuthClientIdChange:p,oauthClientSecret:f,onOAuthClientSecretChange:g,advancedOpen:v,onAdvancedOpenChange:y,guidance:w,matchedEntry:k,onUseMatchedEntry:j,submitting:N,onBack:_,onConnect:I}){const C=xC(e),T=l==="custom_headers"?mbe(d):null,R=RZe({link:e,name:s,authMode:l,needsKey:n,keyValue:i,headers:d,oauthClientId:h,oauthClientSecret:f}),A=l==="auto",L=k?.slug==="zapier"?Jde(e):e,D=r((O,E)=>{u(d.map(q=>q.id===O?{...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)(pP,{host:C})]}),k&&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)(Cc,{name:k.name,logoUrl:k.branding.logoUrl,darkLogoUrl:k.branding.darkLogoUrl,size:24}),(0,t.jsxs)("span",{className:"truncate",children:["Paperclip has a guided setup for ",k.name,"."]})]}),(0,t.jsxs)(F,{type:"button",size:"sm",variant:"outline",onClick:j,children:["Use ",k.name]})]}):null,w?(0,t.jsx)("div",{className:"mt-6",children:(0,t.jsx)(Ya,{tone:"warning",title:w.title,children:w.body})}):null,(0,t.jsxs)("div",{className:"mt-6 space-y-6",children:[A&&(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)(eD,{label:"No",selected:!n,onClick:r(()=>a(!1),"onClick")}),(0,t.jsx)(eD,{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."})]}),A&&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)(jt,{id:"generic-mcp-key",type:"password",autoComplete:"off",value:i,onChange:r(O=>o(O.target.value),"onChange"),placeholder:"••••••••••••••••",className:"mt-2 h-11 font-mono"})]})}):null,(0,t.jsxs)(il,{open:v,onOpenChange:y,children:[(0,t.jsxs)(Yl,{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)(sn,{className:W("h-4 w-4 text-muted-foreground transition-transform",v&&"rotate-180")})]}),(0,t.jsxs)(ol,{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:cZ.map(O=>(0,t.jsx)(eD,{label:O.label,selected:l===O.mode,onClick:r(()=>c(O.mode),"onClick")},O.mode))}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:cZ.find(O=>O.mode===l)?.hint}),l==="custom_headers"?(0,t.jsxs)("div",{className:"space-y-3",children:[d.map(O=>(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(jt,{value:O.name,onChange:r(E=>D(O.id,{name:E.target.value}),"onChange"),placeholder:"Header name","aria-label":"Header name",className:"h-10 font-mono"}),(0,t.jsx)(jt,{type:"password",autoComplete:"off",value:O.value,onChange:r(E=>D(O.id,{value:E.target.value}),"onChange"),placeholder:"Value","aria-label":O.name.trim()?`Value for ${O.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(()=>u(d.filter(E=>E.id!==O.id)),"onClick"),disabled:d.length===1,children:"Remove"})]},O.id)),(0,t.jsx)(F,{type:"button",variant:"outline",size:"sm",onClick:r(()=>u([...d,i6()]),"onClick"),children:"Add another header"}),T?(0,t.jsx)("p",{className:"text-xs text-destructive",children:T}):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)(jt,{id:"generic-mcp-client-id",value:h,onChange:r(O=>p(O.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)(jt,{id:"generic-mcp-client-secret",type:"password",autoComplete:"off",value:f,onChange:r(O=>g(O.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:I,disabled:N||!R||!!T,children:[N&&(0,t.jsx)(rt,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":"Check link"]})]})]})}r(XZe,"LinkConnectStep");var cZ=[{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 eD({label:e,selected:s,onClick:n}){return(0,t.jsx)("button",{type:"button",onClick:n,"aria-pressed":s,className:W("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(eD,"SegmentedOption");function JZe({entry:e,error:s,values:n,onChange:a,oauthClientId:i,onOAuthClientIdChange:o,oauthClientSecret:l,onOAuthClientSecretChange:c,credentialSource:d,vercelConnector:u,onVercelConnectorChange:h,vercelConnectAvailability:p,methodKey:f,onMethodChange:g,configValues:v,onConfigChange:y,googleSheetsLinks:w,googleSheetsError:k,onGoogleSheetsLinksChange:j,submitting:N,onBack:_,onConnect:I}){const C=(0,m.useMemo)(()=>Ej(e,d),[d,e]),T=f?C.find($e=>$e.key===f)??null:vw(C),R=(0,m.useMemo)(()=>C.some($e=>$e.capabilityProfile)?Array.from(C.reduce(($e,Xe)=>{const ue=Xe.capabilityProfile.key,Oe=$e.get(ue);return Oe?Oe.methods.push(Xe):$e.set(ue,{key:ue,label:Xe.capabilityProfile?.label??Xe.label??Xe.key,description:Xe.capabilityProfile?.description??Xe.whenToUse,methods:[Xe]}),$e},new Map)).map(([,$e])=>$e):[],[C]),A=T?.capabilityProfile?.key??T?.key??"",L=R.map($e=>$e.key).join("|"),[D,O]=(0,m.useState)(A||vw(C)?.capabilityProfile?.key||(R.length===1?R[0].key:""));(0,m.useEffect)(()=>{if(A){O(A);return}O($e=>R.some(Xe=>Xe.key===$e)?$e:vw(C)?.capabilityProfile?.key||(R.length===1?R[0].key:""))},[L,R,C,A]);const E=R.length>1?R.find($e=>$e.key===D)?.methods??[]:C,q=(T?.credentialFields??[]).map($e=>({...$e,configPath:eue($e),helpUrl:T?.consoleLinks?.keys??T?.consoleLinks?.docs??""})),B=T?.credentialSources?.vercelConnect??null,U=d==="vercel_connect",z=U||q.every($e=>$e.required===!1||(n[$e.configPath]?.trim().length??0)>0),$=RR(T),K=$&&!Zp(T),H=U||!K||i.trim().length>0,se=!U||u.trim().length>0,Z=T?.auth==="oauth"&&$?AZe():null,ie=[...T?.tenantFields??[],...T?.extensionFields??[]],oe=ie.filter($e=>!$e.hidden),Y=oe.filter($e=>$e.advanced!==!0),ne=oe.filter($e=>$e.advanced===!0),[de,ee]=(0,m.useState)(!1),X=ie.every($e=>{if(!$e.required)return!0;const Xe=v[$e.key];return typeof Xe=="boolean"||typeof Xe=="string"&&Xe.trim().length>0}),Q=T?.configRequirements?.atLeastOneOf??[],fe=Q.length===0||Q.some($e=>{const Xe=v[$e];return typeof Xe=="string"&&Xe.trim().length>0}),te=(R.length<=1||!!D)&&(E.length<=1?!!T:!!f),ae=e.availability?.robotEmail??null,le=e.availability?.available===!1,ce=!U&&$&&!K,he=ne.length>0||ce,ve=R.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)(xu,{ariaLabel:`Access level for ${e.name}`,className:"mt-2",value:D,onValueChange:r($e=>{const Xe=R.find(ue=>ue.key===$e);Xe&&(O($e),g(DU(Xe.methods)))},"onValueChange"),options:R.map($e=>({value:$e.key,title:$e.label,description:$e.description}))}),!D&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Choose an access level to continue."})]}):null,pe=E.find($e=>$e.oauthStrategy==="paperclip_cloud_connector"&&ZTe($e.connectorProfile??"")),xe=pe&&E.find($e=>RR($e)&&!Zp($e)),_e=T?.key===xe?.key,ge=(0,m.useId)(),Ie=pe&&xe&&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":ge,disabled:N,onClick:r(()=>g(_e?pe:xe),"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)(xu,{ariaLabel:`How to connect ${e.name}`,className:"mt-2",value:f,onValueChange:r($e=>{const Xe=E.find(ue=>ue.key===$e);Xe&&g(Xe)},"onValueChange"),options:E.map($e=>({value:$e.key,title:$e.label??($e.auth==="oauth"?`Sign in with ${e.name}`:"Use an API key")}))}),!T&&(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Choose a connection method to continue."})]}):null;if(RS(e,T)){const $e=mB(w),Xe=!le&&!!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:[ve,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)(gbe,{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)(_n,{value:w,onChange:r(ue=>j(ue.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:$e.ids.length>0?`${$e.ids.length} ${$e.ids.length===1?"sheet":"sheets"} ready to connect.`:"Paste one link per line. Both .../edit and .../edit#gid=... links work."}),k&&(0,t.jsx)("div",{className:"mt-2 text-xs text-destructive",children:k})]})]}),(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:I,disabled:N||!Xe,children:[N&&(0,t.jsx)(rt,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":"Connect"]})]})]})}const Ye=T?.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)(to,{className:"h-3 w-3"})]})}):null,(0,t.jsxs)("div",{className:"space-y-6",children:[ve,Ie,U&&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)(to,{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)(jt,{id:"vercel-connect-connector",value:u,onChange:r($e=>h($e.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)(Ya,{tone:"danger",children:s})}):null,Y.map($e=>(0,t.jsx)(uZ,{field:$e,value:v[$e.key],onChange:r(Xe=>y({...v,[$e.key]:Xe}),"onChange")},$e.key)),he&&(0,t.jsxs)(il,{open:de,onOpenChange:ee,children:[(0,t.jsxs)(Yl,{className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[(0,t.jsx)(sn,{className:W("h-4 w-4 transition-transform",de&&"rotate-180")}),"Advanced"]}),(0,t.jsx)(ol,{className:"pt-4",children:(0,t.jsxs)("div",{className:"space-y-6",children:[ne.map($e=>(0,t.jsx)(uZ,{field:$e,value:v[$e.key],onChange:r(Xe=>y({...v,[$e.key]:Xe}),"onChange")},$e.key)),ce?(0,t.jsx)(dZ,{entry:e,method:T,callbackUrl:Z,clientId:i,onClientIdChange:o,clientSecret:l,onClientSecretChange:c,required:!1}):null]})})]}),!U&&T?.auth==="oauth"&&K?(0,t.jsx)("div",{id:ge,role:"region","aria-label":"Your OAuth app",children:(0,t.jsx)(dZ,{entry:e,method:T,callbackUrl:Z,clientId:i,onClientIdChange:o,clientSecret:l,onClientSecretChange:c,required:!0})}):null,U||!T||q.length===0?null:q.map($e=>(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:GJ(e.name,$e.label,q.length)}),(0,t.jsx)(jt,{type:"password","aria-label":GJ(e.name,$e.label,q.length),autoComplete:"off",value:n[$e.configPath]??"",onChange:r(Xe=>a({...n,[$e.configPath]:Xe.target.value}),"onChange"),placeholder:"••••••••••••••••",className:"mt-2 h-11 font-mono"}),$e.helpUrl&&(0,t.jsxs)("a",{href:$e.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)(to,{className:"h-3 w-3"})]})]},$e.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:I,disabled:N||!te||!z||!H||!se||!X||!fe,children:[N&&(0,t.jsx)(rt,{className:"mr-2 h-4 w-4 animate-spin"}),N?"Checking…":U?T?.auth==="oauth"?"Validate and continue":"Validate and connect":T?.auth==="oauth"?e.slug==="github"?"Continue to GitHub":"Continue to sign in":"Connect"]})]})]})}r(JZe,"KeyStep");function gbe({value:e,ariaLabel:s}){const{copied:n,failed:a,copy:i}=Sf();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)(ds,{className:"mr-2 h-4 w-4"}):(0,t.jsx)(kr,{className:"mr-2 h-4 w-4"}),n?"Copied":a?"Copy failed":"Copy"]})}r(gbe,"CopyValueButton");function dZ({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)(to,{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)(gbe,{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)(jt,{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)(jt,{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(dZ,"OAuthClientFields");function uZ({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)(yi,{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)(_n,{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)(jt,{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(uZ,"MethodConfigField");function bbe({companyId:e,...s}){const n=J({queryKey:P.agents.list(e),queryFn:r(()=>Vt.list(e),"queryFn")});return(0,t.jsx)(vbe,{...s,agents:(n.data??[]).filter(a=>a.status!=="terminated"),agentsLoading:n.isLoading})}r(bbe,"AccessStep");function vbe({agents:e,agentsLoading:s=!1,authKind:n,grantKinds:a,grantKind:i,setGrantKind:o,installChoice:l,setInstallChoice:c,installAgentIds:d,setInstallAgentIds:u,lockedAgentId:h,capabilities:p,githubIdentity:f=!1,submitLabel:g,continuesToProvider:v=!1,identityLoading:y=!1,preserveAgentAccess:w=!1,pending:k=!1,onBack:j,onContinue:N}){const _=p?.editableAgentIds,I=_?e.filter(B=>_.includes(B.id)):e,C=p?.canSetCompanyInstall??!0,T=p?.canCreateOrganizationGrant??!0,R=n!=="none",A=a??["user","organization"],L=(!R||i==="user"||i==="agent"||T)&&(w?!0:h?d.has(h):i==="agent"?l==="specific"&&d.size===1:l==="all"?C:d.size>0),D=h?e.find(B=>B.id===h)?.name??"the requesting agent":null,O=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:O}),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)(Nn,{className:"h-20 w-full rounded-md"}),(0,t.jsx)(Nn,{className:"h-20 w-full rounded-md"})]}):R&&A.length===1?(0,t.jsxs)("div",{className:"mt-4 flex items-center gap-3 rounded-md border border-border p-4",children:[A[0]==="user"?(0,t.jsx)(ku,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):A[0]==="agent"?(0,t.jsx)(Zi,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}):(0,t.jsx)(dw,{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:A[0]==="user"?f?"My GitHub account":"Just me":A[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:A[0]==="user"?"Agents use it only for runs where you are the responsible person.":A[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]})]}):R?(0,t.jsx)(xu,{ariaLabel:f?O:"Which humans can use this credential?",className:"mt-4 sm:grid-cols-2",value:i,onValueChange:r(B=>{const U=B;o(U),U==="agent"&&(c("specific"),d.size>1&&u(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)(ku,{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)(Zi,{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)(dw,{className:"h-4 w-4","aria-hidden":"true"}),accessibleLabel:T?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:T?void 0:p?.organizationGrantReason??"Only a connection manager can share this credential with the organization.",disabled:!T}].filter(B=>A.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)(dw,{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:D}),". 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)(xu,{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)(Zi,{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)(ZZe,{}),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)(iy,{agents:I,selectedAgentIds:d,onChange:r(B=>u(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:k,children:"Back"}),(0,t.jsxs)(F,{className:"w-full sm:w-auto",onClick:N,disabled:!L||y||k,children:[k?(0,t.jsx)(rt,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):null,g,!k&&v?(0,t.jsx)(to,{className:"h-4 w-4","aria-hidden":"true"}):null]})]})]})}r(vbe,"AccessStepContent");function ZZe(){return(0,t.jsxs)("span",{className:"relative block h-4 w-5","aria-hidden":"true",children:[(0,t.jsx)(Zi,{className:"absolute left-0 top-0 h-3.5 w-3.5"}),(0,t.jsx)(Zi,{className:"absolute bottom-0 right-0 h-3.5 w-3.5"})]})}r(ZZe,"BotGroupIcon");function eet(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(eet,"accessSummaryLines");function tet({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)(ds,{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)(Cc,{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(tet,"ConnectionSetupCompletionScreen");function ybe(){const{newProjectOpen:e,closeNewProject:s}=c_(),{selectedCompanyId:n}=ps();return n&&e?(0,t.jsx)(set,{companyId:n,onClose:s},n):null}r(ybe,"NewProjectDialog");function set({companyId:e,onClose:s}){const n=Ut(),[a,i]=(0,m.useState)(""),[o,l]=(0,m.useState)([]),[c,d]=(0,m.useState)(!1),u=(0,m.useRef)(null),h=Ne({mutationFn:r(()=>pa.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)(Qs,{open:!0,onOpenChange:r(p=>{!p&&!h.isPending&&s()},"onOpenChange"),children:(0,t.jsx)(Xs,{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(),u.current?.focus()},"onOpenAutoFocus"),children:c?(0,t.jsxs)("div",{className:"min-h-0 overflow-y-auto p-5",children:[(0,t.jsx)(en,{className:"sr-only",children:"Connect GitHub"}),(0,t.jsx)(xP,{host:"dialog",serviceSlug:"github",forceNewConnection:!0,onCancel:r(()=>d(!1),"onCancel"),onComplete:r(()=>{n.invalidateQueries({queryKey:t8(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)(en,{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)(sr,{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)(Yc,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,t.jsx)("input",{ref:u,"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)(Bfe,{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(set,"NewProjectForm");var Tx={list:r(e=>Te.get(`/companies/${e}/goals`),"list"),get:r(e=>Te.get(`/goals/${e}`),"get"),create:r((e,s)=>Te.post(`/companies/${e}/goals`,s),"create"),update:r((e,s)=>Te.patch(`/goals/${e}`,s),"update"),remove:r(e=>Te.delete(`/goals/${e}`),"remove")};function jbe(e){return{"--sc":`var(${e})`}}r(jbe,"scStyle");function net(e){const s=e.replace(/_/g," ");return s.charAt(0).toUpperCase()+s.slice(1)}r(net,"sentenceCaseStatus");function Ja({status:e,label:s}){return(0,t.jsx)("span",{className:W("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap shrink-0",kF[e]??"bg-muted text-muted-foreground"),children:s??e.replace(/[_-]/g," ")})}r(Ja,"StatusBadge$5");function wbe({status:e}){const s=qEe[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:jbe(s),children:n.replace(/_/g," ")})}r(wbe,"AgentStatusBadge");function Up({status:e,externalConversationState:s}){const n=e==="in_review"&&s==="waiting"?"idle":e,a=DEe[n]??"--status-task-backlog";return(0,t.jsxs)("span",{className:W("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:jbe(a),children:[(0,t.jsx)(o_,{status:n,size:"sm"}),net(n)]})}r(Up,"IssueStatusBadge");var mZ={company:"Organization",team:"Team",agent:"Agent",task:"Task"};function Nbe(){const{newGoalOpen:e,newGoalDefaults:s,closeNewGoal:n}=c_(),{selectedCompanyId:a,selectedCompany:i}=ps(),o=Ut(),[l,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(""),[h,p]=(0,m.useState)("planned"),[f,g]=(0,m.useState)("task"),[v,y]=(0,m.useState)(""),[w,k]=(0,m.useState)(!1),[j,N]=(0,m.useState)(!1),[_,I]=(0,m.useState)(!1),[C,T]=(0,m.useState)(!1),R=(0,m.useRef)(null),A=v||s.parentId||"",{data:L}=J({queryKey:P.goals.list(a),queryFn:r(()=>Tx.list(a),"queryFn"),enabled:!!a&&e}),D=Ne({mutationFn:r(z=>Tx.create(a,z),"mutationFn"),onSuccess:r(()=>{o.invalidateQueries({queryKey:P.goals.list(a)}),E(),n()},"onSuccess")}),O=Ne({mutationFn:r(async z=>{if(!a)throw new Error("No organization selected");return P0.uploadImage(a,z,"goals/drafts")},"mutationFn")});function E(){c(""),u(""),p("planned"),g("task"),y(""),k(!1)}r(E,"reset");function q(){!a||!l.trim()||D.mutate({title:l.trim(),description:d.trim()||void 0,status:h,level:f,...A?{parentId:A}:{}})}r(q,"handleSubmit");function B(z){z.key==="Enter"&&(z.metaKey||z.ctrlKey)&&(z.preventDefault(),q())}r(B,"handleKeyDown");const U=(L??[]).find(z=>z.id===A);return(0,t.jsx)(Qs,{open:e,onOpenChange:r(z=>{z||(E(),n())},"onOpenChange"),children:(0,t.jsxs)(Xs,{showCloseButton:!1,className:W("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(()=>k(!w),"onClick"),children:w?(0,t.jsx)(uK,{className:"h-3.5 w-3.5"}):(0,t.jsx)(A0,{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(z=>c(z.target.value),"onChange"),onKeyDown:r(z=>{z.key==="Tab"&&!z.shiftKey&&(z.preventDefault(),R.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)(Ic,{ref:R,value:d,onChange:u,placeholder:"Add description...",bordered:!1,contentClassName:W("text-sm text-muted-foreground",w?"min-h-(--sz-220px)":"min-h-(--sz-120px)"),imageUploadHandler:r(async z=>(await O.mutateAsync(z)).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)(tr,{open:j,onOpenChange:N,children:[(0,t.jsx)(pr,{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)(Ja,{status:h})})}),(0,t.jsx)(Qn,{className:"w-40 p-1",align:"start",children:Xde.map(z=>(0,t.jsx)("button",{className:W("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 capitalize",z===h&&"bg-accent"),onClick:r(()=>{p(z),N(!1)},"onClick"),children:z},z))})]}),(0,t.jsxs)(tr,{open:_,onOpenChange:I,children:[(0,t.jsx)(pr,{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)(bl,{className:"h-3 w-3 text-muted-foreground"}),mZ[f]??f]})}),(0,t.jsx)(Qn,{className:"w-40 p-1",align:"start",children:Yde.map(z=>(0,t.jsx)("button",{className:W("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",z===f&&"bg-accent"),onClick:r(()=>{g(z),I(!1)},"onClick"),children:mZ[z]??z},z))})]}),(0,t.jsxs)(tr,{open:C,onOpenChange:T,children:[(0,t.jsx)(pr,{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)(vf,{className:"h-3 w-3 text-muted-foreground"}),U?U.title:"Parent goal"]})}),(0,t.jsxs)(Qn,{className:"w-48 p-1",align:"start",children:[(0,t.jsx)("button",{className:W("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50",!A&&"bg-accent"),onClick:r(()=>{y(""),T(!1)},"onClick"),children:"No parent"}),(L??[]).map(z=>(0,t.jsx)("button",{className:W("flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-accent/50 truncate",z.id===A&&"bg-accent"),onClick:r(()=>{y(z.id),T(!1)},"onClick"),children:z.title},z.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()||D.isPending,onClick:q,children:D.isPending?"Creating…":s.parentId?"Create sub-goal":"Create goal"})})]})})}r(Nbe,"NewGoalDialog");function ret(e){const s=aet(e),n=iet(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(ret,"buildAgentOnboardingPrompt");function aet(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(aet,"buildCandidateOnboardingUrls");function iet(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(iet,"buildResolutionTestUrl");function oet({companyId:e,onClose:s,onBack:n}){const a=Ut(),i=(0,m.useRef)(!0);(0,m.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]);const[o,l]=(0,m.useState)(""),[c,d]=(0,m.useState)(null),[u,h]=(0,m.useState)(!1),[p,f]=(0,m.useState)(!1);async function g(y){try{await Xr(y),i.current&&(h(!0),f(!1))}catch{i.current&&f(!0)}}r(g,"copy");const v=Ne({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`,k=new URL(w,window.location.origin).href,j=await ur.getInviteOnboarding(y.token).catch(()=>null);return ret({onboardingTextUrl:k,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)(Qs,{open:!0,onOpenChange:r(y=>{y||s()},"onOpenChange"),children:(0,t.jsxs)(Xs,{className:"max-h-(--sz-calc-16) overflow-y-auto sm:max-w-2xl",children:[(0,t.jsx)(en,{children:c?"Agent onboarding prompt":"Invite an external agent"}),(0,t.jsx)(Ln,{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)(_n,{"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:u?"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)(_n,{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(oet,"ExternalAgentInviteDialog");function kbe(){const{newAgentOpen:e,closeNewAgent:s}=c_(),{selectedCompanyId:n}=ps();return e?(0,t.jsx)(cet,{companyId:n,onClose:s},n):null}r(kbe,"NewAgentDialog");function cet({companyId:e,onClose:s}){const n=Xn(),[a,i]=(0,m.useState)(!1);return a&&e?(0,t.jsx)(oet,{companyId:e,onClose:s,onBack:r(()=>i(!1),"onBack")}):(0,t.jsx)(abe,{open:!0,onClose:s,onInvite:e?()=>i(!0):void 0,onContinue:r(o=>{s(),n(`/agents/new?${new URLSearchParams(o)}`)},"onContinue")})}r(cet,"NewAgentDialogContent");var det=[{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 hZ({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(hZ,"KeyCap");function uet(){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"divide-y divide-border border-t border-border",children:det.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)(hZ,{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)(hZ,{children:"Esc"})," to close · Shortcuts are disabled in text fields"]})})]})}r(uet,"KeyboardShortcutsCheatsheetContent");function Sbe({open:e,onOpenChange:s}){return(0,t.jsx)(Qs,{open:e,onOpenChange:s,children:(0,t.jsxs)(Xs,{className:"sm:max-w-md gap-0 p-0 overflow-hidden",showCloseButton:!1,children:[(0,t.jsx)(kn,{className:"px-5 pt-5 pb-3",children:(0,t.jsx)(en,{className:"text-base",children:"Keyboard shortcuts"})}),(0,t.jsx)(uet,{})]})})}r(Sbe,"KeyboardShortcutsCheatsheet");var met={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"},het={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 pet({toast:e,onDismiss:s}){const[n,a]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{const i=requestAnimationFrame(()=>a(!0));return()=>cancelAnimationFrame(i)},[]),(0,t.jsx)("li",{className:W("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",met[e.tone]),children:(0,t.jsxs)("div",{className:"flex items-start gap-3 px-3 py-2.5",children:[(0,t.jsx)("span",{className:W("mt-1 h-2 w-2 shrink-0 rounded-full",het[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)(Qe,{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)(sr,{className:"h-3.5 w-3.5"})})]})})}r(pet,"AnimatedToast");function Cbe(){const e=Hhe(),{dismissToast:s}=fa();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)(pet,{toast:n,onDismiss:s},n.id))})})}r(Cbe,"ToastViewport");async function pZ(e,s){const n=await fetch(`/api/announcements/${e}`,{credentials:"same-origin",cache:"no-store",...s});if(!n.ok)throw new cn("Announcement request failed",n.status,null);return n}r(pZ,"request");var fZ={async current(e){const s=await(await pZ("current",{signal:e})).json();return s===null?null:wRe.parse(s)},async dismiss(e,s,n){await pZ(`${encodeURIComponent(e)}/dismiss`,{method:"POST",signal:n,headers:{"Content-Type":"application/json"},body:JSON.stringify({companyId:s})})}},c6=new Map;function t7(e){return`paperclip.announcement-dismissals.v1:${encodeURIComponent(e)}:`}r(t7,"announcementStoragePrefix");function gA(e){const s=t7(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);tue.safeParse(o).success&&(l==="pending"||l==="synced")&&c6.set(i,l==="pending")}}catch{}for(const[a,i]of c6)a.startsWith(s)&&n.set(a.slice(s.length),i);return n}r(gA,"readAnnouncementDismissals");function tD(e,s,n){const a=`${t7(e)}${s}`;c6.set(a,n);try{return localStorage.setItem(a,n?"pending":"synced"),!0}catch{return!1}}r(tD,"saveAnnouncementDismissal");var fet=3e3;function xet(e){const{userId:s,enabled:n}=e,a=(0,m.useRef)(e);a.current=e;const[i,o]=(0,m.useState)(null),l=(0,m.useRef)(()=>{});(0,m.useEffect)(()=>{if(o(null),!s||!n)return;let d=!1,u=0,h=null,p;const f=new Map,g=new Set,v=t7(s);let y=null;try{y=new BroadcastChannel(v)}catch{}const w=r(()=>!d&&a.current.userId===s&&a.current.enabled,"active");async function k(A,L=!0){if(!w()||f.has(A)||!a.current.companyId)return;const D=new AbortController;f.set(A,D);const O=setTimeout(()=>D.abort(),1e4);try{await fZ.dismiss(A,a.current.companyId,D.signal),w()&&tD(s,A,!1)}catch{w()&&!g.has(A)&&(g.add(A),a.current.onSaveFailure(L))}finally{clearTimeout(O),f.delete(A)}}r(k,"sync");async function j(){for(const[A,L]of gA(s)){if(!w())return;L&&await k(A)}}r(j,"flush");function N(){u++,clearTimeout(p),h?.abort(),h=null,o(null)}r(N,"suspend");function _(){if(!w()||document.visibilityState==="hidden")return;N();const A=u,L=new AbortController;h=L;const D=r(()=>w()&&u===A&&!L.signal.aborted,"stillCurrent");let O=!1,E=!1,q=null;const B=r(()=>{!D()||!O||!E||q&&!gA(s).has(q.id)&&(!q.expiresAt||Date.parse(q.expiresAt)>Date.now())&&o({userId:s,announcement:q})},"show");p=setTimeout(()=>{O=!0,B()},fet),j(),fZ.current(L.signal).then(U=>{q=U,E=!0,B()}).catch(()=>{})}r(_,"resume");function I(){const A=gA(s);o(L=>L?.userId===s&&A.has(L.announcement.id)?null:L)}r(I,"receive");function C(A){A.key?.startsWith(v)&&I()}r(C,"onStorage");function T(){document.visibilityState==="hidden"?N():_()}r(T,"onVisibility");function R(){j()}return r(R,"onOnline"),y&&(y.onmessage=A=>{const L=tue.safeParse(A.data);L.success&&(gA(s).has(L.data)||tD(s,L.data,!0),I())}),l.current=A=>{if(!w())return;const L=tD(s,A,!0);o(null),u++,h?.abort();try{y?.postMessage(A)}catch{}k(A,L)},document.addEventListener("visibilitychange",T),window.addEventListener("online",R),window.addEventListener("storage",C),_(),()=>{d=!0,u++,clearTimeout(p),h?.abort();for(const A of f.values())A.abort();y?.close(),document.removeEventListener("visibilitychange",T),window.removeEventListener("online",R),window.removeEventListener("storage",C),l.current=()=>{}}},[s,n]);const c=n&&i?.userId===s?i.announcement:null;return(0,m.useEffect)(()=>{if(!c?.expiresAt)return;let d;const u=r(()=>{const h=Date.parse(c.expiresAt)-Date.now();h<=0?o(null):d=setTimeout(u,Math.min(h,2147483647))},"check");return u(),()=>clearTimeout(d)},[c]),{announcement:c,dismiss:(0,m.useCallback)(d=>l.current(d),[])}}r(xet,"useAnnouncement");function get(e,s){const n=TEe(),a=s??`/api/announcements/${encodeURIComponent(e.id)}/animation`,i=`${a}:${e.animation?.path??""}`,[o,l]=(0,m.useState)(null),c=!!e.animation&&!n;return(0,m.useEffect)(()=>{if(!c)return;const d=new AbortController,u=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="${uTe}">${p}`})}catch{}finally{clearTimeout(u)}})(),()=>{d.abort(),clearTimeout(u)}},[c,i,a]),c&&o?.key===i?o.document:null}r(get,"useAnnouncementAnimation");function xZ({action:e,primary:s,onClick:n}){const a=(0,t.jsxs)(t.Fragment,{children:[e.label,!s&&e.kind==="external"&&(0,t.jsx)(to,{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)(Qe,{to:e.path,onClick:n,onAuxClick:i,children:a})})}r(xZ,"Action");function DT({announcement:e,onDismiss:s,imageSrc:n,animationSrc:a,className:i}){const o=(0,m.useId)(),[l,c]=(0,m.useState)(null),d=n??`/api/announcements/${encodeURIComponent(e.id)}/image`,u=!!(e.image&&l!==d),h=get(e,a),p=!!h;return(0,t.jsxs)(Js,{role:"region","aria-labelledby":o,className:W("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:[(u||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:[u&&(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)(sr,{className:"size-4","aria-hidden":"true"})}),(0,t.jsxs)("div",{className:W("flex flex-col gap-1 px-4 py-4",!u&&!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)(xZ,{action:e.secondaryLink,onClick:s}),(0,t.jsx)("div",{className:"ml-auto min-w-0 max-w-full",children:(0,t.jsx)(xZ,{action:e.primaryAction,primary:!0,onClick:s})})]})]})}r(DT,"AnnouncementCard");var bet='[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"], [aria-modal="true"]:not([data-state="closed"]), dialog[open]';function vet(e){const[s,n]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(!e)return;const a=r(()=>n(!!document.querySelector(bet)),"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(vet,"useModalOpen");function yet({health:e}){const{userId:s,settled:n}=m3(),{selectedCompanyId:a,loading:i}=ps(),{onboardingOpen:o}=_3(),l=Rc(),c=hFe(),d=e?.deploymentMode==="local_trusted"?"local-board":n?s:null,{announcement:u,dismiss:h}=xet({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=vet(!!u);return!u||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)(DT,{announcement:u,onDismiss:r(()=>h(u.id),"onDismiss")},u.id)})}r(yet,"AnnouncementWell");function gP(e){const s=e.split("/").filter(Boolean);return s.length===1?s[0]?.toLowerCase()==="onboarding":s.length===2?s[1]?.toLowerCase()==="onboarding":!1}r(gP,"isOnboardingPath");function jet(e){const s=e.split("/").filter(Boolean);if(s.length===2&&s[1]?.toLowerCase()==="onboarding")return s[0]}r(jet,"companyPrefixFromOnboardingPath");function U5(){return 3}r(U5,"onboardingStepForCompany");function wet(e){const{pathname:s,companyPrefix:n,companies:a,cloudManaged:i}=e;if(!gP(s))return null;const o=r(()=>a.length===1?{initialStep:U5(),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:U5(),companyId:l.id}:i?o():{initialStep:1}}r(wet,"resolveRouteOnboardingOptions");function Net(e){return!e.agentsLoaded||e.agentsRefreshing||e.agentCount>0?!1:!gP(e.pathname)}r(Net,"shouldRouteAgentlessCompanyToOnboarding");function ket(e){return e.currentStep>1&&e.currentStep>e.entryStep}r(ket,"canGoBackFromOnboardingStep");function gZ(e){return e.targetStep<e.currentStep&&e.targetStep>=e.entryStep}r(gZ,"canJumpToOnboardingStep");function s7(e){return!e.hasCompanies&&!gP(e.pathname)}r(s7,"shouldRedirectCompanylessRouteToOnboarding");function Cet(e){return e.onboardingOpen||!e.routeDismissed}r(Cet,"isOnboardingWizardActive");function _et({context:e}){const{slots:s,errorMessage:n}=ed({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)(Su,{slot:a,context:e,className:"plugin-app-shell-overlay"},`${a.pluginId}:${a.pluginVersion}:${a.id}`))})}r(_et,"AppShellEntries");function _be({localTrusted:e=!1}){const{userId:s,settled:n}=m3(),{selectedCompanyId:a,selectedCompany:i,loading:o}=ps(),{onboardingOpen:l,onboardingRouteDismissed:c}=_3(),{pathname:d}=ra(),u=n?s??(e?"local-board":null):null,h=l||!c&&gP(d);if(!u||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)(_et,{context:p},JSON.stringify([u,a]))}r(_be,"PluginAppShellOverlays");function Ibe({visible:e}){const s=ra(),{selectedCompanyId:n}=ps(),{openNewIssue:a}=zo(),i=BK(n),o=(0,m.useMemo)(()=>[{type:"link",to:"/dashboard",label:"Home",icon:dhe},{type:"link",to:"/issues",label:"Tasks",icon:ca},{type:"action",label:"New Task",icon:b_,onClick:r(()=>a(),"onClick")},{type:"link",to:"/agents/all",label:"Agents",icon:al},{type:"link",to:"/inbox",label:"Inbox",icon:gd,badge:i.inbox}],[a,i.inbox]);return(0,t.jsx)("nav",{className:W("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,u=/\/issues\/new(?:\/|$)/.test(s.pathname);return(0,t.jsxs)("button",{type:"button",onClick:l.onClick,className:W("relative flex min-w-0 flex-col items-center justify-center gap-1 rounded-md text-(length:--text-nano) font-medium transition-colors",u?"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)(I0,{to:l.to,state:Af,className:r(({isActive:d})=>W("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:W("h-(--sz-18px) w-(--sz-18px)",d&&"stroke-(length:--sw-2_3)")}),l.badge!=null&&l.badge>0&&(0,t.jsx)(ot,{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(Ibe,"MobileBottomNav");function Qj(e){if(typeof document>"u")return null;const s=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content")?.trim();return s||null}r(Qj,"readMetaContent");function d6(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(d6,"normalizeHexColor");function Iet(e){const s=d6(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(Iet,"hexToRgb");function sD(e){const s=e/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4}r(sD,"relativeLuminanceChannel");function Aet(e){const{r:s,g:n,b:a}=Iet(e),i=.2126*sD(s)+.7152*sD(n)+.0722*sD(a);return 1.05/(i+.05)>=(i+.05)/.05?nEe:eEe}r(Aet,"pickReadableTextColor");function Tet(){return Qj("paperclip-worktree-enabled")==="true"}r(Tet,"isWorktreeRuntime");function Ret(){return Qj("paperclip-instance-id")}r(Ret,"getWorktreeInstanceId");function Eet(){if(Qj("paperclip-worktree-enabled")!=="true")return null;const e=Qj("paperclip-worktree-name"),s=d6(Qj("paperclip-worktree-color"));return!e||!s?null:{enabled:!0,name:e,color:s,textColor:d6(Qj("paperclip-worktree-text-color"))??Aet(s)}}r(Eet,"getWorktreeUiBranding");function Abe(){const e=Eet(),{copied:s,failed:n,copy:a}=Sf(),i=(0,m.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(Abe,"WorktreeBanner");var Pet=3e4;function Met(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(Met,"formatRelativeTimestamp");function Let(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(Let,"describeReason");function Tbe({devServer:e}){const[s,n]=(0,m.useState)(!1);if((0,m.useEffect)(()=>{if(!s)return;const d=window.setTimeout(()=>{n(!1)},Pet);return()=>window.clearTimeout(d)},[s]),!e?.enabled||!e.restartRequired)return null;const a=e,i=Met(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 cm.requestDevServerRestart()}catch(u){n(!1),window.alert(u instanceof Error?u.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)(_s,{className:"h-3.5 w-3.5 shrink-0"}),(0,t.jsx)("span",{children:"Restart Required"}),e.autoRestartEnabled?(0,t.jsx)(ot,{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:[Let(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)(JLe,{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)(_i,{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)(_i,{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)(_i,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{children:s?"Restart requested":"Restart now"})]})]})]})})}r(Tbe,"DevRestartBanner");var Rbe=["standalone","fullscreen","window-controls-overlay"];function Det(e){return`(display-mode: ${e})`}r(Det,"displayModeQuery");function $et(){if(!(typeof window>"u"||typeof window.matchMedia!="function"))return window.matchMedia.bind(window)}r($et,"defaultMatchMedia");function u6(e=$et(),s=typeof navigator>"u"?void 0:navigator.standalone){return s===!0?!0:e?Rbe.some(n=>e(Det(n)).matches):!1}r(u6,"isChromelessDisplayMode");function bA({label:e,children:s,onClick:n}){return(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{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)(Vn,{children:e})]})}r(bA,"ControlButton");function Oet(e=typeof window>"u"?null:window.history.state){const s=e?.idx;return typeof s=="number"&&s>0}r(Oet,"hasInAppHistory");function Fet(){const[e,s]=(0,m.useState)(()=>typeof window<"u"?u6():!1);return(0,m.useEffect)(()=>{if(typeof window>"u")return;const n=r(()=>s(u6()),"update");if(n(),typeof window.matchMedia!="function")return;const a=Rbe.map(i=>window.matchMedia(`(display-mode: ${i})`));return a.every(i=>typeof i.addEventListener=="function")?(a.forEach(i=>i.addEventListener("change",n)),()=>a.forEach(i=>i.removeEventListener("change",n))):(a.forEach(i=>i.addListener(n)),()=>a.forEach(i=>i.removeListener(n)))},[]),e}r(Fet,"useChromeless");function m6({mobile:e,onNavigateHome:s}){const n=Fet(),a=Rc(),i=(0,m.useCallback)(()=>{if(Oet()){window.history.back();return}s?s():window.location.assign("/dashboard")},[s]),o=(0,m.useCallback)(()=>{window.location.reload()},[]),l=(0,m.useCallback)(async()=>{const d=window.location.href;try{if(navigator.share){await navigator.share({title:document.title||"Paperclip",url:d});return}await Xr(d),a?.pushToast({title:"Link copied",tone:"success"})}catch(u){if(u instanceof DOMException&&u.name==="AbortError")return;a?.pushToast({title:"Share failed",body:"Try opening the page in your browser.",tone:"error"})}},[a]),c=(0,m.useCallback)(()=>{window.open(window.location.href,"_blank","noopener,noreferrer")},[]);return n?(0,t.jsxs)("div",{className:W("flex items-center gap-1",e?"h-10 border-b border-border bg-background/95 px-3 backdrop-blur supports-[backdrop-filter]:bg-background/85":"h-9 border-b border-border px-2"),children:[(0,t.jsx)(bA,{label:"Back",onClick:i,children:(0,t.jsx)(vl,{className:"h-4 w-4"})}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsx)(bA,{label:"Refresh",onClick:o,children:(0,t.jsx)(Bi,{className:"h-4 w-4"})}),(0,t.jsx)(bA,{label:"Share",onClick:l,children:(0,t.jsx)(She,{className:"h-4 w-4"})}),(0,t.jsx)(bA,{label:"Open in Browser",onClick:c,children:(0,t.jsx)(gr,{className:"h-4 w-4"})})]}):null}r(m6,"StandaloneBrowserControls");var Bet=16384,qet=40;function zet(e){if(!e)return;const s=[];for(const n of e.slice(0,Bet).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===qet)break}return s.length?`
|
|
335
335
|
${s.join(`
|
|
336
|
-
`)}`:void 0}r(zet,"sanitizeComponentStack");function Uet(e){const s=zet(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(Uet,"buildBrowserErrorContext");var bZ=Promise.resolve();function n7(e){const s=bZ.then(e);return bZ=s.catch(()=>{}),s}r(n7,"enqueue");var cN=null;function Ket(e,s){return n7(async()=>{if(!cN)try{const n=await Sc(()=>import("./prod-COP_vZWu.js"),__vite__mapDeps([4,5]));n.init(Vet(e,s)),cN=n}catch{}})}r(Ket,"initBrowserErrorMonitoring");function Wet(){return n7(async()=>{const e=cN;if(cN=null,!e)return;const s=e.getClient();try{e.getCurrentScope().setClient(void 0)}catch{}try{await s?.close(2e3)}catch{}})}r(Wet,"teardownBrowserErrorMonitoring");function Ebe(e,s){let n;try{s&&(n=Uet(s))}catch{}n7(async()=>{try{n?cN?.captureException(e,n):cN?.captureException(e)}catch{}})}r(Ebe,"captureBrowserException");function Vet(e,s){return{dsn:e,environment:s??void 0,release:"ad7c37a4ddff686aa61b3ad54ebaf40edb80a498",tracesSampleRate:0,sendDefaultPii:!1,integrations:r(n=>n.filter(a=>a.name!=="HttpContext"&&a.name!=="Breadcrumbs"),"integrations")}}r(Vet,"buildBrowserSentryInitOptions");var Het=class extends m.Component{static{r(this,"RouteErrorBoundaryInner")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,s){Ebe(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 Pbe({children:e}){const s=ra(),n=Xn(),a=`${s.pathname}${s.search}`;return(0,t.jsx)(Het,{resetKey:a,onReset:r(()=>n(-1),"onReset"),children:e})}r(Pbe,"RouteErrorBoundary");var vA=240,h6=208,p6=420,vZ=16;function K5(e){return Math.min(p6,Math.max(h6,e))}r(K5,"clampSidebarWidth$1");function yZ(e){if(typeof window>"u")return vA;try{const s=window.localStorage.getItem(e);if(!s)return vA;const n=Number.parseInt(s,10);return Number.isFinite(n)?K5(n):vA}catch{return vA}}r(yZ,"readStoredSidebarWidth$1");function jZ(e,s){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(K5(s)))}catch{}}r(jZ,"writeStoredSidebarWidth$1");function Get({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:u,onPanelBlurCapture:h}){const[p,f]=(0,m.useState)(()=>yZ(o)),[g,v]=(0,m.useState)(!1),y=(0,m.useRef)(p),w=(0,m.useRef)(null);(0,m.useEffect)(()=>{const E=yZ(o);y.current=E,f(E)},[o]);const k=s?p:0,j=s?n?64:k:0,N=s?n&&!a?64:k:0,_=N>j,I=i&&s&&!n,C=(0,m.useMemo)(()=>({width:`${j}px`}),[j]),T=(0,m.useMemo)(()=>({width:`${N}px`}),[N]),R=(0,m.useCallback)(E=>{const q=K5(E);y.current=q,f(q),jZ(o,q)},[o]),A=(0,m.useCallback)(E=>{I&&(E.preventDefault(),E.currentTarget.setPointerCapture(E.pointerId),w.current={startX:E.clientX,startWidth:y.current},v(!0))},[I]),L=(0,m.useCallback)(E=>{if(!w.current)return;const q=K5(w.current.startWidth+E.clientX-w.current.startX);y.current=q,f(q)},[]),D=(0,m.useCallback)(()=>{w.current&&(w.current=null,v(!1),jZ(o,y.current))},[o]),O=(0,m.useCallback)(E=>{I&&(E.key==="ArrowLeft"?(E.preventDefault(),R(p-vZ)):E.key==="ArrowRight"?(E.preventDefault(),R(p+vZ)):E.key==="Home"?(E.preventDefault(),R(h6)):E.key==="End"&&(E.preventDefault(),R(p6)))},[I,R,p]);return(0,t.jsxs)("div",{className:W("relative h-full shrink-0",l),style:C,children:[(0,t.jsx)("div",{className:W("absolute inset-y-0 left-0 flex flex-col overflow-hidden",_?"z-30 border-r border-border bg-background shadow-lg":"z-0"),style:T,"data-sidebar-overlay":_?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:u,onBlurCapture:h,children:e}),I?(0,t.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":h6,"aria-valuemax":p6,"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:A,onPointerMove:L,onPointerUp:D,onPointerCancel:D,onLostPointerCapture:D,onKeyDown:O,children:(0,t.jsx)("div",{className:W("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(Get,"SidebarShell$1");function yA({children:e,className:s}){return(0,t.jsx)("div",{"data-secondary-sidebar":"",className:W("h-full w-full min-w-0 overflow-hidden",s),children:(0,t.jsx)(Whe,{children:e})})}r(yA,"SecondarySidebar$1");var Qet="Toggle the app appearance.";function yw({className:e,variant:s="icon",onAfterToggle:n}){const{theme:a,toggleTheme:i}=e3e(),o=a==="dark",l=o?"Switch to light mode":"Switch to dark mode",c=o?Che:vhe;function d(){i(),n?.()}return r(d,"handleClick"),s==="compact-menu-action"?(0,t.jsxs)("button",{type:"button",className:W("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:W("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:Qet})]})]}):(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":l,title:l,className:W("text-muted-foreground",e),children:(0,t.jsx)(c,{})})}r(yw,"ThemeToggle");var h1=null,Mbe=!1,f6=!1,x6=new Set;function W5(){for(const e of x6)e()}r(W5,"emit");function Yet(e=typeof navigator>"u"?"":navigator.userAgent,s=typeof navigator>"u"?0:navigator.maxTouchPoints){return/iPhone|iPad|iPod/i.test(e)?!0:/Macintosh/i.test(e)&&s>1}r(Yet,"isIosSafariLike");function Xet(e=window){const s=r(a=>{a.preventDefault(),h1=a,W5()},"onPrompt"),n=r(()=>{h1=null,Mbe=!0,W5()},"onInstalled");return e.addEventListener("beforeinstallprompt",s),e.addEventListener("appinstalled",n),()=>{e.removeEventListener("beforeinstallprompt",s),e.removeEventListener("appinstalled",n)}}r(Xet,"captureInstallPrompt");function Jet(){return Mbe||u6()?"installed":h1?"prompt":Yet()?"ios-manual":"unavailable"}r(Jet,"installAvailability");async function Zet(){const e=h1;if(!e)return"unavailable";h1=null,W5(),await e.prompt();const{outcome:s}=await e.userChoice;return s}r(Zet,"promptInstall");function g6(e){f6!==e&&(f6=e,W5())}r(g6,"setIosInstallHelpOpen");function ett(){return f6}r(ett,"iosInstallHelpOpen");function ttt(){return(0,m.useSyncExternalStore)(Lbe,ett,()=>!1)}r(ttt,"useIosInstallHelpOpen");function Lbe(e){return x6.add(e),()=>{x6.delete(e)}}r(Lbe,"subscribe");function stt(){return(0,m.useSyncExternalStore)(Lbe,Jet,()=>"unavailable")}r(stt,"useInstallAvailability");var wZ="Install app",ntt="Add Paperclip to your home screen or dock.";function Dbe({variant:e,onAfterAction:s}){const n=stt();if(n==="installed"||n==="unavailable")return null;const a=r(()=>{n==="ios-manual"?g6(!0):Zet(),s?.()},"handleClick");return e==="compact-menu-action"?(0,t.jsxs)("button",{type:"button",className:"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",onClick:a,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(To,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:wZ})]}):(0,t.jsxs)("button",{type:"button",className:"flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-accent/60",onClick:a,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)(To,{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:wZ}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:ntt})]})]})}r(Dbe,"InstallAppMenuAction");function rtt(){const e=ttt();return(0,t.jsx)(Qs,{open:e,onOpenChange:g6,children:(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:"Install Paperclip"}),(0,t.jsx)(Ln,{children:"Add Paperclip to your Home Screen from Safari."})]}),(0,t.jsxs)("ol",{className:"space-y-3 text-sm text-foreground",children:[(0,t.jsxs)(nD,{index:1,icon:(0,t.jsx)(TLe,{className:"size-4"}),children:["Tap ",(0,t.jsx)("strong",{children:"Share"})," in the Safari toolbar."]}),(0,t.jsxs)(nD,{index:2,icon:(0,t.jsx)(zLe,{className:"size-4"}),children:["Choose ",(0,t.jsx)("strong",{children:"Add to Home Screen"}),"."]}),(0,t.jsxs)(nD,{index:3,children:["Keep ",(0,t.jsx)("strong",{children:"Open as Web App"})," on, then tap ",(0,t.jsx)("strong",{children:"Add"}),"."]})]}),(0,t.jsx)(jr,{children:(0,t.jsx)(F,{type:"button",onClick:r(()=>g6(!1),"onClick"),children:"Done"})})]})})}r(rtt,"IosInstallHelpDialog");function nD({index:e,icon:s,children:n}){return(0,t.jsxs)("li",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border border-border text-xs font-semibold text-muted-foreground",children:e}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s?(0,t.jsx)("span",{className:"text-muted-foreground",children:s}):null,(0,t.jsx)("span",{children:n})]})]})}r(nD,"InstallStep");function att(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(att,"formatTimestamp$2");function itt(e){return!!e&&!Number.isNaN(new Date(e).getTime())}r(itt,"isValidTimestamp");function ott(e){return e?.devServer?.lastRestartAt??e?.serverInfo?.processStartedAt??null}r(ott,"restartTimestamp");function ltt(e){const s=e?.serverInfo?.git;return s?.available?`${s.shortSha} · ${s.subject}`:"Commit unavailable"}r(ltt,"commitLabel");function ctt(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(ctt,"localChangesLabel");function rD({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(rD,"ServerInfoRow");function $be(){const e=J({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn")}).data?.enableServerInfoDebugView===!0,s=J({queryKey:P.health,queryFn:r(()=>cm.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=ott(n),l=itt(o),c=i?"Health unavailable":a?"Loading...":att(o),d=i?"Health unavailable":a?"Loading...":ltt(n),u=i?"Health unavailable":a?"Loading...":ctt(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)(rD,{icon:dm,label:"Last restarted",value:c,dateTime:!i&&!a&&l?o:null}),(0,t.jsx)(rD,{icon:oK,label:"Running commit",value:d}),(0,t.jsx)(rD,{icon:CMe,label:"Checkout state",value:u})]})}r($be,"SidebarServerInfo");var dtt="/company/settings/instance/profile",utt="https://docs.paperclip.ing/",mtt="https://paperclip.ing/feedback";function htt(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(htt,"deriveInitials$2");function ptt(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(ptt,"deriveUserSlug$1");function jA({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)(Qe,{to:a,className:o,onClick:n,children:l}):(0,t.jsx)("button",{type:"button",className:o,onClick:n,children:l})}r(jA,"MenuAction$1");function NZ({deploymentMode:e,open:s,onOpenChange:n,forceExpanded:a=!1}){const i=!!td(),[o,l]=(0,m.useState)(!1),{isMobile:c,setSidebarOpen:d,collapsed:u,peeking:h}=Ua(),p=u&&!h&&!a,f=s??o,g=n??l,{data:v}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),y=WN({onSignedOut:_}),w=v?.user.name?.trim()||"Board",k=v?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),j=htt(w),N=`/u/${ptt(v?.user.name,v?.user.email,v?.user.id)}`;function _(){g(!1),c&&d(!1)}r(_,"closeNavigationChrome");function I(){y.mutate()}return r(I,"handleSignOut"),(0,t.jsx)("div",{className:"bg-border/50 px-3 py-2 dark:bg-muted",children:(0,t.jsxs)("div",{className:W("flex items-center gap-0.5",!p&&"px-2"),children:[(0,t.jsxs)(tr,{open:f,onOpenChange:g,children:[(0,t.jsx)(pr,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:W("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)(Xi,{size:"sm",children:[v?.user.image?(0,t.jsx)(Jc,{src:v.user.image,alt:w}):null,(0,t.jsx)(Ji,{children:j})]}),(0,t.jsx)("span",{className:W("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)(Qn,{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)(Xi,{className:"size-9",children:[v?.user.image?(0,t.jsx)(Jc,{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:k})]})]}),(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)(jA,{label:"Settings",icon:zd,href:"/company/settings",onClick:_}),(0,t.jsx)(jA,{label:"View profile",icon:ku,href:N,onClick:_}),(0,t.jsx)(jA,{label:"Edit profile",icon:v_,href:dtt,onClick:_}),(0,t.jsx)(jA,{label:"Documentation",icon:FN,href:utt,external:!0,onClick:r(()=>g(!1),"onClick")}),(0,t.jsx)(yw,{variant:"compact-menu-action",onAfterToggle:r(()=>g(!1),"onAfterToggle")}),(0,t.jsx)(Dbe,{variant:"compact-menu-action",onAfterAction:r(()=>g(!1),"onAfterAction")}),e==="authenticated"?(0,t.jsxs)("button",{type:"button",className:W("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:I,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)(op,{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)($be,{})]})]})]}),!p&&!i?(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)("a",{href:mtt,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)(Vx,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsx)(Vn,{side:"top",children:"Share feedback"})]}):null]})})}r(NZ,"SidebarAccountMenu$1");function Obe({enabled:e=!0,onNewIssue:s,onSearch:n,onToggleSidebar:a,onTogglePanel:i,onShowShortcuts:o,onGoToInbox:l}){(0,m.useEffect)(()=>{if(!e)return;let c=!1,d=null;const u=r(()=>{d!==null&&(window.clearTimeout(d),d=null)},"clearGoChordTimeout"),h=r(()=>{c=!1,u()},"disarmGoChord"),p=r(()=>{c=!0,u(),d=window.setTimeout(()=>{c=!1,d=null},1200)},"armGoChord");function f(y){if(y.defaultPrevented){h();return}if(l){const w=Wue({armed:c,defaultPrevented:y.defaultPrevented,key:y.key,metaKey:y.metaKey,ctrlKey:y.ctrlKey,altKey:y.altKey,target:y.target,hasOpenDialog:Uh()});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(!Z1(y.target)){if(y.key==="/"&&!y.metaKey&&!y.ctrlKey&&!y.altKey){if(Uh())return;y.preventDefault(),q5e()||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(Obe,"useKeyboardShortcuts");var ftt=new Set(["auth","invite","board-claim","cli-auth","docs"]);function Fbe(e){const s=(e.split("?")[0]??"").split("/").filter(Boolean);if(s.length===0)return!0;const[n]=s;return!ftt.has(n)}r(Fbe,"isRememberableCompanyPath");function xtt(e){const s=vv(e.companyPrefix);return e.companies.find(n=>vv(n.issuePrefix)===s)??null}r(xtt,"findCompanyByPrefix");function gtt(e){const s=zU(e.pathname);return s?xtt({companies:e.companies,companyPrefix:s})?.id??null:e.fallbackCompanyId}r(gtt,"getRememberedPathOwnerCompanyId");function btt(e){const s=e.path?p3(e.path):"/dashboard";if(!Fbe(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&&vv(i[1]??"")!==vv(e.companyPrefix))return"/dashboard"}return s}r(btt,"sanitizeRememberedPathForCompany");var Bbe="paperclip.companyPaths";function qbe(){try{const e=localStorage.getItem(Bbe);if(e)return JSON.parse(e)}catch{}return{}}r(qbe,"getCompanyPaths");function vtt(e,s){const n=qbe();n[e]=s,localStorage.setItem(Bbe,JSON.stringify(n))}r(vtt,"saveCompanyPath");function zbe(){const{companies:e,selectedCompanyId:s,selectedCompany:n,selectionSource:a}=ps(),i=ra(),o=Xn(),l=(0,m.useRef)(s),c=(0,m.useMemo)(()=>gtt({companies:e,pathname:i.pathname,fallbackCompanyId:l.current}),[e,i.pathname]),d=i.pathname+i.search;(0,m.useEffect)(()=>{const u=c,h=p3(d);u&&Fbe(h)&&vtt(u,h)},[d,c]),(0,m.useEffect)(()=>{if(s){if(l.current!==null&&s!==l.current&&a!=="route_sync"&&n){const u=qbe(),h=btt({path:u[s],companyPrefix:n.issuePrefix});o(`/${n.issuePrefix}${h}`,{replace:!0})}l.current=s}},[n,s,a,o])}r(zbe,"useCompanyPageMemory");var ytt=24,jtt=8;function Ube(e,s,n){const a=n&&!lfe(e,s).isTaskDetail,i=(0,m.useRef)(0),[o,l]=(0,m.useState)(!0),c=(0,m.useCallback)(d=>{const u=d-i.current;i.current=d,d<=ytt?l(!0):u>jtt?l(!1):u<-8&&l(!0)},[]);return(0,m.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(Ube,"useMobileNavAutoHide");function Kbe(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(Kbe,"resolveArchivedCompanyBounce");function wtt(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(wtt,"resolveCompanyArchiveDeparture");function Wbe(e){const{selectionSource:s,selectedCompanyId:n,routeCompanyId:a}=e;return!(n===a||s==="manual"&&n)}r(Wbe,"shouldSyncCompanySelectionFromRoute");function Ntt(e,s){return e instanceof HTMLElement?!(s instanceof HTMLElement)||!document.contains(s)||s===document.body||s===document.documentElement?!0:!e.contains(s):!1}r(Ntt,"shouldFocusMainContentAfterNavigation");function Vbe(e){if(!(e instanceof HTMLElement))return()=>{};const s=window.requestAnimationFrame(()=>{Ntt(e,document.activeElement)&&e.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(s)}r(Vbe,"scheduleMainContentFocus");function Hbe(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(Hbe,"pinDocumentScrollToZero");function ju({scope:e="global",requestedPrefix:s}){const n=ra(),{setBreadcrumbs:a}=Bn(),{companies:i,selectedCompany:o}=ps();(0,m.useEffect)(()=>{a([{label:"Not Found"}])},[a]);const l=o??i[0]??null,c=l?`/${l.issuePrefix}/dashboard`:"/",d=`${n.pathname}${n.search}${n.hash}`,u=s?.toUpperCase(),h=e==="invalid_company_prefix"?"Organization not found":"Page not found",p=e==="invalid_company_prefix"?`No organization matches prefix "${u??"unknown"}".`:"This route does not exist.";return(0,t.jsx)("div",{className:"mx-auto max-w-2xl py-10",children:(0,t.jsxs)(Js,{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)(_s,{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)(Qe,{to:c,children:[(0,t.jsx)(FR,{className:"mr-1.5 h-4 w-4"}),"Open dashboard"]})}),(0,t.jsx)(F,{variant:"outline",asChild:!0,children:(0,t.jsx)(Qe,{to:"/",children:"Go home"})})]})]})})}r(ju,"NotFoundPage");function ktt(e,s){return ofe(e,s)[0]?.toLowerCase()??null}r(ktt,"getCompanyRouteSegment$1");var Stt=new Set(["browse","connections","connect","chat","vercel-connect","review","attention","gateways","advanced","app"]);function Ctt({sidebarSections:e}){const{sidebarOpen:s,setSidebarOpen:n,toggleSidebar:a,collapsed:i,peeking:o,setPeeking:l,isMobile:c,setForceCollapsed:d}=Ua(),{openNewIssue:u,openOnboarding:h}=zo(),{togglePanelVisible:p}=Ef(),f=Rc()?.pushToast??null,{companies:g,loading:v,selectedCompany:y,selectedCompanyId:w,selectionSource:k,setSelectedCompanyId:j}=ps(),{companyPrefix:N,pluginRoutePath:_,agentId:I,routineId:C}=Ia(),T=Xn(),R=ra(),A=h3(),{enabled:L}=Tc(),D=lfe(R.pathname,N),O=D.builtInContextualSurface==="settings",E=D.companySegments,q=D.isTaskDetail,B=L&&q,U=E[0]?.toLowerCase()==="tools",z=E[0]?.toLowerCase()==="apps",$=z&&E[1]&&!Stt.has(E[1].toLowerCase())?E[1]:null,K=z&&E[1]?.toLowerCase()==="app"&&E[2]?E[2]:null,H=(0,m.useRef)(!1),se=(0,m.useRef)(null),Z=(0,m.useRef)(null),ie=(0,m.useRef)(new zhe),oe=(0,m.useRef)(R.key),Y=Ube(R.pathname,N,c),[ne,de]=(0,m.useState)(!1),ee=(0,m.useMemo)(()=>{if(!N)return null;const ut=N.toUpperCase();return g.find(Dt=>Dt.issuePrefix.toUpperCase()===ut)??null},[g,N]),X=!!N&&!v&&g.length>0&&!ee,Q=(0,m.useMemo)(()=>_?.toLowerCase()??ktt(R.pathname,N),[N,R.pathname,_]),fe=ee?.id??null,te=ee?.issuePrefix??null,{slots:ae}=ed({slotTypes:["page","routeSidebar"],companyId:fe,enabled:!!(fe&&Q)}),le=(0,m.useMemo)(()=>EK(ae,Q),[Q,ae]),ce=(0,m.useMemo)(()=>({companyId:fe,companyPrefix:te}),[fe,te]),he=O?(0,t.jsx)(_qe,{}):!L&&D.builtInContextualSurface==="skills"?(0,t.jsx)(mY,{}):$?(0,t.jsx)(dY,{kind:"connection",connectionId:$}):K?(0,t.jsx)(dY,{kind:"application",applicationId:K}):z||U?(0,t.jsx)(Lqe,{}):le?L?(0,t.jsx)(k_,{surface:`plugin:${le.id}`,title:le.displayName,children:(0,t.jsx)(Su,{slot:le,context:ce,className:"min-h-0 flex-1",missingBehavior:"placeholder"})}):(0,t.jsx)(Su,{slot:le,context:ce,className:"h-full w-full",missingBehavior:"placeholder"}):null,ve=D.builtInContextualSurface==="agent"&&I?(0,t.jsx)(Yqe,{agentRef:I}):L&&D.builtInContextualSurface==="routine"&&C?(0,t.jsx)(eFe,{children:(0,t.jsx)(Zqe,{routineId:C})}):L&&D.builtInContextualSurface==="skills"?(0,t.jsx)(mY,{}):he,pe=ve!=null,xe=L&&pe&&(D.builtInContextualSurface==="skills"||D.builtInContextualSurface==="agent"||D.builtInContextualSurface==="routine"||z||U),_e=L&&pe&&!xe,ge=pe&&(!L||xe),Ie=!L||!pe?null:le&&!D.builtInContextualSurface?`plugin:${le.id}`:D.builtInContextualSurface,Ye=(0,m.useRef)(null),{data:$e}=J({queryKey:P.health,queryFn:r(()=>cm.get(),"queryFn"),retry:!1,refetchInterval:r(ut=>ut.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1}),Xe=J({queryKey:P.instance.generalSettings,queryFn:r(()=>Tr.getGeneral(),"queryFn")}).data?.keyboardShortcuts===!0;(0,m.useLayoutEffect)(()=>(d(!L&&pe),()=>d(!1)),[pe,d,L]),(0,m.useEffect)(()=>{const ut=Ye.current;Ie&&N&&ut&&ut.surface!==Ie&&ut.pathname!==R.pathname&&kqe({surface:Ie,companyPrefix:N,previousPathname:ut.pathname}),Ye.current={pathname:R.pathname,surface:Ie}},[N,Ie,R.pathname]),(0,m.useEffect)(()=>{v||H.current||$e?.deploymentMode!=="authenticated"&&($e?.cloud||g.length===0&&(H.current=!0,h()))},[g,v,h,$e?.cloud,$e?.deploymentMode]),(0,m.useEffect)(()=>{if(!N||v||g.length===0)return;if(!ee){const Dt=(w?g.find(Jt=>Jt.id===w):null)??g[0]??null;Dt&&w!==Dt.id&&j(Dt.id,{source:"route_sync"});return}if(N!==ee.issuePrefix){const Dt=R.pathname.replace(/^\/[^/]+/,"");T(`/${ee.issuePrefix}${Dt}${R.search}`,{replace:!0});return}const ut=Kbe({matchedCompany:ee,selectedCompanyId:w,companies:g});if(ut){f?.({title:`${ee.name} is archived`,body:`Switched to ${ut.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${ee.id}`}),j(ut.id,{source:"route_sync"}),T(`/${ut.issuePrefix}/dashboard`,{replace:!0});return}Wbe({selectionSource:k,selectedCompanyId:w,routeCompanyId:ee.id})&&j(ee.id,{source:"route_sync"})},[N,g,v,ee,R.pathname,R.search,T,f,k,w,j]);const ue=p,Oe=(0,m.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),dt=(0,m.useRef)(null),xt=(0,m.useRef)(!1),Le=(0,m.useRef)(!1),Ge=(0,m.useCallback)(()=>{dt.current!==null&&(window.clearTimeout(dt.current),dt.current=null)},[]),ht=(0,m.useCallback)(()=>{Ge(),dt.current=window.setTimeout(()=>l(!0),50)},[Ge,l]),Ve=(0,m.useCallback)(()=>{Ge(),l(!0)},[Ge,l]),Ke=(0,m.useCallback)(()=>{Ge(),dt.current=window.setTimeout(()=>l(!1),120)},[Ge,l]),gt=(0,m.useCallback)(()=>{xt.current=!0,i&&!Le.current&&ht()},[i,ht]),tt=(0,m.useCallback)(()=>{xt.current=!1,Le.current=!1,Ke()},[Ke]),Se=(0,m.useCallback)(()=>{Le.current||Ve()},[Ve]),ke=(0,m.useCallback)(()=>{xt.current||Ke()},[Ke]);(0,m.useEffect)(()=>Ge,[Ge]);const Je=(0,m.useRef)(i);return(0,m.useEffect)(()=>{i!==Je.current&&(i?(Ge(),l(!1),Le.current=xt.current):Le.current=!1,Je.current=i)},[i,Ge,l]),(0,m.useEffect)(()=>{if(!o)return;const ut=r(Dt=>{Dt.key==="Escape"&&(Ge(),l(!1))},"onKeyDown");return window.addEventListener("keydown",ut),()=>window.removeEventListener("keydown",ut)},[o,Ge,l]),zbe(),Obe({enabled:Xe,onNewIssue:r(()=>u(),"onNewIssue"),onSearch:Oe,onToggleSidebar:a,onTogglePanel:ue,onShowShortcuts:r(()=>de(!0),"onShowShortcuts"),onGoToInbox:r(()=>T("/inbox"),"onGoToInbox")}),(0,m.useEffect)(()=>{if(!c)return;const ut=30,Dt=50,Jt=75;let fs=0,We=0;const He=r(ze=>{const is=ze.touches[0];fs=is.clientX,We=is.clientY},"onTouchStart"),ct=r(ze=>{const is=ze.changedTouches[0],Fe=is.clientX-fs;if(!(Math.abs(is.clientY-We)>Jt)){if(!s&&fs<ut&&Fe>Dt){n(!0);return}s&&Fe<-50&&n(!1)}},"onTouchEnd");return document.addEventListener("touchstart",He,{passive:!0}),document.addEventListener("touchend",ct,{passive:!0}),()=>{document.removeEventListener("touchstart",He),document.removeEventListener("touchend",ct)}},[c,s,n]),(0,m.useEffect)(()=>{const ut=document.body.style.overflow;return document.body.style.overflow=c?"visible":"clip",()=>{document.body.style.overflow=ut}},[c]),(0,m.useEffect)(()=>{if(!c)return Hbe()},[c]),(0,m.useEffect)(()=>{if(typeof document>"u")return;const ut=Z.current;return Vbe(ut)},[R.pathname]),(0,m.useEffect)(()=>{const ut=Z.current;if(!ut)return;const Dt=r(()=>{ie.current.remember(oe.current,ut.scrollTop)},"recordScroll");return ut.addEventListener("scroll",Dt,{passive:!0}),()=>ut.removeEventListener("scroll",Dt)},[]),(0,m.useLayoutEffect)(()=>{const ut=Z.current,Dt=qhe({previousPathname:se.current,pathname:R.pathname,navigationType:A,state:R.state});se.current=R.pathname;const Jt=A==="POP",fs=Jt?ie.current.recall(R.key):0;if(oe.current=R.key,Jt){s5(ut,fs);const We=requestAnimationFrame(()=>s5(ut,fs));return()=>cancelAnimationFrame(We)}Dt&&Uhe(ut)},[R.key,R.pathname,R.state,A]),(0,t.jsx)(Bhe,{children:(0,t.jsx)(Hue,{value:{keyboardShortcutsEnabled:Xe},children:(0,t.jsxs)("div",{className:W("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)(Abe,{}),(0,t.jsx)(Tbe,{devServer:$e?.devServer}),(0,t.jsxs)("div",{className:W("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:W("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:pe?(0,t.jsx)(yA,{children:ve}):(0,t.jsx)(iY,{children:e})})}),(0,t.jsx)(NZ,{deploymentMode:$e?.deploymentMode,forceExpanded:_e})]}):(0,t.jsxs)(Get,{open:s,collapsed:_e?!1:i,peeking:_e?!1:o,resizable:!0,onPanelMouseEnter:_e?void 0:gt,onPanelMouseLeave:_e?void 0:tt,onPanelFocusCapture:!_e&&i?Se:void 0,onPanelBlurCapture:!_e&&i?ke:void 0,children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0",children:_e?(0,t.jsx)(yA,{children:ve}):(0,t.jsx)(iY,{children:e})}),(0,t.jsx)(NZ,{deploymentMode:$e?.deploymentMode,forceExpanded:_e})]}),!c&&ge&&!xe?(0,t.jsx)(yA,{className:"w-60 shrink-0",children:ve}):null,(0,t.jsxs)("div",{className:W("flex min-w-0 flex-col",c?"w-full":"h-full flex-1"),children:[(0,t.jsxs)("div",{className:W(!c&&B&&"hidden",c&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:[(0,t.jsx)(m6,{mobile:c,onNavigateHome:r(()=>T("/dashboard"),"onNavigateHome")}),(0,t.jsx)(pY,{}),c&&O?(0,t.jsx)("div",{className:"border-b border-border px-4 pb-3",children:(0,t.jsx)(ufe,{})}):null]}),(0,t.jsxs)("div",{className:W(c?"block":"flex flex-1 min-h-0",!c&&B&&"streamlined-task-detail-surface"),children:[!c&&xe?(0,t.jsx)(yA,{className:"w-60 shrink-0 bg-background",children:ve}):null,(0,t.jsxs)("div",{className:W(!c&&B?"flex min-w-0 flex-1 flex-col":"contents"),children:[!c&&B?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m6,{mobile:!1,onNavigateHome:r(()=>T("/dashboard"),"onNavigateHome")}),(0,t.jsx)(pY,{taskDetailLayout:!0})]}):null,(0,t.jsx)("main",{id:"main-content",ref:Z,tabIndex:-1,style:c?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:W("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:X?(0,t.jsx)(ju,{scope:"invalid_company_prefix",requestedPrefix:N??y?.issuePrefix}):(0,t.jsx)(Pbe,{children:(0,t.jsx)(_0,{})})})]}),(0,t.jsx)(Nfe,{taskDetailLayout:!c&&B})]})]})]}),c&&(0,t.jsx)(Ibe,{visible:Y}),(0,t.jsx)(Cfe,{}),(0,t.jsx)(Ffe,{}),(0,t.jsx)(ybe,{}),(0,t.jsx)(Nbe,{}),(0,t.jsx)(kbe,{}),(0,t.jsx)(Sbe,{open:ne,onOpenChange:de}),(0,t.jsx)(Cbe,{}),(0,t.jsx)(yet,{health:$e}),(0,t.jsx)(_be,{localTrusted:$e?.deploymentMode==="local_trusted"})]})})})}r(Ctt,"Layout$1");var Gbe=(0,m.createContext)(!1);function _tt({children:e}){return(0,t.jsx)(Gbe.Provider,{value:!0,children:e})}r(_tt,"SidebarNavExpandedProvider");function Itt(){return(0,m.useContext)(Gbe)}r(Itt,"useSidebarNavExpanded");function Qa({to:e,label:s,icon:n,iconNode:a,end:i,className:o,labelClassName:l,badge:c,badgeTone:d="default",badgeLabel:u,textBadge:h,textBadgeTone:p="default",alert:f=!1,liveCount:g,active:v,trailing:y,trailingLabel:w,liveAccessory:k}){const{isMobile:j,setSidebarOpen:N,collapsed:_,peeking:I}=Ua(),C=Itt(),T=_&&!I&&!C,R=c!=null&&c>0,A=g!=null&&g>0,L=A?`${g} live`:R?`${c}${u?` ${u}`:""}`:f?"attention needed":void 0,D=!T||!L&&!w?void 0:`${s}${L?`, ${L}`:""}${w?`, ${w}`:""}`,O=(0,t.jsxs)(I0,{to:e,state:Af,end:i,"aria-label":D,onClick:r(()=>{j&&N(!1)},"onClick"),className:r(({isActive:E})=>W("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"}),T&&!f&&A&&(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)"})]}),T&&!f&&!A&&R&&(0,t.jsx)("span",{className:W("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:T?Qv:W("min-w-0 flex-1 truncate",l),children:s}),!T&&y,!T&&h&&(0,t.jsx)(ot,{variant:"ghost",className:W("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}),!T&&(A||k)&&(0,t.jsxs)("span",{className:"ml-auto flex items-center gap-1.5",children:[k,A&&(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"]})]})]}),!T&&R&&(0,t.jsx)(ot,{variant:"ghost",className:W("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 T?(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)("div",{children:O})}),(0,t.jsx)(Vn,{side:"right",children:s})]}):O}r(Qa,"SidebarNavItem");var Att=3,kZ=12e4,Ttt=[{value:"top",label:"Top"},{value:"alphabetical",label:"Alphabetical"},{value:"recent",label:"Recent"}];function Zy(e,s){const n=e[s];if(!n)return 0;const a=new Date(n).getTime();return Number.isFinite(a)?a:0}r(Zy,"agentTimestamp");function SZ(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=Zy(i,"lastHeartbeatAt")-Zy(a,"lastHeartbeatAt");if(o!==0)return o;const l=Zy(i,"updatedAt")-Zy(a,"updatedAt");if(l!==0)return l;const c=Zy(i,"createdAt")-Zy(a,"createdAt");return c!==0?c:a.name.localeCompare(i.name,void 0,{sensitivity:"base"})}),n)}r(SZ,"sortAgents");var Rtt="opacity-0 transition-opacity group-hover/agent:opacity-100 group-focus-within/agent:opacity-100";function Ett({activeAgentId:e,activeTab:s,agent:n,disabled:a,isMobile:i,leaving:o,onLeaveAgent:l,onPauseResume:c,rail:d,runCount:u,setSidebarOpen:h,builtInStatus:p,starred:f=!1,onToggleStar:g,starPending:v=!1}){const y=_c(n),w=s?`${tm(n)}/${s}`:tm(n),k=`${tm(n)}/configuration`,j=e===y,N=n.status==="paused",_=N&&n.pauseReason==="budget",I=n.orgChainHealth?.status==="invalid_org_chain",C=N?"Resume agent":"Pause agent",T=a||n.status==="pending_approval"||_||N&&I,R=a?"Updating...":_?"Budget paused":N&&I?"Invalid org chain":C,A=p==="needs_setup"||p==="pending_approval",L=[A?`Built-in agent ${p.replace(/_/g," ")}`:null,I?"Invalid reporting chain":null].filter(Boolean).join(", ")||void 0,D=(0,t.jsx)(Qa,{to:w,label:n.name,iconNode:(0,t.jsx)(yr,{agent:n,size:16,className:"shrink-0 h-4 w-4"}),active:j,liveCount:u,labelClassName:A?"min-w-(--sz-4_5rem) flex-initial":void 0,className:W("min-w-0 flex-1",f&&!i?"pr-14":"pr-8"),trailing:A||I?(0,t.jsxs)("span",{className:"ml-1 flex shrink-0 items-center gap-1",children:[A?(0,t.jsx)(mw,{status:p,compact:!0}):null,I?(0,t.jsx)(_s,{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)(j_,{title:"Agent paused by budget"}):void 0});return d?D:(0,t.jsxs)("div",{className:"group/agent relative flex items-center",children:[D,f&&!i&&g?(0,t.jsx)("span",{className:"absolute right-10 top-1/2 -translate-y-1/2",children:(0,t.jsx)(R0,{size:"row",quiet:!0,starred:!0,pending:v,resourceName:n.name,onToggle:r(()=>g(n,!1),"onToggle"),revealClassName:Rtt})}):null,(0,t.jsxs)(ja,{children:[(0,t.jsx)(ya,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:W("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)(Mi,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(wa,{align:"end",className:"w-48",children:[g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(hs,{onClick:r(()=>{v||g(n,!f)},"onClick"),disabled:v,children:[v?(0,t.jsx)(rt,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Kh,{className:W("size-4",f&&"fill-amber-500 text-amber-500")}),(0,t.jsx)("span",{children:f?"Remove from starred":"Star agent"})]}),(0,t.jsx)(mi,{})]}):null,(0,t.jsx)(hs,{asChild:!0,children:(0,t.jsxs)(Qe,{to:k,onClick:r(()=>{i&&h(!1)},"onClick"),children:[(0,t.jsx)(Gl,{className:"size-4"}),(0,t.jsx)("span",{children:"Edit agent"})]})}),(0,t.jsx)(mi,{}),(0,t.jsxs)(hs,{onClick:r(()=>{T||c(n,N?"resume":"pause")},"onClick"),disabled:T,title:_?"Agent was paused by budget limits":void 0,children:[N?(0,t.jsx)(f_,{className:"size-4"}):(0,t.jsx)(xd,{className:"size-4"}),(0,t.jsx)("span",{children:R})]}),(0,t.jsx)(mi,{}),(0,t.jsxs)(hs,{onClick:r(()=>{o||l(n)},"onClick"),disabled:o,children:[o?(0,t.jsx)(rt,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(op,{className:"size-4"}),(0,t.jsx)("span",{children:o?"Leaving...":"Leave agent"})]})]})]})]})}r(Ett,"SidebarAgentItem");function Ptt({streamlined:e=!1}={}){const[s,n]=(0,m.useState)(!0),[a,i]=(0,m.useState)(()=>new Set),[o,l]=(0,m.useState)(0),c=(0,m.useRef)(new Map),d=Ut(),{selectedCompanyId:u}=ps(),{openNewAgent:h}=zo(),{isMobile:p,setSidebarOpen:f,collapsed:g,peeking:v}=Ua(),y=g&&!v,{pushToast:w}=fa(),k=ra(),{data:j}=J({queryKey:P.agents.list(u),queryFn:r(()=>Vt.list(u),"queryFn"),enabled:!!u}),{data:N}=J({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn"),enabled:!!u}),_=N?.enableBuiltInAgents===!0,{data:I}=J({queryKey:P.builtInAgents.list(u),queryFn:r(()=>Ch.list(u),"queryFn"),enabled:!!u&&_}),C=(0,m.useMemo)(()=>{const ge=new Map;if(!_)return ge;for(const Ie of I??[])Ie.agentId&&ge.set(Ie.agentId,Ie.status);return ge},[I,_]),{data:T}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn")}),R=Tf(u),A=Rf(u),L=P.liveRuns(u),D=fo({companyId:u,resourceKey:"live-runs",queryKey:L,enabled:!!u,refetchInterval:!1,leaderOnly:!0}),{data:O,dataUpdatedAt:E}=J({queryKey:L,queryFn:r(()=>Yr.liveRunsForCompany(u),"queryFn"),enabled:D.enabled,refetchInterval:D.refetchInterval});xo(D,O,E);const q=(0,m.useMemo)(()=>{const ge=new Map;for(const Ie of O??[])ge.set(Ie.agentId,(ge.get(Ie.agentId)??0)+1);return ge},[O]),B=(0,m.useMemo)(()=>{const ge=new Set;for(const[Ie,Ye]of q)Ye>0&&ge.add(Ie);return ge},[q]),U=(0,m.useMemo)(()=>(j??[]).filter(ge=>ge.status!=="terminated"&&(!R.isSuccess||Ox(R.data,"agent",ge.id)!=="left")),[j,R.data,R.isSuccess]),z=T?.user?.id??T?.session?.userId??null,$=(0,m.useMemo)(()=>u?Jhe(u,z):null,[z,u]),[K,H]=(0,m.useState)(()=>$?hw($):"top"),{orderedAgents:se}=tpe({agents:U,companyId:u,userId:z}),Z=(0,m.useMemo)(()=>SZ(se,K),[se,K]),ie=(0,m.useMemo)(()=>new Set(Z.map(ge=>ge.id)),[Z]);(0,m.useEffect)(()=>{const ge=Date.now();for(const Ie of B)c.current.set(Ie,ge);for(const Ie of c.current.keys())ie.has(Ie)||c.current.delete(Ie)},[B,ie]);const oe=(0,m.useMemo)(()=>{const ge=Date.now(),Ie=c.current;return Z.filter(Ye=>{if((q.get(Ye.id)??0)>0)return!0;const $e=Ie.get(Ye.id);return $e!==void 0&&ge-$e<=kZ})},[q,o,Z]),Y=oe.length>0,ne=e?Y?oe:Z.slice(0,Att):Z,de=e&&Z.length>0,ee=k.pathname.match(/^\/(?:[^/]+\/)?agents\/([^/]+)(?:\/([^/]+))?/),X=ee?.[1]??null,Q=ee?.[2]??null;(0,m.useEffect)(()=>{if(!$){H("top");return}H(hw($))},[$]),(0,m.useEffect)(()=>{if(!$)return;const ge=r(Ye=>{Ye.key===$&&H(hw($))},"onStorage"),Ie=r(Ye=>{const $e=Ye.detail;!$e||$e.storageKey!==$||H($e.sortMode)},"onCustomEvent");return window.addEventListener("storage",ge),window.addEventListener(VC,Ie),()=>{window.removeEventListener("storage",ge),window.removeEventListener(VC,Ie)}},[$]),(0,m.useEffect)(()=>{if(!e)return;const ge=Date.now();let Ie=null;for(const $e of Z){if((q.get($e.id)??0)>0)continue;const Xe=c.current.get($e.id);if(Xe===void 0)continue;const ue=Xe+kZ;ue<ge||(Ie=Ie===null?ue:Math.min(Ie,ue))}if(Ie===null)return;const Ye=window.setTimeout(()=>{l($e=>$e+1)},Math.max(0,Ie-ge+1));return()=>{window.clearTimeout(Ye)}},[e,Z,q,o]);const fe=(0,m.useCallback)(ge=>{const Ie=ge==="alphabetical"||ge==="recent"?ge:"top";H(Ie),$&&epe($,Ie)},[$]),te=Ne({mutationFn:r(({agent:ge,action:Ie})=>Ie==="pause"?Vt.pause(ge.id,u??void 0):Vt.resume(ge.id,u??void 0),"mutationFn"),onMutate:r(({agent:ge})=>{i(Ie=>{const Ye=new Set(Ie);return Ye.add(ge.id),Ye})},"onMutate"),onSuccess:r(async(ge,{agent:Ie,action:Ye})=>{u&&await Promise.all([d.invalidateQueries({queryKey:P.agents.list(u)}),d.invalidateQueries({queryKey:P.liveRuns(u)}),d.invalidateQueries({queryKey:P.dashboard(u)})]),await Promise.all([d.invalidateQueries({queryKey:P.agents.detail(Ie.id)}),d.invalidateQueries({queryKey:P.agents.detail(_c(Ie))})]),w({title:Ye==="pause"?"Agent paused":"Agent resumed",body:Ie.name,tone:"success"})},"onSuccess"),onError:r((ge,{agent:Ie,action:Ye})=>{w({title:Ye==="pause"?"Could not pause agent":"Could not resume agent",body:ge instanceof Error?ge.message:Ie.name,tone:"error"})},"onError"),onSettled:r((ge,Ie,{agent:Ye})=>{i($e=>{const Xe=new Set($e);return Xe.delete(Ye.id),Xe})},"onSettled")}),ae=(0,m.useCallback)(ge=>A.mutate({resourceType:"agent",resourceId:ge.id,resourceName:ge.name,state:"left"}),[A]),le=(0,m.useCallback)(ge=>A.isPending&&A.variables?.resourceType==="agent"&&A.variables.resourceId===ge.id,[A.isPending,A.variables]),ce=(0,m.useCallback)((ge,Ie)=>A.mutate({resourceType:"agent",resourceId:ge.id,resourceName:ge.name,starred:Ie}),[A]),he=(0,m.useCallback)(ge=>A.isPending&&A.variables?.resourceType==="agent"&&A.variables.resourceId===ge.id&&A.variables.starred!==void 0,[A.isPending,A.variables]),ve=(0,m.useMemo)(()=>new Set(F3(R.data,"agent")),[R.data]),pe=(0,m.useMemo)(()=>SZ(U.filter(ge=>ve.has(ge.id)),"alphabetical"),[U,ve]),xe=(0,m.useMemo)(()=>ne.filter(ge=>!ve.has(ge.id)),[ne,ve]),_e=r((ge,Ie)=>(0,t.jsx)(Ett,{activeAgentId:X,activeTab:Q,agent:ge,disabled:a.has(ge.id),isMobile:p,leaving:le(ge),onLeaveAgent:ae,onPauseResume:r((Ye,$e)=>te.mutate({agent:Ye,action:$e}),"onPauseResume"),rail:y,runCount:q.get(ge.id)??0,setSidebarOpen:f,builtInStatus:C.get(ge.id),starred:Ie||T0(R.data,"agent",ge.id),onToggleStar:ce,starPending:he(ge)},ge.id),"renderAgentRow");return(0,t.jsxs)(Ix,{label:"Agents",collapsible:{open:s,onOpenChange:n},headerAction:{ariaLabel:"New agent",icon:vn,onClick:h},menu:{ariaLabel:"Agents section actions",actions:[{type:"item",label:"Browse agents",icon:al,href:"/agents/all"},{type:"separator"}],radioLabel:"Agent sort",radioChoices:Ttt,radioValue:K,onRadioValueChange:fe},children:[pe.map(ge=>_e(ge,!0)),xe.map(ge=>_e(ge,!1)),de&&(()=>{const ge=(0,t.jsxs)(Qe,{to:"/agents/all",state:Af,"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)(al,{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)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:ge}),(0,t.jsx)(Vn,{side:"right",children:"See all agents"})]}):ge})()]})}r(Ptt,"SidebarAgents");var Mtt="opacity-0 transition-opacity group-hover/starred-project:opacity-100 group-focus-within/starred-project:opacity-100";function Ltt(){const{selectedCompanyId:e}=ps(),{isMobile:s,setSidebarOpen:n,collapsed:a,peeking:i}=Ua(),o=a&&!i,l=ra(),{data:c}=J({queryKey:P.projects.list(e),queryFn:r(()=>pa.list(e),"queryFn"),enabled:!!e}),d=Tf(e),u=Rf(e),h=l.pathname.match(/^\/(?:[^/]+\/)?projects\/([^/]+)/)?.[1]??null,p=(0,m.useMemo)(()=>{if(!d.isSuccess)return[];const y=new Set(F3(d.data,"project"));if(y.size===0)return[];const w=new Map((c??[]).map(k=>[k.id,k]));return Array.from(y).map(k=>w.get(k)).filter(k=>!!k).sort((k,j)=>k.name.localeCompare(j.name,void 0,{sensitivity:"base"}))},[d.data,d.isSuccess,c]),f=(0,m.useCallback)(y=>u.mutate({resourceType:"project",resourceId:y.id,resourceName:y.name,starred:!1}),[u]),g=(0,m.useCallback)(y=>u.mutate({resourceType:"project",resourceId:y.id,resourceName:y.name,state:"left"}),[u]),v=(0,m.useCallback)(y=>u.isPending&&u.variables?.resourceType==="project"&&u.variables.resourceId===y.id,[u.isPending,u.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=S0(y),k=h===w||h===y.id,j=v(y),N=j&&u.variables?.starred===!1,_=j&&u.variables?.state==="left",I=T0(d.data,"project",y.id),C=(0,t.jsxs)(I0,{to:`/projects/${w}/issues`,state:Af,onClick:r(()=>{s&&n(!1)},"onClick"),className:W("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",k?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground"),children:[(0,t.jsx)(nh,{color:y.color??null,icon:y.icon??null,size:"xs"}),(0,t.jsx)("span",{className:o?Qv:"flex-1 truncate",children:y.name}),!o&&y.pauseReason==="budget"?(0,t.jsx)(j_,{title:"Project paused by budget"}):null]});return(0,t.jsxs)("div",{className:"group/starred-project relative flex items-center",children:[o?(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)("div",{className:"min-w-0 flex-1",children:C})}),(0,t.jsx)(Vn,{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)(R0,{size:"row",quiet:!0,starred:I,pending:N,resourceName:y.name,onToggle:r(()=>f(y),"onToggle"),revealClassName:Mtt})}):null,!o&&s?(0,t.jsxs)(ja,{children:[(0,t.jsx)(ya,{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)(Mi,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(wa,{align:"end",className:"w-48",children:[(0,t.jsxs)(hs,{onClick:r(()=>{j||f(y)},"onClick"),disabled:j,children:[N?(0,t.jsx)(rt,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Kh,{className:"size-4 fill-amber-500 text-amber-500"}),(0,t.jsx)("span",{children:"Remove from starred"})]}),(0,t.jsx)(mi,{}),(0,t.jsxs)(hs,{onClick:r(()=>{j||g(y)},"onClick"),disabled:j,children:[_?(0,t.jsx)(rt,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(op,{className:"size-4"}),(0,t.jsx)("span",{children:"Leave project"})]})]})]}):null]},y.id)})})}r(Ltt,"SidebarStarredProjects");var Qbe="size-5 shrink-0 rounded-md text-(length:--text-micro)",Ybe="size-(--organization-popover-avatar-size) shrink-0 rounded-lg text-(length:--text-micro)",Xbe="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",aD="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 Jbe({company:e,inPopover:s=!1}){return(0,t.jsx)(Qx,{companyName:e.name,logoUrl:e.logoUrl,className:s?Ybe:Qbe})}r(Jbe,"WorkspaceIcon");function Dtt({displayName:e}){return(0,t.jsx)(Qx,{companyName:e,className:Ybe})}r(Dtt,"StackIcon");function $tt({displayName:e,company:s}){return(0,t.jsx)(Qx,{companyName:e,logoUrl:s?.logoUrl,className:Qbe})}r($tt,"CurrentStackIcon");function Ott({stack:e,isSelected:s,onSelect:n}){return(0,t.jsxs)(hs,{onSelect:r(()=>n(e),"onSelect"),className:Xbe,children:[(0,t.jsx)(Dtt,{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)(ds,{className:"size-4 text-foreground"}):null})]})}r(Ott,"CloudStackItem");function Ftt({company:e,isEditing:s,isSelected:n,onSelect:a}){const{attributes:i,listeners:o,setActivatorNodeRef:l,setNodeRef:c,transform:d,transition:u,isDragging:h}=MN({id:e.id,disabled:!s});return(0,t.jsxs)(hs,{ref:c,style:{transform:RN.Transform.toString(d),transition:u,zIndex:h?10:void 0},onSelect:r(p=>{if(s){p.preventDefault();return}a(e)},"onSelect"),className:W(Xbe,s&&"cursor-grab",h&&"opacity-80"),children:[(0,t.jsx)(Jbe,{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)(R3,{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)(ds,{className:"size-4 text-foreground"}):null})]})}r(Ftt,"SortableCompanyItem");function Btt(e={}){return(0,t.jsx)(tfe,{...e,children:(0,t.jsx)(qtt,{...e})})}r(Btt,"SidebarCompanyMenu");function qtt({open:e,onOpenChange:s}){const[n,a]=(0,m.useState)(!1),[i,o]=(0,m.useState)(!1),{companies:l,selectedCompany:c,setSelectedCompanyId:d,companyListUnavailable:u,retryCompanies:h}=ps(),{openOnboarding:p}=zo(),{isMobile:f,setSidebarOpen:g,collapsed:v,peeking:y}=Ua(),w=v&&!y,k=ra(),j=Xn(),N=e??n,_=s??a,I=PN(bf(WU,{activationConstraint:{distance:8}}),bf(Gue,{activationConstraint:{delay:180,tolerance:6}})),C=(0,m.useMemo)(()=>l.filter(Q=>Q.status!=="archived"),[l]),{data:T}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),R=T?.user?.id??T?.session?.userId??null,{orderedCompanies:A,persistOrder:L}=Zpe({companies:C,userId:R}),D=td(),O=!!D,{hidden:E,loaded:q}=uh(),B=q&&!OC(E,"company.members")&&!OC(E,"company.invites"),U=D?.cloudBaseUrl??null,z=J({queryKey:P.cloud.stacks,queryFn:r(()=>Xpe.listStacks(),"queryFn"),enabled:O,staleTime:3e4,retry:!1}),$=z.data?.stacks??[],K=O?$.find(Q=>Q.isCurrent)??$.find(Q=>!!D?.stackSlug&&Q.stackSlug===D?.stackSlug)??null:null,H=O?U3(U):null,se=O?"organization":"company",Z=O?K?.displayName??D?.stackDisplayName??D?.stackSlug??null:c?.name??null,ie=WN({onSignedOut:Y});function oe(Q){Q||o(!1),_(Q)}r(oe,"handleOpenChange");function Y(){_(!1),o(!1),f&&g(!1)}r(Y,"closeNavigationChrome");function ne(Q){const fe=k.pathname.split("/")[1]?.toUpperCase(),te=C.some(le=>le.issuePrefix.toUpperCase()===fe),ae=Q.id!==c?.id&&(k.pathname.startsWith("/instance/")||te);d(Q.id),_(!1),f&&g(!1),ae&&j(`/${Q.issuePrefix}/dashboard`)}r(ne,"selectCompany");function de(Q){if(_(!1),f&&g(!1),Q.stackSlug===K?.stackSlug)return;const fe=efe(U,Q.stackSlug);fe&&Ac(fe)}r(de,"selectStack");function ee(){if(_(!1),f&&g(!1),O){H&&Ac(H);return}p({initialStep:1})}r(ee,"addCompany");const X=(0,m.useCallback)(Q=>{const{active:fe,over:te}=Q;if(!te||fe.id===te.id)return;const ae=A.map(he=>he.id),le=ae.indexOf(fe.id),ce=ae.indexOf(te.id);le===-1||ce===-1||L(f3(ae,le,ce))},[A,L]);return(0,t.jsxs)(ja,{open:N,onOpenChange:oe,children:[(0,t.jsx)(ya,{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":Z?`Open ${Z} ${se} switcher`:`Open ${se} switcher`,children:[(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[O?Z?(0,t.jsx)($tt,{displayName:Z,company:c}):null:c?(0,t.jsx)(Jbe,{company:c}):null,(0,t.jsx)("span",{className:W("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:Z??void 0,children:Z??(O?"Select organization":"Select company")})]}),!w&&(0,t.jsx)(S3,{className:"size-3.5 shrink-0 text-muted-foreground"})]})}),(0,t.jsxs)(wa,{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)(DN,{className:"p-0 text-(length:--text-compact) font-semibold text-foreground",children:"Organizations"}),O?null:(0,t.jsx)("button",{type:"button",onClick:r(Q=>{Q.preventDefault(),Q.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:O?(0,t.jsxs)(t.Fragment,{children:[$.map(Q=>(0,t.jsx)(Ott,{stack:Q,isSelected:Q.stackSlug===K?.stackSlug,onSelect:de},Q.stackSlug)),$.length===0?(0,t.jsx)(hs,{disabled:!0,children:z.isLoading?"Loading organizations...":z.isError?"Could not load organizations":"No organizations"}):null]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(TN,{sensors:I,collisionDetection:e_,onDragEnd:X,children:(0,t.jsx)(AN,{items:A.map(Q=>Q.id),strategy:X1,children:A.map(Q=>(0,t.jsx)(Ftt,{company:Q,isEditing:i,isSelected:Q.id===c?.id,onSelect:ne},Q.id))})}),A.length===0?u?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(hs,{disabled:!0,children:"Couldn't load companies"}),(0,t.jsxs)(hs,{onSelect:r(Q=>{Q.preventDefault(),h()},"onSelect"),children:[(0,t.jsx)(Bi,{className:"h-4 w-4 mr-2"}),"Try again"]})]}):(0,t.jsx)(hs,{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:[O&&!H?null:(0,t.jsxs)(hs,{onClick:ee,className:aD,disabled:i,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(vn,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:"Create organization"})]}),B?(0,t.jsx)(hs,{asChild:!0,disabled:i,className:aD,children:(0,t.jsxs)(Qe,{to:"/company/settings/invites",onClick:r(Q=>{if(i){Q.preventDefault();return}Y()},"onClick"),children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(ry,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:Z?`Invite people to ${Z}`:"Invite people"})]})}):null,T?.session?(0,t.jsxs)(hs,{className:aD,onClick:r(()=>ie.mutate(),"onClick"),disabled:i||ie.isPending,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(op,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:ie.isPending?"Signing out...":"Sign out"})]}):null]})]})]})}r(qtt,"BuiltinCompanyMenu");function CZ(){const{openNewIssue:e}=zo(),[s,n]=(0,m.useState)(!0),[a,i]=(0,m.useState)(!0),{selectedCompanyId:o,selectedCompany:l}=ps(),{collapsed:c,peeking:d}=Ua(),u=c&&!d,h=BK(o),{data:p,isFetched:f}=J({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn")}),g=P.liveRuns(o),v=fo({companyId:o,resourceKey:"live-runs",queryKey:g,enabled:!!o,refetchInterval:!1,leaderOnly:!0}),{data:y,dataUpdatedAt:w}=J({queryKey:g,queryFn:r(()=>Yr.liveRunsForCompany(o),"queryFn"),enabled:v.enabled,refetchInterval:v.refetchInterval});xo(v,y,w);const k=y?.length??0,j=p?.enableIsolatedWorkspaces===!0,N=p?.enableApps===!0,_=p?.enablePipelines===!0,I=p?.enableStatusCards===!0,C=!f,T=p?.enableGoalsSidebarLink===!0,R=p?.enableDecisions===!0,{data:A}=J({queryKey:P.attention(o),queryFn:r(()=>zN.list(o),"queryFn"),enabled:!!o&&R,refetchInterval:6e4}),L=Ipe(A),D=p?.enableCases===!0,O=!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)(Btt,{})}),(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":u?"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)(b_,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:u?Qv:"truncate",children:"New Task"})]});return u?(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:B}),(0,t.jsx)(Vn,{side:"right",children:"New Task"})]}):B})(),(0,t.jsx)(Qa,{to:"/search",label:"Search",icon:ha}),(0,t.jsx)(Qa,{to:"/dashboard",label:"Dashboard",icon:_x,liveCount:k}),(0,t.jsx)(Qa,{to:"/inbox",label:"Inbox",icon:gd,badge:h.inbox,badgeLabel:"unread",badgeTone:h.failedRuns>0?"danger":"default",alert:h.failedRuns>0}),R?(0,t.jsx)(Qa,{to:"/decisions",label:"Decisions",icon:g_,badge:L,badgeLabel:"decisions"}):null,I?(0,t.jsx)(Qa,{to:"/status",label:"Status",icon:BN,textBadge:"beta"}):null,E?(0,t.jsx)(Qa,{to:"/board-chat",label:"Conference Room",icon:ghe}):null]}),(0,t.jsxs)(Ix,{label:"Work",collapsible:{open:s,onOpenChange:n},children:[(0,t.jsx)(Qa,{to:"/issues",label:"Tasks",icon:hd}),D?(0,t.jsx)(Qa,{to:"/cases",label:"Cases",icon:bl,textBadge:"beta"}):null,(0,t.jsx)(Qa,{to:"/routines",label:"Routines",icon:yu}),_?(0,t.jsx)(Qa,{to:"/pipelines",label:"Pipelines",icon:Bo}):null,T?(0,t.jsx)(Qa,{to:"/goals",label:"Goals",icon:vf}):C?(0,t.jsx)("div",{"data-testid":"sidebar-goals-placeholder",className:"h-8 pointer-coarse:h-7","aria-hidden":"true"}):null,(0,t.jsx)(Qa,{to:"/artifacts",label:"Artifacts",icon:Wh}),(0,t.jsx)(Qa,{to:"/skills",label:"Skills",icon:Hl}),j?(0,t.jsx)(Qa,{to:"/workspaces",label:"Workspaces",icon:Bo}):null,(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Qa,{to:"/projects",label:"Projects",icon:Ao}),(0,t.jsx)(Ltt,{})]}),(0,t.jsx)(tp,{slotTypes:["sidebar"],context:q,className:"flex flex-col gap-0.5",itemClassName:"text-(length:--text-compact) font-medium",missingBehavior:"placeholder"}),(0,t.jsx)(KN,{placementZones:["sidebar"],context:q,className:"flex flex-col gap-0.5",itemClassName:"text-(length:--text-compact) font-medium"})]}),null,(0,t.jsx)(Ptt,{streamlined:O}),(0,t.jsxs)(Ix,{label:"Company",collapsible:{open:a,onOpenChange:i},children:[(0,t.jsx)(Qa,{to:"/org",label:"Org",icon:wv}),N?(0,t.jsx)(Qa,{to:"/apps",label:"Connectors",icon:e5}):null,(0,t.jsx)(Qa,{to:"/timeline",label:"Timeline",icon:$g}),(0,t.jsx)(Qa,{to:"/costs",label:"Costs",icon:Oh}),(0,t.jsx)(Qa,{to:"/activity",label:"Activity",icon:Tl}),(0,t.jsx)(Qa,{to:"/company/settings",label:"Settings",icon:zd})]}),(0,t.jsx)(tp,{slotTypes:["sidebarPanel"],context:q,className:"flex flex-col gap-3",itemClassName:"rounded-lg border border-border p-3",missingBehavior:"placeholder"})]})]})}r(CZ,"Sidebar");function ztt(e){const s=e.manifestJson.environmentDrivers??[];return s.length===0?!1:s.every(n=>n.kind==="sandbox_provider")}r(ztt,"isSandboxProviderOnly");function Utt(){const{selectedCompany:e,selectedCompanyId:s}=ps(),{isMobile:n,setSidebarOpen:a}=Ua(),{hidden:i}=uh(),o=r(f=>!i.has(f),"showPage"),l=o("instance.plugins"),c=!!td(),{slots:d}=ed({slotTypes:["companySettingsPage"],companyId:s,enabled:!!s}),{data:u}=J({queryKey:s?P.sidebarBadges(s):["sidebar-badges","__disabled__"],queryFn:r(async()=>{try{return await ife.get(s)}catch(f){if(f instanceof cn&&(f.status===401||f.status===403))return null;throw f}},"queryFn"),enabled:!!s,retry:!1,refetchInterval:15e3}),{data:h}=J({queryKey:P.plugins.all,queryFn:r(()=>rl.list(),"queryFn"),enabled:l}),p=(h??[]).filter(f=>!ztt(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)(Qe,{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)(Nu,{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)(Qa,{to:"/company/settings",label:"General",icon:um,end:!0}),o("instance.profile")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/profile",label:"Profile",icon:v_,end:!0}),o("company.members")&&(0,t.jsx)(Qa,{to:"/company/settings/members",label:"Members",icon:al,badge:u?.joinRequests??0,end:!0}),d.filter(f=>f.routePath).map(f=>(0,t.jsx)(Qa,{to:`/company/settings/${f.routePath}`,label:f.displayName,icon:Zg,end:!0},`${f.pluginKey}:${f.id}`)),o("company.invites")&&(0,t.jsx)(Qa,{to:"/company/settings/invites",label:"Invites",icon:k4e,end:!0}),o("company.secrets")&&(0,t.jsx)(Qa,{to:"/company/settings/secrets",label:"Secrets",icon:ji,end:!0}),o("instance.environments")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/environments",label:"Environments",icon:bhe,end:!0}),o("instance.access")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/access",label:"Access",icon:y3,end:!0}),o("instance.heartbeats")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/heartbeats",label:"Heartbeats",icon:dm,end:!0}),o("company.export")&&(0,t.jsx)(Qa,{to:"/company/export",label:"Export",icon:To}),!c&&o("company.import")&&(0,t.jsx)(Qa,{to:"/company/import",label:"Import",icon:Vw,end:!0}),o("instance.experimental")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/experimental",label:"Experimental",icon:om}),l&&(0,t.jsx)(Qa,{to:"/company/settings/instance/plugins",label:"Plugins",icon:Zg}),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)(I0,{to:`${_h}/plugins/${f.id}`,state:Af,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)(Qa,{to:"/company/settings/instance/adapters",label:"Adapters",icon:Vm})]})})]})}r(Utt,"CompanySettingsSidebar");function Ktt(){const{pathname:e}=ra(),{selectedCompany:s}=ps(),{isMobile:n,setSidebarOpen:a}=Ua(),i=pfe(),{enabled:o}=K3(),l=WK.filter(d=>!hfe(d.key)||o);if(e.endsWith("/apps/chat/connect"))return(0,t.jsx)(jK,{});const c=e.match(/\/apps\/chat\/([^/]+)(?:\/(?:settings|access|reviews|conversations|activity|approvals|audit))?\/?$/);return c?(0,t.jsx)(mfe,{endpointId:c[1],NavItem:Qa}):(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)(Qe,{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)(Nu,{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)(lQ,{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)(Qa,{to:"/apps",label:"Browse",icon:KC,end:!0}),(0,t.jsx)(Qa,{to:"/apps/review",label:"Review",icon:qN,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)(Qa,{to:"/apps/connections",label:"Connections",icon:lQ,end:!0}),l.map(d=>(0,t.jsx)(Qa,{to:t0(d.key),label:d.label,icon:d.icon,end:!0},d.key))]})]})]})}r(Ktt,"AppsSidebar");function _Z(e){const{selectedCompanyId:s}=ps(),{isMobile:n,setSidebarOpen:a}=Ua(),i=J({queryKey:P.tools.connection(e.kind==="connection"?e.connectionId:"__none__"),queryFn:r(()=>cs.getConnection(e.kind==="connection"?e.connectionId:""),"queryFn"),enabled:e.kind==="connection"&&!!e.connectionId}),o=J({queryKey:P.tools.applications(s??"__none__"),queryFn:r(()=>cs.listApplications(s),"queryFn"),enabled:e.kind==="application"&&!!s}),l=J({queryKey:P.tools.connections(s??"__none__"),queryFn:r(()=>cs.listConnections(s),"queryFn"),enabled:e.kind==="application"&&!!s}),c=J({queryKey:P.apps.gallery(s??"__none__"),queryFn:r(()=>cs.listGallery(s),"queryFn"),enabled:!!s}),d=J({queryKey:P.apps.attention(s??"__none__"),queryFn:r(()=>cs.listAppsAttention(s),"queryFn"),enabled:!!s,refetchInterval:3e4}),u=i.data,h=e.kind==="application"?(o.data?.applications??[]).find(k=>k.id===e.applicationId):null,p=Htt(e.kind==="application"?(l.data?.connections??[]).filter(k=>k.applicationId===e.applicationId):[]),f=u?wf(u):h?.name??"App",g=Vtt(c.data?.apps??[],u,h??void 0),v=u?.id??p?.id??null,y=v?d.data?.apps.find(k=>k.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)(Qe,{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)(Nu,{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)(Cc,{name:f,logoUrl:S_(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:W3.map(k=>(0,t.jsx)(Qa,{to:Wtt(e,k.key),label:k.label,icon:k.icon,end:!0,badge:k.key==="review"&&w>0?w:void 0,badgeTone:"danger",badgeLabel:"needing review"},k.key))})})]})}r(_Z,"AppDetailSidebar");function Wtt(e,s){return e.kind==="connection"?Yu(e.connectionId,s):oC(e.applicationId,s)}r(Wtt,"tabHref");function Vtt(e,s,n){if(n?.applicationKey){const i=e.find(o=>Vc(o)===n.applicationKey);if(i)return i}const a=(s?.name??n?.name)?.toLowerCase();return a?e.find(i=>b0(i).toLowerCase()===a)??e.find(i=>Vc(i)===a)??null:null}r(Vtt,"galleryEntryFor$1");function Htt(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(Htt,"latestArchivedConnection$1");function iD({identifier:e}){return e?(0,t.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e}):null}r(iD,"CrumbIdentifier");function Gtt({context:e}){const{slots:s}=ed({slotTypes:["globalToolbarButton"],companyId:e.companyId}),{launchers:n}=qK({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)(tp,{slotTypes:["globalToolbarButton"],context:e,className:"flex items-center gap-1"}):null,n.length>0?(0,t.jsx)(KN,{placementZones:["globalToolbarButton"],context:e,className:"flex items-center gap-1"}):null]})}r(Gtt,"GlobalToolbar");function Qtt(){const{breadcrumbs:e,mobileToolbar:s}=Bn(),{toggleSidebar:n,isMobile:a}=Ua(),{selectedCompanyId:i,selectedCompany:o}=ps(),l=(0,m.useMemo)(()=>({companyId:i??null,companyPrefix:o?.issuePrefix??null}),[i,o?.issuePrefix]),c=(0,t.jsx)(Gtt,{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)(phe,{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)(iD,{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)(VK,{className:"min-w-0 overflow-hidden",children:(0,t.jsx)(HK,{className:"flex-nowrap",children:e.map((u,h)=>{const p=h===e.length-1;return(0,t.jsxs)(m.Fragment,{children:[h>0&&(0,t.jsx)(u5,{}),(0,t.jsx)(lC,{className:p?"min-w-0":"shrink-0",children:p||!u.href?u.leading||u.identifier?(0,t.jsxs)(XC,{className:"flex min-w-0 items-center gap-1.5",children:[u.leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:u.leading}),(0,t.jsx)(iD,{identifier:u.identifier}),(0,t.jsx)("span",{className:"truncate",children:u.label})]}):(0,t.jsx)(XC,{className:"truncate",children:u.label}):(0,t.jsx)(d5,{asChild:!0,children:u.leading||u.identifier?(0,t.jsxs)(Qe,{to:u.href,onClick:u.onClick,className:"flex items-center gap-1.5",children:[u.leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:u.leading}),(0,t.jsx)(iD,{identifier:u.identifier}),(0,t.jsx)("span",{className:"truncate",children:u.label})]}):(0,t.jsx)(Qe,{to:u.href,onClick:u.onClick,children:u.label})})})]},h)})})})}),c]})}r(Qtt,"BreadcrumbBar");var wA=240,b6=208,v6=420,IZ=16;function V5(e){return Math.min(v6,Math.max(b6,e))}r(V5,"clampSidebarWidth");function AZ(e){if(typeof window>"u")return wA;try{const s=window.localStorage.getItem(e);if(!s)return wA;const n=Number.parseInt(s,10);return Number.isFinite(n)?V5(n):wA}catch{return wA}}r(AZ,"readStoredSidebarWidth");function TZ(e,s){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(V5(s)))}catch{}}r(TZ,"writeStoredSidebarWidth");function Ytt({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:u,onPanelBlurCapture:h}){const[p,f]=(0,m.useState)(()=>AZ(o)),[g,v]=(0,m.useState)(!1),y=(0,m.useRef)(p),w=(0,m.useRef)(null);(0,m.useEffect)(()=>{const E=AZ(o);y.current=E,f(E)},[o]);const k=s?p:0,j=s?n?64:k:0,N=s?n&&!a?64:k:0,_=N>j,I=i&&s&&!n,C=(0,m.useMemo)(()=>({width:`${j}px`}),[j]),T=(0,m.useMemo)(()=>({width:`${N}px`}),[N]),R=(0,m.useCallback)(E=>{const q=V5(E);y.current=q,f(q),TZ(o,q)},[o]),A=(0,m.useCallback)(E=>{I&&(E.preventDefault(),E.currentTarget.setPointerCapture(E.pointerId),w.current={startX:E.clientX,startWidth:y.current},v(!0))},[I]),L=(0,m.useCallback)(E=>{if(!w.current)return;const q=V5(w.current.startWidth+E.clientX-w.current.startX);y.current=q,f(q)},[]),D=(0,m.useCallback)(()=>{w.current&&(w.current=null,v(!1),TZ(o,y.current))},[o]),O=(0,m.useCallback)(E=>{I&&(E.key==="ArrowLeft"?(E.preventDefault(),R(p-IZ)):E.key==="ArrowRight"?(E.preventDefault(),R(p+IZ)):E.key==="Home"?(E.preventDefault(),R(b6)):E.key==="End"&&(E.preventDefault(),R(v6)))},[I,R,p]);return(0,t.jsx)("div",{className:W("relative h-full shrink-0",l),style:C,children:(0,t.jsxs)("div",{className:W("absolute inset-y-0 left-0 flex flex-col overflow-hidden",_?"z-30 border-r border-border bg-background shadow-lg":"z-0"),style:T,"data-sidebar-overlay":_?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:u,onBlurCapture:h,children:[e,I?(0,t.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":b6,"aria-valuemax":v6,"aria-valuenow":p,tabIndex:0,className:W("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:A,onPointerMove:L,onPointerUp:D,onPointerCancel:D,onLostPointerCapture:D,onKeyDown:O}):null]})})}r(Ytt,"SidebarShell");function Xtt({children:e,className:s}){return(0,t.jsx)("div",{"data-secondary-sidebar":"",className:W("h-full w-60 shrink-0 overflow-y-auto border-r border-border bg-background",s),children:(0,t.jsx)(_tt,{children:e})})}r(Xtt,"SecondarySidebar");var Jtt="/company/settings/instance/profile",Ztt="https://docs.paperclip.ing/",est="https://paperclip.ing/feedback";function tst(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(tst,"deriveInitials$1");function sst(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(sst,"deriveUserSlug");function oD({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)(Qe,{to:i,className:l,onClick:a,children:c}):(0,t.jsx)("button",{type:"button",className:l,onClick:a,children:c})}r(oD,"MenuAction");function RZ({deploymentMode:e,open:s,onOpenChange:n}){const a=!!td(),[i,o]=(0,m.useState)(!1),{isMobile:l,setSidebarOpen:c,collapsed:d,peeking:u}=Ua(),h=d&&!u,p=s??i,f=n??o,{data:g}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),v=WN({onSignedOut:N}),y=g?.user.name?.trim()||"Board",w=g?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),k=tst(y),j=`/u/${sst(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:W("flex items-center gap-0.5",!h&&"px-2"),children:[(0,t.jsxs)(tr,{open:p,onOpenChange:f,children:[(0,t.jsx)(pr,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:W("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)(Xi,{size:"sm",children:[g?.user.image?(0,t.jsx)(Jc,{src:g.user.image,alt:y}):null,(0,t.jsx)(Ji,{children:k})]}),(0,t.jsx)("span",{className:W("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)(Qn,{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)(Xi,{size:"lg",children:[g?.user.image?(0,t.jsx)(Jc,{src:g.user.image,alt:y}):null,(0,t.jsx)(Ji,{children:k})]})}),(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)(oD,{label:"View profile",description:"Open your activity, task, and usage ledger.",icon:ku,href:j,onClick:N}),(0,t.jsx)(oD,{label:"Edit profile",description:"Update your display name and avatar.",icon:v_,href:Jtt,onClick:N}),(0,t.jsx)(oD,{label:"Documentation",description:"Open Paperclip docs in a new tab.",icon:FN,href:Ztt,external:!0,onClick:r(()=>f(!1),"onClick")}),(0,t.jsx)(yw,{variant:"menu-action",onAfterToggle:r(()=>f(!1),"onAfterToggle")}),(0,t.jsx)(Dbe,{variant:"menu-action",onAfterAction:r(()=>f(!1),"onAfterAction")}),e==="authenticated"?(0,t.jsxs)("button",{type:"button",className:W("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)(op,{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)($be,{})]})]})]})]}),!h&&!a?(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)("a",{href:est,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)(Vx,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsx)(Vn,{side:"top",children:"Share feedback"})]}):null]})})}r(RZ,"SidebarAccountMenu");function nst(e,s){return Zbe(e,s)[0]?.toLowerCase()??null}r(nst,"getCompanyRouteSegment");function Zbe(e,s){if(!s)return[];const n=e.split("/").filter(Boolean);return n.length<2?[]:n[0]?.toUpperCase()!==s.toUpperCase()?[]:n.slice(1)}r(Zbe,"getCompanyPathSegments");var rst=new Set(["browse","connections","connect","chat","review","attention","gateways","advanced","app"]);function ast(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(ast,"isSkillsStoreRoute");function ist(){const{sidebarOpen:e,setSidebarOpen:s,toggleSidebar:n,collapsed:a,peeking:i,setPeeking:o,isMobile:l,setForceCollapsed:c}=Ua(),{openNewIssue:d,openOnboarding:u}=zo(),{togglePanelVisible:h}=Ef(),p=Rc()?.pushToast??null,{companies:f,loading:g,selectedCompany:v,selectedCompanyId:y,selectionSource:w,setSelectedCompanyId:k}=ps(),{companyPrefix:j,pluginRoutePath:N}=Ia(),_=Xn(),I=ra(),C=h3(),T=["/company/settings","/company/export","/company/import"].some(xt=>I.pathname.includes(xt)),R=Zbe(I.pathname,j),A=R[0]?.toLowerCase()==="tools",L=R[0]?.toLowerCase()==="apps",D=L&&R[1]&&!rst.has(R[1].toLowerCase())?R[1]:null,O=L&&R[1]?.toLowerCase()==="app"&&R[2]?R[2]:null,E=ast(I.pathname,j),q=(0,m.useRef)(!1),B=(0,m.useRef)(null),U=(0,m.useRef)(null),z=(0,m.useRef)(new zhe),$=(0,m.useRef)(I.key),K=Ube(I.pathname,j,l),[H,se]=(0,m.useState)(!1),Z=(0,m.useMemo)(()=>{if(!j)return null;const xt=j.toUpperCase();return f.find(Le=>Le.issuePrefix.toUpperCase()===xt)??null},[f,j]),ie=!!j&&!g&&f.length>0&&!Z,oe=(0,m.useMemo)(()=>N?.toLowerCase()??nst(I.pathname,j),[j,I.pathname,N]),Y=Z?.id??null,ne=Z?.issuePrefix??null,{slots:de}=ed({slotTypes:["page","routeSidebar"],companyId:Y,enabled:!!(Y&&oe)}),ee=(0,m.useMemo)(()=>EK(de,oe),[oe,de]),X=(0,m.useMemo)(()=>({companyId:Y,companyPrefix:ne}),[Y,ne]),Q=T?(0,t.jsx)(Utt,{}):D?(0,t.jsx)(_Z,{kind:"connection",connectionId:D}):O?(0,t.jsx)(_Z,{kind:"application",applicationId:O}):L||A?(0,t.jsx)(Ktt,{}):ee?(0,t.jsx)(Su,{slot:ee,context:X,className:"h-full w-full",missingBehavior:"placeholder"}):null,fe=Q!=null,{data:te}=J({queryKey:P.health,queryFn:r(()=>cm.get(),"queryFn"),retry:!1,refetchInterval:r(xt=>xt.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1}),ae=J({queryKey:P.instance.generalSettings,queryFn:r(()=>Tr.getGeneral(),"queryFn")}).data?.keyboardShortcuts===!0,le=fe||E;(0,m.useLayoutEffect)(()=>(c(le),()=>c(!1)),[le,c]),(0,m.useEffect)(()=>{g||q.current||te?.deploymentMode!=="authenticated"&&(te?.cloud||f.length===0&&(q.current=!0,u()))},[f,g,u,te?.cloud,te?.deploymentMode]),(0,m.useEffect)(()=>{if(!j||g||f.length===0)return;if(!Z){const Le=(y?f.find(Ge=>Ge.id===y):null)??f[0]??null;Le&&y!==Le.id&&k(Le.id,{source:"route_sync"});return}if(j!==Z.issuePrefix){const Le=I.pathname.replace(/^\/[^/]+/,"");_(`/${Z.issuePrefix}${Le}${I.search}`,{replace:!0});return}const xt=Kbe({matchedCompany:Z,selectedCompanyId:y,companies:f});if(xt){p?.({title:`${Z.name} is archived`,body:`Switched to ${xt.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${Z.id}`}),k(xt.id,{source:"route_sync"}),_(`/${xt.issuePrefix}/dashboard`,{replace:!0});return}Wbe({selectionSource:w,selectedCompanyId:y,routeCompanyId:Z.id})&&k(Z.id,{source:"route_sync"})},[j,f,g,Z,I.pathname,I.search,_,p,w,y,k]);const ce=h,he=(0,m.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),ve=(0,m.useRef)(null),pe=(0,m.useRef)(!1),xe=(0,m.useRef)(!1),_e=(0,m.useCallback)(()=>{ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null)},[]),ge=(0,m.useCallback)(()=>{_e(),ve.current=window.setTimeout(()=>o(!0),50)},[_e,o]),Ie=(0,m.useCallback)(()=>{_e(),o(!0)},[_e,o]),Ye=(0,m.useCallback)(()=>{_e(),ve.current=window.setTimeout(()=>o(!1),120)},[_e,o]),$e=(0,m.useCallback)(()=>{pe.current=!0,a&&!xe.current&&ge()},[a,ge]),Xe=(0,m.useCallback)(()=>{pe.current=!1,xe.current=!1,Ye()},[Ye]),ue=(0,m.useCallback)(()=>{xe.current||Ie()},[Ie]),Oe=(0,m.useCallback)(()=>{pe.current||Ye()},[Ye]);(0,m.useEffect)(()=>_e,[_e]);const dt=(0,m.useRef)(a);return(0,m.useEffect)(()=>{a!==dt.current&&(a?(_e(),o(!1),xe.current=pe.current):xe.current=!1,dt.current=a)},[a,_e,o]),(0,m.useEffect)(()=>{if(!i)return;const xt=r(Le=>{Le.key==="Escape"&&(_e(),o(!1))},"onKeyDown");return window.addEventListener("keydown",xt),()=>window.removeEventListener("keydown",xt)},[i,_e,o]),zbe(),Obe({enabled:ae,onNewIssue:r(()=>d(),"onNewIssue"),onSearch:he,onToggleSidebar:n,onTogglePanel:ce,onShowShortcuts:r(()=>se(!0),"onShowShortcuts"),onGoToInbox:r(()=>_("/inbox"),"onGoToInbox")}),(0,m.useEffect)(()=>{if(!l)return;const xt=30,Le=50,Ge=75;let ht=0,Ve=0;const Ke=r(tt=>{const Se=tt.touches[0];ht=Se.clientX,Ve=Se.clientY},"onTouchStart"),gt=r(tt=>{const Se=tt.changedTouches[0],ke=Se.clientX-ht;if(!(Math.abs(Se.clientY-Ve)>Ge)){if(!e&&ht<xt&&ke>Le){s(!0);return}e&&ke<-50&&s(!1)}},"onTouchEnd");return document.addEventListener("touchstart",Ke,{passive:!0}),document.addEventListener("touchend",gt,{passive:!0}),()=>{document.removeEventListener("touchstart",Ke),document.removeEventListener("touchend",gt)}},[l,e,s]),(0,m.useEffect)(()=>{const xt=document.body.style.overflow;return document.body.style.overflow=l?"visible":"clip",()=>{document.body.style.overflow=xt}},[l]),(0,m.useEffect)(()=>{if(!l)return Hbe()},[l]),(0,m.useEffect)(()=>{if(typeof document>"u")return;const xt=U.current;return Vbe(xt)},[I.pathname]),(0,m.useEffect)(()=>{const xt=U.current;if(!xt)return;const Le=r(()=>{z.current.remember($.current,xt.scrollTop)},"recordScroll");return xt.addEventListener("scroll",Le,{passive:!0}),()=>xt.removeEventListener("scroll",Le)},[]),(0,m.useLayoutEffect)(()=>{const xt=U.current,Le=qhe({previousPathname:B.current,pathname:I.pathname,navigationType:C,state:I.state});B.current=I.pathname;const Ge=C==="POP",ht=Ge?z.current.recall(I.key):0;if($.current=I.key,Ge){s5(xt,ht);const Ve=requestAnimationFrame(()=>s5(xt,ht));return()=>cancelAnimationFrame(Ve)}Le&&Uhe(xt)},[I.key,I.pathname,I.state,C]),(0,t.jsx)(Bhe,{children:(0,t.jsx)(Hue,{value:{keyboardShortcutsEnabled:ae},children:(0,t.jsxs)("div",{className:W("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)(Abe,{}),(0,t.jsx)(Tbe,{devServer:te?.devServer}),(0,t.jsxs)("div",{className:W("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:W("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?Q:(0,t.jsx)(CZ,{})})}),(0,t.jsx)(RZ,{deploymentMode:te?.deploymentMode})]}):(0,t.jsxs)(Ytt,{open:e,collapsed:a,peeking:i,resizable:!0,onPanelMouseEnter:$e,onPanelMouseLeave:Xe,onPanelFocusCapture:a?ue:void 0,onPanelBlurCapture:a?Oe:void 0,children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0",children:(0,t.jsx)(CZ,{})}),(0,t.jsx)(RZ,{deploymentMode:te?.deploymentMode})]}),!l&&fe?(0,t.jsx)(Xtt,{children:Q}):null,(0,t.jsxs)("div",{className:W("flex min-w-0 flex-col",l?"w-full":"h-full flex-1"),children:[(0,t.jsxs)("div",{className:W(l&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:[(0,t.jsx)(m6,{mobile:l,onNavigateHome:r(()=>_("/dashboard"),"onNavigateHome")}),(0,t.jsx)(Qtt,{}),l&&T?(0,t.jsx)("div",{className:"border-b border-border px-4 pb-3",children:(0,t.jsx)(ufe,{})}):null]}),(0,t.jsxs)("div",{className:W(l?"block":"flex flex-1 min-h-0"),children:[(0,t.jsx)("main",{id:"main-content",ref:U,tabIndex:-1,style:l?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:W("flex-1 p-4 outline-none md:p-6",l?"overflow-visible pb-(--sz-calc-14)":"overflow-auto [scrollbar-gutter:stable]"),children:ie?(0,t.jsx)(ju,{scope:"invalid_company_prefix",requestedPrefix:j??v?.issuePrefix}):(0,t.jsx)(Pbe,{children:(0,t.jsx)(_0,{})})}),(0,t.jsx)(Nfe,{})]})]})]}),l&&(0,t.jsx)(Ibe,{visible:K}),(0,t.jsx)(Cfe,{}),(0,t.jsx)(Ffe,{}),(0,t.jsx)(ybe,{}),(0,t.jsx)(Nbe,{}),(0,t.jsx)(kbe,{}),(0,t.jsx)(Sbe,{open:H,onOpenChange:se}),(0,t.jsx)(Cbe,{}),(0,t.jsx)(_be,{localTrusted:te?.deploymentMode==="local_trusted"})]})})})}r(ist,"Layout");var EZ=null;function ost(){return EZ??=new J1,EZ}r(ost,"getDetachedClient");function lst(){const e=(0,m.useContext)(d3),{data:s,isFetched:n}=J({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn"),enabled:e!=null},e??ost());return e?{enabled:s?.enableConferenceRoomChat===!0,loaded:n}:{enabled:!1,loaded:!0}}r(lst,"useConferenceRoomChatEnabled");function cst(){const{enabled:e,loaded:s}=lst();return s?e?(0,t.jsx)(_0,{}):(0,t.jsx)(bn,{to:"/dashboard",replace:!0}):null}r(cst,"ConferenceRoomChatGate");var dst=["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"],ust={"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 }"}},fJt=dst.map(e=>ust[e]);function eve({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)(zMe,{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)(Qe,{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)(Bo,{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(eve,"TaskChatProjectCreatedCard");function mst({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)(Mx,{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(mst,"TaskChatSkillCreatedCard");var tve=(0,m.createContext)("streamlined");function hst({mode:e,children:s}){return(0,t.jsx)(tve.Provider,{value:e,children:s})}r(hst,"TaskChatPresentationProvider");function cp(){return(0,m.useContext)(tve)==="streamlined"}r(cp,"useStreamlinedTaskChatPresentation");function pst(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(pst,"McpIcon");var fst=new Set(["tool","tool call","tool_call","acp_tool"]);function Ld(e){const s=(e??"").trim().toLowerCase().replace(/\s*\((?:pending|in[_ -]?progress|completed|failed|cancelled|canceled)\)$/,"");return!s||fst.has(s)}r(Ld,"isGenericToolName");function r7(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(r7,"mcpToolIdentity");function a7(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(a7,"identifierWords");function sve(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(sve,"sentenceCase");function jw(e){const s=(e??"").trim();return Ld(s)?"Unnamed tool":sve(a7(r7(s)?.name??s))}r(jw,"humanizeToolName");var dd=r((e,s,n)=>({key:e,singular:s,plural:n}),"group"),xst={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:dd("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:dd("task_operation","task operation","task operations")},task_create:{action:"create",running:"Creating a task",completed:"Created a task",family:"plan",group:dd("task_operation","task operation","task operations")},task_update:{action:"update",running:"Updating a task",completed:"Updated a task",family:"plan",group:dd("task_operation","task operation","task operations")},task_list:{action:"list",running:"Listing tasks",completed:"Listed tasks",family:"plan",group:dd("task_operation","task operation","task operations")},task_get:{action:"read",running:"Reading a task",completed:"Read a task",family:"plan",group:dd("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:dd("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"}},gst={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:[]},bst={read:"read",edit:"update",delete:"delete",move:"move",search:"search",list:"list",execute:"run",think:"think",fetch:"fetch",switch_mode:"switch"};function vst(e){return a7(e).join("_")}r(vst,"normalizedKey");function yst(e){const s=e[0];if(!s)return null;for(const[n,a]of Object.entries(gst))if(a.includes(s))return n;return null}r(yst,"inferredAction");function jst(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(jst,"actionFamily");var wst={terminal:yv,grep:vLe,search:ha,read:FN,edit:A3,web:VPe,plan:g_,question:Xc,agent:wv,safety:Ii,image:E3,wait:dm,mcp:pst,other:Mx};function Nst(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(Nst,"actionCopy");function kst(e){switch(e){case"run":return dd("command","command","commands");case"read":case"list":return dd("read","read","reads");case"search":return dd("search","search","searches");case"update":case"create":case"delete":case"move":return dd("file_change","file change","file changes");case"start":case"stop":return dd("delegation","delegation","delegations");case"wait":return dd("wait","wait","waits");default:return dd("tool_action","tool action","tool actions")}}r(kst,"defaultSummaryGroup");function Sst(e){return e==="read"||e==="list"?dd("paperclip_read","Paperclip read","Paperclip reads"):dd("task_operation","task operation","task operations")}r(Sst,"paperclipSummaryGroup");function Rv(e){const s=(e.name??"").trim(),n=r7(s),a=(e.namespace??n?.namespace??"").trim(),i=(n?"mcp":e.transport??"builtin").toLowerCase(),o=(n?.name??s).trim(),l=a7(o),c=vst(o),d=xst[c],u=bst[(e.operation??"").trim().toLowerCase()],h=yst(l),p=d?.action??u??h??"other",f=d?"exact":u?"kind":h?"inferred":Ld(o)?"unnamed":"fallback",g=Ld(o)?"Unnamed tool":jw(o),v=/^[A-Za-z][A-Za-z0-9_.:-]*$/.test(o),y=h&&v&&l.length>1?l.slice(1):[],w=y.length?sve(y).replace(/^./,C=>C.toLowerCase()):void 0,k=d?.running&&d.completed?{running:d.running,completed:d.completed}:p==="other"?Ld(o)?{running:"Running an unnamed tool",completed:"Ran an unnamed tool"}:{running:`Running ${g}`,completed:`Ran ${g}`}:Nst(p,d?void 0:w),j=d?.family??jst(p),N=i==="mcp"?"mcp":j,_=a?jw(a):i==="mcp"?"MCP":void 0,I=a.toLowerCase()==="paperclip"?Sst(p):d?.group??kst(p);return{icon:wst[N],family:N,runningLabel:k.running,completedLabel:k.completed,failedLabel:`${k.completed} · failed`,interruptedLabel:`${k.running} · stopped`,displayName:g,sourceLabel:_,technicalName:s||void 0,confidence:f,summaryGroup:I}}r(Rv,"toolActivityPresentation");function bP(e){const s=Rv({name:e});return{family:s.family,icon:s.icon,verbLabel:s.runningLabel}}r(bP,"toolTaxonomy");function Cst(e){const s=(e??"").trim().toLowerCase();return s==="thinking"?Jg:s==="responding"||s.startsWith("responding (")?P4e:null}r(Cst,"statusLabelIcon");var lD=["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"],cD=["Brewing","Tinkering","Distilling","Deliberating"],PZ=(()=>{const e=[],s=Math.max(lD.length,cD.length);for(let n=0;n<s;n++)n<lD.length&&e.push(lD[n]),n<cD.length&&e.push(cD[n]);return e})(),_st=1e4;function Ist(e){const s=(e??"").trim().toLowerCase();return s==="running"||s==="working"}r(Ist,"isGenericStatusLabel");function Ast(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(Ast,"fnv1a");function Tst(e,s=0){const n=Math.floor(Math.max(0,s)/_st);return PZ[(Ast(e)+n)%PZ.length]}r(Tst,"whimsyWord");var Rst=[{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}],xJt=Array.from(new Set(Rst.map(e=>e.group)));function nve(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(nve,"parseCssTimeMs");function Est(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(Est,"elapsedLabel");function Pst(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(Pst,"liveElapsedLabel");function Mst(e,s){const[n,a]=(0,m.useState)(()=>Date.now());return(0,m.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(Mst,"useLiveElapsedMs");function Lst(e,s){return!Number.isFinite(e)||!Number.isFinite(s)||s<=0?0:Math.max(0,Math.round(e/s)-1)}r(Lst,"lineScrollOffset");function $T(e){const s=getComputedStyle(document.documentElement).getPropertyValue(e),n=nve(s);return Number.isFinite(n)?n:0}r($T,"motionTokenMs");function Dst({text:e,streaming:s,leaving:n}){const a=(0,m.useRef)(null),[i,o]=(0,m.useState)(0),[l,c]=(0,m.useState)(!1),[d,u]=(0,m.useState)(!1);(0,m.useLayoutEffect)(()=>{const p=a.current;if(!p)return;const f=r(()=>{const v=parseFloat(window.getComputedStyle(p).lineHeight);o(Lst(p.scrollHeight,v))},"measure");if(f(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(f);return g.observe(p),()=>g.disconnect()},[e,s]),(0,m.useEffect)(()=>{const p=requestAnimationFrame(()=>c(!0)),f=window.setTimeout(()=>u(!0),$T("--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:W("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(Dst,"LiveSelfTalkLine");function $st(e,s){const[n,a]=(0,m.useState)(null),i=(0,m.useRef)(n),o=(0,m.useRef)(null),l=(0,m.useRef)(e),c=(0,m.useRef)(0),d=(0,m.useRef)(null),u=(0,m.useRef)(null),h=(0,m.useRef)(null);return l.current=e,(0,m.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(u),p(h),u.current=window.setTimeout(()=>{if(u.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)},$T("--motion-line-scroll")))},$T("--motion-interstitial-dwell"))},"scheduleLeave"),v=r((w,k)=>{p(u),p(h),c.current=Date.now(),f({text:w,streaming:k,swapKey:(i.current?.swapKey??0)+1}),k||g()},"swapIn");if(!s){p(d),p(u),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=$T("--motion-interstitial-dwell"),k=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)},k)}},[e,s]),(0,m.useEffect)(()=>()=>{d.current!=null&&window.clearTimeout(d.current),u.current!=null&&window.clearTimeout(u.current),h.current!=null&&window.clearTimeout(h.current)},[]),n}r($st,"useHeldSelfTalk");var Ost={running:{Icon:rt,spin:!0,tone:"text-(--status-agent-running)"},working:{Icon:rt,spin:!0,tone:"text-(--status-agent-running)"},awaiting_approval:{Icon:qN,spin:!1,tone:"text-primary"},interrupted:{Icon:mK,spin:!1,tone:"text-destructive"},refused:{Icon:Xu,spin:!1,tone:"text-destructive"},truncated:{Icon:xLe,spin:!1,tone:"text-(--status-agent-paused)"}};function rve({item:e,onApprovalDecision:s,chevronOpen:n,onToggle:a}){const{Icon:i,spin:o,tone:l}=Ost[e.status],c=e.status==="awaiting_approval",d=e.status==="running"||e.status==="working",u=Mst(e.startedAtMs,d),h=$st(d?e.selfTalk:void 0,d),p=Est(e.elapsedMs);if(d){const f=Pst(u??e.elapsedMs),g=e.selfTalk!=null,v=e.toolName?bP(e.toolName).icon:g?null:Cst(e.label),y=g||Ist(e.label)?Tst(e.id,u??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)(En,{className:W("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)(Dst,{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:W("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:W("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:W("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(rve,"TaskChatStatusPill");function ave(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(ave,"downloadBlob$1");function Fst(e,s,n){ave(e,new Blob([s],{type:`${n};charset=utf-8`}))}r(Fst,"downloadTextFile");var dD="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 ive({issueId:e,documentKey:s,title:n,format:a,body:i,className:o}){const[l,c]=(0,m.useState)(null),[d,u]=(0,m.useState)(null),[h,p]=(0,m.useState)(null),{copy:f,copied:g,failed:v}=Sf(),y=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>clearTimeout(y.current),[]);const w=(0,m.useCallback)(async(C,T)=>{c(C),p(null);try{await T(),u(C)}catch(R){u(null),p(R instanceof Error?R.message:"Export failed")}finally{c(null)}clearTimeout(y.current),y.current=setTimeout(()=>{u(null),p(null)},2e3)},[]),k=(0,m.useCallback)(async()=>i??(await _t.getDocument(e,s)).body,[i,s,e]),j=(0,m.useCallback)(()=>{c("copy"),p(null),(async()=>{try{await f(await k())==="failed"&&p("Copy failed")}catch(C){p(C instanceof Error?C.message:"Copy failed")}finally{c(null)}})()},[f,k]),N=v||h==="Copy failed"?"Copy failed":g?"Copied!":"Copy full content",_=d==="download"?"Downloaded!":"Download source",I=d==="pdf"?"Downloaded!":"Export to PDF";return(0,t.jsxs)("div",{className:W("flex items-center gap-0.5",o),"data-testid":"document-export-actions",children:[(0,t.jsx)("button",{type:"button",className:dD,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)(ds,{"aria-hidden":"true",className:"h-3.5 w-3.5"}):(0,t.jsx)(kr,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:dD,disabled:l!==null,"aria-label":"Download source",title:_,"data-testid":"document-export-download",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),w("download",async()=>{const T=m3e(a);Fst(nQ(n,T),await k(),T==="md"?"text/markdown":"text/plain")})},"onClick"),children:(0,t.jsx)(To,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:dD,disabled:l!==null,"aria-label":"Export to PDF",title:I,"data-testid":"document-export-pdf",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),w("pdf",async()=>{ave(nQ(n,"pdf"),await _t.getDocumentPdf(e,s))})},"onClick"),children:(0,t.jsx)(IMe,{"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(ive,"DocumentExportActions");function p1({children:e,className:s}){return(0,t.jsx)("div",{className:W("relative aspect-video w-full overflow-hidden bg-accent/20",s),children:e})}r(p1,"PreviewFrame");function H5({label:e}){return(0,t.jsx)(p1,{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)(Ql,{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(H5,"PlaceholderPreview");function Bst({artifact:e}){const[s,n]=(0,m.useState)(!1);return s||!e.contentPath?(0,t.jsx)(H5,{label:"Image"}):(0,t.jsx)(p1,{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(Bst,"ImagePreview");function qst({artifact:e}){const[s,n]=(0,m.useState)(!1),[a,i]=(0,m.useState)(!1),o=(0,m.useRef)(!1),l=(0,m.useRef)(null);if((0,m.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),s||!e.contentPath)return(0,t.jsx)(p1,{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)(so,{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"),u=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)(p1,{className:"bg-black",children:[(0,t.jsx)("video",{src:e.contentPath,preload:"metadata",muted:!0,playsInline:!0,"data-frame-ready":a?"true":"false",className:W("h-full w-full object-contain transition-opacity",a?"opacity-100":"opacity-0"),onLoadedMetadata:u,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)(so,{className:"h-5 w-5 translate-x-0.5 text-white","aria-hidden":"true"})})})]})}r(qst,"VideoPreview");function zst({artifact:e}){const s=e.previewText?.trim();return s?(0,t.jsxs)(p1,{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)(H5,{label:e.source==="document"?"Document":"Text"})}r(zst,"TextPreview");function L_({artifact:e}){switch(e.mediaKind){case"image":return(0,t.jsx)(Bst,{artifact:e},e.contentPath);case"video":return(0,t.jsx)(qst,{artifact:e},e.contentPath);case"text":case"document":return(0,t.jsx)(zst,{artifact:e});case"file":return(0,t.jsx)(H5,{label:"File"});default:return(0,t.jsx)(H5,{})}}r(L_,"ArtifactPreview");function MZ({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(MZ,"SecondaryAction");function Ust({artifact:e}){return(0,t.jsxs)(Qe,{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)(L_,{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)(ive,{issueId:e.issue.id,documentKey:e.documentKey,title:e.title}):null,e.openPath?(0,t.jsx)(MZ,{href:e.openPath,title:"Open file in new tab",children:(0,t.jsx)(gr,{className:"h-3.5 w-3.5"})}):null,e.downloadPath?(0,t.jsx)(MZ,{href:e.downloadPath,download:!0,title:"Download file",children:(0,t.jsx)(To,{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 ",vu(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(Ust,"ArtifactCard");function XN(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(XN,"formatBytes$4");var G5=new Set(["application/octet-stream","binary/octet-stream","application/x-binary"]),Kst=[".mp4",".m4v",".webm",".mov",".qt",".quicktime"],Wst=[".png",".jpg",".jpeg",".gif",".webp",".avif",".bmp",".svg",".ico"],Vst=new Set(["application/wasm"]),Hst=new Set(["application/zip","application/x-zip","application/x-zip-compressed"]),ove=new Set(["text/markdown","text/x-markdown","application/markdown","application/x-markdown"]),Gst=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"]),Qst=[".csv",".css",".graphql",".htm",".html",".js",".json",".jsx",".log",".markdown",".md",".mdx",".php",".py",".sh",".sql",".toml",".ts",".tsx",".txt",".xml",".yaml",".yml"];function D_(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}r(D_,"normalizeOutputContentType");function Yst(e){const s=(e??"").trim().toLowerCase();return s?Qst.some(n=>s.endsWith(n)):!1}r(Yst,"hasDocumentLikeFilename");function lve(e){return Hst.has(e)||e.endsWith("+zip")}r(lve,"isZipContentType");function Xst(e){return e?!!(e.startsWith("text/")||ove.has(e)||Gst.has(e)||e.startsWith("application/")&&(e.endsWith("+json")||e.endsWith("+xml"))):!1}r(Xst,"isDocumentLikeOutputContentType");function Jst(e,s){const n=D_(e);return!n||Xst(n)||G5.has(n)&&Yst(s)?!1:n.startsWith("video/")||n.startsWith("image/")||n==="application/pdf"||Vst.has(n)||lve(n)||G5.has(n)}r(Jst,"isOutputEligibleContentType");function Zst(e){const s=D_(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"}:lve(s)?{label:"ZIP",tone:"zip"}:s.startsWith("image/")?{label:"IMG",tone:"image"}:ove.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(Zst,"getOutputFileGlyph");function Cu(e,s){const n=D_(e);if(n.startsWith("video/"))return!0;if(!G5.has(n))return!1;const a=(s??"").trim().toLowerCase();return Kst.some(i=>a.endsWith(i))}r(Cu,"isVideoLikeOutput");function dN(e){return D_(e).startsWith("image/")}r(dN,"isImageContentType");function vP(e,s){const n=D_(e);if(dN(n))return!0;if(n&&!G5.has(n))return!1;const a=(s??"").trim().toLowerCase();return Wst.some(i=>a.endsWith(i))}r(vP,"isImageLikeOutput");function LZ(e){const s=new Date(e).getTime();return Number.isNaN(s)?0:s}r(LZ,"toTime");function yP(e){const s=(e??[]).filter(n=>n.type==="artifact"&&n.provider==="paperclip").flatMap(n=>{const a=ATe.safeParse(n.metadata);return a.success&&!Jst(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:LZ(a.createdAt)-LZ(n.createdAt)),{items:s,primary:s[0]??null,rest:s.slice(1),count:s.length}}r(yP,"getIssueOutputs");function i7(e){return e.metadata?.originalFilename||e.title||"output"}r(i7,"outputFilename");function cve(e){return new Set(yP(e).items.flatMap(s=>{const n=s.metadata?.attachmentId;return n?[n]:[]}))}r(cve,"getPromotedOutputAttachmentIds");var Eh={connect:r((e,s)=>Te.post(`/companies/${e}/email/connections`,s),"connect"),inspectSaved:r((e,s)=>Te.post(`/companies/${e}/email/connections/${s}/inspect`,{}),"inspectSaved"),list:r(e=>Te.get(`/companies/${e}/email/inboxes`),"list"),setup:r((e,s)=>Te.post(`/companies/${e}/email/inboxes`,s),"setup"),inspect:r((e,s)=>Te.post(`/companies/${e}/email/inspect`,{apiKey:s}),"inspect"),control:r((e,s)=>Te.post(`/email/inboxes/${e}/control`,{action:s}),"control"),reconnect:r((e,s,n)=>Te.post(`/email/inboxes/${e}/reconnect`,{apiKey:s,receiveMode:n}),"reconnect"),resolve:r((e,s,n,a)=>Te.post(`/companies/${e}/email/deliveries/${s}/resolve`,{outcome:n,providerMessageId:a}),"resolve"),thread:r((e,s)=>Te.get(`/companies/${e}/email/tasks/${s}`),"thread"),send:r((e,s)=>Te.post(`/companies/${e}/email/send`,s),"send")},dve=(0,m.createContext)(null);function ent({companyId:e,issueId:s,children:n}){const{enabled:a}=Yx(),i=J({queryKey:["email-thread",e,s],queryFn:r(()=>Eh.thread(e,s),"queryFn"),enabled:a,refetchInterval:a?3e3:!1});return(0,t.jsx)(dve.Provider,{value:i.data??null,children:n})}r(ent,"EmailThreadProvider");function uve(e){const s=(0,m.useContext)(dve),n=s?.messages.find(a=>a.commentId===e);return n&&s?(0,t.jsx)(mve,{message:n,publication:s.publications.find(a=>a.providerMessageId===n.providerMessageId),issueId:s.issueId}):null}r(uve,"useEmailComment");function mve({message:e,publication:s,issueId:n}){const a=J({queryKey:["email-attachments",n],queryFn:r(()=>_t.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)(pme,{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)(Ql,{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(mve,"EmailMessageCard");var av=(0,m.createContext)(null);function tnt(e){return e.contentType.toLowerCase().split(";")[0]?.trim()??""}r(tnt,"normalizedContentType$1");function $_(e){return e.originalFilename??e.id}r($_,"attachmentFilename");function o7(e){return e.openPath??e.contentPath}r(o7,"attachmentOpenPath");function O_(e){return e.downloadPath??`${e.contentPath}?download=1`}r(O_,"attachmentDownloadPath");function hve(e){const s=tnt(e);return vP(s,e.originalFilename)&&!/^image\/hei[cf](?:-sequence)?$/.test(s)}r(hve,"isImageAttachment$2");function pve(e){return Cu(e.contentType,e.originalFilename)}r(pve,"isVideoAttachment");function snt(e){return STe(e)}r(snt,"isMarkdownAttachment");function oy({items:e,initialIndex:s,open:n,onOpenChange:a}){const[i,o]=(0,m.useState)(s),l=(0,m.useRef)(null),c=(0,m.useCallback)(v=>{l.current=v},[]);(0,m.useEffect)(()=>{n&&o(s)},[n,s]);const d=(0,m.useCallback)(()=>{o(v=>(v+1)%e.length)},[e.length]),u=(0,m.useCallback)(()=>{o(v=>(v-1+e.length)%e.length)},[e.length]);(0,m.useEffect)(()=>{i<e.length||o(0)},[i,e.length]),(0,m.useEffect)(()=>{if(!n)return;const v=r(y=>{y.key==="ArrowRight"?d():y.key==="ArrowLeft"?u():y.key==="Escape"&&a(!1)},"handler");return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n,d,u,a]);const h=(0,m.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=$_(p),g=Cu(p.contentType,p.originalFilename);return(0,t.jsx)(hEe,{open:n,onOpenChange:a,children:(0,t.jsxs)(uEe,{children:[(0,t.jsx)(mEe,{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)(gEe,{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:O_(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)(To,{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)(sr,{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:u,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)(Nu,{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)(En,{className:"h-7 w-7"})})})]}),(0,t.jsx)("div",{className:"h-6 shrink-0"})]})]})})}r(oy,"ImageGalleryModal");function y6(e,s){if(e&&!s)return e;if(!e&&s)return s;if(e||s)return{...e,...s}}r(y6,"mergeObjects");var l7={};function c7(e,s,n,a,i){if(!n&&!a&&!i&&!e)return Q5(s);let o=Q5(e);return s&&(o=ES(o,s)),n&&(o=ES(o,n)),a&&(o=ES(o,a)),i&&(o=ES(o,i)),o}r(c7,"mergeProps");function nnt(e){if(e.length===0)return l7;if(e.length===1)return Q5(e[0]);let s=Q5(e[0]);for(let n=1;n<e.length;n+=1)s=ES(s,e[n]);return s}r(nnt,"mergePropsN");function Q5(e){return d7(e)?{...xve(e,l7)}:rnt(e)}r(Q5,"createInitialMergedProps");function ES(e,s){return d7(s)?xve(s,e):ant(e,s)}r(ES,"mergeInto");function rnt(e){const s={...e};for(const n in s){const a=s[n];fve(n,a)&&(s[n]=gve(a))}return s}r(rnt,"copyInitialProps");function ant(e,s){if(!s)return e;for(const n in s){const a=s[n];switch(n){case"style":e[n]=y6(e.style,a);break;case"className":e[n]=vve(e.className,a);break;default:fve(n,a)?e[n]=int(e[n],a):e[n]=a}}return e}r(ant,"mutablyMergeInto");function fve(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(fve,"isEventHandler");function d7(e){return typeof e=="function"}r(d7,"isPropsGetter");function xve(e,s){return d7(e)?e(s):e??l7}r(xve,"resolvePropsGetter");function int(e,s){return s?e?(...n)=>{const a=n[0];if(yve(a)){const o=a;bve(o);const l=s(...n);return o.baseUIHandlerPrevented||e?.(...n),l}const i=s(...n);return e?.(...n),i}:gve(s):e}r(int,"mergeEventHandlers");function gve(e){return e&&((...s)=>{const n=s[0];return yve(n)&&bve(n),e(...s)})}r(gve,"wrapEventHandler");function bve(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}r(bve,"makeEventPreventable");function vve(e,s){return s?e?s+" "+e:s:e}r(vve,"mergeClassNames");function yve(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}r(yve,"isSyntheticEvent");function ont(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(ont,"createFormatErrorMessage");var lnt=ont("https://base-ui.com/production-error","Base UI"),DZ={};function jve(e,s){const n=m.useRef(DZ);return n.current===DZ&&(n.current=e(s)),n}r(jve,"useRefWithInit");function $Z(e,s,n,a){const i=jve(wve).current;return dnt(i,e,s,n,a)&&Nve(i,[e,s,n,a]),i.callback}r($Z,"useMergedRefs");function cnt(e){const s=jve(wve).current;return unt(s,e)&&Nve(s,e),s.callback}r(cnt,"useMergedRefsN");function wve(){return{callback:null,cleanup:null,refs:[]}}r(wve,"createForkRef");function dnt(e,s,n,a,i){return e.refs[0]!==s||e.refs[1]!==n||e.refs[2]!==a||e.refs[3]!==i}r(dnt,"didChange");function unt(e,s){return e.refs.length!==s.length||e.refs.some((n,a)=>n!==s[a])}r(unt,"didChangeN");function Nve(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(Nve,"update");var mnt=parseInt("19.2.8",10);function hnt(e){return mnt>=e}r(hnt,"isReactVersionAtLeast");function OZ(e){if(!m.isValidElement(e))return null;const s=e,n=s.props;return(hnt(19)?n?.ref:s.ref)??null}r(OZ,"getReactElementRef");var gJt=Object.freeze([]),PS=Object.freeze({});function pnt(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(pnt,"getStateAttributesProps");function fnt(e,s){return typeof e=="function"?e(s):e}r(fnt,"resolveClassName");function xnt(e,s){return typeof e=="function"?e(s):e}r(xnt,"resolveStyle");function gnt(e,s,n={}){const a=s.render,i=bnt(s,n);return n.enabled===!1?null:jnt(e,a,i,n.state??PS)}r(gnt,"useRenderElement");function bnt(e,s={}){const{className:n,style:a,render:i}=e,{state:o=PS,ref:l,props:c,stateAttributesMapping:d,enabled:u=!0}=s,h=u?fnt(n,o):void 0,p=u?xnt(a,o):void 0,f=u?pnt(o,d):PS,g=u&&c?vnt(c):void 0,v=u?y6(f,g)??{}:PS;return typeof document<"u"&&(u?Array.isArray(l)?v.ref=cnt([v.ref,OZ(i),...l]):v.ref=$Z(v.ref,OZ(i),l):$Z(null,null)),u?(h!==void 0&&(v.className=vve(v.className,h)),p!==void 0&&(v.style=y6(v.style,p)),v):PS}r(bnt,"useRenderElementProps");function vnt(e){return Array.isArray(e)?nnt(e):c7(void 0,e)}r(vnt,"resolveRenderFunctionProps");var ynt=Symbol.for("react.lazy");function jnt(e,s,n,a){if(s){if(typeof s=="function")return s(n,a);const i=c7(n,s.props);i.ref=n.ref;let o=s;return o?.$$typeof===ynt&&(o=m.Children.toArray(s)[0]),m.cloneElement(o,i)}if(e&&typeof e=="string")return wnt(e,n);throw new Error(lnt(8))}r(jnt,"evaluateRenderProp");function wnt(e,s){return e==="button"?(0,m.createElement)("button",{type:"button",...s,key:s.key}):e==="img"?(0,m.createElement)("img",{alt:"",...s,key:s.key}):m.createElement(e,s)}r(wnt,"renderTag");function Nnt(e){return gnt(e.defaultTagName??"div",e,e)}r(Nnt,"useRender");var knt=eK("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 kve({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:W(knt({size:n,orientation:a}),e),...i})}r(kve,"Attachment");var Snt=eK("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 Sve({className:e,variant:s="icon",...n}){return(0,t.jsx)("div",{"data-slot":"attachment-media","data-variant":s,className:W(Snt({variant:s}),e),...n})}r(Sve,"AttachmentMedia");function Cve({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-content",className:W("max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1",e),...s})}r(Cve,"AttachmentContent");function _ve({className:e,...s}){return(0,t.jsx)("span",{"data-slot":"attachment-title",className:W("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(_ve,"AttachmentTitle");function Ive({className:e,...s}){return(0,t.jsx)("span",{"data-slot":"attachment-description",className:W("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(Ive,"AttachmentDescription");function Cnt({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-actions",className:W("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(Cnt,"AttachmentActions$1");function _nt({className:e,variant:s,size:n="icon-xs",...a}){return(0,t.jsx)(F,{"data-slot":"attachment-action",variant:s??"ghost",size:n,className:W(e),...a})}r(_nt,"AttachmentAction");function Int({className:e,render:s,type:n,...a}){return Nnt({defaultTagName:"button",props:c7({type:s?n:n??"button",className:W("absolute inset-0 z-10 outline-none",e)},a),render:s,state:{slot:"attachment-trigger"}})}r(Int,"AttachmentTrigger");function Ave({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-group",className:W("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(Ave,"AttachmentGroup");var Ant=new Set(["png","jpg","jpeg","gif","webp","svg","avif","bmp","ico","heic"]),Tnt={pdf:{icon:vi,label:"PDF"},doc:{icon:vi,label:"Doc"},docx:{icon:vi,label:"Doc"},txt:{icon:vi,label:"Text"},md:{icon:vi,label:"Markdown"},rtf:{icon:vi,label:"Text"},csv:{icon:SS,label:"CSV"},tsv:{icon:SS,label:"TSV"},xls:{icon:SS,label:"Sheet"},xlsx:{icon:SS,label:"Sheet"},zip:{icon:jb,label:"ZIP"},gz:{icon:jb,label:"Archive"},tar:{icon:jb,label:"Archive"},tgz:{icon:jb,label:"Archive"},rar:{icon:jb,label:"Archive"},"7z":{icon:jb,label:"Archive"},mp3:{icon:kS,label:"Audio"},wav:{icon:kS,label:"Audio"},m4a:{icon:kS,label:"Audio"},ogg:{icon:kS,label:"Audio"},mp4:{icon:mT,label:"Video"},mov:{icon:mT,label:"Video"},webm:{icon:mT,label:"Video"},json:{icon:Cl,label:"JSON"},yaml:{icon:Cl,label:"YAML"},yml:{icon:Cl,label:"YAML"},xml:{icon:Cl,label:"XML"},html:{icon:Cl,label:"HTML"},css:{icon:Cl,label:"CSS"},js:{icon:Cl,label:"Code"},jsx:{icon:Cl,label:"Code"},ts:{icon:Cl,label:"Code"},tsx:{icon:Cl,label:"Code"},py:{icon:Cl,label:"Code"},rb:{icon:Cl,label:"Code"},go:{icon:Cl,label:"Code"},rs:{icon:Cl,label:"Code"},sh:{icon:Cl,label:"Code"},sql:{icon:Cl,label:"SQL"},log:{icon:vi,label:"Log"},patch:{icon:Cl,label:"Patch"},diff:{icon:Cl,label:"Patch"}};function Tve(e){const s=/\.([a-z0-9]+)$/i.exec(e.trim());return s?s[1].toLowerCase():""}r(Tve,"extensionOf");function FZ(e){return Ant.has(Tve(e))}r(FZ,"isImageFilename");function Rve(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}r(Rve,"normalizedContentType");function NA(e){const s=Rve(e.contentType);return s.startsWith("image/")?!0:s&&s!=="application/octet-stream"?!1:FZ(e.name)||FZ(e.url.split("?")[0])}r(NA,"isImageAttachment$1");function Eve(e){return Tnt[Tve(e)]??{icon:XR,label:"File"}}r(Eve,"fileKindForName");function Rnt(e){const s=Eve(e.name);if(s.label!=="File")return s;const n=Rve(e.contentType);return n==="application/pdf"?{icon:vi,label:"PDF"}:n==="application/json"||n.endsWith("+json")?{icon:Cl,label:"JSON"}:n==="text/csv"||n==="application/csv"?{icon:SS,label:"CSV"}:n.startsWith("text/")?{icon:vi,label:"Text"}:n.startsWith("audio/")?{icon:kS,label:"Audio"}:n.startsWith("video/")?{icon:mT,label:"Video"}:n.includes("zip")||n.includes("archive")?{icon:jb,label:"Archive"}:s}r(Rnt,"fileKindForAttachment");function Pve(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(Pve,"formatFileSize");function Ent(e){return/\/api\/(?:attachments|assets)\/([^/?]+)\/content/.exec(e)?.[1]??null}r(Ent,"attachmentIdFromUrl");function BZ(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(Ent(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(BZ,"hydrateAttachmentRefs");var qZ=/(?<!!)\[((?:\\.|[^\]\\])+)\]\((\/api\/(?:attachments|assets)\/[^()\s]+\/content(?:\?[^()\s]*)?)\)/g,Mve=/!\[((?:\\.|[^\]\\])*)\]\(([^()\s]+)\)/g;function Lve(e){return e.replace(Mve,"").trim().length===0&&e.trim().length>0}r(Lve,"isStandaloneImageEmbedLine");function Pnt(e){const s=[],n=new Set;for(const a of e.split(`
|
|
336
|
+
`)}`:void 0}r(zet,"sanitizeComponentStack");function Uet(e){const s=zet(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(Uet,"buildBrowserErrorContext");var bZ=Promise.resolve();function n7(e){const s=bZ.then(e);return bZ=s.catch(()=>{}),s}r(n7,"enqueue");var cN=null;function Ket(e,s){return n7(async()=>{if(!cN)try{const n=await Sc(()=>import("./prod-COP_vZWu.js"),__vite__mapDeps([4,5]));n.init(Vet(e,s)),cN=n}catch{}})}r(Ket,"initBrowserErrorMonitoring");function Wet(){return n7(async()=>{const e=cN;if(cN=null,!e)return;const s=e.getClient();try{e.getCurrentScope().setClient(void 0)}catch{}try{await s?.close(2e3)}catch{}})}r(Wet,"teardownBrowserErrorMonitoring");function Ebe(e,s){let n;try{s&&(n=Uet(s))}catch{}n7(async()=>{try{n?cN?.captureException(e,n):cN?.captureException(e)}catch{}})}r(Ebe,"captureBrowserException");function Vet(e,s){return{dsn:e,environment:s??void 0,release:"b9f9efd63b7b0f6f66b85e1632f539aa4c5ad108",tracesSampleRate:0,sendDefaultPii:!1,integrations:r(n=>n.filter(a=>a.name!=="HttpContext"&&a.name!=="Breadcrumbs"),"integrations")}}r(Vet,"buildBrowserSentryInitOptions");var Het=class extends m.Component{static{r(this,"RouteErrorBoundaryInner")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,s){Ebe(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 Pbe({children:e}){const s=ra(),n=Xn(),a=`${s.pathname}${s.search}`;return(0,t.jsx)(Het,{resetKey:a,onReset:r(()=>n(-1),"onReset"),children:e})}r(Pbe,"RouteErrorBoundary");var vA=240,h6=208,p6=420,vZ=16;function K5(e){return Math.min(p6,Math.max(h6,e))}r(K5,"clampSidebarWidth$1");function yZ(e){if(typeof window>"u")return vA;try{const s=window.localStorage.getItem(e);if(!s)return vA;const n=Number.parseInt(s,10);return Number.isFinite(n)?K5(n):vA}catch{return vA}}r(yZ,"readStoredSidebarWidth$1");function jZ(e,s){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(K5(s)))}catch{}}r(jZ,"writeStoredSidebarWidth$1");function Get({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:u,onPanelBlurCapture:h}){const[p,f]=(0,m.useState)(()=>yZ(o)),[g,v]=(0,m.useState)(!1),y=(0,m.useRef)(p),w=(0,m.useRef)(null);(0,m.useEffect)(()=>{const E=yZ(o);y.current=E,f(E)},[o]);const k=s?p:0,j=s?n?64:k:0,N=s?n&&!a?64:k:0,_=N>j,I=i&&s&&!n,C=(0,m.useMemo)(()=>({width:`${j}px`}),[j]),T=(0,m.useMemo)(()=>({width:`${N}px`}),[N]),R=(0,m.useCallback)(E=>{const q=K5(E);y.current=q,f(q),jZ(o,q)},[o]),A=(0,m.useCallback)(E=>{I&&(E.preventDefault(),E.currentTarget.setPointerCapture(E.pointerId),w.current={startX:E.clientX,startWidth:y.current},v(!0))},[I]),L=(0,m.useCallback)(E=>{if(!w.current)return;const q=K5(w.current.startWidth+E.clientX-w.current.startX);y.current=q,f(q)},[]),D=(0,m.useCallback)(()=>{w.current&&(w.current=null,v(!1),jZ(o,y.current))},[o]),O=(0,m.useCallback)(E=>{I&&(E.key==="ArrowLeft"?(E.preventDefault(),R(p-vZ)):E.key==="ArrowRight"?(E.preventDefault(),R(p+vZ)):E.key==="Home"?(E.preventDefault(),R(h6)):E.key==="End"&&(E.preventDefault(),R(p6)))},[I,R,p]);return(0,t.jsxs)("div",{className:W("relative h-full shrink-0",l),style:C,children:[(0,t.jsx)("div",{className:W("absolute inset-y-0 left-0 flex flex-col overflow-hidden",_?"z-30 border-r border-border bg-background shadow-lg":"z-0"),style:T,"data-sidebar-overlay":_?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:u,onBlurCapture:h,children:e}),I?(0,t.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":h6,"aria-valuemax":p6,"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:A,onPointerMove:L,onPointerUp:D,onPointerCancel:D,onLostPointerCapture:D,onKeyDown:O,children:(0,t.jsx)("div",{className:W("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(Get,"SidebarShell$1");function yA({children:e,className:s}){return(0,t.jsx)("div",{"data-secondary-sidebar":"",className:W("h-full w-full min-w-0 overflow-hidden",s),children:(0,t.jsx)(Whe,{children:e})})}r(yA,"SecondarySidebar$1");var Qet="Toggle the app appearance.";function yw({className:e,variant:s="icon",onAfterToggle:n}){const{theme:a,toggleTheme:i}=e3e(),o=a==="dark",l=o?"Switch to light mode":"Switch to dark mode",c=o?Che:vhe;function d(){i(),n?.()}return r(d,"handleClick"),s==="compact-menu-action"?(0,t.jsxs)("button",{type:"button",className:W("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:W("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:Qet})]})]}):(0,t.jsx)(F,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":l,title:l,className:W("text-muted-foreground",e),children:(0,t.jsx)(c,{})})}r(yw,"ThemeToggle");var h1=null,Mbe=!1,f6=!1,x6=new Set;function W5(){for(const e of x6)e()}r(W5,"emit");function Yet(e=typeof navigator>"u"?"":navigator.userAgent,s=typeof navigator>"u"?0:navigator.maxTouchPoints){return/iPhone|iPad|iPod/i.test(e)?!0:/Macintosh/i.test(e)&&s>1}r(Yet,"isIosSafariLike");function Xet(e=window){const s=r(a=>{a.preventDefault(),h1=a,W5()},"onPrompt"),n=r(()=>{h1=null,Mbe=!0,W5()},"onInstalled");return e.addEventListener("beforeinstallprompt",s),e.addEventListener("appinstalled",n),()=>{e.removeEventListener("beforeinstallprompt",s),e.removeEventListener("appinstalled",n)}}r(Xet,"captureInstallPrompt");function Jet(){return Mbe||u6()?"installed":h1?"prompt":Yet()?"ios-manual":"unavailable"}r(Jet,"installAvailability");async function Zet(){const e=h1;if(!e)return"unavailable";h1=null,W5(),await e.prompt();const{outcome:s}=await e.userChoice;return s}r(Zet,"promptInstall");function g6(e){f6!==e&&(f6=e,W5())}r(g6,"setIosInstallHelpOpen");function ett(){return f6}r(ett,"iosInstallHelpOpen");function ttt(){return(0,m.useSyncExternalStore)(Lbe,ett,()=>!1)}r(ttt,"useIosInstallHelpOpen");function Lbe(e){return x6.add(e),()=>{x6.delete(e)}}r(Lbe,"subscribe");function stt(){return(0,m.useSyncExternalStore)(Lbe,Jet,()=>"unavailable")}r(stt,"useInstallAvailability");var wZ="Install app",ntt="Add Paperclip to your home screen or dock.";function Dbe({variant:e,onAfterAction:s}){const n=stt();if(n==="installed"||n==="unavailable")return null;const a=r(()=>{n==="ios-manual"?g6(!0):Zet(),s?.()},"handleClick");return e==="compact-menu-action"?(0,t.jsxs)("button",{type:"button",className:"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",onClick:a,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(To,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:wZ})]}):(0,t.jsxs)("button",{type:"button",className:"flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-accent/60",onClick:a,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)(To,{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:wZ}),(0,t.jsx)("span",{className:"block text-xs text-muted-foreground",children:ntt})]})]})}r(Dbe,"InstallAppMenuAction");function rtt(){const e=ttt();return(0,t.jsx)(Qs,{open:e,onOpenChange:g6,children:(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:"Install Paperclip"}),(0,t.jsx)(Ln,{children:"Add Paperclip to your Home Screen from Safari."})]}),(0,t.jsxs)("ol",{className:"space-y-3 text-sm text-foreground",children:[(0,t.jsxs)(nD,{index:1,icon:(0,t.jsx)(TLe,{className:"size-4"}),children:["Tap ",(0,t.jsx)("strong",{children:"Share"})," in the Safari toolbar."]}),(0,t.jsxs)(nD,{index:2,icon:(0,t.jsx)(zLe,{className:"size-4"}),children:["Choose ",(0,t.jsx)("strong",{children:"Add to Home Screen"}),"."]}),(0,t.jsxs)(nD,{index:3,children:["Keep ",(0,t.jsx)("strong",{children:"Open as Web App"})," on, then tap ",(0,t.jsx)("strong",{children:"Add"}),"."]})]}),(0,t.jsx)(jr,{children:(0,t.jsx)(F,{type:"button",onClick:r(()=>g6(!1),"onClick"),children:"Done"})})]})})}r(rtt,"IosInstallHelpDialog");function nD({index:e,icon:s,children:n}){return(0,t.jsxs)("li",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border border-border text-xs font-semibold text-muted-foreground",children:e}),(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s?(0,t.jsx)("span",{className:"text-muted-foreground",children:s}):null,(0,t.jsx)("span",{children:n})]})]})}r(nD,"InstallStep");function att(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(att,"formatTimestamp$2");function itt(e){return!!e&&!Number.isNaN(new Date(e).getTime())}r(itt,"isValidTimestamp");function ott(e){return e?.devServer?.lastRestartAt??e?.serverInfo?.processStartedAt??null}r(ott,"restartTimestamp");function ltt(e){const s=e?.serverInfo?.git;return s?.available?`${s.shortSha} · ${s.subject}`:"Commit unavailable"}r(ltt,"commitLabel");function ctt(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(ctt,"localChangesLabel");function rD({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(rD,"ServerInfoRow");function $be(){const e=J({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn")}).data?.enableServerInfoDebugView===!0,s=J({queryKey:P.health,queryFn:r(()=>cm.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=ott(n),l=itt(o),c=i?"Health unavailable":a?"Loading...":att(o),d=i?"Health unavailable":a?"Loading...":ltt(n),u=i?"Health unavailable":a?"Loading...":ctt(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)(rD,{icon:dm,label:"Last restarted",value:c,dateTime:!i&&!a&&l?o:null}),(0,t.jsx)(rD,{icon:oK,label:"Running commit",value:d}),(0,t.jsx)(rD,{icon:CMe,label:"Checkout state",value:u})]})}r($be,"SidebarServerInfo");var dtt="/company/settings/instance/profile",utt="https://docs.paperclip.ing/",mtt="https://paperclip.ing/feedback";function htt(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(htt,"deriveInitials$2");function ptt(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(ptt,"deriveUserSlug$1");function jA({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)(Qe,{to:a,className:o,onClick:n,children:l}):(0,t.jsx)("button",{type:"button",className:o,onClick:n,children:l})}r(jA,"MenuAction$1");function NZ({deploymentMode:e,open:s,onOpenChange:n,forceExpanded:a=!1}){const i=!!td(),[o,l]=(0,m.useState)(!1),{isMobile:c,setSidebarOpen:d,collapsed:u,peeking:h}=Ua(),p=u&&!h&&!a,f=s??o,g=n??l,{data:v}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),y=WN({onSignedOut:_}),w=v?.user.name?.trim()||"Board",k=v?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),j=htt(w),N=`/u/${ptt(v?.user.name,v?.user.email,v?.user.id)}`;function _(){g(!1),c&&d(!1)}r(_,"closeNavigationChrome");function I(){y.mutate()}return r(I,"handleSignOut"),(0,t.jsx)("div",{className:"bg-border/50 px-3 py-2 dark:bg-muted",children:(0,t.jsxs)("div",{className:W("flex items-center gap-0.5",!p&&"px-2"),children:[(0,t.jsxs)(tr,{open:f,onOpenChange:g,children:[(0,t.jsx)(pr,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:W("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)(Xi,{size:"sm",children:[v?.user.image?(0,t.jsx)(Jc,{src:v.user.image,alt:w}):null,(0,t.jsx)(Ji,{children:j})]}),(0,t.jsx)("span",{className:W("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)(Qn,{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)(Xi,{className:"size-9",children:[v?.user.image?(0,t.jsx)(Jc,{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:k})]})]}),(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)(jA,{label:"Settings",icon:zd,href:"/company/settings",onClick:_}),(0,t.jsx)(jA,{label:"View profile",icon:ku,href:N,onClick:_}),(0,t.jsx)(jA,{label:"Edit profile",icon:v_,href:dtt,onClick:_}),(0,t.jsx)(jA,{label:"Documentation",icon:FN,href:utt,external:!0,onClick:r(()=>g(!1),"onClick")}),(0,t.jsx)(yw,{variant:"compact-menu-action",onAfterToggle:r(()=>g(!1),"onAfterToggle")}),(0,t.jsx)(Dbe,{variant:"compact-menu-action",onAfterAction:r(()=>g(!1),"onAfterAction")}),e==="authenticated"?(0,t.jsxs)("button",{type:"button",className:W("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:I,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)(op,{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)($be,{})]})]})]}),!p&&!i?(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)("a",{href:mtt,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)(Vx,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsx)(Vn,{side:"top",children:"Share feedback"})]}):null]})})}r(NZ,"SidebarAccountMenu$1");function Obe({enabled:e=!0,onNewIssue:s,onSearch:n,onToggleSidebar:a,onTogglePanel:i,onShowShortcuts:o,onGoToInbox:l}){(0,m.useEffect)(()=>{if(!e)return;let c=!1,d=null;const u=r(()=>{d!==null&&(window.clearTimeout(d),d=null)},"clearGoChordTimeout"),h=r(()=>{c=!1,u()},"disarmGoChord"),p=r(()=>{c=!0,u(),d=window.setTimeout(()=>{c=!1,d=null},1200)},"armGoChord");function f(y){if(y.defaultPrevented){h();return}if(l){const w=Wue({armed:c,defaultPrevented:y.defaultPrevented,key:y.key,metaKey:y.metaKey,ctrlKey:y.ctrlKey,altKey:y.altKey,target:y.target,hasOpenDialog:Uh()});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(!Z1(y.target)){if(y.key==="/"&&!y.metaKey&&!y.ctrlKey&&!y.altKey){if(Uh())return;y.preventDefault(),q5e()||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(Obe,"useKeyboardShortcuts");var ftt=new Set(["auth","invite","board-claim","cli-auth","docs"]);function Fbe(e){const s=(e.split("?")[0]??"").split("/").filter(Boolean);if(s.length===0)return!0;const[n]=s;return!ftt.has(n)}r(Fbe,"isRememberableCompanyPath");function xtt(e){const s=vv(e.companyPrefix);return e.companies.find(n=>vv(n.issuePrefix)===s)??null}r(xtt,"findCompanyByPrefix");function gtt(e){const s=zU(e.pathname);return s?xtt({companies:e.companies,companyPrefix:s})?.id??null:e.fallbackCompanyId}r(gtt,"getRememberedPathOwnerCompanyId");function btt(e){const s=e.path?p3(e.path):"/dashboard";if(!Fbe(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&&vv(i[1]??"")!==vv(e.companyPrefix))return"/dashboard"}return s}r(btt,"sanitizeRememberedPathForCompany");var Bbe="paperclip.companyPaths";function qbe(){try{const e=localStorage.getItem(Bbe);if(e)return JSON.parse(e)}catch{}return{}}r(qbe,"getCompanyPaths");function vtt(e,s){const n=qbe();n[e]=s,localStorage.setItem(Bbe,JSON.stringify(n))}r(vtt,"saveCompanyPath");function zbe(){const{companies:e,selectedCompanyId:s,selectedCompany:n,selectionSource:a}=ps(),i=ra(),o=Xn(),l=(0,m.useRef)(s),c=(0,m.useMemo)(()=>gtt({companies:e,pathname:i.pathname,fallbackCompanyId:l.current}),[e,i.pathname]),d=i.pathname+i.search;(0,m.useEffect)(()=>{const u=c,h=p3(d);u&&Fbe(h)&&vtt(u,h)},[d,c]),(0,m.useEffect)(()=>{if(s){if(l.current!==null&&s!==l.current&&a!=="route_sync"&&n){const u=qbe(),h=btt({path:u[s],companyPrefix:n.issuePrefix});o(`/${n.issuePrefix}${h}`,{replace:!0})}l.current=s}},[n,s,a,o])}r(zbe,"useCompanyPageMemory");var ytt=24,jtt=8;function Ube(e,s,n){const a=n&&!lfe(e,s).isTaskDetail,i=(0,m.useRef)(0),[o,l]=(0,m.useState)(!0),c=(0,m.useCallback)(d=>{const u=d-i.current;i.current=d,d<=ytt?l(!0):u>jtt?l(!1):u<-8&&l(!0)},[]);return(0,m.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(Ube,"useMobileNavAutoHide");function Kbe(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(Kbe,"resolveArchivedCompanyBounce");function wtt(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(wtt,"resolveCompanyArchiveDeparture");function Wbe(e){const{selectionSource:s,selectedCompanyId:n,routeCompanyId:a}=e;return!(n===a||s==="manual"&&n)}r(Wbe,"shouldSyncCompanySelectionFromRoute");function Ntt(e,s){return e instanceof HTMLElement?!(s instanceof HTMLElement)||!document.contains(s)||s===document.body||s===document.documentElement?!0:!e.contains(s):!1}r(Ntt,"shouldFocusMainContentAfterNavigation");function Vbe(e){if(!(e instanceof HTMLElement))return()=>{};const s=window.requestAnimationFrame(()=>{Ntt(e,document.activeElement)&&e.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(s)}r(Vbe,"scheduleMainContentFocus");function Hbe(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(Hbe,"pinDocumentScrollToZero");function ju({scope:e="global",requestedPrefix:s}){const n=ra(),{setBreadcrumbs:a}=Bn(),{companies:i,selectedCompany:o}=ps();(0,m.useEffect)(()=>{a([{label:"Not Found"}])},[a]);const l=o??i[0]??null,c=l?`/${l.issuePrefix}/dashboard`:"/",d=`${n.pathname}${n.search}${n.hash}`,u=s?.toUpperCase(),h=e==="invalid_company_prefix"?"Organization not found":"Page not found",p=e==="invalid_company_prefix"?`No organization matches prefix "${u??"unknown"}".`:"This route does not exist.";return(0,t.jsx)("div",{className:"mx-auto max-w-2xl py-10",children:(0,t.jsxs)(Js,{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)(_s,{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)(Qe,{to:c,children:[(0,t.jsx)(FR,{className:"mr-1.5 h-4 w-4"}),"Open dashboard"]})}),(0,t.jsx)(F,{variant:"outline",asChild:!0,children:(0,t.jsx)(Qe,{to:"/",children:"Go home"})})]})]})})}r(ju,"NotFoundPage");function ktt(e,s){return ofe(e,s)[0]?.toLowerCase()??null}r(ktt,"getCompanyRouteSegment$1");var Stt=new Set(["browse","connections","connect","chat","vercel-connect","review","attention","gateways","advanced","app"]);function Ctt({sidebarSections:e}){const{sidebarOpen:s,setSidebarOpen:n,toggleSidebar:a,collapsed:i,peeking:o,setPeeking:l,isMobile:c,setForceCollapsed:d}=Ua(),{openNewIssue:u,openOnboarding:h}=zo(),{togglePanelVisible:p}=Ef(),f=Rc()?.pushToast??null,{companies:g,loading:v,selectedCompany:y,selectedCompanyId:w,selectionSource:k,setSelectedCompanyId:j}=ps(),{companyPrefix:N,pluginRoutePath:_,agentId:I,routineId:C}=Ia(),T=Xn(),R=ra(),A=h3(),{enabled:L}=Tc(),D=lfe(R.pathname,N),O=D.builtInContextualSurface==="settings",E=D.companySegments,q=D.isTaskDetail,B=L&&q,U=E[0]?.toLowerCase()==="tools",z=E[0]?.toLowerCase()==="apps",$=z&&E[1]&&!Stt.has(E[1].toLowerCase())?E[1]:null,K=z&&E[1]?.toLowerCase()==="app"&&E[2]?E[2]:null,H=(0,m.useRef)(!1),se=(0,m.useRef)(null),Z=(0,m.useRef)(null),ie=(0,m.useRef)(new zhe),oe=(0,m.useRef)(R.key),Y=Ube(R.pathname,N,c),[ne,de]=(0,m.useState)(!1),ee=(0,m.useMemo)(()=>{if(!N)return null;const ut=N.toUpperCase();return g.find(Dt=>Dt.issuePrefix.toUpperCase()===ut)??null},[g,N]),X=!!N&&!v&&g.length>0&&!ee,Q=(0,m.useMemo)(()=>_?.toLowerCase()??ktt(R.pathname,N),[N,R.pathname,_]),fe=ee?.id??null,te=ee?.issuePrefix??null,{slots:ae}=ed({slotTypes:["page","routeSidebar"],companyId:fe,enabled:!!(fe&&Q)}),le=(0,m.useMemo)(()=>EK(ae,Q),[Q,ae]),ce=(0,m.useMemo)(()=>({companyId:fe,companyPrefix:te}),[fe,te]),he=O?(0,t.jsx)(_qe,{}):!L&&D.builtInContextualSurface==="skills"?(0,t.jsx)(mY,{}):$?(0,t.jsx)(dY,{kind:"connection",connectionId:$}):K?(0,t.jsx)(dY,{kind:"application",applicationId:K}):z||U?(0,t.jsx)(Lqe,{}):le?L?(0,t.jsx)(k_,{surface:`plugin:${le.id}`,title:le.displayName,children:(0,t.jsx)(Su,{slot:le,context:ce,className:"min-h-0 flex-1",missingBehavior:"placeholder"})}):(0,t.jsx)(Su,{slot:le,context:ce,className:"h-full w-full",missingBehavior:"placeholder"}):null,ve=D.builtInContextualSurface==="agent"&&I?(0,t.jsx)(Yqe,{agentRef:I}):L&&D.builtInContextualSurface==="routine"&&C?(0,t.jsx)(eFe,{children:(0,t.jsx)(Zqe,{routineId:C})}):L&&D.builtInContextualSurface==="skills"?(0,t.jsx)(mY,{}):he,pe=ve!=null,xe=L&&pe&&(D.builtInContextualSurface==="skills"||D.builtInContextualSurface==="agent"||D.builtInContextualSurface==="routine"||z||U),_e=L&&pe&&!xe,ge=pe&&(!L||xe),Ie=!L||!pe?null:le&&!D.builtInContextualSurface?`plugin:${le.id}`:D.builtInContextualSurface,Ye=(0,m.useRef)(null),{data:$e}=J({queryKey:P.health,queryFn:r(()=>cm.get(),"queryFn"),retry:!1,refetchInterval:r(ut=>ut.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1}),Xe=J({queryKey:P.instance.generalSettings,queryFn:r(()=>Tr.getGeneral(),"queryFn")}).data?.keyboardShortcuts===!0;(0,m.useLayoutEffect)(()=>(d(!L&&pe),()=>d(!1)),[pe,d,L]),(0,m.useEffect)(()=>{const ut=Ye.current;Ie&&N&&ut&&ut.surface!==Ie&&ut.pathname!==R.pathname&&kqe({surface:Ie,companyPrefix:N,previousPathname:ut.pathname}),Ye.current={pathname:R.pathname,surface:Ie}},[N,Ie,R.pathname]),(0,m.useEffect)(()=>{v||H.current||$e?.deploymentMode!=="authenticated"&&($e?.cloud||g.length===0&&(H.current=!0,h()))},[g,v,h,$e?.cloud,$e?.deploymentMode]),(0,m.useEffect)(()=>{if(!N||v||g.length===0)return;if(!ee){const Dt=(w?g.find(Jt=>Jt.id===w):null)??g[0]??null;Dt&&w!==Dt.id&&j(Dt.id,{source:"route_sync"});return}if(N!==ee.issuePrefix){const Dt=R.pathname.replace(/^\/[^/]+/,"");T(`/${ee.issuePrefix}${Dt}${R.search}`,{replace:!0});return}const ut=Kbe({matchedCompany:ee,selectedCompanyId:w,companies:g});if(ut){f?.({title:`${ee.name} is archived`,body:`Switched to ${ut.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${ee.id}`}),j(ut.id,{source:"route_sync"}),T(`/${ut.issuePrefix}/dashboard`,{replace:!0});return}Wbe({selectionSource:k,selectedCompanyId:w,routeCompanyId:ee.id})&&j(ee.id,{source:"route_sync"})},[N,g,v,ee,R.pathname,R.search,T,f,k,w,j]);const ue=p,Oe=(0,m.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),dt=(0,m.useRef)(null),xt=(0,m.useRef)(!1),Le=(0,m.useRef)(!1),Ge=(0,m.useCallback)(()=>{dt.current!==null&&(window.clearTimeout(dt.current),dt.current=null)},[]),ht=(0,m.useCallback)(()=>{Ge(),dt.current=window.setTimeout(()=>l(!0),50)},[Ge,l]),Ve=(0,m.useCallback)(()=>{Ge(),l(!0)},[Ge,l]),Ke=(0,m.useCallback)(()=>{Ge(),dt.current=window.setTimeout(()=>l(!1),120)},[Ge,l]),gt=(0,m.useCallback)(()=>{xt.current=!0,i&&!Le.current&&ht()},[i,ht]),tt=(0,m.useCallback)(()=>{xt.current=!1,Le.current=!1,Ke()},[Ke]),Se=(0,m.useCallback)(()=>{Le.current||Ve()},[Ve]),ke=(0,m.useCallback)(()=>{xt.current||Ke()},[Ke]);(0,m.useEffect)(()=>Ge,[Ge]);const Je=(0,m.useRef)(i);return(0,m.useEffect)(()=>{i!==Je.current&&(i?(Ge(),l(!1),Le.current=xt.current):Le.current=!1,Je.current=i)},[i,Ge,l]),(0,m.useEffect)(()=>{if(!o)return;const ut=r(Dt=>{Dt.key==="Escape"&&(Ge(),l(!1))},"onKeyDown");return window.addEventListener("keydown",ut),()=>window.removeEventListener("keydown",ut)},[o,Ge,l]),zbe(),Obe({enabled:Xe,onNewIssue:r(()=>u(),"onNewIssue"),onSearch:Oe,onToggleSidebar:a,onTogglePanel:ue,onShowShortcuts:r(()=>de(!0),"onShowShortcuts"),onGoToInbox:r(()=>T("/inbox"),"onGoToInbox")}),(0,m.useEffect)(()=>{if(!c)return;const ut=30,Dt=50,Jt=75;let fs=0,We=0;const He=r(ze=>{const is=ze.touches[0];fs=is.clientX,We=is.clientY},"onTouchStart"),ct=r(ze=>{const is=ze.changedTouches[0],Fe=is.clientX-fs;if(!(Math.abs(is.clientY-We)>Jt)){if(!s&&fs<ut&&Fe>Dt){n(!0);return}s&&Fe<-50&&n(!1)}},"onTouchEnd");return document.addEventListener("touchstart",He,{passive:!0}),document.addEventListener("touchend",ct,{passive:!0}),()=>{document.removeEventListener("touchstart",He),document.removeEventListener("touchend",ct)}},[c,s,n]),(0,m.useEffect)(()=>{const ut=document.body.style.overflow;return document.body.style.overflow=c?"visible":"clip",()=>{document.body.style.overflow=ut}},[c]),(0,m.useEffect)(()=>{if(!c)return Hbe()},[c]),(0,m.useEffect)(()=>{if(typeof document>"u")return;const ut=Z.current;return Vbe(ut)},[R.pathname]),(0,m.useEffect)(()=>{const ut=Z.current;if(!ut)return;const Dt=r(()=>{ie.current.remember(oe.current,ut.scrollTop)},"recordScroll");return ut.addEventListener("scroll",Dt,{passive:!0}),()=>ut.removeEventListener("scroll",Dt)},[]),(0,m.useLayoutEffect)(()=>{const ut=Z.current,Dt=qhe({previousPathname:se.current,pathname:R.pathname,navigationType:A,state:R.state});se.current=R.pathname;const Jt=A==="POP",fs=Jt?ie.current.recall(R.key):0;if(oe.current=R.key,Jt){s5(ut,fs);const We=requestAnimationFrame(()=>s5(ut,fs));return()=>cancelAnimationFrame(We)}Dt&&Uhe(ut)},[R.key,R.pathname,R.state,A]),(0,t.jsx)(Bhe,{children:(0,t.jsx)(Hue,{value:{keyboardShortcutsEnabled:Xe},children:(0,t.jsxs)("div",{className:W("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)(Abe,{}),(0,t.jsx)(Tbe,{devServer:$e?.devServer}),(0,t.jsxs)("div",{className:W("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:W("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:pe?(0,t.jsx)(yA,{children:ve}):(0,t.jsx)(iY,{children:e})})}),(0,t.jsx)(NZ,{deploymentMode:$e?.deploymentMode,forceExpanded:_e})]}):(0,t.jsxs)(Get,{open:s,collapsed:_e?!1:i,peeking:_e?!1:o,resizable:!0,onPanelMouseEnter:_e?void 0:gt,onPanelMouseLeave:_e?void 0:tt,onPanelFocusCapture:!_e&&i?Se:void 0,onPanelBlurCapture:!_e&&i?ke:void 0,children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0",children:_e?(0,t.jsx)(yA,{children:ve}):(0,t.jsx)(iY,{children:e})}),(0,t.jsx)(NZ,{deploymentMode:$e?.deploymentMode,forceExpanded:_e})]}),!c&&ge&&!xe?(0,t.jsx)(yA,{className:"w-60 shrink-0",children:ve}):null,(0,t.jsxs)("div",{className:W("flex min-w-0 flex-col",c?"w-full":"h-full flex-1"),children:[(0,t.jsxs)("div",{className:W(!c&&B&&"hidden",c&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:[(0,t.jsx)(m6,{mobile:c,onNavigateHome:r(()=>T("/dashboard"),"onNavigateHome")}),(0,t.jsx)(pY,{}),c&&O?(0,t.jsx)("div",{className:"border-b border-border px-4 pb-3",children:(0,t.jsx)(ufe,{})}):null]}),(0,t.jsxs)("div",{className:W(c?"block":"flex flex-1 min-h-0",!c&&B&&"streamlined-task-detail-surface"),children:[!c&&xe?(0,t.jsx)(yA,{className:"w-60 shrink-0 bg-background",children:ve}):null,(0,t.jsxs)("div",{className:W(!c&&B?"flex min-w-0 flex-1 flex-col":"contents"),children:[!c&&B?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m6,{mobile:!1,onNavigateHome:r(()=>T("/dashboard"),"onNavigateHome")}),(0,t.jsx)(pY,{taskDetailLayout:!0})]}):null,(0,t.jsx)("main",{id:"main-content",ref:Z,tabIndex:-1,style:c?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:W("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:X?(0,t.jsx)(ju,{scope:"invalid_company_prefix",requestedPrefix:N??y?.issuePrefix}):(0,t.jsx)(Pbe,{children:(0,t.jsx)(_0,{})})})]}),(0,t.jsx)(Nfe,{taskDetailLayout:!c&&B})]})]})]}),c&&(0,t.jsx)(Ibe,{visible:Y}),(0,t.jsx)(Cfe,{}),(0,t.jsx)(Ffe,{}),(0,t.jsx)(ybe,{}),(0,t.jsx)(Nbe,{}),(0,t.jsx)(kbe,{}),(0,t.jsx)(Sbe,{open:ne,onOpenChange:de}),(0,t.jsx)(Cbe,{}),(0,t.jsx)(yet,{health:$e}),(0,t.jsx)(_be,{localTrusted:$e?.deploymentMode==="local_trusted"})]})})})}r(Ctt,"Layout$1");var Gbe=(0,m.createContext)(!1);function _tt({children:e}){return(0,t.jsx)(Gbe.Provider,{value:!0,children:e})}r(_tt,"SidebarNavExpandedProvider");function Itt(){return(0,m.useContext)(Gbe)}r(Itt,"useSidebarNavExpanded");function Qa({to:e,label:s,icon:n,iconNode:a,end:i,className:o,labelClassName:l,badge:c,badgeTone:d="default",badgeLabel:u,textBadge:h,textBadgeTone:p="default",alert:f=!1,liveCount:g,active:v,trailing:y,trailingLabel:w,liveAccessory:k}){const{isMobile:j,setSidebarOpen:N,collapsed:_,peeking:I}=Ua(),C=Itt(),T=_&&!I&&!C,R=c!=null&&c>0,A=g!=null&&g>0,L=A?`${g} live`:R?`${c}${u?` ${u}`:""}`:f?"attention needed":void 0,D=!T||!L&&!w?void 0:`${s}${L?`, ${L}`:""}${w?`, ${w}`:""}`,O=(0,t.jsxs)(I0,{to:e,state:Af,end:i,"aria-label":D,onClick:r(()=>{j&&N(!1)},"onClick"),className:r(({isActive:E})=>W("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"}),T&&!f&&A&&(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)"})]}),T&&!f&&!A&&R&&(0,t.jsx)("span",{className:W("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:T?Qv:W("min-w-0 flex-1 truncate",l),children:s}),!T&&y,!T&&h&&(0,t.jsx)(ot,{variant:"ghost",className:W("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}),!T&&(A||k)&&(0,t.jsxs)("span",{className:"ml-auto flex items-center gap-1.5",children:[k,A&&(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"]})]})]}),!T&&R&&(0,t.jsx)(ot,{variant:"ghost",className:W("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 T?(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)("div",{children:O})}),(0,t.jsx)(Vn,{side:"right",children:s})]}):O}r(Qa,"SidebarNavItem");var Att=3,kZ=12e4,Ttt=[{value:"top",label:"Top"},{value:"alphabetical",label:"Alphabetical"},{value:"recent",label:"Recent"}];function Zy(e,s){const n=e[s];if(!n)return 0;const a=new Date(n).getTime();return Number.isFinite(a)?a:0}r(Zy,"agentTimestamp");function SZ(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=Zy(i,"lastHeartbeatAt")-Zy(a,"lastHeartbeatAt");if(o!==0)return o;const l=Zy(i,"updatedAt")-Zy(a,"updatedAt");if(l!==0)return l;const c=Zy(i,"createdAt")-Zy(a,"createdAt");return c!==0?c:a.name.localeCompare(i.name,void 0,{sensitivity:"base"})}),n)}r(SZ,"sortAgents");var Rtt="opacity-0 transition-opacity group-hover/agent:opacity-100 group-focus-within/agent:opacity-100";function Ett({activeAgentId:e,activeTab:s,agent:n,disabled:a,isMobile:i,leaving:o,onLeaveAgent:l,onPauseResume:c,rail:d,runCount:u,setSidebarOpen:h,builtInStatus:p,starred:f=!1,onToggleStar:g,starPending:v=!1}){const y=_c(n),w=s?`${tm(n)}/${s}`:tm(n),k=`${tm(n)}/configuration`,j=e===y,N=n.status==="paused",_=N&&n.pauseReason==="budget",I=n.orgChainHealth?.status==="invalid_org_chain",C=N?"Resume agent":"Pause agent",T=a||n.status==="pending_approval"||_||N&&I,R=a?"Updating...":_?"Budget paused":N&&I?"Invalid org chain":C,A=p==="needs_setup"||p==="pending_approval",L=[A?`Built-in agent ${p.replace(/_/g," ")}`:null,I?"Invalid reporting chain":null].filter(Boolean).join(", ")||void 0,D=(0,t.jsx)(Qa,{to:w,label:n.name,iconNode:(0,t.jsx)(yr,{agent:n,size:16,className:"shrink-0 h-4 w-4"}),active:j,liveCount:u,labelClassName:A?"min-w-(--sz-4_5rem) flex-initial":void 0,className:W("min-w-0 flex-1",f&&!i?"pr-14":"pr-8"),trailing:A||I?(0,t.jsxs)("span",{className:"ml-1 flex shrink-0 items-center gap-1",children:[A?(0,t.jsx)(mw,{status:p,compact:!0}):null,I?(0,t.jsx)(_s,{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)(j_,{title:"Agent paused by budget"}):void 0});return d?D:(0,t.jsxs)("div",{className:"group/agent relative flex items-center",children:[D,f&&!i&&g?(0,t.jsx)("span",{className:"absolute right-10 top-1/2 -translate-y-1/2",children:(0,t.jsx)(R0,{size:"row",quiet:!0,starred:!0,pending:v,resourceName:n.name,onToggle:r(()=>g(n,!1),"onToggle"),revealClassName:Rtt})}):null,(0,t.jsxs)(ja,{children:[(0,t.jsx)(ya,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-xs",className:W("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)(Mi,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(wa,{align:"end",className:"w-48",children:[g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(hs,{onClick:r(()=>{v||g(n,!f)},"onClick"),disabled:v,children:[v?(0,t.jsx)(rt,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Kh,{className:W("size-4",f&&"fill-amber-500 text-amber-500")}),(0,t.jsx)("span",{children:f?"Remove from starred":"Star agent"})]}),(0,t.jsx)(mi,{})]}):null,(0,t.jsx)(hs,{asChild:!0,children:(0,t.jsxs)(Qe,{to:k,onClick:r(()=>{i&&h(!1)},"onClick"),children:[(0,t.jsx)(Gl,{className:"size-4"}),(0,t.jsx)("span",{children:"Edit agent"})]})}),(0,t.jsx)(mi,{}),(0,t.jsxs)(hs,{onClick:r(()=>{T||c(n,N?"resume":"pause")},"onClick"),disabled:T,title:_?"Agent was paused by budget limits":void 0,children:[N?(0,t.jsx)(f_,{className:"size-4"}):(0,t.jsx)(xd,{className:"size-4"}),(0,t.jsx)("span",{children:R})]}),(0,t.jsx)(mi,{}),(0,t.jsxs)(hs,{onClick:r(()=>{o||l(n)},"onClick"),disabled:o,children:[o?(0,t.jsx)(rt,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(op,{className:"size-4"}),(0,t.jsx)("span",{children:o?"Leaving...":"Leave agent"})]})]})]})]})}r(Ett,"SidebarAgentItem");function Ptt({streamlined:e=!1}={}){const[s,n]=(0,m.useState)(!0),[a,i]=(0,m.useState)(()=>new Set),[o,l]=(0,m.useState)(0),c=(0,m.useRef)(new Map),d=Ut(),{selectedCompanyId:u}=ps(),{openNewAgent:h}=zo(),{isMobile:p,setSidebarOpen:f,collapsed:g,peeking:v}=Ua(),y=g&&!v,{pushToast:w}=fa(),k=ra(),{data:j}=J({queryKey:P.agents.list(u),queryFn:r(()=>Vt.list(u),"queryFn"),enabled:!!u}),{data:N}=J({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn"),enabled:!!u}),_=N?.enableBuiltInAgents===!0,{data:I}=J({queryKey:P.builtInAgents.list(u),queryFn:r(()=>Ch.list(u),"queryFn"),enabled:!!u&&_}),C=(0,m.useMemo)(()=>{const ge=new Map;if(!_)return ge;for(const Ie of I??[])Ie.agentId&&ge.set(Ie.agentId,Ie.status);return ge},[I,_]),{data:T}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn")}),R=Tf(u),A=Rf(u),L=P.liveRuns(u),D=fo({companyId:u,resourceKey:"live-runs",queryKey:L,enabled:!!u,refetchInterval:!1,leaderOnly:!0}),{data:O,dataUpdatedAt:E}=J({queryKey:L,queryFn:r(()=>Yr.liveRunsForCompany(u),"queryFn"),enabled:D.enabled,refetchInterval:D.refetchInterval});xo(D,O,E);const q=(0,m.useMemo)(()=>{const ge=new Map;for(const Ie of O??[])ge.set(Ie.agentId,(ge.get(Ie.agentId)??0)+1);return ge},[O]),B=(0,m.useMemo)(()=>{const ge=new Set;for(const[Ie,Ye]of q)Ye>0&&ge.add(Ie);return ge},[q]),U=(0,m.useMemo)(()=>(j??[]).filter(ge=>ge.status!=="terminated"&&(!R.isSuccess||Ox(R.data,"agent",ge.id)!=="left")),[j,R.data,R.isSuccess]),z=T?.user?.id??T?.session?.userId??null,$=(0,m.useMemo)(()=>u?Jhe(u,z):null,[z,u]),[K,H]=(0,m.useState)(()=>$?hw($):"top"),{orderedAgents:se}=tpe({agents:U,companyId:u,userId:z}),Z=(0,m.useMemo)(()=>SZ(se,K),[se,K]),ie=(0,m.useMemo)(()=>new Set(Z.map(ge=>ge.id)),[Z]);(0,m.useEffect)(()=>{const ge=Date.now();for(const Ie of B)c.current.set(Ie,ge);for(const Ie of c.current.keys())ie.has(Ie)||c.current.delete(Ie)},[B,ie]);const oe=(0,m.useMemo)(()=>{const ge=Date.now(),Ie=c.current;return Z.filter(Ye=>{if((q.get(Ye.id)??0)>0)return!0;const $e=Ie.get(Ye.id);return $e!==void 0&&ge-$e<=kZ})},[q,o,Z]),Y=oe.length>0,ne=e?Y?oe:Z.slice(0,Att):Z,de=e&&Z.length>0,ee=k.pathname.match(/^\/(?:[^/]+\/)?agents\/([^/]+)(?:\/([^/]+))?/),X=ee?.[1]??null,Q=ee?.[2]??null;(0,m.useEffect)(()=>{if(!$){H("top");return}H(hw($))},[$]),(0,m.useEffect)(()=>{if(!$)return;const ge=r(Ye=>{Ye.key===$&&H(hw($))},"onStorage"),Ie=r(Ye=>{const $e=Ye.detail;!$e||$e.storageKey!==$||H($e.sortMode)},"onCustomEvent");return window.addEventListener("storage",ge),window.addEventListener(VC,Ie),()=>{window.removeEventListener("storage",ge),window.removeEventListener(VC,Ie)}},[$]),(0,m.useEffect)(()=>{if(!e)return;const ge=Date.now();let Ie=null;for(const $e of Z){if((q.get($e.id)??0)>0)continue;const Xe=c.current.get($e.id);if(Xe===void 0)continue;const ue=Xe+kZ;ue<ge||(Ie=Ie===null?ue:Math.min(Ie,ue))}if(Ie===null)return;const Ye=window.setTimeout(()=>{l($e=>$e+1)},Math.max(0,Ie-ge+1));return()=>{window.clearTimeout(Ye)}},[e,Z,q,o]);const fe=(0,m.useCallback)(ge=>{const Ie=ge==="alphabetical"||ge==="recent"?ge:"top";H(Ie),$&&epe($,Ie)},[$]),te=Ne({mutationFn:r(({agent:ge,action:Ie})=>Ie==="pause"?Vt.pause(ge.id,u??void 0):Vt.resume(ge.id,u??void 0),"mutationFn"),onMutate:r(({agent:ge})=>{i(Ie=>{const Ye=new Set(Ie);return Ye.add(ge.id),Ye})},"onMutate"),onSuccess:r(async(ge,{agent:Ie,action:Ye})=>{u&&await Promise.all([d.invalidateQueries({queryKey:P.agents.list(u)}),d.invalidateQueries({queryKey:P.liveRuns(u)}),d.invalidateQueries({queryKey:P.dashboard(u)})]),await Promise.all([d.invalidateQueries({queryKey:P.agents.detail(Ie.id)}),d.invalidateQueries({queryKey:P.agents.detail(_c(Ie))})]),w({title:Ye==="pause"?"Agent paused":"Agent resumed",body:Ie.name,tone:"success"})},"onSuccess"),onError:r((ge,{agent:Ie,action:Ye})=>{w({title:Ye==="pause"?"Could not pause agent":"Could not resume agent",body:ge instanceof Error?ge.message:Ie.name,tone:"error"})},"onError"),onSettled:r((ge,Ie,{agent:Ye})=>{i($e=>{const Xe=new Set($e);return Xe.delete(Ye.id),Xe})},"onSettled")}),ae=(0,m.useCallback)(ge=>A.mutate({resourceType:"agent",resourceId:ge.id,resourceName:ge.name,state:"left"}),[A]),le=(0,m.useCallback)(ge=>A.isPending&&A.variables?.resourceType==="agent"&&A.variables.resourceId===ge.id,[A.isPending,A.variables]),ce=(0,m.useCallback)((ge,Ie)=>A.mutate({resourceType:"agent",resourceId:ge.id,resourceName:ge.name,starred:Ie}),[A]),he=(0,m.useCallback)(ge=>A.isPending&&A.variables?.resourceType==="agent"&&A.variables.resourceId===ge.id&&A.variables.starred!==void 0,[A.isPending,A.variables]),ve=(0,m.useMemo)(()=>new Set(F3(R.data,"agent")),[R.data]),pe=(0,m.useMemo)(()=>SZ(U.filter(ge=>ve.has(ge.id)),"alphabetical"),[U,ve]),xe=(0,m.useMemo)(()=>ne.filter(ge=>!ve.has(ge.id)),[ne,ve]),_e=r((ge,Ie)=>(0,t.jsx)(Ett,{activeAgentId:X,activeTab:Q,agent:ge,disabled:a.has(ge.id),isMobile:p,leaving:le(ge),onLeaveAgent:ae,onPauseResume:r((Ye,$e)=>te.mutate({agent:Ye,action:$e}),"onPauseResume"),rail:y,runCount:q.get(ge.id)??0,setSidebarOpen:f,builtInStatus:C.get(ge.id),starred:Ie||T0(R.data,"agent",ge.id),onToggleStar:ce,starPending:he(ge)},ge.id),"renderAgentRow");return(0,t.jsxs)(Ix,{label:"Agents",collapsible:{open:s,onOpenChange:n},headerAction:{ariaLabel:"New agent",icon:vn,onClick:h},menu:{ariaLabel:"Agents section actions",actions:[{type:"item",label:"Browse agents",icon:al,href:"/agents/all"},{type:"separator"}],radioLabel:"Agent sort",radioChoices:Ttt,radioValue:K,onRadioValueChange:fe},children:[pe.map(ge=>_e(ge,!0)),xe.map(ge=>_e(ge,!1)),de&&(()=>{const ge=(0,t.jsxs)(Qe,{to:"/agents/all",state:Af,"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)(al,{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)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:ge}),(0,t.jsx)(Vn,{side:"right",children:"See all agents"})]}):ge})()]})}r(Ptt,"SidebarAgents");var Mtt="opacity-0 transition-opacity group-hover/starred-project:opacity-100 group-focus-within/starred-project:opacity-100";function Ltt(){const{selectedCompanyId:e}=ps(),{isMobile:s,setSidebarOpen:n,collapsed:a,peeking:i}=Ua(),o=a&&!i,l=ra(),{data:c}=J({queryKey:P.projects.list(e),queryFn:r(()=>pa.list(e),"queryFn"),enabled:!!e}),d=Tf(e),u=Rf(e),h=l.pathname.match(/^\/(?:[^/]+\/)?projects\/([^/]+)/)?.[1]??null,p=(0,m.useMemo)(()=>{if(!d.isSuccess)return[];const y=new Set(F3(d.data,"project"));if(y.size===0)return[];const w=new Map((c??[]).map(k=>[k.id,k]));return Array.from(y).map(k=>w.get(k)).filter(k=>!!k).sort((k,j)=>k.name.localeCompare(j.name,void 0,{sensitivity:"base"}))},[d.data,d.isSuccess,c]),f=(0,m.useCallback)(y=>u.mutate({resourceType:"project",resourceId:y.id,resourceName:y.name,starred:!1}),[u]),g=(0,m.useCallback)(y=>u.mutate({resourceType:"project",resourceId:y.id,resourceName:y.name,state:"left"}),[u]),v=(0,m.useCallback)(y=>u.isPending&&u.variables?.resourceType==="project"&&u.variables.resourceId===y.id,[u.isPending,u.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=S0(y),k=h===w||h===y.id,j=v(y),N=j&&u.variables?.starred===!1,_=j&&u.variables?.state==="left",I=T0(d.data,"project",y.id),C=(0,t.jsxs)(I0,{to:`/projects/${w}/issues`,state:Af,onClick:r(()=>{s&&n(!1)},"onClick"),className:W("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",k?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50 hover:text-foreground"),children:[(0,t.jsx)(nh,{color:y.color??null,icon:y.icon??null,size:"xs"}),(0,t.jsx)("span",{className:o?Qv:"flex-1 truncate",children:y.name}),!o&&y.pauseReason==="budget"?(0,t.jsx)(j_,{title:"Project paused by budget"}):null]});return(0,t.jsxs)("div",{className:"group/starred-project relative flex items-center",children:[o?(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)("div",{className:"min-w-0 flex-1",children:C})}),(0,t.jsx)(Vn,{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)(R0,{size:"row",quiet:!0,starred:I,pending:N,resourceName:y.name,onToggle:r(()=>f(y),"onToggle"),revealClassName:Mtt})}):null,!o&&s?(0,t.jsxs)(ja,{children:[(0,t.jsx)(ya,{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)(Mi,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(wa,{align:"end",className:"w-48",children:[(0,t.jsxs)(hs,{onClick:r(()=>{j||f(y)},"onClick"),disabled:j,children:[N?(0,t.jsx)(rt,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(Kh,{className:"size-4 fill-amber-500 text-amber-500"}),(0,t.jsx)("span",{children:"Remove from starred"})]}),(0,t.jsx)(mi,{}),(0,t.jsxs)(hs,{onClick:r(()=>{j||g(y)},"onClick"),disabled:j,children:[_?(0,t.jsx)(rt,{className:"size-4 motion-safe:animate-spin"}):(0,t.jsx)(op,{className:"size-4"}),(0,t.jsx)("span",{children:"Leave project"})]})]})]}):null]},y.id)})})}r(Ltt,"SidebarStarredProjects");var Qbe="size-5 shrink-0 rounded-md text-(length:--text-micro)",Ybe="size-(--organization-popover-avatar-size) shrink-0 rounded-lg text-(length:--text-micro)",Xbe="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",aD="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 Jbe({company:e,inPopover:s=!1}){return(0,t.jsx)(Qx,{companyName:e.name,logoUrl:e.logoUrl,className:s?Ybe:Qbe})}r(Jbe,"WorkspaceIcon");function Dtt({displayName:e}){return(0,t.jsx)(Qx,{companyName:e,className:Ybe})}r(Dtt,"StackIcon");function $tt({displayName:e,company:s}){return(0,t.jsx)(Qx,{companyName:e,logoUrl:s?.logoUrl,className:Qbe})}r($tt,"CurrentStackIcon");function Ott({stack:e,isSelected:s,onSelect:n}){return(0,t.jsxs)(hs,{onSelect:r(()=>n(e),"onSelect"),className:Xbe,children:[(0,t.jsx)(Dtt,{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)(ds,{className:"size-4 text-foreground"}):null})]})}r(Ott,"CloudStackItem");function Ftt({company:e,isEditing:s,isSelected:n,onSelect:a}){const{attributes:i,listeners:o,setActivatorNodeRef:l,setNodeRef:c,transform:d,transition:u,isDragging:h}=MN({id:e.id,disabled:!s});return(0,t.jsxs)(hs,{ref:c,style:{transform:RN.Transform.toString(d),transition:u,zIndex:h?10:void 0},onSelect:r(p=>{if(s){p.preventDefault();return}a(e)},"onSelect"),className:W(Xbe,s&&"cursor-grab",h&&"opacity-80"),children:[(0,t.jsx)(Jbe,{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)(R3,{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)(ds,{className:"size-4 text-foreground"}):null})]})}r(Ftt,"SortableCompanyItem");function Btt(e={}){return(0,t.jsx)(tfe,{...e,children:(0,t.jsx)(qtt,{...e})})}r(Btt,"SidebarCompanyMenu");function qtt({open:e,onOpenChange:s}){const[n,a]=(0,m.useState)(!1),[i,o]=(0,m.useState)(!1),{companies:l,selectedCompany:c,setSelectedCompanyId:d,companyListUnavailable:u,retryCompanies:h}=ps(),{openOnboarding:p}=zo(),{isMobile:f,setSidebarOpen:g,collapsed:v,peeking:y}=Ua(),w=v&&!y,k=ra(),j=Xn(),N=e??n,_=s??a,I=PN(bf(WU,{activationConstraint:{distance:8}}),bf(Gue,{activationConstraint:{delay:180,tolerance:6}})),C=(0,m.useMemo)(()=>l.filter(Q=>Q.status!=="archived"),[l]),{data:T}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),R=T?.user?.id??T?.session?.userId??null,{orderedCompanies:A,persistOrder:L}=Zpe({companies:C,userId:R}),D=td(),O=!!D,{hidden:E,loaded:q}=uh(),B=q&&!OC(E,"company.members")&&!OC(E,"company.invites"),U=D?.cloudBaseUrl??null,z=J({queryKey:P.cloud.stacks,queryFn:r(()=>Xpe.listStacks(),"queryFn"),enabled:O,staleTime:3e4,retry:!1}),$=z.data?.stacks??[],K=O?$.find(Q=>Q.isCurrent)??$.find(Q=>!!D?.stackSlug&&Q.stackSlug===D?.stackSlug)??null:null,H=O?U3(U):null,se=O?"organization":"company",Z=O?K?.displayName??D?.stackDisplayName??D?.stackSlug??null:c?.name??null,ie=WN({onSignedOut:Y});function oe(Q){Q||o(!1),_(Q)}r(oe,"handleOpenChange");function Y(){_(!1),o(!1),f&&g(!1)}r(Y,"closeNavigationChrome");function ne(Q){const fe=k.pathname.split("/")[1]?.toUpperCase(),te=C.some(le=>le.issuePrefix.toUpperCase()===fe),ae=Q.id!==c?.id&&(k.pathname.startsWith("/instance/")||te);d(Q.id),_(!1),f&&g(!1),ae&&j(`/${Q.issuePrefix}/dashboard`)}r(ne,"selectCompany");function de(Q){if(_(!1),f&&g(!1),Q.stackSlug===K?.stackSlug)return;const fe=efe(U,Q.stackSlug);fe&&Ac(fe)}r(de,"selectStack");function ee(){if(_(!1),f&&g(!1),O){H&&Ac(H);return}p({initialStep:1})}r(ee,"addCompany");const X=(0,m.useCallback)(Q=>{const{active:fe,over:te}=Q;if(!te||fe.id===te.id)return;const ae=A.map(he=>he.id),le=ae.indexOf(fe.id),ce=ae.indexOf(te.id);le===-1||ce===-1||L(f3(ae,le,ce))},[A,L]);return(0,t.jsxs)(ja,{open:N,onOpenChange:oe,children:[(0,t.jsx)(ya,{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":Z?`Open ${Z} ${se} switcher`:`Open ${se} switcher`,children:[(0,t.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[O?Z?(0,t.jsx)($tt,{displayName:Z,company:c}):null:c?(0,t.jsx)(Jbe,{company:c}):null,(0,t.jsx)("span",{className:W("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:Z??void 0,children:Z??(O?"Select organization":"Select company")})]}),!w&&(0,t.jsx)(S3,{className:"size-3.5 shrink-0 text-muted-foreground"})]})}),(0,t.jsxs)(wa,{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)(DN,{className:"p-0 text-(length:--text-compact) font-semibold text-foreground",children:"Organizations"}),O?null:(0,t.jsx)("button",{type:"button",onClick:r(Q=>{Q.preventDefault(),Q.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:O?(0,t.jsxs)(t.Fragment,{children:[$.map(Q=>(0,t.jsx)(Ott,{stack:Q,isSelected:Q.stackSlug===K?.stackSlug,onSelect:de},Q.stackSlug)),$.length===0?(0,t.jsx)(hs,{disabled:!0,children:z.isLoading?"Loading organizations...":z.isError?"Could not load organizations":"No organizations"}):null]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(TN,{sensors:I,collisionDetection:e_,onDragEnd:X,children:(0,t.jsx)(AN,{items:A.map(Q=>Q.id),strategy:X1,children:A.map(Q=>(0,t.jsx)(Ftt,{company:Q,isEditing:i,isSelected:Q.id===c?.id,onSelect:ne},Q.id))})}),A.length===0?u?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(hs,{disabled:!0,children:"Couldn't load companies"}),(0,t.jsxs)(hs,{onSelect:r(Q=>{Q.preventDefault(),h()},"onSelect"),children:[(0,t.jsx)(Bi,{className:"h-4 w-4 mr-2"}),"Try again"]})]}):(0,t.jsx)(hs,{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:[O&&!H?null:(0,t.jsxs)(hs,{onClick:ee,className:aD,disabled:i,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(vn,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:"Create organization"})]}),B?(0,t.jsx)(hs,{asChild:!0,disabled:i,className:aD,children:(0,t.jsxs)(Qe,{to:"/company/settings/invites",onClick:r(Q=>{if(i){Q.preventDefault();return}Y()},"onClick"),children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(ry,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:Z?`Invite people to ${Z}`:"Invite people"})]})}):null,T?.session?(0,t.jsxs)(hs,{className:aD,onClick:r(()=>ie.mutate(),"onClick"),disabled:i||ie.isPending,children:[(0,t.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:(0,t.jsx)(op,{className:"size-4"})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:ie.isPending?"Signing out...":"Sign out"})]}):null]})]})]})}r(qtt,"BuiltinCompanyMenu");function CZ(){const{openNewIssue:e}=zo(),[s,n]=(0,m.useState)(!0),[a,i]=(0,m.useState)(!0),{selectedCompanyId:o,selectedCompany:l}=ps(),{collapsed:c,peeking:d}=Ua(),u=c&&!d,h=BK(o),{data:p,isFetched:f}=J({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn")}),g=P.liveRuns(o),v=fo({companyId:o,resourceKey:"live-runs",queryKey:g,enabled:!!o,refetchInterval:!1,leaderOnly:!0}),{data:y,dataUpdatedAt:w}=J({queryKey:g,queryFn:r(()=>Yr.liveRunsForCompany(o),"queryFn"),enabled:v.enabled,refetchInterval:v.refetchInterval});xo(v,y,w);const k=y?.length??0,j=p?.enableIsolatedWorkspaces===!0,N=p?.enableApps===!0,_=p?.enablePipelines===!0,I=p?.enableStatusCards===!0,C=!f,T=p?.enableGoalsSidebarLink===!0,R=p?.enableDecisions===!0,{data:A}=J({queryKey:P.attention(o),queryFn:r(()=>zN.list(o),"queryFn"),enabled:!!o&&R,refetchInterval:6e4}),L=Ipe(A),D=p?.enableCases===!0,O=!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)(Btt,{})}),(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":u?"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)(b_,{className:"h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:u?Qv:"truncate",children:"New Task"})]});return u?(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:B}),(0,t.jsx)(Vn,{side:"right",children:"New Task"})]}):B})(),(0,t.jsx)(Qa,{to:"/search",label:"Search",icon:ha}),(0,t.jsx)(Qa,{to:"/dashboard",label:"Dashboard",icon:_x,liveCount:k}),(0,t.jsx)(Qa,{to:"/inbox",label:"Inbox",icon:gd,badge:h.inbox,badgeLabel:"unread",badgeTone:h.failedRuns>0?"danger":"default",alert:h.failedRuns>0}),R?(0,t.jsx)(Qa,{to:"/decisions",label:"Decisions",icon:g_,badge:L,badgeLabel:"decisions"}):null,I?(0,t.jsx)(Qa,{to:"/status",label:"Status",icon:BN,textBadge:"beta"}):null,E?(0,t.jsx)(Qa,{to:"/board-chat",label:"Conference Room",icon:ghe}):null]}),(0,t.jsxs)(Ix,{label:"Work",collapsible:{open:s,onOpenChange:n},children:[(0,t.jsx)(Qa,{to:"/issues",label:"Tasks",icon:hd}),D?(0,t.jsx)(Qa,{to:"/cases",label:"Cases",icon:bl,textBadge:"beta"}):null,(0,t.jsx)(Qa,{to:"/routines",label:"Routines",icon:yu}),_?(0,t.jsx)(Qa,{to:"/pipelines",label:"Pipelines",icon:Bo}):null,T?(0,t.jsx)(Qa,{to:"/goals",label:"Goals",icon:vf}):C?(0,t.jsx)("div",{"data-testid":"sidebar-goals-placeholder",className:"h-8 pointer-coarse:h-7","aria-hidden":"true"}):null,(0,t.jsx)(Qa,{to:"/artifacts",label:"Artifacts",icon:Wh}),(0,t.jsx)(Qa,{to:"/skills",label:"Skills",icon:Hl}),j?(0,t.jsx)(Qa,{to:"/workspaces",label:"Workspaces",icon:Bo}):null,(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Qa,{to:"/projects",label:"Projects",icon:Ao}),(0,t.jsx)(Ltt,{})]}),(0,t.jsx)(tp,{slotTypes:["sidebar"],context:q,className:"flex flex-col gap-0.5",itemClassName:"text-(length:--text-compact) font-medium",missingBehavior:"placeholder"}),(0,t.jsx)(KN,{placementZones:["sidebar"],context:q,className:"flex flex-col gap-0.5",itemClassName:"text-(length:--text-compact) font-medium"})]}),null,(0,t.jsx)(Ptt,{streamlined:O}),(0,t.jsxs)(Ix,{label:"Company",collapsible:{open:a,onOpenChange:i},children:[(0,t.jsx)(Qa,{to:"/org",label:"Org",icon:wv}),N?(0,t.jsx)(Qa,{to:"/apps",label:"Connectors",icon:e5}):null,(0,t.jsx)(Qa,{to:"/timeline",label:"Timeline",icon:$g}),(0,t.jsx)(Qa,{to:"/costs",label:"Costs",icon:Oh}),(0,t.jsx)(Qa,{to:"/activity",label:"Activity",icon:Tl}),(0,t.jsx)(Qa,{to:"/company/settings",label:"Settings",icon:zd})]}),(0,t.jsx)(tp,{slotTypes:["sidebarPanel"],context:q,className:"flex flex-col gap-3",itemClassName:"rounded-lg border border-border p-3",missingBehavior:"placeholder"})]})]})}r(CZ,"Sidebar");function ztt(e){const s=e.manifestJson.environmentDrivers??[];return s.length===0?!1:s.every(n=>n.kind==="sandbox_provider")}r(ztt,"isSandboxProviderOnly");function Utt(){const{selectedCompany:e,selectedCompanyId:s}=ps(),{isMobile:n,setSidebarOpen:a}=Ua(),{hidden:i}=uh(),o=r(f=>!i.has(f),"showPage"),l=o("instance.plugins"),c=!!td(),{slots:d}=ed({slotTypes:["companySettingsPage"],companyId:s,enabled:!!s}),{data:u}=J({queryKey:s?P.sidebarBadges(s):["sidebar-badges","__disabled__"],queryFn:r(async()=>{try{return await ife.get(s)}catch(f){if(f instanceof cn&&(f.status===401||f.status===403))return null;throw f}},"queryFn"),enabled:!!s,retry:!1,refetchInterval:15e3}),{data:h}=J({queryKey:P.plugins.all,queryFn:r(()=>rl.list(),"queryFn"),enabled:l}),p=(h??[]).filter(f=>!ztt(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)(Qe,{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)(Nu,{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)(Qa,{to:"/company/settings",label:"General",icon:um,end:!0}),o("instance.profile")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/profile",label:"Profile",icon:v_,end:!0}),o("company.members")&&(0,t.jsx)(Qa,{to:"/company/settings/members",label:"Members",icon:al,badge:u?.joinRequests??0,end:!0}),d.filter(f=>f.routePath).map(f=>(0,t.jsx)(Qa,{to:`/company/settings/${f.routePath}`,label:f.displayName,icon:Zg,end:!0},`${f.pluginKey}:${f.id}`)),o("company.invites")&&(0,t.jsx)(Qa,{to:"/company/settings/invites",label:"Invites",icon:k4e,end:!0}),o("company.secrets")&&(0,t.jsx)(Qa,{to:"/company/settings/secrets",label:"Secrets",icon:ji,end:!0}),o("instance.environments")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/environments",label:"Environments",icon:bhe,end:!0}),o("instance.access")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/access",label:"Access",icon:y3,end:!0}),o("instance.heartbeats")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/heartbeats",label:"Heartbeats",icon:dm,end:!0}),o("company.export")&&(0,t.jsx)(Qa,{to:"/company/export",label:"Export",icon:To}),!c&&o("company.import")&&(0,t.jsx)(Qa,{to:"/company/import",label:"Import",icon:Vw,end:!0}),o("instance.experimental")&&(0,t.jsx)(Qa,{to:"/company/settings/instance/experimental",label:"Experimental",icon:om}),l&&(0,t.jsx)(Qa,{to:"/company/settings/instance/plugins",label:"Plugins",icon:Zg}),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)(I0,{to:`${_h}/plugins/${f.id}`,state:Af,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)(Qa,{to:"/company/settings/instance/adapters",label:"Adapters",icon:Vm})]})})]})}r(Utt,"CompanySettingsSidebar");function Ktt(){const{pathname:e}=ra(),{selectedCompany:s}=ps(),{isMobile:n,setSidebarOpen:a}=Ua(),i=pfe(),{enabled:o}=K3(),l=WK.filter(d=>!hfe(d.key)||o);if(e.endsWith("/apps/chat/connect"))return(0,t.jsx)(jK,{});const c=e.match(/\/apps\/chat\/([^/]+)(?:\/(?:settings|access|reviews|conversations|activity|approvals|audit))?\/?$/);return c?(0,t.jsx)(mfe,{endpointId:c[1],NavItem:Qa}):(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)(Qe,{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)(Nu,{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)(lQ,{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)(Qa,{to:"/apps",label:"Browse",icon:KC,end:!0}),(0,t.jsx)(Qa,{to:"/apps/review",label:"Review",icon:qN,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)(Qa,{to:"/apps/connections",label:"Connections",icon:lQ,end:!0}),l.map(d=>(0,t.jsx)(Qa,{to:t0(d.key),label:d.label,icon:d.icon,end:!0},d.key))]})]})]})}r(Ktt,"AppsSidebar");function _Z(e){const{selectedCompanyId:s}=ps(),{isMobile:n,setSidebarOpen:a}=Ua(),i=J({queryKey:P.tools.connection(e.kind==="connection"?e.connectionId:"__none__"),queryFn:r(()=>cs.getConnection(e.kind==="connection"?e.connectionId:""),"queryFn"),enabled:e.kind==="connection"&&!!e.connectionId}),o=J({queryKey:P.tools.applications(s??"__none__"),queryFn:r(()=>cs.listApplications(s),"queryFn"),enabled:e.kind==="application"&&!!s}),l=J({queryKey:P.tools.connections(s??"__none__"),queryFn:r(()=>cs.listConnections(s),"queryFn"),enabled:e.kind==="application"&&!!s}),c=J({queryKey:P.apps.gallery(s??"__none__"),queryFn:r(()=>cs.listGallery(s),"queryFn"),enabled:!!s}),d=J({queryKey:P.apps.attention(s??"__none__"),queryFn:r(()=>cs.listAppsAttention(s),"queryFn"),enabled:!!s,refetchInterval:3e4}),u=i.data,h=e.kind==="application"?(o.data?.applications??[]).find(k=>k.id===e.applicationId):null,p=Htt(e.kind==="application"?(l.data?.connections??[]).filter(k=>k.applicationId===e.applicationId):[]),f=u?wf(u):h?.name??"App",g=Vtt(c.data?.apps??[],u,h??void 0),v=u?.id??p?.id??null,y=v?d.data?.apps.find(k=>k.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)(Qe,{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)(Nu,{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)(Cc,{name:f,logoUrl:S_(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:W3.map(k=>(0,t.jsx)(Qa,{to:Wtt(e,k.key),label:k.label,icon:k.icon,end:!0,badge:k.key==="review"&&w>0?w:void 0,badgeTone:"danger",badgeLabel:"needing review"},k.key))})})]})}r(_Z,"AppDetailSidebar");function Wtt(e,s){return e.kind==="connection"?Yu(e.connectionId,s):oC(e.applicationId,s)}r(Wtt,"tabHref");function Vtt(e,s,n){if(n?.applicationKey){const i=e.find(o=>Vc(o)===n.applicationKey);if(i)return i}const a=(s?.name??n?.name)?.toLowerCase();return a?e.find(i=>b0(i).toLowerCase()===a)??e.find(i=>Vc(i)===a)??null:null}r(Vtt,"galleryEntryFor$1");function Htt(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(Htt,"latestArchivedConnection$1");function iD({identifier:e}){return e?(0,t.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e}):null}r(iD,"CrumbIdentifier");function Gtt({context:e}){const{slots:s}=ed({slotTypes:["globalToolbarButton"],companyId:e.companyId}),{launchers:n}=qK({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)(tp,{slotTypes:["globalToolbarButton"],context:e,className:"flex items-center gap-1"}):null,n.length>0?(0,t.jsx)(KN,{placementZones:["globalToolbarButton"],context:e,className:"flex items-center gap-1"}):null]})}r(Gtt,"GlobalToolbar");function Qtt(){const{breadcrumbs:e,mobileToolbar:s}=Bn(),{toggleSidebar:n,isMobile:a}=Ua(),{selectedCompanyId:i,selectedCompany:o}=ps(),l=(0,m.useMemo)(()=>({companyId:i??null,companyPrefix:o?.issuePrefix??null}),[i,o?.issuePrefix]),c=(0,t.jsx)(Gtt,{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)(phe,{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)(iD,{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)(VK,{className:"min-w-0 overflow-hidden",children:(0,t.jsx)(HK,{className:"flex-nowrap",children:e.map((u,h)=>{const p=h===e.length-1;return(0,t.jsxs)(m.Fragment,{children:[h>0&&(0,t.jsx)(u5,{}),(0,t.jsx)(lC,{className:p?"min-w-0":"shrink-0",children:p||!u.href?u.leading||u.identifier?(0,t.jsxs)(XC,{className:"flex min-w-0 items-center gap-1.5",children:[u.leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:u.leading}),(0,t.jsx)(iD,{identifier:u.identifier}),(0,t.jsx)("span",{className:"truncate",children:u.label})]}):(0,t.jsx)(XC,{className:"truncate",children:u.label}):(0,t.jsx)(d5,{asChild:!0,children:u.leading||u.identifier?(0,t.jsxs)(Qe,{to:u.href,onClick:u.onClick,className:"flex items-center gap-1.5",children:[u.leading&&(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:u.leading}),(0,t.jsx)(iD,{identifier:u.identifier}),(0,t.jsx)("span",{className:"truncate",children:u.label})]}):(0,t.jsx)(Qe,{to:u.href,onClick:u.onClick,children:u.label})})})]},h)})})})}),c]})}r(Qtt,"BreadcrumbBar");var wA=240,b6=208,v6=420,IZ=16;function V5(e){return Math.min(v6,Math.max(b6,e))}r(V5,"clampSidebarWidth");function AZ(e){if(typeof window>"u")return wA;try{const s=window.localStorage.getItem(e);if(!s)return wA;const n=Number.parseInt(s,10);return Number.isFinite(n)?V5(n):wA}catch{return wA}}r(AZ,"readStoredSidebarWidth");function TZ(e,s){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(V5(s)))}catch{}}r(TZ,"writeStoredSidebarWidth");function Ytt({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:u,onPanelBlurCapture:h}){const[p,f]=(0,m.useState)(()=>AZ(o)),[g,v]=(0,m.useState)(!1),y=(0,m.useRef)(p),w=(0,m.useRef)(null);(0,m.useEffect)(()=>{const E=AZ(o);y.current=E,f(E)},[o]);const k=s?p:0,j=s?n?64:k:0,N=s?n&&!a?64:k:0,_=N>j,I=i&&s&&!n,C=(0,m.useMemo)(()=>({width:`${j}px`}),[j]),T=(0,m.useMemo)(()=>({width:`${N}px`}),[N]),R=(0,m.useCallback)(E=>{const q=V5(E);y.current=q,f(q),TZ(o,q)},[o]),A=(0,m.useCallback)(E=>{I&&(E.preventDefault(),E.currentTarget.setPointerCapture(E.pointerId),w.current={startX:E.clientX,startWidth:y.current},v(!0))},[I]),L=(0,m.useCallback)(E=>{if(!w.current)return;const q=V5(w.current.startWidth+E.clientX-w.current.startX);y.current=q,f(q)},[]),D=(0,m.useCallback)(()=>{w.current&&(w.current=null,v(!1),TZ(o,y.current))},[o]),O=(0,m.useCallback)(E=>{I&&(E.key==="ArrowLeft"?(E.preventDefault(),R(p-IZ)):E.key==="ArrowRight"?(E.preventDefault(),R(p+IZ)):E.key==="Home"?(E.preventDefault(),R(b6)):E.key==="End"&&(E.preventDefault(),R(v6)))},[I,R,p]);return(0,t.jsx)("div",{className:W("relative h-full shrink-0",l),style:C,children:(0,t.jsxs)("div",{className:W("absolute inset-y-0 left-0 flex flex-col overflow-hidden",_?"z-30 border-r border-border bg-background shadow-lg":"z-0"),style:T,"data-sidebar-overlay":_?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:u,onBlurCapture:h,children:[e,I?(0,t.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":b6,"aria-valuemax":v6,"aria-valuenow":p,tabIndex:0,className:W("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:A,onPointerMove:L,onPointerUp:D,onPointerCancel:D,onLostPointerCapture:D,onKeyDown:O}):null]})})}r(Ytt,"SidebarShell");function Xtt({children:e,className:s}){return(0,t.jsx)("div",{"data-secondary-sidebar":"",className:W("h-full w-60 shrink-0 overflow-y-auto border-r border-border bg-background",s),children:(0,t.jsx)(_tt,{children:e})})}r(Xtt,"SecondarySidebar");var Jtt="/company/settings/instance/profile",Ztt="https://docs.paperclip.ing/",est="https://paperclip.ing/feedback";function tst(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(tst,"deriveInitials$1");function sst(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(sst,"deriveUserSlug");function oD({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)(Qe,{to:i,className:l,onClick:a,children:c}):(0,t.jsx)("button",{type:"button",className:l,onClick:a,children:c})}r(oD,"MenuAction");function RZ({deploymentMode:e,open:s,onOpenChange:n}){const a=!!td(),[i,o]=(0,m.useState)(!1),{isMobile:l,setSidebarOpen:c,collapsed:d,peeking:u}=Ua(),h=d&&!u,p=s??i,f=n??o,{data:g}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),v=WN({onSignedOut:N}),y=g?.user.name?.trim()||"Board",w=g?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),k=tst(y),j=`/u/${sst(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:W("flex items-center gap-0.5",!h&&"px-2"),children:[(0,t.jsxs)(tr,{open:p,onOpenChange:f,children:[(0,t.jsx)(pr,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:W("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)(Xi,{size:"sm",children:[g?.user.image?(0,t.jsx)(Jc,{src:g.user.image,alt:y}):null,(0,t.jsx)(Ji,{children:k})]}),(0,t.jsx)("span",{className:W("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)(Qn,{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)(Xi,{size:"lg",children:[g?.user.image?(0,t.jsx)(Jc,{src:g.user.image,alt:y}):null,(0,t.jsx)(Ji,{children:k})]})}),(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)(oD,{label:"View profile",description:"Open your activity, task, and usage ledger.",icon:ku,href:j,onClick:N}),(0,t.jsx)(oD,{label:"Edit profile",description:"Update your display name and avatar.",icon:v_,href:Jtt,onClick:N}),(0,t.jsx)(oD,{label:"Documentation",description:"Open Paperclip docs in a new tab.",icon:FN,href:Ztt,external:!0,onClick:r(()=>f(!1),"onClick")}),(0,t.jsx)(yw,{variant:"menu-action",onAfterToggle:r(()=>f(!1),"onAfterToggle")}),(0,t.jsx)(Dbe,{variant:"menu-action",onAfterAction:r(()=>f(!1),"onAfterAction")}),e==="authenticated"?(0,t.jsxs)("button",{type:"button",className:W("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)(op,{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)($be,{})]})]})]})]}),!h&&!a?(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)("a",{href:est,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)(Vx,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,t.jsx)(Vn,{side:"top",children:"Share feedback"})]}):null]})})}r(RZ,"SidebarAccountMenu");function nst(e,s){return Zbe(e,s)[0]?.toLowerCase()??null}r(nst,"getCompanyRouteSegment");function Zbe(e,s){if(!s)return[];const n=e.split("/").filter(Boolean);return n.length<2?[]:n[0]?.toUpperCase()!==s.toUpperCase()?[]:n.slice(1)}r(Zbe,"getCompanyPathSegments");var rst=new Set(["browse","connections","connect","chat","review","attention","gateways","advanced","app"]);function ast(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(ast,"isSkillsStoreRoute");function ist(){const{sidebarOpen:e,setSidebarOpen:s,toggleSidebar:n,collapsed:a,peeking:i,setPeeking:o,isMobile:l,setForceCollapsed:c}=Ua(),{openNewIssue:d,openOnboarding:u}=zo(),{togglePanelVisible:h}=Ef(),p=Rc()?.pushToast??null,{companies:f,loading:g,selectedCompany:v,selectedCompanyId:y,selectionSource:w,setSelectedCompanyId:k}=ps(),{companyPrefix:j,pluginRoutePath:N}=Ia(),_=Xn(),I=ra(),C=h3(),T=["/company/settings","/company/export","/company/import"].some(xt=>I.pathname.includes(xt)),R=Zbe(I.pathname,j),A=R[0]?.toLowerCase()==="tools",L=R[0]?.toLowerCase()==="apps",D=L&&R[1]&&!rst.has(R[1].toLowerCase())?R[1]:null,O=L&&R[1]?.toLowerCase()==="app"&&R[2]?R[2]:null,E=ast(I.pathname,j),q=(0,m.useRef)(!1),B=(0,m.useRef)(null),U=(0,m.useRef)(null),z=(0,m.useRef)(new zhe),$=(0,m.useRef)(I.key),K=Ube(I.pathname,j,l),[H,se]=(0,m.useState)(!1),Z=(0,m.useMemo)(()=>{if(!j)return null;const xt=j.toUpperCase();return f.find(Le=>Le.issuePrefix.toUpperCase()===xt)??null},[f,j]),ie=!!j&&!g&&f.length>0&&!Z,oe=(0,m.useMemo)(()=>N?.toLowerCase()??nst(I.pathname,j),[j,I.pathname,N]),Y=Z?.id??null,ne=Z?.issuePrefix??null,{slots:de}=ed({slotTypes:["page","routeSidebar"],companyId:Y,enabled:!!(Y&&oe)}),ee=(0,m.useMemo)(()=>EK(de,oe),[oe,de]),X=(0,m.useMemo)(()=>({companyId:Y,companyPrefix:ne}),[Y,ne]),Q=T?(0,t.jsx)(Utt,{}):D?(0,t.jsx)(_Z,{kind:"connection",connectionId:D}):O?(0,t.jsx)(_Z,{kind:"application",applicationId:O}):L||A?(0,t.jsx)(Ktt,{}):ee?(0,t.jsx)(Su,{slot:ee,context:X,className:"h-full w-full",missingBehavior:"placeholder"}):null,fe=Q!=null,{data:te}=J({queryKey:P.health,queryFn:r(()=>cm.get(),"queryFn"),retry:!1,refetchInterval:r(xt=>xt.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1}),ae=J({queryKey:P.instance.generalSettings,queryFn:r(()=>Tr.getGeneral(),"queryFn")}).data?.keyboardShortcuts===!0,le=fe||E;(0,m.useLayoutEffect)(()=>(c(le),()=>c(!1)),[le,c]),(0,m.useEffect)(()=>{g||q.current||te?.deploymentMode!=="authenticated"&&(te?.cloud||f.length===0&&(q.current=!0,u()))},[f,g,u,te?.cloud,te?.deploymentMode]),(0,m.useEffect)(()=>{if(!j||g||f.length===0)return;if(!Z){const Le=(y?f.find(Ge=>Ge.id===y):null)??f[0]??null;Le&&y!==Le.id&&k(Le.id,{source:"route_sync"});return}if(j!==Z.issuePrefix){const Le=I.pathname.replace(/^\/[^/]+/,"");_(`/${Z.issuePrefix}${Le}${I.search}`,{replace:!0});return}const xt=Kbe({matchedCompany:Z,selectedCompanyId:y,companies:f});if(xt){p?.({title:`${Z.name} is archived`,body:`Switched to ${xt.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${Z.id}`}),k(xt.id,{source:"route_sync"}),_(`/${xt.issuePrefix}/dashboard`,{replace:!0});return}Wbe({selectionSource:w,selectedCompanyId:y,routeCompanyId:Z.id})&&k(Z.id,{source:"route_sync"})},[j,f,g,Z,I.pathname,I.search,_,p,w,y,k]);const ce=h,he=(0,m.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),ve=(0,m.useRef)(null),pe=(0,m.useRef)(!1),xe=(0,m.useRef)(!1),_e=(0,m.useCallback)(()=>{ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null)},[]),ge=(0,m.useCallback)(()=>{_e(),ve.current=window.setTimeout(()=>o(!0),50)},[_e,o]),Ie=(0,m.useCallback)(()=>{_e(),o(!0)},[_e,o]),Ye=(0,m.useCallback)(()=>{_e(),ve.current=window.setTimeout(()=>o(!1),120)},[_e,o]),$e=(0,m.useCallback)(()=>{pe.current=!0,a&&!xe.current&&ge()},[a,ge]),Xe=(0,m.useCallback)(()=>{pe.current=!1,xe.current=!1,Ye()},[Ye]),ue=(0,m.useCallback)(()=>{xe.current||Ie()},[Ie]),Oe=(0,m.useCallback)(()=>{pe.current||Ye()},[Ye]);(0,m.useEffect)(()=>_e,[_e]);const dt=(0,m.useRef)(a);return(0,m.useEffect)(()=>{a!==dt.current&&(a?(_e(),o(!1),xe.current=pe.current):xe.current=!1,dt.current=a)},[a,_e,o]),(0,m.useEffect)(()=>{if(!i)return;const xt=r(Le=>{Le.key==="Escape"&&(_e(),o(!1))},"onKeyDown");return window.addEventListener("keydown",xt),()=>window.removeEventListener("keydown",xt)},[i,_e,o]),zbe(),Obe({enabled:ae,onNewIssue:r(()=>d(),"onNewIssue"),onSearch:he,onToggleSidebar:n,onTogglePanel:ce,onShowShortcuts:r(()=>se(!0),"onShowShortcuts"),onGoToInbox:r(()=>_("/inbox"),"onGoToInbox")}),(0,m.useEffect)(()=>{if(!l)return;const xt=30,Le=50,Ge=75;let ht=0,Ve=0;const Ke=r(tt=>{const Se=tt.touches[0];ht=Se.clientX,Ve=Se.clientY},"onTouchStart"),gt=r(tt=>{const Se=tt.changedTouches[0],ke=Se.clientX-ht;if(!(Math.abs(Se.clientY-Ve)>Ge)){if(!e&&ht<xt&&ke>Le){s(!0);return}e&&ke<-50&&s(!1)}},"onTouchEnd");return document.addEventListener("touchstart",Ke,{passive:!0}),document.addEventListener("touchend",gt,{passive:!0}),()=>{document.removeEventListener("touchstart",Ke),document.removeEventListener("touchend",gt)}},[l,e,s]),(0,m.useEffect)(()=>{const xt=document.body.style.overflow;return document.body.style.overflow=l?"visible":"clip",()=>{document.body.style.overflow=xt}},[l]),(0,m.useEffect)(()=>{if(!l)return Hbe()},[l]),(0,m.useEffect)(()=>{if(typeof document>"u")return;const xt=U.current;return Vbe(xt)},[I.pathname]),(0,m.useEffect)(()=>{const xt=U.current;if(!xt)return;const Le=r(()=>{z.current.remember($.current,xt.scrollTop)},"recordScroll");return xt.addEventListener("scroll",Le,{passive:!0}),()=>xt.removeEventListener("scroll",Le)},[]),(0,m.useLayoutEffect)(()=>{const xt=U.current,Le=qhe({previousPathname:B.current,pathname:I.pathname,navigationType:C,state:I.state});B.current=I.pathname;const Ge=C==="POP",ht=Ge?z.current.recall(I.key):0;if($.current=I.key,Ge){s5(xt,ht);const Ve=requestAnimationFrame(()=>s5(xt,ht));return()=>cancelAnimationFrame(Ve)}Le&&Uhe(xt)},[I.key,I.pathname,I.state,C]),(0,t.jsx)(Bhe,{children:(0,t.jsx)(Hue,{value:{keyboardShortcutsEnabled:ae},children:(0,t.jsxs)("div",{className:W("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)(Abe,{}),(0,t.jsx)(Tbe,{devServer:te?.devServer}),(0,t.jsxs)("div",{className:W("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:W("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?Q:(0,t.jsx)(CZ,{})})}),(0,t.jsx)(RZ,{deploymentMode:te?.deploymentMode})]}):(0,t.jsxs)(Ytt,{open:e,collapsed:a,peeking:i,resizable:!0,onPanelMouseEnter:$e,onPanelMouseLeave:Xe,onPanelFocusCapture:a?ue:void 0,onPanelBlurCapture:a?Oe:void 0,children:[(0,t.jsx)("div",{className:"flex flex-1 min-h-0",children:(0,t.jsx)(CZ,{})}),(0,t.jsx)(RZ,{deploymentMode:te?.deploymentMode})]}),!l&&fe?(0,t.jsx)(Xtt,{children:Q}):null,(0,t.jsxs)("div",{className:W("flex min-w-0 flex-col",l?"w-full":"h-full flex-1"),children:[(0,t.jsxs)("div",{className:W(l&&"sticky top-0 z-20 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/85"),children:[(0,t.jsx)(m6,{mobile:l,onNavigateHome:r(()=>_("/dashboard"),"onNavigateHome")}),(0,t.jsx)(Qtt,{}),l&&T?(0,t.jsx)("div",{className:"border-b border-border px-4 pb-3",children:(0,t.jsx)(ufe,{})}):null]}),(0,t.jsxs)("div",{className:W(l?"block":"flex flex-1 min-h-0"),children:[(0,t.jsx)("main",{id:"main-content",ref:U,tabIndex:-1,style:l?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:W("flex-1 p-4 outline-none md:p-6",l?"overflow-visible pb-(--sz-calc-14)":"overflow-auto [scrollbar-gutter:stable]"),children:ie?(0,t.jsx)(ju,{scope:"invalid_company_prefix",requestedPrefix:j??v?.issuePrefix}):(0,t.jsx)(Pbe,{children:(0,t.jsx)(_0,{})})}),(0,t.jsx)(Nfe,{})]})]})]}),l&&(0,t.jsx)(Ibe,{visible:K}),(0,t.jsx)(Cfe,{}),(0,t.jsx)(Ffe,{}),(0,t.jsx)(ybe,{}),(0,t.jsx)(Nbe,{}),(0,t.jsx)(kbe,{}),(0,t.jsx)(Sbe,{open:H,onOpenChange:se}),(0,t.jsx)(Cbe,{}),(0,t.jsx)(_be,{localTrusted:te?.deploymentMode==="local_trusted"})]})})})}r(ist,"Layout");var EZ=null;function ost(){return EZ??=new J1,EZ}r(ost,"getDetachedClient");function lst(){const e=(0,m.useContext)(d3),{data:s,isFetched:n}=J({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn"),enabled:e!=null},e??ost());return e?{enabled:s?.enableConferenceRoomChat===!0,loaded:n}:{enabled:!1,loaded:!0}}r(lst,"useConferenceRoomChatEnabled");function cst(){const{enabled:e,loaded:s}=lst();return s?e?(0,t.jsx)(_0,{}):(0,t.jsx)(bn,{to:"/dashboard",replace:!0}):null}r(cst,"ConferenceRoomChatGate");var dst=["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"],ust={"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 }"}},fJt=dst.map(e=>ust[e]);function eve({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)(zMe,{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)(Qe,{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)(Bo,{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(eve,"TaskChatProjectCreatedCard");function mst({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)(Mx,{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(mst,"TaskChatSkillCreatedCard");var tve=(0,m.createContext)("streamlined");function hst({mode:e,children:s}){return(0,t.jsx)(tve.Provider,{value:e,children:s})}r(hst,"TaskChatPresentationProvider");function cp(){return(0,m.useContext)(tve)==="streamlined"}r(cp,"useStreamlinedTaskChatPresentation");function pst(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(pst,"McpIcon");var fst=new Set(["tool","tool call","tool_call","acp_tool"]);function Ld(e){const s=(e??"").trim().toLowerCase().replace(/\s*\((?:pending|in[_ -]?progress|completed|failed|cancelled|canceled)\)$/,"");return!s||fst.has(s)}r(Ld,"isGenericToolName");function r7(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(r7,"mcpToolIdentity");function a7(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(a7,"identifierWords");function sve(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(sve,"sentenceCase");function jw(e){const s=(e??"").trim();return Ld(s)?"Unnamed tool":sve(a7(r7(s)?.name??s))}r(jw,"humanizeToolName");var dd=r((e,s,n)=>({key:e,singular:s,plural:n}),"group"),xst={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:dd("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:dd("task_operation","task operation","task operations")},task_create:{action:"create",running:"Creating a task",completed:"Created a task",family:"plan",group:dd("task_operation","task operation","task operations")},task_update:{action:"update",running:"Updating a task",completed:"Updated a task",family:"plan",group:dd("task_operation","task operation","task operations")},task_list:{action:"list",running:"Listing tasks",completed:"Listed tasks",family:"plan",group:dd("task_operation","task operation","task operations")},task_get:{action:"read",running:"Reading a task",completed:"Read a task",family:"plan",group:dd("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:dd("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"}},gst={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:[]},bst={read:"read",edit:"update",delete:"delete",move:"move",search:"search",list:"list",execute:"run",think:"think",fetch:"fetch",switch_mode:"switch"};function vst(e){return a7(e).join("_")}r(vst,"normalizedKey");function yst(e){const s=e[0];if(!s)return null;for(const[n,a]of Object.entries(gst))if(a.includes(s))return n;return null}r(yst,"inferredAction");function jst(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(jst,"actionFamily");var wst={terminal:yv,grep:vLe,search:ha,read:FN,edit:A3,web:VPe,plan:g_,question:Xc,agent:wv,safety:Ii,image:E3,wait:dm,mcp:pst,other:Mx};function Nst(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(Nst,"actionCopy");function kst(e){switch(e){case"run":return dd("command","command","commands");case"read":case"list":return dd("read","read","reads");case"search":return dd("search","search","searches");case"update":case"create":case"delete":case"move":return dd("file_change","file change","file changes");case"start":case"stop":return dd("delegation","delegation","delegations");case"wait":return dd("wait","wait","waits");default:return dd("tool_action","tool action","tool actions")}}r(kst,"defaultSummaryGroup");function Sst(e){return e==="read"||e==="list"?dd("paperclip_read","Paperclip read","Paperclip reads"):dd("task_operation","task operation","task operations")}r(Sst,"paperclipSummaryGroup");function Rv(e){const s=(e.name??"").trim(),n=r7(s),a=(e.namespace??n?.namespace??"").trim(),i=(n?"mcp":e.transport??"builtin").toLowerCase(),o=(n?.name??s).trim(),l=a7(o),c=vst(o),d=xst[c],u=bst[(e.operation??"").trim().toLowerCase()],h=yst(l),p=d?.action??u??h??"other",f=d?"exact":u?"kind":h?"inferred":Ld(o)?"unnamed":"fallback",g=Ld(o)?"Unnamed tool":jw(o),v=/^[A-Za-z][A-Za-z0-9_.:-]*$/.test(o),y=h&&v&&l.length>1?l.slice(1):[],w=y.length?sve(y).replace(/^./,C=>C.toLowerCase()):void 0,k=d?.running&&d.completed?{running:d.running,completed:d.completed}:p==="other"?Ld(o)?{running:"Running an unnamed tool",completed:"Ran an unnamed tool"}:{running:`Running ${g}`,completed:`Ran ${g}`}:Nst(p,d?void 0:w),j=d?.family??jst(p),N=i==="mcp"?"mcp":j,_=a?jw(a):i==="mcp"?"MCP":void 0,I=a.toLowerCase()==="paperclip"?Sst(p):d?.group??kst(p);return{icon:wst[N],family:N,runningLabel:k.running,completedLabel:k.completed,failedLabel:`${k.completed} · failed`,interruptedLabel:`${k.running} · stopped`,displayName:g,sourceLabel:_,technicalName:s||void 0,confidence:f,summaryGroup:I}}r(Rv,"toolActivityPresentation");function bP(e){const s=Rv({name:e});return{family:s.family,icon:s.icon,verbLabel:s.runningLabel}}r(bP,"toolTaxonomy");function Cst(e){const s=(e??"").trim().toLowerCase();return s==="thinking"?Jg:s==="responding"||s.startsWith("responding (")?P4e:null}r(Cst,"statusLabelIcon");var lD=["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"],cD=["Brewing","Tinkering","Distilling","Deliberating"],PZ=(()=>{const e=[],s=Math.max(lD.length,cD.length);for(let n=0;n<s;n++)n<lD.length&&e.push(lD[n]),n<cD.length&&e.push(cD[n]);return e})(),_st=1e4;function Ist(e){const s=(e??"").trim().toLowerCase();return s==="running"||s==="working"}r(Ist,"isGenericStatusLabel");function Ast(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(Ast,"fnv1a");function Tst(e,s=0){const n=Math.floor(Math.max(0,s)/_st);return PZ[(Ast(e)+n)%PZ.length]}r(Tst,"whimsyWord");var Rst=[{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}],xJt=Array.from(new Set(Rst.map(e=>e.group)));function nve(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(nve,"parseCssTimeMs");function Est(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(Est,"elapsedLabel");function Pst(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(Pst,"liveElapsedLabel");function Mst(e,s){const[n,a]=(0,m.useState)(()=>Date.now());return(0,m.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(Mst,"useLiveElapsedMs");function Lst(e,s){return!Number.isFinite(e)||!Number.isFinite(s)||s<=0?0:Math.max(0,Math.round(e/s)-1)}r(Lst,"lineScrollOffset");function $T(e){const s=getComputedStyle(document.documentElement).getPropertyValue(e),n=nve(s);return Number.isFinite(n)?n:0}r($T,"motionTokenMs");function Dst({text:e,streaming:s,leaving:n}){const a=(0,m.useRef)(null),[i,o]=(0,m.useState)(0),[l,c]=(0,m.useState)(!1),[d,u]=(0,m.useState)(!1);(0,m.useLayoutEffect)(()=>{const p=a.current;if(!p)return;const f=r(()=>{const v=parseFloat(window.getComputedStyle(p).lineHeight);o(Lst(p.scrollHeight,v))},"measure");if(f(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(f);return g.observe(p),()=>g.disconnect()},[e,s]),(0,m.useEffect)(()=>{const p=requestAnimationFrame(()=>c(!0)),f=window.setTimeout(()=>u(!0),$T("--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:W("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(Dst,"LiveSelfTalkLine");function $st(e,s){const[n,a]=(0,m.useState)(null),i=(0,m.useRef)(n),o=(0,m.useRef)(null),l=(0,m.useRef)(e),c=(0,m.useRef)(0),d=(0,m.useRef)(null),u=(0,m.useRef)(null),h=(0,m.useRef)(null);return l.current=e,(0,m.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(u),p(h),u.current=window.setTimeout(()=>{if(u.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)},$T("--motion-line-scroll")))},$T("--motion-interstitial-dwell"))},"scheduleLeave"),v=r((w,k)=>{p(u),p(h),c.current=Date.now(),f({text:w,streaming:k,swapKey:(i.current?.swapKey??0)+1}),k||g()},"swapIn");if(!s){p(d),p(u),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=$T("--motion-interstitial-dwell"),k=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)},k)}},[e,s]),(0,m.useEffect)(()=>()=>{d.current!=null&&window.clearTimeout(d.current),u.current!=null&&window.clearTimeout(u.current),h.current!=null&&window.clearTimeout(h.current)},[]),n}r($st,"useHeldSelfTalk");var Ost={running:{Icon:rt,spin:!0,tone:"text-(--status-agent-running)"},working:{Icon:rt,spin:!0,tone:"text-(--status-agent-running)"},awaiting_approval:{Icon:qN,spin:!1,tone:"text-primary"},interrupted:{Icon:mK,spin:!1,tone:"text-destructive"},refused:{Icon:Xu,spin:!1,tone:"text-destructive"},truncated:{Icon:xLe,spin:!1,tone:"text-(--status-agent-paused)"}};function rve({item:e,onApprovalDecision:s,chevronOpen:n,onToggle:a}){const{Icon:i,spin:o,tone:l}=Ost[e.status],c=e.status==="awaiting_approval",d=e.status==="running"||e.status==="working",u=Mst(e.startedAtMs,d),h=$st(d?e.selfTalk:void 0,d),p=Est(e.elapsedMs);if(d){const f=Pst(u??e.elapsedMs),g=e.selfTalk!=null,v=e.toolName?bP(e.toolName).icon:g?null:Cst(e.label),y=g||Ist(e.label)?Tst(e.id,u??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)(En,{className:W("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)(Dst,{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:W("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:W("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:W("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(rve,"TaskChatStatusPill");function ave(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(ave,"downloadBlob$1");function Fst(e,s,n){ave(e,new Blob([s],{type:`${n};charset=utf-8`}))}r(Fst,"downloadTextFile");var dD="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 ive({issueId:e,documentKey:s,title:n,format:a,body:i,className:o}){const[l,c]=(0,m.useState)(null),[d,u]=(0,m.useState)(null),[h,p]=(0,m.useState)(null),{copy:f,copied:g,failed:v}=Sf(),y=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>clearTimeout(y.current),[]);const w=(0,m.useCallback)(async(C,T)=>{c(C),p(null);try{await T(),u(C)}catch(R){u(null),p(R instanceof Error?R.message:"Export failed")}finally{c(null)}clearTimeout(y.current),y.current=setTimeout(()=>{u(null),p(null)},2e3)},[]),k=(0,m.useCallback)(async()=>i??(await _t.getDocument(e,s)).body,[i,s,e]),j=(0,m.useCallback)(()=>{c("copy"),p(null),(async()=>{try{await f(await k())==="failed"&&p("Copy failed")}catch(C){p(C instanceof Error?C.message:"Copy failed")}finally{c(null)}})()},[f,k]),N=v||h==="Copy failed"?"Copy failed":g?"Copied!":"Copy full content",_=d==="download"?"Downloaded!":"Download source",I=d==="pdf"?"Downloaded!":"Export to PDF";return(0,t.jsxs)("div",{className:W("flex items-center gap-0.5",o),"data-testid":"document-export-actions",children:[(0,t.jsx)("button",{type:"button",className:dD,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)(ds,{"aria-hidden":"true",className:"h-3.5 w-3.5"}):(0,t.jsx)(kr,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:dD,disabled:l!==null,"aria-label":"Download source",title:_,"data-testid":"document-export-download",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),w("download",async()=>{const T=m3e(a);Fst(nQ(n,T),await k(),T==="md"?"text/markdown":"text/plain")})},"onClick"),children:(0,t.jsx)(To,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{type:"button",className:dD,disabled:l!==null,"aria-label":"Export to PDF",title:I,"data-testid":"document-export-pdf",onClick:r(C=>{C.preventDefault(),C.stopPropagation(),w("pdf",async()=>{ave(nQ(n,"pdf"),await _t.getDocumentPdf(e,s))})},"onClick"),children:(0,t.jsx)(IMe,{"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(ive,"DocumentExportActions");function p1({children:e,className:s}){return(0,t.jsx)("div",{className:W("relative aspect-video w-full overflow-hidden bg-accent/20",s),children:e})}r(p1,"PreviewFrame");function H5({label:e}){return(0,t.jsx)(p1,{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)(Ql,{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(H5,"PlaceholderPreview");function Bst({artifact:e}){const[s,n]=(0,m.useState)(!1);return s||!e.contentPath?(0,t.jsx)(H5,{label:"Image"}):(0,t.jsx)(p1,{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(Bst,"ImagePreview");function qst({artifact:e}){const[s,n]=(0,m.useState)(!1),[a,i]=(0,m.useState)(!1),o=(0,m.useRef)(!1),l=(0,m.useRef)(null);if((0,m.useEffect)(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]),s||!e.contentPath)return(0,t.jsx)(p1,{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)(so,{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"),u=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)(p1,{className:"bg-black",children:[(0,t.jsx)("video",{src:e.contentPath,preload:"metadata",muted:!0,playsInline:!0,"data-frame-ready":a?"true":"false",className:W("h-full w-full object-contain transition-opacity",a?"opacity-100":"opacity-0"),onLoadedMetadata:u,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)(so,{className:"h-5 w-5 translate-x-0.5 text-white","aria-hidden":"true"})})})]})}r(qst,"VideoPreview");function zst({artifact:e}){const s=e.previewText?.trim();return s?(0,t.jsxs)(p1,{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)(H5,{label:e.source==="document"?"Document":"Text"})}r(zst,"TextPreview");function L_({artifact:e}){switch(e.mediaKind){case"image":return(0,t.jsx)(Bst,{artifact:e},e.contentPath);case"video":return(0,t.jsx)(qst,{artifact:e},e.contentPath);case"text":case"document":return(0,t.jsx)(zst,{artifact:e});case"file":return(0,t.jsx)(H5,{label:"File"});default:return(0,t.jsx)(H5,{})}}r(L_,"ArtifactPreview");function MZ({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(MZ,"SecondaryAction");function Ust({artifact:e}){return(0,t.jsxs)(Qe,{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)(L_,{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)(ive,{issueId:e.issue.id,documentKey:e.documentKey,title:e.title}):null,e.openPath?(0,t.jsx)(MZ,{href:e.openPath,title:"Open file in new tab",children:(0,t.jsx)(gr,{className:"h-3.5 w-3.5"})}):null,e.downloadPath?(0,t.jsx)(MZ,{href:e.downloadPath,download:!0,title:"Download file",children:(0,t.jsx)(To,{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 ",vu(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(Ust,"ArtifactCard");function XN(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(XN,"formatBytes$4");var G5=new Set(["application/octet-stream","binary/octet-stream","application/x-binary"]),Kst=[".mp4",".m4v",".webm",".mov",".qt",".quicktime"],Wst=[".png",".jpg",".jpeg",".gif",".webp",".avif",".bmp",".svg",".ico"],Vst=new Set(["application/wasm"]),Hst=new Set(["application/zip","application/x-zip","application/x-zip-compressed"]),ove=new Set(["text/markdown","text/x-markdown","application/markdown","application/x-markdown"]),Gst=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"]),Qst=[".csv",".css",".graphql",".htm",".html",".js",".json",".jsx",".log",".markdown",".md",".mdx",".php",".py",".sh",".sql",".toml",".ts",".tsx",".txt",".xml",".yaml",".yml"];function D_(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}r(D_,"normalizeOutputContentType");function Yst(e){const s=(e??"").trim().toLowerCase();return s?Qst.some(n=>s.endsWith(n)):!1}r(Yst,"hasDocumentLikeFilename");function lve(e){return Hst.has(e)||e.endsWith("+zip")}r(lve,"isZipContentType");function Xst(e){return e?!!(e.startsWith("text/")||ove.has(e)||Gst.has(e)||e.startsWith("application/")&&(e.endsWith("+json")||e.endsWith("+xml"))):!1}r(Xst,"isDocumentLikeOutputContentType");function Jst(e,s){const n=D_(e);return!n||Xst(n)||G5.has(n)&&Yst(s)?!1:n.startsWith("video/")||n.startsWith("image/")||n==="application/pdf"||Vst.has(n)||lve(n)||G5.has(n)}r(Jst,"isOutputEligibleContentType");function Zst(e){const s=D_(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"}:lve(s)?{label:"ZIP",tone:"zip"}:s.startsWith("image/")?{label:"IMG",tone:"image"}:ove.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(Zst,"getOutputFileGlyph");function Cu(e,s){const n=D_(e);if(n.startsWith("video/"))return!0;if(!G5.has(n))return!1;const a=(s??"").trim().toLowerCase();return Kst.some(i=>a.endsWith(i))}r(Cu,"isVideoLikeOutput");function dN(e){return D_(e).startsWith("image/")}r(dN,"isImageContentType");function vP(e,s){const n=D_(e);if(dN(n))return!0;if(n&&!G5.has(n))return!1;const a=(s??"").trim().toLowerCase();return Wst.some(i=>a.endsWith(i))}r(vP,"isImageLikeOutput");function LZ(e){const s=new Date(e).getTime();return Number.isNaN(s)?0:s}r(LZ,"toTime");function yP(e){const s=(e??[]).filter(n=>n.type==="artifact"&&n.provider==="paperclip").flatMap(n=>{const a=ATe.safeParse(n.metadata);return a.success&&!Jst(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:LZ(a.createdAt)-LZ(n.createdAt)),{items:s,primary:s[0]??null,rest:s.slice(1),count:s.length}}r(yP,"getIssueOutputs");function i7(e){return e.metadata?.originalFilename||e.title||"output"}r(i7,"outputFilename");function cve(e){return new Set(yP(e).items.flatMap(s=>{const n=s.metadata?.attachmentId;return n?[n]:[]}))}r(cve,"getPromotedOutputAttachmentIds");var Eh={connect:r((e,s)=>Te.post(`/companies/${e}/email/connections`,s),"connect"),inspectSaved:r((e,s)=>Te.post(`/companies/${e}/email/connections/${s}/inspect`,{}),"inspectSaved"),list:r(e=>Te.get(`/companies/${e}/email/inboxes`),"list"),setup:r((e,s)=>Te.post(`/companies/${e}/email/inboxes`,s),"setup"),inspect:r((e,s)=>Te.post(`/companies/${e}/email/inspect`,{apiKey:s}),"inspect"),control:r((e,s)=>Te.post(`/email/inboxes/${e}/control`,{action:s}),"control"),reconnect:r((e,s,n)=>Te.post(`/email/inboxes/${e}/reconnect`,{apiKey:s,receiveMode:n}),"reconnect"),resolve:r((e,s,n,a)=>Te.post(`/companies/${e}/email/deliveries/${s}/resolve`,{outcome:n,providerMessageId:a}),"resolve"),thread:r((e,s)=>Te.get(`/companies/${e}/email/tasks/${s}`),"thread"),send:r((e,s)=>Te.post(`/companies/${e}/email/send`,s),"send")},dve=(0,m.createContext)(null);function ent({companyId:e,issueId:s,children:n}){const{enabled:a}=Yx(),i=J({queryKey:["email-thread",e,s],queryFn:r(()=>Eh.thread(e,s),"queryFn"),enabled:a,refetchInterval:a?3e3:!1});return(0,t.jsx)(dve.Provider,{value:i.data??null,children:n})}r(ent,"EmailThreadProvider");function uve(e){const s=(0,m.useContext)(dve),n=s?.messages.find(a=>a.commentId===e);return n&&s?(0,t.jsx)(mve,{message:n,publication:s.publications.find(a=>a.providerMessageId===n.providerMessageId),issueId:s.issueId}):null}r(uve,"useEmailComment");function mve({message:e,publication:s,issueId:n}){const a=J({queryKey:["email-attachments",n],queryFn:r(()=>_t.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)(pme,{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)(Ql,{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(mve,"EmailMessageCard");var av=(0,m.createContext)(null);function tnt(e){return e.contentType.toLowerCase().split(";")[0]?.trim()??""}r(tnt,"normalizedContentType$1");function $_(e){return e.originalFilename??e.id}r($_,"attachmentFilename");function o7(e){return e.openPath??e.contentPath}r(o7,"attachmentOpenPath");function O_(e){return e.downloadPath??`${e.contentPath}?download=1`}r(O_,"attachmentDownloadPath");function hve(e){const s=tnt(e);return vP(s,e.originalFilename)&&!/^image\/hei[cf](?:-sequence)?$/.test(s)}r(hve,"isImageAttachment$2");function pve(e){return Cu(e.contentType,e.originalFilename)}r(pve,"isVideoAttachment");function snt(e){return STe(e)}r(snt,"isMarkdownAttachment");function oy({items:e,initialIndex:s,open:n,onOpenChange:a}){const[i,o]=(0,m.useState)(s),l=(0,m.useRef)(null),c=(0,m.useCallback)(v=>{l.current=v},[]);(0,m.useEffect)(()=>{n&&o(s)},[n,s]);const d=(0,m.useCallback)(()=>{o(v=>(v+1)%e.length)},[e.length]),u=(0,m.useCallback)(()=>{o(v=>(v-1+e.length)%e.length)},[e.length]);(0,m.useEffect)(()=>{i<e.length||o(0)},[i,e.length]),(0,m.useEffect)(()=>{if(!n)return;const v=r(y=>{y.key==="ArrowRight"?d():y.key==="ArrowLeft"?u():y.key==="Escape"&&a(!1)},"handler");return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n,d,u,a]);const h=(0,m.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=$_(p),g=Cu(p.contentType,p.originalFilename);return(0,t.jsx)(hEe,{open:n,onOpenChange:a,children:(0,t.jsxs)(uEe,{children:[(0,t.jsx)(mEe,{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)(gEe,{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:O_(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)(To,{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)(sr,{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:u,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)(Nu,{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)(En,{className:"h-7 w-7"})})})]}),(0,t.jsx)("div",{className:"h-6 shrink-0"})]})]})})}r(oy,"ImageGalleryModal");function y6(e,s){if(e&&!s)return e;if(!e&&s)return s;if(e||s)return{...e,...s}}r(y6,"mergeObjects");var l7={};function c7(e,s,n,a,i){if(!n&&!a&&!i&&!e)return Q5(s);let o=Q5(e);return s&&(o=ES(o,s)),n&&(o=ES(o,n)),a&&(o=ES(o,a)),i&&(o=ES(o,i)),o}r(c7,"mergeProps");function nnt(e){if(e.length===0)return l7;if(e.length===1)return Q5(e[0]);let s=Q5(e[0]);for(let n=1;n<e.length;n+=1)s=ES(s,e[n]);return s}r(nnt,"mergePropsN");function Q5(e){return d7(e)?{...xve(e,l7)}:rnt(e)}r(Q5,"createInitialMergedProps");function ES(e,s){return d7(s)?xve(s,e):ant(e,s)}r(ES,"mergeInto");function rnt(e){const s={...e};for(const n in s){const a=s[n];fve(n,a)&&(s[n]=gve(a))}return s}r(rnt,"copyInitialProps");function ant(e,s){if(!s)return e;for(const n in s){const a=s[n];switch(n){case"style":e[n]=y6(e.style,a);break;case"className":e[n]=vve(e.className,a);break;default:fve(n,a)?e[n]=int(e[n],a):e[n]=a}}return e}r(ant,"mutablyMergeInto");function fve(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(fve,"isEventHandler");function d7(e){return typeof e=="function"}r(d7,"isPropsGetter");function xve(e,s){return d7(e)?e(s):e??l7}r(xve,"resolvePropsGetter");function int(e,s){return s?e?(...n)=>{const a=n[0];if(yve(a)){const o=a;bve(o);const l=s(...n);return o.baseUIHandlerPrevented||e?.(...n),l}const i=s(...n);return e?.(...n),i}:gve(s):e}r(int,"mergeEventHandlers");function gve(e){return e&&((...s)=>{const n=s[0];return yve(n)&&bve(n),e(...s)})}r(gve,"wrapEventHandler");function bve(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}r(bve,"makeEventPreventable");function vve(e,s){return s?e?s+" "+e:s:e}r(vve,"mergeClassNames");function yve(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}r(yve,"isSyntheticEvent");function ont(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(ont,"createFormatErrorMessage");var lnt=ont("https://base-ui.com/production-error","Base UI"),DZ={};function jve(e,s){const n=m.useRef(DZ);return n.current===DZ&&(n.current=e(s)),n}r(jve,"useRefWithInit");function $Z(e,s,n,a){const i=jve(wve).current;return dnt(i,e,s,n,a)&&Nve(i,[e,s,n,a]),i.callback}r($Z,"useMergedRefs");function cnt(e){const s=jve(wve).current;return unt(s,e)&&Nve(s,e),s.callback}r(cnt,"useMergedRefsN");function wve(){return{callback:null,cleanup:null,refs:[]}}r(wve,"createForkRef");function dnt(e,s,n,a,i){return e.refs[0]!==s||e.refs[1]!==n||e.refs[2]!==a||e.refs[3]!==i}r(dnt,"didChange");function unt(e,s){return e.refs.length!==s.length||e.refs.some((n,a)=>n!==s[a])}r(unt,"didChangeN");function Nve(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(Nve,"update");var mnt=parseInt("19.2.8",10);function hnt(e){return mnt>=e}r(hnt,"isReactVersionAtLeast");function OZ(e){if(!m.isValidElement(e))return null;const s=e,n=s.props;return(hnt(19)?n?.ref:s.ref)??null}r(OZ,"getReactElementRef");var gJt=Object.freeze([]),PS=Object.freeze({});function pnt(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(pnt,"getStateAttributesProps");function fnt(e,s){return typeof e=="function"?e(s):e}r(fnt,"resolveClassName");function xnt(e,s){return typeof e=="function"?e(s):e}r(xnt,"resolveStyle");function gnt(e,s,n={}){const a=s.render,i=bnt(s,n);return n.enabled===!1?null:jnt(e,a,i,n.state??PS)}r(gnt,"useRenderElement");function bnt(e,s={}){const{className:n,style:a,render:i}=e,{state:o=PS,ref:l,props:c,stateAttributesMapping:d,enabled:u=!0}=s,h=u?fnt(n,o):void 0,p=u?xnt(a,o):void 0,f=u?pnt(o,d):PS,g=u&&c?vnt(c):void 0,v=u?y6(f,g)??{}:PS;return typeof document<"u"&&(u?Array.isArray(l)?v.ref=cnt([v.ref,OZ(i),...l]):v.ref=$Z(v.ref,OZ(i),l):$Z(null,null)),u?(h!==void 0&&(v.className=vve(v.className,h)),p!==void 0&&(v.style=y6(v.style,p)),v):PS}r(bnt,"useRenderElementProps");function vnt(e){return Array.isArray(e)?nnt(e):c7(void 0,e)}r(vnt,"resolveRenderFunctionProps");var ynt=Symbol.for("react.lazy");function jnt(e,s,n,a){if(s){if(typeof s=="function")return s(n,a);const i=c7(n,s.props);i.ref=n.ref;let o=s;return o?.$$typeof===ynt&&(o=m.Children.toArray(s)[0]),m.cloneElement(o,i)}if(e&&typeof e=="string")return wnt(e,n);throw new Error(lnt(8))}r(jnt,"evaluateRenderProp");function wnt(e,s){return e==="button"?(0,m.createElement)("button",{type:"button",...s,key:s.key}):e==="img"?(0,m.createElement)("img",{alt:"",...s,key:s.key}):m.createElement(e,s)}r(wnt,"renderTag");function Nnt(e){return gnt(e.defaultTagName??"div",e,e)}r(Nnt,"useRender");var knt=eK("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 kve({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:W(knt({size:n,orientation:a}),e),...i})}r(kve,"Attachment");var Snt=eK("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 Sve({className:e,variant:s="icon",...n}){return(0,t.jsx)("div",{"data-slot":"attachment-media","data-variant":s,className:W(Snt({variant:s}),e),...n})}r(Sve,"AttachmentMedia");function Cve({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-content",className:W("max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1",e),...s})}r(Cve,"AttachmentContent");function _ve({className:e,...s}){return(0,t.jsx)("span",{"data-slot":"attachment-title",className:W("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(_ve,"AttachmentTitle");function Ive({className:e,...s}){return(0,t.jsx)("span",{"data-slot":"attachment-description",className:W("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(Ive,"AttachmentDescription");function Cnt({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-actions",className:W("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(Cnt,"AttachmentActions$1");function _nt({className:e,variant:s,size:n="icon-xs",...a}){return(0,t.jsx)(F,{"data-slot":"attachment-action",variant:s??"ghost",size:n,className:W(e),...a})}r(_nt,"AttachmentAction");function Int({className:e,render:s,type:n,...a}){return Nnt({defaultTagName:"button",props:c7({type:s?n:n??"button",className:W("absolute inset-0 z-10 outline-none",e)},a),render:s,state:{slot:"attachment-trigger"}})}r(Int,"AttachmentTrigger");function Ave({className:e,...s}){return(0,t.jsx)("div",{"data-slot":"attachment-group",className:W("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(Ave,"AttachmentGroup");var Ant=new Set(["png","jpg","jpeg","gif","webp","svg","avif","bmp","ico","heic"]),Tnt={pdf:{icon:vi,label:"PDF"},doc:{icon:vi,label:"Doc"},docx:{icon:vi,label:"Doc"},txt:{icon:vi,label:"Text"},md:{icon:vi,label:"Markdown"},rtf:{icon:vi,label:"Text"},csv:{icon:SS,label:"CSV"},tsv:{icon:SS,label:"TSV"},xls:{icon:SS,label:"Sheet"},xlsx:{icon:SS,label:"Sheet"},zip:{icon:jb,label:"ZIP"},gz:{icon:jb,label:"Archive"},tar:{icon:jb,label:"Archive"},tgz:{icon:jb,label:"Archive"},rar:{icon:jb,label:"Archive"},"7z":{icon:jb,label:"Archive"},mp3:{icon:kS,label:"Audio"},wav:{icon:kS,label:"Audio"},m4a:{icon:kS,label:"Audio"},ogg:{icon:kS,label:"Audio"},mp4:{icon:mT,label:"Video"},mov:{icon:mT,label:"Video"},webm:{icon:mT,label:"Video"},json:{icon:Cl,label:"JSON"},yaml:{icon:Cl,label:"YAML"},yml:{icon:Cl,label:"YAML"},xml:{icon:Cl,label:"XML"},html:{icon:Cl,label:"HTML"},css:{icon:Cl,label:"CSS"},js:{icon:Cl,label:"Code"},jsx:{icon:Cl,label:"Code"},ts:{icon:Cl,label:"Code"},tsx:{icon:Cl,label:"Code"},py:{icon:Cl,label:"Code"},rb:{icon:Cl,label:"Code"},go:{icon:Cl,label:"Code"},rs:{icon:Cl,label:"Code"},sh:{icon:Cl,label:"Code"},sql:{icon:Cl,label:"SQL"},log:{icon:vi,label:"Log"},patch:{icon:Cl,label:"Patch"},diff:{icon:Cl,label:"Patch"}};function Tve(e){const s=/\.([a-z0-9]+)$/i.exec(e.trim());return s?s[1].toLowerCase():""}r(Tve,"extensionOf");function FZ(e){return Ant.has(Tve(e))}r(FZ,"isImageFilename");function Rve(e){return(e??"").toLowerCase().split(";")[0]?.trim()??""}r(Rve,"normalizedContentType");function NA(e){const s=Rve(e.contentType);return s.startsWith("image/")?!0:s&&s!=="application/octet-stream"?!1:FZ(e.name)||FZ(e.url.split("?")[0])}r(NA,"isImageAttachment$1");function Eve(e){return Tnt[Tve(e)]??{icon:XR,label:"File"}}r(Eve,"fileKindForName");function Rnt(e){const s=Eve(e.name);if(s.label!=="File")return s;const n=Rve(e.contentType);return n==="application/pdf"?{icon:vi,label:"PDF"}:n==="application/json"||n.endsWith("+json")?{icon:Cl,label:"JSON"}:n==="text/csv"||n==="application/csv"?{icon:SS,label:"CSV"}:n.startsWith("text/")?{icon:vi,label:"Text"}:n.startsWith("audio/")?{icon:kS,label:"Audio"}:n.startsWith("video/")?{icon:mT,label:"Video"}:n.includes("zip")||n.includes("archive")?{icon:jb,label:"Archive"}:s}r(Rnt,"fileKindForAttachment");function Pve(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(Pve,"formatFileSize");function Ent(e){return/\/api\/(?:attachments|assets)\/([^/?]+)\/content/.exec(e)?.[1]??null}r(Ent,"attachmentIdFromUrl");function BZ(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(Ent(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(BZ,"hydrateAttachmentRefs");var qZ=/(?<!!)\[((?:\\.|[^\]\\])+)\]\((\/api\/(?:attachments|assets)\/[^()\s]+\/content(?:\?[^()\s]*)?)\)/g,Mve=/!\[((?:\\.|[^\]\\])*)\]\(([^()\s]+)\)/g;function Lve(e){return e.replace(Mve,"").trim().length===0&&e.trim().length>0}r(Lve,"isStandaloneImageEmbedLine");function Pnt(e){const s=[],n=new Set;for(const a of e.split(`
|
|
337
337
|
`))if(Lve(a))for(const i of a.matchAll(Mve)){const[,o,l]=i;n.has(l)||(n.add(l),s.push({name:o.replace(/\\([[\]])/g,"$1"),url:l}))}return s}r(Pnt,"extractImageRefs");function Mnt(e){return e.split(`
|
|
338
338
|
`).filter(s=>!Lve(s)).join(`
|
|
339
339
|
`).replace(/\n{3,}/g,`
|
|
@@ -726,7 +726,7 @@ Last resolved: user values resolve per member`;return(0,t.jsxs)("div",{role:"row
|
|
|
726
726
|
| Stage | Qualified |
|
|
727
727
|
| 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:VW(42)};function yy(e){const{toolAction:s,payload:n,...a}=e;return dl({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:{...kGt,...s}},...a})}r(yy,"createToolActionConfirmationInteraction");var lZt=yy({id:"interaction-tool-action-pending-write"}),cZt=yy({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:VW(4)}}),dZt=yy({id:"interaction-tool-action-running",status:"accepted",resolvedByUserId:Kr.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"}}}),uZt=yy({id:"interaction-tool-action-executed",status:"accepted",resolvedByUserId:Kr.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"}}}),mZt=yy({id:"interaction-tool-action-failed",status:"accepted",resolvedByUserId:Kr.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"}}}),hZt=yy({id:"interaction-tool-action-declined",status:"rejected",resolvedByUserId:Kr.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."}}),pZt=yy({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"}}}),SGt={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:VW(20160)};function aI(e){const{secretProposal:s,payload:n,...a}=e;return dl({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:{...SGt,...s}},...a})}r(aI,"createSecretProposalConfirmationInteraction");var fZt=aI({id:"interaction-secret-proposal-pending"});function $Ae(e={}){const{payload:s,...n}=e;return dl({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:Kr.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($Ae,"createConnectionAuthorizationInteraction");var xZt=$Ae({id:"interaction-connection-authorization-pending"}),gZt=$Ae({id:"interaction-connection-authorization-resolved",status:"accepted",resolvedByUserId:Kr.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 jy(e={}){return{id:"interaction-connection-intent-default",companyId:Kr.companyId,issueId:Kr.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:Kr.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(jy,"createConnectionIntentInteraction");var CGt=jy(),_Gt=jy({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"}}),bZt=jy({id:"interaction-connection-intent-authorizing",payload:{version:1,serviceSlug:"notion",serviceName:"Notion",serviceLogoUrl:null,requestingAgentId:"11111111-1111-4111-8111-111111111111",requestingAgentName:"Researcher",phase:"authorizing"}}),IGt=jy({id:"interaction-connection-intent-connected",status:"accepted",result:{version:1,outcome:"connected",connectionId:"22222222-2222-4222-8222-222222222222"},resolvedByUserId:Kr.currentUserId,resolvedAt:new Date("2026-04-20T15:12:00.000Z")}),vZt=jy({id:"interaction-connection-intent-declined",status:"rejected",result:{version:1,outcome:"declined",reason:"Not right now"},resolvedByUserId:Kr.currentUserId,resolvedAt:new Date("2026-04-20T15:12:00.000Z")}),yZt=jy({id:"interaction-connection-intent-superseded",status:"expired",result:{version:1,outcome:"superseded"},resolvedAt:new Date("2026-04-20T15:12:00.000Z")}),jZt=jy({id:"interaction-connection-intent-expired",status:"expired",result:{version:1,outcome:"expired"},resolvedAt:new Date("2026-04-20T15:12:00.000Z")}),wZt=aI({id:"interaction-secret-proposal-executed",status:"accepted",resolvedByUserId:Kr.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"}}}),NZt=aI({id:"interaction-secret-proposal-failed",status:"accepted",resolvedByUserId:Kr.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"}}}),kZt=aI({id:"interaction-secret-proposal-rejected",status:"rejected",resolvedByUserId:Kr.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"}}}),SZt=aI({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"}}}),CZt=dl({id:"interaction-confirmation-expired-comment",status:"expired",resolvedByUserId:Kr.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"}}),_Zt=dl({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:Kr.issueId,key:"plan",revisionId:"44444444-4444-4444-8444-444444444444",revisionNumber:4}},result:{version:1,outcome:"stale_target",staleTarget:{type:"issue_document",issueId:Kr.issueId,key:"plan",revisionId:"11111111-1111-4111-8111-111111111111",revisionNumber:3}}}),IZt=dl({id:"interaction-confirmation-failed",status:"failed",updatedAt:new Date("2026-04-20T14:42:00.000Z")}),AZt=dl({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"}),TZt=dl({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"}),RZt=dl({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"}),EZt=dl({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"}),PZt=dl({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"}),MZt=dl({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"}}),LZt=dl({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."}}),DZt=dl({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."}}),$Zt=vy({}),OZt=vy({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?"}}),FZt=vy({id:"interaction-checkbox-accepted",status:"accepted",resolvedByUserId:Kr.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"]}}),OAe=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}}),AGt=vy({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:OAe,defaultSelectedOptionIds:[],minSelected:0,maxSelected:null,acceptLabel:"Archive selected",rejectLabel:"Reject",rejectRequiresReason:!1}}),BZt=vy({id:"interaction-checkbox-many-accepted",status:"accepted",title:"Select the customer records to archive",resolvedByUserId:Kr.currentUserId,resolvedAt:new Date("2026-04-20T14:52:00.000Z"),updatedAt:new Date("2026-04-20T14:52:00.000Z"),payload:AGt.payload,result:{version:1,outcome:"accepted",selectedOptionIds:OAe.slice(0,42).map(e=>e.id)}}),qZt=vy({id:"interaction-checkbox-rejected",status:"rejected",resolvedByUserId:Kr.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."}}),zZt=vy({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:Kr.issueId,key:"plan",revisionId:"44444444-4444-4444-8444-444444444444",revisionNumber:4}},result:{version:1,outcome:"stale_target",staleTarget:{type:"issue_document",issueId:Kr.issueId,key:"plan",revisionId:"11111111-1111-4111-8111-111111111111",revisionNumber:3}}});function iI(e){return{id:"interaction-verdicts-default",companyId:Kr.companyId,issueId:Kr.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,...rI(e)}}r(iI,"createRequestItemVerdictsInteraction");var UZt=iI({}),KZt=iI({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:Kr.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:Kr.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")}]}}),WZt=iI({id:"interaction-verdicts-complete",status:"answered",resolvedByUserId:Kr.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:Kr.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:Kr.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")},{id:"post-founder-note",verdict:"approve",resolvedByUserId:Kr.currentUserId,resolvedAt:new Date("2026-04-20T15:14:00.000Z")},{id:"post-customer-story",verdict:"approve",resolvedByUserId:Kr.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:Kr.currentUserId,resolvedAt:new Date("2026-04-20T15:14:00.000Z")}]}}),VZt=iI({id:"interaction-verdicts-superseded",status:"expired",resolvedByUserId:Kr.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:Kr.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:Kr.currentUserId,resolvedAt:new Date("2026-04-20T15:08:00.000Z")}]}}),TGt=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`}}),HZt=iI({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:TGt,verdicts:["approve","reject"],requireReasonOn:["reject"],reasonLabel:"Why reject?",allowBulkApprove:!0,supersedeOnUserComment:!0}}),GZt=[hde({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")}),hde({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"})],QZt=[{id:"event-thread-checkout",createdAt:new Date("2026-04-20T14:01:00.000Z"),actorType:"user",actorId:Kr.currentUserId,statusChange:{from:"todo",to:"in_progress"}}],RGt=new Set(["local_path","agent_package"]);function r3(e){return RGt.has(e.type)?"unsupported_in_ui":e.pinned?"ok":"unpinned"}r(r3,"sourceWarningCode");function EGt(e){let s="safe";for(const n of e.sourceRefs){const a=r3(n);if(a==="unsupported_in_ui")return"blocked";a==="unpinned"&&(s="has_warnings")}return s}r(EGt,"teamRisk");function PGt(e){return e.counts.localSkills+e.counts.catalogSkills+e.counts.externalSkillSources}r(PGt,"skillCount");function pde(e){return e.replace(/[-_/]+/g," ").replace(/\b\w/g,s=>s.toUpperCase()).trim()}r(pde,"titleCase");var MGt={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:Ii},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:Ii},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:_s},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:_s}};function FAe({level:e,iconOnly:s=!1}){const n=MGt[e],{Icon:a}=n;return(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsxs)(ot,{variant:"outline",className:W("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)(Vn,{children:n.tip})]})}r(FAe,"TrustChip");function BAe(e){switch(e){case"github":return Ed;case"url":return dc;case"local_path":return Yc;case"agent_package":return Wh;case"skills_sh":return Hl;default:return dc}}r(BAe,"sourceKindIcon");function LGt({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:W("flex items-center gap-2 px-3 py-2 text-sm",a&&"border-l-2 border-amber-500/50"),children:[(0,t.jsx)(cEe,{className:"h-3.5 w-3.5 text-amber-500"}),(0,t.jsx)("span",{className:"font-medium",children:pde(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)(dw,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,t.jsx)("span",{children:pde(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(LGt,"TeamHierarchyPreview");function DGt({children:e}){return(0,t.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e})}r(DGt,"SectionHeader");function $Gt({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)(Hl,{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)(ot,{variant:"outline",className:"ml-auto text-(length:--text-nano)",children:s.type}),s.resolved?(0,t.jsx)(ot,{variant:"outline",className:"text-(length:--text-nano) text-emerald-600 dark:text-emerald-300 border-emerald-500/30",children:"resolved"}):(0,t.jsx)(ot,{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($Gt,"RequiredSkillsList");function OGt({inputs:e}){return e.length===0?null:(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(DGt,{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)(ji,{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)(ot,{variant:"outline",className:W("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)(ot,{variant:"outline",className:"text-(length:--text-nano)",children:"required"})]},s.key))})]})}r(OGt,"EnvInputsList");function FGt({sources:e}){const s=e.filter(i=>i.type!=="include"),[n,a]=(0,m.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)(sn,{className:"h-3 w-3"}):(0,t.jsx)(En,{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=BAe(i.type),l=r3(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(FGt,"ExternalSourcesList");function BGt({team:e,allowExternalSources:s,allowUnpinnedOptionalSources:n,allowLocalPathSources:a,onChange:i}){const o=e.sourceRefs.filter(c=>c.type!=="include"),l=o.some(c=>r3(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=BAe(c.type),u=r3(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:[u==="ok"&&"pinned",u==="unpinned"&&"unpinned reference",u==="unsupported_in_ui"&&"not installable from the browser"]})]}),(0,t.jsx)(ot,{variant:"outline",className:W("ml-auto text-(length:--text-nano)",u==="unsupported_in_ui"?"text-rose-600 dark:text-rose-300 border-rose-500/30":u==="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)(hF,{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)(hF,{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)(hF,{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(BGt,"StepSourcePolicy");function hF({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)(yi,{checked:n,onCheckedChange:a})]})}r(hF,"PolicyToggle");var qGt={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 zGt({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(UGt)).map(n=>{const a=qGt[n.action];return(0,t.jsxs)("li",{className:"flex items-center gap-2 px-3 py-2.5 text-sm",children:[(0,t.jsx)(Hl,{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)(ot,{variant:"outline",className:W("ml-auto text-(length:--text-nano)",a.tone),children:a.label})]},`${n.type}:${n.ref}`)})})]})}r(zGt,"StepSkillPlan");function UGt(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(UGt,"toPreparation");function sT({team:e,selected:s,onSelect:n,installed:a}){const i=EGt(e),o=!!a?.outOfDate;return(0,t.jsxs)("button",{type:"button",onClick:n,className:W("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)(dw,{className:W("h-3.5 w-3.5 text-muted-foreground",e.kind==="optional"&&"opacity-70")}),(0,t.jsx)("span",{className:W("line-clamp-2 text-(length:--text-compact) font-medium",s&&"text-foreground"),children:e.name}),o&&(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{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)(l_,{className:"h-3 w-3"})})}),(0,t.jsx)(Vn,{children:"Update available — installed team is out of date"})]}),i!=="safe"&&(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)(_s,{className:W("ml-auto h-3.5 w-3.5",i==="blocked"?"text-rose-500":"text-amber-500")})}),(0,t.jsx)(Vn,{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 · ",PGt(e),"s"]}),(0,t.jsx)(FAe,{level:e.trustLevel,iconOnly:!0})]})]})}r(sT,"TeamRow");function KGt({team:e,selected:s=!1,onSelect:n}){return(0,t.jsxs)("button",{type:"button",onClick:n,"aria-pressed":s,className:W("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)(dw,{className:"h-4 w-4 text-muted-foreground"})}),e.trustLevel!=="markdown_only"&&(0,t.jsx)(FAe,{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)(ot,{variant:"outline",className:"text-(length:--text-nano)",children:a},a))})]})}r(KGt,"TeamCard");var Nc={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"},WGt={...Nc,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:{...Nc.counts,agents:4,routines:2},rootAgentSlugs:["tech-lead"],agentSlugs:["tech-lead","eng-1","eng-2","sre"],trustLevel:"markdown_only",sourceRefs:[]},fde={...Nc,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}]},qAe={catalogId:Nc.id,catalogKey:Nc.key,present:!0,currentContentHash:Nc.contentHash,installedOriginHashes:["sha256:0000older0000older0000older"],agentCount:3,outOfDate:!0},VGt={...qAe,installedOriginHashes:[Nc.contentHash],outOfDate:!1},HGt=[{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"}],xde=[{...Nc,trustLevel:"markdown_only",sourceRefs:[],requiredSkills:[],counts:{...Nc.counts,localSkills:0,catalogSkills:0,externalSkillSources:0}},{...Nc,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:[]},{...Nc,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 TU(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(TU,"sampleOutput");var GGt=[TU("wp-vid","aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa","video/mp4","q3-summary.mp4",{byteSize:19293798,isPrimary:!0,createdAt:"2026-05-30T12:00:00Z"}),TU("wp-pdf","bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb","application/pdf","talking-points.pdf",{byteSize:421888,createdAt:"2026-05-30T11:52:00Z"})],QGt=[{...TU("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"}}],nT={id:"design-guide-task",identifier:"PAP-427",title:"Reconcile the navigation model across operator surfaces",status:"in_progress",priority:"medium",blockerAttention:!1};function qr({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)(gl,{}),s]})}r(qr,"Section");function lr({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(lr,"SubSection");function YGt(){const[e,s]=(0,m.useState)(xde[0]?.id??null);return(0,t.jsx)("div",{className:"grid max-w-2xl gap-4 md:grid-cols-2 lg:grid-cols-3",children:xde.map(n=>(0,t.jsx)(KGt,{team:n,selected:n.id===e,onSelect:r(()=>s(n.id),"onSelect")},n.id))})}r(YGt,"TeamCardShowcase");var gde=[{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 XGt(){const[e,s]=(0,m.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)(Tv,{value:e,secrets:gde,onChange:r(n=>s(n??{}),"onChange"),onCreateSecret:r(async n=>({...gde[0],id:`dg-${n}`,key:n,name:n.toUpperCase(),latestVersion:1}),"onCreateSecret")})})}r(XGt,"EnvironmentVariablesEditorShowcase");function nc({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(nc,"Swatch");function JGt(){const[e,s]=(0,m.useState)(!0),[n,a]=(0,m.useState)(null),[i,o]=(0,m.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)(BSe,{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)(eve,{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)(Bve,{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)(M9,{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)(qSe,{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(JGt,"TaskExecutionControlsExample");function ZGt(){const[e,s]=(0,m.useState)(!0),[n,a]=(0,m.useState)(!0);return(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(M9,{onAdd:r(async()=>{},"onAdd"),workMode:"standard",takeover:n&&e?{id:"design-question",label:"Question",pendingCount:1,content:(0,t.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,t.jsx)("p",{children:"Should the agent use the existing draft?"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(F,{size:"sm",onClick:r(()=>a(!1),"onClick"),children:"Use draft"}),(0,t.jsx)(F,{size:"sm",variant:"outline",onClick:r(()=>a(!1),"onClick"),children:"Start fresh"})]})]}),onDismiss:r(()=>s(!1),"onDismiss"),onSkip:r(()=>a(!1),"onSkip")}:null,pendingTakeover:n?{count:1,label:"Question",onOpen:r(()=>s(!0),"onOpen")}:null})})}r(ZGt,"TaskPendingInputExample");function eQt(){const[e,s]=(0,m.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)(ype,{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(eQt,"AgentChatPickerExample");function tQt(){const[e,s]=(0,m.useState)("standard");return(0,t.jsxs)("div",{className:"flex max-w-xl items-center gap-2 rounded-xl border border-border bg-card p-3",children:[(0,t.jsx)(vSe,{mode:e,onModeChange:s,onAttachFile:r(()=>{},"onAttachFile"),onGoal:r(()=>{},"onGoal")}),(0,t.jsx)(ySe,{mode:e,onRemove:r(()=>s("standard"),"onRemove")}),(0,t.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:"Plus menu · removable mode chip"})]})}r(tQt,"ComposerActionsExample");function sQt(){const[e,s]=(0,m.useState)(0),[n,a]=(0,m.useState)("todo"),[i,o]=(0,m.useState)("medium"),[l,c]=(0,m.useState)("in_progress"),[d,u]=(0,m.useState)(!0),[h,p]=(0,m.useState)(!1),[f,g]=(0,m.useState)("Click to edit this text"),[v,y]=(0,m.useState)("Editable Title"),[w,k]=(0,m.useState)("This is an editable description. Click to edit it — the textarea auto-sizes to fit the content without layout shift."),[j,N]=(0,m.useState)([{key:"status",label:"Status",value:"Active"}]),[_,I]=(0,m.useState)(!1),[C,T]=(0,m.useState)(!1),[R,A]=(0,m.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)(qr,{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)(lr,{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)(ot,{variant:"outline",className:"font-mono text-(length:--text-nano)",children:L},L))})}),(0,t.jsx)(lr,{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)(ot,{variant:"ghost",className:"font-mono text-(length:--text-nano)",children:L},L))})})]})]}),(0,t.jsx)(qr,{title:"Announcements",children:(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,t.jsx)(DT,{announcement:mGt,imageSrc:"/announcement-preview.svg",animationSrc:hGt,onDismiss:r(()=>{},"onDismiss")}),(0,t.jsx)(DT,{announcement:IU,imageSrc:"/announcement-preview.svg",onDismiss:r(()=>{},"onDismiss")}),(0,t.jsx)(DT,{announcement:{...IU,image:void 0,secondaryLink:void 0},onDismiss:r(()=>{},"onDismiss")})]})}),(0,t.jsx)(qr,{title:"Task Execution Controls",children:(0,t.jsx)(JGt,{})}),(0,t.jsx)(qr,{title:"Composer actions",children:(0,t.jsx)(tQt,{})}),(0,t.jsxs)(qr,{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)(cme,{context:(0,t.jsx)("span",{className:"text-sm font-medium",children:"Recent tasks"}),search:(0,t.jsx)(jt,{"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)(Yv,{issue:nT,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)(qr,{title:"Theme Toggle",children:(0,t.jsx)(lr,{title:"Variants",children:(0,t.jsxs)("div",{className:"flex max-w-sm flex-col items-start gap-3",children:[(0,t.jsx)(yw,{}),(0,t.jsx)(yw,{variant:"menu-action"}),(0,t.jsx)(yw,{variant:"compact-menu-action"})]})})}),(0,t.jsxs)(qr,{title:"Colors",children:[(0,t.jsx)(lr,{title:"Core",children:(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[(0,t.jsx)(nc,{name:"Background",cssVar:"--background"}),(0,t.jsx)(nc,{name:"Foreground",cssVar:"--foreground"}),(0,t.jsx)(nc,{name:"Card",cssVar:"--card"}),(0,t.jsx)(nc,{name:"Primary",cssVar:"--primary"}),(0,t.jsx)(nc,{name:"Primary foreground",cssVar:"--primary-foreground"}),(0,t.jsx)(nc,{name:"Secondary",cssVar:"--secondary"}),(0,t.jsx)(nc,{name:"Muted",cssVar:"--muted"}),(0,t.jsx)(nc,{name:"Muted foreground",cssVar:"--muted-foreground"}),(0,t.jsx)(nc,{name:"Accent",cssVar:"--accent"}),(0,t.jsx)(nc,{name:"Destructive",cssVar:"--destructive"}),(0,t.jsx)(nc,{name:"Border",cssVar:"--border"}),(0,t.jsx)(nc,{name:"Ring",cssVar:"--ring"})]})}),(0,t.jsx)(lr,{title:"Sidebar",children:(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[(0,t.jsx)(nc,{name:"Sidebar",cssVar:"--sidebar"}),(0,t.jsx)(nc,{name:"Sidebar border",cssVar:"--sidebar-border"})]})}),(0,t.jsx)(lr,{title:"Chart",children:(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[(0,t.jsx)(nc,{name:"Chart 1",cssVar:"--chart-1"}),(0,t.jsx)(nc,{name:"Chart 2",cssVar:"--chart-2"}),(0,t.jsx)(nc,{name:"Chart 3",cssVar:"--chart-3"}),(0,t.jsx)(nc,{name:"Chart 4",cssVar:"--chart-4"}),(0,t.jsx)(nc,{name:"Chart 5",cssVar:"--chart-5"})]})})]}),(0,t.jsxs)(qr,{title:"Runner activity",children:[(0,t.jsx)(f1,{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)(f1,{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)(qr,{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)(qr,{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,D])=>(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:D}}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:L})]},L))})}),(0,t.jsxs)(qr,{title:"Buttons",children:[(0,t.jsx)(lr,{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)(lr,{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)(lr,{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)(lr,{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)(vn,{})," New Issue"]}),(0,t.jsxs)(F,{variant:"outline",children:[(0,t.jsx)(Vw,{})," Upload"]}),(0,t.jsxs)(F,{variant:"destructive",children:[(0,t.jsx)(Sa,{})," Delete"]}),(0,t.jsxs)(F,{size:"sm",children:[(0,t.jsx)(vn,{})," Add"]})]})}),(0,t.jsx)(lr,{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)(qr,{title:"Badges",children:(0,t.jsx)(lr,{title:"Variants",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(ot,{variant:"default",children:"Default"}),(0,t.jsx)(ot,{variant:"secondary",children:"Secondary"}),(0,t.jsx)(ot,{variant:"outline",children:"Outline"}),(0,t.jsx)(ot,{variant:"destructive",children:"Destructive"}),(0,t.jsx)(ot,{variant:"ghost",children:"Ghost"})]})})}),(0,t.jsxs)(qr,{title:"Status System",children:[(0,t.jsx)(lr,{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)(Ja,{status:L},L))})}),(0,t.jsx)(lr,{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)(Up,{status:L},L))})}),(0,t.jsxs)(lr,{title:"Idle Slack conversation",children:[(0,t.jsx)(Yi,{status:"in_review",externalConversationState:"waiting",showLabel:!0}),(0,t.jsx)(Up,{status:"in_review",externalConversationState:"waiting"})]}),(0,t.jsxs)(lr,{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)(Yi,{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)(Yi,{status:n,onChange:a}),(0,t.jsxs)("span",{className:"text-sm",children:["Click the icon to change status (current: ",n,")"]})]})]}),!1,(0,t.jsx)(lr,{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 ${FEe[L]??"bg-neutral-400"}`})}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:L})]},L))})}),(0,t.jsx)(lr,{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,D])=>(0,t.jsx)(ot,{variant:"ghost",className:`px-1.5 text-(length:--text-nano) ${D}`,children:L},L))})}),(0,t.jsxs)(lr,{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)(ud,{issue:{id:"demo-1",identifier:"PAP-123",title:"Identifier only — no status yet"}}),(0,t.jsx)(ud,{issue:{id:"demo-2",identifier:"PAP-456",title:"With in_progress status",status:"in_progress"}}),(0,t.jsx)(ud,{issue:{id:"demo-3",identifier:"PAP-789",title:"Done status",status:"done"}}),(0,t.jsx)(ud,{issue:{id:"demo-4",identifier:"PAP-101",title:"Blocked status",status:"blocked"}}),(0,t.jsx)(ud,{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)(ud,{strikethrough:!0,issue:{id:"demo-5",identifier:"PAP-202",title:"Removed (strikethrough)",status:"todo"}})]})]})]}),(0,t.jsxs)(qr,{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)(lr,{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)(cx,{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)(cx,{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)(cx,{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)(cx,{state:"online",gradient:5,glow:"blue"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"online · blue glow"})]})]})}),(0,t.jsx)(lr,{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)(cx,{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)(cx,{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)(cx,{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)(cx,{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)(lr,{title:"Gradients",children:(0,t.jsx)("div",{className:"flex items-end gap-3 flex-wrap",children:Array.from({length:10},(L,D)=>(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[(0,t.jsx)(cx,{state:"online",size:"sm",gradient:D+1}),(0,t.jsx)("span",{className:"text-(length:--text-nano) font-mono text-muted-foreground",children:D+1})]},D))})})]}),(0,t.jsx)(qr,{title:"Form Elements",children:(0,t.jsxs)("div",{className:"grid gap-6 md:grid-cols-2",children:[(0,t.jsxs)(lr,{title:"Input",children:[(0,t.jsx)(jt,{placeholder:"Default input"}),(0,t.jsx)(jt,{placeholder:"Disabled input",disabled:!0,className:"mt-2"})]}),(0,t.jsx)(lr,{title:"Textarea",children:(0,t.jsx)(_n,{placeholder:"Write something..."})}),(0,t.jsx)(lr,{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)(Gs,{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)(Gs,{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)(Gs,{htmlFor:"check3",children:"Disabled item"})]})]})}),(0,t.jsx)(lr,{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)(Bh,{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)(Bh,{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)(Bh,{value:w,onSave:k,as:"p",className:"text-sm text-muted-foreground",placeholder:"Add a description...",multiline:!0})]})]})})]})}),(0,t.jsx)(qr,{title:"Select",children:(0,t.jsxs)("div",{className:"grid gap-6 md:grid-cols-2",children:[(0,t.jsxs)(lr,{title:"Default size",children:[(0,t.jsxs)(Oa,{value:l,onValueChange:c,children:[(0,t.jsx)($a,{className:"w-full",children:(0,t.jsx)(La,{placeholder:"Select status"})}),(0,t.jsxs)(Da,{children:[(0,t.jsx)(Cn,{value:"backlog",children:"Backlog"}),(0,t.jsx)(Cn,{value:"todo",children:"Todo"}),(0,t.jsx)(Cn,{value:"in_progress",children:"In Progress"}),(0,t.jsx)(Cn,{value:"in_review",children:"In Review"}),(0,t.jsx)(Cn,{value:"done",children:"Done"})]})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Current value: ",l]})]}),(0,t.jsx)(lr,{title:"Small trigger",children:(0,t.jsxs)(Oa,{defaultValue:"high",children:[(0,t.jsx)($a,{size:"sm",className:"w-full",children:(0,t.jsx)(La,{})}),(0,t.jsxs)(Da,{children:[(0,t.jsx)(Cn,{value:"critical",children:"Critical"}),(0,t.jsx)(Cn,{value:"high",children:"High"}),(0,t.jsx)(Cn,{value:"medium",children:"Medium"}),(0,t.jsx)(Cn,{value:"low",children:"Low"})]})]})})]})}),(0,t.jsx)(qr,{title:"Dropdown Menu",children:(0,t.jsxs)(ja,{children:[(0,t.jsx)(ya,{asChild:!0,children:(0,t.jsxs)(F,{variant:"outline",size:"sm",children:["Quick Actions",(0,t.jsx)(sn,{className:"h-4 w-4"})]})}),(0,t.jsxs)(wa,{align:"start",className:"w-56",children:[(0,t.jsxs)(hs,{children:[(0,t.jsx)(ds,{className:"h-4 w-4"}),"Mark as done",(0,t.jsx)(kEe,{children:"⌘D"})]}),(0,t.jsxs)(hs,{children:[(0,t.jsx)(FN,{className:"h-4 w-4"}),"Open docs"]}),(0,t.jsx)(mi,{}),(0,t.jsx)(XU,{checked:d,onCheckedChange:r(L=>u(L===!0),"onCheckedChange"),children:"Watch issue"}),(0,t.jsxs)(hs,{variant:"destructive",children:[(0,t.jsx)(Sa,{className:"h-4 w-4"}),"Delete issue"]})]})]})}),(0,t.jsx)(qr,{title:"Popover",children:(0,t.jsxs)(tr,{children:[(0,t.jsx)(pr,{asChild:!0,children:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Open Popover"})}),(0,t.jsxs)(Qn,{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)(qr,{title:"Collapsible",children:(0,t.jsxs)(il,{open:h,onOpenChange:p,className:"space-y-2",children:[(0,t.jsx)(Yl,{asChild:!0,children:(0,t.jsxs)(F,{variant:"outline",size:"sm",children:[h?"Hide":"Show"," advanced filters"]})}),(0,t.jsx)(ol,{className:"rounded-md border border-border p-3",children:(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(Gs,{htmlFor:"owner-filter",children:"Owner"}),(0,t.jsx)(jt,{id:"owner-filter",placeholder:"Filter by agent name"})]})})]})}),(0,t.jsx)(qr,{title:"Sheet",children:(0,t.jsxs)(ch,{children:[(0,t.jsx)(vme,{asChild:!0,children:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Open Side Panel"})}),(0,t.jsxs)(lh,{side:"right",children:[(0,t.jsxs)(Jh,{children:[(0,t.jsx)(im,{children:"Issue Properties"}),(0,t.jsx)(qC,{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)(Gs,{htmlFor:"sheet-title",children:"Title"}),(0,t.jsx)(jt,{id:"sheet-title",defaultValue:"Improve onboarding docs"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(Gs,{htmlFor:"sheet-description",children:"Description"}),(0,t.jsx)(_n,{id:"sheet-description",defaultValue:"Capture setup pitfalls and screenshots."})]})]}),(0,t.jsxs)(bme,{children:[(0,t.jsx)(F,{variant:"outline",children:"Cancel"}),(0,t.jsx)(F,{children:"Save"})]})]})]})}),(0,t.jsx)(qr,{title:"Scroll Area",children:(0,t.jsx)(Th,{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,D)=>(0,t.jsxs)("div",{className:"rounded-md border border-border p-2 text-sm",children:["Heartbeat run #",D+1,": completed successfully"]},D))})})}),(0,t.jsx)(qr,{title:"Command (CMDK)",children:(0,t.jsx)("div",{className:"rounded-md border border-border",children:(0,t.jsxs)(N3,{children:[(0,t.jsx)(r_,{placeholder:"Type a command or search..."}),(0,t.jsxs)(a_,{children:[(0,t.jsx)(i_,{children:"No results found."}),(0,t.jsxs)(Gu,{heading:"Pages",children:[(0,t.jsxs)(Lo,{children:[(0,t.jsx)(_x,{className:"h-4 w-4"}),"Dashboard"]}),(0,t.jsxs)(Lo,{children:[(0,t.jsx)(hd,{className:"h-4 w-4"}),"Issues"]})]}),(0,t.jsx)(hx,{}),(0,t.jsxs)(Gu,{heading:"Actions",children:[(0,t.jsxs)(Lo,{children:[(0,t.jsx)(cMe,{className:"h-4 w-4"}),"Open command palette"]}),(0,t.jsxs)(Lo,{children:[(0,t.jsx)(vn,{className:"h-4 w-4"}),"Create new issue"]})]})]})]})})}),(0,t.jsx)(qr,{title:"Breadcrumb",children:(0,t.jsx)(VK,{children:(0,t.jsxs)(HK,{children:[(0,t.jsx)(lC,{children:(0,t.jsx)(d5,{href:"#",children:"Projects"})}),(0,t.jsx)(u5,{}),(0,t.jsx)(lC,{children:(0,t.jsx)(d5,{href:"#",children:"Paperclip App"})}),(0,t.jsx)(u5,{}),(0,t.jsx)(lC,{children:(0,t.jsx)(XC,{children:"Issue List"})})]})})}),(0,t.jsxs)(qr,{title:"Cards",children:[(0,t.jsxs)(lr,{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)(ONe,{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)(lr,{title:"Standard Card",children:(0,t.jsxs)(Js,{children:[(0,t.jsxs)(eo,{children:[(0,t.jsx)(po,{children:"Card Title"}),(0,t.jsx)(Il,{children:"Card description with supporting text."})]}),(0,t.jsx)(Ha,{children:(0,t.jsx)("p",{className:"text-sm",children:"Card content goes here. This is the main body area."})}),(0,t.jsxs)(r3e,{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)(lr,{title:"Metric Cards",children:(0,t.jsxs)("div",{className:"grid md:grid-cols-2 xl:grid-cols-4 gap-4",children:[(0,t.jsx)(Kg,{icon:Zi,value:12,label:"Active Agents",description:"+3 this week"}),(0,t.jsx)(Kg,{icon:hd,value:48,label:"Open Issues"}),(0,t.jsx)(Kg,{icon:Oh,value:"$1,234",label:"Monthly Cost",description:"Under budget"}),(0,t.jsx)(Kg,{icon:wF,value:"99.9%",label:"Uptime"})]})})]}),(0,t.jsxs)(qr,{title:"Tabs",children:[(0,t.jsx)(lr,{title:"Default (pill) variant",children:(0,t.jsxs)(Ci,{defaultValue:"overview",children:[(0,t.jsxs)(Qc,{children:[(0,t.jsx)(Ma,{value:"overview",children:"Overview"}),(0,t.jsx)(Ma,{value:"runs",children:"Runs"}),(0,t.jsx)(Ma,{value:"config",children:"Config"}),(0,t.jsx)(Ma,{value:"costs",children:"Costs"})]}),(0,t.jsx)(ma,{value:"overview",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Overview tab content."})}),(0,t.jsx)(ma,{value:"runs",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Runs tab content."})}),(0,t.jsx)(ma,{value:"config",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Config tab content."})}),(0,t.jsx)(ma,{value:"costs",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Costs tab content."})})]})}),(0,t.jsx)(lr,{title:"Line variant",children:(0,t.jsxs)(Ci,{defaultValue:"summary",children:[(0,t.jsxs)(Qc,{variant:"line",children:[(0,t.jsx)(Ma,{value:"summary",children:"Summary"}),(0,t.jsx)(Ma,{value:"details",children:"Details"}),(0,t.jsx)(Ma,{value:"comments",children:"Comments"})]}),(0,t.jsx)(ma,{value:"summary",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Summary content with underline tabs."})}),(0,t.jsx)(ma,{value:"details",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Details content."})}),(0,t.jsx)(ma,{value:"comments",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-4",children:"Comments content."})})]})})]}),(0,t.jsxs)(qr,{title:"Entity Rows",children:[(0,t.jsxs)("div",{className:"border border-border rounded-md",children:[(0,t.jsx)(od,{leading:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Yi,{status:"in_progress"}),!1]}),identifier:"PAP-001",title:"Implement authentication flow",subtitle:"Responsible: Agent Alpha",trailing:(0,t.jsx)(Up,{status:"in_progress"}),onClick:r(()=>{},"onClick")}),(0,t.jsx)(od,{leading:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Yi,{status:"done"}),!1]}),identifier:"PAP-002",title:"Set up CI/CD pipeline",subtitle:"Completed 2 days ago",trailing:(0,t.jsx)(Up,{status:"done"}),onClick:r(()=>{},"onClick")}),(0,t.jsx)(od,{leading:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Yi,{status:"todo"}),!1]}),identifier:"PAP-003",title:"Write API documentation",trailing:(0,t.jsx)(Up,{status:"todo"}),onClick:r(()=>{},"onClick")}),(0,t.jsx)(od,{leading:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Yi,{status:"blocked"}),!1]}),identifier:"PAP-004",title:"Deploy to production",subtitle:"Blocked by PAP-001",trailing:(0,t.jsx)(Up,{status:"blocked"}),selected:!0})]}),(0,t.jsx)(lr,{title:"Membership action",children:(0,t.jsxs)("div",{className:"border border-border rounded-md",children:[(0,t.jsx)(od,{title:"Joined resource",subtitle:"Hover or focus the row to reveal the reserved action slot.",className:"group",trailing:(0,t.jsx)(Hg,{state:"joined",resourceName:"Joined resource",onJoin:r(()=>{},"onJoin"),onLeave:r(()=>{},"onLeave")})}),(0,t.jsx)(od,{title:"Left resource",subtitle:"Persistent action with dimmed row content.",className:"group text-foreground/55",trailing:(0,t.jsx)(Hg,{state:"left",resourceName:"Left resource",onJoin:r(()=>{},"onJoin"),onLeave:r(()=>{},"onLeave")})}),(0,t.jsx)(od,{title:"Leaving resource",subtitle:"Disabled while the optimistic mutation is pending.",className:"group text-foreground/55",trailing:(0,t.jsx)(Hg,{state:"left",pending:!0,pendingState:"left",resourceName:"Leaving resource",onJoin:r(()=>{},"onJoin"),onLeave:r(()=>{},"onLeave")})}),(0,t.jsx)(od,{title:"Joining resource",subtitle:"The target state is visible immediately while the server confirms.",className:"group",trailing:(0,t.jsx)(Hg,{state:"joined",pending:!0,pendingState:"joined",resourceName:"Joining resource",onJoin:r(()=>{},"onJoin"),onLeave:r(()=>{},"onLeave")})})]})})]}),(0,t.jsxs)(qr,{title:"Filter Bar",children:[(0,t.jsx)(v7,{filters:j,onRemove:r(L=>N(D=>D.filter(O=>O.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)(qr,{title:"Avatars",children:[(0,t.jsx)(lr,{title:"Sizes",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(Xi,{size:"sm",children:(0,t.jsx)(Ji,{children:"SM"})}),(0,t.jsx)(Xi,{children:(0,t.jsx)(Ji,{children:"DF"})}),(0,t.jsx)(Xi,{size:"lg",children:(0,t.jsx)(Ji,{children:"LG"})})]})}),(0,t.jsx)(lr,{title:"Group",children:(0,t.jsxs)(yme,{children:[(0,t.jsx)(Xi,{children:(0,t.jsx)(Ji,{children:"A1"})}),(0,t.jsx)(Xi,{children:(0,t.jsx)(Ji,{children:"A2"})}),(0,t.jsx)(Xi,{children:(0,t.jsx)(Ji,{children:"A3"})}),(0,t.jsx)(yEe,{children:"+5"})]})})]}),(0,t.jsx)(qr,{title:"App logos",children:(0,t.jsx)(lr,{title:"Official marks and runtime fallback",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(Cc,{name:"Notion",logoUrl:"/brands/apps/notion.svg",darkLogoUrl:"/brands/apps/notion-dark.svg",size:36}),(0,t.jsx)(Cc,{name:"Jira",logoUrl:"/brands/apps/jira.svg",darkLogoUrl:"/brands/apps/jira-dark.svg",size:44}),(0,t.jsx)(Cc,{name:"Fallback",logoUrl:"/brands/apps/does-not-exist.svg",size:36})]})})}),(0,t.jsxs)(qr,{title:"Agent personas",children:[(0,t.jsx)(lr,{title:"Stable palette identities",children:(0,t.jsx)("div",{className:"flex flex-wrap gap-3",children:nRe.map(L=>(0,t.jsx)(yr,{appearance:aRe(L),size:48,label:L},L))})}),(0,t.jsxs)(lr,{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)(u1,{muted:!0,state:"sleepy",motion:"still",size:128}),(0,t.jsx)(u1,{size:128})]})]})]}),(0,t.jsxs)(qr,{title:"Human identity",children:[(0,t.jsx)(lr,{title:"Sizes",children:(0,t.jsxs)("div",{className:"flex items-center gap-6",children:[(0,t.jsx)(Kl,{name:"Alex Morgan",size:"sm"}),(0,t.jsx)(Kl,{name:"Alex Morgan"}),(0,t.jsx)(Kl,{name:"Alex Morgan",size:"lg"})]})}),(0,t.jsx)(lr,{title:"Initials derivation",children:(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(Kl,{name:"Casey Jordan",size:"sm"}),(0,t.jsx)(Kl,{name:"Alpha",size:"sm"}),(0,t.jsx)(Kl,{name:"Quinn Lee",size:"sm"})]})}),(0,t.jsx)(lr,{title:"Custom initials",children:(0,t.jsx)(Kl,{name:"Backend Service",initials:"BS",size:"sm"})})]}),(0,t.jsx)(qr,{title:"Tooltips",children:(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Hover me"})}),(0,t.jsx)(Vn,{children:"This is a tooltip"})]}),(0,t.jsxs)(Kn,{children:[(0,t.jsx)(Wn,{asChild:!0,children:(0,t.jsx)(F,{variant:"ghost",size:"icon-sm",children:(0,t.jsx)(zd,{})})}),(0,t.jsx)(Vn,{children:"Settings"})]})]})}),(0,t.jsx)(qr,{title:"Dialog",children:(0,t.jsxs)(Qs,{children:[(0,t.jsx)(Jv,{asChild:!0,children:(0,t.jsx)(F,{variant:"outline",children:"Open Dialog"})}),(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:"Dialog Title"}),(0,t.jsx)(Ln,{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)(Gs,{children:"Name"}),(0,t.jsx)(jt,{placeholder:"Enter a name",className:"mt-1.5"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(Gs,{children:"Description"}),(0,t.jsx)(_n,{placeholder:"Describe...",className:"mt-1.5"})]})]}),(0,t.jsxs)(jr,{children:[(0,t.jsx)(F,{variant:"outline",children:"Cancel"}),(0,t.jsx)(F,{children:"Save"})]})]})]})}),(0,t.jsx)(qr,{title:"Empty State",children:(0,t.jsx)("div",{className:"border border-border rounded-md",children:(0,t.jsx)(Dn,{icon:gd,message:"No items to show. Create your first one to get started.",action:"Create Item",onAction:r(()=>{},"onAction")})})}),(0,t.jsx)(qr,{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:D,color:O})=>(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:[D,"%"]})]}),(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 ${O}`,style:{width:`${D}%`}})})]},L))})}),(0,t.jsx)(qr,{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)(qr,{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)(Ja,{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)(Xi,{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)(qr,{title:"Navigation Patterns",children:[(0,t.jsxs)(lr,{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)(dGt,{})]}),(0,t.jsxs)(lr,{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)(O3,{inline:!0,labels:["Choose trigger","Configure","Review"],step:e,availableStep:2,onSelect:s}),(0,t.jsx)(f0,{onSaveExit:r(()=>s(0),"onSaveExit"),children:(0,t.jsx)(F,{onClick:r(()=>s((e+1)%3),"onClick"),children:"Continue"})})]})]}),(0,t.jsx)(lr,{title:"Agent chat picker",children:(0,t.jsx)(eQt,{})}),(0,t.jsxs)(lr,{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)(Js,{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)(_x,{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)(hd,{className:"h-4 w-4"}),"Issues",(0,t.jsx)(ot,{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)(Zi,{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)($d,{className:"h-4 w-4"}),"Projects"]})]})]}),(0,t.jsx)(lr,{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)(uQ,{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)(vf,{className:"h-3.5 w-3.5 inline mr-1"}),"Org"]})]})})]}),(0,t.jsx)(qr,{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)(Yi,{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)(od,{leading:void 0,identifier:"PAP-101",title:"Build agent heartbeat system",onClick:r(()=>{},"onClick")}),(0,t.jsx)(od,{leading:void 0,identifier:"PAP-102",title:"Add cost tracking dashboard",onClick:r(()=>{},"onClick")})]})]})}),(0,t.jsx)(qr,{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)(_n,{placeholder:"Leave a comment...",rows:3}),(0,t.jsx)(F,{size:"sm",children:"Comment"})]})]})}),(0,t.jsx)(qr,{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)(qr,{title:"Skeletons",children:[(0,t.jsx)(lr,{title:"Individual",children:(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(Nn,{className:"h-4 w-48"}),(0,t.jsx)(Nn,{className:"h-8 w-full max-w-sm"}),(0,t.jsx)(Nn,{className:"h-20 w-full"})]})}),(0,t.jsx)(lr,{title:"Page Skeleton (list)",children:(0,t.jsx)("div",{className:"border border-border rounded-md p-4",children:(0,t.jsx)(Ca,{variant:"list"})})}),(0,t.jsx)(lr,{title:"Page Skeleton (detail)",children:(0,t.jsx)("div",{className:"border border-border rounded-md p-4",children:(0,t.jsx)(Ca,{variant:"detail"})})})]}),(0,t.jsx)(qr,{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)(gl,{}),(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)(gl,{orientation:"vertical"}),(0,t.jsx)("span",{className:"text-sm",children:"Right"})]})]})}),(0,t.jsxs)(qr,{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)(lr,{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)(sT,{team:Nc,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)(sT,{team:WGt,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)(sT,{team:Nc,selected:!1,onSelect:r(()=>{},"onSelect"),installed:qAe}),(0,t.jsx)(sT,{team:fde,selected:!1,onSelect:r(()=>{},"onSelect"),installed:VGt})]}),(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)(lr,{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)(YGt,{})]}),(0,t.jsx)(lr,{title:"TeamHierarchyPreview",children:(0,t.jsx)("div",{className:"max-w-md",children:(0,t.jsx)(LGt,{team:Nc})})}),(0,t.jsx)(lr,{title:"RequiredSkillsList",children:(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)($Gt,{skills:Nc.requiredSkills})})}),(0,t.jsx)(lr,{title:"EnvInputsList",children:(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(OGt,{inputs:Nc.envInputs})})}),(0,t.jsx)(lr,{title:"ExternalSourcesList",children:(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(FGt,{sources:Nc.sourceRefs})})}),(0,t.jsx)(lr,{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)(BGt,{team:fde,allowExternalSources:_,allowUnpinnedOptionalSources:C,allowLocalPathSources:R,onChange:r((L,D)=>{L==="external"&&I(D),L==="unpinned"&&T(D),L==="localPath"&&A(D)},"onChange")})})}),(0,t.jsx)(lr,{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)(zGt,{team:Nc,preparations:HGt})})})]}),(0,t.jsx)(qr,{title:"Common Icons (Lucide)",children:(0,t.jsx)("div",{className:"grid grid-cols-4 md:grid-cols-6 gap-4",children:[["Inbox",gd],["ListTodo",uQ],["CircleDot",hd],["Hexagon",$d],["Target",vf],["LayoutDashboard",_x],["Bot",Zi],["DollarSign",Oh],["History",Tl],["Search",ha],["Plus",vn],["Trash2",Sa],["Settings",zd],["User",kc],["Mail",pme],["Upload",Vw],["Zap",wF]].map(([L,D])=>(0,t.jsxs)("div",{className:"flex flex-col items-center gap-1.5 p-2",children:[(0,t.jsx)(D,{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)(qr,{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,D])=>(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:D}),(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)(qr,{title:"Issue Output Surface",children:[(0,t.jsx)(lr,{title:"Multiple outputs (primary video + 'Also produced')",children:(0,t.jsx)(TE,{workProducts:GGt})}),(0,t.jsx)(lr,{title:"Degraded output (invalid / failed attachment metadata)",children:(0,t.jsx)(TE,{workProducts:QGt})}),(0,t.jsx)(lr,{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)(qr,{title:"Tools & Access",children:[(0,t.jsxs)(lr,{title:"EnforcementBanner — default / denied-detected",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)($b,{companyId:"",forceVariant:"default",recentDenialCount:0}),(0,t.jsx)($b,{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)(lr,{title:"EnforcementBanner — presentational tones (info / warning / error)",children:[(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)($b,{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)($b,{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)($b,{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)(lr,{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)(AU,{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)(AU,{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)(lr,{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)(wGt,{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)(lr,{title:"BindingsTable (reused in the audit row drilldown)",children:[(0,t.jsx)(DAe,{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)(lr,{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)(Ja,{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)(lr,{title:"EmptyState (canonical, with description + action)",children:(0,t.jsx)(Dn,{icon:gd,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)(qr,{title:"Source Repositories",children:[(0,t.jsx)(lr,{title:"Empty and disconnected",children:(0,t.jsx)(uB,{selected:[],onChange:r(()=>{},"onChange"),state:"disconnected",onConnect:r(()=>{},"onConnect"),onRetry:r(()=>{},"onRetry")})}),(0,t.jsx)(lr,{title:"Selected and searchable",children:(0,t.jsx)(uB,{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)(qr,{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)(XGt,{})]}),(0,t.jsxs)(qr,{title:"Tasks created from a task",children:[(0,t.jsx)(lr,{title:"Subtasks and created work are independent",children:(0,t.jsx)("div",{className:"max-w-xl",children:(0,t.jsx)(OS,{subtasks:[nT],createdTasks:[{...nT,projectId:"design-board",project:{id:"design-board",name:"Board UI"}},{...nT,id:"design-followup",identifier:"PAP-428",title:"Write release notes",status:"todo",projectId:null}],projects:[]})})}),(0,t.jsxs)(lr,{title:"Empty, loading and failed",children:[(0,t.jsx)(OS,{subtasks:[],createdTasks:[],projects:[]}),(0,t.jsx)(OS,{subtasks:[],createdTasks:[],projects:[],isLoading:!0}),(0,t.jsx)(OS,{subtasks:[],createdTasks:[],projects:[],hasError:!0,onRetry:r(()=>{},"onRetry")})]})]}),(0,t.jsxs)(qr,{title:"Pending task input above composer",children:[(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:"A decision card sits above the ordinary message composer. Dismiss the card to keep a reopen control, or resolve it to clear the pending state."}),(0,t.jsx)(ZGt,{})]}),(0,t.jsx)(qr,{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)(qr,{title:"Saved provider API keys",children:[(0,t.jsx)(gw,{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)(gw,{options:[],value:"",onChange:r(()=>{},"onChange"),loading:!0,error:!1}),(0,t.jsx)(gw,{options:[],value:"",onChange:r(()=>{},"onChange"),loading:!1,error:!0})]}),(0,t.jsxs)(qr,{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)(pf,{interaction:CGt,currentUserId:Kr.currentUserId}),(0,t.jsx)(pf,{interaction:_Gt,currentUserId:Kr.currentUserId}),(0,t.jsx)(pf,{interaction:IGt,currentUserId:Kr.currentUserId})]})]}),(0,t.jsxs)(qr,{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)(FW,{children:[(0,t.jsx)(fv,{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)(V1,{}),(0,t.jsx)(fv,{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)(V1,{}),(0,t.jsx)(fv,{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)(qr,{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)(sW,{url:L},L))})}),(0,t.jsxs)(qr,{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)(Ya,{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)(Ya,{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)(Ya,{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)(Ya,{tone:"info",compact:!0,children:"Compact variant for embedding inside dialogs and modals."})]})]}),(0,t.jsxs)(qr,{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)(_6,{id:"design-image",title:"Launch artwork",contentPath:"/announcement-preview.svg",contentType:"image/svg+xml",originalFilename:"launch.svg",detail:"Image"}),(0,t.jsx)(_6,{id:"design-video",title:"Video preview unavailable",contentPath:"",contentType:"video/mp4",originalFilename:"preview.mp4",detail:"Video"})]})]}),(0,t.jsx)(qr,{title:"AI Connections",children:(0,t.jsx)(fGt,{})}),(0,t.jsxs)(qr,{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)(mw,{status:"needs_setup"}),(0,t.jsx)(mw,{status:"pending_approval"}),(0,t.jsx)(mw,{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(sQt,"DesignGuide");function nQt(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(nQt,"resolveWorktreeRunExecutionDisplayState");function rQt(e){const s=new Date(e);return Number.isNaN(s.getTime())?e:s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}r(rQt,"formatActivationTimestamp");function zAe(){return(0,t.jsxs)(ot,{variant:"outline",className:"text-muted-foreground",children:[(0,t.jsx)(Bd,{"aria-hidden":"true"}),"Managed by Paperclip Cloud"]})}r(zAe,"ManagedByCloudBadge");function jo({title:e,description:s,footnote:n,checked:a,onCheckedChange:i,disabled:o,settingKey:l,managed:c,ariaLabel:d}){const{hidden:u}=uh(),h=c?.managed===!0;return u.has(due(l))?null:(0,t.jsx)(Js,{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)(zAe,{}):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)(yi,{checked:a,onCheckedChange:r(p=>{h||i(p)},"onCheckedChange"),disabled:o||h,"aria-label":d})]})})}r(jo,"ExperimentalToggleCard");function aQt(){const{setBreadcrumbs:e}=Bn(),s=Ut(),{hidden:n}=uh(),[a,i]=(0,m.useState)(null);(0,m.useEffect)(()=>{e([{label:"Settings",href:"/company/settings"},{label:"Experimental"}])},[e]);const o=J({queryKey:P.instance.experimentalSettings,queryFn:r(()=>Tr.getExperimental(),"queryFn")}),l=Ne({mutationFn:r(async ee=>Tr.updateExperimental(ee),"mutationFn"),onMutate:r(async ee=>{await s.cancelQueries({queryKey:P.instance.experimentalSettings});const X=s.getQueryData(P.instance.experimentalSettings);return X&&s.setQueryData(P.instance.experimentalSettings,{...X,...ee}),{previousSettings:X}},"onMutate"),onSuccess:r(async ee=>{i(null),s.setQueryData(P.instance.experimentalSettings,ee),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((ee,X,Q)=>{Q?.previousSettings&&s.setQueryData(P.instance.experimentalSettings,Q.previousSettings),i(ee instanceof Error?ee.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=Tet(),d=o.data?.managedKeys??{},u=o.data?.enableWorktreeRunExecution===!0,h=d.enableWorktreeRunExecution?.managed===!0,p=nQt(o.data,Ret()),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,k=o.data?.enableIsolatedWorkspacesByDefault===!0,j=o.data?.enableStreamlinedUi!==!1;o.data?.enableConferenceRoomChat;const N=o.data?.enableClassicTaskInterface===!0,_=o.data?.enableIssuePlanDecompositions===!0,I=o.data?.enableExperimentalFileViewer===!0,C=o.data?.enableExternalObjects===!0,T=o.data?.enableBuiltInAgents===!0,R=o.data?.enableBetaSkills===!0,A=o.data?.enableSummaries===!0,L=o.data?.enableStatusCards===!0,D=d.enableSummaries?.managed===!0,O=d.enableStatusCards?.managed===!0,E=D&&!A,q=O&&L,B=o.data?.enableDecisions===!0,U=o.data?.enableGoalsSidebarLink===!0,z=o.data?.enableCases===!0,$=o.data?.enableServerInfoDebugView===!0,K=o.data?.enablePaperclipDeveloperMode===!0,H=o.data?.enableSimplifiedEnglishInteractions===!0,se=o.data?.enableFirstTaskPlanProposal===!0,Z=o.data?.enableSmokeLab===!0,ie=o.data?.autoRestartDevServerWhenIdle===!0,oe=r(ee=>!n.has(due(ee)),"isVisible"),Y=c&&oe("enableWorktreeRunExecution"),ne=Y||["autoRestartDevServerWhenIdle","enableManagedSandboxOnly","enablePaperclipDeveloperMode","enableServerInfoDebugView","enableSmokeLab","enableIssuePlanDecompositions"].some(oe),de=oe("enableClassicTaskInterface")||oe("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)(om,{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)(_s,{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)(jo,{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(ee=>l.mutate({enableAgentChat:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableAgentChat",managed:d.enableAgentChat,ariaLabel:"Toggle agent chat experimental setting"}),(0,t.jsx)(jo,{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:R,onCheckedChange:r(ee=>l.mutate({enableBetaSkills:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableBetaSkills",managed:d.enableBetaSkills,ariaLabel:"Toggle beta skills experimental setting"}),(0,t.jsx)(jo,{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:T,onCheckedChange:r(ee=>l.mutate({enableBuiltInAgents:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableBuiltInAgents",managed:d.enableBuiltInAgents,ariaLabel:"Toggle built-in agents experimental setting"}),(0,t.jsx)(jo,{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:z,onCheckedChange:r(ee=>l.mutate({enableCases:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableCases",managed:d.enableCases,ariaLabel:"Toggle cases experimental setting"}),(0,t.jsx)(jo,{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(ee=>l.mutate({enableChatConnectors:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableChatConnectors",managed:d.enableChatConnectors,ariaLabel:"Toggle chat connectors experimental setting"}),null,(0,t.jsx)(jo,{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(ee=>l.mutate({enableDecisions:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableDecisions",managed:d.enableDecisions,ariaLabel:"Toggle decisions experimental setting"}),(0,t.jsx)(jo,{title:"Enable Environments",description:"Show environment management in company settings and allow project and agent environment assignment controls.",checked:f,onCheckedChange:r(ee=>l.mutate({enableEnvironments:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableEnvironments",managed:d.enableEnvironments,ariaLabel:"Toggle environments experimental setting"}),(0,t.jsx)(jo,{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(ee=>l.mutate({enableExternalObjects:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableExternalObjects",managed:d.enableExternalObjects,ariaLabel:"Toggle external objects experimental setting"}),(0,t.jsx)(jo,{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(ee=>l.mutate({enableIsolatedWorkspaces:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableIsolatedWorkspaces",managed:d.enableIsolatedWorkspaces,ariaLabel:"Toggle isolated workspaces experimental setting"}),(0,t.jsx)(jo,{title:"Experimental File Viewer",description:"Show task detail controls for browsing and previewing workspace files relative to a task.",checked:I,onCheckedChange:r(ee=>l.mutate({enableExperimentalFileViewer:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableExperimentalFileViewer",managed:d.enableExperimentalFileViewer,ariaLabel:"Toggle experimental file viewer setting"}),(0,t.jsx)(jo,{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:se,onCheckedChange:r(ee=>l.mutate({enableFirstTaskPlanProposal:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableFirstTaskPlanProposal",managed:d.enableFirstTaskPlanProposal,ariaLabel:"Toggle first task plan proposal experimental setting"}),(0,t.jsx)(jo,{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(ee=>l.mutate({enableMcpAggregators:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableMcpAggregators",managed:d.enableMcpAggregators,ariaLabel:"Toggle MCP aggregators experimental setting"}),(0,t.jsx)(jo,{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(ee=>l.mutate({enableNativeRunner:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableNativeRunner",managed:d.enableNativeRunner,ariaLabel:"Toggle Paperclip Runner experimental setting"}),(0,t.jsx)(jo,{title:"Pixels Office",description:"Show a live pixel-art office floor plan where each agent is a character and each character shows how many tasks that agent is holding.",checked:o.data?.enablePixelsOffice===!0,onCheckedChange:r(ee=>l.mutate({enablePixelsOffice:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enablePixelsOffice",managed:d.enablePixelsOffice,ariaLabel:"Toggle Pixels Office experimental setting"}),(0,t.jsx)(jo,{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(ee=>l.mutate({enableSimplifiedEnglishInteractions:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableSimplifiedEnglishInteractions",managed:d.enableSimplifiedEnglishInteractions,ariaLabel:"Toggle simplified english interactions experimental setting"}),(0,t.jsx)(jo,{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(ee=>l.mutate(ee?{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)(jo,{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(ee=>l.mutate({enableStreamlinedUi:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableStreamlinedUi",managed:d.enableStreamlinedUi,ariaLabel:"Toggle Streamlined UI experimental setting"}),(0,t.jsx)(jo,{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:A,onCheckedChange:r(ee=>l.mutate(ee||!L?{enableSummaries:ee}:{enableSummaries:!1,enableStatusCards:!1}),"onCheckedChange"),disabled:l.isPending||q,settingKey:"enableSummaries",managed:d.enableSummaries,ariaLabel:"Toggle summaries experimental setting"}),w&&(0,t.jsx)(jo,{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:k,onCheckedChange:r(ee=>l.mutate({enableIsolatedWorkspacesByDefault:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableIsolatedWorkspacesByDefault",managed:d.enableIsolatedWorkspacesByDefault,ariaLabel:"Toggle isolated workspaces by default experimental setting"})]}),ne?(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)(jo,{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:ie,onCheckedChange:r(ee=>l.mutate({autoRestartDevServerWhenIdle:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"autoRestartDevServerWhenIdle",managed:d.autoRestartDevServerWhenIdle,ariaLabel:"Toggle guarded dev-server auto-restart"}),(0,t.jsx)(jo,{title:"Managed Environment Only",description:"Hide the local environment and run all agents in the platform-managed environment.",checked:y,onCheckedChange:r(ee=>l.mutate({enableManagedSandboxOnly:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableManagedSandboxOnly",managed:d.enableManagedSandboxOnly,ariaLabel:"Toggle managed environment only experimental setting"}),(0,t.jsx)(jo,{title:"Paperclip Developer Mode",description:"Show internal Paperclip maintainer tools and observability links, including Honeycomb trace queries on run pages.",checked:K,onCheckedChange:r(ee=>l.mutate({enablePaperclipDeveloperMode:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enablePaperclipDeveloperMode",managed:d.enablePaperclipDeveloperMode,ariaLabel:"Toggle Paperclip developer mode experimental setting"}),Y?(0,t.jsx)(Js,{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)(zAe,{}):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)(yi,{checked:u,onCheckedChange:r(ee=>{h||l.mutate({enableWorktreeRunExecution:ee})},"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)(so,{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:rQt(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)(_s,{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)(jo,{title:"Server Info Debug View",description:'Show a "Server" section in the account drawer with the current server restart time and running commit.',checked:$,onCheckedChange:r(ee=>l.mutate({enableServerInfoDebugView:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableServerInfoDebugView",managed:d.enableServerInfoDebugView,ariaLabel:"Toggle server info debug view experimental setting"}),(0,t.jsx)(jo,{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:Z,onCheckedChange:r(ee=>l.mutate({enableSmokeLab:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableSmokeLab",managed:d.enableSmokeLab,ariaLabel:"Toggle smoke lab experimental setting"}),(0,t.jsx)(jo,{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(ee=>l.mutate({enableIssuePlanDecompositions:ee}),"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)(jo,{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(ee=>l.mutate({enableClassicTaskInterface:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableClassicTaskInterface",managed:d.enableClassicTaskInterface,ariaLabel:"Toggle classic task interface experimental setting"}),(0,t.jsx)(jo,{title:"Goals Sidebar Link",description:"Restore the Goals item in the main sidebar while the goals surface is being evaluated.",checked:U,onCheckedChange:r(ee=>l.mutate({enableGoalsSidebarLink:ee}),"onCheckedChange"),disabled:l.isPending,settingKey:"enableGoalsSidebarLink",managed:d.enableGoalsSidebarLink,ariaLabel:"Toggle goals sidebar link experimental setting"})]}):null]})}r(aQt,"InstanceExperimentalSettings");function iQt(){const{userId:e,settled:s}=m3(),{setBreadcrumbs:n}=Bn(),{pushToast:a}=Ai(),i=Ut(),[o,l]=(0,m.useState)(""),[c,d]=(0,m.useState)(null),[u,h]=(0,m.useState)(new Set);(0,m.useEffect)(()=>{n([{label:"Settings",href:"/company/settings"},{label:"Instance settings",href:"/company/settings/instance/general"},{label:"Access"}])},[n]);const p=J({queryKey:P.access.adminUsers(o),queryFn:r(()=>ur.searchAdminUsers(o),"queryFn")}),f=J({...NTe(e),enabled:s&&p.isSuccess}),g=f.data??[],v=(0,m.useMemo)(()=>p.data?.find(j=>j.id===c)??null,[c,p.data]),y=J({queryKey:P.access.userCompanyAccess(c??""),queryFn:r(()=>ur.getUserCompanyAccess(c),"queryFn"),enabled:!!c});(0,m.useEffect)(()=>{!c&&p.data?.[0]&&d(p.data[0].id)},[c,p.data]),(0,m.useEffect)(()=>{y.data&&h(new Set(y.data.companyAccess.filter(j=>j.status==="active").map(j=>j.companyId)))},[y.data]);const w=Ne({mutationFn:r(()=>ur.setUserCompanyAccess(c,[...u]),"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")}),k=Ne({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 cn&&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)(y3,{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)(Js,{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)(Ii,{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)(Js,{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(()=>k.mutate(!(v?.isInstanceAdmin??!1)),"onClick"),disabled:k.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:u.has(j.id),onCheckedChange:r(N=>{h(_=>{const I=new Set(_);return N?I.add(j.id):I.delete(j.id),I})},"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(iQt,"InstanceAccess");var bde={getMine:r(e=>Te.get(`/companies/${e}/users/me/inbox-agent-policy`),"getMine"),updateMine:r((e,s)=>Te.put(`/companies/${e}/users/me/inbox-agent-policy`,s),"updateMine")},oQt=[{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 rT(e,s){return`${e}:${[...s].sort().join(",")}`}r(rT,"policyKey");function lQt({companyId:e}){const s=Ut(),[n,a]=(0,m.useState)(null),i=(0,m.useRef)(null),o=J({queryKey:e?P.inboxAgentPolicy.mine(e):["inbox-agent-policy","none"],queryFn:r(()=>bde.getMine(e),"queryFn"),enabled:!!e}),l=o.data,c=J({queryKey:e?P.agents.list(e):["agents","none"],queryFn:r(()=>Vt.list(e),"queryFn"),enabled:!!e}),d=(0,m.useMemo)(()=>(c.data??[]).filter(jf),[c.data]),u=(0,m.useMemo)(()=>d.map(g=>({id:g.id,name:g.name,title:g.title??g.role,icon:g.icon})),[d]),h=(0,m.useMemo)(()=>new Set(n?.allowedAgentIds??[]),[n?.allowedAgentIds]);(0,m.useEffect)(()=>{if(!l)return;const g=rT(l.mode,l.allowedAgentIds);a(v=>v===null||rT(v.mode,v.allowedAgentIds)===i.current?{mode:l.mode,allowedAgentIds:l.allowedAgentIds}:v),i.current=g},[l]);const p=Ne({mutationFn:r(g=>bde.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&&rT(n.mode,n.allowedAgentIds)!==rT(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)(gd,{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)(xu,{ariaLabel:"Inbox agent archiving policy",value:n.mode,onValueChange:r(g=>a(v=>v&&{...v,mode:g}),"onValueChange"),options:oQt,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)(iy,{agents:u,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)(rt,{className:"size-4 animate-spin"}):(0,t.jsx)(of,{className:"size-4"}),p.isPending?"Saving…":"Save"]})]})]})}r(lQt,"InboxAgentPolicyControl");function cQt(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(cQt,"deriveInitials");function dQt(){const{setBreadcrumbs:e}=Bn(),{selectedCompanyId:s,selectedCompany:n}=ps(),a=Ut(),i=(0,m.useId)(),o=(0,m.useRef)(null),[l,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(""),[h,p]=(0,m.useState)(null),f=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1});(0,m.useEffect)(()=>{e([{label:"Settings",href:"/company/settings"},{label:"Profile"}])},[e]),(0,m.useEffect)(()=>{const R=f.data;R&&(c(R.user.name??""),u(R.user.image??""))},[f.data]);function g(R){a.setQueryData(P.auth.session,A=>A&&{...A,user:{...A.user,...R}})}r(g,"syncSessionProfile");async function v(R){const A=await za.updateProfile(R);return g(A),A}r(v,"persistProfile");function y(){return l.trim()||f.data?.user.name||"Board"}r(y,"resolveProfileName");const w=Ne({mutationFn:r(R=>v(R),"mutationFn"),onSuccess:r(R=>{p(null),c(R.name??""),u(R.image??"")},"onSuccess"),onError:r(R=>{p(R instanceof Error?R.message:"Failed to update profile.")},"onError")}),k=Ne({mutationFn:r(async R=>{if(!s)throw new Error("Select an organization before uploading a profile avatar.");const A=await P0.uploadImage(s,R,`profiles/${f.data?.user.id??"board-user"}`);return v({name:y(),image:A.contentPath})},"mutationFn"),onSuccess:r(R=>{p(null),c(R.name??""),u(R.image??"")},"onSuccess"),onError:r(R=>{p(R instanceof Error?R.message:"Failed to upload avatar.")},"onError")}),j=Ne({mutationFn:r(()=>v({name:y(),image:null}),"mutationFn"),onSuccess:r(R=>{p(null),c(R.name??""),u(R.image??"")},"onSuccess"),onError:r(R=>{p(R instanceof Error?R.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,I=cQt(N),C=w.isPending||k.isPending||j.isPending,T=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)(v_,{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)(Js,{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(R=>{const A=R.target.files?.[0];A&&(k.mutate(A),R.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:k.isPending?(0,t.jsx)(rt,{className:"size-4 animate-spin"}):(0,t.jsx)(cQ,{className:"size-4"})}),(0,t.jsxs)(Xi,{size:"lg",className:"data-[size=lg]:size-24 ring-4 ring-background shadow-xl",children:[_?(0,t.jsx)(Jc,{src:_,alt:N}):null,(0,t.jsx)(Ji,{children:I})]})]}),(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:[k.isPending?(0,t.jsx)(rt,{className:"size-4 animate-spin"}):(0,t.jsx)(cQ,{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)(rt,{className:"size-4 animate-spin"}):(0,t.jsx)(Sa,{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. ",T]})]})]})})]}),(0,t.jsxs)("form",{className:"grid gap-6 md:grid-cols-2",onSubmit:r(R=>{R.preventDefault(),w.mutate({name:y(),image:d.trim()||null})},"onSubmit"),children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(Gs,{htmlFor:"profile-name",children:"Display name"}),(0,t.jsx)(jt,{id:"profile-name",value:l,onChange:r(R=>c(R.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)(Gs,{htmlFor:"profile-email",children:"Email"}),(0,t.jsx)(jt,{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)(rt,{className:"size-4 animate-spin"}):(0,t.jsx)(of,{className:"size-4"}),w.isPending?"Saving...":"Save profile"]})})]}),(0,t.jsx)(lQt,{companyId:s})]})]})}r(dQt,"ProfileSettings");function uQt(e){return e?e.split(/\r?\n/).map(s=>s.trim()).find(Boolean)??null:null}r(uQt,"firstNonEmptyLine");function vde(e){return uQt(e.lastError)??"Plugin entered an error state without a stored error message."}r(vde,"getPluginErrorSummary");function yde(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(yde,"isExperimentalPluginIdentity");function jde(){return(0,t.jsx)(ot,{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(jde,"ExperimentalBadge");function mQt(){const{selectedCompany:e}=ps(),{setBreadcrumbs:s}=Bn(),n=Ut(),{pushToast:a}=fa(),[i,o]=(0,m.useState)(""),[l,c]=(0,m.useState)(!1),[d,u]=(0,m.useState)(null),[h,p]=(0,m.useState)(""),[f,g]=(0,m.useState)(null);(0,m.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}=J({queryKey:P.plugins.all,queryFn:r(()=>rl.list(),"queryFn")}),k=J({queryKey:P.plugins.examples,queryFn:r(()=>rl.listBundled(),"queryFn")}),j=r(()=>{n.invalidateQueries({queryKey:P.plugins.all}),n.invalidateQueries({queryKey:P.plugins.examples}),n.invalidateQueries({queryKey:P.plugins.uiContributions})},"invalidatePluginQueries"),N=Ne({mutationFn:r(E=>rl.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")}),_=Ne({mutationFn:r(E=>rl.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")}),I=Ne({mutationFn:r(E=>rl.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=Ne({mutationFn:r(E=>rl.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")}),T=v??[],R=k.data??[],A=new Map(T.map(E=>[E.packageName,E])),L=new Map(R.map(E=>[E.packageName,E])),D=N.variables?.isLocalPath?N.error?.message??null:null,O=(0,m.useMemo)(()=>new Map(T.map(E=>[E.id,vde(E)])),[T]);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)(Zg,{className:"h-6 w-6 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Plugin Manager"})]}),(0,t.jsxs)(Qs,{open:l,onOpenChange:c,children:[(0,t.jsx)(Jv,{asChild:!0,children:(0,t.jsxs)(F,{size:"sm",className:"gap-2",children:[(0,t.jsx)(vn,{className:"h-4 w-4"}),"Install Plugin"]})}),(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:"Install Plugin"}),(0,t.jsx)(Ln,{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)(Gs,{htmlFor:"packageName",children:"npm Package Name"}),(0,t.jsx)(jt,{id:"packageName",placeholder:"@tickernelz/paperclip-pro-plugin-example",value:i,onChange:r(E=>o(E.target.value),"onChange")})]})}),(0,t.jsxs)(jr,{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)(_s,{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)(om,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Available Plugins"}),(0,t.jsx)(ot,{variant:"outline",children:"Bundled"})]}),D&&(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:D}),k.isLoading?(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading bundled plugins..."}):k.error?(0,t.jsx)("div",{className:"text-sm text-destructive",children:"Failed to load bundled plugins."}):R.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)(Js,{className:"block py-0",children:(0,t.jsx)("ul",{className:"divide-y",children:R.map(E=>{const q=A.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)(ot,{variant:"outline",children:E.tag==="first-party"?"First-party":"Example"}),yde({packageName:E.packageName,packagePath:E.localPath,bundledExperimental:E.experimental})&&(0,t.jsx)(jde,{}),q?(0,t.jsx)(ot,{variant:q.status==="ready"?"default":"secondary",className:q.status==="ready"?"bg-green-600 hover:bg-green-700":"",children:q.status}):(0,t.jsx)(ot,{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:I.isPending,onClick:r(()=>I.mutate(q.id),"onClick"),children:"Enable"}),(0,t.jsx)(F,{variant:"outline",size:"sm",asChild:!0,children:(0,t.jsx)(Qe,{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)(Zg,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Installed Plugins"})]}),T.length?(0,t.jsx)(Js,{className:"block py-0",children:(0,t.jsx)("ul",{className:"divide-y",children:T.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)(Qe,{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)(ot,{variant:"outline",children:L.get(E.packageName)?.tag==="first-party"?"First-party":"Example"}),yde({packageName:E.packageName,packagePath:E.packagePath,manifestJson:E.manifestJson,bundledExperimental:L.get(E.packageName)?.experimental})&&(0,t.jsx)(jde,{})]}),(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)(_s,{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:O.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)(ot,{variant:E.status==="ready"?"default":E.status==="error"?"destructive":"secondary",className:W("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):I.mutate(E.id)},"onClick"),disabled:I.isPending||C.isPending,children:(0,t.jsx)(hK,{className:W("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(()=>{u(E.id),p(E.manifestJson.displayName??E.packageName)},"onClick"),disabled:_.isPending,children:(0,t.jsx)(sDe,{className:"h-4 w-4"})})]}),(0,t.jsx)(F,{variant:"outline",size:"sm",className:"mt-2 h-8",asChild:!0,children:(0,t.jsxs)(Qe,{to:`/company/settings/instance/plugins/${E.id}`,children:[(0,t.jsx)(zd,{className:"h-4 w-4"}),"Configure"]})})]})})]})},E.id))})}):(0,t.jsx)(Js,{className:"bg-muted/30",children:(0,t.jsxs)(Ha,{className:"flex flex-col items-center justify-center py-10",children:[(0,t.jsx)(Zg,{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)(Qs,{open:d!==null,onOpenChange:r(E=>{E||u(null)},"onOpenChange"),children:(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:"Uninstall Plugin"}),(0,t.jsxs)(Ln,{children:["Are you sure you want to uninstall ",(0,t.jsx)("strong",{children:h}),"? This action cannot be undone."]})]}),(0,t.jsxs)(jr,{children:[(0,t.jsx)(F,{variant:"outline",onClick:r(()=>u(null),"onClick"),children:"Cancel"}),(0,t.jsx)(F,{variant:"destructive",disabled:_.isPending,onClick:r(()=>{d&&_.mutate(d,{onSettled:r(()=>u(null),"onSettled")})},"onClick"),children:_.isPending?"Uninstalling...":"Uninstall"})]})]})}),(0,t.jsx)(Qs,{open:f!==null,onOpenChange:r(E=>{E||g(null)},"onOpenChange"),children:(0,t.jsxs)(Xs,{className:"sm:max-w-2xl",children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:"Error Details"}),(0,t.jsxs)(Ln,{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)(_s,{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?vde(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)(jr,{children:(0,t.jsx)(F,{variant:"outline",onClick:r(()=>g(null),"onClick"),children:"Close"})})]})})]})}r(mQt,"PluginManager");function hQt(){const{selectedCompany:e,selectedCompanyId:s}=ps(),{setBreadcrumbs:n}=Bn(),{companyPrefix:a,pluginId:i}=Ia(),{hideHostPaths:o}=U_(),[l,c]=(0,m.useState)("configuration"),{data:d,isLoading:u}=J({queryKey:P.plugins.detail(i),queryFn:r(()=>rl.get(i),"queryFn"),enabled:!!i}),{data:h,isLoading:p}=J({queryKey:P.plugins.health(i),queryFn:r(()=>rl.health(i),"queryFn"),enabled:!!i&&d?.status==="ready",refetchInterval:3e4}),{data:f}=J({queryKey:P.plugins.dashboard(i),queryFn:r(()=>rl.dashboard(i),"queryFn"),enabled:!!i,refetchInterval:3e4}),{data:g}=J({queryKey:P.plugins.logs(i),queryFn:r(()=>rl.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:k,isLoading:j}=J({queryKey:w,queryFn:r(()=>rl.getConfig(i,s),"queryFn"),enabled:!!i&&!!y&&!!s}),{slots:N}=ed({slotTypes:["settingsPage"],companyId:s,enabled:!!s}),_=N.filter(q=>q.pluginId===i),I=_.length>0;if((0,m.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,m.useEffect)(()=>{c("configuration")},[i]),u)return(0,t.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading plugin details..."});if(!d)return(0,t.jsx)(bn,{to:"/company/settings/instance/plugins",replace:!0});const C=d.status,T=d.status==="ready"?"default":d.status==="error"?"destructive":"secondary",R=d.manifestJson.description||"No description provided.",A=d.manifestJson.capabilities??[],L=d.manifestJson.environmentDrivers??[],D=d.manifestJson.localFolders??[],O=D.length>0&&!o,E=L.map(q=>q.displayName?.trim()||q.driverKey).filter((q,B,U)=>U.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)(Qe,{to:"/company/settings/instance/plugins",children:(0,t.jsx)(F,{variant:"outline",size:"icon",className:"h-8 w-8",children:(0,t.jsx)(vl,{className:"h-4 w-4"})})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Zg,{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)(ot,{variant:T,className:"ml-2",children:C}),(0,t.jsxs)(ot,{variant:"outline",className:"ml-1",children:["v",d.manifestJson.version??d.version]})]})]}),(0,t.jsxs)(Ci,{value:l,onValueChange:r(q=>c(q),"onValueChange"),className:"space-y-6",children:[(0,t.jsx)(cc,{align:"start",items:[{value:"configuration",label:"Configuration"},{value:"status",label:"Status"}],value:l,onValueChange:r(q=>c(q),"onValueChange")}),(0,t.jsx)(ma,{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:R})]}),(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)(ot,{variant:"outline",className:"capitalize",children:q},q)):(0,t.jsx)("span",{className:"text-foreground",children:"None"})})]})]})]})]}),(0,t.jsx)(gl,{}),(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"})}),O?(0,t.jsx)(pQt,{pluginId:i,companyId:s,declarations:D}):null,I?(0,t.jsx)("div",{className:"space-y-3",children:_.map(q=>(0,t.jsx)(Su,{slot:q,context:{companyId:s,companyPrefix:a??null},missingBehavior:"placeholder"},`${q.pluginKey}:${q.id}`))}):y?(0,t.jsx)(vQt,{pluginId:i,companyId:s,schema:v,initialValues:k?.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)(Qe,{to:"/company/settings/instance/environments",children:(0,t.jsx)(F,{variant:"outline",size:"sm",children:"Open Environments"})})})]}):O?null:(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"This plugin does not require any settings."})]})]})}),(0,t.jsx)(ma,{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)(Js,{children:[(0,t.jsxs)(eo,{children:[(0,t.jsxs)(po,{className:"text-base flex items-center gap-1.5",children:[(0,t.jsx)(Vm,{className:"h-4 w-4"}),"Runtime Dashboard"]}),(0,t.jsx)(Il,{children:"Worker process, scheduled jobs, and webhook deliveries"})]}),(0,t.jsx)(Ha,{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)(Vm,{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)(ot,{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:yQt(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)(_s,{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:jQt(f.worker.lastCrashAt)})]})]})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No worker process registered."})]}),(0,t.jsx)(gl,{}),(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)(h0,{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)(wQt,{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)(ot,{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:Nde(q.durationMs)}):null,(0,t.jsx)("span",{title:q.createdAt,children:kde(q.createdAt)})]})]},q.id))}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground italic",children:"No job runs recorded yet."})]}),(0,t.jsx)(gl,{}),(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)(bK,{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)(NQt,{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:Nde(q.durationMs)}):null,(0,t.jsx)("span",{title:q.createdAt,children:kde(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)(no,{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)(Js,{children:[(0,t.jsxs)(eo,{children:[(0,t.jsxs)(po,{className:"text-base flex items-center gap-1.5",children:[(0,t.jsx)(mQ,{className:"h-4 w-4"}),"Recent Logs"]}),(0,t.jsxs)(Il,{children:["Last ",g.length," log entries"]})]}),(0,t.jsx)(Ha,{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)(ot,{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)(Js,{children:[(0,t.jsx)(eo,{children:(0,t.jsxs)(po,{className:"text-base flex items-center gap-1.5",children:[(0,t.jsx)(mQ,{className:"h-4 w-4"}),"Health Status"]})}),(0,t.jsx)(Ha,{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)(ot,{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)(QPe,{className:"h-4 w-4 shrink-0 text-green-500"}):(0,t.jsx)(lc,{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)(ot,{variant:T,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)(Js,{children:[(0,t.jsx)(eo,{children:(0,t.jsx)(po,{className:"text-base",children:"Details"})}),(0,t.jsxs)(Ha,{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)(Js,{children:[(0,t.jsx)(eo,{children:(0,t.jsxs)(po,{className:"text-base flex items-center gap-1.5",children:[(0,t.jsx)(Al,{className:"h-4 w-4"}),"Permissions"]})}),(0,t.jsx)(Ha,{children:A.length>0?(0,t.jsx)("ul",{className:"space-y-2 text-sm text-muted-foreground",children:A.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(hQt,"PluginSettings");function pQt({pluginId:e,companyId:s,declarations:n}){const{data:a,isLoading:i,error:o}=J({queryKey:s?P.plugins.localFolders(e,s):["plugins",e,"companies","none","local-folders"],queryFn:r(()=>rl.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)(Ao,{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)(rt,{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)(fQt,{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(pQt,"PluginLocalFoldersSettings");function fQt({pluginId:e,companyId:s,declaration:n,status:a}){const i=Ut(),o=a?.path??"",[l,c]=(0,m.useState)(o),[d,u]=(0,m.useState)(null);(0,m.useEffect)(()=>{c(o),u(null)},[o,n.folderKey]);const h=Ne({mutationFn:r(y=>rl.configureLocalFolder(e,s,n.folderKey,{path:y,access:n.access,requiredDirectories:n.requiredDirectories,requiredFiles:n.requiredFiles}),"mutationFn"),onSuccess:r(y=>{u({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=>{u({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,m.useCallback)(()=>{if(!p){u({type:"error",text:"Local folder path is required."});return}if(!bQt(p)){u({type:"error",text:"Local folder must be a full absolute path."});return}u(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)(ot,{variant:"outline",className:"font-mono text-(length:--text-nano)",children:n.folderKey}),(0,t.jsx)(ot,{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)(ot,{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)(pF,{label:"Configured",value:a?.configured?"Yes":"No",ok:!!a?.configured}),(0,t.jsx)(pF,{label:"Readable",value:a?.readable?"Yes":"No",ok:!!a?.readable}),(0,t.jsx)(pF,{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),u(null)},"onChange"),placeholder:"/absolute/path/to/folder"}),(0,t.jsx)(yd,{className:"h-8"}),(0,t.jsxs)(F,{size:"sm",onClick:v,disabled:h.isPending||!f||!s,children:[h.isPending?(0,t.jsx)(rt,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(of,{className:"h-3.5 w-3.5"}),"Save"]})]})]}),(0,t.jsx)(xQt,{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(fQt,"PluginLocalFolderRow");function pF({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)(ot,{variant:n?"default":"secondary",children:s})]})}r(pF,"FolderStatusMetric");function xQt({status:e,declaration:s}){const n=e?.requiredDirectories??s.requiredDirectories??[],a=e?.requiredFiles??s.requiredFiles??[],i=e?.missingDirectories??n,o=e?.missingFiles??a,l=gQt(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)(wde,{title:"Required directories",items:n,missingItems:i,missingLabel:"Missing directories",inspectionUnavailable:l}),(0,t.jsx)(wde,{title:"Required files",items:a,missingItems:o,missingLabel:"Missing files",inspectionUnavailable:l})]})}r(xQt,"FolderRequirements");function gQt(e){return!e?.configured||e.readable?!1:e.problems.some(s=>s.code==="missing"||s.code==="not_readable"||s.code==="not_directory")}r(gQt,"isRootNotInspected");function wde({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)(ot,{variant:"secondary",className:"text-(length:--text-nano)",children:"Not inspected"}):n.length>0?(0,t.jsxs)(ot,{variant:"destructive",className:"text-(length:--text-nano)",children:[n.length," missing"]}):(0,t.jsx)(ot,{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(wde,"RequirementList");function bQt(e){return e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)||e.startsWith("\\\\")}r(bQt,"isLikelyAbsolutePath");function vQt({pluginId:e,companyId:s,schema:n,initialValues:a,isLoading:i,pluginStatus:o,supportsConfigTest:l}){const c=Ut(),[d,u]=(0,m.useState)(()=>({...tf(n),...a??{}})),h=(0,m.useRef)(!1);(0,m.useEffect)(()=>{h.current=!1,u(tf(n))},[s,e,n]),(0,m.useEffect)(()=>{a&&!h.current&&(h.current=!0,u({...tf(n),...a}))},[a,n]);const[p,f]=(0,m.useState)({}),[g,v]=(0,m.useState)(null),[y,w]=(0,m.useState)(null),k=JSON.stringify(d)!==JSON.stringify({...tf(n),...a??{}}),j=Ne({mutationFn:r(T=>{if(!s)throw new Error("Select an organization before saving plugin configuration.");return rl.saveConfig(e,s,T)},"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(T=>{v({type:"error",text:T.message||"Failed to save configuration."})},"onError")}),N=Ne({mutationFn:r(T=>{if(!s)throw new Error("Select an organization before testing plugin configuration.");return rl.testConfig(e,s,T)},"mutationFn"),onSuccess:r(T=>{T.valid?w({type:"success",text:"Configuration test passed."}):w({type:"error",text:T.message||"Configuration test failed."})},"onSuccess"),onError:r(T=>{w({type:"error",text:T.message||"Configuration test failed."})},"onError")}),_=(0,m.useCallback)(T=>{u(T),f({}),v(null)},[]),I=(0,m.useCallback)(()=>{const T=_v(n,d);if(Object.keys(T).length>0){f(T);return}f({}),j.mutate(d)},[n,d,j]),C=(0,m.useCallback)(()=>{const T=_v(n,d);if(Object.keys(T).length>0){f(T);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)(rt,{className:"h-4 w-4 animate-spin"}),"Loading configuration..."]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(__,{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:I,disabled:j.isPending||!k,size:"sm",children:j.isPending?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(rt,{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)(rt,{className:"h-3.5 w-3.5 animate-spin"}),"Testing..."]}):"Test Configuration"})]})]})}r(vQt,"PluginConfigForm");function yQt(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(yQt,"formatUptime");function Nde(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}r(Nde,"formatDuration");function kde(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(kde,"formatRelativeTime");function jQt(e){return new Date(e).toLocaleString()}r(jQt,"formatTimestamp");function wQt({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(wQt,"JobStatusDot");function NQt({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(NQt,"DeliveryStatusDot");function fF({adapter:e,canRemove:s,onToggle:n,onRemove:a,onReload:i,onReinstall:o,isToggling:l,isReloading:c,isReinstalling:d,overriddenBy:u,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:W("font-medium",e.disabled&&"text-muted-foreground line-through"),children:e.label&&e.label!==e.type?e.label:kf(e.type)}),(0,t.jsx)(ot,{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)(Ao,{className:"h-4 w-4 text-amber-500"})}):(0,t.jsx)("span",{title:"Installed from npm",children:(0,t.jsx)(Wh,{className:"h-4 w-4 text-red-500"})})),e.version&&(0,t.jsxs)(ot,{variant:"secondary",className:"font-mono text-(length:--text-nano)",children:["v",e.version]}),e.overriddenBuiltin&&(0,t.jsx)(ot,{variant:"secondary",className:"text-blue-600 border-blue-400",children:"Overrides built-in"}),u&&(0,t.jsxs)(ot,{variant:"secondary",className:"text-blue-600 border-blue-400",children:["Overridden by ",u]}),e.disabled&&(0,t.jsx)(ot,{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)(To,{className:W("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)(Bi,{className:W("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)(hK,{className:W("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)(Sa,{className:"h-4 w-4"})})]})]})})}r(fF,"AdapterRow");function kQt(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(kQt,"fetchNpmLatestVersion");function SQt({adapter:e,open:s,isReinstalling:n,onConfirm:a,onCancel:i}){const{data:o,isLoading:l}=J({queryKey:["npm-latest-version",e?.packageName],queryFn:r(()=>e?.packageName?kQt(e.packageName):null,"queryFn"),enabled:s&&!!e?.packageName,staleTime:6e4}),c=e?.version&&o&&e.version===o;return(0,t.jsx)(Qs,{open:s,onOpenChange:r(d=>{d||i()},"onOpenChange"),children:(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:"Reinstall Adapter"}),(0,t.jsxs)(Ln,{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)(jr,{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(SQt,"ReinstallDialog");function Sde(){const{selectedCompany:e}=ps(),{setBreadcrumbs:s}=Bn(),n=Ut(),{pushToast:a}=fa(),[i,o]=(0,m.useState)(""),[l,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(!1),[h,p]=(0,m.useState)(!1),[f,g]=(0,m.useState)(null),[v,y]=(0,m.useState)(null);(0,m.useEffect)(()=>{s([{label:e?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Adapters"}])},[e?.name,s]);const{data:w,isLoading:k}=J({queryKey:P.adapters.all,queryFn:r(()=>Fm.list(),"queryFn")}),j=r(()=>{n.invalidateQueries({queryKey:P.adapters.all})},"invalidate"),N=Ne({mutationFn:r(E=>Fm.install(E),"mutationFn"),onSuccess:r(E=>{j(),p(!1),o(""),c(""),u(!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")}),_=Ne({mutationFn:r(E=>Fm.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")}),I=Ne({mutationFn:r(({type:E,disabled:q})=>Fm.setDisabled(E,q),"mutationFn"),onSuccess:r(()=>{j()},"onSuccess"),onError:r(E=>{a({title:"Toggle failed",body:E.message,tone:"error"})},"onError")}),C=Ne({mutationFn:r(({type:E,paused:q})=>Fm.setOverridePaused(E,q),"mutationFn"),onSuccess:r(()=>{j()},"onSuccess"),onError:r(E=>{a({title:"Override toggle failed",body:E.message,tone:"error"})},"onError")}),T=Ne({mutationFn:r(E=>Fm.reload(E),"mutationFn"),onSuccess:r(E=>{j(),QB(E.type),lJ(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")}),R=Ne({mutationFn:r(E=>Fm.reinstall(E),"mutationFn"),onSuccess:r(E=>{j(),QB(E.type),lJ(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")}),A=(w??[]).filter(E=>E.source==="builtin"),L=(w??[]).filter(E=>E.source==="external"),D=(w??[]).filter(E=>E.source==="external"&&E.overriddenBuiltin).filter(E=>!A.some(q=>q.type===E.type)).map(E=>({type:E.type,label:kf(E.type),overriddenBy:[E.packageName,E.version?`v${E.version}`:void 0].filter(Boolean).join(" "),overridePaused:!!E.overridePaused,menuDisabled:!!E.disabled}));if(k)return(0,t.jsx)("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading adapters..."});const O=N.isPending||_.isPending||I.isPending||C.isPending||T.isPending||R.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)(Vm,{className:"h-6 w-6 text-muted-foreground"}),(0,t.jsx)("h1",{className:"text-xl font-semibold",children:"Adapters"}),(0,t.jsx)(ot,{variant:"outline",className:"text-amber-600 border-amber-400",children:"Alpha"})]}),(0,t.jsxs)(Qs,{open:h,onOpenChange:p,children:[(0,t.jsx)(Jv,{asChild:!0,children:(0,t.jsxs)(F,{size:"sm",className:"gap-2",children:[(0,t.jsx)(vn,{className:"h-4 w-4"}),"Install Adapter"]})}),(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:"Install External Adapter"}),(0,t.jsxs)(Ln,{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:W("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(()=>u(!1),"onClick"),children:[(0,t.jsx)(Wh,{className:"h-3.5 w-3.5"}),"npm package"]}),(0,t.jsxs)("button",{type:"button",className:W("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(()=>u(!0),"onClick"),children:[(0,t.jsx)(Ao,{className:"h-3.5 w-3.5"}),"Local path"]})]}),d?(0,t.jsxs)("div",{className:"grid gap-2",children:[(0,t.jsx)(Gs,{htmlFor:"adapterLocalPath",children:"Path to adapter package"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(jt,{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)(yd,{})]}),(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)(Gs,{htmlFor:"adapterPackageName",children:"Package Name"}),(0,t.jsx)(jt,{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)(Gs,{htmlFor:"adapterVersion",children:"Version (optional)"}),(0,t.jsx)(jt,{id:"adapterVersion",placeholder:"latest",value:l,onChange:r(E=>c(E.target.value),"onChange")})]})]})]}),(0,t.jsxs)(jr,{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)(_s,{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)(Vm,{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)(Js,{className:"bg-muted/30",children:(0,t.jsxs)(Ha,{className:"flex flex-col items-center justify-center py-10",children:[(0,t.jsx)(Vm,{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)(Js,{className:"block py-0",children:(0,t.jsx)("ul",{className:"divide-y",children:L.map(E=>{const q=E.overriddenBuiltin,B=q&&!!E.overridePaused,U=q?{...E,disabled:B??!1}:E;return(0,t.jsx)(fF,{adapter:U,canRemove:!0,onToggle:q?(z,$)=>C.mutate({type:z,paused:$}):(z,$)=>I.mutate({type:z,disabled:$}),onRemove:r(z=>g(z),"onRemove"),onReload:r(z=>T.mutate(z),"onReload"),onReinstall:E.isLocalPath?void 0:z=>y(E),isToggling:q?C.isPending:I.isPending,isReloading:T.isPending,isReinstalling:R.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)(Vm,{className:"h-5 w-5 text-muted-foreground"}),(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Built-in Adapters"})]}),A.length===0&&D.length===0?(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"No built-in adapters found."}):(0,t.jsx)(Js,{className:"block py-0",children:(0,t.jsxs)("ul",{className:"divide-y",children:[A.map(E=>(0,t.jsx)(fF,{adapter:E,canRemove:!1,onToggle:r((q,B)=>I.mutate({type:q,disabled:B}),"onToggle"),onRemove:r(()=>{},"onRemove"),isToggling:O},E.type)),D.map(E=>(0,t.jsx)(fF,{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)=>I.mutate({type:q,disabled:B}),"onToggle"),onRemove:r(()=>{},"onRemove"),isToggling:O,overriddenBy:E.overridePaused?void 0:E.overriddenBy},E.type))]})})]}),(0,t.jsx)(Qs,{open:f!==null,onOpenChange:r(E=>{E||g(null)},"onOpenChange"),children:(0,t.jsxs)(Xs,{children:[(0,t.jsxs)(kn,{children:[(0,t.jsx)(en,{children:"Remove Adapter"}),(0,t.jsxs)(Ln,{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)(jr,{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)(SQt,{adapter:v,open:v!==null,isReinstalling:R.isPending,onConfirm:r(()=>{v&&R.mutate(v.type,{onSettled:r(()=>y(null),"onSettled")})},"onConfirm"),onCancel:r(()=>y(null),"onCancel")})]})}r(Sde,"AdapterManager");function Cde(){const e=Ia(),{companyPrefix:s,pluginId:n,pluginRoutePath:a}=e,i=e["*"],{companies:o,selectedCompanyId:l}=ps(),{setBreadcrumbs:c}=Bn(),d=(0,m.useMemo)(()=>{if(!s)return null;const w=s.toUpperCase();return o.find(k=>k.issuePrefix.toUpperCase()===w)??null},[o,s]),u=!!s&&!d,h=(0,m.useMemo)(()=>d?d.id:s?null:l??null,[d,s,l]),p=(0,m.useMemo)(()=>h?o.find(w=>w.id===h)?.issuePrefix??null:null,[o,h]),{data:f}=J({queryKey:P.plugins.uiContributions,queryFn:r(()=>rl.listUiContributions(),"queryFn"),enabled:!!h&&(!!n||!!a)}),g=(0,m.useMemo)(()=>{if(!f)return null;if(n){const k=f.find(N=>N.pluginId===n);if(!k)return null;const j=k.slots.find(N=>N.type==="page");return j?{...j,pluginId:k.pluginId,pluginKey:k.pluginKey,pluginDisplayName:k.displayName,pluginVersion:k.version}:null}if(!a)return null;const w=f.flatMap(k=>{const j=k.slots.find(N=>N.type==="page"&&N.routePath===a);return j?[{...j,pluginId:k.pluginId,pluginKey:k.pluginKey,pluginDisplayName:k.displayName,pluginVersion:k.version}]:[]});return w.length!==1?null:w[0]??null},[n,a,f]),v=(0,m.useMemo)(()=>({companyId:h??null,companyPrefix:p}),[h,p]),y=(0,m.useMemo)(()=>{if(!a||!f)return!1;const w=f.flatMap(k=>k.slots.map(j=>({...j,pluginId:k.pluginId,pluginKey:k.pluginKey,pluginDisplayName:k.displayName,pluginVersion:k.version})));return EK(w,a)!==null},[f,a]);if((0,m.useEffect)(()=>{if(g){if(y){c([{label:CQt(g,i)}]);return}c([{label:"Plugins",href:"/company/settings/instance/plugins"},{label:g.pluginDisplayName}])}},[g,i,c,y]),!h)return u?(0,t.jsx)(ju,{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(k=>k.type==="page"&&k.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)(ju,{scope:"board"});const w=n?`/company/settings/instance/plugins/${n}`:"/company/settings/instance/plugins";return(0,t.jsx)(bn,{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)(Qe,{to:p?`/${p}/dashboard`:"/dashboard",children:[(0,t.jsx)(vl,{className:"h-4 w-4 mr-1"}),"Back"]})})}),(0,t.jsx)(Su,{slot:g,context:v,className:"min-h-(--sz-200px)",missingBehavior:"placeholder"})]})}r(Cde,"PluginPage");function CQt(e,s){return _Qt(s)??e.displayName??e.pluginDisplayName}r(CQt,"resolveRouteSidebarPageTitle");function _Qt(e){const s=(e??"").split("/").filter(Boolean).map(IQt);return s.length===0?null:s[0]==="page"&&s.length>1?_de(s.slice(1).join("/"),{preserveCase:!0}):_de(s[0]??null)}r(_Qt,"titleFromRouteSplat");function _de(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(_de,"titleFromPath");function IQt(e){try{return decodeURIComponent(e)}catch{return e}}r(IQt,"decodeRouteSegment");var aT="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",Ide=r(e=>e.status==="fail"||e.checks.some(s=>s.code==="adapter_auth_missing"),"blocking");function AQt(){const{selectedCompanyId:e}=ps(),[s]=Ei();return e?(0,t.jsx)(TQt,{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(AQt,"NewAgentSetup");function TQt({companyId:e,name:s,adapterType:n,runnerProvider:a,createdAgentId:i}){const o=Xn(),l=Ut(),{openNewIssue:c}=zo(),d=nbe(`${e}:new-agent`),u=n==="paperclip_runner",h=u?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=lHe(h),v=f||h==="hermes_local",y=v||!!rJ[n],w=!["cursor_cloud","hermes_gateway"].includes(n),[k,j]=(0,m.useState)(""),[N,_]=(0,m.useState)(""),[I,C]=(0,m.useState)(""),[T,R]=(0,m.useState)("kimi"),[A,L]=(0,m.useState)(i?"saved":p?"connect":"runtime"),[D,O]=(0,m.useState)(""),E=u?[]:M5(n,D),[q,B]=(0,m.useState)(""),[U,z]=(0,m.useState)(!1),[$,K]=(0,m.useState)(""),[H,se]=(0,m.useState)("openrouter"),[Z,ie]=(0,m.useState)(""),[oe,Y]=(0,m.useState)(null),[ne,de]=(0,m.useState)(()=>h==="opencode_local"?{provider:"openrouter",method:"api_key",mode:"responsible_user"}:void 0),[ee,X]=(0,m.useState)(null),Q=ne??ee?.aiConnection,[fe,te]=(0,m.useState)(""),[ae,le]=(0,m.useState)(""),[ce,he]=(0,m.useState)(null),ve=J({queryKey:P.agents.detail(i??"new"),queryFn:r(()=>Vt.get(i,e),"queryFn"),enabled:!!i,retry:!1}),pe=ce??(ve.data?.companyId===e?ve.data:null),[xe,_e]=(0,m.useState)(!1),[ge,Ie]=(0,m.useState)("idle"),[Ye,$e]=(0,m.useState)(null),[Xe,ue]=(0,m.useState)(null),Oe=(0,m.useRef)(0),dt=(0,m.useRef)(!1);(0,m.useEffect)(()=>()=>{Oe.current++},[]);const xt=r(()=>{Oe.current++,$e(null),Ie("idle"),ue(null)},"resetTest"),Le=J({queryKey:P.adapters.all,queryFn:Fm.list}),Ge=J({queryKey:P.agents.list(e),queryFn:r(()=>Vt.list(e),"queryFn")}),ht=J({queryKey:P.environments.list(e),queryFn:r(()=>Ri.list(e),"queryFn")}),Ve=J({queryKey:P.instance.settings,queryFn:Tr.get}),Ke=J({queryKey:P.instance.experimentalSettings,queryFn:Tr.getExperimental}),gt=J({queryKey:P.instance.generalSettings,queryFn:Tr.getGeneral}),tt=J({queryKey:P.environments.capabilities(e),queryFn:r(()=>Ri.capabilities(e),"queryFn")}),Se=J({queryKey:P.agents.adapterModels(e,h,null,Q?.provider),queryFn:r(()=>Vt.adapterModels(e,h,{provider:Q?.provider}),"queryFn"),enabled:!!h&&w,retry:!1}),ke=J({queryKey:P.secrets.list(e),queryFn:r(()=>vr.list(e),"queryFn"),enabled:y&&n!=="cursor_cloud"}),Je=J({queryKey:P.secrets.myUserSecrets(e),queryFn:r(()=>vr.listMyUserSecrets(e),"queryFn"),enabled:y&&n!=="cursor_cloud",retry:!1}),ut=G8(gt.data?.executionMode,ht.data??[]),Dt=Ke.data?.enableManagedSandboxOnly===!0;let Jt=null,fs=null;try{Jt=ut.forced?ut.kubernetesEnvironment?.id??null:sN({agentDefaultEnvironmentId:$||null,instanceDefaultEnvironmentId:Ve.data?.defaultEnvironmentId??null,localDefaultEnvironmentId:rN(ht.data??[]),managedSandboxOnly:Dt,managedSandboxEnvironmentId:nN(ht.data??[]),visibleEnvironmentIds:(ht.data??[]).map(qe=>qe.id)})}catch(qe){fs=qe instanceof Error?qe.message:"Could not resolve the environment."}const We=ht.data?.find(qe=>qe.id===Jt),He=typeof We?.config?.provider=="string"?We.config.provider:"",ct=We?.driver==="sandbox"&&tt.data?.sandboxProviders?.[He]?.supportsLoginPty===!0,ze=rJ[n]??g[H]??"API_KEY",is=Je.data?.find(qe=>qe.definition.key===ze&&qe.secret),Fe=ke.data?.find(qe=>qe.key===ze&&qe.status==="active"),Qt=n==="cursor_cloud"?null:oe??(Fe?{type:"secret_ref",secretId:Fe.id,version:"latest"}:is?{type:"user_secret_ref",key:ze,version:"latest"}:null),Tt=n==="kimi_local"&&!!(Z.trim()||Qt),Ms=!!td(),Ue=rbe(n,{cloud:Ms,nativeRunnerEnabled:Ke.data?.enableNativeRunner===!0})&&Le.data?.some(qe=>qe.type===n&&qe.loaded&&!qe.disabled&&!Jm(n).comingSoon),pt=!!(Ue&&!fs&&!ht.isPending&&!Ve.isPending&&!Ke.isPending&&!gt.isPending&&!Ge.isPending&&!tt.isPending&&!ht.error&&!Ve.error&&!Ke.error&&!gt.error&&!Ge.error&&!tt.error&&(!(Dt||ut.forced)||Jt)),$t=ge==="running"||xe;function gs(qe=ee,Nt=Qt){const St={...j0,adapterType:n,model:D||(h==="codex_local"?Xw:""),thinkingEffort:q,dangerouslyBypassSandbox:n==="codex_local",envBindings:qe?.env??{},...u?{adapterSchemaValues:{provider:a==="claude"?"acpx":a,...a==="claude"?{acpxAgent:"claude"}:{}}}:{}},Ee=YN(n).buildAdapterConfig(St);return u&&Object.assign(Ee,{provider:a==="claude"?"acpx":a,...a==="claude"?{acpxAgent:"claude"}:{},...D?{model:D}:{}}),!Q&&!qe?.aiConnection&&y&&Nt&&(n==="hermes_gateway"?Ee.apiKey=Nt:Ee.env={...Ee.env??{},[ze]:Nt}),n==="cursor_cloud"&&Object.assign(Ee,{repoUrl:fe.trim(),...ae.trim()?{repoStartingRef:ae.trim()}:{}}),n==="hermes_gateway"&&(Ee.apiBaseUrl=k.trim()),Tt&&(delete Ee.model,Ee.env={...Ee.env??{},KIMI_MODEL_NAME:{type:"plain",value:N.trim()},KIMI_MODEL_PROVIDER_TYPE:{type:"plain",value:T},...I.trim()?{KIMI_MODEL_BASE_URL:{type:"plain",value:I.trim()}}:{}}),Ee}r(gs,"buildConfig");function Rs(qe=ee){if(f&&(!D.trim()||!D.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)&&!Z.trim()&&!Qt)throw new Error(n==="cursor_cloud"?"Enter a Cursor API key.":`Enter ${ze} or select an organization secret.`);if(n==="hermes_gateway")try{const Nt=new URL(k.trim());if(!["https:","http:"].includes(Nt.protocol))throw new Error}catch{throw new Error("Enter the Hermes API base URL.")}if(Tt&&!N.trim())throw new Error("Enter the Kimi API model name.");return gs(qe)}r(Rs,"preparedConfig");function Ct(qe=ee){return Q||qe?.aiConnection?{}:{...qe?.credentials,...y&&Z.trim()?{[ze]:Z.trim()}:{}}}r(Ct,"pendingCredentials");async function we(qe=ee){if(!pt)return!1;const Nt=++Oe.current;Ie("running"),$e(null),ue(null);try{const St=await Rs(qe),Ee=await Yge({companyId:e,adapterType:n,providerAdapter:h,adapterConfig:St,testCredentials:Ct(qe),aiConnection:ne??qe?.aiConnection,environmentId:Jt});return Nt!==Oe.current?!1:($e(Ee),Ie(Ide(Ee)?"fail":Ee.status),!Ide(Ee)&&(!p||Ee.checks.some(De=>De.code.endsWith("hello_probe_passed"))))}catch(St){return Nt===Oe.current&&(ue(St instanceof Error?St.message:"Could not test the agent."),Ie("fail")),!1}}r(we,"runTest");async function Pe(){if(dt.current||i||pe||!pt||!s.trim()||ge==="running"||ge==="fail"||p&&!ee)return;dt.current=!0,_e(!0),ue(null);const qe=[];let Nt=!1;try{const St=Rs(),Ee=Ct();if(Object.keys(Ee).length&&!await we())return;for(const[Kt,Lt]of Object.entries(Ee)){const Ft=await(p?Jge:iHe)(e,Kt,Lt);qe.push(Ft),n==="hermes_gateway"&&Kt==="API_SERVER_KEY"?St.apiKey=Ft.binding:St.env={...St.env??{},[Kt]:Ft.binding}}const De=Ge.data??[],Ze=De.find(Kt=>Kt.role==="ceo"&&Kt.status!=="terminated"),kt=await Vt.hire(e,{name:s.trim(),appearance:d.appearance,role:De.length?"general":"ceo",...Ze?{reportsTo:Ze.id}:{},adapterType:n,adapterConfig:St,defaultEnvironmentId:$||(ut.forced||Dt?Jt:null),runtimeConfig:{...ije({heartbeatEnabled:!1}),...Q?{aiConnection:Q}:{}},budgetMonthlyCents:0,...ee?.storedSessionId?{storedSessionId:ee.storedSessionId}:{},...ee?.applyStoredClaudeLogin?{applyStoredClaudeLogin:!0}:{}});Nt=!0,ie(""),X(null),he(kt.agent),d.clear(),L("saved"),o(`/agents/new?${new URLSearchParams({name:kt.agent.name,adapterType:n,runnerProvider:a,createdAgentId:kt.agent.id})}`,{replace:!0}),l.setQueryData(P.agents.detail(kt.agent.id),kt.agent),await Promise.all([l.invalidateQueries({queryKey:P.agents.list(e)}),l.invalidateQueries({queryKey:P.approvals.list(e)})])}catch(St){ue(St instanceof Error?St.message:"Could not create the agent.")}finally{if(!Nt)try{await Promise.all(qe.map(St=>St.remove()))}catch{ue(St=>`${St?`${St} `:""}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)}),dt.current=!1,_e(!1)}}if(r(Pe,"finish"),i&&!pe)return(0,t.jsx)("p",{role:ve.error?"alert":"status",className:"text-sm text-muted-foreground",children:ve.error?"Could not load the created agent. Return to Agents to view it.":"Loading your agent…"});if(!s||!n)return(0,t.jsx)(abe,{open:!0,initialAdapter:n,onClose:r(()=>o("/agents/all"),"onClose"),onContinue:r(qe=>o(`/agents/new?${new URLSearchParams(qe)}`,{replace:!0}),"onContinue")});const lt=[...p?["connect"]:[],"runtime","saved"],Ot={connect:"Connect",runtime:"Configure",saved:"Confirmation"},ft=pe?.defaultEnvironmentId?ht.data?.find(qe=>qe.id===pe.defaultEnvironmentId):We,us=pe?.adapterConfig?.env?.KIMI_MODEL_NAME,dn=pe?.adapterConfig?.model||(typeof us=="string"?us:us?.value)||D||"Default",xs=n==="cursor_cloud"?"Cursor Cloud":n==="hermes_gateway"?"Hermes Gateway":ft?aN(ft):"Local machine",bs=Le.error??ht.error??Ve.error??Ke.error??gt.error??Ge.error??tt.error;return(0,t.jsx)(Lge,{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)(u1,{appearance:pe?.appearance??d.appearance,size:256,className:"size-48",trackingScope:"page",state:pe||ge==="pass"?"success":ge==="running"?"loading":"sleepy",muted:!pe&&ge!=="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)(X8,{type:h}),(0,t.jsx)("span",{children:Jm(h).label}),u&&(0,t.jsxs)("span",{children:["·"," ",a==="codex"?"Native app server runner":"Paperclip Runner"]})]})]})]}),fs&&!ht.isPending&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:fs}),bs&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:bs.message}),Le.data&&!Ue&&(0,t.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:"This adapter is unavailable. Choose an enabled adapter."}),(Dt||ut.forced)&&!ht.isPending&&!Jt&&(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:lt.map((qe,Nt)=>(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button","aria-current":qe===A?"step":void 0,disabled:$t||!!pe||Nt>lt.indexOf(A),onClick:r(()=>L(qe),"onClick"),className:W("flex w-full items-center gap-3 rounded-md px-3 py-3 text-left text-sm",qe===A?"bg-accent font-medium":"text-muted-foreground"),children:[(0,t.jsx)("span",{className:W("flex size-6 shrink-0 items-center justify-center rounded-full border text-xs",qe===A?"border-foreground bg-foreground text-background":"border-border"),children:Nt+1}),Ot[qe]]})},qe))})}),(0,t.jsx)("div",{className:"min-w-0 flex-1",children:(0,t.jsx)(QN,{mode:"wait",initial:!1,children:(0,t.jsx)(nl.div,{...kHe,children:A==="connect"&&p?(0,t.jsxs)(qlt,{className:"mx-auto",children:[(0,t.jsx)("div",{className:"mb-8",children:(0,t.jsx)(oje,{title:"Connect a model",lede:`Connect ${s} to ${p==="claude_local"?"Claude":p==="grok_local"?"Grok":"OpenAI"}.`,center:!0})}),(0,t.jsx)(cbe,{companyId:e,adapterType:p,environmentId:Jt,canLogin:ct,localEnvironment:We?.driver==="local",onBack:r(()=>o("/agents/all"),"onBack"),testConnection:we,testError:Xe??(Ye?.checks.find(qe=>qe.level==="error")??Ye?.checks.find(qe=>qe.code.includes("hello_probe")&&qe.level==="warn"))?.message,onConnected:r(qe=>{X(qe),xt(),L("runtime")},"onConnected")},Jt??"local")]}):A==="saved"&&pe?(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)(ds,{className:"size-5"}),pe.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:Jm(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(dn)})]}),(0,t.jsx)("dt",{className:"text-muted-foreground",children:"Environment"}),(0,t.jsx)("dd",{children:xs})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:pe.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(`${tm(pe)}/runtime`),"onClick"),children:[(0,t.jsx)(fK,{className:"size-4"}),"Edit configuration"]}),(0,t.jsxs)(F,{disabled:pe.status==="pending_approval",onClick:r(()=>c({assigneeAgentId:pe.id,status:"todo"}),"onClick"),children:["Assign ",pe.name," a Task",(0,t.jsx)(Ho,{className:"size-4"})]})]})]}):(0,t.jsxs)("form",{className:"space-y-8",onSubmit:r(qe=>{qe.preventDefault(),Pe()},"onSubmit"),children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:"Configure your agent"}),(0,t.jsxs)("fieldset",{disabled:$t,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"}),L8(h)&&(ee&&!Q?(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)(Qge,{companyId:e,agentName:s,adapterType:h,model:D,environmentId:Jt??void 0,value:Q,onChange:r(qe=>{de(qe),xt()},"onChange")})),Se.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&&!Tt||E.length>0)&&(0,t.jsxs)("div",{className:"grid items-start gap-5 sm:grid-cols-2",children:[w&&!Tt&&(0,t.jsx)(Y8,{models:Se.data??[],value:D,onChange:r(qe=>{O(qe),q&&!M5(n,qe).includes(q)&&B("");const Nt=qe.split("/")[0];f&&Xge[Nt]&&Nt!==H&&(se(Nt),ie(""),Y(null)),xt()},"onChange"),open:U,onOpenChange:z,allowDefault:!f,required:f,creatable:!0,groupByProvider:f}),E.length>0&&(0,t.jsx)(ys,{label:"Thinking effort",children:(0,t.jsxs)("select",{"aria-label":"Thinking effort",className:aT,value:q,onChange:r(qe=>{B(qe.target.value),xt()},"onChange"),children:[(0,t.jsx)("option",{value:"",children:"Auto"}),E.map(qe=>(0,t.jsx)("option",{value:qe,children:qe},qe))]})})]}),aJ[n]&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:aJ[n]}),w&&Se.error&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Couldn’t load models. You can enter a model ID manually."}),y&&!Q&&(0,t.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[v&&(0,t.jsx)(ys,{label:"API key provider",children:(0,t.jsx)("select",{"aria-label":"API key provider",className:aT,value:H,onChange:r(qe=>{se(qe.target.value),O(""),ie(""),Y(null),xt()},"onChange"),children:Object.keys(g).map(qe=>(0,t.jsx)("option",{value:qe,children:qe==="openrouter"?"OpenRouter":qe==="openai"?"OpenAI":qe==="anthropic"?"Anthropic":{google:"Google",xai:"xAI",groq:"Groq",opencode:"OpenCode"}[qe]??qe},qe))})}),(0,t.jsx)("div",{className:n==="cursor_cloud"?"sm:col-span-2":void 0,children:(0,t.jsx)(ys,{label:ze,children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(jt,{"aria-label":ze,type:"password",autoComplete:"off",value:Z,onChange:r(qe=>{ie(qe.target.value),Y(null),xt()},"onChange"),placeholder:Qt?"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)(ys,{label:"Or use an organization secret",children:(0,t.jsx)(U8,{secretId:Qt&&typeof Qt=="object"&&Qt.type==="secret_ref"?Qt.secretId:"",secrets:ke.data??[],disabled:$t,onSelect:r(qe=>{Y({type:"secret_ref",secretId:qe,version:"latest"}),ie(""),xt()},"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)(ys,{label:"Hermes API base URL",children:(0,t.jsx)(jt,{"aria-label":"Hermes API base URL",value:k,onChange:r(qe=>{j(qe.target.value),xt()},"onChange"),placeholder:"https://hermes.example.com"})}),Tt&&(0,t.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[(0,t.jsx)(ys,{label:"Kimi API model name",children:(0,t.jsx)(jt,{"aria-label":"Kimi API model name",value:N,onChange:r(qe=>{_(qe.target.value),xt()},"onChange"),placeholder:"kimi-for-coding"})}),(0,t.jsx)(ys,{label:"Kimi API protocol",children:(0,t.jsx)("select",{"aria-label":"Kimi API protocol",className:aT,value:T,onChange:r(qe=>{R(qe.target.value),xt()},"onChange"),children:["kimi","anthropic","openai"].map(qe=>(0,t.jsx)("option",{children:qe},qe))})}),(0,t.jsx)(ys,{label:"Kimi API base URL",hint:"Optional override for your provider endpoint.",children:(0,t.jsx)(jt,{"aria-label":"Kimi API base URL",value:I,onChange:r(qe=>{C(qe.target.value),xt()},"onChange"),placeholder:"Provider default"})})]}),n==="cursor_cloud"&&(0,t.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[(0,t.jsx)(ys,{label:"GitHub repository",children:(0,t.jsx)(jt,{"aria-label":"GitHub repository",value:fe,onChange:r(qe=>{te(qe.target.value),xt()},"onChange"),placeholder:"https://github.com/your-org/repo"})}),(0,t.jsx)(ys,{label:"Branch",children:(0,t.jsx)(jt,{"aria-label":"Branch",placeholder:"Repository default",value:ae,onChange:r(qe=>{le(qe.target.value),xt()},"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:aT,value:$,disabled:ut.forced||Dt,onChange:r(qe=>{K(qe.target.value),X(null),xt(),p&&L("connect")},"onChange"),children:[(0,t.jsxs)("option",{value:"",children:["Default: ",xs]}),(ht.data??[]).filter(qe=>qe.status==="active").map(qe=>(0,t.jsx)("option",{value:qe.id,children:aN(qe)},qe.id))]})]})]}),(0,t.jsx)(Zge,{state:ge,result:Ye,error:Xe,disabled:!pt||$t,onTest:r(()=>{we()},"onTest")}),Xe&&ge!=="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:$t,onClick:r(()=>L("connect"),"onClick"),children:[(0,t.jsx)(vl,{className:"size-4"}),"Connection"]}):(0,t.jsx)("span",{}),(0,t.jsxs)(F,{type:"submit",disabled:!pt||$t||ge==="fail"||!!(p&&!ee),children:[xe?"Creating…":"Finish setup",(0,t.jsx)(ds,{className:"size-4"})]})]})]})},A)})})]})]})})}r(TQt,"Setup");function RQt(){const{setBreadcrumbs:e}=Bn();return(0,m.useEffect)(()=>{e([{label:"Agents",href:"/agents"},{label:"New agent"}])},[e]),(0,t.jsx)(AQt,{})}r(RQt,"NewAgent");var a3="paperclip:pending-invite-token";function HW(){return typeof window<"u"&&typeof window.localStorage<"u"}r(HW,"canUseStorage");function Ade(e){const s=e.trim();if(!(!s||!HW()))try{window.localStorage.setItem(a3,s)}catch{}}r(Ade,"rememberPendingInviteToken");function iT(e){if(HW())try{const s=window.localStorage.getItem(a3);if(e&&s!==e.trim())return;window.localStorage.removeItem(a3)}catch{}}r(iT,"clearPendingInviteToken");function EQt(){if(!HW())return null;try{const e=window.localStorage.getItem(a3)?.trim();return e?`/invite/${e}`:null}catch{return null}}r(EQt,"getRememberedInvitePath");var Tde=[" ",".","·","▪","▫","○"],PQt=1e3/24,oT=[[" ╭────╮ "," ╭╯╭──╮│ "," │ │ ││ "," │ │ ││ "," │ │ ││ "," │ │ ││ "," │ ╰──╯│ "," ╰─────╯ "],[" ╭─────╮ "," │╭──╮╰╮ "," ││ │ │ "," ││ │ │ "," ││ │ │ "," ││ │ │ "," │╰──╯ │ "," ╰────╯ "]];function Rde(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(Rde,"measureChar");function MQt(e){let s=0;for(const n of e)s=Math.max(s,n.length);return{width:s,height:e.length}}r(MQt,"spriteSize");function LQt(){const e=(0,m.useRef)(null),s=(0,m.useRef)(null);return(0,m.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,u=0,h=7,p=11,f=new Float32Array(0),g=new Float32Array(0),v=new Float32Array(0),y=new Uint16Array(0),w=[],k="";function j(E){const q=Math.floor(Math.max(0,Math.min(.999,E))*Tde.length);return Tde[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===u)return;d=E,u=q;const B=d*u;f=new Float32Array(B),g=new Float32Array(d),v=new Float32Array(u),y=new Uint16Array(B),w=w.filter(U=>U.x>-U.width-2&&U.x<d+2&&U.y>-U.height-2&&U.y<u+2),k=""}r(N,"rebuildGrid");function _(){if(d<=0||u<=0){n.textContent="";return}const E=Array.from({length:u},()=>Array.from({length:d},()=>" "));for(let z=0;z<u;z++)for(let $=0;$<d;$++){const K=(Math.sin($*.11+z*.04)+Math.cos(z*.08-$*.02))*.18+.22;E[z][$]=j(K)}const q=18,B=13;for(let z=1;z<u-9;z+=B){const $=Math.floor(z/B)%2===0?2:10;for(let K=$;K<d-10;K+=q){const H=oT[(K+z)%oT.length];for(let se=0;se<H.length;se++){const Z=H[se];for(let ie=0;ie<Z.length;ie++){const oe=Z[ie]??" ";if(oe===" ")continue;const Y=z+se,ne=K+ie;Y<0||Y>=u||ne<0||ne>=d||(E[Y][ne]=oe)}}}}const U=E.map(z=>z.join("")).join(`
|
|
728
728
|
`);n.textContent=U,k=U}r(_,"drawStaticFrame");function I(){const E=oT[Math.floor(Math.random()*oT.length)],q=MQt(E),B=Math.random();let U=0,z=0,$=0,K=0;B<.68?(U=Math.random()<.5?-q.width-1:d+1,z=Math.random()*Math.max(1,u-q.height),$=U<0?.04+Math.random()*.05:-(.04+Math.random()*.05),K=(Math.random()-.5)*.014):(U=Math.random()*Math.max(1,d-q.width),z=Math.random()<.5?-q.height-1:u+1,$=(Math.random()-.5)*.014,K=z<0?.028+Math.random()*.034:-(.028+Math.random()*.034)),w.push({x:U,y:z,vx:$,vy:K,life:0,maxLife:260+Math.random()*220,drift:(Math.random()-.5)*1.2,sprite:E,width:q.width,height:q.height})}r(I,"spawnClip");function C(E,q){const B=Math.round(E.x),U=Math.round(E.y);for(let z=0;z<E.sprite.length;z++){const $=E.sprite[z],K=U+z;if(!(K<0||K>=u))for(let H=0;H<$.length;H++){const se=$[H]??" ";if(se===" ")continue;const Z=B+H;if(Z<0||Z>=d)continue;const ie=K*d+Z,oe=se==="│"||se==="─"?.8:.92;f[ie]=Math.max(f[ie]??0,q*oe),y[ie]=se.charCodeAt(0)}}}r(C,"stampClip");function T(E){if(!o||(s.current=requestAnimationFrame(T),E-l<PQt||d<=0||u<=0))return;const q=Math.min(2,l===0?1:(E-l)/16.6667);l=E,c+=q;const B=d*u,U=Math.max(3,Math.floor(B/2200));for(;w.length<U;)I();for(let $=0;$<f.length;$++)f[$]*=.92;y.fill(0);for(let $=w.length-1;$>=0;$--){const K=w[$];K.life+=q;const H=Math.sin((K.y+K.drift+c*.12)*.09)*.0018,se=Math.cos((K.x-K.drift-c*.09)*.08)*.0014;if(K.vx=(K.vx+H)*.998,K.vy=(K.vy+se)*.998,K.x+=K.vx*q,K.y+=K.vy*q,K.life>=K.maxLife||K.x<-K.width-2||K.x>d+2||K.y<-K.height-2||K.y>u+2){w.splice($,1);continue}const Z=K.life/K.maxLife;C(K,Z<.12?Z/.12:Z>.88?(1-Z)/.12:1)}for(let $=0;$<d;$++)g[$]=Math.sin($*.08+c*.06);for(let $=0;$<u;$++)v[$]=Math.cos($*.1-c*.05);let z="";for(let $=0;$<u;$++){for(let K=0;K<d;K++){const H=$*d+K,se=y[H];if(se>0){z+=String.fromCharCode(se);continue}const Z=(g[K]+v[$])*.08+.1,ie=Math.max(f[H]??0,Z*.45);z+=j(ie)}$<u-1&&(z+=`
|
|
729
|
-
`)}z!==k&&(n.textContent=z,k=z)}r(T,"step");function R(){const E=d>0&&u>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(T))}r(R,"syncLoop");const A=new ResizeObserver(()=>{const E=Rde(n);h=E.w,p=E.h,N(),R()});A.observe(n);const L=r(()=>{i=document.visibilityState!=="hidden",R()},"onVisibilityChange");document.addEventListener("visibilitychange",L);const D=r(()=>{R()},"onMotionChange");a.addEventListener("change",D);const O=Rde(n);return h=O.w,p=O.h,N(),R(),()=>{o=!1,s.current!==null&&cancelAnimationFrame(s.current),A.disconnect(),document.removeEventListener("visibilitychange",L),a.removeEventListener("change",D)}},[]),(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(LQt,"AsciiArtAnimation");function DQt({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(DQt,"PaperclipLockup");function $Qt(){const e=Ut(),s=Xn(),[n]=Ei(),[a,i]=(0,m.useState)("sign_in"),[o,l]=(0,m.useState)(""),[c,d]=(0,m.useState)(""),[u,h]=(0,m.useState)(""),[p,f]=(0,m.useState)(null),g="auth-error",v=(0,m.useMemo)(()=>n.get("next")||EQt()||"/",[n]),{data:y,isLoading:w}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1});(0,m.useEffect)(()=>{y&&s(v,{replace:!0})},[y,s,v]);const k=Ne({mutationFn:r(async()=>{if(a==="sign_in"){await za.signInEmail({email:c.trim(),password:u});return}await za.signUpEmail({name:o.trim(),email:c.trim(),password:u})},"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&&u.trim().length>0&&(a==="sign_in"||o.trim().length>0&&u.trim().length>=8);return w?(0,t.jsx)("div",{className:"fixed inset-0 flex items-center justify-center",children:(0,t.jsx)(oh,{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)(yw,{})}),(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)(DQt,{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(),!k.isPending){if(!j){f("Please fill in all required fields.");return}k.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:u,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:k.isPending,"aria-disabled":!j||k.isPending,className:`w-full ${!j&&!k.isPending?"opacity-50":""}`,children:k.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)(LQt,{})})]})}r($Qt,"AuthPage");function OQt(){const e=Ut(),s=Ia(),[n]=Ei(),a=(s.token??"").trim(),i=(n.get("code")??"").trim(),o=(0,m.useMemo)(()=>`/board-claim/${encodeURIComponent(a)}${i?`?code=${encodeURIComponent(i)}`:""}`,[a,i]),l=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),c=J({queryKey:["board-claim",a,i],queryFn:r(()=>ur.getBoardClaimStatus(a,i),"queryFn"),enabled:a.length>0&&i.length>0,retry:!1}),d=Ne({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)(Js,{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 u=c.data;return u?u.status==="claimed"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Js,{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)(Qe,{to:"/",children:"Open board"})})]})}):l.data?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Js,{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)(Js,{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)(Qe,{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(OQt,"BoardClaimPage");function FQt(){const e=Ut(),s=Ia(),[n]=Ei(),a=(s.id??"").trim(),i=(n.get("token")??"").trim(),o=(0,m.useMemo)(()=>`/cli-auth/${encodeURIComponent(a)}${i?`?token=${encodeURIComponent(i)}`:""}`,[a,i]),l=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),c=J({queryKey:["cli-auth-challenge",a,i],queryFn:r(()=>ur.getCliAuthChallenge(a,i),"queryFn"),enabled:a.length>0&&i.length>0,retry:!1}),d=Ne({mutationFn:r(()=>ur.approveCliAuthChallenge(a,i),"mutationFn"),onSuccess:r(async()=>{await e.invalidateQueries({queryKey:P.auth.session}),await c.refetch()},"onSuccess")}),u=Ne({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)(Js,{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)(Js,{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)(Js,{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)(Js,{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)(Qe,{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)(Js,{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||u.error)&&(0,t.jsx)("p",{className:"mt-4 text-sm text-destructive",children:(d.error??u.error)instanceof Error?(d.error??u.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||u.isPending,children:d.isPending?"Approving...":"Approve CLI access"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>u.mutate(),"onClick"),disabled:d.isPending||u.isPending,children:u.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(FQt,"CliAuthPage");var BQt=xTe.filter(e=>e!=="paperclip_runner"),Ede=new Set(["claude_local","codex_local","gemini_local","kimi_local","opencode_local","pi_local","cursor"]);function qQt(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(qQt,"readNestedString");var Ij="w-full border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-zinc-500",Pde="border border-zinc-800 bg-zinc-950/95 p-6",Mde="flex-1 border px-3 py-2 text-sm transition-colors";function zQt(e){return e?e.charAt(0).toUpperCase()+e.slice(1):null}r(zQt,"formatHumanRole");function UAe(e){if(!e||typeof e!="object")return null;const s=e.code;return typeof s=="string"&&s.trim().length>0?s:null}r(UAe,"getAuthErrorCode");function UQt(e){if(!(e instanceof Error))return null;const s=e.message.trim();return s.length>0?s:null}r(UQt,"getAuthErrorMessage");function KQt(e,s,n){const a=UAe(e),i=UQt(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(KQt,"mapInviteAuthFeedback");function Lde(e){return!!(e&&typeof e=="object"&&"bootstrapAccepted"in e)}r(Lde,"isBootstrapAcceptancePayload");function WQt(e,s){return!e||typeof e!="object"||s?!1:e.status==="approved"}r(WQt,"isApprovedHumanJoinPayload");function RU({companyDisplayName:e,companyLogoUrl:s,className:n}){return(0,t.jsx)(Qx,{companyName:e,logoUrl:s,logoFit:"contain",className:n})}r(RU,"InviteCompanyLogo");function Dde({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)(RU,{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(Dde,"AwaitingJoinApprovalPanel");function VQt(){const e=Ut(),s=Xn(),{setSelectedCompanyId:n}=ps(),a=(Ia().token??"").trim(),[i,o]=(0,m.useState)("sign_up"),[l,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(""),[h,p]=(0,m.useState)(""),[f,g]=(0,m.useState)(""),[v,y]=(0,m.useState)("claude_local"),[w,k]=(0,m.useState)(""),[j,N]=(0,m.useState)(null),[_,I]=(0,m.useState)(null),[C,T]=(0,m.useState)(null),[R,A]=(0,m.useState)(!1),L="invite-auth-error",D=J({queryKey:P.health,queryFn:r(()=>cm.get(),"queryFn"),retry:!1}),O=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),E=J({queryKey:P.access.invite(a),queryFn:r(()=>ur.getInvite(a),"queryFn"),enabled:a.length>0,retry:!1}),q=PU({enabled:!!O.data&&!!E.data?.companyId,staleTime:0}),B=D.data?.deploymentMode!=="local_trusted"?q.isFetchedAfterMount:!0,U=B?q.data?.companies??[]:[];(0,m.useEffect)(()=>{a&&Ade(a)},[a]),(0,m.useEffect)(()=>{A(!1)},[a]),(0,m.useEffect)(()=>{if(!B)return;const he=q.data?.companies;!he||!E.data?.companyId||he.some(ve=>ve.id===E.data.companyId)&&iT(a)},[q.data,E.data,B,a]);const z=E.data,$=!!O.data&&!!z?.companyId&&!B,K=!!z?.companyId&&U.some(he=>he.id===z?.companyId),H=z?.companyName?.trim()||"this Paperclip company",se=z?.companyLogoUrl?.trim()||null,Z=z?.invitedByUserName?.trim()||null,ie=z?.inviteMessage?.trim()||null,oe=zQt(z?.humanRole),Y=z?.joinRequestStatus??null,ne=z?.joinRequestType??null,de=ne==="human"&&(Y==="pending_approval"||Y==="approved"),ee=D.data?.deploymentMode==="authenticated"&&!O.data&&z?.allowedJoinTypes!=="agent",X=z?.inviteType!=="bootstrap_ceo"&&z?.allowedJoinTypes==="agent",Q=!!O.data&&!X&&z?.inviteType!=="bootstrap_ceo"&&(!Y||de)&&!$&&!K&&!j&&_===null,fe=O.data?.user.name?.trim()||O.data?.user.email?.trim()||"this account",te=d.trim().length>0&&h.trim().length>0&&(i==="sign_in"||l.trim().length>0&&h.trim().length>=8),ae=Ne({mutationFn:r(async()=>{if(!z)throw new Error("Invite not found");if($)throw new Error("Checking your organization access. Try again in a moment.");if(K)throw new Error("This account already belongs to the organization.");return z.inviteType==="bootstrap_ceo"||z.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 he=>{I(null),iT(a);const ve=Lde(he);N({kind:ve?"bootstrap":"join",payload:he}),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.access.currentBoardAccess}),await e.invalidateQueries({queryKey:P.companies.all}),z?.companyId&&WQt(he,X)&&(n(z.companyId,{source:"manual"}),s("/",{replace:!0}))},"onSuccess"),onError:r(he=>{I(he instanceof Error?he.message:"Failed to accept invite")},"onError")});(0,m.useEffect)(()=>{!Q||R||ae.isPending||(A(!0),I(null),ae.mutate())},[ae,R,Q]);const le=Ne({mutationFn:r(async()=>{if(i==="sign_in"){await za.signInEmail({email:d.trim(),password:h});return}await za.signUpEmail({name:l.trim(),email:d.trim(),password:h})},"mutationFn"),onSuccess:r(async()=>{T(null),Ade(a),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.invalidateQueries({queryKey:P.access.currentBoardAccess});const{companies:he}=await _Te(e);if(z?.companyId&&he.some(ve=>ve.id===z.companyId)){iT(a),n(z.companyId,{source:"manual"}),s("/",{replace:!0});return}if(!(!z||z.inviteType!=="bootstrap_ceo"))try{Lde(await ae.mutateAsync())&&s("/",{replace:!0})}catch{return}},"onSuccess"),onError:r(he=>{const ve=KQt(he,i,d);UAe(he)==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"&&(o("sign_in"),p("")),T(ve)},"onError")}),ce=(0,m.useMemo)(()=>z?K?"Open organization":z.inviteType==="bootstrap_ceo"?"Accept invite":X?"Submit request":O.data?"Accept invite":"Continue":"Continue",[z,K,O.data,X]);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||D.isLoading||O.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading invite..."});if($)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||!z)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(Y==="approved"&&ne==="human"&&K)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Opening organization..."});if(Y==="pending_approval"&&!de)return(0,t.jsx)(Dde,{companyDisplayName:H,companyLogoUrl:se,invitedByUserName:Z});if(Y&&!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:Y==="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)(Qe,{to:"/",children:"Open board"})})})]})});if(j?.kind==="join"){const he=j.payload,ve=typeof he.claimSecret=="string"?he.claimSecret:null,pe=typeof he.claimApiKeyPath=="string"?he.claimApiKeyPath:null,xe=qQt(he.onboarding,["textInstructions","url"]);return!X&&he.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)(RU,{companyDisplayName:H,companyLogoUrl:se,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)(Qe,{to:"/",children:"Open board"})})})]})}):(0,t.jsx)(Dde,{companyDisplayName:H,companyLogoUrl:se,invitedByUserName:Z,claimSecret:ve,claimApiKeyPath:pe,onboardingTextUrl:xe})}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:`${Pde} space-y-6`,children:[(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[(0,t.jsx)(RU,{companyDisplayName:H,companyLogoUrl:se,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:z.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:X?"Review the invite details, then submit the agent information below to start the join request.":ee?"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:Z??"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:X?"Agent join request":oe??"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:vu(z.expiresAt)})]})]}),ie?(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:ie})]}):null,O.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:`${Pde} h-fit`,children:X?(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:Ij,value:f,onChange:r(he=>g(he.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:Ij,value:v,onChange:r(he=>y(he.target.value),"onChange"),children:BQt.map(he=>(0,t.jsxs)("option",{value:he,disabled:!Ede.has(he),children:[kf(he),Ede.has(he)?"":" (Coming soon)"]},he))})]}),(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:Ij,rows:4,value:w,onChange:r(he=>k(he.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...":ce})]}):ee?(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:`${Mde} ${i==="sign_up"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:r(()=>{T(null),o("sign_up")},"onClick"),children:"Create account"}),(0,t.jsx)("button",{type:"button",className:`${Mde} ${i==="sign_in"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:r(()=>{T(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(he=>{if(he.preventDefault(),!le.isPending){if(!te){T({tone:"error",message:"Please fill in all required fields."});return}le.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:Ij,value:l,onChange:r(he=>{c(he.target.value),T(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:Ij,value:d,onChange:r(he=>{u(he.target.value),T(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:Ij,value:h,onChange:r(he=>{p(he.target.value),T(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:le.isPending,"aria-disabled":!te||le.isPending,children:le.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:K?"Already in this organization":Q?"Completing organization access":z.inviteType==="bootstrap_ceo"?"Accept bootstrap invite":"Accept organization invite"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:Q?`Granting your access to ${H}.`:K?`This account already belongs to ${H}.`:`This will ${z.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,Q?(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(K&&z.companyId){iT(a),n(z.companyId,{source:"manual"}),s("/",{replace:!0});return}ae.mutate()},"onClick"),children:ae.isPending?"Working...":ce})]})})]})})})}r(VQt,"InviteLandingPage");function HQt(){const{selectedCompany:e,selectedCompanyId:s}=ps(),{setBreadcrumbs:n}=Bn(),{pushToast:a}=Ai(),i=Ut(),[o,l]=(0,m.useState)("pending_approval"),[c,d]=(0,m.useState)("all");(0,m.useEffect)(()=>{n([{label:e?.name??"Organization",href:"/dashboard"},{label:"Inbox",href:"/inbox"},{label:"Join Requests"}])},[e?.name,n]);const u=J({queryKey:P.access.joinRequests(s??"",`${o}:${c}`),queryFn:r(()=>ur.listJoinRequests(s,o,c==="all"?void 0:c),"queryFn"),enabled:!!s}),h=Ne({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=Ne({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(u.isLoading)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading join requests…"});if(u.error){const f=u.error instanceof cn&&u.error.status===403?"You do not have permission to review join requests for this organization.":u.error instanceof Error?u.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)(bDe,{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)(Js,{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:(u.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."}):u.data.map(f=>(0,t.jsxs)(Js,{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)(ot,{variant:f.status==="pending_approval"?"secondary":f.status==="approved"?"outline":"destructive",children:f.status.replace("_"," ")}),(0,t.jsx)(ot,{variant:"outline",children:f.requestType}),f.adapterType?(0,t.jsx)(ot,{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(HQt,"JoinRequestQueue");var GQt=(0,m.lazy)(()=>Sc(()=>import("./CompanyExport-BPSpRY83.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]))),QQt=(0,m.lazy)(()=>Sc(()=>import("./Agents.production-JxKz0JXx.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]))),YQt=(0,m.lazy)(()=>Sc(()=>import("./Routines.production-Cqmj3iUl.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]))),$de=(0,m.lazy)(()=>Sc(()=>import("./RoutineDetail.production-CLjPte-l.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]))),XQt=(0,m.lazy)(()=>Sc(()=>import("./CompanySkills.production-QuhKpjUZ.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]))),JQt=(0,m.lazy)(()=>Sc(()=>import("./CompanyActivity.production-Dr3ODOqW.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]))),ZQt=(0,m.lazy)(()=>Sc(()=>import("./Costs.production-C_6rqSBB.js").then(e=>({default:e.Costs})),__vite__mapDeps([58,5,7,28,29,13,12,44,41,50,27,51,24,25]))),eYt=(0,m.lazy)(()=>Sc(()=>import("./OrgChart.production-_dYTeNBw.js").then(e=>({default:e.OrgChart})),__vite__mapDeps([59,5,7,8,9,10,11,12,13,27,45,46,51,24,25])));function Rg({children:e}){return(0,t.jsx)(m.Suspense,{fallback:(0,t.jsx)(oh,{}),children:e})}r(Rg,"ProductionSurface");function tYt(e){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(it,{index:!0,element:(0,t.jsx)(bn,{to:"dashboard",replace:!0})}),(0,t.jsx)(it,{path:"dashboard",element:(0,t.jsx)(W0t,{})}),(0,t.jsx)(it,{path:"dashboard/live",element:(0,t.jsx)(V0t,{})}),(0,t.jsx)(it,{path:"timeline",element:e?(0,t.jsx)(Ep,{to:"/activity/timeline"}):(0,t.jsx)(QNe,{})}),(0,t.jsx)(it,{path:"onboarding",element:(0,t.jsx)(VAe,{})}),(0,t.jsx)(it,{path:"companies",element:(0,t.jsx)(Ebt,{})}),(0,t.jsx)(it,{path:"company/settings",element:(0,t.jsx)(z$t,{})}),(0,t.jsx)(it,{path:"company/settings/environments",element:(0,t.jsx)(bn,{to:"/company/settings/instance/environments",replace:!0})}),(0,t.jsx)(it,{path:"company/settings/cloud-upstream",element:(0,t.jsx)(bn,{to:"/company/export",replace:!0})}),(0,t.jsxs)(it,{element:(0,t.jsx)(yh,{pageKey:"company.members"}),children:[(0,t.jsx)(it,{path:"company/settings/members",element:(0,t.jsx)(dqt,{})}),(0,t.jsx)(it,{path:"company/settings/access",element:(0,t.jsx)(uqt,{})})]}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"company.invites"}),children:(0,t.jsx)(it,{path:"company/settings/invites",element:(0,t.jsx)(bn,{to:"/company/settings/members?tab=invites",replace:!0})})}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"company.export"}),children:(0,t.jsx)(it,{path:"company/export/*",element:(0,t.jsx)(m.Suspense,{fallback:(0,t.jsx)(oh,{}),children:(0,t.jsx)(GQt,{})})})}),(0,t.jsx)(it,{element:(0,t.jsx)(Nat,{}),children:(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"company.import"}),children:(0,t.jsx)(it,{path:"company/import",element:(0,t.jsx)(lGt,{})})})}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"company.secrets"}),children:(0,t.jsx)(it,{path:"company/settings/secrets",element:(0,t.jsx)(nHt,{})})}),(0,t.jsx)(it,{path:"company/settings/tools",element:(0,t.jsx)(Fde,{})}),(0,t.jsx)(it,{path:"company/settings/tools/:tab",element:(0,t.jsx)(Fde,{})}),(0,t.jsx)(it,{path:"tools",element:(0,t.jsx)(Bde,{})}),(0,t.jsx)(it,{path:"tools/:tab",element:(0,t.jsx)(Bde,{})}),(0,t.jsx)(it,{path:"apps",element:(0,t.jsx)(Gzt,{})}),(0,t.jsx)(it,{path:"apps/browse",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/connections",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/byo",element:(0,t.jsx)(pIe,{byoOnly:!0})}),(0,t.jsx)(it,{path:"apps/vercel-connect",element:(0,t.jsx)(Ode,{credentialSource:"vercel_connect"})}),(0,t.jsx)(it,{path:"apps/connect",element:(0,t.jsx)(Ode,{})}),(0,t.jsx)(it,{path:"apps/chat/connect",element:(0,t.jsx)(KO,{children:(0,t.jsx)(SUt,{})})}),(0,t.jsx)(it,{path:"apps/chat/:endpointId",element:(0,t.jsx)(KO,{children:(0,t.jsx)(bn,{to:"settings",replace:!0})})}),(0,t.jsx)(it,{path:"apps/chat/:endpointId/:tab",element:(0,t.jsx)(KO,{children:(0,t.jsx)(IKt,{})})}),(0,t.jsx)(it,{path:"apps/connect/:appKey",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/connect/:appKey/:stage",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/review",element:(0,t.jsx)(LKt,{})}),(0,t.jsx)(it,{path:"apps/attention",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/gateways",element:(0,t.jsx)(Gle,{})}),(0,t.jsx)(it,{path:"apps/gateways/:gatewayId",element:(0,t.jsx)(bn,{to:"overview",replace:!0})}),(0,t.jsx)(it,{path:"apps/gateways/:gatewayId/:tab",element:(0,t.jsx)(A8t,{})}),(0,t.jsx)(it,{path:"apps/advanced",element:(0,t.jsx)(Nle,{})}),(0,t.jsx)(it,{path:"apps/advanced/gateways",element:(0,t.jsx)(Gle,{})}),(0,t.jsx)(it,{path:"apps/advanced/profiles/new",element:(0,t.jsx)(Ile,{mode:"new"})}),(0,t.jsx)(it,{path:"apps/advanced/profiles/:profileId/edit",element:(0,t.jsx)(Ile,{mode:"edit"})}),(0,t.jsx)(it,{path:"apps/advanced/profiles/:profileId",element:(0,t.jsx)(Rzt,{})}),(0,t.jsx)(it,{path:"apps/advanced/audit",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/advanced/run-your-own",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/advanced/:tab",element:(0,t.jsx)(Nle,{})}),(0,t.jsx)(it,{path:"apps/app/:applicationId",element:(0,t.jsx)(Wle,{})}),(0,t.jsx)(it,{path:"apps/app/:applicationId/:tab",element:(0,t.jsx)(Wle,{})}),(0,t.jsx)(it,{path:"apps/:connectionId",element:(0,t.jsx)(bn,{to:"permissions",replace:!0})}),(0,t.jsx)(it,{path:"apps/:connectionId/:tab",element:(0,t.jsx)(UKt,{})}),(0,t.jsx)(it,{path:"company/settings/instance",element:(0,t.jsx)(bn,{to:"/company/settings",replace:!0})}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"instance.profile"}),children:(0,t.jsx)(it,{path:"company/settings/instance/profile",element:(0,t.jsx)(dQt,{})})}),(0,t.jsx)(it,{path:"company/settings/instance/general",element:(0,t.jsx)(bn,{to:"/company/settings",replace:!0})}),(0,t.jsx)(it,{path:"company/settings/instance/heartbeats",element:(0,t.jsx)(bn,{to:"/company/settings",replace:!0})}),(0,t.jsxs)(it,{element:(0,t.jsx)(yh,{pageKey:"instance.environments"}),children:[(0,t.jsx)(it,{path:"company/settings/instance/environments",element:(0,t.jsx)(EO,{})}),(0,t.jsx)(it,{path:"company/settings/instance/environments/new",element:(0,t.jsx)(EO,{mode:"create"})}),(0,t.jsx)(it,{path:"company/settings/instance/environments/:environmentId/edit",element:(0,t.jsx)(EO,{mode:"edit"})})]}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"instance.access"}),children:(0,t.jsx)(it,{path:"company/settings/instance/access",element:(0,t.jsx)(iQt,{})})}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"instance.experimental"}),children:(0,t.jsx)(it,{path:"company/settings/instance/experimental",element:(0,t.jsx)(aQt,{})})}),(0,t.jsxs)(it,{element:(0,t.jsx)(yh,{pageKey:"instance.plugins"}),children:[(0,t.jsx)(it,{path:"company/settings/instance/plugins",element:(0,t.jsx)(mQt,{})}),(0,t.jsx)(it,{path:"company/settings/instance/plugins/:pluginId",element:(0,t.jsx)(hQt,{})})]}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"instance.adapters"}),children:(0,t.jsx)(it,{path:"company/settings/instance/adapters",element:(0,t.jsx)(Sde,{})})}),(0,t.jsx)(it,{path:"company/settings/:settingsRoutePath/*",element:(0,t.jsx)(nqt,{})}),(0,t.jsx)(it,{path:"skills/studio",element:(0,t.jsx)(rF,{})}),(0,t.jsx)(it,{path:"skills/studio/new",element:(0,t.jsx)(rF,{})}),(0,t.jsx)(it,{path:"skills/studio/:skillId",element:(0,t.jsx)(rF,{})}),(0,t.jsx)(it,{path:"skills/:skillId/studio",element:(0,t.jsx)(KAe,{})}),(0,t.jsx)(it,{path:"skills/*",element:e?(0,t.jsx)(K7t,{}):(0,t.jsx)(Rg,{children:(0,t.jsx)(XQt,{})})}),(0,t.jsx)(it,{path:"settings",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"settings/*",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"plugins/:pluginId",element:(0,t.jsx)(Cde,{})}),(0,t.jsx)(it,{path:"org",element:e?(0,t.jsx)(bn,{to:"/agents/all",replace:!0}):(0,t.jsx)(Rg,{children:(0,t.jsx)(eYt,{})})}),(0,t.jsx)(it,{path:"agents",element:(0,t.jsx)(bn,{to:"/agents/all",replace:!0})}),f9.map(s=>(0,t.jsx)(it,{path:`agents/${s}`,element:e?(0,t.jsx)(avt,{}):(0,t.jsx)(Rg,{children:(0,t.jsx)(QQt,{})})},s)),(0,t.jsx)(it,{path:"agents/new",element:(0,t.jsx)(RQt,{})}),(0,t.jsx)(it,{path:"agents/:agentId",element:(0,t.jsx)(u$,{})}),(0,t.jsx)(it,{path:"agents/:agentId/:tab",element:(0,t.jsx)(u$,{})}),(0,t.jsx)(it,{path:"agents/:agentId/runs/:runId",element:(0,t.jsx)(u$,{})}),(0,t.jsx)(it,{path:"projects",element:(0,t.jsx)(gwt,{})}),(0,t.jsx)(it,{path:"projects/:projectId",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{path:"projects/:projectId/overview",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{path:"projects/:projectId/issues",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{path:"projects/:projectId/issues/:filter",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{element:(0,t.jsx)(fD,{}),children:(0,t.jsx)(it,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,t.jsx)(mkt,{})})}),(0,t.jsx)(it,{path:"projects/:projectId/workspaces",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{path:"projects/:projectId/configuration",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{path:"projects/:projectId/budget",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{element:(0,t.jsx)(fD,{}),children:(0,t.jsx)(it,{path:"workspaces",element:(0,t.jsx)(fkt,{})})}),(0,t.jsx)(it,{path:"issues",element:(0,t.jsx)(Nkt,{})}),(0,t.jsx)(it,{path:"tasks",element:(0,t.jsx)(bn,{to:"/issues",replace:!0})}),(0,t.jsx)(it,{path:"search",element:(0,t.jsx)(Qkt,{})}),(0,t.jsx)(it,{path:"issues/all",element:(0,t.jsx)(bn,{to:"/issues",replace:!0})}),(0,t.jsx)(it,{path:"issues/active",element:(0,t.jsx)(bn,{to:"/issues",replace:!0})}),(0,t.jsx)(it,{path:"issues/backlog",element:(0,t.jsx)(bn,{to:"/issues",replace:!0})}),(0,t.jsx)(it,{path:"issues/done",element:(0,t.jsx)(bn,{to:"/issues",replace:!0})}),(0,t.jsx)(it,{path:"issues/recent",element:(0,t.jsx)(bn,{to:"/issues",replace:!0})}),(0,t.jsx)(it,{path:"chats/:agentRef",element:(0,t.jsx)(gIt,{})}),(0,t.jsx)(it,{path:"issues/:issueId",element:(0,t.jsx)(fIt,{})}),null,(0,t.jsx)(it,{path:"routines",element:e?(0,t.jsx)(YIt,{}):(0,t.jsx)(Rg,{children:(0,t.jsx)(YQt,{})})}),(0,t.jsx)(it,{path:"cases",element:(0,t.jsx)(tee,{children:(0,t.jsx)(Uat,{})})}),(0,t.jsx)(it,{path:"cases/:caseIdentifier",element:(0,t.jsx)(tee,{children:(0,t.jsx)(Clt,{})})}),(0,t.jsx)(it,{path:"pixels-office",element:(0,t.jsx)(wat,{children:(0,t.jsx)(_Pt,{})})}),(0,t.jsx)(it,{path:"status",element:(0,t.jsx)(see,{children:(0,t.jsx)(mae,{})})}),(0,t.jsx)(it,{path:"status/:cardId",element:(0,t.jsx)(see,{children:(0,t.jsx)(mae,{})})}),(0,t.jsx)(it,{path:"status-cards",element:(0,t.jsx)(qde,{})}),(0,t.jsx)(it,{path:"status-cards/:cardId",element:(0,t.jsx)(qde,{})}),(0,t.jsx)(it,{path:"review-queue",element:(0,t.jsx)(yg,{children:(0,t.jsx)(pTt,{})})}),(0,t.jsx)(it,{path:"learnings",element:(0,t.jsx)(yg,{children:(0,t.jsx)(xTt,{})})}),(0,t.jsx)(it,{path:"pipelines",element:(0,t.jsx)(yg,{children:(0,t.jsx)(V$,{})})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId",element:(0,t.jsx)(yg,{children:(0,t.jsx)(V$,{})})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/add",element:(0,t.jsx)(yg,{children:(0,t.jsx)(V$,{})})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/settings",element:(0,t.jsx)(yg,{children:(0,t.jsx)(cRt,{})})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/items/:caseId",element:(0,t.jsx)(yg,{children:(0,t.jsx)(M2t,{})})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,t.jsx)(yg,{children:(0,t.jsx)(R2t,{})})}),(0,t.jsx)(it,{path:"routines/:routineId",element:e?(0,t.jsx)(pie,{}):(0,t.jsx)(Rg,{children:(0,t.jsx)($de,{})})}),(0,t.jsx)(it,{path:"routines/:routineId/:section",element:e?(0,t.jsx)(pie,{}):(0,t.jsx)(Rg,{children:(0,t.jsx)($de,{})})}),(0,t.jsx)(it,{element:(0,t.jsx)(fD,{}),children:(0,t.jsxs)(it,{element:(0,t.jsx)(Sat,{}),children:[(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId",element:(0,t.jsx)(wj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/services",element:(0,t.jsx)(wj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/configuration",element:(0,t.jsx)(wj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,t.jsx)(wj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/issues",element:(0,t.jsx)(wj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/routines",element:(0,t.jsx)(wj,{})})]})}),(0,t.jsx)(it,{path:"goals",element:(0,t.jsx)(w4t,{})}),(0,t.jsx)(it,{path:"goals/:goalId",element:(0,t.jsx)(D4t,{})}),(0,t.jsx)(it,{path:"artifacts",element:(0,t.jsx)(bie,{})}),(0,t.jsx)(it,{path:"approvals",element:(0,t.jsx)(bn,{to:"/approvals/pending",replace:!0})}),(0,t.jsx)(it,{path:"approvals/pending",element:(0,t.jsx)(yie,{})}),(0,t.jsx)(it,{path:"approvals/all",element:(0,t.jsx)(yie,{})}),(0,t.jsx)(it,{path:"approvals/:approvalId",element:(0,t.jsx)($4t,{})}),(0,t.jsx)(it,{path:"activity",element:e?(0,t.jsx)(kLt,{}):(0,t.jsx)(Rg,{children:(0,t.jsx)(JQt,{})})}),e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(it,{path:"activity/runs",element:(0,t.jsx)(US,{section:"runs"})}),(0,t.jsx)(it,{path:"activity/costs",element:(0,t.jsx)(US,{section:"costs"})}),(0,t.jsx)(it,{path:"activity/budgets",element:(0,t.jsx)(US,{section:"budgets"})}),(0,t.jsx)(it,{path:"activity/timeline",element:(0,t.jsx)(US,{section:"timeline"})}),(0,t.jsx)(it,{path:"audit",element:(0,t.jsx)(Ep,{to:"/activity",forceAgentMode:!0})}),(0,t.jsx)(it,{path:"audit/activity",element:(0,t.jsx)(Ep,{to:"/activity"})}),(0,t.jsx)(it,{path:"audit/runs",element:(0,t.jsx)(Ep,{to:"/activity/runs"})}),(0,t.jsx)(it,{path:"audit/costs",element:(0,t.jsx)(Ep,{to:"/activity/costs"})}),(0,t.jsx)(it,{path:"audit/budgets",element:(0,t.jsx)(Ep,{to:"/activity/budgets"})}),(0,t.jsx)(it,{path:"audit/timeline",element:(0,t.jsx)(Ep,{to:"/activity/timeline"})}),(0,t.jsx)(it,{path:"runs",element:(0,t.jsx)(Ep,{to:"/activity/runs"})}),(0,t.jsx)(it,{path:"costs",element:(0,t.jsx)(Ep,{to:"/activity/costs"})}),(0,t.jsx)(it,{path:"budgets",element:(0,t.jsx)(Ep,{to:"/activity/budgets"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(it,{path:"costs",element:(0,t.jsx)(Rg,{children:(0,t.jsx)(ZQt,{})})}),(0,t.jsx)(it,{path:"audit",element:(0,t.jsx)(bn,{to:"/activity?mode=agents",replace:!0})})]}),(0,t.jsxs)(it,{element:(0,t.jsx)(cst,{}),children:[(0,t.jsx)(it,{path:"board-chat",element:(0,t.jsx)(A$t,{})}),(0,t.jsx)(it,{path:"artifacts",element:(0,t.jsx)(bie,{})})]}),null,(0,t.jsx)(it,{path:"decisions",element:(0,t.jsx)(e$t,{})}),(0,t.jsx)(it,{path:"decisions/queues/:key",element:(0,t.jsx)(r$t,{})}),(0,t.jsx)(it,{path:"inbox",element:(0,t.jsx)(sYt,{})}),(0,t.jsx)(it,{path:"inbox/mine",element:(0,t.jsx)(uS,{})}),(0,t.jsx)(it,{path:"inbox/recent",element:(0,t.jsx)(uS,{})}),(0,t.jsx)(it,{path:"inbox/unread",element:(0,t.jsx)(uS,{})}),(0,t.jsx)(it,{path:"inbox/blocked",element:(0,t.jsx)(uS,{})}),(0,t.jsx)(it,{path:"inbox/all",element:(0,t.jsx)(uS,{})}),(0,t.jsx)(it,{path:"inbox/requests",element:(0,t.jsx)(HQt,{})}),(0,t.jsx)(it,{path:"inbox/new",element:(0,t.jsx)(bn,{to:"/inbox/mine",replace:!0})}),(0,t.jsx)(it,{path:"u/:userSlug",element:(0,t.jsx)(YMt,{})}),(0,t.jsx)(it,{path:"design-guide",element:(0,t.jsx)(sQt,{})}),(0,t.jsx)(it,{path:"instance/settings/adapters",element:(0,t.jsx)(Sde,{})}),(0,t.jsx)(it,{path:":pluginRoutePath/*",element:(0,t.jsx)(Cde,{})}),(0,t.jsx)(it,{path:"*",element:(0,t.jsx)(ju,{scope:"board"})})]})}r(tYt,"boardRoutes");function Ode({credentialSource:e="paperclip_vault"}={}){const s=ra(),n=new URLSearchParams(s.search),{enabled:a}=Yx();return yZe(n,{chatConnectorsEnabled:a})?(0,t.jsx)(pIe,{credentialSource:e}):(0,t.jsx)(bn,{to:"/apps",replace:!0})}r(Ode,"AppsConnectEntryRoute");function sYt(){return(0,t.jsx)(bn,{to:`/inbox/${D5e()}`,replace:!0})}r(sYt,"InboxRootRedirect");function KAe(){const e=ra(),{companies:s,selectedCompany:n,loading:a}=ps(),{companyPrefix:i,skillId:o}=Ia();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)(bn,{to:"/skills/studio",replace:!0}):(0,t.jsx)(bn,{to:`/${l.issuePrefix}/skills/studio/${encodeURIComponent(o)}${e.search}${e.hash}`,replace:!0})}r(KAe,"LegacySkillStudioRedirect");function qb(){const e=ra(),{companies:s,selectedCompany:n,loading:a}=ps(),{companyPrefix:i}=Ia(),{hidden:o}=uh();if(a)return(0,t.jsx)(oh,{});const l=(i?s.find(d=>d.issuePrefix.toUpperCase()===i.toUpperCase()):null)??n??s[0]??null;if(!l)return s7({pathname:e.pathname,hasCompanies:!1})?(0,t.jsx)(bn,{to:"/onboarding",replace:!0}):(0,t.jsx)(GW,{});const c=aBe(dpe(`${e.pathname}${e.search}${e.hash}`),o);return(0,t.jsx)(bn,{to:`/${l.issuePrefix}${c}`,replace:!0})}r(qb,"LegacySettingsRedirect");function Fde(){const{tab:e}=Ia();return(0,t.jsx)(bn,{to:WAe(e),replace:!0})}r(Fde,"LegacyToolsSettingsRedirect");function Bde(){const{tab:e}=Ia();return(0,t.jsx)(bn,{to:WAe(e),replace:!0})}r(Bde,"LegacyToolsRedirect");function WAe(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(WAe,"legacyToolsRedirectTarget");function VAe(){const{companies:e}=ps(),{openOnboarding:s}=zo(),{t:n}=Ohe(),a=td(),i=U3(a?.cloudBaseUrl??null),{onboardingOpen:o,onboardingRouteDismissed:l}=_3(),{companyPrefix:c}=Ia(),d=c?e.find(p=>p.issuePrefix.toUpperCase()===c.toUpperCase())??null:null;if(Cet({onboardingOpen:o,routeDismissed:l}))return null;const u=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:u}),(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:U5(),companyId:d.id}):a&&i?Ac(i):s(),"onClick"),children:d?"Add Agent":"Start Onboarding"})})]})})}r(VAe,"OnboardingRoutePage");function nYt(){const{companies:e,selectedCompany:s,loading:n}=ps(),a=ra();if(n)return(0,t.jsx)(oh,{});const i=s??e[0]??null;return i?(0,t.jsx)(bn,{to:`/${i.issuePrefix}/dashboard`,replace:!0}):s7({pathname:a.pathname,hasCompanies:!1})?(0,t.jsx)(bn,{to:"/onboarding",replace:!0}):(0,t.jsx)(GW,{})}r(nYt,"CompanyRootRedirect");function qde(){const{cardId:e}=Ia(),s=KRe(),n=s?`/${s}`:"";return(0,t.jsx)(bn,{to:`${n}/status${e?`/${e}`:""}`,replace:!0})}r(qde,"StatusCardsLegacyRedirect");function Ep({to:e,forceAgentMode:s=!1}){const n=ra(),a=new URLSearchParams(n.search);s&&a.set("mode","agents");const i=a.toString();return(0,t.jsx)(bn,{to:`${e}${i?`?${i}`:""}${n.hash}`,replace:!0})}r(Ep,"AuditCompatibilityRedirect");function ga(){const e=ra(),{companies:s,selectedCompany:n,loading:a}=ps();if(a)return(0,t.jsx)(oh,{});const i=n??s[0]??null;return i?(0,t.jsx)(bn,{to:`/${i.issuePrefix}${e.pathname}${e.search}${e.hash}`,replace:!0}):s7({pathname:e.pathname,hasCompanies:!1})?(0,t.jsx)(bn,{to:"/onboarding",replace:!0}):(0,t.jsx)(GW,{})}r(ga,"UnprefixedBoardRedirect");function GW(){const{openOnboarding:e}=zo(),{t:s}=Ohe(),n=td(),a=U3(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?Ac(a):e(),"onClick"),children:s("app.noCompanies.newCompany",{defaultValue:"New Organization"})})})]})})}r(GW,"NoCompaniesStartPage");function rYt(){const{enabled:e,loaded:s}=Tc();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(HRe,{children:[(0,t.jsx)(it,{path:"oauth-handoff",element:(0,t.jsx)(o8t,{})}),(0,t.jsx)(it,{path:"auth",element:(0,t.jsx)($Qt,{})}),(0,t.jsx)(it,{path:"board-claim/:token",element:(0,t.jsx)(OQt,{})}),(0,t.jsx)(it,{path:"cli-auth/:id",element:(0,t.jsx)(FQt,{})}),(0,t.jsx)(it,{path:"invite/:token",element:(0,t.jsx)(VQt,{})}),(0,t.jsx)(it,{element:s?(0,t.jsx)(Qee,{allowMembershipRequest:!0}):(0,t.jsx)(oh,{}),children:(0,t.jsx)(it,{path:"chat-identity/confirm",element:(0,t.jsx)(PKt,{})})}),(0,t.jsx)(it,{path:"tests/perf/long-thread",element:(0,t.jsx)(IIt,{})}),(0,t.jsx)(it,{path:"ux-lab/bootstrap-setup",element:(0,t.jsx)(Z6t,{})}),(0,t.jsx)(it,{path:"ux-lab/responsible-user-denial",element:(0,t.jsx)(eqt,{})}),(0,t.jsx)(it,{path:"ux-lab/cross-issue-collaboration",element:(0,t.jsx)(sqt,{})}),(0,t.jsxs)(it,{element:s?(0,t.jsx)(Qee,{}):(0,t.jsx)(oh,{}),children:[(0,t.jsx)(it,{index:!0,element:(0,t.jsx)(nYt,{})}),(0,t.jsx)(it,{path:"onboarding",element:(0,t.jsx)(VAe,{})}),(0,t.jsx)(it,{path:"instance",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"instance/settings",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"instance/settings/*",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"companies",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"dashboard",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"inbox/*",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"issues",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"tasks",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"issues/:issueId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"routines",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"routines/:routineId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"review-queue",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"learnings",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"cases",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"cases/:caseIdentifier",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pixels-office",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"status",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"status/:cardId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"status-cards",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"status-cards/:cardId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pipelines",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/add",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/settings",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/items/:caseId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"artifacts",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"audit",element:(0,t.jsx)(ga,{})}),e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(it,{path:"audit/*",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"activity",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"activity/*",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"runs",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"costs",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"budgets",element:(0,t.jsx)(ga,{})})]}):null,(0,t.jsx)(it,{path:"decisions",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"u/:userSlug",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"skills/studio",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"skills/studio/new",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"skills/studio/:skillId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"skills/:skillId/studio",element:(0,t.jsx)(KAe,{})}),(0,t.jsx)(it,{path:"skills/*",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"settings",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"settings/*",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"agents",element:(0,t.jsx)(ga,{})}),f9.map(n=>(0,t.jsx)(it,{path:`agents/${n}`,element:(0,t.jsx)(ga,{})},n)),(0,t.jsx)(it,{path:"agents/new",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"agents/:agentId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"agents/:agentId/:tab",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"agents/:agentId/runs/:runId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId/overview",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId/issues",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId/issues/:filter",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId/workspaces",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId/configuration",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"workspaces",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId",element:(0,t.jsx)(sj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/services",element:(0,t.jsx)(sj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/configuration",element:(0,t.jsx)(sj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,t.jsx)(sj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/issues",element:(0,t.jsx)(sj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/routines",element:(0,t.jsx)(sj,{})}),(0,t.jsx)(it,{path:":companyPrefix",element:e?(0,t.jsx)(Ctt,{}):(0,t.jsx)(ist,{}),children:tYt(e)}),(0,t.jsx)(it,{path:"*",element:(0,t.jsx)(ju,{scope:"global"})})]})]}),(0,t.jsx)(tct,{}),(0,t.jsx)(rtt,{})]})}r(rYt,"App");var aYt=class extends m.Component{static{r(this,"AppErrorBoundary")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,s){Ebe(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 iYt(){const{data:e}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),s=e?.sentryDsn,n=e?.sentryEnvironment??void 0;return(0,m.useEffect)(()=>{if(s)return Ket(s,n),()=>{Wet()}},[s,n]),null}r(iYt,"SentryGate");function oYt(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(oYt,"managedRoutineToRow");function lYt({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:u,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=oYt(y),k=y.href??(y.routineId?`/routines/${y.routineId}`:"/routines"),j=y.missingRefs??[],N=!!(y.routineId&&y.resourceKey&&j.length===0),_=y.managedByPluginDisplayName??a,I=!!(p||f);return(0,t.jsxs)("div",{className:"last:[&_a]:border-b-0",children:[(0,t.jsx)(QSe,{routine:w,projectById:v,agentById:g,runningRoutineId:o,statusMutationRoutineId:l,href:k,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(()=>u?.(y),"onRunNow"),onToggleEnabled:r(()=>h?.(y,w.status==="active"),"onToggleEnabled")}),I?(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(lYt,"ManagedRoutinesList");function zde(e){return new Set(e??[])}r(zde,"toPathSet");function cYt({expandedPaths:e,checkedPaths:s,selectedFile:n=null,showCheckboxes:a=!1,onToggleDir:i,onSelectFile:o,...l}){return(0,m.createElement)(G_,{...l,selectedFile:n,expandedDirs:zde(e),checkedFiles:s?zde(s):void 0,showCheckboxes:a,onToggleDir:i??(()=>{}),onSelectFile:o??(()=>{})})}r(cYt,"PluginSdkFileTree");function dYt(e){const[s,n]=(0,m.useState)(null);return(0,m.useEffect)(()=>{let a=!1;return Sc(()=>import("./MarkdownEditor-BXxDMPIh.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,m.createElement)(s,e):(0,m.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(dYt,"PluginSdkMarkdownEditor");function uYt(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!=null&&s!==""&&s!==!1))}r(uYt,"compactIssueFilters");function mYt({companyId:e,projectId:s=null,filters:n,viewStateKey:a="paperclip:plugin-issues-view",initialSearch:i,createIssueLabel:o,searchWithinLoadedIssues:l=!0}){const c=Ut(),d=(0,m.useMemo)(()=>uYt({...n??{},projectId:n?.projectId??s??void 0}),[n,s]),u=d.originKindPrefix??null,h=d.projectId??s??null,p=(0,m.useMemo)(()=>["plugins","sdk-ui","issues-list",e??"__no-company__",d],[e,d]),{data:f}=J({queryKey:P.agents.list(e??"__no-company__"),queryFn:r(()=>Vt.list(e),"queryFn"),enabled:!!e}),{data:g}=J({queryKey:P.projects.list(e??"__no-company__",{includeArchived:!0}),queryFn:r(()=>pa.list(e,{includeArchived:!0}),"queryFn"),enabled:!!e}),v=P.liveRuns(e??"__no-company__"),y=fo({companyId:e,resourceKey:"live-runs",queryKey:v,enabled:!!e,refetchInterval:!1,leaderOnly:!0}),{data:w,dataUpdatedAt:k}=J({queryKey:v,queryFn:r(()=>Yr.liveRunsForCompany(e),"queryFn"),enabled:y.enabled,refetchInterval:y.refetchInterval});xo(y,w,k);const{data:j,isLoading:N,error:_}=J({queryKey:p,queryFn:r(()=>_t.list(e,d),"queryFn"),enabled:!!e}),I=(0,m.useMemo)(()=>Kx(w,j),[j,w]),C=Ne({mutationFn:r(({id:T,data:R})=>_t.update(T,R),"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)}),u&&c.invalidateQueries({queryKey:P.issues.listPluginOperationsByProject(e,h,u)})))},"onSuccess")});return e?(0,m.createElement)(Px,{issues:j??[],isLoading:N,error:_,agents:f,projects:g,liveIssueIds:I,projectId:h??void 0,viewStateKey:a,initialSearch:i,createIssueLabel:o,searchWithinLoadedIssues:l,onUpdateIssue:r((T,R)=>C.mutate({id:T,data:R}),"onUpdateIssue")}):(0,m.createElement)("div",{className:"text-sm text-muted-foreground"},"Select an organization to view tasks.")}r(mYt,"PluginSdkIssuesList");function hYt({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:u,onConfirm:h}){const p=RK(),f=e??p.companyId??null,{data:g}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),enabled:c}),v=g?.user?.id??g?.session?.userId??null,{data:y}=J({queryKey:P.agents.list(f??"__no-company__"),queryFn:r(()=>Vt.list(f),"queryFn"),enabled:!!f}),{data:w}=J({queryKey:P.access.companyUserDirectory(f??"__no-company__"),queryFn:r(()=>ur.listUserDirectory(f),"queryFn"),enabled:!!f&&c}),k=(0,m.useMemo)(()=>x5e(),[]),j=(0,m.useMemo)(()=>k.map(T=>T.startsWith("agent:")?T.slice(6):null).filter(T=>!!T),[k]),N=(0,m.useMemo)(()=>u0((y??[]).filter(T=>d||T.status!=="terminated"),j),[y,d,j]),_=(0,m.useMemo)(()=>[...c?tme(v):[],...c?ON(w?.users,{excludeUserIds:[v]}):[],...N.map(T=>({id:Um({assigneeAgentId:T.id}),label:T.name,searchText:`${T.name} ${T.role} ${T.title??""}`}))],[w?.users,v,c,N]),I=zc(s),C=I.assigneeAgentId?N.find(T=>T.id===I.assigneeAgentId):null;return(0,m.createElement)(oc,{value:s,options:_,recentOptionIds:k,placeholder:a,noneLabel:i,searchPlaceholder:o,emptyMessage:l,className:u,onConfirm:h,onChange:r(T=>{const R=zc(T);R.assigneeAgentId&&t_(R.assigneeAgentId),R.assigneeUserId&&Due(R.assigneeUserId),n(T,R)},"onChange"),renderTriggerValue:r(T=>T?C?(0,m.createElement)(i3,null,(0,m.createElement)(Yw,{icon:C.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,m.createElement)("span",{className:"truncate"},T.label)):(0,m.createElement)("span",{className:"truncate"},T.label):(0,m.createElement)("span",{className:"text-muted-foreground"},a),"renderTriggerValue"),renderOption:r(T=>{if(!T.id)return(0,m.createElement)("span",{className:"truncate"},T.label);const R=zc(T.id),A=R.assigneeAgentId?N.find(L=>L.id===R.assigneeAgentId):null;return(0,m.createElement)(i3,null,A?(0,m.createElement)(Yw,{icon:A.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,m.createElement)(kc,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,m.createElement)("span",{className:"truncate"},T.label))},"renderOption")})}r(hYt,"PluginSdkAssigneePicker");function pYt({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:u}){const h=RK(),p=e??h.companyId??null,{data:f}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn")}),g=f?.user?.id??f?.session?.userId??null,{data:v}=J({queryKey:P.projects.list(p??"__no-company__",{includeArchived:c}),queryFn:r(()=>pa.list(p,{includeArchived:c}),"queryFn"),enabled:!!p}),y=(0,m.useMemo)(()=>(v??[]).filter(_=>c||!_.archivedAt),[c,v]),{orderedProjects:w}=ay({projects:y,companyId:p,userId:g}),k=(0,m.useMemo)(()=>LN(),[]),j=(0,m.useMemo)(()=>w.map(_=>({id:_.id,label:_.name,searchText:_.description??""})),[w]),N=w.find(_=>_.id===s)??null;return(0,m.createElement)(oc,{value:s,options:j,recentOptionIds:k,placeholder:a,noneLabel:i,searchPlaceholder:o,emptyMessage:l,className:d,onConfirm:u,onChange:r(_=>{_&&EN(_),n(_)},"onChange"),renderTriggerValue:r(_=>!_||!N?(0,m.createElement)("span",{className:"text-muted-foreground"},a):(0,m.createElement)(i3,null,(0,m.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:N.color??"#6366f1"}}),(0,m.createElement)("span",{className:"truncate"},_.label)),"renderTriggerValue"),renderOption:r(_=>{if(!_.id)return(0,m.createElement)("span",{className:"truncate"},_.label);const I=w.find(C=>C.id===_.id);return(0,m.createElement)(i3,null,(0,m.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:I?.color??"#6366f1"}}),(0,m.createElement)("span",{className:"truncate"},_.label))},"renderOption")})}r(pYt,"PluginSdkProjectPicker");function i3({children:e}){return(0,m.createElement)("span",{className:"contents"},e)}r(i3,"FragmentSafe");function fYt({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,m.createElement)("span",{className:`inline-flex w-fit items-center rounded-full border px-2 py-0.5 text-xs font-medium ${n}`},e)}r(fYt,"PluginSdkStatusBadge");function xYt({columns:e,rows:s,loading:n,emptyMessage:a="No rows."}){if(n)return(0,m.createElement)("div",{className:"text-sm text-muted-foreground"},"Loading...");if(!s.length)return(0,m.createElement)("div",{className:"text-sm text-muted-foreground"},a);const i=e.map(o=>o.width??"minmax(0, 1fr)").join(" ");return(0,m.createElement)("div",{className:"overflow-hidden rounded-md border"},(0,m.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,m.createElement)("div",{key:o.key},o.header))),(0,m.createElement)("div",{className:"divide-y"},s.map((o,l)=>(0,m.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,m.createElement)("div",{key:c.key,className:"min-w-0 text-sm"},(0,m.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(xYt,"PluginSdkDataTable");function gYt({pairs:e}){return(0,m.createElement)("dl",{className:"grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[max-content_minmax(0,1fr)]"},e.flatMap(s=>[(0,m.createElement)("dt",{key:`${s.label}:label`,className:"text-muted-foreground"},s.label),(0,m.createElement)("dd",{key:`${s.label}:value`,className:"min-w-0"},s.value)]))}r(gYt,"PluginSdkKeyValueList");function bYt({label:e,value:s,unit:n}){return(0,m.createElement)("div",{className:"rounded-md border bg-card p-3"},(0,m.createElement)("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground"},e),(0,m.createElement)("div",{className:"mt-1 text-lg font-semibold"},`${s}${n??""}`))}r(bYt,"PluginSdkMetricCard");function vYt({data:e}){return(0,m.createElement)("pre",{className:"max-h-80 overflow-auto rounded-md border bg-muted/30 p-2 text-xs"},JSON.stringify(e,null,2))}r(vYt,"PluginSdkJsonTree");function yYt({label:e="Loading"}){return(0,m.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(yYt,"PluginSdkSpinner");var jYt=class extends m.Component{static{r(this,"PluginSdkErrorBoundary")}state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??(0,m.createElement)("div",{className:"rounded-md border border-destructive/30 p-3 text-sm text-destructive"},"Plugin UI failed to render."):this.props.children}};function wYt(e,s){globalThis.__paperclipPluginBridge__={react:e,reactJsxRuntime:t,reactDom:s,sdkUi:{usePluginData:pBe,usePluginAction:fBe,useHostContext:RK,useHostLocation:gBe,useHostNavigation:xBe,usePluginStream:vBe,usePluginToast:bBe,copyTextToClipboard:Xr,MarkdownBlock:r(({content:n,className:a,enableWikiLinks:i,wikiLinkRoot:o,resolveWikiLinkHref:l})=>(0,m.createElement)($n,{className:a,softBreaks:!1,enableWikiLinks:i,wikiLinkRoot:o,resolveWikiLinkHref:l,children:n}),"MarkdownBlock"),MetricCard:bYt,StatusBadge:fYt,DataTable:xYt,KeyValueList:gYt,JsonTree:vYt,Spinner:yYt,ErrorBoundary:jYt,MarkdownEditor:dYt,FileTree:cYt,IssuesList:mYt,AssigneePicker:hYt,ProjectPicker:pYt,ManagedRoutinesList:lYt}}}r(wYt,"initPluginBridge");var NYt=1e4;function kYt(e=NYt){if(typeof performance>"u"||typeof performance.clearMeasures!="function")return()=>{};const n=setInterval(r(()=>{globalThis.__paperclipKeepPerfMeasures||performance.clearMeasures()},"reap"),e);return()=>clearInterval(n)}r(kYt,"startPerfMeasureReaper");var SYt=Gv((e=>{function s(U,z){var $=U.length;U.push(z);e:for(;0<$;){var K=$-1>>>1,H=U[K];if(0<i(H,z))U[K]=z,U[$]=H,$=K;else break e}}r(s,"push");function n(U){return U.length===0?null:U[0]}r(n,"peek");function a(U){if(U.length===0)return null;var z=U[0],$=U.pop();if($!==z){U[0]=$;e:for(var K=0,H=U.length,se=H>>>1;K<se;){var Z=2*(K+1)-1,ie=U[Z],oe=Z+1,Y=U[oe];if(0>i(ie,$))oe<H&&0>i(Y,ie)?(U[K]=Y,U[oe]=$,K=oe):(U[K]=ie,U[Z]=$,K=Z);else if(oe<H&&0>i(Y,$))U[K]=Y,U[oe]=$,K=oe;else break e}}return z}r(a,"pop");function i(U,z){var $=U.sortIndex-z.sortIndex;return $!==0?$:U.id-z.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=[],u=[],h=1,p=null,f=3,g=!1,v=!1,y=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function _(U){for(var z=n(u);z!==null;){if(z.callback===null)a(u);else if(z.startTime<=U)a(u),z.sortIndex=z.expirationTime,s(d,z);else break;z=n(u)}}r(_,"advanceTimers");function I(U){if(y=!1,_(U),!v)if(n(d)!==null)v=!0,C||(C=!0,O());else{var z=n(u);z!==null&&B(I,z.startTime-U)}}r(I,"handleTimeout");var C=!1,T=-1,R=5,A=-1;function L(){return w?!0:!(e.unstable_now()-A<R)}r(L,"shouldYieldToHost");function D(){if(w=!1,C){var U=e.unstable_now();A=U;var z=!0;try{e:{v=!1,y&&(y=!1,j(T),T=-1),g=!0;var $=f;try{t:{for(_(U),p=n(d);p!==null&&!(p.expirationTime>U&&L());){var K=p.callback;if(typeof K=="function"){p.callback=null,f=p.priorityLevel;var H=K(p.expirationTime<=U);if(U=e.unstable_now(),typeof H=="function"){p.callback=H,_(U),z=!0;break t}p===n(d)&&a(d),_(U)}else a(d);p=n(d)}if(p!==null)z=!0;else{var se=n(u);se!==null&&B(I,se.startTime-U),z=!1}}break e}finally{p=null,f=$,g=!1}z=void 0}}finally{z?O():C=!1}}}r(D,"performWorkUntilDeadline");var O;if(typeof N=="function")O=r(function(){N(D)},"schedulePerformWorkUntilDeadline");else if(typeof MessageChannel<"u"){var E=new MessageChannel,q=E.port2;E.port1.onmessage=D,O=r(function(){q.postMessage(null)},"schedulePerformWorkUntilDeadline")}else O=r(function(){k(D,0)},"schedulePerformWorkUntilDeadline");function B(U,z){T=k(function(){U(e.unstable_now())},z)}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(U){U.callback=null},e.unstable_forceFrameRate=function(U){0>U||125<U||(R=0<U?Math.floor(1e3/U):5)},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(U){switch(f){case 1:case 2:case 3:var z=3;break;default:z=f}var $=f;f=z;try{return U()}finally{f=$}},e.unstable_requestPaint=function(){w=!0},e.unstable_runWithPriority=function(U,z){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var $=f;f=U;try{return z()}finally{f=$}},e.unstable_scheduleCallback=function(U,z,$){var K=e.unstable_now();switch(typeof $=="object"&&$!==null?($=$.delay,$=typeof $=="number"&&0<$?K+$:K):$=K,U){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=$+H,U={id:h++,callback:z,priorityLevel:U,startTime:$,expirationTime:H,sortIndex:-1},$>K?(U.sortIndex=$,s(u,U),n(d)===null&&U===n(u)&&(y?(j(T),T=-1):y=!0,B(I,$-K))):(U.sortIndex=H,s(d,U),v||g||(v=!0,C||(C=!0,O()))),U},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(U){var z=f;return function(){var $=f;f=z;try{return U.apply(this,arguments)}finally{f=$}}}})),CYt=Gv(((e,s)=>{s.exports=SYt()})),_Yt=Gv((e=>{var s=CYt(),n=EU(),a=Gde();function i(x){var b="https://react.dev/errors/"+x;if(1<arguments.length){b+="?args[]="+encodeURIComponent(arguments[1]);for(var S=2;S<arguments.length;S++)b+="&args[]="+encodeURIComponent(arguments[S])}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,S=x;if(x.alternate)for(;b.return;)b=b.return;else{x=b;do b=x,(b.flags&4098)!==0&&(S=b.return),x=b.return;while(x)}return b.tag===3?S: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 u(x){if(l(x)!==x)throw Error(i(188))}r(u,"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 S=x,M=b;;){var V=S.return;if(V===null)break;var G=V.alternate;if(G===null){if(M=V.return,M!==null){S=M;continue}break}if(V.child===G.child){for(G=V.child;G;){if(G===S)return u(V),x;if(G===M)return u(V),b;G=G.sibling}throw Error(i(188))}if(S.return!==M.return)S=V,M=G;else{for(var be=!1,Me=V.child;Me;){if(Me===S){be=!0,S=V,M=G;break}if(Me===M){be=!0,M=V,S=G;break}Me=Me.sibling}if(!be){for(Me=G.child;Me;){if(Me===S){be=!0,S=G,M=V;break}if(Me===M){be=!0,M=G,S=V;break}Me=Me.sibling}if(!be)throw Error(i(189))}}if(S.alternate!==M)throw Error(i(190))}if(S.tag!==3)throw Error(i(188));return S.stateNode.current===S?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"),k=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),_=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),O=Symbol.iterator;function E(x){return x===null||typeof x!="object"?null:(x=O&&x[O]||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 k:return"StrictMode";case C:return"Suspense";case T: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 I:var b=x.render;return x=x.displayName,x||(x=b.displayName||b.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case R:return b=x.displayName||null,b!==null?b:B(x.type)||"Memo";case A:b=x._payload,x=x._init;try{return B(x(b))}catch{}}return null}r(B,"getComponentNameFromType");var U=Array.isArray,z=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K={pending:!1,data:null,method:null,action:null},H=[],se=-1;function Z(x){return{current:x}}r(Z,"createCursor");function ie(x){0>se||(x.current=H[se],H[se]=null,se--)}r(ie,"pop");function oe(x,b){se++,H[se]=x.current,x.current=b}r(oe,"push");var Y=Z(null),ne=Z(null),de=Z(null),ee=Z(null);function X(x,b){switch(oe(de,b),oe(ne,x),oe(Y,null),b.nodeType){case 9:case 11:x=(x=b.documentElement)&&(x=x.namespaceURI)?eG(x):0;break;default:if(x=b.tagName,b=b.namespaceURI)b=eG(b),x=tG(b,x);else switch(x){case"svg":x=1;break;case"math":x=2;break;default:x=0}}ie(Y),oe(Y,x)}r(X,"pushHostContainer");function Q(){ie(Y),ie(ne),ie(de)}r(Q,"popHostContainer");function fe(x){x.memoizedState!==null&&oe(ee,x);var b=Y.current,S=tG(b,x.type);b!==S&&(oe(ne,x),oe(Y,S))}r(fe,"pushHostContext");function te(x){ne.current===x&&(ie(Y),ie(ne)),ee.current===x&&(ie(ee),Ek._currentValue=K)}r(te,"popHostContext");var ae,le;function ce(x){if(ae===void 0)try{throw Error()}catch(S){var b=S.stack.trim().match(/\n( *(at )?)/);ae=b&&b[1]||"",le=-1<S.stack.indexOf(`
|
|
729
|
+
`)}z!==k&&(n.textContent=z,k=z)}r(T,"step");function R(){const E=d>0&&u>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(T))}r(R,"syncLoop");const A=new ResizeObserver(()=>{const E=Rde(n);h=E.w,p=E.h,N(),R()});A.observe(n);const L=r(()=>{i=document.visibilityState!=="hidden",R()},"onVisibilityChange");document.addEventListener("visibilitychange",L);const D=r(()=>{R()},"onMotionChange");a.addEventListener("change",D);const O=Rde(n);return h=O.w,p=O.h,N(),R(),()=>{o=!1,s.current!==null&&cancelAnimationFrame(s.current),A.disconnect(),document.removeEventListener("visibilitychange",L),a.removeEventListener("change",D)}},[]),(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(LQt,"AsciiArtAnimation");function DQt({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(DQt,"PaperclipLockup");function $Qt(){const e=Ut(),s=Xn(),[n]=Ei(),[a,i]=(0,m.useState)("sign_in"),[o,l]=(0,m.useState)(""),[c,d]=(0,m.useState)(""),[u,h]=(0,m.useState)(""),[p,f]=(0,m.useState)(null),g="auth-error",v=(0,m.useMemo)(()=>n.get("next")||EQt()||"/",[n]),{data:y,isLoading:w}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1});(0,m.useEffect)(()=>{y&&s(v,{replace:!0})},[y,s,v]);const k=Ne({mutationFn:r(async()=>{if(a==="sign_in"){await za.signInEmail({email:c.trim(),password:u});return}await za.signUpEmail({name:o.trim(),email:c.trim(),password:u})},"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&&u.trim().length>0&&(a==="sign_in"||o.trim().length>0&&u.trim().length>=8);return w?(0,t.jsx)("div",{className:"fixed inset-0 flex items-center justify-center",children:(0,t.jsx)(oh,{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)(yw,{})}),(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)(DQt,{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(),!k.isPending){if(!j){f("Please fill in all required fields.");return}k.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:u,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:k.isPending,"aria-disabled":!j||k.isPending,className:`w-full ${!j&&!k.isPending?"opacity-50":""}`,children:k.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)(LQt,{})})]})}r($Qt,"AuthPage");function OQt(){const e=Ut(),s=Ia(),[n]=Ei(),a=(s.token??"").trim(),i=(n.get("code")??"").trim(),o=(0,m.useMemo)(()=>`/board-claim/${encodeURIComponent(a)}${i?`?code=${encodeURIComponent(i)}`:""}`,[a,i]),l=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),c=J({queryKey:["board-claim",a,i],queryFn:r(()=>ur.getBoardClaimStatus(a,i),"queryFn"),enabled:a.length>0&&i.length>0,retry:!1}),d=Ne({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)(Js,{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 u=c.data;return u?u.status==="claimed"?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Js,{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)(Qe,{to:"/",children:"Open board"})})]})}):l.data?(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,t.jsxs)(Js,{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)(Js,{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)(Qe,{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(OQt,"BoardClaimPage");function FQt(){const e=Ut(),s=Ia(),[n]=Ei(),a=(s.id??"").trim(),i=(n.get("token")??"").trim(),o=(0,m.useMemo)(()=>`/cli-auth/${encodeURIComponent(a)}${i?`?token=${encodeURIComponent(i)}`:""}`,[a,i]),l=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),c=J({queryKey:["cli-auth-challenge",a,i],queryFn:r(()=>ur.getCliAuthChallenge(a,i),"queryFn"),enabled:a.length>0&&i.length>0,retry:!1}),d=Ne({mutationFn:r(()=>ur.approveCliAuthChallenge(a,i),"mutationFn"),onSuccess:r(async()=>{await e.invalidateQueries({queryKey:P.auth.session}),await c.refetch()},"onSuccess")}),u=Ne({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)(Js,{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)(Js,{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)(Js,{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)(Js,{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)(Qe,{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)(Js,{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||u.error)&&(0,t.jsx)("p",{className:"mt-4 text-sm text-destructive",children:(d.error??u.error)instanceof Error?(d.error??u.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||u.isPending,children:d.isPending?"Approving...":"Approve CLI access"}),(0,t.jsx)(F,{type:"button",variant:"outline",onClick:r(()=>u.mutate(),"onClick"),disabled:d.isPending||u.isPending,children:u.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(FQt,"CliAuthPage");var BQt=xTe.filter(e=>e!=="paperclip_runner"),Ede=new Set(["claude_local","codex_local","gemini_local","kimi_local","opencode_local","pi_local","cursor"]);function qQt(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(qQt,"readNestedString");var Ij="w-full border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-zinc-500",Pde="border border-zinc-800 bg-zinc-950/95 p-6",Mde="flex-1 border px-3 py-2 text-sm transition-colors";function zQt(e){return e?e.charAt(0).toUpperCase()+e.slice(1):null}r(zQt,"formatHumanRole");function UAe(e){if(!e||typeof e!="object")return null;const s=e.code;return typeof s=="string"&&s.trim().length>0?s:null}r(UAe,"getAuthErrorCode");function UQt(e){if(!(e instanceof Error))return null;const s=e.message.trim();return s.length>0?s:null}r(UQt,"getAuthErrorMessage");function KQt(e,s,n){const a=UAe(e),i=UQt(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(KQt,"mapInviteAuthFeedback");function Lde(e){return!!(e&&typeof e=="object"&&"bootstrapAccepted"in e)}r(Lde,"isBootstrapAcceptancePayload");function WQt(e,s){return!e||typeof e!="object"||s?!1:e.status==="approved"}r(WQt,"isApprovedHumanJoinPayload");function RU({companyDisplayName:e,companyLogoUrl:s,className:n}){return(0,t.jsx)(Qx,{companyName:e,logoUrl:s,logoFit:"contain",className:n})}r(RU,"InviteCompanyLogo");function Dde({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)(RU,{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(Dde,"AwaitingJoinApprovalPanel");function VQt(){const e=Ut(),s=Xn(),{setSelectedCompanyId:n}=ps(),a=(Ia().token??"").trim(),[i,o]=(0,m.useState)("sign_up"),[l,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(""),[h,p]=(0,m.useState)(""),[f,g]=(0,m.useState)(""),[v,y]=(0,m.useState)("claude_local"),[w,k]=(0,m.useState)(""),[j,N]=(0,m.useState)(null),[_,I]=(0,m.useState)(null),[C,T]=(0,m.useState)(null),[R,A]=(0,m.useState)(!1),L="invite-auth-error",D=J({queryKey:P.health,queryFn:r(()=>cm.get(),"queryFn"),retry:!1}),O=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),E=J({queryKey:P.access.invite(a),queryFn:r(()=>ur.getInvite(a),"queryFn"),enabled:a.length>0,retry:!1}),q=PU({enabled:!!O.data&&!!E.data?.companyId,staleTime:0}),B=D.data?.deploymentMode!=="local_trusted"?q.isFetchedAfterMount:!0,U=B?q.data?.companies??[]:[];(0,m.useEffect)(()=>{a&&Ade(a)},[a]),(0,m.useEffect)(()=>{A(!1)},[a]),(0,m.useEffect)(()=>{if(!B)return;const he=q.data?.companies;!he||!E.data?.companyId||he.some(ve=>ve.id===E.data.companyId)&&iT(a)},[q.data,E.data,B,a]);const z=E.data,$=!!O.data&&!!z?.companyId&&!B,K=!!z?.companyId&&U.some(he=>he.id===z?.companyId),H=z?.companyName?.trim()||"this Paperclip company",se=z?.companyLogoUrl?.trim()||null,Z=z?.invitedByUserName?.trim()||null,ie=z?.inviteMessage?.trim()||null,oe=zQt(z?.humanRole),Y=z?.joinRequestStatus??null,ne=z?.joinRequestType??null,de=ne==="human"&&(Y==="pending_approval"||Y==="approved"),ee=D.data?.deploymentMode==="authenticated"&&!O.data&&z?.allowedJoinTypes!=="agent",X=z?.inviteType!=="bootstrap_ceo"&&z?.allowedJoinTypes==="agent",Q=!!O.data&&!X&&z?.inviteType!=="bootstrap_ceo"&&(!Y||de)&&!$&&!K&&!j&&_===null,fe=O.data?.user.name?.trim()||O.data?.user.email?.trim()||"this account",te=d.trim().length>0&&h.trim().length>0&&(i==="sign_in"||l.trim().length>0&&h.trim().length>=8),ae=Ne({mutationFn:r(async()=>{if(!z)throw new Error("Invite not found");if($)throw new Error("Checking your organization access. Try again in a moment.");if(K)throw new Error("This account already belongs to the organization.");return z.inviteType==="bootstrap_ceo"||z.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 he=>{I(null),iT(a);const ve=Lde(he);N({kind:ve?"bootstrap":"join",payload:he}),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.access.currentBoardAccess}),await e.invalidateQueries({queryKey:P.companies.all}),z?.companyId&&WQt(he,X)&&(n(z.companyId,{source:"manual"}),s("/",{replace:!0}))},"onSuccess"),onError:r(he=>{I(he instanceof Error?he.message:"Failed to accept invite")},"onError")});(0,m.useEffect)(()=>{!Q||R||ae.isPending||(A(!0),I(null),ae.mutate())},[ae,R,Q]);const le=Ne({mutationFn:r(async()=>{if(i==="sign_in"){await za.signInEmail({email:d.trim(),password:h});return}await za.signUpEmail({name:l.trim(),email:d.trim(),password:h})},"mutationFn"),onSuccess:r(async()=>{T(null),Ade(a),await e.invalidateQueries({queryKey:P.auth.session}),await e.invalidateQueries({queryKey:P.health}),await e.invalidateQueries({queryKey:P.access.currentBoardAccess});const{companies:he}=await _Te(e);if(z?.companyId&&he.some(ve=>ve.id===z.companyId)){iT(a),n(z.companyId,{source:"manual"}),s("/",{replace:!0});return}if(!(!z||z.inviteType!=="bootstrap_ceo"))try{Lde(await ae.mutateAsync())&&s("/",{replace:!0})}catch{return}},"onSuccess"),onError:r(he=>{const ve=KQt(he,i,d);UAe(he)==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"&&(o("sign_in"),p("")),T(ve)},"onError")}),ce=(0,m.useMemo)(()=>z?K?"Open organization":z.inviteType==="bootstrap_ceo"?"Accept invite":X?"Submit request":O.data?"Accept invite":"Continue":"Continue",[z,K,O.data,X]);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||D.isLoading||O.isLoading)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Loading invite..."});if($)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||!z)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(Y==="approved"&&ne==="human"&&K)return(0,t.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-muted-foreground",children:"Opening organization..."});if(Y==="pending_approval"&&!de)return(0,t.jsx)(Dde,{companyDisplayName:H,companyLogoUrl:se,invitedByUserName:Z});if(Y&&!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:Y==="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)(Qe,{to:"/",children:"Open board"})})})]})});if(j?.kind==="join"){const he=j.payload,ve=typeof he.claimSecret=="string"?he.claimSecret:null,pe=typeof he.claimApiKeyPath=="string"?he.claimApiKeyPath:null,xe=qQt(he.onboarding,["textInstructions","url"]);return!X&&he.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)(RU,{companyDisplayName:H,companyLogoUrl:se,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)(Qe,{to:"/",children:"Open board"})})})]})}):(0,t.jsx)(Dde,{companyDisplayName:H,companyLogoUrl:se,invitedByUserName:Z,claimSecret:ve,claimApiKeyPath:pe,onboardingTextUrl:xe})}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:`${Pde} space-y-6`,children:[(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[(0,t.jsx)(RU,{companyDisplayName:H,companyLogoUrl:se,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:z.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:X?"Review the invite details, then submit the agent information below to start the join request.":ee?"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:Z??"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:X?"Agent join request":oe??"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:vu(z.expiresAt)})]})]}),ie?(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:ie})]}):null,O.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:`${Pde} h-fit`,children:X?(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:Ij,value:f,onChange:r(he=>g(he.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:Ij,value:v,onChange:r(he=>y(he.target.value),"onChange"),children:BQt.map(he=>(0,t.jsxs)("option",{value:he,disabled:!Ede.has(he),children:[kf(he),Ede.has(he)?"":" (Coming soon)"]},he))})]}),(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:Ij,rows:4,value:w,onChange:r(he=>k(he.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...":ce})]}):ee?(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:`${Mde} ${i==="sign_up"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:r(()=>{T(null),o("sign_up")},"onClick"),children:"Create account"}),(0,t.jsx)("button",{type:"button",className:`${Mde} ${i==="sign_in"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:r(()=>{T(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(he=>{if(he.preventDefault(),!le.isPending){if(!te){T({tone:"error",message:"Please fill in all required fields."});return}le.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:Ij,value:l,onChange:r(he=>{c(he.target.value),T(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:Ij,value:d,onChange:r(he=>{u(he.target.value),T(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:Ij,value:h,onChange:r(he=>{p(he.target.value),T(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:le.isPending,"aria-disabled":!te||le.isPending,children:le.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:K?"Already in this organization":Q?"Completing organization access":z.inviteType==="bootstrap_ceo"?"Accept bootstrap invite":"Accept organization invite"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:Q?`Granting your access to ${H}.`:K?`This account already belongs to ${H}.`:`This will ${z.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,Q?(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(K&&z.companyId){iT(a),n(z.companyId,{source:"manual"}),s("/",{replace:!0});return}ae.mutate()},"onClick"),children:ae.isPending?"Working...":ce})]})})]})})})}r(VQt,"InviteLandingPage");function HQt(){const{selectedCompany:e,selectedCompanyId:s}=ps(),{setBreadcrumbs:n}=Bn(),{pushToast:a}=Ai(),i=Ut(),[o,l]=(0,m.useState)("pending_approval"),[c,d]=(0,m.useState)("all");(0,m.useEffect)(()=>{n([{label:e?.name??"Organization",href:"/dashboard"},{label:"Inbox",href:"/inbox"},{label:"Join Requests"}])},[e?.name,n]);const u=J({queryKey:P.access.joinRequests(s??"",`${o}:${c}`),queryFn:r(()=>ur.listJoinRequests(s,o,c==="all"?void 0:c),"queryFn"),enabled:!!s}),h=Ne({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=Ne({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(u.isLoading)return(0,t.jsx)("div",{className:"text-sm text-muted-foreground",children:"Loading join requests…"});if(u.error){const f=u.error instanceof cn&&u.error.status===403?"You do not have permission to review join requests for this organization.":u.error instanceof Error?u.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)(bDe,{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)(Js,{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:(u.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."}):u.data.map(f=>(0,t.jsxs)(Js,{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)(ot,{variant:f.status==="pending_approval"?"secondary":f.status==="approved"?"outline":"destructive",children:f.status.replace("_"," ")}),(0,t.jsx)(ot,{variant:"outline",children:f.requestType}),f.adapterType?(0,t.jsx)(ot,{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(HQt,"JoinRequestQueue");var GQt=(0,m.lazy)(()=>Sc(()=>import("./CompanyExport-D292Sl0q.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]))),QQt=(0,m.lazy)(()=>Sc(()=>import("./Agents.production-CsT8F2HV.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]))),YQt=(0,m.lazy)(()=>Sc(()=>import("./Routines.production-CFwud8fp.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]))),$de=(0,m.lazy)(()=>Sc(()=>import("./RoutineDetail.production-D5NesMYZ.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]))),XQt=(0,m.lazy)(()=>Sc(()=>import("./CompanySkills.production-DsyMs6yM.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]))),JQt=(0,m.lazy)(()=>Sc(()=>import("./CompanyActivity.production-7Z8RokE5.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]))),ZQt=(0,m.lazy)(()=>Sc(()=>import("./Costs.production-DdMJsdPe.js").then(e=>({default:e.Costs})),__vite__mapDeps([58,5,7,28,29,13,12,44,41,50,27,51,24,25]))),eYt=(0,m.lazy)(()=>Sc(()=>import("./OrgChart.production-DdTAZv-5.js").then(e=>({default:e.OrgChart})),__vite__mapDeps([59,5,7,8,9,10,11,12,13,27,45,46,51,24,25])));function Rg({children:e}){return(0,t.jsx)(m.Suspense,{fallback:(0,t.jsx)(oh,{}),children:e})}r(Rg,"ProductionSurface");function tYt(e){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(it,{index:!0,element:(0,t.jsx)(bn,{to:"dashboard",replace:!0})}),(0,t.jsx)(it,{path:"dashboard",element:(0,t.jsx)(W0t,{})}),(0,t.jsx)(it,{path:"dashboard/live",element:(0,t.jsx)(V0t,{})}),(0,t.jsx)(it,{path:"timeline",element:e?(0,t.jsx)(Ep,{to:"/activity/timeline"}):(0,t.jsx)(QNe,{})}),(0,t.jsx)(it,{path:"onboarding",element:(0,t.jsx)(VAe,{})}),(0,t.jsx)(it,{path:"companies",element:(0,t.jsx)(Ebt,{})}),(0,t.jsx)(it,{path:"company/settings",element:(0,t.jsx)(z$t,{})}),(0,t.jsx)(it,{path:"company/settings/environments",element:(0,t.jsx)(bn,{to:"/company/settings/instance/environments",replace:!0})}),(0,t.jsx)(it,{path:"company/settings/cloud-upstream",element:(0,t.jsx)(bn,{to:"/company/export",replace:!0})}),(0,t.jsxs)(it,{element:(0,t.jsx)(yh,{pageKey:"company.members"}),children:[(0,t.jsx)(it,{path:"company/settings/members",element:(0,t.jsx)(dqt,{})}),(0,t.jsx)(it,{path:"company/settings/access",element:(0,t.jsx)(uqt,{})})]}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"company.invites"}),children:(0,t.jsx)(it,{path:"company/settings/invites",element:(0,t.jsx)(bn,{to:"/company/settings/members?tab=invites",replace:!0})})}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"company.export"}),children:(0,t.jsx)(it,{path:"company/export/*",element:(0,t.jsx)(m.Suspense,{fallback:(0,t.jsx)(oh,{}),children:(0,t.jsx)(GQt,{})})})}),(0,t.jsx)(it,{element:(0,t.jsx)(Nat,{}),children:(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"company.import"}),children:(0,t.jsx)(it,{path:"company/import",element:(0,t.jsx)(lGt,{})})})}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"company.secrets"}),children:(0,t.jsx)(it,{path:"company/settings/secrets",element:(0,t.jsx)(nHt,{})})}),(0,t.jsx)(it,{path:"company/settings/tools",element:(0,t.jsx)(Fde,{})}),(0,t.jsx)(it,{path:"company/settings/tools/:tab",element:(0,t.jsx)(Fde,{})}),(0,t.jsx)(it,{path:"tools",element:(0,t.jsx)(Bde,{})}),(0,t.jsx)(it,{path:"tools/:tab",element:(0,t.jsx)(Bde,{})}),(0,t.jsx)(it,{path:"apps",element:(0,t.jsx)(Gzt,{})}),(0,t.jsx)(it,{path:"apps/browse",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/connections",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/byo",element:(0,t.jsx)(pIe,{byoOnly:!0})}),(0,t.jsx)(it,{path:"apps/vercel-connect",element:(0,t.jsx)(Ode,{credentialSource:"vercel_connect"})}),(0,t.jsx)(it,{path:"apps/connect",element:(0,t.jsx)(Ode,{})}),(0,t.jsx)(it,{path:"apps/chat/connect",element:(0,t.jsx)(KO,{children:(0,t.jsx)(SUt,{})})}),(0,t.jsx)(it,{path:"apps/chat/:endpointId",element:(0,t.jsx)(KO,{children:(0,t.jsx)(bn,{to:"settings",replace:!0})})}),(0,t.jsx)(it,{path:"apps/chat/:endpointId/:tab",element:(0,t.jsx)(KO,{children:(0,t.jsx)(IKt,{})})}),(0,t.jsx)(it,{path:"apps/connect/:appKey",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/connect/:appKey/:stage",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/review",element:(0,t.jsx)(LKt,{})}),(0,t.jsx)(it,{path:"apps/attention",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/gateways",element:(0,t.jsx)(Gle,{})}),(0,t.jsx)(it,{path:"apps/gateways/:gatewayId",element:(0,t.jsx)(bn,{to:"overview",replace:!0})}),(0,t.jsx)(it,{path:"apps/gateways/:gatewayId/:tab",element:(0,t.jsx)(A8t,{})}),(0,t.jsx)(it,{path:"apps/advanced",element:(0,t.jsx)(Nle,{})}),(0,t.jsx)(it,{path:"apps/advanced/gateways",element:(0,t.jsx)(Gle,{})}),(0,t.jsx)(it,{path:"apps/advanced/profiles/new",element:(0,t.jsx)(Ile,{mode:"new"})}),(0,t.jsx)(it,{path:"apps/advanced/profiles/:profileId/edit",element:(0,t.jsx)(Ile,{mode:"edit"})}),(0,t.jsx)(it,{path:"apps/advanced/profiles/:profileId",element:(0,t.jsx)(Rzt,{})}),(0,t.jsx)(it,{path:"apps/advanced/audit",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/advanced/run-your-own",element:(0,t.jsx)(bn,{to:"/apps",replace:!0})}),(0,t.jsx)(it,{path:"apps/advanced/:tab",element:(0,t.jsx)(Nle,{})}),(0,t.jsx)(it,{path:"apps/app/:applicationId",element:(0,t.jsx)(Wle,{})}),(0,t.jsx)(it,{path:"apps/app/:applicationId/:tab",element:(0,t.jsx)(Wle,{})}),(0,t.jsx)(it,{path:"apps/:connectionId",element:(0,t.jsx)(bn,{to:"permissions",replace:!0})}),(0,t.jsx)(it,{path:"apps/:connectionId/:tab",element:(0,t.jsx)(UKt,{})}),(0,t.jsx)(it,{path:"company/settings/instance",element:(0,t.jsx)(bn,{to:"/company/settings",replace:!0})}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"instance.profile"}),children:(0,t.jsx)(it,{path:"company/settings/instance/profile",element:(0,t.jsx)(dQt,{})})}),(0,t.jsx)(it,{path:"company/settings/instance/general",element:(0,t.jsx)(bn,{to:"/company/settings",replace:!0})}),(0,t.jsx)(it,{path:"company/settings/instance/heartbeats",element:(0,t.jsx)(bn,{to:"/company/settings",replace:!0})}),(0,t.jsxs)(it,{element:(0,t.jsx)(yh,{pageKey:"instance.environments"}),children:[(0,t.jsx)(it,{path:"company/settings/instance/environments",element:(0,t.jsx)(EO,{})}),(0,t.jsx)(it,{path:"company/settings/instance/environments/new",element:(0,t.jsx)(EO,{mode:"create"})}),(0,t.jsx)(it,{path:"company/settings/instance/environments/:environmentId/edit",element:(0,t.jsx)(EO,{mode:"edit"})})]}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"instance.access"}),children:(0,t.jsx)(it,{path:"company/settings/instance/access",element:(0,t.jsx)(iQt,{})})}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"instance.experimental"}),children:(0,t.jsx)(it,{path:"company/settings/instance/experimental",element:(0,t.jsx)(aQt,{})})}),(0,t.jsxs)(it,{element:(0,t.jsx)(yh,{pageKey:"instance.plugins"}),children:[(0,t.jsx)(it,{path:"company/settings/instance/plugins",element:(0,t.jsx)(mQt,{})}),(0,t.jsx)(it,{path:"company/settings/instance/plugins/:pluginId",element:(0,t.jsx)(hQt,{})})]}),(0,t.jsx)(it,{element:(0,t.jsx)(yh,{pageKey:"instance.adapters"}),children:(0,t.jsx)(it,{path:"company/settings/instance/adapters",element:(0,t.jsx)(Sde,{})})}),(0,t.jsx)(it,{path:"company/settings/:settingsRoutePath/*",element:(0,t.jsx)(nqt,{})}),(0,t.jsx)(it,{path:"skills/studio",element:(0,t.jsx)(rF,{})}),(0,t.jsx)(it,{path:"skills/studio/new",element:(0,t.jsx)(rF,{})}),(0,t.jsx)(it,{path:"skills/studio/:skillId",element:(0,t.jsx)(rF,{})}),(0,t.jsx)(it,{path:"skills/:skillId/studio",element:(0,t.jsx)(KAe,{})}),(0,t.jsx)(it,{path:"skills/*",element:e?(0,t.jsx)(K7t,{}):(0,t.jsx)(Rg,{children:(0,t.jsx)(XQt,{})})}),(0,t.jsx)(it,{path:"settings",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"settings/*",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"plugins/:pluginId",element:(0,t.jsx)(Cde,{})}),(0,t.jsx)(it,{path:"org",element:e?(0,t.jsx)(bn,{to:"/agents/all",replace:!0}):(0,t.jsx)(Rg,{children:(0,t.jsx)(eYt,{})})}),(0,t.jsx)(it,{path:"agents",element:(0,t.jsx)(bn,{to:"/agents/all",replace:!0})}),f9.map(s=>(0,t.jsx)(it,{path:`agents/${s}`,element:e?(0,t.jsx)(avt,{}):(0,t.jsx)(Rg,{children:(0,t.jsx)(QQt,{})})},s)),(0,t.jsx)(it,{path:"agents/new",element:(0,t.jsx)(RQt,{})}),(0,t.jsx)(it,{path:"agents/:agentId",element:(0,t.jsx)(u$,{})}),(0,t.jsx)(it,{path:"agents/:agentId/:tab",element:(0,t.jsx)(u$,{})}),(0,t.jsx)(it,{path:"agents/:agentId/runs/:runId",element:(0,t.jsx)(u$,{})}),(0,t.jsx)(it,{path:"projects",element:(0,t.jsx)(gwt,{})}),(0,t.jsx)(it,{path:"projects/:projectId",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{path:"projects/:projectId/overview",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{path:"projects/:projectId/issues",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{path:"projects/:projectId/issues/:filter",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{element:(0,t.jsx)(fD,{}),children:(0,t.jsx)(it,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,t.jsx)(mkt,{})})}),(0,t.jsx)(it,{path:"projects/:projectId/workspaces",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{path:"projects/:projectId/configuration",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{path:"projects/:projectId/budget",element:(0,t.jsx)(lb,{})}),(0,t.jsx)(it,{element:(0,t.jsx)(fD,{}),children:(0,t.jsx)(it,{path:"workspaces",element:(0,t.jsx)(fkt,{})})}),(0,t.jsx)(it,{path:"issues",element:(0,t.jsx)(Nkt,{})}),(0,t.jsx)(it,{path:"tasks",element:(0,t.jsx)(bn,{to:"/issues",replace:!0})}),(0,t.jsx)(it,{path:"search",element:(0,t.jsx)(Qkt,{})}),(0,t.jsx)(it,{path:"issues/all",element:(0,t.jsx)(bn,{to:"/issues",replace:!0})}),(0,t.jsx)(it,{path:"issues/active",element:(0,t.jsx)(bn,{to:"/issues",replace:!0})}),(0,t.jsx)(it,{path:"issues/backlog",element:(0,t.jsx)(bn,{to:"/issues",replace:!0})}),(0,t.jsx)(it,{path:"issues/done",element:(0,t.jsx)(bn,{to:"/issues",replace:!0})}),(0,t.jsx)(it,{path:"issues/recent",element:(0,t.jsx)(bn,{to:"/issues",replace:!0})}),(0,t.jsx)(it,{path:"chats/:agentRef",element:(0,t.jsx)(gIt,{})}),(0,t.jsx)(it,{path:"issues/:issueId",element:(0,t.jsx)(fIt,{})}),null,(0,t.jsx)(it,{path:"routines",element:e?(0,t.jsx)(YIt,{}):(0,t.jsx)(Rg,{children:(0,t.jsx)(YQt,{})})}),(0,t.jsx)(it,{path:"cases",element:(0,t.jsx)(tee,{children:(0,t.jsx)(Uat,{})})}),(0,t.jsx)(it,{path:"cases/:caseIdentifier",element:(0,t.jsx)(tee,{children:(0,t.jsx)(Clt,{})})}),(0,t.jsx)(it,{path:"pixels-office",element:(0,t.jsx)(wat,{children:(0,t.jsx)(_Pt,{})})}),(0,t.jsx)(it,{path:"status",element:(0,t.jsx)(see,{children:(0,t.jsx)(mae,{})})}),(0,t.jsx)(it,{path:"status/:cardId",element:(0,t.jsx)(see,{children:(0,t.jsx)(mae,{})})}),(0,t.jsx)(it,{path:"status-cards",element:(0,t.jsx)(qde,{})}),(0,t.jsx)(it,{path:"status-cards/:cardId",element:(0,t.jsx)(qde,{})}),(0,t.jsx)(it,{path:"review-queue",element:(0,t.jsx)(yg,{children:(0,t.jsx)(pTt,{})})}),(0,t.jsx)(it,{path:"learnings",element:(0,t.jsx)(yg,{children:(0,t.jsx)(xTt,{})})}),(0,t.jsx)(it,{path:"pipelines",element:(0,t.jsx)(yg,{children:(0,t.jsx)(V$,{})})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId",element:(0,t.jsx)(yg,{children:(0,t.jsx)(V$,{})})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/add",element:(0,t.jsx)(yg,{children:(0,t.jsx)(V$,{})})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/settings",element:(0,t.jsx)(yg,{children:(0,t.jsx)(cRt,{})})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/items/:caseId",element:(0,t.jsx)(yg,{children:(0,t.jsx)(M2t,{})})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,t.jsx)(yg,{children:(0,t.jsx)(R2t,{})})}),(0,t.jsx)(it,{path:"routines/:routineId",element:e?(0,t.jsx)(pie,{}):(0,t.jsx)(Rg,{children:(0,t.jsx)($de,{})})}),(0,t.jsx)(it,{path:"routines/:routineId/:section",element:e?(0,t.jsx)(pie,{}):(0,t.jsx)(Rg,{children:(0,t.jsx)($de,{})})}),(0,t.jsx)(it,{element:(0,t.jsx)(fD,{}),children:(0,t.jsxs)(it,{element:(0,t.jsx)(Sat,{}),children:[(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId",element:(0,t.jsx)(wj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/services",element:(0,t.jsx)(wj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/configuration",element:(0,t.jsx)(wj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,t.jsx)(wj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/issues",element:(0,t.jsx)(wj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/routines",element:(0,t.jsx)(wj,{})})]})}),(0,t.jsx)(it,{path:"goals",element:(0,t.jsx)(w4t,{})}),(0,t.jsx)(it,{path:"goals/:goalId",element:(0,t.jsx)(D4t,{})}),(0,t.jsx)(it,{path:"artifacts",element:(0,t.jsx)(bie,{})}),(0,t.jsx)(it,{path:"approvals",element:(0,t.jsx)(bn,{to:"/approvals/pending",replace:!0})}),(0,t.jsx)(it,{path:"approvals/pending",element:(0,t.jsx)(yie,{})}),(0,t.jsx)(it,{path:"approvals/all",element:(0,t.jsx)(yie,{})}),(0,t.jsx)(it,{path:"approvals/:approvalId",element:(0,t.jsx)($4t,{})}),(0,t.jsx)(it,{path:"activity",element:e?(0,t.jsx)(kLt,{}):(0,t.jsx)(Rg,{children:(0,t.jsx)(JQt,{})})}),e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(it,{path:"activity/runs",element:(0,t.jsx)(US,{section:"runs"})}),(0,t.jsx)(it,{path:"activity/costs",element:(0,t.jsx)(US,{section:"costs"})}),(0,t.jsx)(it,{path:"activity/budgets",element:(0,t.jsx)(US,{section:"budgets"})}),(0,t.jsx)(it,{path:"activity/timeline",element:(0,t.jsx)(US,{section:"timeline"})}),(0,t.jsx)(it,{path:"audit",element:(0,t.jsx)(Ep,{to:"/activity",forceAgentMode:!0})}),(0,t.jsx)(it,{path:"audit/activity",element:(0,t.jsx)(Ep,{to:"/activity"})}),(0,t.jsx)(it,{path:"audit/runs",element:(0,t.jsx)(Ep,{to:"/activity/runs"})}),(0,t.jsx)(it,{path:"audit/costs",element:(0,t.jsx)(Ep,{to:"/activity/costs"})}),(0,t.jsx)(it,{path:"audit/budgets",element:(0,t.jsx)(Ep,{to:"/activity/budgets"})}),(0,t.jsx)(it,{path:"audit/timeline",element:(0,t.jsx)(Ep,{to:"/activity/timeline"})}),(0,t.jsx)(it,{path:"runs",element:(0,t.jsx)(Ep,{to:"/activity/runs"})}),(0,t.jsx)(it,{path:"costs",element:(0,t.jsx)(Ep,{to:"/activity/costs"})}),(0,t.jsx)(it,{path:"budgets",element:(0,t.jsx)(Ep,{to:"/activity/budgets"})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(it,{path:"costs",element:(0,t.jsx)(Rg,{children:(0,t.jsx)(ZQt,{})})}),(0,t.jsx)(it,{path:"audit",element:(0,t.jsx)(bn,{to:"/activity?mode=agents",replace:!0})})]}),(0,t.jsxs)(it,{element:(0,t.jsx)(cst,{}),children:[(0,t.jsx)(it,{path:"board-chat",element:(0,t.jsx)(A$t,{})}),(0,t.jsx)(it,{path:"artifacts",element:(0,t.jsx)(bie,{})})]}),null,(0,t.jsx)(it,{path:"decisions",element:(0,t.jsx)(e$t,{})}),(0,t.jsx)(it,{path:"decisions/queues/:key",element:(0,t.jsx)(r$t,{})}),(0,t.jsx)(it,{path:"inbox",element:(0,t.jsx)(sYt,{})}),(0,t.jsx)(it,{path:"inbox/mine",element:(0,t.jsx)(uS,{})}),(0,t.jsx)(it,{path:"inbox/recent",element:(0,t.jsx)(uS,{})}),(0,t.jsx)(it,{path:"inbox/unread",element:(0,t.jsx)(uS,{})}),(0,t.jsx)(it,{path:"inbox/blocked",element:(0,t.jsx)(uS,{})}),(0,t.jsx)(it,{path:"inbox/all",element:(0,t.jsx)(uS,{})}),(0,t.jsx)(it,{path:"inbox/requests",element:(0,t.jsx)(HQt,{})}),(0,t.jsx)(it,{path:"inbox/new",element:(0,t.jsx)(bn,{to:"/inbox/mine",replace:!0})}),(0,t.jsx)(it,{path:"u/:userSlug",element:(0,t.jsx)(YMt,{})}),(0,t.jsx)(it,{path:"design-guide",element:(0,t.jsx)(sQt,{})}),(0,t.jsx)(it,{path:"instance/settings/adapters",element:(0,t.jsx)(Sde,{})}),(0,t.jsx)(it,{path:":pluginRoutePath/*",element:(0,t.jsx)(Cde,{})}),(0,t.jsx)(it,{path:"*",element:(0,t.jsx)(ju,{scope:"board"})})]})}r(tYt,"boardRoutes");function Ode({credentialSource:e="paperclip_vault"}={}){const s=ra(),n=new URLSearchParams(s.search),{enabled:a}=Yx();return yZe(n,{chatConnectorsEnabled:a})?(0,t.jsx)(pIe,{credentialSource:e}):(0,t.jsx)(bn,{to:"/apps",replace:!0})}r(Ode,"AppsConnectEntryRoute");function sYt(){return(0,t.jsx)(bn,{to:`/inbox/${D5e()}`,replace:!0})}r(sYt,"InboxRootRedirect");function KAe(){const e=ra(),{companies:s,selectedCompany:n,loading:a}=ps(),{companyPrefix:i,skillId:o}=Ia();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)(bn,{to:"/skills/studio",replace:!0}):(0,t.jsx)(bn,{to:`/${l.issuePrefix}/skills/studio/${encodeURIComponent(o)}${e.search}${e.hash}`,replace:!0})}r(KAe,"LegacySkillStudioRedirect");function qb(){const e=ra(),{companies:s,selectedCompany:n,loading:a}=ps(),{companyPrefix:i}=Ia(),{hidden:o}=uh();if(a)return(0,t.jsx)(oh,{});const l=(i?s.find(d=>d.issuePrefix.toUpperCase()===i.toUpperCase()):null)??n??s[0]??null;if(!l)return s7({pathname:e.pathname,hasCompanies:!1})?(0,t.jsx)(bn,{to:"/onboarding",replace:!0}):(0,t.jsx)(GW,{});const c=aBe(dpe(`${e.pathname}${e.search}${e.hash}`),o);return(0,t.jsx)(bn,{to:`/${l.issuePrefix}${c}`,replace:!0})}r(qb,"LegacySettingsRedirect");function Fde(){const{tab:e}=Ia();return(0,t.jsx)(bn,{to:WAe(e),replace:!0})}r(Fde,"LegacyToolsSettingsRedirect");function Bde(){const{tab:e}=Ia();return(0,t.jsx)(bn,{to:WAe(e),replace:!0})}r(Bde,"LegacyToolsRedirect");function WAe(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(WAe,"legacyToolsRedirectTarget");function VAe(){const{companies:e}=ps(),{openOnboarding:s}=zo(),{t:n}=Ohe(),a=td(),i=U3(a?.cloudBaseUrl??null),{onboardingOpen:o,onboardingRouteDismissed:l}=_3(),{companyPrefix:c}=Ia(),d=c?e.find(p=>p.issuePrefix.toUpperCase()===c.toUpperCase())??null:null;if(Cet({onboardingOpen:o,routeDismissed:l}))return null;const u=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:u}),(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:U5(),companyId:d.id}):a&&i?Ac(i):s(),"onClick"),children:d?"Add Agent":"Start Onboarding"})})]})})}r(VAe,"OnboardingRoutePage");function nYt(){const{companies:e,selectedCompany:s,loading:n}=ps(),a=ra();if(n)return(0,t.jsx)(oh,{});const i=s??e[0]??null;return i?(0,t.jsx)(bn,{to:`/${i.issuePrefix}/dashboard`,replace:!0}):s7({pathname:a.pathname,hasCompanies:!1})?(0,t.jsx)(bn,{to:"/onboarding",replace:!0}):(0,t.jsx)(GW,{})}r(nYt,"CompanyRootRedirect");function qde(){const{cardId:e}=Ia(),s=KRe(),n=s?`/${s}`:"";return(0,t.jsx)(bn,{to:`${n}/status${e?`/${e}`:""}`,replace:!0})}r(qde,"StatusCardsLegacyRedirect");function Ep({to:e,forceAgentMode:s=!1}){const n=ra(),a=new URLSearchParams(n.search);s&&a.set("mode","agents");const i=a.toString();return(0,t.jsx)(bn,{to:`${e}${i?`?${i}`:""}${n.hash}`,replace:!0})}r(Ep,"AuditCompatibilityRedirect");function ga(){const e=ra(),{companies:s,selectedCompany:n,loading:a}=ps();if(a)return(0,t.jsx)(oh,{});const i=n??s[0]??null;return i?(0,t.jsx)(bn,{to:`/${i.issuePrefix}${e.pathname}${e.search}${e.hash}`,replace:!0}):s7({pathname:e.pathname,hasCompanies:!1})?(0,t.jsx)(bn,{to:"/onboarding",replace:!0}):(0,t.jsx)(GW,{})}r(ga,"UnprefixedBoardRedirect");function GW(){const{openOnboarding:e}=zo(),{t:s}=Ohe(),n=td(),a=U3(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?Ac(a):e(),"onClick"),children:s("app.noCompanies.newCompany",{defaultValue:"New Organization"})})})]})})}r(GW,"NoCompaniesStartPage");function rYt(){const{enabled:e,loaded:s}=Tc();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(HRe,{children:[(0,t.jsx)(it,{path:"oauth-handoff",element:(0,t.jsx)(o8t,{})}),(0,t.jsx)(it,{path:"auth",element:(0,t.jsx)($Qt,{})}),(0,t.jsx)(it,{path:"board-claim/:token",element:(0,t.jsx)(OQt,{})}),(0,t.jsx)(it,{path:"cli-auth/:id",element:(0,t.jsx)(FQt,{})}),(0,t.jsx)(it,{path:"invite/:token",element:(0,t.jsx)(VQt,{})}),(0,t.jsx)(it,{element:s?(0,t.jsx)(Qee,{allowMembershipRequest:!0}):(0,t.jsx)(oh,{}),children:(0,t.jsx)(it,{path:"chat-identity/confirm",element:(0,t.jsx)(PKt,{})})}),(0,t.jsx)(it,{path:"tests/perf/long-thread",element:(0,t.jsx)(IIt,{})}),(0,t.jsx)(it,{path:"ux-lab/bootstrap-setup",element:(0,t.jsx)(Z6t,{})}),(0,t.jsx)(it,{path:"ux-lab/responsible-user-denial",element:(0,t.jsx)(eqt,{})}),(0,t.jsx)(it,{path:"ux-lab/cross-issue-collaboration",element:(0,t.jsx)(sqt,{})}),(0,t.jsxs)(it,{element:s?(0,t.jsx)(Qee,{}):(0,t.jsx)(oh,{}),children:[(0,t.jsx)(it,{index:!0,element:(0,t.jsx)(nYt,{})}),(0,t.jsx)(it,{path:"onboarding",element:(0,t.jsx)(VAe,{})}),(0,t.jsx)(it,{path:"instance",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"instance/settings",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"instance/settings/*",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"companies",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"dashboard",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"inbox/*",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"issues",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"tasks",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"issues/:issueId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"routines",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"routines/:routineId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"review-queue",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"learnings",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"cases",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"cases/:caseIdentifier",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pixels-office",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"status",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"status/:cardId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"status-cards",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"status-cards/:cardId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pipelines",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/add",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/settings",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/items/:caseId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"artifacts",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"audit",element:(0,t.jsx)(ga,{})}),e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(it,{path:"audit/*",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"activity",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"activity/*",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"runs",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"costs",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"budgets",element:(0,t.jsx)(ga,{})})]}):null,(0,t.jsx)(it,{path:"decisions",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"u/:userSlug",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"skills/studio",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"skills/studio/new",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"skills/studio/:skillId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"skills/:skillId/studio",element:(0,t.jsx)(KAe,{})}),(0,t.jsx)(it,{path:"skills/*",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"settings",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"settings/*",element:(0,t.jsx)(qb,{})}),(0,t.jsx)(it,{path:"agents",element:(0,t.jsx)(ga,{})}),f9.map(n=>(0,t.jsx)(it,{path:`agents/${n}`,element:(0,t.jsx)(ga,{})},n)),(0,t.jsx)(it,{path:"agents/new",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"agents/:agentId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"agents/:agentId/:tab",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"agents/:agentId/runs/:runId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId/overview",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId/issues",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId/issues/:filter",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId/workspaces",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"projects/:projectId/configuration",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"workspaces",element:(0,t.jsx)(ga,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId",element:(0,t.jsx)(sj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/services",element:(0,t.jsx)(sj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/configuration",element:(0,t.jsx)(sj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,t.jsx)(sj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/issues",element:(0,t.jsx)(sj,{})}),(0,t.jsx)(it,{path:"execution-workspaces/:workspaceId/routines",element:(0,t.jsx)(sj,{})}),(0,t.jsx)(it,{path:":companyPrefix",element:e?(0,t.jsx)(Ctt,{}):(0,t.jsx)(ist,{}),children:tYt(e)}),(0,t.jsx)(it,{path:"*",element:(0,t.jsx)(ju,{scope:"global"})})]})]}),(0,t.jsx)(tct,{}),(0,t.jsx)(rtt,{})]})}r(rYt,"App");var aYt=class extends m.Component{static{r(this,"AppErrorBoundary")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,s){Ebe(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 iYt(){const{data:e}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),retry:!1}),s=e?.sentryDsn,n=e?.sentryEnvironment??void 0;return(0,m.useEffect)(()=>{if(s)return Ket(s,n),()=>{Wet()}},[s,n]),null}r(iYt,"SentryGate");function oYt(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(oYt,"managedRoutineToRow");function lYt({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:u,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=oYt(y),k=y.href??(y.routineId?`/routines/${y.routineId}`:"/routines"),j=y.missingRefs??[],N=!!(y.routineId&&y.resourceKey&&j.length===0),_=y.managedByPluginDisplayName??a,I=!!(p||f);return(0,t.jsxs)("div",{className:"last:[&_a]:border-b-0",children:[(0,t.jsx)(QSe,{routine:w,projectById:v,agentById:g,runningRoutineId:o,statusMutationRoutineId:l,href:k,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(()=>u?.(y),"onRunNow"),onToggleEnabled:r(()=>h?.(y,w.status==="active"),"onToggleEnabled")}),I?(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(lYt,"ManagedRoutinesList");function zde(e){return new Set(e??[])}r(zde,"toPathSet");function cYt({expandedPaths:e,checkedPaths:s,selectedFile:n=null,showCheckboxes:a=!1,onToggleDir:i,onSelectFile:o,...l}){return(0,m.createElement)(G_,{...l,selectedFile:n,expandedDirs:zde(e),checkedFiles:s?zde(s):void 0,showCheckboxes:a,onToggleDir:i??(()=>{}),onSelectFile:o??(()=>{})})}r(cYt,"PluginSdkFileTree");function dYt(e){const[s,n]=(0,m.useState)(null);return(0,m.useEffect)(()=>{let a=!1;return Sc(()=>import("./MarkdownEditor-BXxDMPIh.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,m.createElement)(s,e):(0,m.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(dYt,"PluginSdkMarkdownEditor");function uYt(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!=null&&s!==""&&s!==!1))}r(uYt,"compactIssueFilters");function mYt({companyId:e,projectId:s=null,filters:n,viewStateKey:a="paperclip:plugin-issues-view",initialSearch:i,createIssueLabel:o,searchWithinLoadedIssues:l=!0}){const c=Ut(),d=(0,m.useMemo)(()=>uYt({...n??{},projectId:n?.projectId??s??void 0}),[n,s]),u=d.originKindPrefix??null,h=d.projectId??s??null,p=(0,m.useMemo)(()=>["plugins","sdk-ui","issues-list",e??"__no-company__",d],[e,d]),{data:f}=J({queryKey:P.agents.list(e??"__no-company__"),queryFn:r(()=>Vt.list(e),"queryFn"),enabled:!!e}),{data:g}=J({queryKey:P.projects.list(e??"__no-company__",{includeArchived:!0}),queryFn:r(()=>pa.list(e,{includeArchived:!0}),"queryFn"),enabled:!!e}),v=P.liveRuns(e??"__no-company__"),y=fo({companyId:e,resourceKey:"live-runs",queryKey:v,enabled:!!e,refetchInterval:!1,leaderOnly:!0}),{data:w,dataUpdatedAt:k}=J({queryKey:v,queryFn:r(()=>Yr.liveRunsForCompany(e),"queryFn"),enabled:y.enabled,refetchInterval:y.refetchInterval});xo(y,w,k);const{data:j,isLoading:N,error:_}=J({queryKey:p,queryFn:r(()=>_t.list(e,d),"queryFn"),enabled:!!e}),I=(0,m.useMemo)(()=>Kx(w,j),[j,w]),C=Ne({mutationFn:r(({id:T,data:R})=>_t.update(T,R),"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)}),u&&c.invalidateQueries({queryKey:P.issues.listPluginOperationsByProject(e,h,u)})))},"onSuccess")});return e?(0,m.createElement)(Px,{issues:j??[],isLoading:N,error:_,agents:f,projects:g,liveIssueIds:I,projectId:h??void 0,viewStateKey:a,initialSearch:i,createIssueLabel:o,searchWithinLoadedIssues:l,onUpdateIssue:r((T,R)=>C.mutate({id:T,data:R}),"onUpdateIssue")}):(0,m.createElement)("div",{className:"text-sm text-muted-foreground"},"Select an organization to view tasks.")}r(mYt,"PluginSdkIssuesList");function hYt({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:u,onConfirm:h}){const p=RK(),f=e??p.companyId??null,{data:g}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn"),enabled:c}),v=g?.user?.id??g?.session?.userId??null,{data:y}=J({queryKey:P.agents.list(f??"__no-company__"),queryFn:r(()=>Vt.list(f),"queryFn"),enabled:!!f}),{data:w}=J({queryKey:P.access.companyUserDirectory(f??"__no-company__"),queryFn:r(()=>ur.listUserDirectory(f),"queryFn"),enabled:!!f&&c}),k=(0,m.useMemo)(()=>x5e(),[]),j=(0,m.useMemo)(()=>k.map(T=>T.startsWith("agent:")?T.slice(6):null).filter(T=>!!T),[k]),N=(0,m.useMemo)(()=>u0((y??[]).filter(T=>d||T.status!=="terminated"),j),[y,d,j]),_=(0,m.useMemo)(()=>[...c?tme(v):[],...c?ON(w?.users,{excludeUserIds:[v]}):[],...N.map(T=>({id:Um({assigneeAgentId:T.id}),label:T.name,searchText:`${T.name} ${T.role} ${T.title??""}`}))],[w?.users,v,c,N]),I=zc(s),C=I.assigneeAgentId?N.find(T=>T.id===I.assigneeAgentId):null;return(0,m.createElement)(oc,{value:s,options:_,recentOptionIds:k,placeholder:a,noneLabel:i,searchPlaceholder:o,emptyMessage:l,className:u,onConfirm:h,onChange:r(T=>{const R=zc(T);R.assigneeAgentId&&t_(R.assigneeAgentId),R.assigneeUserId&&Due(R.assigneeUserId),n(T,R)},"onChange"),renderTriggerValue:r(T=>T?C?(0,m.createElement)(i3,null,(0,m.createElement)(Yw,{icon:C.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,m.createElement)("span",{className:"truncate"},T.label)):(0,m.createElement)("span",{className:"truncate"},T.label):(0,m.createElement)("span",{className:"text-muted-foreground"},a),"renderTriggerValue"),renderOption:r(T=>{if(!T.id)return(0,m.createElement)("span",{className:"truncate"},T.label);const R=zc(T.id),A=R.assigneeAgentId?N.find(L=>L.id===R.assigneeAgentId):null;return(0,m.createElement)(i3,null,A?(0,m.createElement)(Yw,{icon:A.icon,className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,m.createElement)(kc,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,m.createElement)("span",{className:"truncate"},T.label))},"renderOption")})}r(hYt,"PluginSdkAssigneePicker");function pYt({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:u}){const h=RK(),p=e??h.companyId??null,{data:f}=J({queryKey:P.auth.session,queryFn:r(()=>za.getSession(),"queryFn")}),g=f?.user?.id??f?.session?.userId??null,{data:v}=J({queryKey:P.projects.list(p??"__no-company__",{includeArchived:c}),queryFn:r(()=>pa.list(p,{includeArchived:c}),"queryFn"),enabled:!!p}),y=(0,m.useMemo)(()=>(v??[]).filter(_=>c||!_.archivedAt),[c,v]),{orderedProjects:w}=ay({projects:y,companyId:p,userId:g}),k=(0,m.useMemo)(()=>LN(),[]),j=(0,m.useMemo)(()=>w.map(_=>({id:_.id,label:_.name,searchText:_.description??""})),[w]),N=w.find(_=>_.id===s)??null;return(0,m.createElement)(oc,{value:s,options:j,recentOptionIds:k,placeholder:a,noneLabel:i,searchPlaceholder:o,emptyMessage:l,className:d,onConfirm:u,onChange:r(_=>{_&&EN(_),n(_)},"onChange"),renderTriggerValue:r(_=>!_||!N?(0,m.createElement)("span",{className:"text-muted-foreground"},a):(0,m.createElement)(i3,null,(0,m.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:N.color??"#6366f1"}}),(0,m.createElement)("span",{className:"truncate"},_.label)),"renderTriggerValue"),renderOption:r(_=>{if(!_.id)return(0,m.createElement)("span",{className:"truncate"},_.label);const I=w.find(C=>C.id===_.id);return(0,m.createElement)(i3,null,(0,m.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:I?.color??"#6366f1"}}),(0,m.createElement)("span",{className:"truncate"},_.label))},"renderOption")})}r(pYt,"PluginSdkProjectPicker");function i3({children:e}){return(0,m.createElement)("span",{className:"contents"},e)}r(i3,"FragmentSafe");function fYt({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,m.createElement)("span",{className:`inline-flex w-fit items-center rounded-full border px-2 py-0.5 text-xs font-medium ${n}`},e)}r(fYt,"PluginSdkStatusBadge");function xYt({columns:e,rows:s,loading:n,emptyMessage:a="No rows."}){if(n)return(0,m.createElement)("div",{className:"text-sm text-muted-foreground"},"Loading...");if(!s.length)return(0,m.createElement)("div",{className:"text-sm text-muted-foreground"},a);const i=e.map(o=>o.width??"minmax(0, 1fr)").join(" ");return(0,m.createElement)("div",{className:"overflow-hidden rounded-md border"},(0,m.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,m.createElement)("div",{key:o.key},o.header))),(0,m.createElement)("div",{className:"divide-y"},s.map((o,l)=>(0,m.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,m.createElement)("div",{key:c.key,className:"min-w-0 text-sm"},(0,m.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(xYt,"PluginSdkDataTable");function gYt({pairs:e}){return(0,m.createElement)("dl",{className:"grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[max-content_minmax(0,1fr)]"},e.flatMap(s=>[(0,m.createElement)("dt",{key:`${s.label}:label`,className:"text-muted-foreground"},s.label),(0,m.createElement)("dd",{key:`${s.label}:value`,className:"min-w-0"},s.value)]))}r(gYt,"PluginSdkKeyValueList");function bYt({label:e,value:s,unit:n}){return(0,m.createElement)("div",{className:"rounded-md border bg-card p-3"},(0,m.createElement)("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground"},e),(0,m.createElement)("div",{className:"mt-1 text-lg font-semibold"},`${s}${n??""}`))}r(bYt,"PluginSdkMetricCard");function vYt({data:e}){return(0,m.createElement)("pre",{className:"max-h-80 overflow-auto rounded-md border bg-muted/30 p-2 text-xs"},JSON.stringify(e,null,2))}r(vYt,"PluginSdkJsonTree");function yYt({label:e="Loading"}){return(0,m.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(yYt,"PluginSdkSpinner");var jYt=class extends m.Component{static{r(this,"PluginSdkErrorBoundary")}state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??(0,m.createElement)("div",{className:"rounded-md border border-destructive/30 p-3 text-sm text-destructive"},"Plugin UI failed to render."):this.props.children}};function wYt(e,s){globalThis.__paperclipPluginBridge__={react:e,reactJsxRuntime:t,reactDom:s,sdkUi:{usePluginData:pBe,usePluginAction:fBe,useHostContext:RK,useHostLocation:gBe,useHostNavigation:xBe,usePluginStream:vBe,usePluginToast:bBe,copyTextToClipboard:Xr,MarkdownBlock:r(({content:n,className:a,enableWikiLinks:i,wikiLinkRoot:o,resolveWikiLinkHref:l})=>(0,m.createElement)($n,{className:a,softBreaks:!1,enableWikiLinks:i,wikiLinkRoot:o,resolveWikiLinkHref:l,children:n}),"MarkdownBlock"),MetricCard:bYt,StatusBadge:fYt,DataTable:xYt,KeyValueList:gYt,JsonTree:vYt,Spinner:yYt,ErrorBoundary:jYt,MarkdownEditor:dYt,FileTree:cYt,IssuesList:mYt,AssigneePicker:hYt,ProjectPicker:pYt,ManagedRoutinesList:lYt}}}r(wYt,"initPluginBridge");var NYt=1e4;function kYt(e=NYt){if(typeof performance>"u"||typeof performance.clearMeasures!="function")return()=>{};const n=setInterval(r(()=>{globalThis.__paperclipKeepPerfMeasures||performance.clearMeasures()},"reap"),e);return()=>clearInterval(n)}r(kYt,"startPerfMeasureReaper");var SYt=Gv((e=>{function s(U,z){var $=U.length;U.push(z);e:for(;0<$;){var K=$-1>>>1,H=U[K];if(0<i(H,z))U[K]=z,U[$]=H,$=K;else break e}}r(s,"push");function n(U){return U.length===0?null:U[0]}r(n,"peek");function a(U){if(U.length===0)return null;var z=U[0],$=U.pop();if($!==z){U[0]=$;e:for(var K=0,H=U.length,se=H>>>1;K<se;){var Z=2*(K+1)-1,ie=U[Z],oe=Z+1,Y=U[oe];if(0>i(ie,$))oe<H&&0>i(Y,ie)?(U[K]=Y,U[oe]=$,K=oe):(U[K]=ie,U[Z]=$,K=Z);else if(oe<H&&0>i(Y,$))U[K]=Y,U[oe]=$,K=oe;else break e}}return z}r(a,"pop");function i(U,z){var $=U.sortIndex-z.sortIndex;return $!==0?$:U.id-z.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=[],u=[],h=1,p=null,f=3,g=!1,v=!1,y=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function _(U){for(var z=n(u);z!==null;){if(z.callback===null)a(u);else if(z.startTime<=U)a(u),z.sortIndex=z.expirationTime,s(d,z);else break;z=n(u)}}r(_,"advanceTimers");function I(U){if(y=!1,_(U),!v)if(n(d)!==null)v=!0,C||(C=!0,O());else{var z=n(u);z!==null&&B(I,z.startTime-U)}}r(I,"handleTimeout");var C=!1,T=-1,R=5,A=-1;function L(){return w?!0:!(e.unstable_now()-A<R)}r(L,"shouldYieldToHost");function D(){if(w=!1,C){var U=e.unstable_now();A=U;var z=!0;try{e:{v=!1,y&&(y=!1,j(T),T=-1),g=!0;var $=f;try{t:{for(_(U),p=n(d);p!==null&&!(p.expirationTime>U&&L());){var K=p.callback;if(typeof K=="function"){p.callback=null,f=p.priorityLevel;var H=K(p.expirationTime<=U);if(U=e.unstable_now(),typeof H=="function"){p.callback=H,_(U),z=!0;break t}p===n(d)&&a(d),_(U)}else a(d);p=n(d)}if(p!==null)z=!0;else{var se=n(u);se!==null&&B(I,se.startTime-U),z=!1}}break e}finally{p=null,f=$,g=!1}z=void 0}}finally{z?O():C=!1}}}r(D,"performWorkUntilDeadline");var O;if(typeof N=="function")O=r(function(){N(D)},"schedulePerformWorkUntilDeadline");else if(typeof MessageChannel<"u"){var E=new MessageChannel,q=E.port2;E.port1.onmessage=D,O=r(function(){q.postMessage(null)},"schedulePerformWorkUntilDeadline")}else O=r(function(){k(D,0)},"schedulePerformWorkUntilDeadline");function B(U,z){T=k(function(){U(e.unstable_now())},z)}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(U){U.callback=null},e.unstable_forceFrameRate=function(U){0>U||125<U||(R=0<U?Math.floor(1e3/U):5)},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(U){switch(f){case 1:case 2:case 3:var z=3;break;default:z=f}var $=f;f=z;try{return U()}finally{f=$}},e.unstable_requestPaint=function(){w=!0},e.unstable_runWithPriority=function(U,z){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var $=f;f=U;try{return z()}finally{f=$}},e.unstable_scheduleCallback=function(U,z,$){var K=e.unstable_now();switch(typeof $=="object"&&$!==null?($=$.delay,$=typeof $=="number"&&0<$?K+$:K):$=K,U){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=$+H,U={id:h++,callback:z,priorityLevel:U,startTime:$,expirationTime:H,sortIndex:-1},$>K?(U.sortIndex=$,s(u,U),n(d)===null&&U===n(u)&&(y?(j(T),T=-1):y=!0,B(I,$-K))):(U.sortIndex=H,s(d,U),v||g||(v=!0,C||(C=!0,O()))),U},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(U){var z=f;return function(){var $=f;f=z;try{return U.apply(this,arguments)}finally{f=$}}}})),CYt=Gv(((e,s)=>{s.exports=SYt()})),_Yt=Gv((e=>{var s=CYt(),n=EU(),a=Gde();function i(x){var b="https://react.dev/errors/"+x;if(1<arguments.length){b+="?args[]="+encodeURIComponent(arguments[1]);for(var S=2;S<arguments.length;S++)b+="&args[]="+encodeURIComponent(arguments[S])}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,S=x;if(x.alternate)for(;b.return;)b=b.return;else{x=b;do b=x,(b.flags&4098)!==0&&(S=b.return),x=b.return;while(x)}return b.tag===3?S: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 u(x){if(l(x)!==x)throw Error(i(188))}r(u,"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 S=x,M=b;;){var V=S.return;if(V===null)break;var G=V.alternate;if(G===null){if(M=V.return,M!==null){S=M;continue}break}if(V.child===G.child){for(G=V.child;G;){if(G===S)return u(V),x;if(G===M)return u(V),b;G=G.sibling}throw Error(i(188))}if(S.return!==M.return)S=V,M=G;else{for(var be=!1,Me=V.child;Me;){if(Me===S){be=!0,S=V,M=G;break}if(Me===M){be=!0,M=V,S=G;break}Me=Me.sibling}if(!be){for(Me=G.child;Me;){if(Me===S){be=!0,S=G,M=V;break}if(Me===M){be=!0,M=G,S=V;break}Me=Me.sibling}if(!be)throw Error(i(189))}}if(S.alternate!==M)throw Error(i(190))}if(S.tag!==3)throw Error(i(188));return S.stateNode.current===S?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"),k=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),_=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),O=Symbol.iterator;function E(x){return x===null||typeof x!="object"?null:(x=O&&x[O]||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 k:return"StrictMode";case C:return"Suspense";case T: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 I:var b=x.render;return x=x.displayName,x||(x=b.displayName||b.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case R:return b=x.displayName||null,b!==null?b:B(x.type)||"Memo";case A:b=x._payload,x=x._init;try{return B(x(b))}catch{}}return null}r(B,"getComponentNameFromType");var U=Array.isArray,z=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K={pending:!1,data:null,method:null,action:null},H=[],se=-1;function Z(x){return{current:x}}r(Z,"createCursor");function ie(x){0>se||(x.current=H[se],H[se]=null,se--)}r(ie,"pop");function oe(x,b){se++,H[se]=x.current,x.current=b}r(oe,"push");var Y=Z(null),ne=Z(null),de=Z(null),ee=Z(null);function X(x,b){switch(oe(de,b),oe(ne,x),oe(Y,null),b.nodeType){case 9:case 11:x=(x=b.documentElement)&&(x=x.namespaceURI)?eG(x):0;break;default:if(x=b.tagName,b=b.namespaceURI)b=eG(b),x=tG(b,x);else switch(x){case"svg":x=1;break;case"math":x=2;break;default:x=0}}ie(Y),oe(Y,x)}r(X,"pushHostContainer");function Q(){ie(Y),ie(ne),ie(de)}r(Q,"popHostContainer");function fe(x){x.memoizedState!==null&&oe(ee,x);var b=Y.current,S=tG(b,x.type);b!==S&&(oe(ne,x),oe(Y,S))}r(fe,"pushHostContext");function te(x){ne.current===x&&(ie(Y),ie(ne)),ee.current===x&&(ie(ee),Ek._currentValue=K)}r(te,"popHostContext");var ae,le;function ce(x){if(ae===void 0)try{throw Error()}catch(S){var b=S.stack.trim().match(/\n( *(at )?)/);ae=b&&b[1]||"",le=-1<S.stack.indexOf(`
|
|
730
730
|
at`)?" (<anonymous>)":-1<S.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
731
731
|
`+ae+x+le}r(ce,"describeBuiltInComponentFrame");var he=!1;function ve(x,b){if(!x||he)return"";he=!0;var S=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:r(function(){try{if(b){var Ts=r(function(){throw Error()},"Fake");if(Object.defineProperty(Ts.prototype,"props",{set:r(function(){throw Error()},"set")}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ts,[])}catch(os){var ss=os}Reflect.construct(x,[],Ts)}else{try{Ts.call()}catch(os){ss=os}x.call(Ts.prototype)}}else{try{throw Error()}catch(os){ss=os}(Ts=x())&&typeof Ts.catch=="function"&&Ts.catch(function(){})}}catch(os){if(os&&ss&&typeof os.stack=="string")return[os.stack,ss.stack]}return[null,null]},"DetermineComponentFrameRoot")};M.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var V=Object.getOwnPropertyDescriptor(M.DetermineComponentFrameRoot,"name");V&&V.configurable&&Object.defineProperty(M.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var G=M.DetermineComponentFrameRoot(),be=G[0],Me=G[1];if(be&&Me){var yt=be.split(`
|
|
732
732
|
`),ts=Me.split(`
|