dorkos 0.101.0 → 0.103.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/bin/cli.js +2935 -1738
- package/dist/browser/native/package-manifest.json +1 -1
- package/dist/browser/source-manifest.json +1 -1
- package/dist/client/assets/{AboutPage-CwxCTicf.js → AboutPage-BNVLNd3q.js} +1 -1
- package/dist/client/assets/{ActivityRow-D0QQ0SFu.js → ActivityRow-CvjAfRBM.js} +1 -1
- package/dist/client/assets/AdapterIcon-wGSXBn-k.js +1 -0
- package/dist/client/assets/AdapterSetupWizard-CmSJ2sno.js +2 -0
- package/dist/client/assets/{AgentRequestCard-BLLmoAES.js → AgentRequestCard-D62XQXBM.js} +4 -4
- package/dist/client/assets/{AppearancePage-GqrWckTQ.js → AppearancePage-Bds0L-wm.js} +1 -1
- package/dist/client/assets/{AttentionSignalRow-sEhnIPBB.js → AttentionSignalRow-C6RkjCWK.js} +1 -1
- package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-BXjzhT_D.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-CerNarG-.js} +24 -24
- package/dist/client/assets/{BlintzCanvas-CXi0fvcM.js → BlintzCanvas-CUqethk_.js} +24 -24
- package/dist/client/assets/{CanvasCsvContent-QhDSf8Pd.js → CanvasCsvContent-DdbIUPMJ.js} +1 -1
- package/dist/client/assets/CanvasFileContent-CX2VNF4o.js +2 -0
- package/dist/client/assets/CanvasModel3dContent-OprkQsgq.js +2 -0
- package/dist/client/assets/{CodeMirrorDiff-BMG7DBg2.js → CodeMirrorDiff-BnMdmI0K.js} +1 -1
- package/dist/client/assets/{CodeMirrorEditor-BYdz0ipX.js → CodeMirrorEditor-C7T-DaVA.js} +1 -1
- package/dist/client/assets/ConnectionAccessLists-B3QGnSxM.js +1 -0
- package/dist/client/assets/ConnectionsPage-E3br6maQ.js +11 -0
- package/dist/client/assets/{ConventionPage-y-Zq3Klp.js → ConventionPage-vMN5qEwP.js} +3 -3
- package/dist/client/assets/{ExtensionPageRoute-gZKKPhaj.js → ExtensionPageRoute-DFkPAzjs.js} +2 -2
- package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-CbKIa11X.js → FloatingTanStackRouterDevtools-CqogiFob-BP4itJWW.js} +1 -1
- package/dist/client/assets/HandlePage-De4D_IVs.js +1 -0
- package/dist/client/assets/{LexicalField-Ceoa9flp.js → LexicalField-BbUXXxTw.js} +1 -1
- package/dist/client/assets/{ManagesPage-Dcqdm6I8.js → ManagesPage-DsNSZHug.js} +1 -1
- package/dist/client/assets/Marketplace-D4zHIIak.js +36 -0
- package/dist/client/assets/MarketplaceSourcesView-DILS8-ca.js +1 -0
- package/dist/client/assets/{McpAppFrame-B1ThSf2U.js → McpAppFrame-Cl_2azg-.js} +2 -2
- package/dist/client/assets/McpSigninBody-TpoSImsV.js +1 -0
- package/dist/client/assets/{Model3dViewer-DlcQ3-LS.js → Model3dViewer-C-iyu5eV.js} +1 -1
- package/dist/client/assets/NamePage-C-3w8oeg.js +1 -0
- package/dist/client/assets/NewDirectMessageMenu-bJE7b4lX.js +1 -0
- package/dist/client/assets/{NotificationsPage-CQQIdLtI.js → NotificationsPage-CL23qwVw.js} +1 -1
- package/dist/client/assets/OperatorIdentityForm-ixaqUfIO.js +1 -0
- package/dist/client/assets/{PermissionsPage-TX-d7aVQ.js → PermissionsPage-D4xbxTkc.js} +1 -1
- package/dist/client/assets/{PersonalityPicker-C_9JVOva.js → PersonalityPicker-CTvPlN-k.js} +1 -1
- package/dist/client/assets/{PersonalityPopover-BoTED73t.js → PersonalityPopover-Coy0eaIg.js} +1 -1
- package/dist/client/assets/PhotoPage-DpEEXO3e.js +1 -0
- package/dist/client/assets/PreviewRefusedNotice-B2GLqLYi.js +1 -0
- package/dist/client/assets/{PromptSuggestionChips-B_oUtFMI.js → PromptSuggestionChips-YdKEWyNT.js} +1 -1
- package/dist/client/assets/RoomSurface-BwIBBvYq.js +44 -0
- package/dist/client/assets/{RoomsPage-zOjjpHdA.js → RoomsPage-DaEXPz65.js} +1 -1
- package/dist/client/assets/RunsOnPopover-tvbVPKVf.js +1 -0
- package/dist/client/assets/SessionsPage-CAdV_XBY.js +1 -0
- package/dist/client/assets/SkillsPage-B4F19LmV.js +1 -0
- package/dist/client/assets/{TasksPage-BZapA_v6.js → TasksPage-BXcaEx3V.js} +1 -1
- package/dist/client/assets/ToolsPage-BYBwPql_.js +2 -0
- package/dist/client/assets/{TopologyGraph-BMcPxZsA.js → TopologyGraph-CZ2Y5I2e.js} +1 -1
- package/dist/client/assets/TourHost-BNpDrN0O.js +1 -0
- package/dist/client/assets/UnlinkDialog-Zyuh5qZY.js +1 -0
- package/dist/client/assets/{UnreadDivider-KSqqcHKN.js → UnreadDivider-Dh67_mAz.js} +1 -1
- package/dist/client/assets/_shell-lcu5vkQ7.js +98 -0
- package/dist/client/assets/{_shell._home-Bp_p1VUv.js → _shell._home-CPV1Z64k.js} +1 -1
- package/dist/client/assets/_shell._home.activity-CEvkKYBD.js +1 -0
- package/dist/client/assets/_shell._home.index-tGnRLvY-.js +3 -0
- package/dist/client/assets/{_shell._home.tasks-BsBH_4tZ.js → _shell._home.tasks-CtpZNevK.js} +1 -1
- package/dist/client/assets/_shell._home.workspaces-D6tkWdS8.js +1 -0
- package/dist/client/assets/{_shell.channels-DWAHkDPV.js → _shell.channels-DbrQXIVv.js} +4 -4
- package/dist/client/assets/_shell.connections-C3Ho4S8R.js +6 -0
- package/dist/client/assets/{_shell.feedback-requests-Hjv640j9.js → _shell.feedback-requests-D9l7SJi1.js} +1 -1
- package/dist/client/assets/_shell.marketplace-BfY-kBJk.js +1 -0
- package/dist/client/assets/_shell.marketplace_.sources-B0km_EUs.js +1 -0
- package/dist/client/assets/_shell.session-O8MC-USm.js +54 -0
- package/dist/client/assets/{_shell.team-ctLQztjw.js → _shell.team-DvJK7irE.js} +4 -4
- package/dist/client/assets/_shell.x._extensionId-_-fII74H.js +1 -0
- package/dist/client/assets/_shell.x._extensionId_._-_-fII74H.js +1 -0
- package/dist/client/assets/agent-attention-BvnWcLpc.js +5 -0
- package/dist/client/assets/{agent-browser-CCN16ZOz.js → agent-browser-DsDp0cSX.js} +1 -1
- package/dist/client/assets/{banner-DOm9_4l-.js → banner-Cja2VfwN.js} +2 -2
- package/dist/client/assets/{file-exclamation-point-BKzL0QhY.js → file-exclamation-point-D8KYFYSh.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-DTxMTVdP.js → highlighted-body-KPVGNVTW-Chp5pHWq.js} +1 -1
- package/dist/client/assets/{hover-card-qzuFUCaR.js → hover-card-FvX18DHP.js} +1 -1
- package/dist/client/assets/{index-Dcs6e-U_.js → index-BFPRILKF.js} +1 -1
- package/dist/client/assets/{index-CtOB9fS3.js → index-BKCteC7q.js} +1 -1
- package/dist/client/assets/index-Bbffv0TQ.js +1247 -0
- package/dist/client/assets/{index-BMOfHKE0.js → index-BhatJcNc.js} +1 -1
- package/dist/client/assets/index-BroohPSu.js +1 -0
- package/dist/client/assets/{index-DT_v3O-B.js → index-Bt4vTnDj.js} +1 -1
- package/dist/client/assets/{index-DwzSdOh3.js → index-BwkmCRvO.js} +1 -1
- package/dist/client/assets/{index-CTai_TxZ.js → index-BzS1K2wS.js} +1 -1
- package/dist/client/assets/{index-C3XnoXTY.js → index-C6F5gzX-.js} +1 -1
- package/dist/client/assets/{index-BaB-skF0.js → index-CIzSi3tA.js} +3 -3
- package/dist/client/assets/{index-BPcwoJoz.js → index-CLCbHvV5.js} +1 -1
- package/dist/client/assets/{index-DA-i3I4q.js → index-CXjobHw0.js} +1 -1
- package/dist/client/assets/{index-DgH_dl1a.js → index-CYcJ7ENW.js} +2 -2
- package/dist/client/assets/{index-3lQkXKcq.js → index-CeqzGl3y.js} +1 -1
- package/dist/client/assets/{index-DgtF-nBt.js → index-CknNaeS2.js} +1 -1
- package/dist/client/assets/{index-Bk98IpMn.js → index-CtK6WJzD.js} +1 -1
- package/dist/client/assets/{index-C8ZMfyGc.js → index-CvxLe-_3.js} +1 -1
- package/dist/client/assets/{index-CF9fqPef.js → index-D24Ttd-y.js} +4 -4
- package/dist/client/assets/{index-CIPHHziB.js → index-D6Jn2eBq.js} +1 -1
- package/dist/client/assets/{index-D3DXMH4x.js → index-DDibi3-x.js} +1 -1
- package/dist/client/assets/{index-C7B2uRgo.js → index-DElGMXW8.js} +2 -2
- package/dist/client/assets/{index-CmlaXay_.js → index-DGNJkiFb.js} +1 -1
- package/dist/client/assets/{index-WjW-NUCp.js → index-DI2T-dXr.js} +1 -1
- package/dist/client/assets/{index-CLhD0Bno.js → index-DZf_utaG.js} +1 -1
- package/dist/client/assets/{index-CTXNRyRE.js → index-D_XtXoLp.js} +1 -1
- package/dist/client/assets/{index-CDTumWMC.js → index-DjdQaKwP.js} +1 -1
- package/dist/client/assets/index-Do18O9VZ.js +1 -0
- package/dist/client/assets/{index-CVl132_4.js → index-Do1vOFrm.js} +1 -1
- package/dist/client/assets/{index-BIMClIrX.js → index-Dv1DkyeB.js} +1 -1
- package/dist/client/assets/{index-IgIVF9T_.js → index-DyvLJ_Z5.js} +1 -1
- package/dist/client/assets/index-HgvJwMGi.js +5 -0
- package/dist/client/assets/{index-DR1JT9Uz.js → index-OxwtxTFo.js} +3 -3
- package/dist/client/assets/index-QSDTjavn.js +1 -0
- package/dist/client/assets/{index-DOxEmnH2.js → index-ZLdoJdwS.js} +1 -1
- package/dist/client/assets/index-_GlgFH88.css +1 -0
- package/dist/client/assets/{index-CScfHuKF.js → index-euarUu2E.js} +1 -1
- package/dist/client/assets/{index-B-z7hA9x.js → index-jYh6X22t.js} +1 -1
- package/dist/client/assets/{index-CIfwPLXd.js → index-uQ1vTS05.js} +1 -1
- package/dist/client/assets/{index-CejezM4U.js → index-xfBvKz-h.js} +1 -1
- package/dist/client/assets/{index-BW5ce4t8.js → index-znQ5q2gV.js} +1 -1
- package/dist/client/assets/{layers-CJHXSEKK.js → layers-8-cbYlfw.js} +1 -1
- package/dist/client/assets/{lightbulb-DWjxw7lb.js → lightbulb-DoB0IKly.js} +1 -1
- package/dist/client/assets/{mention-pill-akMU3IVs.js → mention-pill-BHC6tMG9.js} +1 -1
- package/dist/client/assets/{message-square-off-DEagHpQY.js → message-square-off-CEHuZJtY.js} +1 -1
- package/dist/client/assets/{owner-notice-CLsx0s7q.js → owner-notice-dtDSKfGs.js} +1 -1
- package/dist/client/assets/{page-container-W7byjRmk.js → page-container-BOrdASM1.js} +1 -1
- package/dist/client/assets/primer-trigger-CC-cR5zN.js +3 -0
- package/dist/client/assets/{radio-B8Ozjv9U.js → radio-BfZPhctR.js} +1 -1
- package/dist/client/assets/{room-files-source-Bsc3YA91.js → room-files-source-BHupFaLE.js} +2 -2
- package/dist/client/assets/{rotate-ccw-clock-CNcDcTvq.js → rotate-ccw-clock-BvzfP8lR.js} +1 -1
- package/dist/client/assets/{rotate-cw-xvfipJLN.js → rotate-cw-BDweizfR.js} +1 -1
- package/dist/client/assets/{scroll-area-C95q3ss7.js → scroll-area-Dph6w3a6.js} +1 -1
- package/dist/client/assets/{search-x-C6SAxw7a.js → search-x-CoFJOP2l.js} +2 -2
- package/dist/client/assets/{shield-x-DxOGc0dW.js → shield-x-BZ6rhiT0.js} +1 -1
- package/dist/client/assets/{soul-file-pg0ShYy3.js → soul-file-H8fwhgiL.js} +1 -1
- package/dist/client/assets/use-delete-binding-CUsepFIL.js +1 -0
- package/dist/client/assets/use-dev-links-DYYe0vvP.js +1 -0
- package/dist/client/assets/{use-external-adapter-catalog-B0gcY-k7.js → use-external-adapter-catalog-CAl3MNq-.js} +1 -1
- package/dist/client/assets/use-full-activity-feed-Bb7BUusp.js +1 -0
- package/dist/client/assets/use-is-below-desktop-CIgGSgoL.js +1 -0
- package/dist/client/assets/use-jump-back-in-BdLBzvDr.js +11 -0
- package/dist/client/assets/use-mesh-topology-wYtCBbF_.js +1 -0
- package/dist/client/assets/use-pending-read-9UcfnDwF.js +1 -0
- package/dist/client/assets/{use-personality-commit-OH7d0xl_.js → use-personality-commit-CaxUHrX5.js} +1 -1
- package/dist/client/assets/{use-promo-activation-BgdGasXE.js → use-promo-activation-rNaAOdoh.js} +2 -2
- package/dist/client/assets/use-pulse-freshness-CygG3s-S.js +1 -0
- package/dist/client/assets/use-room-follow-claim-BIK37Iy3.js +1 -0
- package/dist/client/assets/{use-roving-tab-list-Be60AWK3.js → use-roving-tab-list-DQgkKGzc.js} +1 -1
- package/dist/client/assets/{use-session-canvas-Bqs6IQO7.js → use-session-canvas-Dpy5BEId.js} +5 -5
- package/dist/client/assets/use-session-diagnostics-atu9cfgr.js +16 -0
- package/dist/client/assets/use-unclaimed-chats-qUI5vY5K.js +1 -0
- package/dist/client/index.html +2 -2
- package/dist/drizzle/20261008170031_session_touches.sql +5 -0
- package/dist/drizzle/20261009171311_chat_messages.sql +41 -0
- package/dist/drizzle/20261009173712_started_by_report_back.sql +1 -0
- package/dist/drizzle/meta/20261008170031_snapshot.json +12642 -0
- package/dist/drizzle/meta/20261009171311_snapshot.json +12906 -0
- package/dist/drizzle/meta/20261009173712_snapshot.json +12914 -0
- package/dist/drizzle/meta/_journal.json +21 -0
- package/dist/server/index.js +23608 -19236
- package/dist/server/index.js.map +2 -2
- package/package.json +6 -6
- package/dist/client/assets/AdapterIcon-CL-MyyKy.js +0 -1
- package/dist/client/assets/AdapterSetupWizard-C8HOvHLF.js +0 -2
- package/dist/client/assets/CanvasFileContent-ZZhdofR4.js +0 -2
- package/dist/client/assets/CanvasModel3dContent-DMMMZh4o.js +0 -2
- package/dist/client/assets/ConnectionAccessLists-PW1uzcGU.js +0 -1
- package/dist/client/assets/ConnectionsPage-EwitZwOE.js +0 -11
- package/dist/client/assets/HandlePage-CL3_n1CI.js +0 -1
- package/dist/client/assets/Marketplace-DsU-q1ZZ.js +0 -36
- package/dist/client/assets/MarketplaceSourcesView-D72YoKNR.js +0 -1
- package/dist/client/assets/McpSigninBody-Btg3PnYN.js +0 -1
- package/dist/client/assets/NamePage-Bzqj4Eob.js +0 -1
- package/dist/client/assets/NewDirectMessageMenu-89yeGqvy.js +0 -1
- package/dist/client/assets/OperatorIdentityForm-BhiB9tQp.js +0 -1
- package/dist/client/assets/PhotoPage-C3fMlebQ.js +0 -1
- package/dist/client/assets/PreviewRefusedNotice-ChCgdKWN.js +0 -1
- package/dist/client/assets/RoomSurface-CgtNuYhl.js +0 -39
- package/dist/client/assets/RunsOnPopover-JTm1cYuw.js +0 -1
- package/dist/client/assets/SessionsPage-D4kyvHQf.js +0 -6
- package/dist/client/assets/SkillsPage-KYUVzuVa.js +0 -1
- package/dist/client/assets/ToolsPage-CWpHMlrR.js +0 -2
- package/dist/client/assets/TourHost-VY1-sy1Y.js +0 -1
- package/dist/client/assets/UnlinkDialog-3p38G_9q.js +0 -1
- package/dist/client/assets/_shell-DAjwimLg.js +0 -93
- package/dist/client/assets/_shell._home.activity-tk-XApvX.js +0 -1
- package/dist/client/assets/_shell._home.index-BNVhSN0y.js +0 -3
- package/dist/client/assets/_shell._home.workspaces-DuXnjQh0.js +0 -1
- package/dist/client/assets/_shell.connections-DIm3mUHy.js +0 -6
- package/dist/client/assets/_shell.marketplace-DF6Y7mc0.js +0 -1
- package/dist/client/assets/_shell.marketplace_.sources-Do8cm7kq.js +0 -1
- package/dist/client/assets/_shell.session-DlN8iOl-.js +0 -43
- package/dist/client/assets/_shell.x._extensionId-0Q1rJtud.js +0 -1
- package/dist/client/assets/_shell.x._extensionId_._-0Q1rJtud.js +0 -1
- package/dist/client/assets/agent-attention-Dn__3LQE.js +0 -5
- package/dist/client/assets/hand-DLUdsiuR.js +0 -6
- package/dist/client/assets/index-CQWqpw_G.js +0 -1
- package/dist/client/assets/index-D5uYwabS.js +0 -1
- package/dist/client/assets/index-DFMDv6qR.js +0 -1
- package/dist/client/assets/index-DMYBI16t.js +0 -1252
- package/dist/client/assets/index-DbbZNAKk.js +0 -5
- package/dist/client/assets/index-Dgp1LmEk.css +0 -1
- package/dist/client/assets/primer-trigger-DuM9vVnV.js +0 -3
- package/dist/client/assets/use-delete-binding-CZVeHqn0.js +0 -1
- package/dist/client/assets/use-dev-links-Df2WkCic.js +0 -1
- package/dist/client/assets/use-full-activity-feed-SYcgdMZu.js +0 -1
- package/dist/client/assets/use-is-below-desktop-C5_YenEp.js +0 -1
- package/dist/client/assets/use-jump-back-in-DWUPb1gi.js +0 -11
- package/dist/client/assets/use-mesh-topology-HLzZIgis.js +0 -1
- package/dist/client/assets/use-pending-read-BuJknrxG.js +0 -1
- package/dist/client/assets/use-pulse-freshness-BlD-dM_g.js +0 -1
- package/dist/client/assets/use-rename-session-D3MuyK-F.js +0 -1
- package/dist/client/assets/use-room-follow-claim-CyjhzbRJ.js +0 -1
- package/dist/client/assets/use-session-diagnostics-CfKdB2iY.js +0 -16
- package/dist/client/assets/use-unclaimed-chats-lqMhotUB.js +0 -1
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
var Ru=Object.defineProperty;var Du=(e,t,s)=>t in e?Ru(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Jt=(e,t,s)=>Du(e,typeof t!="symbol"?t+"":t,s);import{p_ as Ou,r as l,p$ as Ko,q0 as Mu,q1 as qr,j as n,q2 as _u,q3 as zi,q4 as Pu,Q as ie,ad as be,hz as De,eG as Ae,dU as ss,q5 as _s,hT as Lu,q6 as Fu,q7 as $u,q8 as Bu,R as ce,ah as ue,ot as zu,q9 as Uu,Y as Se,et as hs,O as G,B as _,oX as Ku,X as He,aa as z,g3 as Ce,im as Ui,qa as Hu,aU as wt,am as Ki,bc as Hi,a$ as fs,hE as Pe,aH as qu,qb as Ho,qc as Wu,bh as qi,kr as Wi,bM as Ie,ds as Oe,hx as ut,iK as Gu,iL as Gi,W as ae,qd as jn,gE as it,qe as Yi,U as kn,ia as Vi,e$ as Wr,ci as Gr,ak as Lt,qf as qo,hy as Sn,qg as Yu,kX as Yr,dt as Qi,du as Xi,qh as Ji,qi as Vu,bd as Ee,qj as Zi,dC as Ye,dl as Cn,dm as Nn,dG as mt,dn as An,dp as En,aF as Ft,e6 as xr,cA as ps,cB as gs,cC as xs,qk as ec,ql as Qu,eL as yr,eM as br,eN as vr,eO as wr,hq as Ot,kP as Xu,aD as B,eJ as tc,bT as rt,eu as Te,qm as Ju,pE as Zu,eB as ct,m6 as rs,V as $t,qn as em,qo as tm,py as Wo,pF as nm,qp as sm,nc as rm,e_ as ys,el as om,qq as am,qr as nc,a2 as Go,qs as im,kn as Vr,a7 as cm,pd as lm,br as Qr,qt as In,qu as dm,qv as bs,dM as um,a3 as fn,cr as Bt,cs as zt,ct as Ut,fY as ke,C as Tn,ir as vs,mI as sc,qw as rc,hv as pn,dQ as mm,qx as hm,bp as Rn,js as ws,ga as js,K as fm,qy as Xr,pD as oc,oj as pm,hM as qe,fV as ks,fa as Kt,iD as Jr,f as Ht,aW as ac,qz as ic,ey as Ss,l as pe,qA as gm,d7 as xm,iQ as gn,cR as et,cS as tt,cT as Xe,cU as ze,cV as Je,ew as lt,cW as Dt,cP as ym,qB as bm,qC as Dn,qD as vm,ib as wm,qE as jm,dr as Ne,id as Cs,gn as km,kk as Sm,gp as Cm,gq as Nm,gr as Am,nG as cc,qF as Em,qG as Me,qH as lc,dd as Im,qI as Yo,qJ as dc,n as uc,ic as Tm,hP as mc,dR as hc,qK as Rm,gf as fc,j7 as Zr,i1 as pc,gL as qt,gM as eo,gP as gc,fn as Dm,fg as to,hk as Om,qL as xc,qM as Mt,qN as xn,qO as Mm,qP as _m,gw as yc,gx as bc,fy as vc,fz as wc,fB as jc,qQ as jt,fC as Pm,qR as kc,qS as Lm,qT as pt,qU as Ge,f9 as dt,qV as Sc,qW as Fm,F as he,qX as $m,z as re,G as Wt,_ as Gt,D as me,A as xt,qY as no,qZ as Bm,q_ as Cc,es as yn,ep as _e,I as Ze,q$ as Nc,r0 as zm,r1 as Ac,r2 as Ec,r3 as Um,r4 as Km,r5 as Hm,fi as kt,fh as _t,fj as Ns,jq as qm,ff as Ic,eC as Tc,lq as Rc,lB as Wm,fe as Gm,r6 as Ym,r7 as Vm,r8 as Pt,r9 as Dc,hC as Oc,ra as Qm,rb as Mc,rc as _c,rd as Xm,re as Jm,aI as so,fk as ro,rf as Zm,ge as On,rg as an,rh as oo,gV as ao,hw as Tt,oN as Pc,ri as eh,iM as Vo,kS as th,rj as nh,rk as sh,rl as rh,bE as oh,gb as io,nr as Lc,nq as Fc,ht as ah,dc as $c,rm as Be,kh as fe,rn as Qo,cX as As,ro as ih,rp as ch,rq as lh,rr as dh,rs as uh,hn as mh,rt as hh,hj as co,aV as lo,ru as Bc,mL as fh,hB as zc,rv as Uc,pN as uo,rw as ph,n9 as Kc,rx as Mn,nm as mo,ry as Yt,rz as gh,rA as xh,rB as yh,rC as bh,rD as vh,rE as wh,rF as jh,fl as kh,rG as Sh,rH as Ch,nn as Hc,np as Nh,rI as Ah,rJ as qc,hH as Eh,rK as Wc,rL as Xo,rM as Jo,rN as Ih,rO as Th,rP as Rh,rQ as Dh,rR as Oh,rS as Mh,rT as Zo,rU as _h,by as ln,rV as Ph,rW as ea,rX as Lh,rY as Fh,rZ as $h,r_ as Bh,r$ as zh,s0 as Uh,s1 as Kh,s2 as Ps,s3 as Hh,jO as qh,e as yt,s4 as Wh,s5 as Gh,s6 as Yh,aS as Vh,iu as Qh,s7 as Xh,s8 as Jh,aR as Zh,s9 as ef,sa as tf,g8 as Vt,hr as nf,sb as sf,sc as os,sd as rf,se as Gc,sf as of,sg as af,sh as cf,si as Yc,sj as Kn,sk as lf,sl as df,sm as uf,sn as Vc,so as jr,sp as mf,pi as hf,H as ho,ab as ff,oT as Qc,lm as Xc,iF as fo,eX as pf,t as gf,g as xf,gm as yf,aB as po,hI as Jc,sq as bf,kI as vf,kj as wf,n1 as jf,sr as kf,gS as Zc,fG as Sf,fH as Cf,fI as Nf,fJ as Af,fK as Ef,fL as If,fM as Tf,ss as Rf,st as kr,su as Df,sv as Ls,sw as Of,sx as Mf,sy as bn,sz as _f,sA as ta,kq as Pf,gN as Lf,sB as Ff,hX as $f,hY as Bf,h_ as zf,h$ as na,l1 as sa,k$ as Uf,l0 as ra,sC as Kf,sD as Hf,sE as qf,sF as Wf,nh as Gf,sG as Yf,sH as Vf,sI as Qf,kd as el,ke as tl,kf as nl,kg as Xf,bt as Jf,hs as Zf,sJ as ep,sK as sl,sL as rl,sM as tp,sN as np,bm as sp,fo as rp,sO as Fs,aE as op,sP as ap,sQ as ip,sR as cp,sS as lp,sT as dp,sU as up,sV as mp,sW as hp,sX as fp,sY as oa,aX as ol,fc as pp,hZ as gp,bl as xp,sZ as al,s_ as yp,fb as bp,s$ as aa,gl as vp,t0 as wp,t1 as jp,t2 as kp,t3 as Sp,t4 as Cp,pQ as Np,gg as Ap,h as go,t5 as Ep,t6 as Ip,t7 as Tp,ef as Rp,t8 as ia,t9 as Dp,ta as Op,oB as Mp,g9 as il,oD as _p,tb as Pp,tc as Lp,td as Fp,oJ as $p,j8 as Bp,te as zp,tf as Up,eK as Kp,jd as Hp,je as qp,jf as Wp,ji as Gp,jg as Yp,tg as Vp,th as Qp,jc as Xp,ja as Jp,jb as Zp,ti as cl,i9 as eg,tj as tg,tk as ng,tl as ll,tm as sg,tn as xo,to as dl,a6 as ul,tp as ml,tq as rg,cw as og,cx as ag,eA as ca,tr as la,ts as ig,b0 as cg,aJ as lg,fT as dg,tt as ug,kJ as $s,hh as Bs,tu as mg,tv as hg,tw as fg,dX as pg,tx as yo,ll as gg,ty as xg,lp as yg,tz as hl,tA as fl,tB as pl,tC as bg,tD as vg,tE as da,tF as wg,tG as jg,tH as kg,tI as Rt,cD as Sg,tJ as ua,mm as Cg,mo as gl,cQ as Ng,iB as Ag,tK as Eg,mG as Ig,tL as Sr,tM as Tg,hG as Rg,mz as Qe,mB as Dg,tN as Og,bN as Mg,tO as _g,tP as Pg,tQ as Lg,tR as Fg,tS as $g,kC as Bg,i_ as zg,ka as Ug,l3 as Kg,tT as Hg,tU as qg,tV as Wg,tW as Gg,tX as Yg,tY as Vg,bO as Qg,tZ as Xg,t_ as Jg,nF as Zg,ch as ex}from"./index-DMYBI16t.js";import{D as Ve,a as tx}from"./TourHost-VY1-sy1Y.js";import{O as nx,B as bo}from"./banner-DOm9_4l-.js";import{u as sx}from"./use-dev-links-Df2WkCic.js";import{d as rx}from"./untrusted-text-1hXdPgLA.js";import{S as dn}from"./scroll-area-C95q3ss7.js";import{T as xl,a as yl,b as Jn,c as zs,u as ox,i as ax,d as ix,P as bl}from"./PreviewRefusedNotice-ChCgdKWN.js";import{L as cx}from"./lightbulb-DWjxw7lb.js";import{i as lx,O as vo,b as dx,u as ux,a as mx}from"./OperatorIdentityForm-BhiB9tQp.js";import{c as hx,b as fx,u as px,O as gx,d as xx}from"./agent-attention-Dn__3LQE.js";import{a as yx}from"./use-pulse-freshness-BlD-dM_g.js";import{T as vl,F as bx,r as vx,c as wx,B as jx,b as kx,a as Sx,w as Cx,e as Nx}from"./primer-trigger-DuM9vVnV.js";import{M as Ax,u as Ex,a as wl,s as Ix,P as Tx,b as Rx}from"./use-promo-activation-BgdGasXE.js";import{u as jl}from"./use-pending-read-BuJknrxG.js";import{a as oe,d as Dx,b as Ox}from"./dorkbot-templates-cu4wApxb.js";import{A as kl,P as Mx,u as _x,a as Px}from"./use-jump-back-in-DWUPb1gi.js";import{R as Lx}from"./rotate-cw-xvfipJLN.js";import{u as Fx,a as $x,C as Bx,N as zx}from"./NewDirectMessageMenu-89yeGqvy.js";import{o as Ux}from"./owner-notice-CLsx0s7q.js";import{A as Sl,M as Kx}from"./McpAppFrame-B1ThSf2U.js";import{R as Cl}from"./radio-B8Ozjv9U.js";import{M as Zt,C as Hx,i as qx}from"./index-DbbZNAKk.js";import{P as Wx,p as Gx}from"./PersonalityPicker-C_9JVOva.js";import{H as Yx,a as Vx,b as Qx}from"./hover-card-qzuFUCaR.js";import{P as Us}from"./page-container-W7byjRmk.js";import{u as Xx}from"./use-roving-tab-list-Be60AWK3.js";import{R as Jx}from"./rotate-ccw-clock-CNcDcTvq.js";import{L as Zx}from"./layers-CJHXSEKK.js";import{u as ey}from"./use-is-below-desktop-C5_YenEp.js";import"./use-external-adapter-catalog-B0gcY-k7.js";import"./shield-x-DxOGc0dW.js";import"./use-mesh-topology-HLzZIgis.js";import"./use-full-activity-feed-SYcgdMZu.js";import"./file-drag-GDx2qhdk.js";import"./index-CejezM4U.js";function ty({children:e,isValidProp:t,...s}){t&&Ou(t);const r=l.useContext(Ko);s={...r,...s},s.transition=Mu(s.transition,r.transition),s.isStatic=qr(()=>s.isStatic);const o=l.useMemo(()=>s,[JSON.stringify(s.transition),s.transformPagePoint,s.reducedMotion,s.skipAnimations]);return n.jsx(Ko.Provider,{value:o,children:e})}function ny(e){e.values.forEach(t=>t.stop())}function Cr(e,t){[...t].reverse().forEach(r=>{const o=e.getVariant(r);o&&zi(e,o),e.variantChildren&&e.variantChildren.forEach(a=>{Cr(a,t)})})}function sy(e,t){if(Array.isArray(t))return Cr(e,t);if(typeof t=="string")return Cr(e,[t]);zi(e,t)}function ry(){const e=new Set,t={subscribe(s){return e.add(s),()=>void e.delete(s)},start(s,r){const o=[];return e.forEach(a=>{o.push(_u(a,s,{transitionOverride:r}))}),Promise.all(o)},set(s){return e.forEach(r=>{sy(r,s)})},stop(){e.forEach(s=>{ny(s)})},mount(){return()=>{t.stop()}}};return t}function oy(){const e=qr(ry);return Pu(e.mount,[]),e}class ay{constructor(){this.componentControls=new Set}subscribe(t){return this.componentControls.add(t),()=>this.componentControls.delete(t)}start(t,s){this.componentControls.forEach(r=>{r.start(t.nativeEvent||t,s)})}cancel(){this.componentControls.forEach(t=>{t.cancel()})}stop(){this.componentControls.forEach(t=>{t.stop()})}}const iy=()=>new ay;function cy(){return qr(iy)}const ly="dork-labs/dorkos",dy=`https://github.com/${ly}/issues/new`,uy={"tunnel.enabled":"boolean","tasks.enabled":"boolean","relay.enabled":"boolean","scheduler.enabled":"boolean","mesh.enabled":"boolean","mcp.enabled":"boolean","telemetry.install":"boolean","telemetry.heartbeat":"boolean","telemetry.errorReporting":"boolean","auth.enabled":"boolean","workspace.enabled":"boolean","harness.autoSync":"boolean","harness.autoAdopt":"boolean","runtimes.codex.enabled":"boolean","runtimes.opencode.enabled":"boolean","runtimes.default":"enum","logging.level":"enum","ui.theme":"enum"},my={"runtimes.default":["claude-code","codex","opencode","doe"],"logging.level":["fatal","error","warn","info","debug","trace"],"ui.theme":["light","dark","system"]},hy=/^[a-z0-9][a-z0-9._-]{0,31}$/,fy={bug:["bug"],feature:["enhancement"],runtime:["bug"]},py={bug:"Bug: (describe what went wrong)",feature:"Feature: (describe what you want)",runtime:"Runtime issue: (describe what went wrong)"};function gy(e){return e.replace(/\b(?:sk-|pk-|rk-|ghp_|gho_|ghu_|ghs_|github_pat_|glpat-|npm_|xox[baprsc]-)[A-Za-z0-9._-]+/g,"[redacted]").replace(/\b(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16}\b/g,"[redacted]").replace(/\bBearer\s+[A-Za-z0-9._-]+/gi,"[redacted]")}function wo(e){return gy(e).replace(/[^\s/@]+@[^\s/@]+\.[^\s/@]+/g,"[email]").replace(/\b\d{1,3}(?:\.\d{1,3}){3}\b/g,"[ip]").replace(/\b(?:[A-Fa-f0-9]{1,4}:){2,7}[A-Fa-f0-9]{1,4}\b/g,"[ip]").replace(new RegExp("(?<![\\w:.])(?:[A-Fa-f0-9]{1,4})?(?::[A-Fa-f0-9]{0,4}){2,}(?![\\w:.])","g"),"[ip]").replace(/\\\\[^\s\\]+(?:\\[^\s\\]+)+/g,"[path]").replace(/(^|[\s"'`(<[{])\/\/[^\s"'`)>\]}/]+\/[^\s"'`)>\]}]+/g,"$1[path]").replace(/\b[A-Za-z]:\\[^\r\n]*/g,"[path]").replace(/(^|[\s"'`(<[{/:])(~|\/(?:Users|home))\/[^\s"'`)>\]}]+/g,"$1[home]").replace(/(^|[\s"'`(<[{])\/[\w.-]+(?:\/[\w.-]*)+/g,"$1[path]").replace(/\b(?=[A-Za-z0-9_-]*\d)[A-Za-z0-9_-]{24,}\b/g,"[redacted]")}function xy(e,t){const s=my[e];return s?s.includes(t):hy.test(t)&&wo(t)===t}function yy(e){const t={};for(const[s,r]of Object.entries(uy)){const o=e[s];o!=null&&(r==="boolean"&&typeof o=="boolean"||r==="number"&&typeof o=="number"&&Number.isFinite(o)||r==="enum"&&typeof o=="string"&&xy(s,o))&&(t[s]=o)}return t}const by=["details","summary"];function jo(e){return rx(wo(e),by)}function vy(e){const t=e.runtimes.length>0?e.runtimes.join(", "):"none configured",s=Object.entries(e.flags).map(([o,a])=>`- ${o}: ${String(a)}`).join(`
|
|
2
|
-
`),r=[`- DorkOS version: ${e.version}`,`- OS / arch: ${e.platform}`,`- Runtimes configured: ${t}`,`- Reported from: ${e.surface}`,"","Settings (on/off values only, no secrets or file paths):",s.length>0?s:"- (none available)"];return wo(r.join(`
|
|
3
|
-
`))}function wy(e){var s;const t=(s=e.body)==null?void 0:s.trim();return t?[jo(t)]:e.kind==="feature"?["## What do you want DorkOS to do?","","","## Why would it help?","",""]:["## What happened?","","","## What did you expect?","","","## Steps to reproduce","","1. ","2. ","3. "]}function jy(e){return["<details><summary>Environment</summary>","",vy(e),"","</details>","","DorkOS filled in the details above. Please check them and remove anything you do not want to share.","","---","",...wy(e)].join(`
|
|
4
|
-
`)}function Ks(e){var r;const t=(r=e.title)==null?void 0:r.trim(),s=new URLSearchParams({title:jo(t||py[e.kind]),body:jy(e),labels:fy[e.kind].join(",")});return`${dy}?${s.toString()}`}const ky=6e3,ma=`
|
|
5
|
-
|
|
6
|
-
… (shortened to fit the link; paste the rest yourself)`;function ha(e){return new TextEncoder().encode(e).length}function fa(e,t){return Array.from(e).slice(0,t).join("")}function Sy(e,t=ky){var d;const s=Ks(e);if(ha(s)<=t)return{url:s,truncated:!1};const r=((d=e.body)==null?void 0:d.trim())??"";if(!r)return{url:s,truncated:!1};const o=Array.from(r).length;let a=0,i=o;for(;a<i;){const m=Math.ceil((a+i)/2),u={...e,body:fa(r,m)+ma};ha(Ks(u))<=t?a=m:i=m-1}const c={...e,body:fa(r,a)+ma};return{url:Ks(c),truncated:!0,fullBody:jo(r)}}function Cy(e){return Sy(e).url}function Ny(e){var t,s,r,o,a,i,c,d,m,u;return{"tunnel.enabled":(t=e.tunnel)==null?void 0:t.enabled,"tasks.enabled":(s=e.tasks)==null?void 0:s.enabled,"relay.enabled":(r=e.relay)==null?void 0:r.enabled,"mesh.enabled":(o=e.mesh)==null?void 0:o.enabled,"mcp.enabled":(a=e.mcp)==null?void 0:a.enabled,"telemetry.install":(i=e.telemetry)==null?void 0:i.install,"telemetry.heartbeat":(c=e.telemetry)==null?void 0:c.heartbeat,"telemetry.errorReporting":(d=e.telemetry)==null?void 0:d.errorReporting,"auth.enabled":(m=e.auth)==null?void 0:m.enabled,"logging.level":(u=e.logging)==null?void 0:u.level}}function Nl(e,t,s){return{kind:e,version:(t==null?void 0:t.version)??"unknown",platform:(t==null?void 0:t.platform)??"unknown",runtimes:(t==null?void 0:t.runtimes)??[],surface:`web ${s}`.trim(),flags:t?yy(Ny(t)):{}}}function Ay(){const e=ie(),{data:t}=be({queryKey:De.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),s=Ae({select:r=>r.location.pathname});return l.useCallback(r=>{const o=Cy(Nl(r,t,s));ss(o)},[t,s])}const Ey=100;function Iy({cwd:e,isStreaming:t,color:s}){const r=l.useRef(""),o=l.useRef([]),a=l.useRef(null),i=l.useRef(0),c=l.useRef(t);l.useEffect(()=>{c.current=t},[t]);const d=l.useCallback(()=>{a.current&&(clearInterval(a.current),a.current=null),o.current.length!==0&&(i.current=0,a.current=window.setInterval(()=>{const u=o.current;u.length!==0&&(_s(u[i.current]),i.current=(i.current+1)%u.length)},Ey))},[]),m=l.useCallback(()=>{a.current&&(clearInterval(a.current),a.current=null),r.current&&_s(r.current)},[]);l.useEffect(()=>{if(!e)return;const u=s??Lu(e),h=Fu(u);r.current=h,o.current=[],_s(h);let p=!1;return $u(h).then(f=>{p||(o.current=f,c.current&&d())}).catch(()=>{}),()=>{p=!0}},[e,s,d]),l.useEffect(()=>(t?d():m(),m),[t,d,m])}const pa=40,ga=" — DorkOS";function xa({cwd:e,roomTitle:t,activeForm:s,prefix:r,agentName:o,agentEmoji:a,badgeCount:i,isTabHidden:c}){const d=c&&i>0?`(${i}) `:"";if(t)return`${d}${r}${t}${ga}`;if(!e)return`${d}DorkOS`;const m=a??Bu(e),u=o??e.split("/").filter(Boolean).pop()??e;let h=`${d}${r}${m} ${u}`;if(s){const p=s.length>pa?s.slice(0,pa)+"…":s;h+=` — ${p}`}return h+=ga,h}function Ty({cwd:e,activeForm:t,isStreaming:s,isWaitingForUser:r,agentName:o,agentEmoji:a,tasksBadgeCount:i,roomTitle:c,unreadRoomCount:d}){const m=l.useRef(document.hidden),u=l.useRef(!1),h=l.useRef(s),p=(i??0)+(d??0),f=l.useRef({cwd:e,activeForm:t,isWaitingForUser:r,agentName:o,agentEmoji:a,badgeCount:p,roomTitle:c});l.useEffect(()=>{f.current={cwd:e,activeForm:t,isWaitingForUser:r,agentName:o,agentEmoji:a,badgeCount:p,roomTitle:c}},[e,t,r,o,a,p,c]),l.useEffect(()=>{const g=()=>{if(m.current=document.hidden,!document.hidden){const x=f.current,b=u.current,y=x.badgeCount>0;if(b||y){u.current=!1;const k=x.isWaitingForUser?"🔔 ":"";document.title=xa({cwd:x.cwd,roomTitle:x.roomTitle??null,activeForm:x.activeForm,prefix:k,agentName:x.agentName,agentEmoji:x.agentEmoji,badgeCount:x.badgeCount,isTabHidden:!1})}}};return document.addEventListener("visibilitychange",g),()=>document.removeEventListener("visibilitychange",g)},[]),l.useEffect(()=>{h.current&&!s&&m.current&&(u.current=!0),h.current=s},[s]),l.useEffect(()=>{let g="";r?g="🔔 ":u.current&&(g="🏁 "),document.title=xa({cwd:e,roomTitle:c??null,activeForm:t,prefix:g,agentName:o,agentEmoji:a,badgeCount:p,isTabHidden:m.current})},[e,c,t,s,r,o,a,p])}function Ry(){const e=ce();ue("account_usage",t=>{const s=t;!s||typeof s.runtime!="string"||e.getQueryData(zu.usage(s.runtime))!==void 0&&Uu(e,s.runtime,[s])})}function Dy(e,t,s,r){let o;switch(e){case"ArrowRight":o=t+1;break;case"ArrowLeft":o=t-1;break;case"ArrowDown":o=t+s;break;case"ArrowUp":o=t-s;break;case"Home":o=0;break;case"End":o=r-1;break;default:return null}return Math.max(0,Math.min(r-1,o))}function Oy(e){const[t,s]=l.useState(0),r=l.useRef([]);function o(){const m=r.current.slice(0,e).filter(Boolean);if(m.length===0)return 1;const u=m[0].offsetTop;return Math.max(1,m.filter(h=>h.offsetTop===u).length)}function a(m){var h;const u=Math.max(0,Math.min(e-1,m));s(u),(h=r.current[u])==null||h.focus()}function i(m){return u=>{r.current[m]=u}}function c(m){return t===m?0:-1}function d(m,u){const h=Dy(m.key,u,o(),e);h!==null&&(m.preventDefault(),a(h))}return{focusIndex:t,setRef:i,tabIndexFor:c,handleKeyDown:d,moveFocus:a}}/**
|
|
7
|
-
* @license lucide-react v1.48.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Al={name:"building-complex",size:24,node:[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],aliases:["building-2"]};Al.node;const My=Se(Al);/**
|
|
12
|
-
* @license lucide-react v1.48.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const El={name:"camera",size:24,node:[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]};El.node;const _y=Se(El);/**
|
|
17
|
-
* @license lucide-react v1.48.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Il={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};Il.node;const Py=Se(Il);/**
|
|
22
|
-
* @license lucide-react v1.48.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const Tl={name:"circle-plus",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],aliases:["plus-circle"]};Tl.node;const Ly=Se(Tl);/**
|
|
27
|
-
* @license lucide-react v1.48.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const Rl={name:"coffee",size:24,node:[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]};Rl.node;const Dl=Se(Rl);/**
|
|
32
|
-
* @license lucide-react v1.48.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const Ol={name:"compass",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]};Ol.node;const Fy=Se(Ol);/**
|
|
37
|
-
* @license lucide-react v1.48.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const Ml={name:"crosshair",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]};Ml.node;const as=Se(Ml);/**
|
|
42
|
-
* @license lucide-react v1.48.0 - ISC
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the ISC license.
|
|
45
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const _l={name:"folder-search",size:24,node:[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]};_l.node;const $y=Se(_l);/**
|
|
47
|
-
* @license lucide-react v1.48.0 - ISC
|
|
48
|
-
*
|
|
49
|
-
* This source code is licensed under the ISC license.
|
|
50
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const Pl={name:"hard-drive",size:24,node:[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]]};Pl.node;const ya=Se(Pl);/**
|
|
52
|
-
* @license lucide-react v1.48.0 - ISC
|
|
53
|
-
*
|
|
54
|
-
* This source code is licensed under the ISC license.
|
|
55
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const Ll={name:"list-todo",size:24,node:[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]]};Ll.node;const By=Se(Ll);/**
|
|
57
|
-
* @license lucide-react v1.48.0 - ISC
|
|
58
|
-
*
|
|
59
|
-
* This source code is licensed under the ISC license.
|
|
60
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const Fl={name:"message-square-text",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]};Fl.node;const zy=Se(Fl);/**
|
|
62
|
-
* @license lucide-react v1.48.0 - ISC
|
|
63
|
-
*
|
|
64
|
-
* This source code is licensed under the ISC license.
|
|
65
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const $l={name:"minus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}]]};$l.node;const Uy=Se($l);/**
|
|
67
|
-
* @license lucide-react v1.48.0 - ISC
|
|
68
|
-
*
|
|
69
|
-
* This source code is licensed under the ISC license.
|
|
70
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const Bl={name:"plug",size:24,node:[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]};Bl.node;const Ky=Se(Bl);/**
|
|
72
|
-
* @license lucide-react v1.48.0 - ISC
|
|
73
|
-
*
|
|
74
|
-
* This source code is licensed under the ISC license.
|
|
75
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const zl={name:"square-arrow-out-up-right",size:24,node:[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]],aliases:["arrow-up-right-from-square"]};zl.node;const Hy=Se(zl);/**
|
|
77
|
-
* @license lucide-react v1.48.0 - ISC
|
|
78
|
-
*
|
|
79
|
-
* This source code is licensed under the ISC license.
|
|
80
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const Ul={name:"users-round",size:24,node:[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]],aliases:["users-2"]};Ul.node;const Nr=Se(Ul);/**
|
|
82
|
-
* @license lucide-react v1.48.0 - ISC
|
|
83
|
-
*
|
|
84
|
-
* This source code is licensed under the ISC license.
|
|
85
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const Kl={name:"venetian-mask",size:24,node:[["path",{d:"M18 11c-1.5 0-2.5.5-3 2",key:"1fod00"}],["path",{d:"M4 6a2 2 0 0 0-2 2v4a5 5 0 0 0 5 5 8 8 0 0 1 5 2 8 8 0 0 1 5-2 5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3a8 8 0 0 0-5 2 8 8 0 0 0-5-2z",key:"d70hit"}],["path",{d:"M6 11c1.5 0 2.5.5 3 2",key:"136fht"}]]};Kl.node;const qy=Se(Kl),ba=16,Wy=280,Gy=180;function va(e,t,s){const r=Math.max(t,window.innerWidth-ba),o=Math.max(s,window.innerHeight-ba),a=Math.min(Math.max(e.width,t),r),i=Math.min(Math.max(e.height,s),o),c=Math.min(Math.max(e.x,0),Math.max(0,window.innerWidth-a)),d=Math.min(Math.max(e.y,0),Math.max(0,window.innerHeight-i));return{x:c,y:d,width:a,height:i}}function Yy(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}function Vy(e){const{title:t,geometry:s,onGeometryChange:r,onClose:o,onRestore:a,minWidth:i,minHeight:c,children:d,className:m}=e,u=l.useRef(null),h=i??Wy,p=c??Gy;l.useEffect(()=>{const y=()=>{const k=va(s,h,p);Yy(k,s)&&r(k)};return y(),window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[s,h,p,r]);const f=l.useRef(null);l.useEffect(()=>()=>{var y;return(y=f.current)==null?void 0:y.call(f)},[]);const g=l.useCallback((y,k)=>{var M;y.preventDefault();const j=u.current;if(!j)return;const C=j;(M=f.current)==null||M.call(f);const v=y.clientX,N=y.clientY,I=s;let D=I,T=0;function E(){T=0,C.style.left=`${D.x}px`,C.style.top=`${D.y}px`,C.style.width=`${D.width}px`,C.style.height=`${D.height}px`}function w(R){D=k(R.clientX-v,R.clientY-N,I),T||(T=requestAnimationFrame(E))}function A(){T&&cancelAnimationFrame(T),T=0,document.removeEventListener("pointermove",w),document.removeEventListener("pointerup",S),document.removeEventListener("pointercancel",S),f.current=null}function S(){A(),r(va(D,h,p))}document.addEventListener("pointermove",w),document.addEventListener("pointerup",S),document.addEventListener("pointercancel",S),f.current=A},[s,h,p,r]),x=l.useCallback(y=>{y.target.closest("button")||g(y,(k,j,C)=>({...C,x:C.x+k,y:C.y+j}))},[g]),b=l.useCallback(y=>{y.stopPropagation(),g(y,(k,j,C)=>({...C,width:Math.max(h,C.width+k),height:Math.max(p,C.height+j)}))},[g,h,p]);return hs.createPortal(n.jsxs(G.div,{ref:u,"data-slot":"floating-panel",role:"complementary","aria-label":t,initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.15,ease:[0,0,.2,1]},style:{left:s.x,top:s.y,width:s.width,height:s.height},className:z("bg-card border-border shadow-floating fixed z-40 flex flex-col overflow-hidden rounded-lg border",m),children:[n.jsxs("div",{onPointerDown:x,className:"border-border flex cursor-grab items-center gap-1 border-b px-3 py-2 select-none active:cursor-grabbing",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:t}),a?n.jsx(_,{variant:"ghost",size:"icon-sm","aria-label":"Restore",onClick:a,className:"text-muted-foreground hover:text-foreground",children:n.jsx(Ku,{})}):null,n.jsx(_,{variant:"ghost",size:"icon-sm","aria-label":"Close",onClick:o,className:"text-muted-foreground hover:text-foreground",children:n.jsx(He,{})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d}),n.jsx("div",{"aria-hidden":!0,onPointerDown:b,className:"absolute right-0 bottom-0 size-4 cursor-nwse-resize"})]}),document.body)}const en=["TOP","LEFT","BOTTOM","RIGHT"],Hs={TOP:"radial-gradient(20.7% 50% at 50% 0%, hsl(var(--brand) / 0.7) 0%, transparent 100%)",LEFT:"radial-gradient(16.6% 43.1% at 0% 50%, hsl(var(--brand) / 0.7) 0%, transparent 100%)",BOTTOM:"radial-gradient(20.7% 50% at 50% 100%, hsl(var(--brand) / 0.7) 0%, transparent 100%)",RIGHT:"radial-gradient(16.2% 41.2% at 100% 50%, hsl(var(--brand) / 0.7) 0%, transparent 100%)"},Qy="radial-gradient(75% 181.2% at 50% 50%, hsl(var(--brand)) 0%, transparent 100%)";function Hl({children:e,containerClassName:t,className:s,duration:r=1,clockwise:o=!0,...a}){const i=Ce(),[c,d]=l.useState(!1),[m,u]=l.useState("TOP");return l.useEffect(()=>{if(i||c)return;const h=setInterval(()=>{u(p=>{const f=en.indexOf(p),g=o?(f-1+en.length)%en.length:(f+1)%en.length;return en[g]})},r*1e3);return()=>clearInterval(h)},[c,i,r,o]),n.jsxs("button",{type:"button","data-slot":"hover-border-gradient",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:z("bg-muted/40 hover:bg-muted/20 relative flex h-min w-fit items-center justify-center overflow-visible rounded-md border border-transparent p-px transition duration-500",t),...a,children:[n.jsx("div",{className:z("bg-brand text-brand-foreground z-10 w-auto rounded-[inherit] px-4 py-2 text-sm font-medium",s),children:e}),n.jsx(G.div,{className:"absolute inset-0 z-0 flex-none overflow-hidden rounded-[inherit]",style:{filter:"blur(2px)"},initial:{background:Hs[m]},animate:{background:c?[Hs[m],Qy]:Hs[m]},transition:{ease:"linear",duration:i?0:r??1}}),n.jsx("div",{className:"bg-brand absolute inset-[2px] z-[1] flex-none rounded-[inherit]"})]})}function Xy({...e}){const{theme:t}=Ui();return n.jsx(Hu,{theme:t,className:"toaster group",icons:{success:n.jsx(fs,{className:"size-4"}),info:n.jsx(Hi,{className:"size-4"}),warning:n.jsx(Ki,{className:"size-4"}),error:n.jsx(nx,{className:"size-4"}),loading:n.jsx(wt,{})},style:{"--normal-bg":"var(--color-popover)","--normal-text":"var(--color-popover-foreground)","--normal-border":"var(--color-border)","--border-radius":"var(--radius)"},...e})}async function Jy(){var t;if(!Pe())return;const e=(t=window.electronAPI)==null?void 0:t.getShellLogExcerpt;if(typeof e=="function")try{const s=await e();return s&&s.length>0?s:void 0}catch{return}}const ql="root";function Wl(){return document.getElementById(ql)??document.body}const wa=2e4;class Ue extends Error{constructor(s,r){super(r);Jt(this,"reason");this.name="AppCaptureError",this.reason=s}}function Zy(){const e=typeof window<"u"?window.electronAPI:void 0;if(typeof(e==null?void 0:e.captureAppView)!="function")return null;const{captureAppView:t}=e;return()=>t()}function eb(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}function tb(){const e=[];for(const t of Array.from(document.body.children)){if(!(t instanceof HTMLElement)||t.id===ql)continue;const s=t.style.opacity;t.style.opacity="0",e.push(()=>{t.style.opacity=s})}return()=>{for(const t of e)t()}}async function nb(e){const t=await e().catch(s=>{throw new Ue("failed",`The desktop bridge threw: ${String(s)}`)});if(!t.ok)throw new Ue("failed",t.message);return{dataUrl:t.dataUrl,region:{left:0,top:0,width:window.innerWidth,height:window.innerHeight}}}async function sb(){let e;try{({snapdom:e}=await qu(()=>import("./snapdom-SRLjr6oU.js"),[]))}catch(r){const o=r instanceof Error?r.message:String(r);throw new Ue("unsupported",`Loading the screenshot library failed: ${o}`)}const t=Wl(),s=getComputedStyle(document.body).backgroundColor;try{const r=t.getBoundingClientRect();return{dataUrl:(await e.toPng(t,{backgroundColor:s})).src,region:{left:r.left,top:r.top,width:r.width,height:r.height}}}catch(r){const o=r instanceof Error?r.message:String(r);throw new Ue("failed",`Rendering the app to an image failed: ${o}`)}}async function rb(e){let t;const s=new Promise((r,o)=>{t=setTimeout(()=>{o(new Ue("failed",`The capture did not finish in ${wa}ms.`))},wa)});try{return await Promise.race([e,s])}finally{clearTimeout(t),e.catch(()=>{})}}async function ob(){const e=Zy(),t=tb();try{return await eb(),await rb(e?nb(e):sb())}finally{t()}}let tn=null;function Gl(){if(tn)return tn;const e=ob();tn=e;const t=()=>{tn===e&&(tn=null)};return e.then(t,t),e}function ab(){return Gl().then(e=>e.dataUrl)}function ib(){if(typeof window>"u")return;const{innerWidth:e,innerHeight:t,devicePixelRatio:s}=window;if(!(typeof e!="number"||typeof t!="number"))return{width:Math.round(e),height:Math.round(t),devicePixelRatio:typeof s=="number"?s:1}}function cb(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function lb(e){const t=ib(),s=typeof navigator<"u"?navigator.userAgent:void 0,r=typeof navigator<"u"?navigator.language:void 0,o=cb();return{theme:e,shell:Pe()?"desktop-app":"browser",...t?{viewport:t}:{},...s?{browser:s.slice(0,Wu)}:{},...r?{locale:r.slice(0,Ho)}:{},...o?{timezone:o.slice(0,Ho)}:{}}}function Es(e){return t=>()=>{e(),t()}}const db=2e3,ub=.8,mb=1400,hb=.6,Zn=6e5,is=1e4,fb=["image/webp","image/jpeg","image/png"],pb=/^data:image\/(webp|png|jpeg);base64,/;class St extends Error{constructor(s,r){super(r);Jt(this,"reason");this.name="ImageCompressError",this.reason=s}}function gb(e){return pb.test(e)&&e.length<=Zn}function xb(e){return new Promise((t,s)=>{const r=new Image,o=setTimeout(()=>{s(new St("unreadable",`Decoding timed out after ${is}ms.`))},is);r.onload=()=>{clearTimeout(o),t(r)},r.onerror=()=>{clearTimeout(o),s(new St("unreadable",`Could not decode the image at ${e.slice(0,32)}…`))},r.src=e})}function yb(e,t){for(const s of fb){const r=e.toDataURL(s,t);if(r.startsWith(`data:${s};base64,`))return r}throw new St("unsupported","This canvas produced no usable image encoding.")}function ja(e,t,s=db){const r=Math.min(1,s/Math.max(e,t));return{width:Math.max(1,Math.round(e*r)),height:Math.max(1,Math.round(t*r))}}function ka(e,t,s){const r=document.createElement("canvas");r.width=t.width,r.height=t.height;const o=r.getContext("2d");if(!o)throw new St("unsupported","This browser gave no 2d canvas context.");return o.drawImage(e,0,0,t.width,t.height),yb(r,s)}async function Ar(e){const t=typeof e=="string"?null:URL.createObjectURL(e);let s;try{s=await xb(t??e)}finally{t&&URL.revokeObjectURL(t)}const r=s.naturalWidth||s.width,o=s.naturalHeight||s.height;if(r<=0||o<=0)throw new St("unreadable","The image decoded to zero pixels.");let a=ka(s,ja(r,o),ub);if(a.length>Zn&&(a=ka(s,ja(r,o,mb),hb)),a.length>Zn)throw new St("too-large",`Compressed to ${a.length} characters, over the ${Zn} cap.`);return a}const bb=500;function vb(e=bb){const t=ce(),s=qi({coalesceMs:e,shouldFlush:()=>t.isMutating({mutationKey:Wi})===0});ue("config_changed",()=>{const r={queryKey:De.current()};s([r])})}const Yl="dorkbot",wb=["mesh","agent-paths"];function jb(e){var r,o;const t=(r=e==null?void 0:e.agents)==null?void 0:r.defaultDirectory;if(!t)return"";const s=((o=e==null?void 0:e.agents)==null?void 0:o.defaultAgent)||Yl;return`${t}/${s}`}function Vl(){var d;const e=Ie(),t=ie(),{data:s}=Oe(),{data:r}=be({queryKey:[...wb],queryFn:()=>t.listMeshAgentPaths(),staleTime:3e4}),o=((d=s==null?void 0:s.agents)==null?void 0:d.defaultAgent)||Yl,a=r==null?void 0:r.agents.find(m=>m.name===o),i=(a==null?void 0:a.projectPath)??jb(s);return{startSession:l.useCallback(()=>{a?e(ut({agentId:a.id})):i&&Gu(t,i).then(m=>e(m)).catch(m=>{Gi(t,m),ae.error("Could not open the conversation. Try again.")})},[e,i,a,t]),defaultAgentDir:i}}function kb(e){var t,s;return{pinned:e.pinned??[],groups:e.groups??[],muted:e.muted??[],sections:e.sections??{},gettingStarted:{retired:((t=e.gettingStarted)==null?void 0:t.retired)??[]},digest:{lastShownDate:(s=e.digest)==null?void 0:s.lastShownDate}}}function Sb(){const e=ce(),t=jn();ue("community_connections_changed",()=>{t&&e.invalidateQueries({queryKey:it.connections(t),exact:!0})})}function Ql(e){const t=ie(),s=e!==null&&e.status!=="pending",r=jn(s),o=(e==null?void 0:e.ref)??"";return be({queryKey:r?it.disconnectImpact(r,o):[...it.all,"owner","unresolved",o,"disconnect-impact"],queryFn:()=>Yi(r,()=>t.getCommunityDisconnectImpact(o)),enabled:s&&r!==null,staleTime:0,refetchOnMount:"always"})}function Xl(e){const t=e.flatMap(r=>r.displayName?[r.displayName]:[]),s=e.length-t.length;return s>0&&t.push(s===1?"an unnamed agent":`${s} unnamed agents`),t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function Jl(e,t){return t.length===0?null:t.length===1?t[0].displayName?`The agent you added from here, ${t[0].displayName}, will be removed from ${e}.`:`The agent you added from here will be removed from ${e}.`:`The ${t.length} agents you added from here will be removed from ${e}: ${Xl(t)}.`}function Zl(e){return`Any agents you added from here will be removed from ${e}.`}function ed(e,{remoteRevoked:t,agentsNotRemoved:s}){const r=Xl(s);return s.length===0?t?{tone:"success",message:`${e} is disconnected.`}:{tone:"warning",message:Cb(e)}:t?{tone:"warning",message:`Disconnected, but ${r} couldn’t be removed. Remove ${s.length===1?"it":"them"} under Agents on ${e}.`}:{tone:"warning",message:`Disconnected here, but ${e} couldn’t be reached. Remove ${r} and this DorkOS there.`}}function Cb(e){return`Disconnected here, but ${e} couldn’t be reached. Finish under Connected installations on ${e}.`}function Nt(){const e=ie(),t=ce(),s=l.useRef(new Set),r=l.useRef(new Set),{data:o,isLoading:a}=be({queryKey:De.current(),queryFn:()=>e.getConfig(),staleTime:Vi}),i=jl(a),c={completedSteps:[],skippedSteps:[],startedAt:null,dismissedAt:null,completedAt:null,runtimeDefaultSetAt:null},d=o!=null&&o.onboarding?{completedSteps:o.onboarding.completedSteps,skippedSteps:o.onboarding.skippedSteps,startedAt:o.onboarding.startedAt,dismissedAt:o.onboarding.dismissedAt,completedAt:o.onboarding.completedAt??null,runtimeDefaultSetAt:o.onboarding.runtimeDefaultSetAt}:c,m=d.completedAt!==null,u=d.dismissedAt!==null,p=!i&&o!==void 0&&!m&&!u,f=!i&&m&&!u,g=kn({mutationFn:C=>e.updateConfig({onboarding:C}),onSuccess:()=>{t.invalidateQueries({queryKey:De.all}).then(()=>{s.current.clear(),r.current.clear()})},onError:(C,v)=>{s.current.clear(),r.current.clear(),console.error("[onboarding] could not save progress",{fields:Object.keys(v),error:C}),ae.error("Couldn’t save your setup progress",{description:"Keep going. DorkOS tries again."})},meta:{suppressErrorToast:!0}});function x(C){const v=new Set([...d.completedSteps,...s.current]);v.has(C)||(s.current.add(C),g.mutate({completedSteps:[...v,C]}))}function b(C){const v=new Set([...d.skippedSteps,...r.current]);v.has(C)||(r.current.add(C),g.mutate({skippedSteps:[...v,C]}))}function y(){return g.mutateAsync({dismissedAt:new Date().toISOString()})}function k(){d.completedAt||g.mutate({completedAt:new Date().toISOString()})}function j(){d.startedAt||g.mutate({startedAt:new Date().toISOString()})}return{state:d,config:o,isLoading:i,isOnboardingComplete:m,isOnboardingDismissed:u,shouldShowOnboarding:p,shouldShowGettingStarted:f,completeStep:x,skipStep:b,dismiss:y,completeOnboarding:k,startOnboarding:j}}function Nb(e){const{shouldShowOnboarding:t,onboardingHiddenForSession:s}=e,r=t&&!s,[o,a]=l.useState(!1);return r&&!o&&a(!0),o&&!s}function Ab(){const e=Wr(),t=Lt(),s=Gr({strict:!1}).onboarding,r=qo(s)?s:"welcome",o=l.useRef(!1),a=Ae({select:m=>m.status==="idle"}),i=l.useRef(!1);l.useEffect(()=>{if(i.current||!a||(i.current=!0,qo(s)))return;const m=u=>({...u,onboarding:"welcome"});e==null||e({search:m,replace:!0})},[a,s,e]);const c=l.useCallback(m=>{const u=h=>({...h,onboarding:m});o.current=!0,e==null||e({search:u})},[e]),d=l.useCallback(m=>{if(o.current){t.history.back();return}const u=h=>({...h,onboarding:m});e==null||e({search:u})},[t,e]);return{stage:r,goToStage:c,goBack:d}}function Eb(e){const{done:t,overlayVisible:s}=e,r=Wr(),o=Gr({strict:!1}).onboarding;l.useEffect(()=>{if(!o||!t||s)return;const a=i=>({...i,onboarding:void 0});r==null||r({search:a,replace:!0})},[o,t,s,r])}function qs({onBack:e,onSkipAll:t}){return n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 sm:px-6",children:[n.jsx(_,{variant:"ghost",size:"sm",onClick:e,children:"Back"}),n.jsx(_,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground",children:"Skip all setup"})]})}const Ib="claude-code";function ko(e,t){return e.length===0?null:e.includes(t)?t:Yu.find(r=>e.includes(r))??e[0]}function Tb({readyTypes:e,settled:t,settleToken:s}){var b,y;const{data:r}=Oe(),o=Sn(),a=ce(),[i,c]=l.useState(null),[d,m]=l.useState(null),u=l.useRef(null),h=((b=r==null?void 0:r.executionDefaults)==null?void 0:b.runtime)??Ib,p=!!((y=r==null?void 0:r.onboarding)!=null&&y.runtimeDefaultSetAt),f=l.useCallback((k,j)=>{c(null),m(j),o.mutate(k,{onSuccess:()=>void a.invalidateQueries({queryKey:De.all}),onError:C=>{m(null),c(C.message||"Couldn’t save that. Try again.")}})},[o,a]);l.useEffect(()=>{if(!t||e.length===0||!r||p)return;const k=ko(e,h);k&&u.current!==s&&(u.current=s,f({onboarding:{runtimeDefaultSetAt:new Date().toISOString()},...k===h?{}:{runtimes:{default:k}}},k))},[t,s,e,r,p,h,f]);const g=l.useCallback(k=>{k!==(d??h)&&f({runtimes:{default:k},...p?{}:{onboarding:{runtimeDefaultSetAt:new Date().toISOString()}}},k)},[f,d,h,p]);return{runtime:d??((p||d!==null)&&r?h:null),current:d??h,choose:g,error:i}}const Rb=2200,Db=["Checking","your","setup"],Ob=["You’re","ready"],Mb=["Connect","your","first","runtime"],_b=["One","moment"];function Pb({onContinue:e,renderConnect:t,simulatedResult:s,simulatedDefaultRuntime:r}){const o=Ce(),a=Yr(),{data:i}=Qi(),{data:c}=Xi(),d=s??a.data,m=s!==void 0||a.isSuccess||a.isError,u=s===void 0&&a.isError,[h,p]=l.useState(!1);l.useEffect(()=>{const E=setTimeout(()=>p(!0),o?0:Rb);return()=>clearTimeout(E)},[o]);const f=h&&m?"done":"checking",g=i?Object.keys(i.capabilities):void 0,{readyTypes:x,notReadyTypes:b}=l.useMemo(()=>{if(!d)return{readyTypes:[],notReadyTypes:[]};const E=[],w=[];for(const A of Object.keys(d.runtimes))Ji(d,A,!0).state==="ready"||s===void 0&&Vu(c,A)?E.push(A):w.push(A);return{readyTypes:E,notReadyTypes:w}},[d,c,s]),y=x.length>0;l.useEffect(()=>{if(f!=="done"||u||!y)return;const E=w=>{if(w.key!=="Enter")return;const A=w.target;A!=null&&A.closest("input, textarea, [contenteditable], form")||e()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[f,u,y,e]);const k=f==="checking"?Db:u?_b:y?Ob:Mb,j=Tb({readyTypes:x,settled:f==="done"&&!u&&s===void 0,settleToken:a.dataUpdatedAt}),[C,v]=l.useState(null),I=(r?{runtime:C??r,current:C??r,choose:v,error:null}:null)??j,D=f==="checking"?"Looking for Claude Code, Codex, and OpenCode on your machine.":u?"Couldn’t check your setup.":y?Ub(x,I.runtime):"DorkOS runs Claude Code, Codex or OpenCode. Set one up in about a minute.",T=f==="checking";return n.jsxs(G.div,{className:"mx-auto flex w-full max-w-md flex-col items-center text-center",children:[n.jsx(G.div,{className:"mb-8",initial:o?!1:{opacity:0,scale:.8},animate:{opacity:T?.6:.9,scale:1},transition:{duration:.5},children:n.jsxs(G.div,{animate:T&&!o?{scale:[1,1.04,1],opacity:[.6,.8,.6]}:{scale:1,opacity:1},transition:T?{duration:2,repeat:1/0,ease:"easeInOut"}:{},children:[n.jsx(Ve,{size:104,className:"dark:hidden"}),n.jsx(Ve,{variant:"white",size:104,className:"hidden dark:block"})]})}),n.jsx($b,{words:k,reducedMotion:!!o}),n.jsx(Ee,{mode:"wait",children:n.jsx(G.p,{className:"text-muted-foreground mt-3 text-sm text-balance",initial:o?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:D},D)}),f==="done"&&!u&&y&&n.jsx(zb,{chosen:I.current,readyTypes:x,otherTypes:b,onChoose:I.choose}),I.error&&n.jsx("p",{className:"text-destructive mt-2 text-xs","data-testid":"default-runtime-error",children:I.error}),n.jsx(Ee,{children:T&&n.jsx(Bb,{},"scanning")}),f==="done"&&n.jsx("div",{className:"mt-8 w-full",children:u?n.jsx(Fb,{onRetry:()=>void a.refetch(),isRetrying:a.isFetching}):y?n.jsx(Lb,{onContinue:e,notReadyTypes:b,requirements:d,registeredTypes:g,renderConnect:t,onRecheck:()=>void a.refetch(),isRechecking:a.isFetching,reducedMotion:!!o}):n.jsx(G.div,{initial:o?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"text-left",children:n.jsx(Zi,{requirements:d,registeredTypes:g,renderConnect:t,onRecheck:()=>void a.refetch(),isRechecking:a.isFetching})})})]})}function Lb({onContinue:e,notReadyTypes:t,requirements:s,registeredTypes:r,renderConnect:o,onRecheck:a,isRechecking:i,reducedMotion:c}){const[d,m]=l.useState(!1),u=t.length;return n.jsxs(G.div,{className:"flex flex-col items-center",initial:c?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.35},children:[n.jsx(Hl,{className:"px-6 py-2",duration:1.2,onClick:e,autoFocus:!0,"data-testid":"onboarding-get-started",children:"Meet DorkBot"}),u>0&&n.jsxs(ps,{open:d,onOpenChange:m,className:"mt-8 w-full",children:[n.jsxs(gs,{className:"text-muted-foreground hover:text-foreground mx-auto inline-flex items-center gap-1.5 text-xs transition-colors",children:[n.jsx(mt,{className:z("size-3.5 transition-transform",d&&"rotate-180")}),`${u} more to set up`]}),n.jsxs(xs,{className:"mt-4 space-y-3 text-left",children:[n.jsx(Zi,{types:t,requirements:s,registeredTypes:r,renderConnect:o,onRecheck:a,isRechecking:i}),n.jsx("p",{className:"text-muted-foreground text-center text-xs",children:"Add these anytime from the status bar."})]})]})]})}function Fb({onRetry:e,isRetrying:t}){return n.jsxs("div",{className:"flex flex-col items-center gap-3",role:"alert",children:[n.jsx("p",{className:"text-muted-foreground text-sm text-balance",children:"Couldn’t reach the DorkOS server. Check that it’s running, then try again."}),n.jsxs(_,{variant:"outline",className:"gap-2",onClick:e,disabled:t,children:[n.jsx(xr,{className:z("size-3.5",t&&"animate-spin")}),"Try again"]})]})}function $b({words:e,reducedMotion:t}){return n.jsx(Ee,{mode:"wait",children:n.jsx(G.h1,{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:t?e.join(" "):n.jsx(G.span,{initial:"hidden",animate:"visible",exit:"exit",variants:{visible:{transition:{staggerChildren:.08}},exit:{transition:{staggerChildren:.02,staggerDirection:-1}}},children:e.map((s,r)=>n.jsxs(G.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"},exit:{opacity:0,filter:"blur(4px)"}},transition:{duration:.3},children:[s,r<e.length-1?" ":""]},r))})},e.join("-"))})}function Bb(){const e=Ce();return n.jsxs(G.div,{className:"mt-8 flex flex-col items-center gap-4 py-2",initial:e?!1:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25},"data-testid":"requirements-checking",children:[n.jsx("div",{className:"flex items-center gap-1.5",children:[0,1,2].map(t=>n.jsx(G.div,{className:"bg-muted-foreground/40 size-2 rounded-full",animate:e?{}:{scale:[1,1.5,1],opacity:[.3,1,.3]},transition:{duration:1.2,repeat:1/0,delay:t*.2,ease:"easeInOut"}},t))}),n.jsx("span",{className:"text-muted-foreground text-sm",children:"Scanning…"})]})}function zb({chosen:e,readyTypes:t,otherTypes:s,onChoose:r}){const[o,a]=l.useState(!1),i=[...t,...s];return i.includes(e)||i.unshift(e),n.jsxs(Cn,{open:o,onOpenChange:a,children:[n.jsxs(Nn,{className:"text-muted-foreground hover:text-foreground mt-1 inline-flex items-center gap-1 text-xs underline-offset-2 transition-colors hover:underline","data-testid":"default-runtime-change",children:["Change",n.jsx(mt,{className:"size-3"})]}),n.jsxs(An,{align:"center",className:"p-1",children:[n.jsx(En,{children:"Start new chats with"}),n.jsx("div",{className:"flex flex-col",role:"listbox","aria-label":"Start new chats with",children:i.map(c=>{const d=c===e;return n.jsxs("button",{type:"button",role:"option","aria-selected":d,onClick:()=>{r(c),a(!1)},className:"hover:bg-accent flex items-center justify-between gap-3 rounded-md px-3 py-2.5 text-left text-sm transition-colors","data-testid":`default-runtime-option-${c}`,children:[n.jsxs("span",{className:"flex flex-col",children:[n.jsx("span",{children:Ye(c).label}),!t.includes(c)&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Not connected yet"})]}),d&&n.jsx(Ft,{className:"size-3.5 shrink-0","aria-hidden":!0})]},c)})})]})]})}function Ub(e,t){const s=e.map(c=>Ye(c).label),r=s.length===0?"Ready to go.":s.length===1?`${s[0]} is connected.`:s.length===2?`${s[0]} and ${s[1]} are connected.`:`${s.slice(0,-1).join(", ")}, and ${s[s.length-1]} are connected.`;if(!t)return r;if(e.length===1&&e[0]===t)return`${r} New chats will start with it.`;const o=Ye(t).label;if(e.includes(t))return`${r} New chats will start with ${o}.`;const a=ko(e,t),i=a?Ye(a).label:null;return i?`${r} New chats use ${i} until ${o} is connected.`:`${r} New chats will start with ${o} once it’s connected.`}function Kb(){var m;const e=ie(),t=ce(),{data:s}=be({queryKey:De.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),r=((m=s==null?void 0:s.mesh)==null?void 0:m.scanRoots)??[],o=(s==null?void 0:s.boundary)??"",a=r.length>0?r:o?[o]:[],{mutate:i,isPending:c}=kn({mutationKey:Wi,mutationFn:async u=>{await e.updateConfig({mesh:{scanRoots:u}})},onSuccess:()=>{t.invalidateQueries({queryKey:De.all})}}),d=l.useCallback(u=>i(u),[i]);return{roots:a,boundary:o,isSaving:c,setScanRoots:d}}const Hb=[{queryKey:["mesh"]},{queryKey:["agents"]},{queryKey:["team"]}],qb=400;function Wb(e=qb){const t=qi({coalesceMs:e});ue("agents_changed",()=>t(Hb))}function Gb(){const e=ce();ue("capabilities_changed",()=>{e.invalidateQueries({queryKey:ec.all})})}function Yb(){const e=ie(),t=ce();return kn({mutationFn:({agentId:s,key:r,surface:o})=>e.patchAgentPermissions(s,{...r.kind==="area"?{areas:{[r.area]:null}}:{},...r.kind==="action"?{actions:{[r.action]:null}}:{},...r.kind==="files"?{filesAndCommands:null}:{},surface:o}),onSettled:()=>{t.invalidateQueries({queryKey:ec.all}),t.invalidateQueries({queryKey:["mesh","agents"]})}})}function Sa(e){return e instanceof Error&&e.message||"Couldn’t save that. Try again."}const Vb=[{lead:"Edits and commands run without asking.",rest:"Agents still ask when something needs your call."},{lead:"Your instructions still hold.",rest:"If you told an agent to check first, it does."},{lead:"Agents reach across projects.",rest:"They can message agents in your other projects too."},{lead:"Approvals can stick.",rest:"Always allow remembers your yes for that agent and action."},{lead:"Scheduled runs use your power level.",rest:"Timed runs get the same freedom."}];function td({heading:e,onClose:t,onCustomize:s}){const r=Sn(),o=hx(),a=Qu({kind:"default"}),i=ce(),[c,d]=l.useState(!1),[m,u]=l.useState(null),[h,p]=l.useState(!1),f=c||r.isPending||o.isPending||a.isPending,g=l.useCallback(()=>{i.invalidateQueries({queryKey:De.all})},[i]),x=l.useCallback(async()=>{u(null),p(!1),d(!0);const C=new Date().toISOString();try{await r.mutateAsync({ui:{autonomyAcknowledgedAt:C,fullPowerDecidedAt:C,fullPowerChoice:"full"},runtimes:{defaultTrustStop:"autonomy"}}),await a.mutateAsync({kind:"preset",preset:"full",surface:"first-run"})}catch(v){u(Sa(v)),d(!1);return}g();try{await o.mutateAsync(!0)}catch{p(!0),d(!1);return}d(!1),t()},[r,a,o,g,t]),b=l.useCallback(async()=>{u(null),d(!0);try{await r.mutateAsync({ui:{fullPowerDecidedAt:new Date().toISOString(),fullPowerChoice:"supervised"}}),await a.mutateAsync({kind:"preset",preset:"careful",surface:"first-run"})}catch(C){return u(Sa(C)),d(!1),!1}return g(),d(!1),!0},[r,a,g]),y=l.useCallback(async()=>{await b()&&t()},[b,t]),k=l.useCallback(async()=>{await b()&&(s==null||s(),t())},[b,s,t]),j=l.useCallback(async()=>{d(!0);try{await o.mutateAsync(!0)}catch{d(!1);return}p(!1),d(!1),t()},[o,t]);return h?n.jsxs(n.Fragment,{children:[n.jsxs(yr,{children:[n.jsx(br,{children:"Full power is on"}),n.jsx(vr,{children:"One step didn’t finish."})]}),n.jsx("p",{role:"alert",className:"text-muted-foreground text-sm",children:"Agents can’t message other projects yet. Full power stays on."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Try again now, or later from Settings."}),n.jsxs(wr,{className:"items-center gap-2 sm:justify-end",children:[n.jsx(_,{variant:"outline",size:"sm",onClick:t,disabled:f,children:"Close"}),n.jsx(_,{size:"sm",onClick:j,disabled:f,children:"Try again"})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs(yr,{children:[n.jsx(br,{"data-testid":"full-power-door",children:e}),n.jsx(vr,{children:"Agents stop asking before each action. Here’s what changes:"})]}),n.jsx("ul",{className:"space-y-2 text-sm",children:Vb.map(C=>n.jsxs("li",{className:"flex items-start gap-2",children:[n.jsx(Ot,{className:"text-status-success mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("span",{children:[n.jsx("span",{className:"font-medium",children:C.lead})," ",n.jsx("span",{children:C.rest})]})]},C.lead))}),n.jsx(Xu,{mode:"bypassPermissions"}),s&&n.jsx("div",{children:n.jsx(_,{variant:"link",size:"sm",className:"text-muted-foreground h-auto p-0 text-left whitespace-normal",onClick:k,disabled:f,children:"Pick the pieces yourself"})}),n.jsxs(wr,{className:"items-center gap-2 sm:justify-between",children:[m?n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:m}):n.jsx("span",{"aria-hidden":!0}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(_,{variant:"outline",size:"sm",onClick:y,disabled:f,children:"Keep asking me first"}),n.jsxs(_,{size:"sm",onClick:x,disabled:f,className:z("bg-status-success dark:text-status-success-bg text-white","hover:bg-status-success/90 focus-visible:ring-status-success","focus-visible:ring-offset-background focus-visible:ring-offset-2"),children:[n.jsx(Ot,{"aria-hidden":!0}),"Unlock full power"]})]})]})]})}function Qb({onClose:e}){const t=B(s=>s.setControlCenterOpen);return n.jsx(td,{heading:"DorkOS runs at full power",onClose:e,onCustomize:()=>t(!0)})}function Xb({onAdvance:e}){const{completeStep:t,skipStep:s}=Nt(),r=l.useCallback(()=>{t("power"),e()},[t,e]),o=l.useCallback(()=>{s("power"),e()},[s,e]);return n.jsx(tc,{open:!0,modal:!1,children:n.jsxs("div",{className:"flex w-full max-w-lg flex-col items-center gap-3",children:[n.jsx("div",{className:"bg-background grid w-full gap-4 rounded-lg border p-6 shadow-lg",children:n.jsx(td,{heading:"Choose your power level",onClose:r})}),n.jsx(_,{variant:"ghost",size:"sm",className:"text-muted-foreground",onClick:o,"data-testid":"onboarding-power-decide-later",children:"Decide later"})]})})}const Ws=["Welcome","to","DorkOS"],Jb=[{icon:rt,label:"Build your team"},{icon:Sl,label:"Ask for tools"},{icon:Cl,label:"Connect services"}];function Zb({onGetStarted:e,onSkipAll:t}){const s=Ce();return n.jsxs("div",{className:"mx-auto flex w-full max-w-md flex-col items-center px-4 text-center",children:[n.jsxs(G.div,{className:"mb-6 opacity-80",initial:s?!1:{opacity:0,scale:.8},animate:{opacity:.8,scale:1},transition:{duration:.4},children:[n.jsx(Ve,{size:150,className:"dark:hidden"}),n.jsx(Ve,{variant:"white",size:150,className:"hidden dark:block"})]}),n.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:s?Ws.join(" "):n.jsx(G.span,{initial:"hidden",animate:"visible",variants:{visible:{transition:{staggerChildren:.08}}},children:Ws.map((r,o)=>n.jsxs(G.span,{className:"inline-block",variants:{hidden:{opacity:0,filter:"blur(4px)"},visible:{opacity:1,filter:"blur(0px)"}},transition:{duration:.4},children:[r,o<Ws.length-1?" ":""]},o))})}),n.jsx(G.p,{className:"text-muted-foreground mt-4",initial:s?!1:{opacity:0},animate:{opacity:1},transition:{delay:.4,duration:.5},children:"Build and run your business with an agent team."}),n.jsx(G.div,{className:"mt-10 flex gap-8",initial:s?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:.6,duration:.4},children:Jb.map(({icon:r,label:o},a)=>n.jsxs("div",{className:"flex flex-col items-center gap-2",children:[n.jsx("div",{className:"bg-muted flex size-10 items-center justify-center rounded-lg",children:n.jsx(r,{className:"text-muted-foreground size-5"})}),n.jsx("span",{className:"text-muted-foreground text-xs",children:o})]},a))}),n.jsxs(G.div,{className:"mt-12 flex flex-col items-center gap-3",initial:s?!1:{opacity:0},animate:{opacity:1},transition:{delay:.8,duration:.4},children:[n.jsx(Hl,{className:"px-6 py-2",duration:1.2,onClick:e,children:"Get started"}),n.jsx(_,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground",children:"Skip all setup"})]})]})}const ev=50,nn=["room_created","room_updated","room_member_added","room_member_removed","room_activity"];function Ca(e){if(typeof e!="object"||e===null)return!1;const{roomId:t}=e;return typeof t=="string"&&t.length>0}function tv(e){if(typeof e!="object"||e===null)return!1;const{userId:t,threadKind:s,threadId:r,lastReadSeq:o,unreadCount:a}=e;return s==="room"&&typeof t=="string"&&t.length>0&&typeof r=="string"&&r.length>0&&typeof o=="number"&&typeof a=="number"}function nv(e,t){const s=e.getQueryData(Te.detail(t.threadId));return s===void 0||s.viewerAuthorId===t.userId}function sv(e,t){const s=e.isFetching({queryKey:Te.lists()})>0;e.cancelQueries({queryKey:Te.lists()}),e.setQueriesData({queryKey:Te.lists()},o=>Array.isArray(o)?o.map(a=>a.id===t.threadId&&a.unreadCount!==null?{...a,unreadCount:Math.min(a.unreadCount,t.unreadCount)}:a):o),e.setQueryData(Te.detail(t.threadId),o=>o&&{...o,members:o.members.map(a=>a.authorId===t.userId?{...a,lastReadSeq:Math.max(a.lastReadSeq,t.lastReadSeq)}:a)});const r=e.getQueryData(Te.threads());r!=null&&r.some(o=>o.roomId===t.threadId&&o.unreadCount>0)&&e.invalidateQueries({queryKey:Te.threads()}),s&&e.invalidateQueries({queryKey:Te.lists()})}function rv(){const e=ce(),t=()=>{e.invalidateQueries({queryKey:Te.lists()}),e.invalidateQueries({queryKey:Te.wellKnowns()}),e.invalidateQueries({queryKey:Te.threads()})};ue(nn[0],t),ue(nn[1],t),ue(nn[2],t),ue(nn[3],t),ue(nn[4],t),ue("room_updated",o=>{Ca(o)&&e.invalidateQueries({queryKey:Te.detail(o.roomId)})});const s=l.useRef(new Set),r=o=>{if(!Ca(o))return;const a=s.current;if(a.has(o.roomId))return;a.add(o.roomId);const i=o.roomId;setTimeout(()=>{a.delete(i),e.invalidateQueries({queryKey:Te.detail(i)})},ev)};ue("room_member_added",r),ue("room_member_removed",r),ue("room_presence",o=>Ju.getState().observe(o)),ue("read_cursor",o=>{!tv(o)||!nv(e,o)||sv(e,o)})}function ov(){const e=ie(),t=B(o=>o.selectedCwd),s=B(o=>o.setSelectedCwd),{data:r}=be({queryKey:["defaultCwd"],queryFn:()=>e.getDefaultCwd(),enabled:t===null,staleTime:1/0,refetchOnMount:!1,refetchOnReconnect:!1,networkMode:"always"});l.useEffect(()=>{r!=null&&r.path&&B.getState().selectedCwd===null&&s(r.path)},[r,t,s])}function Na(e){e.invalidateQueries({queryKey:$t.recentRoot})}function Aa(e){e.invalidateQueries({queryKey:$t.dailyCountsRoot})}function av(e,t){const s=Object.keys(e);return s.length!==Object.keys(t).length?!0:s.some(r=>!(r in t))}function iv(e,t){e.setQueryData($t.list(t.cwd??null),s=>{const r=s??[];return(r.some(a=>a.id===t.id)?r.map(a=>a.id===t.id?t:a):[t,...r]).sort((a,i)=>i.updatedAt.localeCompare(a.updatedAt))})}function cv(e,t,s){e.setQueryData($t.list(s),r=>r&&r.filter(o=>o.id!==t))}function Ea(e,t,s){const r=new Set(Object.keys(t).filter(o=>!(o in s)));r.size!==0&&e.setQueriesData({queryKey:$t.listRoot},o=>o!=null&&o.some(a=>r.has(a.id))?o.flatMap(a=>{if(!r.has(a.id))return[a];const i=t[a.id];return o.some(d=>d.id===i)?[]:[{...a,id:i}]}):o)}function Ia(e,t,s){const r=Date.now(),o=[];for(const[a,i]of Object.entries(t))s[a]!==i&&(iv(e,i),o.push(i));em(e,o,r);for(const[a,i]of Object.entries(s))t[a]||cv(e,a,i.cwd??null)}function lv(){const e=ce();l.useEffect(()=>{Zu();let t={},s={};const r=ct.subscribe(i=>{i.sessions!==t&&(Ia(e,i.sessions,t),Na(e),av(i.sessions,t)&&Aa(e),t=i.sessions),i.rekeys!==s&&(Ea(e,i.rekeys,s),s=i.rekeys)}),o=rs.subscribeEvent("session_list_invalidated",()=>{ct.getState().dropSessions(),e.invalidateQueries({queryKey:$t.listRoot}),Na(e),Aa(e)}),a=ct.getState();return Object.keys(a.sessions).length>0&&(Ia(e,a.sessions,t),t=a.sessions),Object.keys(a.rekeys).length>0&&(Ea(e,a.rekeys,s),s=a.rekeys),rs.connectList(),()=>{r(),o()}},[e])}function dv(){const e=ce();ue("tasks_changed",()=>{e.invalidateQueries({queryKey:[...tm],exact:!0})})}const uv={reactions:!1,threads:!1,runWith:!1,attachments:!1,mentions:!1,streamHealth:!1,presence:!1,turnStatus:!1,asks:!1};function mv({sessionId:e}){l.useEffect(()=>{var a;const r=ct.getState(),o=((a=r.sessions[e])==null?void 0:a.cwd)??r.statusCwds[e]??null;return rs.pinSession(e,o),Wo.getState().setPinnedSession(e),()=>{rs.unpinSession(),Wo.getState().setPinnedSession(null)}},[e]);const t=nm(e),s=l.useMemo(()=>sm(t),[t]);return s===null?n.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-4 text-center text-sm",children:"No live widget in this session"}):n.jsx(rm,{code:s.code,isIncomplete:s.isIncomplete,sessionId:e,isLatestMessage:s.isLatest,isStreaming:s.isStreaming},s.sourceMessageKey)}const Ta="inbox",hv="open";function fv({blocked:e=!1}={}){const t=ys()[Ta],s=Wr(),r=t!==void 0,o=t==null?"":String(t).trim();l.useEffect(()=>{!r||!s||(o&&!e&&om(void 0,o===hv?void 0:{focus:o}),s({search:a=>({...a,[Ta]:void 0}),replace:!0}))},[r,o,e,s]),l.useEffect(()=>{e&&am()},[e])}function pv({agentName:e,className:t}){var c;const s=nc(),r=e.trim()||"This agent";if(s.isPending)return n.jsx("p",{className:z("text-muted-foreground text-center text-xs",t),"data-testid":"every-agent-access-checking",children:"Checking apps every agent can use…"});if(s.isError)return n.jsxs("p",{className:z("text-muted-foreground text-xs",t),"data-testid":"every-agent-access-unknown",children:["Couldn’t check apps shared with every agent. ",r," gets them too."]});const o=((c=s.data)==null?void 0:c.connections)??[];if(o.length===0)return null;const a=new Map;for(const d of o)a.set(d.toolkit,(a.get(d.toolkit)??0)+1);const i=o.map(d=>{const m=(a.get(d.toolkit)??0)>1?`${Go(d.toolkit)} · ${d.label}`:Go(d.toolkit),u=im(d.access.classifications);return`${m} (${d.lifecycle==="paused"?`${u}, paused`:u})`});return n.jsxs("div",{className:z("bg-muted/40 flex items-start gap-3 rounded-xl px-4 py-3 text-sm",t),"data-testid":"every-agent-access-notice",children:[n.jsx(Vr,{className:"text-muted-foreground mt-0.5 size-4 shrink-0","aria-hidden":!0}),n.jsxs("p",{className:"min-w-0 flex-1",children:[n.jsxs("span",{className:"font-medium",children:[r," will get:"]})," ",i.join(", "),"."," ",n.jsx("span",{className:"text-muted-foreground",children:"You can change this in Connections."})]})]})}function gv(){const e=ce();ue("relay_bindings_changed",()=>{e.invalidateQueries({queryKey:[...cm]})})}function xv(){const e=ce();ue("commands_changed",()=>{e.invalidateQueries({queryKey:["commands"]})})}function yv({message:e,grouping:t,author:s}){const r=l.useId(),o=`${r}-author`,a=`${r}-content`,i=t.position==="first"||t.position==="only";return n.jsxs(Zt.Root,{position:t.position,"data-testid":"message-item",...i?{"aria-labelledby":o}:{"aria-label":s.displayName},"aria-describedby":a,className:"hover:bg-transparent",children:[n.jsx(Zt.Gutter,{author:s}),n.jsxs(Zt.Body,{children:[n.jsx(Zt.Author,{id:o,author:s}),n.jsx(Zt.Content,{id:a,children:n.jsx("div",{className:"msg-prose",children:n.jsx(lm,{content:e.content})})})]})]})}const bv=4e3;function So(){var o;const e=Qr(),{identityPromptDismissedAt:t,isLoading:s}=In();if(s||e.isPending)return"pending";if(t!==null)return"settled";const r=(o=e.data)==null?void 0:o.members.find(a=>a.isSelf);return r&&lx(r)?"ask":"settled"}function vv(){const{state:e,isLoading:t,shouldShowGettingStarted:s}=Nt(),r=So(),{dismissIdentityPrompt:o}=In(),[a,i]=l.useState("ask");l.useEffect(()=>{if(a!=="saved")return;const u=setTimeout(()=>i("done"),bv);return()=>clearTimeout(u)},[a]);const c=e.completedAt!==null||e.dismissedAt!==null,d=!t&&c&&r==="ask"&&!s,m=()=>{o().catch(()=>{})};return{visible:a!=="done"&&(d||a==="saved"),phase:a,markSaved:()=>{i("saved"),m()},skip:()=>{i("done"),m()}}}const Co=[{id:"arrival",lines:[...oe.arrival],composerEnabled:!1},{id:"identity",lines:[...oe.identityPrompt],widget:"identity",composerEnabled:!1},{id:"personality",lines:[oe.personalityPrompt],widget:"personality",composerEnabled:!1},{id:"profile",lines:[...oe.profilePrompt],widget:"profile",composerEnabled:!1},{id:"discovery",lines:[oe.discoveryPrompt],widget:"discovery",composerEnabled:!1},{id:"handoff",lines:[oe.handoffPrompt],composerEnabled:!0}];function Ra(e){const t=Co.find(s=>s.id===e);if(!t)throw new Error(`Unknown onboarding beat: ${e}`);return t}function wv(e,t,s){return{id:e,role:t,content:s,parts:[{type:"text",text:s}],timestamp:new Date().toISOString()}}function jv(e){const t=[];for(let s=0;s<e.length;s++){const r=e[s].role,o=s>0&&e[s-1].role===r,a=s<e.length-1&&e[s+1].role===r;let i;!o&&!a?i="only":o?a?i="middle":i="last":i="first",t.push({position:i})}return t}const kv=420,Sv=680,Cv={stage:"first-light",beatIndex:0,revealed:[],queue:[],isTyping:!1,idCounter:0,saving:!1,saveError:!1,discoveryPhase:"unasked"};function Gs(e,t){let s=e.idCounter;const r=t.map(o=>wv(`ob-line-${s++}`,"assistant",o));return{queue:[...e.queue,...r],idCounter:s}}function Nv(e){return Co.findIndex(t=>t.id===e)}function Av(e,t){switch(t.type){case"begin":return e.stage==="talking"?e:{...e,stage:"talking",...Gs(e,Ra("arrival").lines)};case"reveal-one":{if(e.queue.length===0)return e;const[s,...r]=e.queue;return{...e,revealed:[...e.revealed,s],queue:r,isTyping:!1}}case"drain":return e.queue.length===0?{...e,isTyping:!1}:{...e,revealed:[...e.revealed,...e.queue],queue:[],isTyping:!1};case"start-typing":return e.queue.length===0?e:{...e,isTyping:!0};case"saving":return{...e,saving:!0,saveError:!1};case"save-error":return{...e,saving:!1,saveError:!0};case"goto-beat":{const s=Ra(t.beatId);return{...e,beatIndex:Nv(t.beatId),saving:!1,discoveryPhase:"unasked",...Gs(e,[...t.extraLines,...s.lines])}}case"discovery-scanning":return{...e,discoveryPhase:"scanning"};case"discovery-results":return{...e,discoveryPhase:"results",...Gs(e,[t.line])};default:return e}}function Ev(e){const[t,s]=l.useReducer(Av,Cv),r=l.useRef(e);l.useEffect(()=>{r.current=e});const o=Co[t.beatIndex],a=t.queue.length===0&&!t.isTyping;l.useEffect(()=>{if(t.queue.length===0)return;if(r.current.reducedMotion){s({type:"drain"});return}if(t.isTyping){const w=setTimeout(()=>s({type:"reveal-one"}),Sv);return()=>clearTimeout(w)}const E=setTimeout(()=>s({type:"start-typing"}),kv);return()=>clearTimeout(E)},[t.queue.length,t.isTyping]);const i=e.identityQuestion;l.useEffect(()=>{t.stage!=="talking"||o.id!=="arrival"||!a||i!=="pending"&&s({type:"goto-beat",beatId:i==="ask"?"identity":"personality",extraLines:[]})},[t.stage,o.id,a,i]);const c=l.useRef(!1);l.useEffect(()=>{o.id==="handoff"&&!c.current&&(c.current=!0,r.current.completeOnboarding())},[o.id]);const d=l.useCallback(()=>s({type:"begin"}),[]),m=l.useCallback(()=>s({type:"drain"}),[]),u=l.useCallback(()=>{r.current.closeIdentityQuestion(),s({type:"goto-beat",beatId:"personality",extraLines:[oe.identitySaved]})},[]),h=l.useCallback(()=>{r.current.closeIdentityQuestion(),s({type:"goto-beat",beatId:"personality",extraLines:[oe.identitySkip]})},[]),p=l.useCallback(E=>{s({type:"saving"}),r.current.saveTraits(E).then(()=>{r.current.completeStep("meet-dorkbot"),s({type:"goto-beat",beatId:"profile",extraLines:[]})}).catch(()=>s({type:"save-error"}))},[]),f=l.useCallback(()=>{r.current.skipStep("meet-dorkbot"),s({type:"goto-beat",beatId:"profile",extraLines:[oe.personalitySkip]})},[]),g=l.useCallback(E=>{s({type:"saving"}),r.current.saveProfile(E).then(()=>{r.current.completeStep("profile");const w=Dx(dm(E));s({type:"goto-beat",beatId:"discovery",extraLines:w?[w]:[]})}).catch(()=>s({type:"save-error"}))},[]),x=l.useCallback(()=>{r.current.skipStep("profile"),s({type:"goto-beat",beatId:"discovery",extraLines:[oe.profileSkip]})},[]),b=l.useCallback(()=>s({type:"discovery-scanning"}),[]),y=l.useCallback(()=>{r.current.skipStep("discovery"),s({type:"goto-beat",beatId:"handoff",extraLines:[oe.discoveryDecline]})},[]),k=l.useCallback(E=>{s({type:"discovery-results",line:Ox(E)})},[]),j=l.useCallback(()=>{r.current.completeStep("discovery"),s({type:"goto-beat",beatId:"handoff",extraLines:[oe.discoveryZero]})},[]),C=l.useCallback(()=>{r.current.skipStep("discovery"),s({type:"goto-beat",beatId:"handoff",extraLines:[oe.discoveryTimeout]})},[]),v=l.useCallback(()=>{r.current.completeStep("discovery"),s({type:"goto-beat",beatId:"handoff",extraLines:[]})},[]),N=l.useCallback(E=>{r.current.onDissolve(E)},[]),I=l.useMemo(()=>jv(t.revealed),[t.revealed]),D=t.stage==="talking"&&a&&o.widget?o.widget:null,T=t.stage==="talking"&&o.composerEnabled&&a;return{isFirstLight:t.stage==="first-light",messages:t.revealed,grouping:I,isTyping:t.isTyping,isRevealing:t.queue.length>0||t.isTyping,beatId:o.id,activeWidget:D,composerEnabled:T,discoveryPhase:t.discoveryPhase,saving:t.saving,saveError:t.saveError,beginConversation:d,fastForward:m,confirmIdentity:u,skipIdentity:h,confirmPersonality:p,skipPersonality:f,confirmProfile:g,skipProfile:x,consentDiscovery:b,declineDiscovery:y,reportDiscoveryResults:k,reportDiscoveryZero:j,reportDiscoveryTimeout:C,finishDiscovery:v,submitFirstMessage:N}}function nd(){const e=ie(),t=l.useRef(null),{startScan:s,addCandidate:r,addExistingAgent:o,setProgress:a,completeScan:i,setError:c}=bs(),d=l.useCallback((u={roots:[]})=>{var p;(p=t.current)==null||p.abort();const h=new AbortController;t.current=h,s(),e.scan(u,f=>{switch(f.type){case"candidate":r(f.data);break;case"existing-agent":o(f.data);break;case"progress":a(f.data);break;case"complete":i(f.data);break;case"error":c(f.data.error);break}},h.signal).catch(f=>{f instanceof Error&&f.name!=="AbortError"&&c(f.message)})},[e,s,r,o,a,i,c]),m=l.useCallback(()=>{var u;(u=t.current)==null||u.abort(),t.current=null},[]);return{startScan:d,stopScan:m}}function sd(){const[e,t]=l.useState(new Set),s=l.useCallback(o=>{t(a=>new Set(a).add(o))},[]),r=l.useCallback(()=>{t(new Set)},[]);return{actedPaths:e,markActed:s,resetActed:r}}function rd({register:e,onSuccess:t}){const s=l.useRef(new Set),[r,o]=l.useState(new Set),[a,i]=l.useState(new Set),c=l.useCallback(async m=>{if(!s.current.has(m.path)){s.current.add(m.path),o(u=>new Set(u).add(m.path)),i(u=>{const h=new Set(u);return h.delete(m.path),h});try{await e(m),t(m)}catch{i(u=>new Set(u).add(m.path))}finally{s.current.delete(m.path),o(u=>{const h=new Set(u);return h.delete(m.path),h})}}},[t,e]),d=l.useCallback(()=>i(new Set),[]);return{failedPaths:a,pendingPaths:r,registerCandidate:c,resetFailures:d}}function od(e){return{name:e.hints.suggestedName,runtime:e.hints.detectedRuntime,...e.hints.inferredCapabilities?{capabilities:e.hints.inferredCapabilities}:{},...e.hints.description?{description:e.hints.description}:{}}}function ad(e){return[...e].sort((t,s)=>{const r=t.strategy==="dork-manifest",o=s.strategy==="dork-manifest";return r!==o?r?-1:1:t.path.localeCompare(s.path)})}const Iv={"claude-code":"Has an AGENTS.md file, so it’s a Claude Code project.",cursor:"Has a .cursor folder, so it’s a Cursor project.",codex:"Has a .codex folder, so it’s a Codex project.","dork-manifest":"Has a .dork/agent.json file, so it’s already a DorkOS agent."};function Tv(e){return Iv[e]??`Found by the “${e}” check.`}const Rv={"code-review":"Reviews code for bugs, style issues, and correctness.",summarize:"Summarizes documents, conversations, or code.","file-ops":"Reads and writes files on the filesystem.",test:"Generates and runs tests for a codebase.",search:"Searches code, files, or the web for relevant information.",refactor:"Refactors code while preserving existing behavior.",analyze:"Analyzes data, logs, or codebases for patterns and insights.",generate:"Generates code, content, or structured output.",debug:"Diagnoses and fixes bugs in code.",deploy:"Manages deployment pipelines and infrastructure changes."};function Dv(e){return Rv[e]??"Found in the project’s files."}function id({candidate:e,onApprove:t,onDeny:s,onSkip:r,registrationFailed:o=!1,registrationPending:a=!1,className:i,ref:c}){const{path:d,strategy:m,hints:u}=e;return n.jsxs(G.div,{ref:c,"data-slot":"candidate-card","aria-busy":a,layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.15,ease:"easeOut"},className:z("flex items-start justify-between rounded-xl border p-4",i),children:[n.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[n.jsx("p",{className:"truncate text-sm leading-tight font-semibold",title:u.suggestedName||d.split("/").pop()||d,children:u.suggestedName||d.split("/").pop()||d}),n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[n.jsx(um,{className:"size-3 shrink-0"}),n.jsx("span",{className:"truncate font-mono",title:d,children:d})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsxs(Yx,{openDelay:300,children:[n.jsx(Vx,{asChild:!0,children:n.jsx(fn,{variant:"secondary",className:"hover:bg-secondary/80 cursor-default",children:u.detectedRuntime})}),n.jsxs(Qx,{className:"w-56 space-y-1.5 p-3",side:"top",align:"start",children:[n.jsx("p",{className:"text-xs font-medium",children:"How DorkOS knows"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:Tv(m)})]})]}),u.inferredCapabilities&&u.inferredCapabilities.length>0&&u.inferredCapabilities.map(h=>n.jsxs(Bt,{children:[n.jsx(zt,{asChild:!0,children:n.jsx(fn,{size:"xs",variant:"outline",className:"cursor-default",children:h})}),n.jsx(Ut,{side:"top",className:"max-w-48 text-center",children:Dv(h)})]},h))]}),o&&n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t add this project. Try again."})]}),n.jsxs("div",{className:"ml-4 flex shrink-0 items-center gap-1.5",children:[n.jsx("button",{type:"button",onClick:()=>t(e),disabled:a,className:"focus-visible:ring-ring rounded-md bg-green-600/10 px-2.5 py-1 text-xs font-medium text-green-700 hover:bg-green-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:text-green-400",children:a?"Adding…":o?"Try again":"Add"}),r&&n.jsx("button",{type:"button",onClick:()=>r(e),disabled:a,className:"text-muted-foreground hover:bg-muted focus-visible:ring-ring rounded-md px-2.5 py-1 text-xs font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",children:"Skip"}),s&&n.jsx("button",{type:"button",onClick:()=>s(e),disabled:a,className:"focus-visible:ring-ring rounded-md bg-red-600/10 px-2.5 py-1 text-xs font-medium text-red-700 hover:bg-red-600/20 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 dark:text-red-400",children:"Deny"})]})]})}function Ov({agent:e}){return n.jsxs("div",{className:"bg-muted/50 flex items-center gap-3 rounded-lg border px-4 py-3",children:[n.jsx(fs,{className:"text-muted-foreground size-4 shrink-0"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-sm font-medium",children:ke(e)}),n.jsx("p",{className:"text-muted-foreground truncate text-xs",children:e.path})]}),n.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:"Imported"})]})}const Mv=2;function _v({agents:e}){const[t,s]=l.useState(e.length<=Mv);return e.length===0?null:n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>s(r=>!r),className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-1.5 py-1.5 text-xs transition-colors",children:[n.jsx(Tn,{className:z("size-3 transition-transform",t&&"rotate-90")}),e.length," project",e.length===1?"":"s"," already in DorkOS"]}),t&&n.jsx("div",{className:"mt-2 space-y-2",children:e.map(r=>n.jsx(Ov,{agent:r},r.path))})]})}function cd({count:e,onAddAll:t,disabled:s}){return e===0?null:n.jsxs("div",{className:"flex items-center justify-between py-1",children:[n.jsxs("span",{className:"text-muted-foreground text-sm font-medium",children:[e," new project",e===1?"":"s"]}),n.jsx(_,{variant:"outline",size:"sm",onClick:t,disabled:s,children:"Add all"})]})}function Pv({roots:e,onChange:t}){const[s,r]=l.useState(""),[o,a]=l.useState(!1),i=l.useCallback(u=>{const h=u.trim();h&&!e.includes(h)&&t([...e,h])},[e,t]),c=l.useCallback(u=>{t(e.filter(h=>h!==u))},[e,t]),d=l.useCallback(u=>{(u.key==="Enter"||u.key===",")&&(u.preventDefault(),s.trim()&&(i(s),r(""))),u.key==="Backspace"&&s===""&&e.length>0&&c(e[e.length-1])},[s,e,i,c]),m=l.useCallback(u=>{i(u)},[i]);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"focus-within:ring-ring flex min-h-[40px] flex-wrap items-center gap-1.5 rounded-md border bg-transparent px-3 py-1.5 focus-within:ring-2",children:[e.map(u=>n.jsxs(fn,{variant:"secondary",className:"gap-1 py-0.5 font-mono",children:[u,n.jsx("button",{type:"button",onClick:()=>c(u),className:"hover:bg-muted-foreground/20 ml-0.5 rounded-sm","aria-label":`Remove ${u}`,children:n.jsx(He,{className:"size-3"})})]},u)),n.jsx("input",{type:"text",value:s,onChange:u=>r(u.target.value),onKeyDown:d,placeholder:e.length===0?"Type a folder, then press Enter":"Add more…",className:"placeholder:text-muted-foreground min-w-[120px] flex-1 bg-transparent text-sm focus-visible:outline-none"}),n.jsx("button",{type:"button",onClick:()=>a(!0),className:"text-muted-foreground hover:bg-accent hover:text-foreground shrink-0 rounded p-1","aria-label":"Browse for a folder",children:n.jsx(vs,{className:"size-4"})})]}),n.jsx(sc,{open:o,onOpenChange:a,onSelect:m})]})}const Lv=8e3;function Fv({phase:e,onConsent:t,onDecline:s,onResults:r,onZero:o,onTimeout:a,onDone:i}){const{startScan:c}=nd(),{candidates:d,isScanning:m,lastScanAt:u,error:h}=bs(),{mutateAsync:p}=rc(),{actedPaths:f,markActed:g}=sd(),x=l.useCallback(T=>p({path:T.path,overrides:od(T)}),[p]),b=l.useCallback(T=>g(T.path),[g]),{failedPaths:y,pendingPaths:k,registerCandidate:j}=rd({register:x,onSuccess:b}),C=l.useRef(!1),v=l.useCallback(()=>{C.current=!1,t(),c()},[t,c]);l.useEffect(()=>{if(e!=="scanning")return;const T=setTimeout(()=>{C.current||(C.current=!0,a())},Lv);return()=>clearTimeout(T)},[e,a]),l.useEffect(()=>{if(!(e!=="scanning"||C.current)){if(h){C.current=!0,a();return}!m&&u!==null&&(C.current=!0,d.length>0?r(d.length):o())}},[e,m,u,h,d.length,r,o,a]);const I=l.useMemo(()=>ad(d),[d]).filter(T=>!f.has(T.path)),D=l.useCallback(()=>{for(const T of I)j(T)},[I,j]);return e==="unasked"?n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(_,{size:"sm",onClick:v,children:"Sure, look around"}),n.jsx(_,{size:"sm",variant:"outline",onClick:s,children:"Not now"})]}):e==="scanning"?n.jsxs("div",{className:"text-muted-foreground flex items-center gap-2 text-sm","aria-live":"polite",children:[n.jsx(pn,{className:"size-4"}),"Looking…",n.jsx(vl,{})]}):n.jsxs("div",{className:"flex w-full flex-col gap-3",children:[n.jsx("div",{className:"flex flex-col gap-2",children:n.jsx(Ee,{mode:"popLayout",children:I.map(T=>n.jsx(id,{candidate:T,registrationFailed:y.has(T.path),registrationPending:k.has(T.path),onApprove:E=>void j(E),onSkip:E=>g(E.path)},T.path))})}),I.length>0&&n.jsx(cd,{count:I.length,onAddAll:D,disabled:k.size>0}),n.jsx("div",{className:"flex justify-start",children:n.jsx(_,{size:"sm",onClick:i,children:"Done"})})]})}function Hn({children:e}){return n.jsx(mm,{gap:"none",className:"bg-card/50",children:e})}const $v=1500,Bv=4e3,It="dorkbot",qn="DorkBot",Ys="var(--color-muted-foreground)",Da="";function zv({onComplete:e}){var K,ne;const t=Ce()??!1,s=Ie(),{config:r,completeStep:o,skipStep:a,completeOnboarding:i}=Nt(),c=hm(),{defaultAgentDir:d}=Vl(),{data:m}=Rn(),u=l.useMemo(()=>((m==null?void 0:m.agents)??[]).map(W=>W.projectPath),[m]),{data:h}=ws(u),p=l.useMemo(()=>{const W=u.map(we=>h==null?void 0:h[we]).find(we=>(we==null?void 0:we.isSystem)===!0);if(!W)return null;const{color:le,emoji:ve}=js(W);return{id:W.id,color:le,emoji:ve}},[u,h]),f=((K=r==null?void 0:r.executionDefaults)==null?void 0:K.runtime)??"claude-code",{data:g}=Yr(),x=l.useMemo(()=>{if(!g)return f;const W=Object.keys(g.runtimes).filter(le=>Ji(g,le,!0).state==="ready");return W.length===0||W.includes(f)?f:ko(W,f)??f},[g,f]),[b,y]=l.useState({...fm}),[k,j]=l.useState([]),{saveRoles:C,dismissIdentityPrompt:v}=In(),N=So(),[I,D]=l.useState(""),T=l.useRef(!1),E=(ne=r==null?void 0:r.agents)==null?void 0:ne.defaultDirectory,w=E?`${E}/dorkbot`:null,S=Ev({reducedMotion:t,identityQuestion:N,closeIdentityQuestion:()=>{v().catch(()=>{})},saveTraits:W=>w?c.mutateAsync({path:w,updates:{traits:W}}).then(()=>{}):Promise.reject(new Error("DorkBot’s location is still loading. Try again in a moment.")),saveProfile:W=>C(W),completeStep:o,skipStep:a,completeOnboarding:i,onDissolve:W=>{const le=crypto.randomUUID(),ve={kind:"first-message",name:It,displayName:qn,agentId:(p==null?void 0:p.id)??It,icon:(p==null?void 0:p.emoji)??Da,color:(p==null?void 0:p.color)??Ys,bornAt:new Date().toISOString(),path:d,runtime:x,kickoffMessage:W};oc.getState().register(le,ve),pm().then(we=>{setTimeout(we,Bv)}),s(ut({agentId:(p==null?void 0:p.id)??It,draft:"1",session:le,runtime:x})),e()}}),{beginConversation:M}=S;l.useEffect(()=>{const W=setTimeout(M,t?0:$v);return()=>clearTimeout(W)},[M,t]);const R=l.useRef(null);l.useEffect(()=>{var W,le;(le=(W=R.current)==null?void 0:W.scrollIntoView)==null||le.call(W,{behavior:t?"auto":"smooth"})},[S.messages.length,S.isTyping,S.activeWidget,t]);const O=l.useCallback(()=>{const W=I.trim();!W||T.current||(T.current=!0,S.submitFirstMessage(W))},[I,S]),P=B(W=>W.requestTour),F=l.useCallback(()=>{T.current||(T.current=!0,i(),P("general"),e())},[i,P,e]),{fastForward:V}=S,Z=l.useCallback(W=>{(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),V())},[V]),H=S.isRevealing?{role:"button",tabIndex:0,"aria-label":"Reveal the rest of the message",onClick:V,onKeyDown:Z}:{},ee=l.useMemo(()=>p?{id:p.id,displayName:qn,emoji:p.emoji,color:p.color}:{id:It,displayName:qn,color:Ys},[p]),te=l.useMemo(()=>({name:It,displayName:qn,agentId:(p==null?void 0:p.id)??It,icon:(p==null?void 0:p.emoji)??Da,color:(p==null?void 0:p.color)??Ys,bornAt:new Date().toISOString(),path:d,runtime:f,kickoffMessage:"",fired:!1}),[p,d,f]);if(S.isFirstLight)return n.jsx("div",{className:"flex h-full w-full items-center justify-center p-4",children:n.jsx(bx,{record:te})});const se=S.composerEnabled?oe.composerHandoffPlaceholder:oe.composerSetupPlaceholder;let L="That’s the one";S.saving?L="Saving…":S.saveError&&(L="Try again");let q="That’s us";return S.saving?q="Saving…":S.saveError&&(q="Try again"),n.jsxs("div",{className:"mx-auto flex h-full w-full max-w-2xl flex-col",children:[n.jsxs("div",{className:"min-h-0 flex-1 cursor-default overflow-y-auto px-2 py-4",...H,children:[n.jsxs("div",{className:"flex flex-col gap-1","aria-live":"polite","aria-atomic":"false",children:[n.jsx(Hx.Root,{surface:"session",capabilities:uv,children:S.messages.map((W,le)=>n.jsx(yv,{message:W,grouping:S.grouping[le],author:vx(W,{agent:ee})},W.id))}),S.isTyping&&n.jsx("div",{className:"px-1 py-2",children:n.jsx(vl,{})})]}),S.activeWidget==="identity"&&n.jsx("div",{className:"mt-3 px-1",children:n.jsx(Hn,{children:n.jsx(vo,{onSaved:S.confirmIdentity,confirmLabel:"That’s me",onSkip:S.skipIdentity,skipLabel:"Skip this"})})}),S.activeWidget==="personality"&&n.jsx("div",{className:"mt-3 px-1",children:n.jsx(Hn,{children:n.jsxs("div",{className:"flex flex-col items-stretch gap-3",children:[n.jsx(Wx,{traits:b,onTraitsChange:y,layout:"stacked",sampleLabel:"How DorkBot talks"}),S.saveError&&n.jsx("p",{className:"text-destructive text-sm",role:"alert","data-testid":"personality-save-error",children:oe.saveError}),n.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[n.jsx(_,{size:"sm",onClick:()=>S.confirmPersonality(b),disabled:S.saving,"data-testid":"confirm-personality",children:L}),n.jsx(_,{size:"sm",variant:"outline",onClick:S.skipPersonality,disabled:S.saving,"data-testid":"skip-personality",children:"Skip this step"})]})]})})}),S.activeWidget==="profile"&&n.jsx("div",{className:"mt-3 px-1",children:n.jsx(Hn,{children:n.jsx(Xr,{selected:k,onChange:j,onConfirm:()=>S.confirmProfile(k),confirmLabel:q,onSkip:S.skipProfile,skipLabel:"Skip this",busy:S.saving,error:S.saveError?oe.saveError:null})})}),S.activeWidget==="discovery"&&n.jsx("div",{className:"mt-3 px-1",children:n.jsx(Hn,{children:n.jsx(Fv,{phase:S.discoveryPhase,onConsent:S.consentDiscovery,onDecline:S.declineDiscovery,onResults:S.reportDiscoveryResults,onZero:S.reportDiscoveryZero,onTimeout:S.reportDiscoveryTimeout,onDone:S.finishDiscovery})})}),n.jsx("div",{ref:R})]}),n.jsx("div",{className:"shrink-0 px-2 pb-3",children:S.composerEnabled?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mb-2 flex flex-wrap gap-1.5",children:[n.jsx(_,{size:"xs",variant:"outline",onClick:F,children:"Show me around"}),["Help me set up a project","Just exploring for now"].map(W=>n.jsx(_,{size:"xs",variant:"outline",onClick:()=>D(W),children:W},W))]}),n.jsx(qx.Input,{value:I,onChange:D,onSubmit:O,isStreaming:!1,placeholder:se})]}):n.jsx("div",{className:"border-input bg-muted/40 text-muted-foreground flex items-center rounded-md border px-3 py-2.5 text-sm","aria-disabled":"true",children:se})})]})}function Uv({onComplete:e,renderRuntimeConnect:t}){const{stage:s,goToStage:r,goBack:o}=Ab(),{dismiss:a,startOnboarding:i}=Nt(),{open:c}=qe(),d=l.useRef(!1);l.useEffect(()=>{d.current||(d.current=!0,i())},[i]);const m=l.useCallback(async()=>{await a(),ae("Setup skipped",{description:"Replay it anytime in Settings → Preferences.",action:{label:"Replay setup",onClick:()=>c("preferences")}}),e()},[a,e,c]),u=l.useCallback(()=>r("requirements"),[r]),h=l.useCallback(()=>r("power"),[r]),p=l.useCallback(()=>r("conversation"),[r]),f=l.useCallback(()=>o("welcome"),[o]),g=l.useCallback(()=>o("requirements"),[o]),x=l.useCallback(()=>o("power"),[o]);return s==="welcome"?n.jsx("div",{className:"bg-background h-full w-full overflow-y-auto",children:n.jsx("div",{className:"flex min-h-full w-full items-center justify-center p-4",children:n.jsx(Zb,{onGetStarted:u,onSkipAll:m})})}):s==="requirements"?n.jsxs("div",{className:"bg-background flex h-full w-full flex-col",children:[n.jsx(qs,{onBack:f,onSkipAll:m}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:n.jsx("div",{className:"flex min-h-full w-full items-center justify-center p-4 pb-10",children:n.jsx(Pb,{onContinue:h,renderConnect:t})})})]}):s==="power"?n.jsxs("div",{className:"bg-background flex h-full w-full flex-col",children:[n.jsx(qs,{onBack:g,onSkipAll:m}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:n.jsx("div",{className:"flex min-h-full w-full items-center justify-center p-4 pb-10",children:n.jsx(Xb,{onAdvance:p})})})]}):n.jsxs("div",{className:"bg-background flex h-full w-full flex-col",children:[n.jsx(qs,{onBack:x,onSkipAll:m}),n.jsx("div",{className:"min-h-0 flex-1",children:n.jsx(zv,{onComplete:e})})]})}const Kv=4e3,Vs="Tell DorkBot your name",Oa="Tell DorkBot about your work";function Hv({onDismiss:e}){const t=Ce(),s=Ie(),{open:r}=qe(),o=ks(),a=B(D=>D.requestTour),{startSession:i}=Vl(),{roles:c,rolePromptDismissedAt:d,isLoading:m,saveRoles:u,dismissIdentityPrompt:h}=In(),p=So(),[f,g]=l.useState("closed"),[x,b]=l.useState("closed"),[y,k]=l.useState([]),j=!m&&c.length===0&&d===null;l.useEffect(()=>{if(f!=="saved")return;const D=setTimeout(()=>g("closed"),Kv);return()=>clearTimeout(D)},[f]);const C=()=>{g("saved"),h().catch(()=>{})},v=()=>{b("saving"),u(y).then(()=>b("closed")).catch(()=>b("error"))};let N="Save";x==="saving"?N="Saving…":x==="error"&&(N="Try again");const I=[{icon:Kt,label:"Talk to DorkBot",onClick:i},...p==="ask"||f==="saved"?[{icon:kl,label:Vs,onClick:()=>g(D=>D==="saved"?D:D==="closed"?"open":"closed"),expanded:f!=="closed"}]:[],...j?[{icon:Jr,label:Oa,onClick:()=>b(D=>D==="closed"?"open":"closed"),expanded:x!=="closed"}]:[],{icon:Fy,label:"Show me around",onClick:()=>a("general")},{icon:Ht,label:"Create an agent",onClick:()=>Ss.getState().open("new")},{icon:ac,label:"Schedule a task",onClick:()=>s({...pe.tasks()})},{icon:ic,label:"Connect more runtimes",onClick:()=>r("runtimes")},{icon:Ky,label:"Connect a service",onClick:()=>o()}];return n.jsxs(G.div,{initial:t?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3},className:"border-border bg-card relative rounded-lg border p-3",children:[n.jsx("button",{onClick:e,className:"text-muted-foreground/50 hover:text-muted-foreground absolute top-1.5 right-1.5 rounded-md p-0.5 transition-colors duration-150","aria-label":"Dismiss getting started",children:n.jsx(He,{className:"size-3.5"})}),n.jsx("h3",{className:"mb-2 text-xs font-medium",children:"Getting started"}),n.jsx("ul",{className:"space-y-0.5",children:I.map(({icon:D,label:T,onClick:E,expanded:w})=>n.jsxs("li",{children:[n.jsxs("button",{onClick:E,className:"hover:bg-accent group flex w-full items-center gap-2 rounded-md px-1.5 py-1 text-left transition-colors duration-150","aria-expanded":w,children:[n.jsx(D,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("span",{className:"text-foreground flex-1 text-xs",children:T}),n.jsx(Tn,{className:"text-muted-foreground/40 group-hover:text-muted-foreground size-3.5 shrink-0 transition-colors"})]}),T===Vs&&f==="open"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-identity-form",children:n.jsx(vo,{onSaved:C})}),T===Vs&&f==="saved"&&n.jsx("p",{role:"status",className:"text-muted-foreground px-1.5 py-2 text-xs",children:oe.identityCardSaved}),T===Oa&&x!=="closed"&&n.jsx("div",{className:"px-1.5 py-2","data-testid":"progress-card-profile-picker",children:n.jsx(Xr,{selected:y,onChange:k,onConfirm:v,confirmLabel:N,busy:x==="saving",error:x==="error"?oe.saveError:null})})]},T))})]})}const qv="pl-12";function Wv({prompt:e}){const t=Ce(),{open:s}=qe(),{phase:r,selected:o,setSelected:a,confirmLabel:i,errorMessage:c}=e;return n.jsxs(G.div,{initial:t?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},role:"group","aria-label":"DorkBot suggestion","data-testid":"profile-prompt-card",className:"bg-secondary/60 flex flex-col gap-2 rounded-lg border p-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsxs("span",{className:"mt-0.5 shrink-0",children:[n.jsx(Ve,{size:40,className:"dark:hidden"}),n.jsx(Ve,{variant:"white",size:40,className:"hidden dark:block"})]}),n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("p",{className:"text-sm leading-relaxed",children:r==="saved"?oe.profileSaved:oe.profileCardPrompt[0]}),n.jsxs("p",{className:"text-muted-foreground text-xs leading-relaxed",children:[oe.profileCardPrompt[1]," ",n.jsx("button",{type:"button",onClick:()=>s("profile"),className:"focus-visible:ring-ring hover:text-foreground rounded-sm underline underline-offset-2 focus-visible:ring-2 focus-visible:outline-none",children:"Change it in Settings"}),"."]})]})]}),r!=="saved"&&n.jsx("div",{className:qv,children:n.jsx(Xr,{selected:o,onChange:a,onConfirm:e.save,confirmLabel:i,onSkip:e.skip,skipLabel:"Don’t ask again",busy:r==="saving",error:c})})]})}const Gv=4e3;function Yv(){const{state:e,isLoading:t,shouldShowGettingStarted:s}=Nt(),{roles:r,rolePromptDismissedAt:o,isLoading:a,saveRoles:i,dismissRolePrompt:c}=In(),[d,m]=l.useState([]),[u,h]=l.useState("ask");l.useEffect(()=>{if(u!=="saved")return;const b=setTimeout(()=>h("done"),Gv);return()=>clearTimeout(b)},[u]);const p=e.completedAt!==null||e.dismissedAt!==null,f=!e.completedSteps.includes("profile")&&!e.skippedSteps.includes("profile"),g=!t&&!a&&p&&r.length===0&&f&&o===null&&!s;let x="Save";return u==="saving"?x="Saving…":u==="error"&&(x="Try again"),{visible:u!=="done"&&(g||u==="saved"),phase:u,selected:d,setSelected:m,confirmLabel:x,errorMessage:u==="error"?oe.saveError:null,save:()=>{h("saving"),i(d).then(()=>h("saved")).catch(()=>h("error"))},skip:()=>{h("done"),c().catch(()=>{})}}}function Vv({prompt:e}){const t=Ce(),s=e.phase==="saved";return n.jsxs(G.div,{initial:t?!1:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},role:"group","aria-label":"DorkBot suggestion","data-testid":"identity-prompt-card",className:"bg-secondary/60 flex flex-col gap-3 rounded-lg border p-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsxs("span",{className:"mt-0.5 shrink-0",children:[n.jsx(Ve,{size:40,className:"dark:hidden"}),n.jsx(Ve,{variant:"white",size:40,className:"hidden dark:block"})]}),n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsx("p",{className:"text-sm leading-relaxed",role:s?"status":void 0,children:s?oe.identityCardSaved:oe.identityCardPrompt[0]}),!s&&n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:oe.identityCardPrompt[1]})]})]}),!s&&n.jsx(vo,{onSaved:e.markSaved,onSkip:e.skip,skipLabel:"Don’t ask again"})]})}function Qv(e,t){let s;for(const r of t){const o=r.endsWith("/")?r.slice(0,-1):r;(e===o||e.startsWith(o+"/"))&&(!s||o.length>s.length)&&(s=o)}return s}function Xv(){return n.jsxs("svg",{viewBox:"0 0 240 120",className:"mx-auto h-24 w-48","aria-hidden":"true",children:[n.jsx("path",{d:"M15 25 L33 25 L37 33 L60 33 L60 77 L15 77 Z",className:"fill-none stroke-current",strokeWidth:"1.5"}),n.jsx("rect",{x:"23",y:"44",width:"16",height:"2",rx:"1",className:"fill-current opacity-40"}),n.jsx("rect",{x:"23",y:"50",width:"26",height:"2",rx:"1",className:"fill-current opacity-20"}),n.jsx("rect",{x:"23",y:"56",width:"20",height:"2",rx:"1",className:"fill-current opacity-20"}),n.jsx("path",{d:"M180 25 L198 25 L202 33 L225 33 L225 77 L180 77 Z",className:"fill-none stroke-current",strokeWidth:"1.5"}),n.jsx("rect",{x:"188",y:"44",width:"20",height:"2",rx:"1",className:"fill-current opacity-40"}),n.jsx("rect",{x:"188",y:"50",width:"14",height:"2",rx:"1",className:"fill-current opacity-20"}),n.jsx("rect",{x:"188",y:"56",width:"24",height:"2",rx:"1",className:"fill-current opacity-20"}),n.jsx("circle",{cx:"120",cy:"48",r:"18",className:"fill-none stroke-current",strokeWidth:"2"}),n.jsx("line",{x1:"133",y1:"61",x2:"148",y2:"76",className:"stroke-current",strokeWidth:"3",strokeLinecap:"round"}),n.jsx("path",{d:"M110 38 Q114 33 120 32",className:"fill-none stroke-current opacity-30",strokeWidth:"1.5",strokeLinecap:"round"}),n.jsx("line",{x1:"63",y1:"55",x2:"102",y2:"50",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"}),n.jsx("line",{x1:"138",y1:"50",x2:"177",y2:"55",className:"stroke-current opacity-40",strokeWidth:"1.5",strokeDasharray:"4 3"})]})}const Jv=[{name:"claude-code",signal:"AGENTS.md",label:"Claude Code project"},{name:"cursor",signal:".cursor/",label:"Cursor project"},{name:"codex",signal:".codex/",label:"Codex project"},{name:"dork",signal:".dork/agent.json",label:"DorkOS agent (auto-imported)"}];function Zv({fullBleed:e=!1,onRegistered:t}){var q;const{roots:s,setScanRoots:r}=Kb(),[o,a]=l.useState(null),[i,c]=l.useState(!1),[d,m]=l.useState(3),{startScan:u}=nd(),{candidates:h,existingAgents:p,isScanning:f,progress:g,error:x,lastScanAt:b}=bs(),{mutateAsync:y}=rc(),{mutate:k}=gm(),{data:j}=xm(),{actedPaths:C,markActed:v,resetActed:N}=sd(),I=o??s,D=l.useCallback(K=>y({path:K.path,overrides:od(K),scanRoot:Qv(K.path,I)}),[I,y]),T=l.useCallback(K=>{v(K.path),t==null||t()},[v,t]),{failedPaths:E,pendingPaths:w,registerCandidate:A,resetFailures:S}=rd({register:D,onSuccess:T});function M(K){a(K),r(K)}function R(){I.length>0&&(N(),S(),u({roots:I,maxDepth:d}))}const P=l.useMemo(()=>f?h:ad(h),[h,f]).filter(K=>!C.has(K.path)),F=(((q=j==null?void 0:j.agents)==null?void 0:q.length)??0)>0,V=p.length>0,Z=h.length>0,H=V||Z,ee=!f&&b!==null,te=!f&&b===null;function se(){for(const K of P)A(K)}const L=n.jsxs("div",{children:[n.jsxs("button",{type:"button",onClick:()=>c(!i),className:"text-muted-foreground hover:text-foreground flex items-center gap-1 text-xs",children:[n.jsx(mt,{className:`size-3 transition-transform ${i?"":"-rotate-90"}`}),"Advanced"]}),i&&n.jsxs("div",{className:"bg-muted/30 mt-2 space-y-3 rounded-lg border p-3",children:[n.jsx(Pv,{roots:I,onChange:M}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("label",{htmlFor:"scan-depth",className:"text-muted-foreground text-xs",children:"Scan depth"}),n.jsx("input",{id:"scan-depth",type:"range",min:1,max:5,value:d,onChange:K=>m(Number(K.target.value)),className:"flex-1"}),n.jsx("span",{className:"min-w-[1.5rem] text-center text-xs font-medium",children:d})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs("p",{className:"text-muted-foreground flex items-center gap-1 text-xs",children:[n.jsx($y,{className:"size-3"}),"What it looks for"]}),n.jsx("ul",{className:"space-y-1 pl-4",children:Jv.map(K=>n.jsxs("li",{className:"flex items-baseline gap-1.5",children:[n.jsx("code",{className:"text-foreground/70 text-3xs",children:K.signal}),n.jsxs("span",{className:"text-muted-foreground text-3xs",children:["→ ",K.label]})]},K.name))})]})]})]});return n.jsx("div",{className:e?"flex h-full flex-col p-6":"space-y-4 p-4",children:te?n.jsx("div",{className:e?"flex flex-1 items-center justify-center":"",children:n.jsxs("div",{className:e?"w-full max-w-sm space-y-5":"space-y-5",children:[n.jsx(Xv,{}),n.jsxs("div",{className:"text-center",children:[n.jsx("p",{className:"text-foreground text-sm font-medium",children:"Find your existing projects"}),n.jsx("p",{className:"text-muted-foreground mx-auto mt-1 max-w-[300px] text-xs leading-relaxed",children:"Find Claude Code, Cursor, Codex and other AI projects on this computer."})]}),x&&n.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive rounded-lg border px-4 py-3 text-sm",children:x}),n.jsxs(_,{onClick:R,disabled:I.length===0,className:"w-full",children:[n.jsx(pn,{className:"size-4"}),"Search for projects"]}),n.jsx("p",{className:"text-muted-foreground/60 text-center text-xs",children:"Read-only scan. Nothing changes until you approve"}),L]})}):n.jsxs(n.Fragment,{children:[e&&n.jsxs("div",{className:"mb-4 space-y-1",children:[n.jsx("h2",{className:"text-lg font-semibold",children:"Bring in existing projects"}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Search for existing projects to bring into DorkOS."})]}),n.jsxs("div",{className:"space-y-3",children:[L,n.jsxs(_,{onClick:R,disabled:f||I.length===0,children:[f?n.jsx(wt,{}):n.jsx(pn,{className:"size-4"}),"Search for projects"]})]}),n.jsxs("div",{className:e?"mt-4 flex-1 overflow-y-auto":"",children:[f&&n.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 p-8",children:[n.jsx(wt,{size:"md",className:"text-muted-foreground",label:"Searching for projects"}),g&&n.jsxs("div",{className:"text-muted-foreground space-y-0.5 text-center text-xs",children:[n.jsxs("p",{children:["Scanned ",g.scannedDirs," directories"]}),n.jsxs("p",{children:["Found ",g.foundAgents," project",g.foundAgents===1?"":"s"]})]})]}),x&&n.jsx("div",{className:"border-destructive/30 bg-destructive/5 text-destructive mb-3 rounded-lg border px-4 py-3 text-sm",children:x}),ee&&!Z&&V&&n.jsxs("div",{className:"rounded-xl border border-dashed p-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium",children:"All projects already added"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"See them on the Agents tab."})]}),ee&&!H&&n.jsxs("div",{className:"rounded-xl border border-dashed p-8 text-center",children:[n.jsx("p",{className:"text-sm font-medium",children:F?"No new projects found":"No projects found"}),n.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:F?"They’re already added. See the Agents tab.":"Try a deeper scan or other folders."})]}),ee&&P.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(cd,{count:P.length,onAddAll:se,disabled:w.size>0}),n.jsx(Ee,{mode:"popLayout",children:P.map(K=>n.jsx(id,{candidate:K,className:"mb-2",registrationFailed:E.has(K.path),registrationPending:w.has(K.path),onApprove:ne=>void A(ne),onSkip:ne=>v(ne.path),onDeny:ne=>k({path:ne.path},{onSuccess:()=>v(ne.path)})},K.path))})]}),ee&&V&&n.jsx("div",{className:"mt-3",children:n.jsx(_v,{agents:p})})]})]})})}function ew(){const e=gn(p=>p.isOpen),t=gn(p=>p.close),s=Ie(),[r,o]=l.useState(0),[a,i]=l.useState(!1),[c,d]=l.useState(!1);e!==c&&(d(e),e&&(o(0),i(!1)));function m(p){p||t()}function u(){if(r>0&&!a){i(!0);return}t(),r>0&&s({...pe.team()})}const h=`${r} project${r===1?"":"s"} joined`;return n.jsx(et,{open:e,onOpenChange:m,children:n.jsxs(tt,{className:"max-h-[85vh] !min-h-0 sm:max-w-2xl",children:[n.jsxs(Xe,{className:"shrink-0",children:[n.jsx(ze,{children:"Bring in existing projects"}),n.jsx(Je,{children:a?"Your projects are ready in DorkOS.":"Find projects on this computer to add."})]}),a?n.jsx(lt,{className:"mt-2",children:n.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-10 text-center","data-testid":"import-complete",children:[n.jsx(fs,{className:"text-primary size-12","aria-hidden":!0}),n.jsx("p",{className:"text-lg font-semibold","data-testid":"import-joined-summary",children:h}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage agents, tasks and chat apps from the Team page."})]})}):n.jsx(lt,{className:"mt-2 overflow-y-auto",children:n.jsx(Zv,{onRegistered:()=>o(p=>p+1)})}),n.jsxs(Dt,{className:"shrink-0 sm:justify-between",children:[!a&&r>0?n.jsx("span",{className:"text-muted-foreground text-sm","data-testid":"import-joined-count",children:h}):n.jsx("span",{}),n.jsx(_,{onClick:u,"data-testid":"import-done",children:"Done"})]})]})})}function tw(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.name=="string"&&(t.scope==="global"||t.scope==="project")&&typeof t.at=="string"&&Array.isArray(t.actions)&&(t.errors===void 0||Array.isArray(t.errors)&&t.errors.every(s=>typeof s=="string"))}function nw(){const e=ym(s=>s.record),t=sx();ue("marketplace_dev_link_reloaded",s=>{tw(s)&&(e(s),t())})}class sw extends l.Component{constructor(){super(...arguments);Jt(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(s,r){console.error("[RightPanel] Tab component error:",s,r)}componentDidUpdate(s){s.tabId!==this.props.tabId&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?n.jsx("div",{className:"flex h-full items-center justify-center p-4",children:n.jsx("p",{className:"text-muted-foreground text-sm",children:"This panel stopped working. Switch tabs to try again."})}):this.props.children}}const rw={canvas:"canvas",browser:"browser"};function ow(e,t){return t==="attention"?`${e}, something needs you`:e}function aw({contributionId:e}){const t=rw[e],s=B(o=>{var i;const a=o.roomCanvasLiveRoomId;return a===null||t===void 0?!1:(((i=o.roomCanvasUnread[a])==null?void 0:i[t].length)??0)>0});return bm(e)==="attention"?n.jsx("span",{"data-slot":"right-panel-tab-marker","aria-hidden":!0,className:"bg-status-warning-dot size-1.5 shrink-0 rounded-full"}):s?n.jsx("span",{"data-slot":"right-panel-tab-unread","aria-hidden":!0,className:"bg-primary size-1.5 shrink-0 rounded-full"}):null}const ld="right-panel-content";function Er(e){return`right-panel-tab-${e}`}function iw({contributions:e,actions:t}){const s=B(a=>a.setRightPanelOpen),r=B(a=>a.activeRightPanelTab),o=B(a=>a.setActiveRightPanelTab);return n.jsxs("div",{className:"flex w-full items-center justify-between border-b px-3 py-2","data-slot":"right-panel-header",children:[e.length>1?n.jsx(cw,{contributions:e,activeTab:r,onActivate:o}):e.length===1?n.jsxs("div",{className:"text-foreground flex items-center gap-1.5 px-1 text-xs font-medium",children:[n.jsx(Dn,{icon:e[0].icon,className:"text-muted-foreground size-3.5"}),n.jsx("span",{children:e[0].title})]}):n.jsx("div",{}),n.jsxs("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:[t,n.jsx(_,{variant:"ghost",size:"icon-md","aria-label":"Close panel",className:"size-7 shrink-0",onClick:()=>s(!1),children:n.jsx(He,{className:"size-3.5"})})]})]})}function cw({contributions:e,activeTab:t,onActivate:s}){const r=l.useRef(null),o=l.useRef(null),a=vm(u=>u.tabMarkers),i=wm(r,"horizontal"),c=l.useCallback(()=>{const u=r.current;return!u||!t?null:u.querySelector(`#${CSS.escape(Er(t))}`)},[t]),d=l.useCallback(()=>{const u=r.current,h=c();!u||!h||jm(u,h)},[c]),m=e.map(u=>u.id).join(",");return l.useEffect(()=>{if(d(),typeof ResizeObserver>"u")return;const u=new ResizeObserver(d);for(const h of[r.current,o.current,c()])h&&u.observe(h);return()=>u.disconnect()},[d,c,m]),n.jsx(xl,{asChild:!0,value:t??"",onValueChange:s,children:n.jsxs("div",{className:"relative min-w-0 flex-1",children:[n.jsx("div",{ref:r,onScroll:i.onScroll,className:"-my-1 overflow-x-auto overflow-y-hidden py-1",children:n.jsx(yl,{ref:o,responsive:!1,"aria-label":"Right panel tabs",className:"bg-accent/60 h-auto justify-start gap-0.5 rounded-lg p-0.5",children:e.map(u=>{const h=u.id===t;return n.jsxs(Bt,{children:[n.jsx(zt,{asChild:!0,children:n.jsxs(Jn,{value:u.id,"aria-label":ow(u.title,a[u.id]??null),id:Er(u.id),"aria-controls":h?ld:void 0,className:z("text-muted-foreground hover:text-foreground text-3xs shrink-0 gap-1.5 rounded-md px-2.5 py-1",h&&"bg-background text-foreground shadow-sm"),children:[n.jsx(Dn,{icon:u.icon,className:"size-3.5"}),n.jsx("span",{children:u.title}),n.jsx(aw,{contributionId:u.id})]})}),n.jsx(Ut,{side:"bottom",children:u.title})]},u.id)})})}),i.start&&n.jsx("div",{"aria-hidden":!0,"data-testid":"right-panel-tabs-fade-start",className:"from-sidebar via-sidebar/70 pointer-events-none absolute inset-y-0 left-0 w-6 bg-gradient-to-r to-transparent"}),i.end&&n.jsx("div",{"aria-hidden":!0,"data-testid":"right-panel-tabs-fade-end",className:"from-sidebar via-sidebar/70 pointer-events-none absolute inset-y-0 right-0 w-6 bg-gradient-to-l to-transparent"})]})})}const Ir="app-shell-right-panel",lw=40,dw=320,dd=20,uw=50;function mw(e){if(e<=0)return dd;const t=dw/e*100;return Math.min(Math.round(t*10)/10,uw)}function hw(){const[e,t]=l.useState(dd);return l.useLayoutEffect(()=>{const s=document.querySelector(`[data-panel-group-id="${Ir}"]`);if(!(s instanceof HTMLElement))return;const r=()=>t(mw(s.offsetWidth));r();const o=new ResizeObserver(r);return o.observe(s),()=>o.disconnect()},[]),{minPct:e,defaultPct:Math.max(lw,e)}}const fw="cubic-bezier(0, 0, 0.2, 1)",pw="cubic-bezier(0.4, 0, 1, 1)";function Ma(e,t){return`${e} 300ms ${t?fw:pw}`}const gw=new Set(["pulse","files"]);function xw({pathname:e,isRemoteCommunityRoom:t=!1}){const s=B(w=>w.rightPanelOpen),r=B(w=>w.setRightPanelOpen),o=B(w=>w.activeRightPanelTab),a=B(w=>w.setActiveRightPanelTabView),i=ey(),c=Ne(),d=l.useRef(null),[m,u]=l.useState(!1),[h,p]=l.useState(!1);l.useEffect(()=>{const w=requestAnimationFrame(()=>p(!0));return()=>cancelAnimationFrame(w)},[]);const f=ie(),g=B(w=>w.currentAgentId),x=B(w=>w.selectedCwd),b=B(w=>w.explicitAgentPath),y=Cs("right-panel"),k=l.useMemo(()=>y.filter(w=>!w.visibleWhen||w.visibleWhen({pathname:e,transport:f,agentId:g,cwd:x,explicitAgentPath:b,isRemoteCommunityRoom:t})),[y,e,f,g,x,b,t]);l.useEffect(()=>{if(k.length>0&&!k.some(A=>A.id===o)){const A=k.find(S=>!S.isGlobal);a((A??k[0]).id)}},[k,o,a]);const j=s,{minPct:C,defaultPct:v}=hw();l.useEffect(()=>{const w=d.current;w&&(j&&w.isCollapsed()?w.expand(v):!j&&w.isExpanded()&&w.collapse())},[j,v]);const N=k.find(w=>w.id===o),I=N==null?void 0:N.component,D=N==null?void 0:N.headerActions,T=n.jsxs(n.Fragment,{children:[n.jsx(iw,{contributions:k,actions:D?n.jsx(l.Suspense,{fallback:null,children:n.jsx(D,{})}):void 0}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",...k.length>1&&o&&k.some(w=>w.id===o)?{id:ld,role:"tabpanel","aria-labelledby":Er(o)}:{},children:n.jsx(sw,{tabId:o,children:n.jsx(l.Suspense,{fallback:null,children:I?n.jsx(I,{}):null})})})]});if(i)return j?n.jsx(km,{open:!0,onOpenChange:w=>!w&&r(!1),children:n.jsxs(Sm,{showCloseButton:!1,className:z("bg-sidebar text-sidebar-foreground flex w-full flex-col gap-0 p-0",c&&"sm:max-w-full",c&&o&&gw.has(o)&&"!bottom-auto !h-auto max-h-dvh overflow-y-auto"),children:[n.jsxs(Cm,{className:"sr-only",children:[n.jsx(Nm,{children:"Panel"}),n.jsx(Am,{children:"Right panel content."})]}),T]})}):null;const E=h&&!m;return n.jsxs(n.Fragment,{children:[n.jsx(Mx,{"aria-label":"Resize right panel",disabled:!j,onDragging:u,gripStyle:{opacity:j?1:0,pointerEvents:j?"auto":"none",...E&&{transition:Ma("opacity",j)}}}),n.jsx(cc,{ref:d,id:"right-panel",order:2,defaultSize:j?v:0,minSize:C,collapsible:!0,collapsedSize:0,onCollapse:()=>{h&&r(!1)},onExpand:()=>{s||r(!0)},style:E?{transition:Ma("flex-grow",j)}:void 0,children:n.jsx("div",{className:"bg-sidebar text-sidebar-foreground flex h-full flex-col overflow-hidden border-l",children:T})})]})}function yw(){const e=B(t=>t.toggleRightPanel);l.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.key==="."&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const _a=new WeakMap;let bw=0;function vw(e){const t=_a.get(e);if(t!==void 0)return t;const s=`bar-${bw++}`;return _a.set(e,s),s}function ww(e){var t;for(let s=e.length-1;s>=0;s--){const r=(t=e[s].staticData)==null?void 0:t.header;if(r)return{key:vw(r),Header:r}}return null}const jw="/";function No(){const e=Lt();return l.useMemo(()=>{const t=()=>lc(e),s=o=>{Me.getState().selectTab(o),t()},r=o=>{const{tabs:a}=Me.getState(),i=a[o];i&&s(i.id)};return{activate:s,activateIndex:r,activateLast:()=>r(Me.getState().tabs.length-1),activateRelative:o=>{const{tabs:a,activeTabId:i}=Me.getState();if(a.length<2)return;const c=a.findIndex(u=>u.id===i),m=(((c===-1?0:c)+o)%a.length+a.length)%a.length;s(a[m].id)},close:o=>{Me.getState().closeTab(o),t()},closeActive:()=>{const{tabs:o,activeTabId:a}=Me.getState();if(!a)return!1;const i=o.length;Me.getState().closeTab(a);const c=Me.getState().tabs.length<i;if(c)try{t()}catch(d){console.error("[dorkos:tabs] could not follow a closed tab",d)}return c},create:()=>Em(e,jw)}},[e])}const kw={"/":"Home","/activity":"Activity","/team":"Team","/agents":"Team","/channels":"Channels","/connections":"Connections","/feedback-requests":"Your reports","/marketplace":"Marketplace","/marketplace/sources":"Marketplace sources","/tasks":"Schedules","/workspaces":"Workspaces"},Sw={"/":mc,"/activity":Tm,"/team":rt,"/agents":rt,"/channels":uc,"/connections":Vr,"/feedback-requests":dc,"/marketplace":Yo,"/marketplace/sources":Yo,"/session":Kt,"/tasks":By,"/workspaces":Im},ud="Add-on",Cw="Session",Nw="DorkOS",Aw="http://tab.local";function Ew(e){let t;try{t=new URL(e,Aw)}catch{return{pathname:"/",sessionId:null,dir:null,roomId:null,community:null}}const s=t.pathname.length>1&&t.pathname.replace(/\/+$/,"")||"/";return s==="/session"?{pathname:s,sessionId:t.searchParams.get("session")||null,dir:t.searchParams.get("dir")||null,roomId:null,community:null}:s==="/channels"?{pathname:s,sessionId:null,dir:null,roomId:t.searchParams.get("id")||null,community:t.searchParams.get("community")||null}:{pathname:s,sessionId:null,dir:null,roomId:null,community:null}}function Iw(e){if(!e)return;const t=e.split("/").filter(Boolean);return t[t.length-1]}function Tw(e){return e.pathname==="/session"?Iw(e.dir)??Cw:Rm(e.pathname)!==null?ud:kw[e.pathname]??Nw}function Rw(e){var s;if(e===null)return null;const t=(s=e.match)==null?void 0:s.page;return{label:(t==null?void 0:t.title)??ud,icon:(t==null?void 0:t.icon)??hc}}function md(e){var g,x;const t=l.useMemo(()=>Ew(e),[e]),s=t.pathname==="/session",r=t.pathname==="/channels",{data:o}=fc(s?t.dir:null),a=Zr(o??null,t.dir??""),i=r?t.community:null,{data:c}=pc(r&&!i?t.roomId:null),d=qt(i!==null),m=eo((x=(g=d.data)==null?void 0:g.find(b=>b.ref===i))==null?void 0:x.access),{data:u}=gc(i??"",t.roomId??"",i!==null&&t.roomId!==null&&m.capabilities.read,m.fingerprint),h=i?u:c,p=Rw(Dm(t.pathname)),f=o?ke(o):h?to(h):(p==null?void 0:p.label)??Tw(t);return{target:t,label:f,emoji:o?a.emoji:null,extensionIcon:o?null:(p==null?void 0:p.icon)??null,Icon:Sw[t.pathname]??Kt}}function hd({view:e}){if(e.emoji!==null)return n.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-sm leading-none",children:e.emoji});if(e.extensionIcon!==null)return n.jsx(Dn,{icon:e.extensionIcon,className:"size-3.5 shrink-0"});const{Icon:t}=e;return n.jsx(t,{className:"size-3.5 shrink-0"})}const fd="app-tab-panel",Dw={streaming:"working",pendingApproval:"needs-you",error:"error",unseen:"unseen"};function Ow({tab:e,isActive:t,canClose:s,tabProps:r,onClose:o}){const a=md(e.href),{target:i,label:c}=a,d=i.pathname==="/session",m=Om(i.sessionId??""),u=d?Dw[m.kind]:void 0,h=l.useRef(null);return l.useEffect(()=>{var p,f;t&&((f=(p=h.current)==null?void 0:p.scrollIntoView)==null||f.call(p,{block:"nearest",inline:"nearest"}))},[t]),n.jsxs("div",{ref:h,role:"presentation",className:"group relative flex shrink-0",children:[n.jsxs("button",{type:"button",role:"tab","aria-selected":t,"aria-controls":t?fd:void 0,...r,className:z("focus-ring flex max-w-48 min-w-0 items-center gap-1.5 rounded-md py-1 pl-2 text-xs transition-colors",s?"pr-7":"pr-2",t?"bg-background text-foreground shadow-soft":"text-muted-foreground hover:bg-background/60 hover:text-foreground"),children:[n.jsx(hd,{view:a}),n.jsx("span",{className:"truncate font-medium",children:c}),u&&n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":"true",className:z("size-1.5 shrink-0 rounded-full",xc(u))}),n.jsxs("span",{className:"sr-only",children:[", ",m.label]})]})]}),s&&n.jsx("button",{type:"button",tabIndex:-1,onClick:()=>o(e.id,"pointer"),"aria-label":`Close ${c}`,className:z("focus-ring hover:bg-muted absolute top-1/2 right-1 -translate-y-1/2 rounded-sm p-0.5","opacity-0 transition-opacity group-hover:opacity-70 hover:opacity-100",t&&"opacity-70"),children:n.jsx(He,{className:"size-3"})})]})}function Mw({tabs:e,activeId:t,onActivate:s,onClose:r,onCreate:o,className:a}){const i=l.useRef(null),c=e.length>1,{getTabProps:d}=Xx({orderedIds:e.map(m=>m.id),activeId:t,onActivate:s,onClose:c?r:void 0,getFallbackFocus:()=>i.current});return n.jsxs("div",{className:z("bg-muted/40 flex shrink-0 items-stretch border-b px-2 py-1",a),children:[n.jsx("div",{className:"flex min-w-0 flex-1 items-stretch overflow-x-auto",children:n.jsx("div",{role:"tablist","aria-label":"Open tabs",className:"flex items-stretch gap-1",children:e.map(m=>n.jsx(Ow,{tab:m,isActive:m.id===t,canClose:c,tabProps:d(m.id),onClose:r},m.id))})}),n.jsx("button",{ref:i,type:"button",onClick:o,"aria-label":"New tab",title:`New tab (${Mt(xn.NEW_TAB)})`,className:"focus-ring text-muted-foreground hover:bg-background/60 hover:text-foreground ml-1 flex shrink-0 items-center rounded-md px-1.5 transition-colors",children:n.jsx(Ht,{className:"size-3.5"})})]})}function _w({className:e}){const t=Mm(),s=Me(i=>i.activeTabId),{activate:r,close:o,create:a}=No();return n.jsx(Mw,{tabs:t,activeId:s,onActivate:r,onClose:o,onCreate:a,className:e})}function cs(){var s;const{tabs:e,activeTabId:t}=Me.getState();return((s=e.find(r=>r.id===t))==null?void 0:s.cursor)??null}function Ao(e,t){const s=cs();s!==null&&(Me.getState().goToHistoryIndex(t),cs()!==s&&lc(e))}function pd(e){const t=cs();t!==null&&Ao(e,t-1)}function gd(e){const t=cs();t!==null&&Ao(e,t+1)}function Pw(e,t){Ao(e,t)}function Pa(e,t){const s=Mt(e);return jt?s:`${s} or ${Mt(`alt+${t}`)}`}const Qs="size-7";function Lw({href:e,isCurrent:t,onSelect:s}){const r=md(e);return n.jsxs(Pm,{disabled:t,"aria-current":t?"page":void 0,onSelect:s,className:"data-[disabled]:opacity-100",children:[n.jsx(hd,{view:r}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.label}),n.jsx(Ft,{className:z("size-3.5 shrink-0",!t&&"invisible")})]})}function Xs({label:e,keys:t,children:s}){return n.jsxs(Bt,{children:[n.jsx(zt,{asChild:!0,children:s}),n.jsx(Ut,{side:"bottom",className:"text-xs",children:t?`${e} (${t})`:e})]})}function Fw(){const e=Lt(),{entries:t,cursor:s,canGoBack:r,canGoForward:o}=_m();if(!Pe())return null;const a=t.map((i,c)=>({href:i,index:c})).reverse();return n.jsxs("div",{className:"flex items-center",children:[n.jsx(Xs,{label:"Back",keys:Pa(xn.HISTORY_BACK.key,"←"),children:n.jsx(_,{variant:"ghost",size:"icon-md",className:Qs,"aria-label":"Back",disabled:!r,onClick:()=>pd(e),children:n.jsx(yc,{})})}),n.jsx(Xs,{label:"Forward",keys:Pa(xn.HISTORY_FORWARD.key,"→"),children:n.jsx(_,{variant:"ghost",size:"icon-md",className:Qs,"aria-label":"Forward",disabled:!o,onClick:()=>gd(e),children:n.jsx(bc,{})})}),n.jsxs(vc,{children:[n.jsx(Xs,{label:"History",children:n.jsx(wc,{asChild:!0,children:n.jsx(_,{variant:"ghost",size:"icon-md",className:Qs,"aria-label":"History",children:n.jsx(Jx,{})})})}),n.jsx(jc,{align:"start",className:"max-w-72 min-w-48",children:a.map(({href:i,index:c})=>n.jsx(Lw,{href:i,isCurrent:c===s,onSelect:()=>Pw(e,c)},c))})]})]})}function $w(){const e=Lt(),t=Ae({select:o=>o.location.href}),s=l.useRef(!1),r=l.useRef(!0);l.useEffect(()=>{if(Pe())return e.history.subscribe(({action:o})=>{s.current=o.type!=="PUSH"&&o.type!=="REPLACE",r.current=o.type==="REPLACE"})},[e]),l.useEffect(()=>{if(!Pe())return;const o=s.current,a=r.current;s.current=!1,r.current=!1,Me.getState().syncLocation(t,{traversal:o,replace:a})},[t])}const La=9;function Bw(){const e=No();l.useEffect(()=>{if(!Pe())return;const t=s=>{if(!(s.metaKey||s.ctrlKey)||s.altKey)return;if(s.shiftKey){s.code==="BracketLeft"?(s.preventDefault(),e.activateRelative(-1)):s.code==="BracketRight"&&(s.preventDefault(),e.activateRelative(1));return}if(s.key==="t"||s.key==="T"){s.preventDefault(),e.create();return}if(!s.code.startsWith("Digit"))return;const r=Number(s.code.slice(5));!Number.isInteger(r)||r<1||r>La||(s.preventDefault(),r===La?e.activateLast():e.activateIndex(r-1))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const Fa=3,zw=4;function Uw(e){return e instanceof Element?e.closest("input, textarea, select")?!0:e.closest('[contenteditable]:not([contenteditable="false"])')!==null:!1}function $a(e){return e instanceof Element&&e.closest('[role="dialog"], [role="alertdialog"], [role="menu"]')!==null}function Kw(e){if(e.shiftKey)return null;if((jt?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey)return e.code==="BracketLeft"?"back":e.code==="BracketRight"?"forward":null;if(!jt&&e.altKey&&!e.ctrlKey&&!e.metaKey){if(Uw(e.target))return null;if(e.key==="ArrowLeft")return"back";if(e.key==="ArrowRight")return"forward"}return null}function Hw(){const e=Lt();l.useEffect(()=>{if(!Pe())return;const t=i=>i==="back"?pd(e):gd(e),s=i=>{if(i.defaultPrevented||i.isComposing||$a(i.target))return;const c=Kw(i);c&&(i.preventDefault(),t(c))},r=i=>i.button===Fa||i.button===zw,o=i=>{r(i)&&i.preventDefault()},a=i=>{r(i)&&(i.preventDefault(),!$a(i.target)&&t(i.button===Fa?"back":"forward"))};return document.addEventListener("keydown",s),document.addEventListener("mousedown",o),document.addEventListener("mouseup",a),()=>{document.removeEventListener("keydown",s),document.removeEventListener("mousedown",o),document.removeEventListener("mouseup",a)}},[e])}function bt(e){return"problem"in e?{problem:e.problem}:{message:e.message}}const vt={message:"Couldn’t reach your DorkOS account. Try again."},qw={message:"Finish signing in in your browser, then try again."},Ww={message:"Your browser blocked the window. Allow pop-ups, then try again."},Js={message:"Couldn’t connect this DorkOS to the space. Try again."},Gw={message:"The approval ran out. Connect again."};function Eo(e,t,s){var T,E;const r=ie(),o=ce(),a=jn(e!==null),{signsInWithAccount:i,linkFor:c}=kc(e!==null),[d,m]=l.useState({opened:!1,busy:!1,notice:null}),[u,h]=l.useState(null),p=l.useRef(null),f=be({queryKey:Ge.list(),queryFn:()=>r.listHostedCommunities(),enabled:e!==null&&u===null,refetchInterval:w=>{const A=w.state.data,S=(A==null?void 0:A.available)===!0?A.communities.find(M=>M.communityId===(e==null?void 0:e.communityId)):void 0;return(S==null?void 0:S.state)==="provisioning"?2e3:!1}}),g=((T=f.data)==null?void 0:T.available)===!0?f.data.communities.find(w=>w.communityId===(e==null?void 0:e.communityId)):void 0,x=(g==null?void 0:g.state)==="provisioning",b=l.useCallback(()=>{if(!e||d.busy)return;const w=Lm();if(w===null){m(A=>({...A,notice:Ww}));return}m(A=>({...A,busy:!0,notice:null})),r.getHostedCommunityClaimLink(e.communityId).then(A=>{if(!A.ok){w.close(),m(M=>({...M,busy:!1,notice:bt(A)}));return}const S=w.go(c(A.claimUrl));m(M=>({opened:M.opened||S,busy:!1,notice:null}))}).catch(()=>{w.close(),m(A=>({...A,busy:!1,notice:vt}))})},[e,d.busy,r,c]),y=l.useCallback(async()=>{if(e){if(!a||!pt(a)){h({ref:null,approvalUrl:null,busy:!1,notice:Js});return}h({ref:null,approvalUrl:null,busy:!0,notice:null});try{const w=await r.startCommunityConnection({url:e.communityUrl,installName:t});h({ref:w.connection.ref,approvalUrl:w.approvalUrl,busy:!1,notice:null}),await o.invalidateQueries({queryKey:it.connections(a)})}catch{h({ref:null,approvalUrl:null,busy:!1,notice:Js})}}},[e,a,r,t,o]),k=l.useCallback(()=>{!e||d.busy||(m(w=>({...w,busy:!0,notice:null})),r.listHostedCommunities().then(w=>{o.setQueryData(Ge.list(),w);const A=w.available===!0?w.communities.find(S=>S.communityId===e.communityId):void 0;if(!A||A.state==="pending_owner"||A.state==="provisioning"){m(S=>({...S,busy:!1,notice:qw}));return}m(S=>({...S,busy:!1})),y()}).catch(()=>m(w=>({...w,busy:!1,notice:vt}))))},[e,d.busy,r,o,y]),j=(u==null?void 0:u.ref)??null,C=be({queryKey:a&&j?it.approval(a,j):["cloud","no-approval"],queryFn:()=>Yi(a,()=>r.pollCommunityConnection(j)),enabled:a!==null&&j!==null,retry:!1,refetchInterval:w=>!w.state.error&&(!w.state.data||w.state.data.status==="pending")?2e3:!1}),v=j!==null?((E=C.data)==null?void 0:E.status)??"pending":"pending",N=v==="connected"?j:null;l.useEffect(()=>{N===null||p.current===N||(p.current=N,a&&o.invalidateQueries({queryKey:it.connections(a)}),o.invalidateQueries({queryKey:Ge.all}),s(N))},[N,a,o,s]);const I=v==="expired"||v==="cancelled";return{state:N!==null?{kind:"done",ref:N}:u!==null?{kind:"connecting",approvalUrl:u.approvalUrl,busy:u.busy,notice:u.notice??(I?Gw:C.error?Js:null)}:x?{kind:"preparing"}:{kind:"claim",...d,withAccount:e!==null&&i(e.communityUrl)},openClaim:b,confirmClaimed:k,openApproval:()=>{u!=null&&u.approvalUrl&&dt(c(u.approvalUrl))},retryConnect:()=>void y()}}const ot=Fm({offset:!0}).describe("An ISO-8601 instant with an explicit UTC offset."),Ke=he().min(1).describe("An opaque server-issued identifier. Clients never parse or enumerate it.");he().regex(/^-?(0|[1-9][0-9]*)$/,"must be a base-10 integer count of micro-units carried as a string").describe("An exact integer count of micro-units, carried as a string so no value goes through a JavaScript number. A micro-unit is a millionth of the major unit of the currency the response names.");const Yw=he().regex(/^[1-9][0-9]*$/,"must be a positive base-10 integer count of micro-units carried as a string").describe("A strictly positive exact integer count of micro-units, carried as a string so no amount goes through a JavaScript number."),Io="amountKind";Gt(["money","credit"]).describe("What an amount counts: money paid, refunded, offered or capped, or credits held, spent or priced.");const xd=/^-?(0|[1-9][0-9]*)$/,Vw=/^[1-9][0-9]*$/;he().regex(xd,"must be a base-10 integer count of micro-units carried as a string").describe("An exact integer count of micro-units of the response's currency: money paid, refunded, offered or capped.").meta({[Io]:"money"});he().regex(Vw,"must be a positive base-10 integer count of micro-units carried as a string").describe("A strictly positive exact integer count of micro-units of money to be paid, in the currency the service names.").meta({[Io]:"money"});he().regex(xd,"must be a base-10 integer count of micro-units carried as a string").describe("An exact integer count of micro-units of the response's currency, counted as credits: divide by the response's denomination.microPerCredit to get credits.").meta({[Io]:"credit"});re({currency:he().regex(/^[A-Z]{3}$/,"must be an ISO 4217 currency code").describe("An ISO 4217 code. Rendered, never enumerated."),microPerCredit:Yw.describe("How many micro-units of currency one credit is. Served by the service; a client never hard-codes it.")}).describe("The unit these amounts are in: the currency their micro-units are millionths of, and how many micro-units one credit is.");const Qw=he().min(1).describe("A credential returned exactly once. Store it as a credential reference; never log it or persist it as configuration."),yd=he().min(1).describe("An opaque pagination cursor, passed back verbatim from a previous page.");re({cursor:yd.optional(),limit:me().int().min(1).max(200).optional().describe("Maximum items in the page. The server may return fewer, and clamps anything larger.")}).describe("Cursor pagination parameters, shared by every collection in this contract.");function bd(e,t){return re({items:Wt(e),nextCursor:yd.nullable().describe("The cursor for the next page, or null when this is the last page.")}).describe(t)}const Xw=Sc({protocol:/^https$/}).regex(/^https:\/\//,"must be an https: link").describe("An absolute https: link. Any other scheme is refused."),_n=Sc({protocol:/^https?$/}).regex(/^(https:\/\/|http:\/\/(localhost|127\.0\.0\.1|\[::1\])(:[0-9]+)?([/?#]|$))/,"must be an https: link, or http: to a loopback address").describe("An absolute https: link, or an http: link to a loopback address only."),vd="x-dorkos-one-time-credential",Jw="unrecognised";function ls(e){return $m([e,he().transform(()=>Jw).describe("A value this release does not know. It reads as unrecognised.")])}const Qt=he().regex(/^[a-z](?:[a-z0-9]|-(?=[a-z0-9])){2,31}$/,"must be lower-case letters, digits and single hyphens, start with a letter, and not end with a hyphen").describe("A community short name: lower case, 3 to 32 characters, letters, digits and single hyphens, starting with a letter and not ending with a hyphen."),wd=he().trim().min(1).max(80).describe("The community`s display name. Trimmed, 1 to 80 characters."),jd=he().min(1).max(200).describe("A key the caller chooses, scoped to the caller. Sending it again returns the same community or move instead of making a second one.");function Zw(e){return _n.meta({description:e,[vd]:!0})}const ej=Gt(["provisioning","pending_owner","active","archived","held","suspended","deletion_pending"]).describe("Where a hosted community is in its lifecycle. The Community server`s own lifecycle names, plus provisioning while the server confirms a start."),tj=Gt(["over_limit","inactive","host"]).describe("Why a hosted community is on hold: the account holds more than its allowance covers, nobody has posted in a long time, or the host placed the hold itself."),nj=re({title:he().min(1).max(120).describe("A short summary, safe to show a person."),detail:he().max(2e3).describe("The explanation, safe to show a person."),actionUrl:Xw.optional().catch(void 0).describe("A page where the owner can act on the notice. Open it as given. A malformed value is dropped."),actionLabel:he().min(1).max(60).optional().catch(void 0).describe("The text for a button that opens `actionUrl`. A malformed value is dropped.")}).describe("What the service wants the owner to read about this community, in its own words."),sj=re({allowed:xt().describe("The owner may choose this community as one to keep open."),wouldHold:Wt(Ke).describe("The caller`s other communities that keeping this one would put on hold.")}).describe("Whether the owner may keep this community open, and which others it would hold."),To=re({communityId:Ke.describe("The community`s permanent identifier on its Community server. Never changes, even across a rename."),orgId:Ke.describe("The organization whose account this community belongs to."),name:he().min(1).max(80).describe("The community`s display name."),shortName:Qt.nullable().describe("The community`s current short name, or null when it has none."),communityUrl:_n.describe("The community`s canonical link on its Community server, built on its permanent identifier. A runtime value; pair a DorkOS installation with this."),state:ls(ej).describe("Where the community is in its lifecycle. A state this release does not know reads as unrecognised."),hold:re({reason:ls(tj).describe("Why the community is on hold. A reason this release does not know reads as unrecognised."),since:ot,deletionNoticeAt:ot.nullable().describe("When the host may delete the community if the hold is not lifted, or null when no deletion is planned. The owner can export until then.")}).nullable().describe("Why and since when the community is on hold. Always set when the state is held."),deletionAt:ot.nullable().describe("When the Community server will delete the community for good. Always set when the state is deletion_pending."),notice:nj.nullable().describe("What the service wants the owner to read about this community, or null when there is nothing."),kept:xt().describe("True when the owner chose this community to stay open while the account holds more communities than its allowance covers."),moveId:Ke.nullable().describe("The move filling this community from an owner export, while that move is unfinished. Null otherwise. Lets the app pick up a move after a restart."),limits:re({maxActiveMembers:me().int().positive().nullable().describe("The most people who may be active members at once. Null means no limit."),maxStorageBytes:me().int().nonnegative().nullable().describe("The most bytes of files the community may store. Null means no per-community limit.")}).describe("The limits the host enforces on this community. Agents and history never count."),usage:re({activeMembers:me().int().nonnegative(),storageBytes:me().int().nonnegative().describe("The bytes that count against the storage limit. Owner exports never count."),measuredAt:ot}).nullable().describe("The community`s last measured usage, or null before the first measurement."),actions:re({claimLink:xt().describe("The service will issue a fresh owner-claim link for this community."),keep:sj,restore:xt().describe("The owner may ask for this held community to reopen.")}).describe("What the caller may do next. Render an action only when it is allowed; the service applies the rule, the app never re-derives it."),createdAt:ot}).superRefine((e,t)=>{e.state==="held"&&e.hold===null&&t.addIssue({code:"custom",path:["hold"],message:"a held community says why"}),e.state==="deletion_pending"&&e.deletionAt===null&&t.addIssue({code:"custom",path:["deletionAt"],message:"a community pending deletion says when"})}).describe("One community the caller has hosted, with its state, limits and usage. Numbers only.");bd(To,"A page of the communities the caller has hosted.");re({name:Qt}).describe("The short name to check.");const rj=Gt(["taken","reserved"]).describe("Why a short name cannot be used: another community has it, or the host reserves it.");re({name:Qt,available:xt(),reason:rj.nullable().describe("Why the name cannot be used. Null exactly when it is available.")}).superRefine((e,t)=>{e.available!==(e.reason===null)&&t.addIssue({code:"custom",path:["reason"],message:"reason is null exactly when the name is available"})}).describe("Whether a short name is free right now. Advisory; starting a community checks again.");re({idempotencyKey:jd,name:wd,shortName:Qt.optional().describe("The short name to give the community. Omitted means none."),orgId:Ke.optional().describe("The organization whose account the community belongs to. Omitted means the caller`s personal one.")}).describe("Start a hosted community. Idempotent on the caller`s key.");const oj=re({communityId:Ke,claimUrl:Zw("The owner-claim link. A single-use credential: open it in the person`s own browser and never log it."),expiresAt:ot.describe("When the link stops working.")}).describe("A one-time link that makes a person the owner of a new community. Returned once.");re({community:To,claim:oj.nullable().describe("The owner-claim link, or null when this answer repeats an earlier request or the community is still provisioning."),replayed:xt().describe("True when this answer repeats an earlier request with the same key.")}).superRefine((e,t)=>{e.claim!==null&&(e.replayed||e.community.state!=="pending_owner")&&t.addIssue({code:"custom",path:["claim"],message:"a claim link comes only on the first answer, for a pending_owner community"})}).describe("The started community and, the first time only, its owner-claim link.");re({expectedHeldCommunityIds:Wt(Ke).describe("The communities the owner was told this choice would hold, in any order.")}).describe("Keep this community open, confirming which others the owner agreed to hold.");re({community:To,heldCommunityIds:Wt(Ke).describe("Other communities of the caller`s that this choice put on hold. Often empty.")}).describe("The kept community, and every other community the choice put on hold.");const aj=Gt(["awaiting_upload","importing","ready","failed","cancelled","claimed"]).describe("Where a move is: waiting for the export, importing it, ready to claim, or finished."),ij=Gt(["not_owner_export","archive_invalid","checksum_mismatch","version_unsupported","too_large","storage_limit_reached","upload_expired","storage_unavailable"]).describe("Why a move failed, in terms a person can act on."),cj=re({channels:me().int().nonnegative(),entries:me().int().nonnegative().describe("Messages and replies."),attachments:me().int().nonnegative(),historicalMembers:me().int().nonnegative().describe("People whose messages move. They join again by invitation."),historicalAgents:me().int().nonnegative().describe("Agents whose messages move. Their owners pair them again."),attachmentBytes:me().int().nonnegative(),countedBytes:me().int().nonnegative().describe("The bytes that will count against the community`s storage limit.")}).describe("What an owner export holds, in counts and sizes only."),kd=re({moveId:Ke,communityId:Ke.describe("The new community the export fills. It no longer exists once a move has failed or been cancelled."),communityUrl:_n.describe("The new community`s canonical link. A runtime value."),name:he().min(1).max(80).describe("The name the new community was given."),state:ls(aj).describe("Where the move is. A state this release does not know reads as unrecognised."),failureCode:ls(ij).nullable().describe("Why the move failed. Always set when the state is failed. A code this release does not know reads as unrecognised."),report:cj.nullable().describe("What the export holds, once it has been read. Null before then."),pollAfterMs:me().int().nonnegative().nullable().describe("How long to wait before reading the move again. Null once it has finished."),updatedAt:ot}).superRefine((e,t)=>{e.state==="failed"&&e.failureCode===null&&t.addIssue({code:"custom",path:["failureCode"],message:"a failed move says why"})}).describe("One move of a community into hosting, from an owner export.");bd(kd,"A page of the caller`s moves: every unfinished one, and those that finished within the last 7 days, newest first.");re({idempotencyKey:jd,name:wd,shortName:Qt.optional().describe("The short name to give the new community. Omitted means none."),orgId:Ke.optional().describe("The organization whose account the community belongs to. Omitted means the caller`s personal one."),archiveBytes:me().int().positive().describe("The size of the export file, in bytes."),archiveSha256:he().regex(/^[a-f0-9]{64}$/,"must be a lower-case hex SHA-256 digest").describe("The SHA-256 of the export file, as lower-case hex.")}).describe("Start moving a community in from an owner export. Idempotent on the caller`s key.");const lj=re({url:_n.describe("Where to send the export. A runtime value."),token:Qw.meta({description:"The upload bearer credential. Returned once; never log it.",[vd]:!0}),expiresAt:ot.describe("When the upload window closes."),maxBytes:me().int().positive().describe("The largest file the upload accepts."),parts:re({partBytes:me().int().positive().describe("The largest part the upload accepts."),maxBytes:me().int().positive().describe("The largest file a parted upload accepts.")}).optional().describe("Present when the Community server accepts the file in parts.")}).describe("Where and how to send the export file. The token is returned once."),Sd=he().regex(/^[a-f0-9]{64}$/,"must be a lower-case hex SHA-256 digest"),Ro=1e4,dj=re({partNumber:me().int().positive().max(Ro).describe("The number of the part, counting up from one."),byteSize:me().int().positive().describe("The size of the part, in bytes."),sha256:Sd.describe("The SHA-256 of the part, as lower-case hex.")}).describe("One part the Community server has received.");re({parts:Wt(dj).max(Ro).describe("The parts received, in part order."),maxPartBytes:me().int().positive().describe("The largest part the upload accepts."),maxArchiveBytes:me().int().positive().describe("The largest file a parted upload accepts.")}).describe("The parts of a parted upload received so far.");re({parts:me().int().positive().max(Ro).describe("How many parts make up the file."),archiveBytes:me().int().positive().describe("The size of the whole file, in bytes."),archiveSha256:Sd.describe("The SHA-256 of the whole file, as lower-case hex.")}).describe("Put the uploaded parts together into the declared file.");re({move:kd,upload:lj.nullable().describe("Where to send the export, or null when this answer repeats an earlier request."),replayed:xt().describe("True when this answer repeats an earlier request with the same key.")}).superRefine((e,t)=>{e.replayed!==(e.upload===null)&&t.addIssue({code:"custom",path:["upload"],message:"upload is null exactly when the answer is replayed"})}).describe("The started move and, the first time only, where to send the export.");const uj=_n.regex(/^https?:\/\/[^/?#]+$/,"must be an origin: no path, query or fragment").refine(e=>new URL(e).origin===e,{message:"must be written as the URL standard writes an origin"}).describe("A Community server`s origin: scheme, host and port, written as the URL standard writes it. A runtime value."),mj=re({origin:uj}).describe("A Community server whose single sign-on is this account.");re({servers:Wt(mj).max(100).describe("Every Community server whose single sign-on is this account. Often one.")}).describe("The Community servers where this account signs a person in.");function Cd(e){switch(e){case"not_owner_export":return{title:"This is a personal export, not an owner export.",next:"Sign in to the old space as its owner, export it from Settings, then try again."};case"archive_invalid":return{title:"This file is damaged, or it isn’t a space export.",next:"Export the old space again, then try again."};case"checksum_mismatch":return{title:"Part of this export is damaged.",next:"Export the old space again, then try again."};case"version_unsupported":return{title:"This export comes from a version DorkOS can’t read yet.",next:"Update the old space, export it again, then try again."};case"too_large":return{title:"This export is too large to move.",next:"Delete some large files in the old space, export it again, then try again."};case"storage_limit_reached":return{title:"The files don’t fit in the new space’s storage.",next:"Delete some files in the old space, export it again, then try again."};case"upload_expired":return{title:"The file didn’t arrive in time.",next:"Start the move again."};case"storage_unavailable":return{title:"DorkOS couldn’t store the files just now.",next:"Wait a little while, then start the move again."};default:return{title:"The move stopped for an unknown reason.",next:"Update DorkOS to see more, or start the move again."}}}function hj(e){switch(e){case"provisioning":return"Being set up";case"pending_owner":return"Waiting for its owner";case"active":return"Open";case"archived":return"Archived";case"held":return"On hold";case"suspended":return"Suspended";case"deletion_pending":return"Being deleted";default:return"Unknown state"}}function fj(e){switch(e){case"over_limit":return"Your account has more spaces than it allows. Choose which ones stay open.";case"inactive":return"Nobody has posted here in a long time. You can reopen it.";case"host":return"DorkOS put this space on hold. People can still read it.";default:return"This space is on hold. Update DorkOS to see why."}}function Zs(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"})}function vn(e){const t=["bytes","KB","MB","GB","TB"];let s=e,r=0;for(;s>=1e3&&r<t.length-1;)s/=1e3,r++;return`${r===0||s>=10?Math.round(s):Math.round(s*10)/10} ${t[r]}`}function Nd(e){if((e==null?void 0:e.maxCommunities)==null||e.usedCommunities==null)return null;const t=e.maxCommunities-e.usedCommunities;return t<=0?"Your account has no room for another space right now.":`You can start ${t} more ${t===1?"space":"spaces"}.`}const Ad="Lower-case letters, numbers and single hyphens. 3 to 32 characters, starting with a letter.";function Pn(e){const t=e.trim().toLowerCase();return t===""?{value:t,valid:!0}:{value:t,valid:Qt.safeParse(t).success}}const pj=80,Ed="That web address is taken.",Id="That web address can’t be used.";function Td(e){const t=ie(),{value:s,valid:r}=Pn(e),[o,a]=l.useState(s);l.useEffect(()=>{const d=setTimeout(()=>a(s),400);return()=>clearTimeout(d)},[s]);const i=be({queryKey:Ge.name(o),queryFn:()=>t.checkHostedCommunityName(o),enabled:r&&o!==""&&o===s,staleTime:1e4,retry:!1});if(s==="")return{kind:"none"};if(!r)return{kind:"invalid"};if(o!==s||i.isPending)return{kind:"checking"};const c=i.data;return!c||c.available===!1?{kind:"none"}:c.check.available?{kind:"available"}:{kind:c.check.reason==="reserved"?"reserved":"taken"}}function gj(){const e=l.useRef(null);return t=>{var r;const s=JSON.stringify(t);return((r=e.current)==null?void 0:r.body)!==s&&(e.current={body:s,key:crypto.randomUUID()}),e.current.key}}function xj(){const e=ie(),t=ce(),s=gj(),[r,o]=l.useState(!1),[a,i]=l.useState({field:null,notice:null});async function c(d){const m={name:d.name.trim(),...d.shortName?{shortName:d.shortName}:{}};o(!0),i({field:null,notice:null});try{const u=await e.startHostedCommunity({...m,idempotencyKey:s(m)});return u.ok?(t.invalidateQueries({queryKey:Ge.list()}),{community:u.community}):("problem"in u&&u.problem.code==="community_name_taken"?i({field:Ed,notice:null}):"problem"in u&&u.problem.code==="community_name_reserved"?i({field:Id,notice:null}):i({field:null,notice:bt(u)}),null)}catch{return i({field:null,notice:vt}),null}finally{o(!1)}}return{submitting:r,failure:a,clearFieldFailure:()=>i(d=>({...d,field:null})),submit:c}}function yj(e){switch(e.state){case"awaiting_upload":{const t=e.upload;if((t==null?void 0:t.state)==="sending")return{kind:"uploading",move:e};if((t==null?void 0:t.state)==="sent")return{kind:"importing",move:e};const s=t===null?"restarted":t.failure==="interrupted"?"interrupted":t.failure==="rejected"?"refused":"expired";return{kind:"upload-failed",move:e,why:s}}case"importing":return{kind:"importing",move:e};case"ready":case"claimed":return{kind:"ready",move:e};case"failed":return{kind:"failed",move:e};case"cancelled":return{kind:"cancelled",move:e};default:return{kind:"unrecognised",move:e}}}function bj(e){return e.state==="awaiting_upload"||e.state==="importing"||e.state==="ready"}function vj(e){var C;const t=ie(),s=ce(),[r,o]=l.useState(e),[a,i]=l.useState(null),[c,d]=l.useState({field:null,notice:null}),[m,u]=l.useState(!1),h=l.useRef(null),p=l.useRef(null),f=be({queryKey:Ge.move(r??""),queryFn:()=>t.getHostedCommunityMove(r),enabled:r!==null,refetchInterval:v=>{var I;const N=v.state.data;return(N==null?void 0:N.available)!==!0?!1:((I=N.move.upload)==null?void 0:I.state)==="sending"?1e3:N.move.pollAfterMs===null?!1:Math.max(1e3,N.move.pollAfterMs)}}),g=((C=f.data)==null?void 0:C.available)===!0?f.data.move:null,x=g?yj(g):null,b=l.useCallback(v=>{s.setQueryData(Ge.move(v.moveId),{available:!0,move:v})},[s]);async function y(v){var E;const N={name:v.name.trim(),...v.shortName?{shortName:v.shortName}:{},file:[v.file.name,v.file.size,v.file.lastModified]},I=JSON.stringify(N);((E=p.current)==null?void 0:E.body)!==I&&(p.current={body:I,key:crypto.randomUUID()});const D=p.current.key,T=new AbortController;h.current=T,d({field:null,notice:null}),i({loaded:0,total:v.file.size});try{const w=await t.checkHostedCommunityMoveRoom(v.file.size,T.signal);if(T.signal.aborted)return;const A=w.ok?await t.startHostedCommunityMove(v.file,{idempotencyKey:D,name:N.name,...v.shortName?{shortName:v.shortName}:{}},S=>i(S),T.signal):w;(A.ok||A.mayExist!==!0)&&(p.current=null),A.ok?(b(A.move),o(A.move.moveId),s.invalidateQueries({queryKey:Ge.list()})):"problem"in A&&A.problem.code==="community_name_taken"?d({field:Ed,notice:null}):"problem"in A&&A.problem.code==="community_name_reserved"?d({field:Id,notice:null}):d({field:null,notice:bt(A)})}catch{T.signal.aborted?p.current=null:d({field:null,notice:vt})}finally{h.current=null,i(null)}}async function k(){if(h.current){h.current.abort();return}if(r){u(!0);try{const v=await t.cancelHostedCommunityMove(r);v.ok?b(v.move):d({field:null,notice:bt(v)}),s.invalidateQueries({queryKey:Ge.list()})}catch{d({field:null,notice:vt})}finally{u(!1)}}}async function j(){if(r){u(!0),d({field:null,notice:null});try{const v=await t.retryHostedCommunityMoveUpload(r);v.ok?b(v.move):d({field:null,notice:bt(v)})}catch{d({field:null,notice:vt})}finally{u(!1)}}}return{step:x,sending:a,failure:c,clearFieldFailure:()=>d(v=>({...v,field:null})),busy:m,start:y,cancel:k,sendAgain:j,startOver:()=>{o(null),d({field:null,notice:null})}}}function wj(){var a,i,c;const e=no(),t=Bm(),s=Cc(t);if(!e||!t||s.isPending||((a=s.data)==null?void 0:a.available)===!1)return null;const r=((i=s.data)==null?void 0:i.available)===!0?s.data:null,o=(r==null?void 0:r.moves)??[];return{allowance:(r==null?void 0:r.allowance)??null,unfinishedMoveId:((c=o.find(bj))==null?void 0:c.moveId)??null}}const jj={message:"Your spaces changed. Check the list again."};function kj(){const e=ie(),t=ce(),[s,r]=l.useState(null),[o,a]=l.useState(null),[i,c]=l.useState({});function d(u,h){c(p=>{const f={...p};return h?f[u]=h:delete f[u],f})}async function m(u,h){a(u),d(u,null);try{d(u,await h())}catch{d(u,vt)}finally{a(null),await t.invalidateQueries({queryKey:Ge.list()})}}return{confirmingKeep:s,busyId:o,notices:i,askKeep:r,cancelKeep:()=>r(null),keep:u=>m(u.communityId,async()=>{r(null);const h=await e.keepHostedCommunity(u.communityId,u.actions.keep.wouldHold);return h.ok?null:"problem"in h&&h.problem.code==="conflict"?jj:bt(h)}),restore:u=>m(u.communityId,async()=>{const h=await e.restoreHostedCommunity(u.communityId);return h.ok?null:bt(h)})}}function Do({open:e,onOpenChange:t,step:s,locked:r}){return n.jsx(et,{open:e,onOpenChange:o=>r&&!o?void 0:t(o),children:n.jsxs(tt,{className:"!min-h-0 sm:max-w-lg",children:[n.jsxs(Xe,{children:[n.jsx(ze,{children:s.title}),s.description!==void 0&&n.jsx(Je,{children:s.description})]}),s.body!==void 0&&n.jsx(lt,{className:"space-y-4 py-2",children:s.body}),n.jsx(Dt,{className:"gap-2 sm:gap-2",children:s.actions})]})})}function Ct({notice:e}){if("message"in e)return n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:e.message});const{title:t,detail:s,actionUrl:r,actionLabel:o}=e.problem;return n.jsxs("div",{role:"alert",className:"border-status-warning-border bg-status-warning-bg text-status-warning-fg space-y-2 rounded-md border p-3 text-sm",children:[n.jsx("p",{className:"font-medium break-words",children:t}),s&&n.jsx("p",{className:"break-words",children:s}),r&&n.jsxs(_,{type:"button",size:"sm",variant:"outline",onClick:()=>dt(r),children:[o??"Open your account",n.jsx(yn,{className:"size-3.5","aria-hidden":!0})]})]})}function Oo(e){const{state:t,name:s}=e;switch(t.kind){case"preparing":return{title:`Setting up ${s}`,description:"Keep this open, or come back later.",body:n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(wt,{className:"size-4"})," Setting up…"]}),actions:n.jsx(_,{variant:"outline",onClick:e.onClose,children:"Close"})};case"claim":return{title:`Make ${s} yours`,description:t.withAccount?"Sign in with your DorkOS account in your browser, then come back.":"Sign in or create an account in your browser, then come back.",body:t.notice?n.jsx(Ct,{notice:t.notice}):void 0,actions:n.jsxs(n.Fragment,{children:[n.jsxs(_,{variant:t.opened?"outline":"default",disabled:t.busy,onClick:e.onOpenClaim,children:[t.opened?"Open it again":"Open in your browser",n.jsx(yn,{className:"size-3.5","aria-hidden":!0})]}),n.jsx(_,{variant:t.opened?"default":"outline",disabled:t.busy,onClick:e.onConfirmClaimed,children:t.busy?"Checking…":"I’ve finished"})]})};case"connecting":return{title:`Connect this DorkOS to ${s}`,description:t.approvalUrl?`Approve this DorkOS on ${s}. This page then moves on.`:"Getting the approval page ready…",body:n.jsxs(n.Fragment,{children:[t.approvalUrl&&!t.notice&&n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(wt,{className:"size-4"})," Waiting for your approval"]}),t.notice&&n.jsx(Ct,{notice:t.notice})]}),actions:t.notice?n.jsx(_,{disabled:t.busy,onClick:e.onRetryConnect,children:"Connect again"}):n.jsxs(_,{disabled:t.busy||!t.approvalUrl,onClick:e.onOpenApproval,children:["Open approval page",n.jsx(yn,{className:"size-3.5","aria-hidden":!0})]})};case"done":return{title:`${s} is ready`,description:e.doneDetail,body:n.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[n.jsx(fs,{className:"text-status-success-fg size-4","aria-hidden":!0}),"It’s selected in your spaces."]}),actions:n.jsx(_,{onClick:e.onClose,children:"Done"})}}}function Sj(e){const t=e.usage;if(!t)return null;const{maxActiveMembers:s,maxStorageBytes:r}=e.limits,o=`${t.activeMembers.toLocaleString()}${s!==null?` of ${s.toLocaleString()}`:""} ${t.activeMembers===1&&s===null?"person":"people"}`,a=`${vn(t.storageBytes)}${r!==null?` of ${vn(r)}`:""} of files`;return`${o} · ${a}`}function Cj({community:e,names:t,actions:s,onFinishSetup:r,onOpenMove:o}){const a=s.busyId===e.communityId,i=s.confirmingKeep===e.communityId,c=s.notices[e.communityId],d=Sj(e),m=e.actions.keep.wouldHold.map(h=>t.get(h)??"another space"),u=e.state==="held"||e.state==="deletion_pending"||e.state==="suspended";return n.jsxs("li",{className:"space-y-2 rounded-lg border p-3",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("p",{className:"truncate text-sm font-medium",children:e.name}),e.shortName&&n.jsx("p",{className:"text-muted-foreground truncate font-mono text-xs",children:e.shortName})]}),n.jsx(fn,{variant:u?"outline":"secondary",className:u?"border-status-warning-border text-status-warning-fg shrink-0":"shrink-0",children:hj(e.state)})]}),e.state==="unrecognised"&&n.jsx("p",{className:"text-muted-foreground text-sm",children:"Update DorkOS to see this space’s state."}),e.hold&&n.jsxs("div",{className:"space-y-1 text-sm",children:[n.jsx("p",{children:fj(e.hold.reason)}),n.jsxs("p",{className:"text-muted-foreground",children:["On hold since ",Zs(e.hold.since),"."]}),e.hold.deletionNoticeAt&&n.jsxs("p",{className:"text-destructive",children:["DorkOS may delete it after ",Zs(e.hold.deletionNoticeAt),". You can export it until then."]})]}),e.deletionAt&&n.jsxs("p",{className:"text-destructive text-sm",children:["It will be deleted for good on ",Zs(e.deletionAt),"."]}),e.notice&&n.jsxs("div",{className:"bg-muted/50 space-y-1 rounded-md p-2 text-sm",children:[n.jsx("p",{className:"font-medium break-words",children:e.notice.title}),e.notice.detail&&n.jsx("p",{className:"break-words",children:e.notice.detail}),e.notice.actionUrl&&n.jsxs(_,{size:"sm",variant:"outline",onClick:()=>dt(e.notice.actionUrl),children:[e.notice.actionLabel??"Learn more",n.jsx(yn,{className:"size-3.5","aria-hidden":!0})]})]}),d&&n.jsx("p",{className:"text-muted-foreground text-xs tabular-nums",children:d}),i&&n.jsxs("div",{role:"group","aria-label":`Keep ${e.name} open`,className:"space-y-2 text-sm",children:[n.jsx("p",{children:m.length===0?`Keep ${e.name} open? Nothing else changes.`:`Keeping ${e.name} open puts ${m.length===1?"this one":"these"} on hold: ${m.join(", ")}. People can still read ${m.length===1?"it":"them"}.`}),n.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.jsx(_,{size:"sm",variant:"outline",onClick:s.cancelKeep,children:"Cancel"}),n.jsx(_,{size:"sm",disabled:a,onClick:()=>void s.keep(e),children:"Keep it open"})]})]}),c&&n.jsx(Ct,{notice:c}),!i&&n.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.actions.claimLink&&n.jsx(_,{size:"sm",onClick:()=>r(e),children:"Finish setting up"}),e.moveId&&n.jsx(_,{size:"sm",variant:"outline",onClick:()=>o(e.moveId),children:"See the move"}),e.actions.keep.allowed&&n.jsx(_,{size:"sm",variant:"outline",disabled:a,onClick:()=>s.askKeep(e.communityId),children:"Keep this one open"}),e.actions.restore&&n.jsx(_,{size:"sm",variant:"outline",disabled:a,onClick:()=>void s.restore(e),children:a?"Reopening…":"Reopen"})]})]})}function Nj(e){switch(e.state){case"awaiting_upload":return{text:"Uploading the export"};case"importing":return{text:"Moving the history"};case"ready":return{text:"Ready to make yours"};case"claimed":return{text:"Moved"};case"cancelled":return{text:"Cancelled"};case"failed":{const t=Cd(e.failureCode??"unrecognised");return{text:t.title,next:t.next}}default:return{text:"Unknown state. Update DorkOS to see more."}}}function Aj(e){const t=new Map(e.communities.map(s=>[s.communityId,s.name]));return n.jsxs("div",{className:"space-y-4",children:[e.allowanceText&&n.jsx("p",{className:"text-muted-foreground text-sm",children:e.allowanceText}),e.communities.length>0?n.jsx("ul",{className:"space-y-2",children:e.communities.map(s=>n.jsx(Cj,{community:s,names:t,actions:e.actions,onFinishSetup:e.onFinishSetup,onOpenMove:e.onOpenMove},s.communityId))}):n.jsx("p",{className:"text-muted-foreground text-sm",children:"No spaces yet."}),e.moves.length>0&&n.jsxs("section",{"aria-labelledby":"hosted-moves",className:"space-y-2",children:[n.jsx("h4",{id:"hosted-moves",className:"text-sm font-medium",children:"Recent moves"}),n.jsx("ul",{className:"space-y-2",children:e.moves.map(s=>{const r=Nj(s),o=s.state==="awaiting_upload"||s.state==="importing"||s.state==="ready";return n.jsxs("li",{className:"flex flex-wrap items-start justify-between gap-2 rounded-lg border p-3",children:[n.jsxs("div",{className:"min-w-0 space-y-0.5 text-sm",children:[n.jsx("p",{className:"truncate font-medium",children:s.name}),n.jsx("p",{className:s.state==="failed"?"text-destructive":"text-muted-foreground",children:r.text}),r.next&&n.jsx("p",{className:"text-muted-foreground",children:r.next})]}),o&&n.jsx(_,{size:"sm",variant:"outline",onClick:()=>e.onOpenMove(s.moveId),children:"Continue"})]},s.moveId)})})]})]})}function Ej(e){return e.open?n.jsx(Ij,{...e}):null}function Ij({open:e,onOpenChange:t,installName:s,onOpenMove:r,onMoveHere:o,onConnected:a}){var f;const i=Cc(!0),c=kj(),[d,m]=l.useState(null),u=Eo(d,s,a),h=()=>t(!1);let p;if(d)p=Oo({state:u.state,name:d.name,doneDetail:"Invite people from the space’s own settings when you’re ready.",onOpenClaim:u.openClaim,onConfirmClaimed:u.confirmClaimed,onOpenApproval:u.openApproval,onRetryConnect:u.retryConnect,onClose:h});else{const g=((f=i.data)==null?void 0:f.available)===!0?i.data:null;p={title:"Your spaces",description:"Spaces hosted under your DorkOS account.",body:i.isPending?n.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading…"}):g?n.jsx(Aj,{communities:g.communities,moves:g.moves,allowanceText:Nd(g.allowance),actions:c,onFinishSetup:m,onOpenMove:x=>{h(),r(x)}}):n.jsx(Ct,{notice:{message:"Couldn’t reach your DorkOS account. Try again."}}),actions:n.jsxs(n.Fragment,{children:[n.jsx(_,{variant:"outline",onClick:h,children:"Close"}),n.jsx(_,{variant:"outline",onClick:()=>{h(),o()},children:"Move one here"})]})}}return n.jsx(Do,{open:e,onOpenChange:t,step:p})}function Tj(e){switch(e.kind){case"invalid":return{text:Ad,error:!0};case"checking":return{text:"Checking…",error:!1};case"available":return{text:"That web address is free.",error:!1};case"taken":return{text:"That web address is taken.",error:!0};case"reserved":return{text:"That web address can’t be used.",error:!0};default:return null}}function Rd(e){const t=l.useId(),s=e.webAddressError?{text:e.webAddressError,error:!0}:Tj(e.webAddressStatus);return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_e,{htmlFor:`${t}-name`,children:"Space name"}),n.jsx(Ze,{id:`${t}-name`,required:!0,maxLength:pj,autoComplete:"off",value:e.name,disabled:e.disabled,onChange:r=>e.onNameChange(r.target.value)})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsxs(_e,{htmlFor:`${t}-address`,children:["Web address ",n.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),n.jsx(Ze,{id:`${t}-address`,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,maxLength:32,placeholder:"book-club",value:e.webAddress,disabled:e.disabled,"aria-invalid":(s==null?void 0:s.error)||void 0,"aria-describedby":`${t}-address-hint`,onChange:r=>e.onWebAddressChange(r.target.value)}),n.jsx("p",{id:`${t}-address-hint`,"aria-live":"polite",className:s!=null&&s.error?"text-destructive text-sm":"text-muted-foreground text-sm",children:(s==null?void 0:s.text)??Ad})]})]})}const Rj="Your history is here. Send invitations so people can join again.";function Dj(e,t){return{title:"Move a space here",description:"This copies your space’s history and files to DorkOS.",body:n.jsxs("div",{className:"space-y-2 text-sm",children:[n.jsx("p",{children:"Everyone joins again and reconnects their DorkOS."}),n.jsx("p",{className:"text-muted-foreground",children:"Your old space keeps running until you delete it."}),n.jsx("p",{className:"font-medium",children:"First, export the old space:"}),n.jsxs("ol",{className:"text-muted-foreground list-decimal space-y-1 pl-5",children:[n.jsx("li",{children:"Sign in to the old space as its owner."}),n.jsx("li",{children:"Open its Settings."}),n.jsx("li",{children:"Choose Export."}),n.jsx("li",{children:"Enter your password."}),n.jsx("li",{children:"Save the .zip file."})]})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(_,{variant:"outline",onClick:t,children:"Cancel"}),n.jsx(_,{onClick:e,children:"I have the file"})]})}}function Oj({file:e,onFileChange:t}){const s=l.useId();return n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_e,{htmlFor:s,children:"Export file"}),n.jsx(Ze,{id:s,type:"file",accept:".zip,application/zip",onChange:r=>{var o;return t(((o=r.target.files)==null?void 0:o[0])??null)},className:"cursor-pointer"}),e&&n.jsxs("p",{className:"text-muted-foreground text-sm break-all",children:[e.name,", ",vn(e.size)]})]})}function Mj(e){const t=Pn(e.webAddress),s=e.file===null||e.name.trim()===""||!t.valid||e.webAddressStatus.kind==="taken"||e.webAddressStatus.kind==="reserved";return{title:"Choose the export",description:"Pick the .zip file, then name the space.",body:n.jsxs("form",{id:e.formId,onSubmit:e.onSubmit,className:"space-y-4",noValidate:!0,children:[n.jsx(Oj,{file:e.file,onFileChange:e.onFileChange}),n.jsx(Rd,{name:e.name,onNameChange:e.onNameChange,webAddress:e.webAddress,onWebAddressChange:e.onWebAddressChange,webAddressStatus:e.webAddressStatus,webAddressError:e.failure.field,disabled:!1}),e.failure.notice&&n.jsx(Ct,{notice:e.failure.notice}),n.jsx(Nc,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(_,{type:"button",variant:"outline",onClick:e.onBack,children:"Back"}),n.jsx(_,{type:"submit",form:e.formId,disabled:s,children:"Start moving"})]})}}function Dd({label:e,loaded:t,total:s}){const r=s>0?Math.round(t/s*100):0;return n.jsxs("div",{className:"space-y-2",children:[n.jsx(zm,{value:r,"aria-label":e}),n.jsxs("p",{className:"text-muted-foreground text-sm tabular-nums",children:[vn(t)," of ",vn(s)]})]})}function _j(e,t){return{title:"Getting the file ready",description:"Keep this open. The upload then starts on its own.",body:n.jsx(Dd,{label:"Getting the file ready",...e}),actions:n.jsx(_,{variant:"outline",onClick:t,children:"Cancel"})}}function Pj(e){const t=e.report;if(!t)return null;const s=r=>r.toLocaleString();return`${s(t.channels)} ${t.channels===1?"channel":"channels"}, ${s(t.entries)} ${t.entries===1?"message":"messages"} and ${s(t.attachments)} ${t.attachments===1?"file":"files"}.`}function Lj(e,t){const{move:s}=e,r=t.notice?n.jsx(Ct,{notice:t.notice}):null,o=n.jsx(_,{variant:"outline",disabled:t.busy,onClick:t.onCancelMove,children:"Cancel move"}),a=n.jsx(_,{onClick:t.onStartOver,children:"Start again"}),i=n.jsx(_,{variant:"outline",onClick:t.onClose,children:"Close"});switch(e.kind){case"uploading":{const c=s.upload;return{title:`Uploading ${s.name}`,description:"You can close this window. Keep DorkOS running until it finishes.",body:n.jsxs(n.Fragment,{children:[n.jsx(Dd,{label:`Uploading ${s.name}`,loaded:c.sentBytes,total:c.totalBytes}),r]}),actions:o}}case"upload-failed":return e.why==="interrupted"?{title:"The upload didn’t finish",description:"DorkOS still has the file. Send it again to continue.",body:r,actions:n.jsxs(n.Fragment,{children:[o,n.jsx(_,{disabled:t.busy,onClick:t.onSendAgain,children:"Send again"})]})}:e.why==="refused"?{title:"DorkOS didn’t accept the file",description:"The file arrived changed or incomplete.",body:n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Cancel the move, export the old space again, then start again."}),r]}),actions:o}:e.why==="restarted"?{title:"This move has to start again",description:"DorkOS restarted, or the move began on another computer.",body:n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-muted-foreground text-sm",children:"Cancel the move and start again with the same export."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"Or finish it on the computer that started it."}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"For safety, uploads only work while DorkOS stays running."}),r]}),actions:o}:{title:"The time to upload ran out",description:"Cancel the move, then start again with the same export.",body:r,actions:o};case"importing":{const c=Pj(s);return{title:`Moving ${s.name}`,description:"You can close this window or quit. The move keeps going.",body:n.jsxs(n.Fragment,{children:[n.jsxs("p",{role:"status",className:"text-muted-foreground flex items-center gap-2 text-sm",children:[n.jsx(wt,{className:"size-4"})," Moving your history…"]}),c&&n.jsx("p",{className:"text-sm",children:c}),r]}),actions:n.jsxs(n.Fragment,{children:[o,n.jsx(_,{onClick:t.onClose,children:"Close"})]})}}case"failed":{const c=Cd(s.failureCode??"unrecognised");return{title:c.title,description:c.next,body:n.jsx("p",{className:"text-muted-foreground text-sm",children:"Nothing was kept. Your old space is unchanged."}),actions:n.jsxs(n.Fragment,{children:[i,a]})}}case"cancelled":return{title:"Move cancelled",description:"Nothing was kept. Your old space is unchanged.",actions:n.jsxs(n.Fragment,{children:[i,a]})};case"unrecognised":return{title:`Moving ${s.name}`,description:"Update DorkOS to see where this move is.",body:r,actions:i}}}function Fj(e){return e.open?n.jsx($j,{...e}):null}function $j({open:e,onOpenChange:t,installName:s,resumeMoveId:r,onConnected:o}){var C,v;const[a,i]=l.useState("explain"),[c,d]=l.useState(null),[m,u]=l.useState(""),[h,p]=l.useState(""),f=vj(r),g=Td(a==="choose"&&!f.step?h:""),x=((C=f.step)==null?void 0:C.kind)==="ready"?f.step.move:null,b=Eo(x?{communityId:x.communityId,name:x.name,communityUrl:x.communityUrl}:null,s,o),y=()=>t(!1);function k(N){N.preventDefault();const I=Pn(h);!c||m.trim()===""||!I.valid||f.start({file:c,name:m,shortName:I.value})}let j;return f.sending?j=_j(f.sending,()=>void f.cancel()):((v=f.step)==null?void 0:v.kind)==="ready"?j=Oo({state:b.state,name:f.step.move.name,doneDetail:Rj,onOpenClaim:b.openClaim,onConfirmClaimed:b.confirmClaimed,onOpenApproval:b.openApproval,onRetryConnect:b.retryConnect,onClose:y}):f.step?j=Lj(f.step,{busy:f.busy,notice:f.failure.notice,onCancelMove:()=>void f.cancel(),onSendAgain:()=>void f.sendAgain(),onStartOver:()=>{f.startOver(),i("choose")},onClose:y}):a==="explain"?j=Dj(()=>i("choose"),y):j=Mj({file:c,onFileChange:d,name:m,onNameChange:u,webAddress:h,onWebAddressChange:N=>{p(N),f.clearFieldFailure()},webAddressStatus:g,failure:f.failure,formId:"move-community-form",onSubmit:k,onBack:()=>i("explain")}),n.jsx(Do,{open:e,onOpenChange:t,step:j,locked:f.sending!==null})}function Bj(e){const t=Pn(e.webAddress),s=e.name.trim()===""||!t.valid||e.webAddressStatus.kind==="taken"||e.webAddressStatus.kind==="reserved",r=Nd(e.allowance);return{title:"Start a space",description:"Share channels with people and agents. You own it.",body:n.jsxs("form",{id:e.formId,onSubmit:e.onSubmit,className:"space-y-4",noValidate:!0,children:[n.jsx(Rd,{name:e.name,onNameChange:e.onNameChange,webAddress:e.webAddress,onWebAddressChange:e.onWebAddressChange,webAddressStatus:e.webAddressStatus,webAddressError:e.failure.field,disabled:e.submitting}),r&&n.jsx("p",{className:"text-muted-foreground text-sm",children:r}),e.failure.notice&&n.jsx(Ct,{notice:e.failure.notice}),n.jsx(Nc,{})]}),actions:n.jsxs(n.Fragment,{children:[n.jsx(_,{type:"button",variant:"outline",onClick:e.onCancel,children:"Cancel"}),n.jsx(_,{type:"submit",form:e.formId,disabled:s||e.submitting,children:e.submitting?"Starting…":"Start space"})]})}}function zj(e){return e.open?n.jsx(Uj,{...e}):null}function Uj({open:e,onOpenChange:t,installName:s,allowance:r,onConnected:o}){const[a,i]=l.useState(""),[c,d]=l.useState(""),[m,u]=l.useState(null),h=xj(),p=Td(m?"":c),f=Eo(m,s,o),g=()=>t(!1);async function x(y){y.preventDefault();const k=Pn(c);if(a.trim()===""||!k.valid||h.submitting)return;const j=await h.submit({name:a,shortName:k.value});j&&u({communityId:j.community.communityId,name:j.community.name,communityUrl:j.community.communityUrl})}const b=m?Oo({state:f.state,name:m.name,doneDetail:"Invite people from the space’s own settings when you’re ready.",onOpenClaim:f.openClaim,onConfirmClaimed:f.confirmClaimed,onOpenApproval:f.openApproval,onRetryConnect:f.retryConnect,onClose:g}):Bj({name:a,webAddress:c,onNameChange:i,onWebAddressChange:y=>{d(y),h.clearFieldFailure()},webAddressStatus:p,submitting:h.submitting,failure:h.failure,allowance:r,formId:"start-community-form",onSubmit:y=>void x(y),onCancel:g});return n.jsx(Do,{open:e,onOpenChange:t,step:b,locked:h.submitting})}function Kj({entry:e,dialog:t,onDialogChange:s,installName:r,onConnected:o}){if(e===null)return null;const a=i=>{i||s(null)};return n.jsxs(n.Fragment,{children:[n.jsx(zj,{open:(t==null?void 0:t.kind)==="start",onOpenChange:a,installName:r,allowance:e.allowance,onConnected:o}),n.jsx(Fj,{open:(t==null?void 0:t.kind)==="move",onOpenChange:a,installName:r,resumeMoveId:(t==null?void 0:t.kind)==="move"?t.moveId:null,onConnected:o},(t==null?void 0:t.kind)==="move"?t.moveId??"new":"closed"),n.jsx(Ej,{open:(t==null?void 0:t.kind)==="hosted",onOpenChange:a,installName:r,onOpenMove:i=>s({kind:"move",moveId:i}),onMoveHere:()=>s({kind:"move",moveId:e.unfinishedMoveId}),onConnected:o})]})}const Hj=.1;function qj(e){if(!(e!=null&&e.available)||e.balance===null)return null;const{allowance:t,purchased:s,denomination:r}=e.balance,o=Um(t.remainingMicro,t.grantedMicro);if(o===null||o>=Hj||!/^\d+$/.test(t.remainingMicro)||!/^\d+$/.test(s.remainingMicro)||BigInt(s.remainingMicro)>0n)return null;const a=Km(Hm(t.remainingMicro,r));return a===null?null:`${a} left`}function Wj(e){if(e.state!=="loading")return e.state==="signed-out"?"Not signed in":["Signed in",e.label,e.lowCredits].filter(Boolean).join(" · ")}function Gj(){var r;const e=Ac(),t=((r=e.data)==null?void 0:r.linked)===!0,s=Ec({enabled:t});return e.data===void 0?{state:"loading"}:t?{state:"signed-in",label:e.data.accountLabel,lowCredits:qj(s.data)}:{state:"signed-out"}}function Od(e){return e.kind==="agent"?kt("agent",e.agent.projectPath):kt("room",e.room.id)}function Tr(e){return e.kind==="agent"?ke(e.agent):e.room.kind==="channel"&&e.room.slug?`#${e.room.slug}`:e.room.title}function Ba(e){return`Conversations ${e.kind==="agent"?"with":"in"} ${Tr(e)}`}function Yj(e){return e.kind==="agent"?`No conversations with ${Tr(e)} yet.`:`No conversations came from ${Tr(e)}.`}function Vj(e){return e.kind==="channel"&&e.slug?`#${e.slug}`:e.title}function Qj(e){const t=new Map,s=[...e].sort((r,o)=>{const a=+(r.kind==="dm")-+(o.kind==="dm");return a!==0?a:Number(r.archived)-Number(o.archived)});for(const r of s){const o=Vj(r);t.has(o)||t.set(o,r.id)}return t}function Xj(e,t){const s=[];e.cwd!==null&&s.push(kt("agent",e.cwd));const r=Jj(e,t);return r!==void 0&&s.push(kt("room",r)),s}function Jj(e,t){if(e.origin==="room"){if(e.originRoomId!==void 0)return e.originRoomId;if(e.originLabel!==void 0)return t.get(e.originLabel)}}function Zj(e,t){const s=Number(e.archived)-Number(t.archived);if(s!==0)return s;const r=Number(_t(t))-Number(_t(e));return r!==0?r:t.lastActivityAt.localeCompare(e.lastActivityAt)||t.id.localeCompare(e.id)}function er(e){return[...e].sort(Zj)}function Rr(e){const t=[e.title];e.slug&&t.push(e.slug);for(const s of e.participants??[])t.push(s.displayName);return t}function e0(){const{data:e,isLoading:t,isError:s}=Ns({includeArchived:!0});return l.useMemo(()=>{const r=e??[],o=er(r.filter(i=>i.kind==="channel")),a=er(r.filter(i=>i.kind==="dm"));return{channels:o,dms:a,unread:er([...o,...a].filter(i=>!i.archived&&_t(i))),isLoading:t,isError:s}},[e,t,s])}const t0=8;function n0(e,t){const s=new Set(qm(Object.keys(e),t)),r=[];for(const[o,a]of Object.entries(e))a&&s.has(o)&&(a.lifecycle!=="streaming"&&a.lifecycle!=="blocked"||r.push({sessionId:o,lifecycle:a.lifecycle,activity:a.activity??null}));return r.sort((o,a)=>o.lifecycle!==a.lifecycle?o.lifecycle==="blocked"?-1:1:o.sessionId.localeCompare(a.sessionId))}function za(e){const t=Date.parse(e.lastActivityAt);return Number.isNaN(t)?Number.NEGATIVE_INFINITY:t}function s0(e){return!(e.unreadCount===null||e.archived||e.lastActivityAt===e.createdAt)}function r0({sessions:e,rooms:t,unreadRoomIds:s,agents:r,agentActivity:o,excludeSessionIds:a=new Set,limit:i=t0}){const c=e.filter(g=>!a.has(g.id)).map(g=>({kind:"session",key:`session:${g.id}`,lastActivityAt:g.lastActivityAt,session:g})),d=new Set(e.flatMap(g=>g.cwd?[g.cwd]:[])),m=t.filter(s0).map(g=>({kind:"room",key:`room:${g.id}`,lastActivityAt:g.lastActivityAt,room:g})),u=r.flatMap(g=>{if(d.has(g.projectPath))return[];const x=o[g.projectPath];return x?[{kind:"agent",key:`agent:${g.projectPath}`,lastActivityAt:x,agent:g}]:[]}),h=[],p=[];for(const g of[...c,...m,...u])g.kind==="room"&&s.has(g.room.id)?h.push(g):p.push(g);const f=(g,x)=>za(x)-za(g)||x.key.localeCompare(g.key);return[...h.sort(f),...p.sort(f)].slice(0,i)}const o0=50;function Md(e){const t=[e.id];return e.who&&t.push(e.who),e.cwd&&t.push(e.cwd),t}function a0(e){return e?e.split("/").filter(Boolean).pop()??null:null}function Ua(e,t,s){const r=new Map(t.map(o=>[o.projectPath,o]));return e.map(o=>{const a=o.cwd??null,i=a?r.get(a)??null:null,c=Date.parse(o.updatedAt);return{id:o.id,who:i?ke(i):a0(a),title:Ic(o.title),cwd:a,agent:i,origin:o.origin,originLabel:o.originLabel,originRoomId:o.originRoomId,lastActivityAt:o.updatedAt,archived:!Number.isNaN(c)&&c<s}})}function i0(e,t,s,r){const{data:o}=Tc(o0),a=ct(p=>p.statuses),i=ct(Rc(p=>Object.values(p.sessions))),c=l.useMemo(()=>Ua((o==null?void 0:o.sessions)??[],e,r),[o==null?void 0:o.sessions,e,r]),d=l.useMemo(()=>Ua(i,e,r),[i,e,r]),m=l.useMemo(()=>[...i,...(o==null?void 0:o.sessions)??[]],[i,o]),u=l.useMemo(()=>{const p=new Map;for(const f of d)p.set(f.id,f);for(const f of c)p.has(f.id)||p.set(f.id,f);return n0(a,m).flatMap(f=>{const g=p.get(f.sessionId);return g?[{session:g,verb:Wm(f.lifecycle,f.activity),signal:f.lifecycle==="blocked"?"needs-you":"working"}]:[]})},[a,d,c,m]),h=l.useMemo(()=>{const p=new Set(Gm(o!=null&&o.sessions?[...o.sessions]:[]).conversations.map(f=>f.id));return r0({sessions:c.filter(f=>p.has(f.id)),rooms:t,unreadRoomIds:s,agents:e,agentActivity:(o==null?void 0:o.agentActivity)??{},excludeSessionIds:new Set(u.map(f=>f.session.id))})},[o,c,t,s,e,u]);return{sessions:c,continueRows:u,recent:h,agentActivity:(o==null?void 0:o.agentActivity)??c0}}const c0=Object.freeze({});function l0(){const{data:e,dataUpdatedAt:t}=Oe(),s=e!==void 0&&t>Pt,{status:r,url:o}=Ym(e==null?void 0:e.tunnel),a=l.useRef(void 0);l.useEffect(()=>{if(!s)return;const i=a.current;a.current=r,!(i===void 0||i===r)&&(Vm.getState().consumeSuppression()||(r==="reconnecting"?ae.warning("Remote access is reconnecting",{id:"tunnel-status",description:"Your other devices can’t reach DorkOS until then."}):r==="off"?ae.error("Remote access turned off",{id:"tunnel-status",description:"Your other devices can’t reach DorkOS now."}):o&&ae.success("Remote access is on",{id:"tunnel-status",description:o})))},[s,r,o])}const at={copyLink:"copyRemoteLink",showQr:"showRemoteQr",turnOn:"turnRemoteAccessOn",turnOff:"turnRemoteAccessOff"},Wn={copyLink:11,showQr:12,turnOff:13,turnOn:11};function d0(e,t,s){return(e==="connected"||e==="reconnecting")&&t?[{id:"remote-access-copy",label:"Copy remote link",icon:"Copy",action:at.copyLink,category:"quick-action",priority:Wn.copyLink,keywords:["remote","tunnel","url","address","phone","share"]},{id:"remote-access-qr",label:"Show QR code",icon:"QrCode",action:at.showQr,category:"quick-action",priority:Wn.showQr,keywords:["remote","tunnel","scan","phone"]},{id:"remote-access-off",label:"Turn remote access off",icon:"Globe",action:at.turnOff,category:"quick-action",priority:Wn.turnOff,keywords:["remote","tunnel","ngrok","stop","disconnect"]}]:s&&(e==="off"||e==="error")?[{id:"remote-access-on",label:"Turn remote access on",icon:"Globe",action:at.turnOn,category:"quick-action",priority:Wn.turnOn,keywords:["remote","tunnel","ngrok","phone","start"]}]:[]}function u0(){const{state:e,url:t,tokenConfigured:s}=Dc();return l.useMemo(()=>d0(e,t,s),[e,t,s])}const Gn={usageKey:null,lastActivityAt:null,waiting:!1,demoted:!1,scopes:[]};function Ka(e){return{usageKey:kt("room",e.id),lastActivityAt:e.lastActivityAt,waiting:_t(e),demoted:e.archived,scopes:[]}}function m0(e,t){const{data:s,isLoading:r}=Rn(),o=e0(),{sessions:a}=Oc(),i=l.useMemo(()=>!a||!e?null:Qm(a,e)[0]??null,[a,e]),{data:c}=wx(e,i==null?void 0:i.id,i==null?void 0:i.runtime),d=Cs("command-palette.items"),m=Mc(),u=l.useMemo(()=>m.map(E=>({id:E.id,label:E.title,href:_c(E.extensionId,E.path),icon:E.icon})),[m]),h=l.useMemo(()=>d.filter(E=>E.category==="feature"),[d]),p=u0(),f=l.useMemo(()=>[...d.filter(E=>E.category==="quick-action"),...p],[d,p]),g=l.useMemo(()=>Xm.flatMap(E=>{const w=f.find(A=>A.id===E);return w?[w]:[]}),[f]),x=l.useMemo(()=>(s==null?void 0:s.agents)??[],[s]),b=l.useMemo(()=>new Set(o.unread.map(E=>E.id)),[o.unread]),y=l.useMemo(()=>[...o.channels,...o.dms],[o.channels,o.dms]),k=l.useMemo(()=>Jm(t),[t]),{sessions:j,continueRows:C,recent:v,agentActivity:N}=i0(x,y,b,k),I=l.useMemo(()=>Qj(y),[y]),D=l.useMemo(()=>c?c.commands.map(E=>({name:E.fullCommand,description:E.description})):[],[c]),T=l.useMemo(()=>{const E=[];for(const w of x)E.push({id:w.id,name:w.name,type:"agent",keywords:[w.projectPath,w.id],usageKey:kt("agent",w.projectPath),lastActivityAt:N[w.projectPath]??null,waiting:!1,demoted:!1,scopes:[],data:w});for(const w of j)E.push({id:w.id,name:w.title,type:"session",keywords:Md(w),usageKey:kt("session",w.id),lastActivityAt:w.lastActivityAt,waiting:!1,demoted:!1,scopes:Xj(w,I),data:w});for(const w of h)E.push({id:w.id,name:w.label,type:"feature",keywords:w.keywords,...Gn,data:w});for(const w of D)E.push({id:`cmd-${w.name}`,name:w.name,type:"command",keywords:w.description?[w.description]:void 0,...Gn,data:w});for(const w of f)E.push({id:w.id,name:w.label,type:"quick-action",keywords:w.keywords,...Gn,data:w});for(const w of o.channels)E.push({id:w.id,name:to(w),type:"room",keywords:Rr(w),...Ka(w),data:w});for(const w of o.dms)E.push({id:w.id,name:w.title,type:"dm",keywords:Rr(w),...Ka(w),data:w});for(const w of u)E.push({id:w.id,name:w.label,type:"page",keywords:["add-on","extension"],...Gn,data:w});return E},[x,N,j,D,h,f,o.channels,o.dms,I,u]);return{allAgents:x,newActions:g,rooms:o,sessions:j,continueRows:C,recent:v,searchableItems:T,isLoading:r}}function h0(){const e=B(a=>a.toggleGlobalPalette),t=B(a=>a.setGlobalPaletteOpen),s=B(a=>a.globalPaletteOpen),{close:r}=qe(),{close:o}=so();return l.useEffect(()=>{const a=i=>{(i.metaKey||i.ctrlKey)&&i.key==="k"&&(i.preventDefault(),s||(r(),o()),e())};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,r,o,s]),{globalPaletteOpen:s,setGlobalPaletteOpen:t,toggleGlobalPalette:e}}function ht(e){return Array.isArray?Array.isArray(e):Pd(e)==="[object Array]"}function f0(e){if(typeof e=="string")return e;if(typeof e=="bigint")return e.toString();const t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function Dr(e){return e==null?"":f0(e)}function je(e){return typeof e=="string"}function es(e){return typeof e=="number"}function p0(e){return e===!0||e===!1||g0(e)&&Pd(e)=="[object Boolean]"}function _d(e){return typeof e=="object"}function g0(e){return _d(e)&&e!==null}function Re(e){return e!=null}function Yn(e){return!e.trim().length}function Pd(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const x0="Incorrect 'index' type",Or="Invalid doc index: must be a non-negative integer within the bounds of the docs array",y0=e=>`Invalid value for key ${e}`,b0=e=>`Pattern length exceeds max of ${e}.`,v0=e=>`Missing ${e} property in key`,w0=e=>`Property 'weight' in key '${e}' must be a positive integer`,j0="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",Ha=Object.prototype.hasOwnProperty;var k0=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(s=>{const r=Ld(s);this._keys.push(r),this._keyMap[r.id]=r,t+=r.weight}),this._keys.forEach(s=>{s.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function Ld(e){let t=null,s=null,r=null,o=1,a=null;if(je(e)||ht(e))r=e,t=qa(e),s=ts(e);else{if(!Ha.call(e,"name"))throw new Error(v0("name"));const i=e.name;if(r=i,Ha.call(e,"weight")&&e.weight!==void 0&&(o=e.weight,o<=0))throw new Error(w0(ts(i)));t=qa(i),s=ts(i),a=e.getFn??null}return{path:t,id:s,weight:o,src:r,getFn:a}}function qa(e){return ht(e)?e:e.split(".")}function ts(e){return ht(e)?e.join("."):e}function S0(e,t){const s=[];let r=!1;const o=(a,i,c,d)=>{if(Re(a))if(!i[c])s.push(d!==void 0?{v:a,i:d}:a);else{const m=a[i[c]];if(!Re(m))return;if(c===i.length-1&&(je(m)||es(m)||p0(m)||typeof m=="bigint"))s.push(d!==void 0?{v:Dr(m),i:d}:Dr(m));else if(ht(m)){r=!0;for(let u=0,h=m.length;u<h;u+=1)o(m[u],i,c+1,u)}else i.length&&o(m,i,c+1,d)}};return o(e,je(t)?t.split("."):t,0),r?s:s[0]}const C0={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},N0={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},A0={location:0,threshold:.6,distance:100},E0={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:S0,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},Y=Object.freeze({...N0,...C0,...A0,...E0});function I0(e){return e>=9&&e<=13||e===32||e===160}function T0(e=1,t=3){const s=new Map,r=Math.pow(10,t);return{get(o){let a=0,i=!1;for(let d=0;d<o.length;d++)I0(o.charCodeAt(d))?i=!1:i||(a++,i=!0);if(a===0&&(a=1),s.has(a))return s.get(a);const c=Math.round(r/Math.pow(a,.5*e))/r;return s.set(a,c),c},clear(){s.clear()}}}var Mo=class{constructor({getFn:e=Y.getFn,fieldNormWeight:t=Y.fieldNormWeight}={}){this.norm=T0(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((t,s)=>{this._keysMap[t.id]=s})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const e=this.docs.length;this.records=new Array(e);let t=0;if(je(this.docs[0]))for(let s=0;s<e;s++){const r=this._createStringRecord(this.docs[s],s);r&&(this.records[t++]=r)}else for(let s=0;s<e;s++)this.records[t++]=this._createObjectRecord(this.docs[s],s);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw new Error(Or);if(je(e)){const r=this._createStringRecord(e,t);return r&&this.records.push(r),r}const s=this._createObjectRecord(e,t);return this.records.push(s),s}removeAt(e){if(!Number.isInteger(e)||e<0)throw new Error(Or);for(let t=0,s=this.records.length;t<s;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,s=this.records.length;t<s;t+=1)this.records[t].i>e&&(this.records[t].i-=1)}removeAll(e){const t=new Set;for(const r of e)Number.isInteger(r)&&r>=0&&t.add(r);if(t.size===0)return;this.records=this.records.filter(r=>!t.has(r.i));const s=Array.from(t).sort((r,o)=>r-o);for(const r of this.records){let o=0,a=s.length;for(;o<a;){const i=o+a>>>1;s[i]<r.i?o=i+1:a=i}r.i-=o}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_createStringRecord(e,t){return!Re(e)||Yn(e)?null:{v:e,i:t,n:this.norm.get(e)}}_createObjectRecord(e,t){const s={i:t,$:{}};for(let r=0,o=this.keys.length;r<o;r++){const a=this.keys[r],i=a.getFn?a.getFn(e):this.getFn(e,a.path);if(Re(i)){if(ht(i)){const c=[];for(let d=0,m=i.length;d<m;d+=1){const u=i[d];if(Re(u)){if(je(u)){if(!Yn(u)){const h={v:u,i:d,n:this.norm.get(u)};c.push(h)}}else if(Re(u.v)){const h=je(u.v)?u.v:Dr(u.v);if(!Yn(h)){const p={v:h,i:u.i,n:this.norm.get(h)};c.push(p)}}}}s.$[r]=c}else if(je(i)&&!Yn(i)){const c={v:i,n:this.norm.get(i)};s.$[r]=c}}}return s}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}};function Fd(e,t,{getFn:s=Y.getFn,fieldNormWeight:r=Y.fieldNormWeight}={}){const o=new Mo({getFn:s,fieldNormWeight:r});return o.setKeys(e.map(Ld)),o.setSources(t),o.create(),o}function R0(e,{getFn:t=Y.getFn,fieldNormWeight:s=Y.fieldNormWeight}={}){const{keys:r,records:o}=e,a=new Mo({getFn:t,fieldNormWeight:s});return a.setKeys(r),a.setIndexRecords(o),a}function D0(e=[],t=Y.minMatchCharLength){const s=[];let r=-1,o=-1,a=0;for(let i=e.length;a<i;a+=1){const c=e[a];c&&r===-1?r=a:!c&&r!==-1&&(o=a-1,o-r+1>=t&&s.push([r,o]),r=-1)}return e[a-1]&&a-r>=t&&s.push([r,a-1]),s}function O0(e,t,s,{location:r=Y.location,distance:o=Y.distance,threshold:a=Y.threshold,findAllMatches:i=Y.findAllMatches,minMatchCharLength:c=Y.minMatchCharLength,includeMatches:d=Y.includeMatches,ignoreLocation:m=Y.ignoreLocation}={}){if(t.length>32)throw new Error(b0(32));const u=t.length,h=e.length,p=Math.max(0,Math.min(r,h));let f=a,g=p;const x=(T,E)=>{const w=T/u;if(m)return w;const A=Math.abs(p-E);return o?w+A/o:A?1:w},b=c>1||d,y=b?Array(h):[];let k;for(;(k=e.indexOf(t,g))>-1;){const T=x(0,k);if(f=Math.min(T,f),g=k+u,b){let E=0;for(;E<u;)y[k+E]=1,E+=1}}g=-1;let j=[],C=1,v=0,N=u+h;const I=1<<u-1;for(let T=0;T<u;T+=1){let E=0,w=N;for(;E<w;)x(T,p+w)<=f?E=w:N=w,w=Math.floor((N-E)/2+E);N=w;let A=Math.max(1,p-w+1);const S=i?h:Math.min(p+w,h)+u,M=Array(S+2);M[S+1]=(1<<T)-1;for(let R=S;R>=A;R-=1){const O=R-1,P=s[e[O]];if(M[R]=(M[R+1]<<1|1)&P,T&&(M[R]|=(j[R+1]|j[R])<<1|1|j[R+1]),M[R]&I&&(C=x(T,O),C<=f)){if(f=C,g=O,v=T,g<=p)break;A=Math.max(1,2*p-g)}}if(x(T+1,p)>f)break;j=M}if(b&&g>=0){const T=Math.min(h-1,g+u-1+v);for(let E=g;E<=T;E+=1)s[e[E]]&&(y[E]=1)}const D={isMatch:g>=0,score:Math.max(.001,C)};if(b){const T=D0(y,c);T.length?d&&(D.indices=T):D.isMatch=!1}return D}function M0(e){const t={};for(let s=0,r=e.length;s<r;s+=1){const o=e.charAt(s);t[o]=(t[o]||0)|1<<r-s-1}return t}function _o(e){if(e.length<=1)return e;e.sort((s,r)=>s[0]-r[0]||s[1]-r[1]);const t=[e[0]];for(let s=1,r=e.length;s<r;s+=1){const o=t[t.length-1],a=e[s];a[0]<=o[1]+1?o[1]=Math.max(o[1],a[1]):t.push(a)}return t}const $d={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},_0=new RegExp("["+Object.keys($d).join("")+"]","g"),wn=typeof String.prototype.normalize=="function"?e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(_0,t=>$d[t]):e=>e;var Po=class{constructor(e,{location:t=Y.location,threshold:s=Y.threshold,distance:r=Y.distance,includeMatches:o=Y.includeMatches,findAllMatches:a=Y.findAllMatches,minMatchCharLength:i=Y.minMatchCharLength,isCaseSensitive:c=Y.isCaseSensitive,ignoreDiacritics:d=Y.ignoreDiacritics,ignoreLocation:m=Y.ignoreLocation}={}){if(this.options={location:t,threshold:s,distance:r,includeMatches:o,findAllMatches:a,minMatchCharLength:i,isCaseSensitive:c,ignoreDiacritics:d,ignoreLocation:m},e=c?e:e.toLowerCase(),e=d?wn(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const u=(p,f)=>{this.chunks.push({pattern:p,alphabet:M0(p),startIndex:f})},h=this.pattern.length;if(h>32){let p=0;const f=h%32,g=h-f;for(;p<g;)u(this.pattern.substr(p,32),p),p+=32;if(f){const x=h-32;u(this.pattern.substr(x),x)}}else u(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:s,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=s?wn(e):e,this.pattern===e){if(e.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const g={isMatch:!0,score:0};return r&&(g.indices=[[0,e.length-1]]),g}const{location:o,distance:a,threshold:i,findAllMatches:c,minMatchCharLength:d,ignoreLocation:m}=this.options,u=[];let h=0,p=!1;this.chunks.forEach(({pattern:g,alphabet:x,startIndex:b})=>{const{isMatch:y,score:k,indices:j}=O0(e,g,x,{location:o+b,distance:a,threshold:i,findAllMatches:c,minMatchCharLength:d,includeMatches:r,ignoreLocation:m});y&&(p=!0),h+=k,y&&j&&u.push(...j)});const f={isMatch:p,score:p?h/this.chunks.length:1};return p&&r&&(f.indices=_o(u)),f}};const P0=new Set(["fuzzy","include"]);function L0(e){return e.startsWith("inverse")}const Mr=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:e=>({type:"exact",search(t){const s=t===e;return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:e=>({type:"include",search(t){let s=0,r;const o=[],a=e.length;for(;(r=t.indexOf(e,s))>-1;)s=r+a,o.push([r,s-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:e=>({type:"prefix-exact",search(t){const s=t.startsWith(e);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:e=>({type:"inverse-prefix-exact",search(t){const s=!t.startsWith(e);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:e=>({type:"inverse-suffix-exact",search(t){const s=!t.endsWith(e);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:e=>({type:"suffix-exact",search(t){const s=t.endsWith(e);return{isMatch:s,score:s?0:1,indices:[t.length-e.length,t.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:e=>({type:"inverse-exact",search(t){const s=t.indexOf(e)===-1;return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(e,t={})=>{const s=new Po(e,{location:t.location??Y.location,threshold:t.threshold??Y.threshold,distance:t.distance??Y.distance,includeMatches:t.includeMatches??Y.includeMatches,findAllMatches:t.findAllMatches??Y.findAllMatches,minMatchCharLength:t.minMatchCharLength??Y.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??Y.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??Y.ignoreDiacritics,ignoreLocation:t.ignoreLocation??Y.ignoreLocation});return{type:"fuzzy",search(r){return s.searchIn(r)}}}}],Wa=Mr.length,F0="\0",$0="|";function B0(e){const t=[],s=e.length;let r=0;for(;r<s;){for(;r<s&&e[r]===" ";)r++;if(r>=s)break;let o=r;for(;o<s&&e[o]!==" "&&e[o]!=='"';)o++;if(o<s&&e[o]==='"'){for(o++;o<s;){if(e[o]==='"'){const a=o+1;if(a>=s||e[a]===" "){o++;break}if(e[a]==="$"&&(a+1>=s||e[a+1]===" ")){o+=2;break}}o++}t.push(e.substring(r,o)),r=o}else{for(;o<s&&e[o]!==" ";)o++;t.push(e.substring(r,o)),r=o}}return t}function Ga(e,t){const s=e.match(t);return s?s[1]:null}function z0(e,t={}){return e.replace(/\\\|/g,F0).split($0).map(s=>{const r=B0(s.replace(/\u0000/g,"|").trim()).filter(a=>a&&!!a.trim()),o=[];for(let a=0,i=r.length;a<i;a+=1){const c=r[a];let d=!1,m=-1;for(;!d&&++m<Wa;){const u=Mr[m],h=Ga(c,u.multiRegex);h&&(o.push(u.create(h,t)),d=!0)}if(!d)for(m=-1;++m<Wa;){const u=Mr[m],h=Ga(c,u.singleRegex);if(h){o.push(u.create(h,t));break}}}return o})}var U0=class{constructor(e,{isCaseSensitive:t=Y.isCaseSensitive,ignoreDiacritics:s=Y.ignoreDiacritics,includeMatches:r=Y.includeMatches,minMatchCharLength:o=Y.minMatchCharLength,ignoreLocation:a=Y.ignoreLocation,findAllMatches:i=Y.findAllMatches,location:c=Y.location,threshold:d=Y.threshold,distance:m=Y.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:s,includeMatches:r,minMatchCharLength:o,findAllMatches:i,ignoreLocation:a,location:c,threshold:d,distance:m},e=t?e:e.toLowerCase(),e=s?wn(e):e,this.pattern=e,this.query=z0(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:s,isCaseSensitive:r,ignoreDiacritics:o}=this.options;e=r?e:e.toLowerCase(),e=o?wn(e):e;let a=0;const i=[];let c=0,d=!1;for(let m=0,u=t.length;m<u;m+=1){const h=t[m];i.length=0,a=0,d=!1;for(let p=0,f=h.length;p<f;p+=1){const g=h[p],{isMatch:x,indices:b,score:y}=g.search(e);if(x)a+=1,c+=y,L0(g.type)&&(d=!0),s&&(P0.has(g.type)?i.push(...b):i.push(b));else{c=0,a=0,i.length=0,d=!1;break}}if(a){const p={isMatch:!0,score:c/a};return d&&(p.hasInverse=!0),s&&(p.indices=_o(i)),p}}return{isMatch:!1,score:1}}};const _r=[];function Lo(...e){_r.push(...e)}function ds(e,t){for(let s=0,r=_r.length;s<r;s+=1){const o=_r[s];if(o.condition(e,t))return new o(e,t)}return new Po(e,t)}const us={AND:"$and",OR:"$or"},Pr={PATH:"$path",PATTERN:"$val"},Lr=e=>!!(e[us.AND]||e[us.OR]),K0=e=>!!e[Pr.PATH],H0=e=>!ht(e)&&_d(e)&&!Lr(e),Ya=e=>({[us.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Bd(e,t,{auto:s=!0}={}){const r=o=>{if(je(o)){const d={keyId:null,pattern:o};return s&&(d.searcher=ds(o,t)),d}const a=Object.keys(o),i=K0(o);if(!i&&a.length>1&&!Lr(o))return r(Ya(o));if(H0(o)){const d=i?o[Pr.PATH]:a[0],m=i?o[Pr.PATTERN]:o[d];if(!je(m))throw new Error(y0(d));const u={keyId:ts(d),pattern:m};return s&&(u.searcher=ds(m,t)),u}const c={children:[],operator:a[0]};return a.forEach(d=>{const m=o[d];ht(m)&&m.forEach(u=>{c.children.push(r(u))})}),c};return Lr(e)||(e=Ya(e)),r(e)}function Fr(e,{ignoreFieldNorm:t=Y.ignoreFieldNorm}){let s=1;return e.forEach(({key:r,norm:o,score:a})=>{const i=r?r.weight:null;s*=Math.pow(a===0&&i?Number.EPSILON:a,(i||1)*(t?1:o))}),s}function q0(e,{ignoreFieldNorm:t=Y.ignoreFieldNorm}){e.forEach(s=>{s.score=Fr(s.matches,{ignoreFieldNorm:t})})}var W0=class{constructor(e,t){this.limit=e,this.heap=[],this.comparator=t}get size(){return this.heap.length}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):this.comparator(e,this.heap[0])<0&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(e){const t=this.heap;for(;e>0;){const s=e-1>>1;if(this.comparator(t[e],t[s])<=0)break;const r=t[e];t[e]=t[s],t[s]=r,e=s}}_sinkDown(e){const t=this.heap,s=t.length;let r=e;do{e=r;const o=2*e+1,a=2*e+2;if(o<s&&this.comparator(t[o],t[r])>0&&(r=o),a<s&&this.comparator(t[a],t[r])>0&&(r=a),r!==e){const i=t[e];t[e]=t[r],t[r]=i}}while(r!==e)}};function G0(e){const t=[];return e.matches.forEach(s=>{if(!Re(s.indices)||!s.indices.length)return;const r={indices:s.indices,value:s.value};s.key&&(r.key=s.key.id),s.idx>-1&&(r.refIndex=s.idx),t.push(r)}),t}function Y0(e,t,{includeMatches:s=Y.includeMatches,includeScore:r=Y.includeScore}={}){return e.map(o=>{const{idx:a}=o,i={item:t[a],refIndex:a};return s&&(i.matches=G0(o)),r&&(i.score=o.score),i})}const V0=/[\p{L}\p{M}\p{N}_]+/gu,Va=new WeakSet;function Q0(e){Va.has(e)||(Va.add(e),console.warn(`[Fuse] tokenize regex ${e} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function X0(e){if(typeof e=="function"){let t=!1;return s=>{const r=e(s);if(!t&&(t=!0,!Array.isArray(r)||r.some(o=>typeof o!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(r)?"array containing non-strings":typeof r}.`);return r}}return e instanceof RegExp?(e.global||Q0(e),t=>t.match(e)||[]):t=>t.match(V0)||[]}function $r({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:s}={}){const r=X0(s);return{tokenize(o){return e||(o=o.toLowerCase()),t&&(o=wn(o)),r(o)}}}var J0=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=$r({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,tokenize:t.tokenize});const s=this.analyzer.tokenize(e),{df:r,fieldCount:o}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const a of s){this.termSearchers.push(new Po(a,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));const i=r.get(a)||0,c=Math.log(1+(o-i+.5)/(i+.5));this.idfWeights.push(c)}this.combineAll=t.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};const t=[];let s=0,r=0,o=0,a=0;const i=this.combineAll&&!this.useMask?new Set:null;for(let m=0;m<this.termSearchers.length;m++){const u=this.termSearchers[m].searchIn(e),h=this.idfWeights[m];r+=h,u.isMatch&&(o++,s+=h*(1-u.score),u.indices&&t.push(...u.indices),this.combineAll&&(this.useMask?a|=1<<m:i.add(m)))}if(o===0)return{isMatch:!1,score:1};const c=r>0?1-s/r:0,d={isMatch:!0,score:Math.max(.001,c)};return this.options.includeMatches&&t.length&&(d.indices=_o(t)),this.combineAll&&(this.useMask?d.matchedMask=a:d.matchedTerms=i,d.termCount=this.numTerms),d}};function tr(e,t,s,r){const o=r.tokenize(t);if(!o.length)return;e.fieldCount++,e.docFieldCount.set(s,(e.docFieldCount.get(s)||0)+1);const a=new Set(o);let i=e.docTermFieldHits.get(s);i||(i=new Map,e.docTermFieldHits.set(s,i));for(const c of a)i.set(c,(i.get(c)||0)+1),e.df.set(c,(e.df.get(c)||0)+1)}function zd(e,t,s,r){const{i:o,v:a,$:i}=t;if(a!==void 0){tr(e,a,o,r);return}if(i)for(let c=0;c<s;c++){const d=i[c];if(d)if(Array.isArray(d))for(const m of d)tr(e,m.v,o,r);else tr(e,d.v,o,r)}}function Z0(e,t,s){const r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const o of e)zd(r,o,t,s);return r}function ek(e,t,s,r){zd(e,t,s,r)}function tk(e,t){const s=e.docFieldCount.get(t);if(s===void 0)return;e.fieldCount-=s,e.docFieldCount.delete(t);const r=e.docTermFieldHits.get(t);if(r){for(const[o,a]of r){const i=(e.df.get(o)||0)-a;i<=0?e.df.delete(o):e.df.set(o,i)}e.docTermFieldHits.delete(t)}}function Qa(e,t){if(t.length===0)return;const s=Array.from(new Set(t)).sort((c,d)=>c-d);for(const c of s)tk(e,c);const r=c=>{let d=0,m=s.length;for(;d<m;){const u=d+m>>>1;s[u]<c?d=u+1:m=u}return c-d},o=s[0],a=new Map;for(const[c,d]of e.docFieldCount)a.set(c>o?r(c):c,d);e.docFieldCount=a;const i=new Map;for(const[c,d]of e.docTermFieldHits)i.set(c>o?r(c):c,d);e.docTermFieldHits=i}var ft=class{constructor(e,t,s){this.options={...Y,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new k0(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,s),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;const t=ds(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Mo))throw new Error(x0);if(this._myIndex=t||Fd(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const s=$r({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=Z0(this._myIndex.records,this._myIndex.keys.length,s)}this._invalidateSearcherCache()}add(e){if(!Re(e))return;this._docs.push(e);const t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){const s=$r({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});ek(this._invertedIndex,t,this._myIndex.keys.length,s)}this._invalidateSearcherCache()}remove(e=()=>!1){const t=[],s=[];for(let r=0,o=this._docs.length;r<o;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),s.push(r));if(s.length){this._invertedIndex&&Qa(this._invertedIndex,s);const r=new Set(s);this._docs=this._docs.filter((o,a)=>!r.has(a)),this._myIndex.removeAll(s),this._invalidateSearcherCache()}return t}removeAt(e){if(!Number.isInteger(e)||e<0||e>=this._docs.length)throw new Error(Or);this._invertedIndex&&Qa(this._invertedIndex,[e]);const t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),this._invalidateSearcherCache(),t}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(e=>this._keyStore.get(e.id)||e)}search(e,t){const{limit:s=-1}=t||{},{includeMatches:r,includeScore:o,shouldSort:a,sortFn:i,ignoreFieldNorm:c}=this.options;if(je(e)&&!e.trim()){let p=this._docs.map((f,g)=>({item:f,refIndex:g}));return es(s)&&s>-1&&(p=p.slice(0,s)),p}const d=a&&es(s)&&s>0&&je(e),m=i,u=(p,f)=>m(p,f)||p.idx-f.idx;let h;if(d){const p=new W0(s,u);je(this._docs[0])?this._searchStringList(e,{heap:p,ignoreFieldNorm:c}):this._searchObjectList(e,{heap:p,ignoreFieldNorm:c}),h=p.extractSorted()}else h=je(e)?je(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),q0(h,{ignoreFieldNorm:c}),a&&h.sort(je(e)?u:m),es(s)&&s>-1&&(h=h.slice(0,s));return Y0(h,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(e,{heap:t,ignoreFieldNorm:s}={}){const r=this._getSearcher(e),o=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:a}=this._myIndex,i=t?null:[];return a.forEach(({v:c,i:d,n:m})=>{if(!Re(c))return;const u=r.searchIn(c);if(u.isMatch){const h={score:u.score,value:c,norm:m,indices:u.indices};o&&(h.matchedMask=u.matchedMask,h.matchedTerms=u.matchedTerms,h.termCount=u.termCount);const p=[h];if(!o||this._coversAllTokens(p)){const f={item:c,idx:d,matches:p};t?(f.score=Fr(f.matches,{ignoreFieldNorm:s}),t.insert(f)):i.push(f)}}}),i}_searchLogical(e){const t=Bd(e,this.options),s=this._normalizedKeys(),r=(c,d,m)=>{if(!("children"in c)){const{keyId:f,searcher:g}=c;let x;return f===null?(x=[],s.forEach((b,y)=>{x.push(...this._findMatches({key:b,value:d[y],searcher:g}))})):x=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(d,f),searcher:g}),x&&x.length?[{idx:m,item:d,matches:x}]:[]}const{children:u,operator:h}=c,p=[];for(let f=0,g=u.length;f<g;f+=1){const x=u[f],b=r(x,d,m);if(b.length)p.push(...b);else if(h===us.AND)return[]}return p},o=this._myIndex.records,a=new Map,i=[];return o.forEach(({$:c,i:d})=>{if(Re(c)){const m=r(t,c,d);m.length&&(a.has(d)||(a.set(d,{idx:d,item:c,matches:[]}),i.push(a.get(d))),m.forEach(({matches:u})=>{a.get(d).matches.push(...u)}))}}),i}_searchObjectList(e,{heap:t,ignoreFieldNorm:s}={}){const r=this._getSearcher(e),o=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:a}=this._myIndex,i=this._normalizedKeys(),c=t?null:[];return a.forEach(({$:d,i:m})=>{if(!Re(d))return;const u=[];let h=!1,p=!1;if(i.forEach((f,g)=>{const x=this._findMatches({key:f,value:d[g],searcher:r});x.length?(u.push(...x),x[0].hasInverse&&(p=!0)):h=!0}),!(p&&h)&&u.length&&(!o||this._coversAllTokens(u))){const f={idx:m,item:d,matches:u};t?(f.score=Fr(f.matches,{ignoreFieldNorm:s}),t.insert(f)):c.push(f)}}),c}_findMatches({key:e,value:t,searcher:s}){if(!Re(t))return[];const r=[];if(ht(t))t.forEach(({v:o,i:a,n:i})=>{if(!Re(o))return;const c=s.searchIn(o);if(c.isMatch){const d={score:c.score,key:e,value:o,idx:a,norm:i,indices:c.indices,hasInverse:c.hasInverse};c.termCount!==void 0&&(d.matchedMask=c.matchedMask,d.matchedTerms=c.matchedTerms,d.termCount=c.termCount),r.push(d)}});else{const{v:o,n:a}=t,i=s.searchIn(o);if(i.isMatch){const c={score:i.score,key:e,value:o,norm:a,indices:i.indices,hasInverse:i.hasInverse};i.termCount!==void 0&&(c.matchedMask=i.matchedMask,c.matchedTerms=i.matchedTerms,c.termCount=i.termCount),r.push(c)}}return r}_coversAllTokens(e){const t=e.length?e[0].termCount:void 0;if(t===void 0)return!0;if(t<=31){let r=0;for(let o=0;o<e.length;o++)r|=e[o].matchedMask||0;return r===2**t-1}const s=new Set;for(let r=0;r<e.length;r++){const o=e[r].matchedTerms;if(o)for(const a of o)s.add(a)}return s.size===t}};ft.version="7.5.0";ft.createIndex=Fd;ft.parseIndex=R0;ft.config=Y;ft.match=function(e,t,s){if(s&&s.useTokenSearch)throw new Error(j0);return ds(e,{...Y,...s}).searchIn(t)};ft.parseQuery=Bd;Lo(U0);Lo(J0);ft.use=function(...e){e.forEach(t=>Lo(t))};var nk=ft;const sk=.02,Ud=.5,Kd=.35,Hd=.15,rk=1+Ud+Kd+Hd,ok=4320*60*1e3,ak=3,ik=1440*60*1e3,ck=.15,lk={lastUsedAt:null,useCount:0};function Fo(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function qd(e,t){return!Number.isFinite(e)||e<=0?1:Fo(Math.pow(2,-e/t))}function dk(e,t){const s=e.lastUsedAt===null?0:qd(t-e.lastUsedAt,ok),r=Math.max(0,e.useCount),o=r===0?0:r/(r+ak);return Fo((s+o)/2)}function uk(e,t){const s=e.distance===null?1:Fo(Math.pow(2,-Math.max(0,e.distance)/sk)),r=dk(e.usage,t),o=e.lastActivityAt===null?0:qd(t-e.lastActivityAt,ik),a=1+(e.waiting?Ud:0)+Kd*r+Hd*o;return{score:s*a/rk,signals:{relevance:s,frecency:r,recency:o}}}function mk(e,t){return e.map(s=>{const{score:r,signals:o}=uk(s,t);return{key:s.key,item:s.item,score:r,signals:o,demoted:s.demoted}}).sort((s,r)=>Number(s.demoted)-Number(r.demoted)||r.score-s.score||s.key.localeCompare(r.key))}function hk(e,t){const s=[...e],r=e[0],o=e[1];return t.queried?!r||!o?{best:null,rest:s}:r.demoted||r.score<=0?{best:null,rest:s}:(r.score-o.score)/r.score<ck?{best:null,rest:s}:{best:r,rest:s.slice(1)}:{best:null,rest:s}}function fk(e,t){const s=[];for(const r of e){const o=t(r),a=s[s.length-1];a&&a.label===o?a.rows.push(r):s.push({label:o,rows:[r]})}return s}const pk={keys:["name","keywords"],includeMatches:!0,includeScore:!0,threshold:.3,distance:100,minMatchCharLength:1};function gk(e,t,s){const{usage:r,now:o,scope:a}=s,{prefix:i,term:c}=l.useMemo(()=>a===null?xk(t):{prefix:null,term:t},[t,a]),d=l.useMemo(()=>{if(a===null)return e;const x=Od(a);return e.filter(b=>b.scopes.includes(x))},[e,a]),m=l.useMemo(()=>i==="#"?d.filter(x=>x.type==="room"):i==="@"?d.filter(x=>x.type==="agent"||x.type==="dm"):i===">"?d.filter(x=>x.type==="command"):d,[d,i]),u=l.useMemo(()=>new nk(m,pk),[m]),h=l.useMemo(()=>{const x=(b,y,k)=>{const j=b.lastActivityAt===null?NaN:Date.parse(b.lastActivityAt);return{key:`${b.type}:${b.id}`,item:{item:b,matches:y},distance:k,usage:(b.usageKey===null?void 0:r[b.usageKey])??lk,lastActivityAt:Number.isNaN(j)?null:j,waiting:b.waiting,demoted:b.demoted}};return c?u.search(c).map(b=>x(b.item,b.matches,b.score??0)):m.map(b=>x(b,void 0,null))},[u,c,m,r]),p=l.useMemo(()=>mk(h,o),[h,o]),{best:f,rest:g}=l.useMemo(()=>hk(p,{queried:c.length>0}),[p,c]);return{bestMatch:f,rows:g,prefix:i,term:c}}function xk(e){return e.startsWith("#")?{prefix:"#",term:e.slice(1)}:e.startsWith("@")?{prefix:"@",term:e.slice(1)}:e.startsWith(">")?{prefix:">",term:e.slice(1)}:{prefix:null,term:e}}function yk(){const e=ro(),t=Zm();return l.useMemo(()=>{const s={};for(const[r,o]of Object.entries(e)){const a=Date.parse(o);s[r]={lastUsedAt:Number.isNaN(a)?null:a,useCount:t[r]??0}}return s},[e,t])}const bk=/^\/([A-Za-z0-9][\w.-]*(?::[\w.-]+)*)(?=\s|$)\s*/;function vk(e,t){const s=t.trim().replace(bk,"").trim();return s?`${e} ${s}`:`${e} `}function wk(e){const[t,s]=On(),{setTheme:r,theme:o}=Ui(),a=Ie(),i=ce(),c=ie(),d=an(S=>S.openFeedback),m=oo(),{url:u}=Dc(),{copy:h}=ao({toastOnSettle:!0}),{open:p}=qe(),{open:f}=so(),g=ks(),x=B(S=>S.setPickerOpen),b=B(S=>S.setCanvasOpen),y=B(S=>S.setRightPanelOpen),k=B(S=>S.setActiveRightPanelTab),j=l.useCallback(S=>{Tt.getState().recordOpened("agent",S)},[]),C=l.useCallback(S=>{s(S.projectPath,{onOpened:()=>{j(S.projectPath)}}),e()},[j,s,e]),v=Pc(),N=l.useCallback(S=>{Tt.getState().recordOpened("room",S.id),e(),a({...pe.channels(),search:{id:S.id}})},[e,a]),I=l.useCallback((S,M)=>{Tt.getState().recordOpened("session",S),M&&j(M),e(),a(ut({session:S,dir:M??void 0}))},[e,a,j]),D=l.useCallback(S=>{e(),eh({queryClient:i,transport:c},t).then(async M=>{if(M===null){Vo(t);return}Tt.getState().recordOpened("session",M.sessionId),t&&j(t);const R=th.getState(),O=R.getSession(M.sessionId).input;R.updateSession(M.sessionId,{input:vk(S,O)}),a(M.isNew?await nh(c,{session:M.sessionId,dir:t??void 0}):ut({session:M.sessionId}))}).catch(M=>{Gi(c,M),Vo(t)})},[e,a,i,c,t,j]),T=l.useCallback(S=>{e(),a({href:S})},[e,a]),E=l.useCallback(S=>{sh(S)||console.warn(`[command-palette] no handler registered for action "${S}"`)},[]),w=l.useCallback(S=>{switch(e(),S){case"openTasks":f();return;case"openRelay":g();return;case"openMesh":a({...pe.team()});return;case"openSettings":p();return;case"discoverAgents":gn.getState().open();return;case"browseFilesystem":x(!0);return;case"openAgentProfile":k(oh),y(!0);return;default:{const M=rh(S);if(M){p(M);return}E(S);return}}},[e,a,f,g,p,x,k,y,E]),A=l.useCallback(S=>{switch(e(),S){case"navigateDashboard":a({...pe.home()});return;case"newSession":v();return;case"openDevPlayground":ss("/dev");return;case"toggleDevtools":B.getState().toggleDevtools();return;case"toggleRouterDevtools":B.getState().toggleRouterDevtools();return;case"createAgent":Ss.getState().open();return;case"switchShape":B.getState().setShapeSwitcherOpen(!0);return;case"openControlCenter":B.getState().setControlCenterOpen(!0);return;case"toggleCanvas":b(!B.getState().canvasOpen);return;case"toggleTheme":r(o==="dark"?"light":"dark");return;case"openFeedback":d();return;case"openYourReports":a({...pe.feedbackRequests()});return;case"openTasks":f();return;case"openRelay":g();return;case"openMesh":a({...pe.team()});return;case"discoverAgents":gn.getState().open();return;case"openSettings":p();return;case"browseFilesystem":x(!0);return;case at.copyLink:u&&h(u);return;case at.showQr:B.getState().setRemoteAccessBeaconOpen(!0);return;case at.turnOn:m.start();return;case at.turnOff:m.stop();return;default:E(S);return}},[e,a,E,r,o,b,x,f,g,p,d,h,m,u,v]);return{handleAgentSelect:C,startNewSession:v,handleFeatureAction:w,handleQuickAction:A,handleRoomSelect:N,handleSessionSelect:I,handleCommandSelect:D,handlePageSelect:T,recordAgentOpened:j,setDir:s,selectedCwd:t}}const Xa='[cmdk-item=""]:not([aria-disabled="true"])',jk=new Set(["ArrowUp","ArrowDown","Home","End"]),kk=new Set(["n","p","j","k"]);function Sk({rootRef:e,activePage:t,onPin:s,resetKey:r}){const o=l.useRef(!1);l.useLayoutEffect(()=>{o.current=!1},[r]),l.useLayoutEffect(()=>{var m;if(o.current)return;const c=(m=e.current)==null?void 0:m.querySelector(`[data-palette-page="${CSS.escape(t)}"] ${Xa}`);if(!c||c.getAttribute("aria-selected")==="true")return;const d=c.getAttribute("data-value");d&&s(d)});const a=l.useCallback(c=>{c.nativeEvent.isComposing||c.keyCode===229||(jk.has(c.key)||c.ctrlKey&&kk.has(c.key))&&(o.current=!0)},[]),i=l.useCallback(c=>{c.target instanceof Element&&c.target.closest(Xa)&&(o.current=!0)},[]);return{onKeyDown:a,onPointerMove:i}}function Ck({scope:e,className:t}){return n.jsx("span",{"data-testid":"palette-scope-chip",className:z("bg-accent text-accent-foreground inline-flex shrink-0 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-xs font-medium",t),children:e.kind==="agent"?n.jsxs(n.Fragment,{children:[n.jsx(io,{...js(e.agent),size:"xs",badge:null}),ke(e.agent)]}):n.jsxs(n.Fragment,{children:[n.jsx(Lc,{room:e.room,participants:e.room.participants,size:"xs"}),n.jsx(Fc,{room:e.room})]})})}function Nk(e){const t=e.trim();return t.length===0?null:t}function Wd(e,t){const s=l.useDeferredValue(e),{sessions:r}=ah(t),{data:o}=fx(s||null),a=l.useMemo(()=>r.slice(0,3).map(i=>({id:i.id,title:Ic(i.title),lastActive:i.updatedAt})),[r]);return{sessionCount:r.length,recentSessions:a,health:o??null}}function Ak({agent:e}){const{sessionCount:t,recentSessions:s,health:r}=Wd(e.id,e.projectPath),{color:o,emoji:a}=js(e);return n.jsx(G.div,{initial:{opacity:0,width:0},animate:{opacity:1,width:240},exit:{opacity:0,width:0},transition:{duration:.2,ease:[0,0,.2,1]},className:"flex-shrink-0 overflow-hidden border-l will-change-[width]",children:n.jsxs("div",{className:"w-[240px] space-y-3 p-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(io,{color:o,emoji:a,size:"sm",className:"shrink-0"}),n.jsx("span",{className:"truncate text-sm font-semibold",children:ke(e)})]}),n.jsx("p",{className:"text-muted-foreground truncate text-xs",children:$c(e.projectPath)}),n.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[r&&n.jsx(fn,{size:"xs",variant:r.status==="active"?"default":"secondary",children:r.status}),n.jsxs("span",{className:"text-muted-foreground",children:[t," ",t===1?"session":"sessions"]})]}),s.length>0&&n.jsxs("div",{className:"space-y-1 pt-1",children:[n.jsx("p",{className:"text-muted-foreground text-3xs font-medium tracking-wider uppercase",children:"Recent"}),n.jsx("ul",{className:"space-y-0.5",children:s.map(i=>n.jsx("li",{className:"text-muted-foreground truncate text-xs",children:i.title},i.id))})]})]})})}function Ek({agent:e,onOpenHere:t,onOpenNewTab:s,onOpenNewWindow:r,onNewSession:o,onBrowseSessions:a,onEditSettings:i,recentSessions:c,onSelectSession:d}){const m=jt?"⌘":"Ctrl+";return n.jsxs(n.Fragment,{children:[n.jsxs(Be,{heading:`${ke(e)} actions`,children:[n.jsxs(fe,{value:"open-here",onSelect:t,children:[n.jsx(vs,{className:"size-4"}),n.jsx("span",{children:"Open here"}),n.jsx(Qo,{children:"Enter"})]}),n.jsxs(fe,{value:"open-new-tab",onSelect:s,children:[n.jsx(Sl,{className:"size-4"}),n.jsx("span",{children:"Open in a new tab"}),n.jsxs(Qo,{children:[m,"Enter"]})]}),r&&n.jsxs(fe,{value:"open-new-window",onSelect:r,children:[n.jsx(Hy,{className:"size-4"}),n.jsx("span",{children:"Open in a new window"})]}),n.jsxs(fe,{value:"new-session",onSelect:o,children:[n.jsx(Ht,{className:"size-4"}),n.jsx("span",{children:"New session"})]}),a&&n.jsxs(fe,{value:"browse-sessions",onSelect:a,children:[n.jsx(Zx,{className:"size-4"}),n.jsx("span",{children:"Browse sessions…"})]}),n.jsxs(fe,{value:"edit-settings",onSelect:i,children:[n.jsx(As,{className:"size-4"}),n.jsxs("span",{children:["Edit ",ke(e)," settings"]})]})]}),c.length>0&&n.jsx(Be,{heading:"Recent sessions",children:c.map(u=>n.jsxs(fe,{value:u.id,onSelect:()=>d(u.id),children:[n.jsx(Kt,{className:"size-4"}),n.jsx("span",{className:"truncate",children:u.title}),n.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:Ik(u.lastActive)})]},u.id))})]})}function Ik(e){const t=Date.now(),s=new Date(e).getTime(),r=t-s,o=Math.floor(r/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const a=Math.floor(o/60);if(a<24)return`${a}h ago`;const i=Math.floor(a/24);return i<7?`${i}d ago`:`${Math.floor(i/7)}w ago`}const st="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function Tk({page:e,hasAgentSelected:t,canScope:s,isScoped:r}){const o=jt?"⌘":"Ctrl";return n.jsxs("div",{className:"text-muted-foreground flex flex-shrink-0 items-center gap-3 border-t px-3 py-1.5 text-xs",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"↑↓"}),"Navigate"]}),!e&&t&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"Enter"}),"Open"]}),(!e&&t||e==="agent-actions")&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsxs("kbd",{className:st,children:[o,"Enter"]}),"New tab"]}),e==="agent-actions"&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"Enter"}),"Select"]}),e&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"Backspace"}),"Back"]}),s&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"Tab"}),"Search inside"]}),r&&n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"Backspace"}),"Clear scope, at the start"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:st,children:"esc"}),"Close"]})]})}const Rk=[{key:"#",means:"channels"},{key:"@",means:"agents and DMs"},{key:">",means:"commands"}];function Gd({className:e}){return n.jsx("div",{className:z("text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2 text-xs",e),children:Rk.map(({key:t,means:s})=>n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:"bg-muted text-3xs rounded px-1 py-0.5 font-mono",children:t}),s]},t))})}function Dk({text:e,indices:t,className:s}){if(!t||t.length===0)return n.jsx("span",{className:s,children:e});const r=[];let o=0;for(let a=0;a<t.length;a++){const[i,c]=t[a],d=c+1;o<i&&r.push(n.jsx("span",{children:e.slice(o,i)},`p-${a}`)),r.push(n.jsx("mark",{className:"text-foreground bg-transparent font-semibold",children:e.slice(i,d)},`m-${a}`)),o=d}return o<e.length&&r.push(n.jsx("span",{children:e.slice(o)},"tail")),n.jsx("span",{className:s,children:r})}function Yd({agent:e,isActive:t,onSelect:s,nameIndices:r,isSelected:o}){return n.jsxs(fe,{value:ke(e),keywords:[e.name,e.projectPath,e.id],onSelect:()=>s(),className:"relative py-2",forceMount:t?!0:void 0,children:[o&&n.jsx(G.div,{layoutId:"cmd-palette-selection",className:"bg-accent absolute inset-0 rounded-sm",transition:{duration:.15,ease:[0,0,.2,1]}}),n.jsx("div",{className:"relative z-10 w-full",children:n.jsx(ih,{agent:e,name:r?n.jsx(Dk,{text:ke(e),indices:r,className:"truncate text-sm font-semibold"}):n.jsx("span",{className:"truncate text-sm font-semibold",children:ke(e)}),secondary:$c(e.projectPath),selected:t})})]})}function Vd(){return n.jsx("span",{"data-testid":"palette-archived-mark",className:"text-muted-foreground border-border text-3xs shrink-0 rounded-full border px-1.5 py-0.5 font-medium",children:"Archived"})}function Qd({room:e,onSelect:t}){const s=_t(e);return n.jsxs(fe,{value:e.id,keywords:Rr(e),onSelect:t,className:"flex items-center gap-2 py-2",children:[n.jsx(Lc,{room:e,participants:e.participants,className:"shrink-0"}),e.kind==="dm"?n.jsxs("span",{className:"min-w-0 flex-1 truncate text-sm",children:["Open conversation with ",e.title]}):n.jsx(Fc,{room:e,className:"min-w-0 flex-1 text-sm"}),e.archived&&n.jsx(Vd,{}),s&&n.jsx("span",{className:"bg-brand/15 text-brand text-3xs shrink-0 rounded-full px-1.5 py-0.5 font-medium tabular-nums","aria-label":`${e.unreadCount} unread`,children:e.unreadCount})]})}const Ok=6e4;function Mk({lastActivityAt:e}){const t=co(Ok),s=l.useMemo(()=>Number.isNaN(Date.parse(e))?null:lo(e),[e,t]);return s===null?null:n.jsx("span",{className:"text-muted-foreground text-2xs font-normal",children:s})}function Br({item:e,live:t,isSelected:s=!1,onSelect:r}){const o=Zr(e.agent,e.cwd??e.id),a=ch(e.who,e.title),i=(t==null?void 0:t.verb)??null;return n.jsxs(fe,{value:e.id,keywords:Md(e),onSelect:r,title:a,className:z("flex gap-2 py-1.5",i!==null?"items-start":"items-center"),children:[n.jsx(io,{color:o.color,emoji:o.emoji,size:"xs",className:z("shrink-0",i!==null&&"mt-px")}),n.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[n.jsxs("span",{"data-slot":"palette-session-line",className:"flex w-full items-center gap-1.5 text-sm",children:[e.who?n.jsxs(n.Fragment,{children:[n.jsx("span",{"data-slot":"palette-session-who",className:lh,children:e.who}),n.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60 flex-none",children:dh})]}):null,n.jsx("span",{"data-slot":"palette-session-title",className:uh,children:e.title}),n.jsxs("span",{className:z("flex items-center gap-1.5",hh),children:[e.archived&&t===void 0&&n.jsx(Vd,{}),n.jsx(mh,{origin:e.origin,label:e.originLabel,className:"text-muted-foreground"}),n.jsx(Mk,{lastActivityAt:e.lastActivityAt}),s&&n.jsx(_k,{canStartNewSession:e.cwd!==null})]})]}),i!==null&&n.jsxs("span",{className:"text-muted-foreground text-2xs flex items-center gap-1.5 font-normal",children:[t!==void 0&&n.jsx("span",{"aria-hidden":!0,className:z("size-1.5 shrink-0 rounded-full",xc(t.signal))}),i]})]})]})}function _k({canStartNewSession:e}){return n.jsxs("span",{"aria-hidden":!0,className:"text-muted-foreground flex items-center gap-1",children:[n.jsx("kbd",{className:"bg-accent text-3xs rounded px-1 py-0.5 font-mono",children:"↵"}),e&&n.jsx("kbd",{className:"bg-accent text-3xs rounded px-1 py-0.5 font-mono",children:"⌘↵"})]})}const Pk={session:"Conversations",agent:"Agents",room:"Channels",dm:"Direct messages",command:"Commands",feature:"Actions","quick-action":"Actions",page:"Add-ons"},Lk="Best match",zr={Clock:ac,Radio:Cl,Globe:zc,Settings:As,Plus:Ht,Search:pn,FolderOpen:vs,Moon:Ax,Shapes:fh,MessageSquarePlus:Bc,Inbox:dc},gt=[0,0,.2,1],Fk=[.4,0,1,1],Xd={hidden:{opacity:0,scale:.96,y:-8},visible:{opacity:1,scale:1,y:0,transition:{duration:.2,ease:gt}},exit:{opacity:0,scale:.96,y:-8,transition:{duration:.12,ease:Fk}}},$k={hidden:{},visible:{transition:{staggerChildren:.035,delayChildren:.04}}},un={hidden:{opacity:0,y:-4},visible:{opacity:1,y:0,transition:{duration:.15,ease:gt}}},nr=8;function Bk({continueRows:e,recent:t,newActions:s,selectedCwd:r,selectedValue:o,onSessionSelect:a,onRoomSelect:i,onGoToAgentActions:c,onQuickAction:d}){return n.jsxs(n.Fragment,{children:[e.length>0&&n.jsx(Be,{heading:"Continue",children:e.map((m,u)=>n.jsx(G.div,{variants:u<nr?un:void 0,children:n.jsx(Br,{item:m.session,live:{verb:m.verb,signal:m.signal},isSelected:o===m.session.id,onSelect:()=>a(m.session)})},m.session.id))}),t.length>0&&n.jsx(Be,{heading:"Recent",children:t.map((m,u)=>n.jsxs(G.div,{variants:u<nr?un:void 0,children:[m.kind==="session"&&n.jsx(Br,{item:m.session,isSelected:o===m.session.id,onSelect:()=>a(m.session)}),m.kind==="room"&&n.jsx(Qd,{room:m.room,onSelect:()=>i(m.room)}),m.kind==="agent"&&n.jsx(Yd,{agent:m.agent,isActive:m.agent.projectPath===r,isSelected:o===ke(m.agent),onSelect:()=>c(m.agent)})]},m.key))}),s.length>0&&n.jsxs(n.Fragment,{children:[(e.length>0||t.length>0)&&n.jsx(Uc,{}),n.jsx(Be,{heading:"New",children:s.map((m,u)=>{const h=zr[m.icon];return n.jsx(G.div,{variants:u<nr?un:void 0,children:n.jsx(fe,{value:m.label,onSelect:()=>d(m.action),children:n.jsxs(G.div,{whileHover:{x:2},transition:{duration:.1,ease:gt},className:"flex w-full items-center gap-2",children:[h&&n.jsx(h,{className:"size-4"}),n.jsx("span",{children:m.label})]})})},m.id)})})]})]})}function Ja({row:e,selectedCwd:t,selectedValue:s,onFeatureAction:r,onQuickAction:o,onGoToAgentActions:a,onRoomSelect:i,onSessionSelect:c,onCommandSelect:d,onPageSelect:m}){var p;const{item:u,matches:h}=e.item;switch(u.type){case"session":return n.jsx(Br,{item:u.data,isSelected:s===u.data.id,onSelect:()=>c(u.data)});case"agent":return n.jsx(Yd,{agent:u.data,isActive:u.data.projectPath===t,isSelected:s===ke(u.data),onSelect:()=>a(u.data),nameIndices:(p=h==null?void 0:h.find(f=>f.key==="name"))==null?void 0:p.indices});case"room":case"dm":return n.jsx(Qd,{room:u.data,onSelect:()=>i(u.data)});case"command":return n.jsx(fe,{value:u.data.name,onSelect:()=>d(u.data.name),children:n.jsxs(G.div,{whileHover:{x:2},transition:{duration:.1,ease:gt},className:"flex w-full items-center gap-2",children:[n.jsx("span",{className:"font-mono text-xs",children:u.data.name}),u.data.description&&n.jsx("span",{className:"text-muted-foreground ml-2 text-xs",children:u.data.description})]})});case"feature":{const f=zr[u.data.icon];return n.jsx(fe,{value:u.data.label,onSelect:()=>r(u.data.action),children:n.jsxs(G.div,{whileHover:{x:2},transition:{duration:.1,ease:gt},className:"flex w-full items-center gap-2",children:[f&&n.jsx(f,{className:"size-4"}),n.jsx("span",{children:u.data.label}),u.data.shortcut&&n.jsx("span",{className:"text-muted-foreground ml-auto text-xs",children:u.data.shortcut})]})})}case"page":return n.jsx(fe,{value:u.data.id,onSelect:()=>m(u.data.href),children:n.jsxs(G.div,{whileHover:{x:2},transition:{duration:.1,ease:gt},className:"flex w-full items-center gap-2",children:[n.jsx(Dn,{icon:u.data.icon,className:"size-4"}),n.jsx("span",{children:u.data.label})]})});case"quick-action":{const f=zr[u.data.icon];return n.jsx(fe,{value:u.data.label,onSelect:()=>o(u.data.action),children:n.jsxs(G.div,{whileHover:{x:2},transition:{duration:.1,ease:gt},className:"flex w-full items-center gap-2",children:[f&&n.jsx(f,{className:"size-4"}),n.jsx("span",{children:u.data.label})]})})}}}function zk({term:e,isScoped:t=!1,onSelect:s}){return n.jsxs(fe,{value:"search-messages-handoff",onSelect:s,className:"flex items-center gap-2 py-2",children:[n.jsx(Kt,{className:"text-muted-foreground size-4 shrink-0"}),n.jsxs("span",{className:"min-w-0 flex-1 truncate text-sm",children:["Search ",t?"all messages":"messages"," for"," ",n.jsxs("mark",{className:"text-foreground bg-transparent font-semibold",children:["“",e,"”"]}),"…"]}),n.jsx("kbd",{className:"bg-muted text-muted-foreground text-3xs shrink-0 rounded px-1 py-0.5 font-mono",children:jt?"⌘⇧F":"Ctrl⇧F"})]})}const Za=8;function Uk({staggerKey:e,isZeroQuery:t,isRoomMode:s,scope:r,hasQuery:o,selectedCwd:a,selectedValue:i,continueRows:c,recent:d,newActions:m,bestMatch:u,rows:h,rooms:p,searchHandoff:f,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:b,onRoomSelect:y,onSessionSelect:k,onCommandSelect:j,onPageSelect:C}){const v=s?p.isError?"Couldn’t load your channels.":p.isLoading?"Loading channels…":p.channels.length===0?"No channels yet.":null:null,N=fk(h,E=>r?Ba(r):Pk[E.item.item.type]),I=r&&!o&&h.length===0&&!u?Yj(r):null,D=new Set(h.slice(0,u?Za-1:Za).map(E=>E.key)),T={selectedCwd:a,selectedValue:i,onFeatureAction:g,onQuickAction:x,onGoToAgentActions:b,onRoomSelect:y,onSessionSelect:k,onCommandSelect:j,onPageSelect:C};return n.jsxs(G.div,{variants:$k,initial:"hidden",animate:"visible",children:[t&&n.jsx(Bk,{continueRows:c,recent:d,newActions:m,selectedCwd:a,selectedValue:i,onSessionSelect:k,onRoomSelect:y,onGoToAgentActions:b,onQuickAction:x}),!t&&u&&n.jsx(Be,{heading:Lk,children:n.jsx(G.div,{variants:un,children:n.jsx(Ja,{row:u,...T})})}),!t&&N.map((E,w)=>n.jsx(Be,{heading:E.label,children:E.rows.map(A=>n.jsx(G.div,{variants:D.has(A.key)?un:void 0,children:n.jsx(Ja,{row:A,...T})},A.key))},`${E.label}-${w}`)),I&&n.jsx(Be,{heading:r?Ba(r):void 0,children:n.jsx(fe,{disabled:!0,value:"scope-status",className:"text-muted-foreground text-sm",children:I})}),v&&n.jsx(Be,{heading:"Channels",children:n.jsx(fe,{disabled:!0,value:"rooms-status",className:"text-muted-foreground text-sm",children:v})}),f&&n.jsx(Be,{children:n.jsx(zk,{term:f.term,isScoped:f.isScoped,onSelect:f.onSelect})}),t&&n.jsxs(n.Fragment,{children:[n.jsx(Uc,{}),n.jsx(Gd,{})]})]},e)}function Kk(e,t){const s=Ex(),{dismissedIds:r}=wl(),o=B(a=>a.promoEnabled);return l.useMemo(()=>o?Ix(Tx.filter(a=>a.placements.includes(e)),s,r,t):[],[e,t,s,r,o])}const Hk={initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95,transition:{duration:.15}}};function qk({promo:e}){const{activate:t,dialog:s}=Rx(e),{dismissPromo:r}=wl(),o=Ce(),a=e.content.icon;return n.jsxs(G.div,{variants:o?void 0:Hk,layout:!o,className:"group/promo relative",children:[n.jsxs("button",{"data-slot":"promo-card-compact",onClick:t,className:"bg-sidebar-accent/40 text-sidebar-foreground/70 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring flex w-full items-center gap-2 rounded-md py-1.5 pr-7 pl-2 text-left outline-hidden transition-colors duration-150 focus-visible:ring-2",children:[n.jsx("span",{className:"flex size-[18px] shrink-0 items-center justify-center",children:n.jsx(a,{className:"size-4"})}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"text-sidebar-foreground/90 block truncate text-[13px] font-medium",children:e.content.title}),n.jsx("span",{className:"text-2xs block truncate",children:e.content.shortDescription})]}),n.jsx(bc,{className:"size-3.5 shrink-0 opacity-60"})]}),n.jsx("button",{type:"button",onClick:()=>r(e.id),"aria-label":"Dismiss",className:"text-sidebar-foreground/40 hover:text-sidebar-foreground focus-ring absolute top-1/2 right-1.5 -translate-y-1/2 rounded-md p-0.5 opacity-70 transition-[color,opacity] duration-150 group-hover/promo:opacity-100",children:n.jsx(He,{className:"size-3.5"})}),s]})}const Wk=1;function Gk(e){const[t]=Kk(e,Wk);return l.useMemo(()=>t===void 0?{id:"promo",show:!1,render:()=>null}:{id:`promo:${t.id}`,show:!0,render:()=>n.jsx(qk,{promo:t})},[t])}const Yk=new Set(["downloading","downloaded","install-failed"]);function ei(e,t){return(e==null?void 0:e.state)==="install-failed"?t.state==="downloaded"&&uo(t.version,e.version)?t:e:Yk.has(t.state)||t.state==="error"?t:e&&(e.state==="downloading"||e.state==="downloaded")?e:t}function Vk(){var o;const e=typeof window<"u"&&!!((o=window.electronAPI)!=null&&o.onUpdateStatus),[t,s]=l.useState(null);l.useEffect(()=>{var c;const a=window.electronAPI;if(!(a!=null&&a.onUpdateStatus))return;const i=a.onUpdateStatus(d=>{s(m=>ei(m,d))});return(c=a.getUpdateStatus)==null||c.call(a).then(d=>{d&&s(m=>ei(m,d))}),i},[]);const r=l.useCallback(()=>{var a,i;(i=(a=window.electronAPI)==null?void 0:a.restartToUpdate)==null||i.call(a)},[]);return{isDesktop:e,status:t,restart:r}}const Qk={darwin:"https://dorkos.ai/download/mac",win32:"https://dorkos.ai/download/windows"},Xk="https://dorkos.ai";function Jk(){var t;const e=typeof window>"u"||(t=window.electronAPI)==null?void 0:t.platform;dt((e&&Qk[e])??Xk)}function Zk(){const{data:e}=Oe(),{isDesktop:t,status:s,restart:r}=Vk(),o=Sn(),a=e==null?void 0:e.version,i=(e==null?void 0:e.latestVersion)??null,c=l.useMemo(()=>(e==null?void 0:e.dismissedUpgradeVersions)??[],[e==null?void 0:e.dismissedUpgradeVersions]),d=l.useCallback(m=>{o.mutate({ui:{dismissedUpgradeVersions:[...c,m]}})},[c,o]);return l.useMemo(()=>t?(s==null?void 0:s.state)==="install-failed"?{kind:"desktop-install-failed",downloadFresh:Jk}:(s==null?void 0:s.state)!=="downloaded"?{kind:"none"}:{kind:"desktop-restart",restart:r}:i!==null&&a!==void 0&&uo(i,a)&&!c.includes(i)?{kind:"command",latestVersion:i,dismiss:()=>d(i)}:{kind:"none"},[t,s,r,i,a,c,d])}const eS="npm update -g dorkos",tS="The update couldn’t install itself. Download a fresh copy. Your settings and agents stay put.",sr="focus-ring inline-flex items-center gap-1 rounded-full bg-amber-500/15 px-2 py-0.5 text-2xs font-medium text-amber-700 transition-colors duration-150 hover:bg-amber-500/25 dark:text-amber-300";function nS(e,t,s){return t?"Command copied":s?"Couldn’t copy":`Update ready: v${e}`}function sS({update:e}){const{copied:t,failed:s,copy:r}=ao(),o=l.useCallback(()=>{r(eS)},[r]);return e.kind==="none"?null:e.kind==="desktop-restart"?n.jsx("div",{className:"flex items-center px-0.5",children:n.jsxs("button",{type:"button",onClick:e.restart,"aria-label":"Restart to install the update",className:sr,children:[n.jsx(Lx,{className:"size-3"}),"Restart to update"]})}):e.kind==="desktop-install-failed"?n.jsxs("div",{role:"group","aria-label":"Update didn’t install",className:"flex flex-col gap-1.5 px-0.5",children:[n.jsx("p",{className:"text-sidebar-foreground/70 text-2xs leading-snug",children:tS}),n.jsxs("button",{type:"button",onClick:e.downloadFresh,"aria-label":"Download a fresh copy of DorkOS",className:z(sr,"self-start"),children:[n.jsx(ph,{className:"size-3"}),"Download fresh copy"]})]}):n.jsxs("div",{className:"flex items-center gap-1 px-0.5",children:[n.jsxs("button",{type:"button",onClick:o,"aria-label":`Copy the update command for v${e.latestVersion}`,className:sr,children:[t?n.jsx(Ft,{className:"size-3"}):n.jsx(Kc,{className:"size-3"}),nS(e.latestVersion,t,s)]}),n.jsx("button",{type:"button",onClick:e.dismiss,"aria-label":"Dismiss update notification",className:"text-sidebar-foreground/50 hover:text-sidebar-foreground focus-ring rounded-md p-0.5 transition-colors duration-150",children:n.jsx(He,{className:"size-3"})})]})}function Jd(){const{shouldShowGettingStarted:e,dismiss:t}=Nt(),s=Zk(),r=vv(),o=Yv(),a=Gk("dashboard-sidebar"),i=Mn(),c=[{id:"getting-started",show:e,render:()=>n.jsx(Hv,{onDismiss:t})},{id:"update",show:s.kind!=="none",render:()=>n.jsx(sS,{update:s})},{id:"identity-prompt",show:r.visible,render:()=>n.jsx(Vv,{prompt:r})},{id:"profile-prompt",show:o.visible,render:()=>n.jsx(Wv,{prompt:o})},a];return n.jsx(jx,{candidates:c,ready:i.settled})}const ti="dorkos-pinned-agents";function Zd(){const{data:e}=Oe(),t=mo(),{update:s}=Yt(),r=t.pinned.length,o=l.useRef(!1);l.useEffect(()=>{if(o.current||e===void 0)return;const a=localStorage.getItem(ti);if(a===null){o.current=!0;return}o.current=!0;let i=[];try{const c=JSON.parse(a);Array.isArray(c)&&(i=c.filter(d=>typeof d=="string"))}catch{i=[]}r===0&&i.length>0&&s(c=>({...c,pinned:i.map(d=>({kind:"agent",path:d}))})),localStorage.removeItem(ti)},[e,r,s])}function eu(e){return l.useMemo(()=>gh(e),[e])}const rS=1800*1e3,sn={finishedWhileAwayCount:0,idleWhileAwayCount:0};function ni(e){let t=null;for(const s of Object.values(e)){const r=Date.parse(s);Number.isNaN(r)||(t===null||r>t)&&(t=r)}return t}function oS(e,t,s,r){const o=new Set(t);let a=0;for(const i of e){if(o.has(i.id))continue;const c=Date.parse(i.updatedAt);Number.isNaN(c)||c>s&&c<=r&&(a+=1)}return a}function aS(e,t,s,r,o){const a=new Set(t);let i=0;for(const c of e){if(a.has(c.id))continue;const d=s[c.id];if(d==="streaming"||d==="blocked"||d==="error")continue;const m=Date.parse(c.updatedAt);Number.isNaN(m)||m<=r||m>o||o-m<rS||(i+=1)}return i}function iS(e){const{now:t,sessions:s,workingSessionIds:r,sessionStatuses:o,interactions:a,storedLastShownDate:i,settled:c}=e,d=xh(),{update:m}=Yt(),[u,h]=l.useState(null),p=l.useRef(!1);l.useEffect(()=>{!c||p.current||(p.current=!0,h({value:i}))},[c,i]);const f=u==null?void 0:u.value,[g]=l.useState(()=>ni(a)),x=ni(a),b=x!==null&&(g===null||x>g),y=l.useMemo(()=>b||!d.isAvailable||!d.enabled||d.maxPosts<=0||x===null||t-x<d.absenceThresholdMinutes*6e4?sn:{finishedWhileAwayCount:oS(s,r,x,t),idleWhileAwayCount:aS(s,r,o,x,t)},[b,d.isAvailable,d.enabled,d.absenceThresholdMinutes,d.maxPosts,x,t,s,r,o]),k=yh(t),j=u!==null&&y.finishedWhileAwayCount>0&&f!==k,C=l.useRef(!1);return l.useEffect(()=>{!j||C.current||(C.current=!0,m(v=>bh(v,k)))},[j,k,m]),{digest:y,lastShownDate:f}}function cS(e,t){const{update:s}=Yt(),r=l.useMemo(()=>t?vh(e).map(a=>a.target.kind==="suggestion"?a.target.suggestionId:null).filter(a=>a!==null):null,[e,t]),o=l.useRef(null);l.useEffect(()=>{const a=o.current;if(o.current=r,a===null||r===null)return;const i=a.filter(c=>!r.includes(c));i.length!==0&&s(c=>i.reduce((d,m)=>wh(d,m),c))},[r,s])}const lS={discoveredUnregisteredPaths:[],nonSystemAgentCount:1,hasEverStartedSession:!0,hasPostedInTeam:!0,hasDorkBotSession:!0};function dS(e){const{agents:t,agentActivity:s,sessionCount:r,rooms:o,rosterResolved:a}=e,i=bs(c=>c.candidates);return l.useMemo(()=>{if(!a)return{facts:lS,isResolved:!1};const c=new Set(t.map(h=>h.path)),d=i.map(h=>h.path).filter(h=>!c.has(h)),m=t.find(h=>h.isSystem)??null,u=o.find(h=>h.wellKnown===jh);return{facts:{discoveredUnregisteredPaths:d,nonSystemAgentCount:t.filter(h=>!h.isSystem).length,hasEverStartedSession:r>0||Object.keys(s).length>0,hasPostedInTeam:(u==null?void 0:u.viewerHasPosted)??!0,hasDorkBotSession:m!==null&&s[m.path]!==void 0},isResolved:!0}},[t,s,r,o,a,i])}const uS=6e4,si=10,mS=[],hS={};function fS(e){return e.sessions.length<=si?e:{...e,sessions:e.sessions.slice(0,si)}}function tu(e,t){const s=Eh(e),r=s.read();return r!==e&&!t(r,e)?(s.write(e),e):r}function pS(e,t){const s=Object.keys(e),r=Object.keys(t);return s.length===r.length&&r.every(o=>Object.is(e[o],t[o]))}function gS(e,t){return e.length===t.length&&t.every((s,r)=>e[r]===s)}function rr(e){return tu(e,pS)}function xS(e){return tu(e,gS)}function yS(e){const t=Ae({select:d=>d.location.pathname}),s=Gr({strict:!1}),r=t==="/session"?s.session??null:null,o=t==="/session"?s.dir??null:null,a=t==="/channels"?s.id??null:null,i=t==="/channels"||t==="/"?s.thread??null:null,c=a===null?null:e(a);return l.useMemo(()=>r!==null?{kind:"session",sessionId:r,agentPath:o??"",cwd:o}:a===null||c===null?null:i!==null?{kind:"room",roomId:a,roomKind:"thread",rootEntryId:i}:{kind:"room",roomId:a,roomKind:c},[r,o,a,c,i])}function nu(e={}){const{coveredSignalIds:t}=e,s=co(uS),r=Mn(),o=Tc(kh,{select:fS}),a=l.useMemo(()=>{var L;return((L=o.data)==null?void 0:L.sessions)??[]},[o.data]),i=ct(Rc(L=>{const q={};for(const[K,ne]of Object.entries(L.statuses))q[K]=ne.lifecycle;return q})),c=l.useMemo(()=>Object.entries(i).filter(([,L])=>L==="streaming").map(([L])=>L),[i]),d=ct(l.useCallback(L=>L.statusCwds,[])),m=Ns(),u=l.useMemo(()=>{const L=m.data??[];return r.fleetKnown?L:L.filter(q=>q.kind!=="dm")},[m.data,r.fleetKnown]),h=Sh(),p=l.useMemo(()=>h.data??[],[h.data]),f=ro(),g=rr(l.useMemo(()=>{const L={};for(const[q,K]of Object.entries(f)){if(!q.startsWith("agent:"))continue;const ne=Date.parse(K);Number.isNaN(ne)||(L[q.slice(6)]=ne)}return L},[f])),b=Rn().data,y=xS(l.useMemo(()=>((b==null?void 0:b.agents)??[]).map(L=>L.projectPath),[b])),j=ws(y).data,{brokenPaths:C}=Ch(),v=rr(px(y,C,g)),N=l.useMemo(()=>{var L;return((L=o.data)==null?void 0:L.agentActivity)??{}},[o.data]),I=r.fleetKnown?y:mS,D=l.useMemo(()=>I.map(L=>{const q=(j==null?void 0:j[L])??null,K=N[L],ne=K===void 0?NaN:Date.parse(K);return{path:L,runtime:(q==null?void 0:q.runtime)??"claude-code",namespace:(q==null?void 0:q.namespace)??null,isSystem:(q==null?void 0:q.isSystem)??!1,lastActivityAt:Number.isNaN(ne)?null:ne,lastInteractionAt:g[L]??null,attention:v[L]??"inactive"}}),[I,j,N,v,g]),T=l.useMemo(()=>Hc(I,j??{}),[I,j]),E=rr(l.useMemo(()=>{const L={};for(const q of a){const K=q.userLastMessageAt;K!==void 0&&(L[`session:${q.id}`]=K)}return L},[a])),w=mo(),A=l.useMemo(()=>kb(w),[w]),S=iS({now:s,sessions:a,workingSessionIds:c,sessionStatuses:i,interactions:f,storedLastShownDate:A.digest.lastShownDate,settled:r.settled}),M=l.useMemo(()=>({...A,digest:{lastShownDate:S.lastShownDate}}),[A,S.lastShownDate]),R=l.useMemo(()=>Nh(w.muted),[w.muted]),O=_x({mutedRoomIds:R}),P=l.useMemo(()=>({items:O.items,automated:O.automated}),[O.items,O.automated]),F=l.useMemo(()=>{const L=new Map;for(const q of u)L.set(q.id,q.kind==="dm"?"dm":"channel");return L},[u]),V=l.useMemo(()=>L=>F.get(L)??"channel",[F]),Z=yS(V),H=Ah(L=>L.automatedExpanded),ee=qc(),te=dS({agents:D,agentActivity:N,sessionCount:a.length,rooms:u,rosterResolved:r.phase!=="cold"}),se=l.useMemo(()=>({now:s,sessions:a,workingSessionIds:c,liveSessionCwds:d,sessionStatuses:i,rooms:u,threads:p,agents:D,displayNames:T,attention:ee,recents:P,prefs:M,interactions:f,userLastMessageAt:E,mentions:hS,...t===void 0?{}:{coveredSignalIds:t},todayAutomatedExpanded:H,activeTarget:Z,journey:te.facts,digest:S.digest}),[t,s,a,c,d,i,u,p,D,T,ee,P,M,f,E,H,Z,te.facts,S.digest]);return cS(se,te.isResolved),se}const su="Heads up and Today fill themselves. Pin it to Library to keep it in place.",ru={channels:"Channels",dms:"Direct messages",agents:"Agents"};function ri(e){if(typeof e!="object"||e===null)return!1;const t=e.kind;if(t==="pinned")return!0;if(t==="ungrouped"){const s=e.section;return s===void 0||typeof s=="string"&&s in ru}if(t==="computed"){const s=e.zone;return s==="now"||s==="today"||s==="getting-started"}return t==="group"&&typeof e.groupId=="string"}function bS(e){if(typeof e!="object"||e===null)return!1;const t=e.kind;return t==="agent"?typeof e.path=="string":t==="room"&&typeof e.roomId=="string"}function mn(e){if(typeof e!="object"||e===null)return null;const t=e.type;if(t==="item"){const s=e.ref,r=e.container;return bS(s)&&ri(r)?{type:"item",ref:s,container:r}:null}if(t==="group"){const s=e.groupId;return typeof s=="string"?{type:"group",groupId:s}:null}if(t==="container"){const s=e.container;return ri(s)?{type:"container",container:s}:null}return null}function ou(e){return e===null?null:e.type==="item"?{type:"item",ref:e.ref,from:e.container}:e.type==="group"?{type:"group",groupId:e.groupId}:null}function au(e){if(e===null)return null;switch(e.type){case"item":return{type:"item",ref:e.ref,container:e.container};case"group":return{type:"group-header",groupId:e.groupId};case"container":return{type:"container",container:e.container}}}function iu(e){switch(e.type){case"container":return{container:e.container};case"item":return{container:e.container,overRef:e.ref};case"group-header":return{container:{kind:"group",groupId:e.groupId}}}}function cn(e,t){return e.findIndex(s=>Wc(s,t))}function oi(e,t,s,r){const o=e.groups.find(i=>i.id===s);if(!o)return{kind:"none"};if(o.kind==="smart")return{kind:"reject-smart-group",groupId:s,ref:t};let a=null;if(o.sortMode==="manual"&&r!==void 0){const i=cn(o.items,r);i>=0&&(a=i)}return{kind:"move-to-group",ref:t,groupId:s,toIndex:a}}function $o(e,t,s){if(s===null)return{kind:"none"};if(t.type==="group"){if(s.type!=="group-header")return{kind:"none"};const c=e.groups.findIndex(m=>m.id===t.groupId),d=e.groups.findIndex(m=>m.id===s.groupId);return c<0||d<0||c===d?{kind:"none"}:{kind:"reorder-group",groupId:t.groupId,from:c,to:d}}const{ref:r,from:o}=t,{container:a,overRef:i}=iu(s);if(a.kind==="computed")return{kind:"reject-computed-zone",ref:r};if(o.kind==="pinned"){if(a.kind!=="pinned")return{kind:"unpin",ref:r};if(i===void 0)return{kind:"none"};const c=cn(e.pinned,r),d=cn(e.pinned,i);return c<0||d<0||c===d?{kind:"none"}:{kind:"reorder-pinned",ref:r,from:c,to:d}}if(o.kind==="group"){if(a.kind==="pinned")return{kind:"pin",ref:r};if(a.kind==="ungrouped")return{kind:"remove-from-group",ref:r};if(a.groupId!==o.groupId)return oi(e,r,a.groupId,i);const c=e.groups.find(u=>u.id===o.groupId);if(!c||c.sortMode!=="manual"||i===void 0)return{kind:"none"};const d=cn(c.items,r),m=cn(c.items,i);return d<0||m<0||d===m?{kind:"none"}:{kind:"reorder-within-group",groupId:o.groupId,ref:r,from:d,to:m}}return a.kind==="pinned"?{kind:"pin",ref:r}:a.kind==="group"?oi(e,r,a.groupId,i):{kind:"none"}}function vS(e,t){switch(t.kind){case"none":case"reject-smart-group":case"reject-computed-zone":return e;case"reorder-group":return Dh(e,t.from,t.to);case"pin":return Rh(e,t.ref);case"unpin":return Th(e,t.ref);case"remove-from-group":return Xo(e,t.ref,null);case"reorder-within-group":return Jo(e,t.groupId,t.from,t.to);case"reorder-pinned":return Ih(e,t.from,t.to);case"move-to-group":{const s=Xo(e,t.ref,t.groupId);if(t.toIndex===null)return s;const r=s.groups.find(o=>o.id===t.groupId);return r?Jo(s,t.groupId,r.items.length-1,t.toIndex):s}}}function wS(e,t,s){return vS(e,$o(e,t,s))}function jS(e,t){return e.type==="group"?`Picked up section ${t.groupName(e.groupId)}.`:`Picked up ${t.itemName(e.ref)}.`}function kS(e,t){switch(e.kind){case"reorder-group":return`Moved section ${t.groupName(e.groupId)}.`;case"move-to-group":return`Moved ${t.itemName(e.ref)} to ${t.groupName(e.groupId)}.`;case"pin":return`Pinned ${t.itemName(e.ref)}.`;case"unpin":return`Unpinned ${t.itemName(e.ref)}.`;case"remove-from-group":return`Moved ${t.itemName(e.ref)} out of its section.`;case"reorder-within-group":return`Reordered ${t.itemName(e.ref)} in ${t.groupName(e.groupId)}.`;case"reorder-pinned":return`Reordered ${t.itemName(e.ref)} in Pinned.`;case"reject-smart-group":return`Can’t move ${t.itemName(e.ref)} into ${t.groupName(e.groupId)}. Membership is rule-based. Edit rules instead.`;case"reject-computed-zone":return`Can’t move ${t.itemName(e.ref)} there. ${su}`;case"none":return""}}function SS(e,t){if(e===null)return"";const{container:s}=iu(e);switch(s.kind){case"pinned":return"Over Pinned.";case"ungrouped":return`Over ${s.section===void 0?"Agents":ru[s.section]}.`;case"computed":return s.zone==="today"?"Over Today.":"Over Heads up.";case"group":return`Over ${t.groupName(s.groupId)}.`}}function CS(e){const t=r=>ou(mn(r.active.data.current)),s=r=>{var o;return au(mn((o=r.over)==null?void 0:o.data.current))};return{onDragStart:r=>{const o=t(r);return o?jS(o,e()):void 0},onDragOver:r=>{if(t(r))return SS(s(r),e())||void 0},onDragEnd:r=>{const o=t(r);if(!o)return;const a=e(),i=$o(a.prefs,o,s(r));return i.kind==="none"?"Movement cancelled. Item returned to its place.":kS(i,a)},onDragCancel:r=>{const o=t(r);if(!o)return;const a=e();return`Movement cancelled. ${o.type==="group"?a.groupName(o.groupId):a.itemName(o.ref)} returned to its place.`}}}function NS({label:e}){const t=Ce();return n.jsx(G.div,{initial:{scale:1},animate:{scale:t===!0?1:Mh},transition:{duration:t===!0?0:Oh},className:"bg-sidebar border-sidebar-border text-sidebar-foreground shadow-floating flex items-center rounded-md border px-2.5 py-1.5 text-xs font-medium",children:e})}const AS=60;function ES(e){const t=document.querySelectorAll(`[${Zo}]`);for(const s of t)if(s.getAttribute(Zo)===e)return s.querySelector(`[${_h}]`);return null}function IS(e,t=AS){let s=t;const r=()=>{const o=ES(e);if(o!==null){o.focus();return}s-- >0&&requestAnimationFrame(r)};requestAnimationFrame(r)}const TS={start:["Space"],cancel:["Escape"],end:["Space","Enter","Tab"]};function RS(e,t){switch(t.kind){case"move-to-group":return Ps(t.groupId,t.ref);case"remove-from-group":return Ps("ungrouped",t.ref);case"unpin":{const s=e.groups.find(r=>r.items.some(o=>Wc(o,t.ref)));return Ps((s==null?void 0:s.id)??"ungrouped",t.ref)}default:return null}}function DS({data:e,itemName:t,groupName:s}){const r=e.type==="group"?s(e.groupId):e.type==="item"?t(e.ref):"";return n.jsx(NS,{label:r})}function OS({children:e,displayNames:t,rooms:s}){const r=Ne(),o=mo(),{update:a}=Yt(),[i,c]=l.useState(null),d=ln(o),m=ln(t),u=l.useMemo(()=>Object.fromEntries(s.map(k=>[k.id,k.slug??k.title])),[s]),h=ln(u),p=Ph(ea(Kh,{activationConstraint:{distance:8}}),ea(Uh,{coordinateGetter:zh,keyboardCodes:TS}));if(r)return n.jsx(n.Fragment,{children:e});const f=k=>{var j;return((j=d.read().groups.find(C=>C.id===k))==null?void 0:j.name)??"group"},g=k=>k.kind==="agent"?m.read()[k.path]??k.path.split("/").pop()??"Agent":h.read()[k.roomId]??"room",x=CS(()=>({prefs:d.read(),itemName:g,groupName:f})),b=k=>{c(mn(k.active.data.current))},y=k=>{var I;c(null);const j=ou(mn(k.active.data.current));if(j===null)return;const C=au(mn((I=k.over)==null?void 0:I.data.current)),v=$o(d.read(),j,C);if(v.kind==="reject-smart-group"){ae.info("Membership is rule-based. Edit rules instead.",{description:f(v.groupId)});return}if(v.kind==="reject-computed-zone"){ae.info(su,{description:g(v.ref)});return}if(v.kind==="none"||(a(D=>wS(D,j,C)),!(k.activatorEvent instanceof KeyboardEvent)))return;const N=RS(d.read(),v);N!==null&&IS(N)};return n.jsx(Lh,{value:!0,children:n.jsxs(Fh,{sensors:p,collisionDetection:$h,accessibility:{announcements:x},onDragStart:b,onDragEnd:y,onDragCancel:()=>c(null),children:[e,n.jsx(Bh,{children:i?n.jsx(DS,{data:i,itemName:g,groupName:f}):null})]})})}function MS(){var r;const e=qt(!0),t=ys();if(!t.community)return null;if(e.isPending)return n.jsx("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:"Loading space…"});if(e.isError)return n.jsxs("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:["Spaces could not be loaded."," ",n.jsx(_,{variant:"ghost",size:"sm",onClick:()=>void e.refetch(),children:"Retry"})]});const s=(r=e.data)==null?void 0:r.find(({ref:o})=>o===t.community);return s?s.status!=="connected"?n.jsx("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:"Reconnect this space to open its channels."}):n.jsx(_S,{connection:s}):n.jsx("p",{role:"status",className:"text-muted-foreground px-3 py-2 text-xs",children:"This space is no longer connected."})}function _S({connection:e}){var o,a,i;const t=eo(e.access),s=Hh(e.ref,t.capabilities.read,t.fingerprint),r=ys();return n.jsxs("section",{"aria-label":e.label,className:"px-2 py-2",children:[n.jsx("h3",{className:"text-muted-foreground px-2 text-xs font-medium",children:e.label}),!t.cacheReadable&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:e.status==="reconnect-required"?"Reconnect to view channels.":"Channels aren’t available."}),t.cacheReadable&&!t.verified&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:"Saved channels"}),t.verified&&s.isPending&&n.jsx("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:"Loading channels…"}),t.verified&&s.isError&&n.jsxs("p",{role:"status",className:"text-muted-foreground px-2 py-1 text-xs",children:["Space unavailable."," ",n.jsx(_,{variant:"ghost",size:"sm",onClick:()=>void s.refetch(),children:"Retry"})]}),((o=s.data)==null?void 0:o.stale)&&n.jsx("p",{className:"text-muted-foreground px-2 text-xs",children:"Saved channels · offline"}),(a=s.data)==null?void 0:a.rooms.filter(c=>!c.archived).map(c=>n.jsxs(qh,{...pe.channels(),search:{community:e.ref,id:c.roomId},"aria-current":r.community===e.ref&&r.id===c.roomId?"page":void 0,className:"hover:bg-accent aria-[current=page]:bg-accent flex min-h-9 items-center justify-between gap-2 rounded-md px-2 py-1 text-sm",children:[n.jsxs("span",{className:"truncate",children:["#",c.slug??c.title]}),c.unreadCount!==null&&c.unreadCount>0&&n.jsx("span",{className:"text-muted-foreground text-xs","aria-label":`${c.unreadCount} unread messages`,children:c.unreadCount})]},c.roomId)),((i=s.data)==null?void 0:i.rooms.length)===0&&n.jsx("p",{className:"text-muted-foreground px-2 py-1 text-xs",children:"No channels available."})]})}const PS=[2,3,3],ai=["w-14","w-10","w-16"];function LS(){return n.jsx("div",{className:"flex flex-col gap-1","data-testid":"sidebar-skeleton","aria-hidden":!0,children:PS.map((e,t)=>n.jsxs("div",{className:"flex flex-col",children:[n.jsx("div",{className:z("flex h-7 items-center",Wh),children:n.jsx(yt,{className:z("h-2.5 rounded-sm",ai[t])})}),Array.from({length:e},(s,r)=>n.jsx(Gh,{showIcon:!0},r))]},ai[t]))})}const FS=.16,$S=4,BS=.03,zS={hidden:{},shown:{transition:{staggerChildren:BS}}},US={hidden:{opacity:0,y:$S},shown:{opacity:1,y:0}};function ii(e){return{duration:e===!0?0:FS}}const KS=2500;function ci(e){var t;return((t=e.zones.find(s=>s.id==="now"))==null?void 0:t.needsYouCount)??0}function HS(e){const t=Ce(),[s,r]=l.useState(!1),o=l.useRef(ci(e)),a=ci(e),i=e.zones.some(c=>c.id==="now");return l.useEffect(()=>{const c=o.current;if(o.current=a,!(t!==!0&&c>0&&a===0&&!i)){r(!1);return}r(!0);const m=setTimeout(()=>r(!1),KS);return()=>clearTimeout(m)},[a,i,t]),s}function cu(){const[e,t]=l.useState(!1),[s,r]=l.useState(!1),o=l.useCallback(()=>t(!0),[]),a=l.useCallback(()=>t(!1),[]),i=l.useCallback(()=>r(!0),[]),c=l.useCallback(()=>r(!1),[]);return{inside:e||s,handlers:{onPointerEnter:o,onPointerLeave:a,onFocus:i,onBlur:c}}}const li=5e3;function qS(e){const{inside:t,handlers:s}=cu(),r=e.zones.some(m=>m.id==="getting-started"),[o,a]=l.useState(r),i=l.useRef(null),c=l.useRef(!r);return l.useEffect(()=>{if(!r){c.current||(c.current=!0,i.current=Date.now(),a(!1));return}if(o||t)return;const m=i.current===null?Number.POSITIVE_INFINITY:Date.now()-i.current;if(m>=li){c.current=!1,a(!0);return}const u=setTimeout(()=>{c.current=!1,a(!0)},li-m);return()=>clearTimeout(u)},[r,o,t]),{model:l.useMemo(()=>!r||o?e:{...e,zones:e.zones.filter(m=>m.id!=="getting-started")},[e,r,o]),handlers:s}}const WS=1e3;function lu(e){const[t,s]=l.useState(""),r=l.useRef(t);return l.useEffect(()=>{const o=e??"";if(o===r.current)return;const a=setTimeout(()=>{r.current=o,s(o)},WS);return()=>clearTimeout(a)},[e]),t}function GS(){return n.jsxs("p",{"data-slot":"sidebar-all-clear",className:"text-sidebar-foreground/70 flex min-h-7 items-center gap-1.5 px-2 text-[13px]",children:[n.jsx(Ft,{className:"text-status-success size-3.5 shrink-0","aria-hidden":!0}),"All clear"]})}const YS=1,di=40;function VS({onCommit:e,onCancel:t}){const[s,r]=l.useState(""),o=l.useRef(null),a=l.useRef(!1),i=Yh(o);l.useEffect(()=>{var m;(m=o.current)==null||m.focus()},[]);const c=()=>{if(a.current)return;a.current=!0;const m=s.trim();if(m.length<YS||m.length>di){t();return}e(m)},d=m=>{m.key==="Enter"?(m.preventDefault(),c()):m.key==="Escape"&&(m.preventDefault(),a.current=!0,t())};return n.jsx(Vh,{children:n.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5",children:[n.jsx(Qh,{className:"text-muted-foreground size-3.5 shrink-0"}),n.jsx("input",{ref:o,value:s,maxLength:di,placeholder:"Section name","aria-label":"New section name",onChange:m=>r(m.target.value),onKeyDown:d,onBlur:m=>{i.shouldHandleBlur(m)&&(a.current||t())},className:z("bg-background text-foreground placeholder:text-muted-foreground/50","focus-visible:ring-ring min-w-0 flex-1 rounded border px-1.5 py-0.5 text-xs outline-none focus-visible:ring-1")})]})})}function ns({zone:e,onToggleAll:t,allClear:s=!1,lead:r,silenceLiveRegion:o=!1}){const a=lu(e.liveRegionText);return n.jsxs("section",{"aria-label":e.label,"data-sidebar-zone":e.id,className:z("rounded-lg py-1",e.id==="now"||e.id==="getting-started"?"bg-sidebar-accent/40":void 0),children:[!o&&n.jsx("span",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:a}),r,s?n.jsx(GS,{}):n.jsxs(n.Fragment,{children:[e.id==="library"&&e.sections.length>0&&n.jsx(QS,{}),e.sections.map(i=>n.jsx(Xh,{section:i,onToggleAll:t},i.id))]})]})}function QS(){const e=Jh();return e.groupCreation===null?null:n.jsx(Zh,{children:n.jsx(VS,{onCommit:e.commitNewGroup,onCancel:e.cancelNewGroup})})}const XS='[aria-current="page"]';function JS(e,t,s){const r=Ce(),o=l.useRef(null);l.useLayoutEffect(()=>{var m,u;if(!s)return;const a=o.current===null,i=((m=o.current)==null?void 0:m.key)??null;if(o.current={key:t},!a&&(i===t||t===null)||t===null)return;const c=(u=e.current)==null?void 0:u.querySelector(XS);if(!(c instanceof HTMLElement))return;const d=!a&&r!==!0;c.scrollIntoView({block:"nearest",behavior:d?"smooth":"auto"})},[t,e,s])}function ZS(e,t){const s=new Map(t.map((a,i)=>[a,i])),r=[],o=[];for(const a of e){const i=s.get(a.key);i===void 0?o.push(a):r.push({row:a,at:i})}return r.sort((a,i)=>a.at-i.at),[...r.map(a=>a.row),...o]}function eC(e,t){const{inside:s,handlers:r}=cu(),[o,a]=l.useState(null),[i,c]=l.useState(s);i!==s&&(c(s),a(s?e.map(h=>h.key):null));const[d,m]=l.useState(t);return d!==t&&(m(t),a(s?e.map(h=>h.key):null)),{rows:o===null?[...e]:ZS(e,o),handlers:r}}const tC="anchor:active-session";function nC({zone:e,onToggleAll:t,silenceLiveRegion:s=!1}){var h;const r=l.useRef(null),o=e.sections.find(p=>p.id==="today"),a=l.useMemo(()=>(o==null?void 0:o.rows)??[],[o]),i=((h=a.find(p=>p.reason===tC))==null?void 0:h.key)??null,c=eC(a,i),d=Mn();JS(r,i,d.settled);const m=l.useMemo(()=>sC(a),[a]),u=l.useMemo(()=>({...e,sections:e.sections.map(p=>p.id==="today"?{...p,rows:c.rows}:p)}),[e,c.rows]);return n.jsx("div",{ref:r,...c.handlers,children:n.jsx(ns,{zone:u,onToggleAll:t,silenceLiveRegion:s,lead:n.jsx(rC,{roomIds:m})})})}function sC(e){const t=new Set;for(const s of e)s.unread.tier!=="none"&&s.target.kind==="room"&&t.add(s.target.roomId);return[...t]}function rC({roomIds:e}){const t=Ne(),s=ef();return!t||e.length===0?null:n.jsx(oC,{count:e.length,onCatchUp:()=>s(e)})}function oC({count:e,onCatchUp:t}){return n.jsx("div",{className:"px-2 pt-0.5 pb-1",children:n.jsxs("button",{type:"button","data-testid":"today-catch-up",onClick:t,"aria-label":`Catch up: mark ${e} unread ${e===1?"conversation":"conversations"} in Today as read`,className:z("text-sidebar-foreground/80 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-ring","flex w-full items-center gap-2 rounded-md px-2 text-[13px] font-medium",nf,Vt),children:[n.jsx(tf,{className:"size-4 shrink-0","aria-hidden":!0}),"Catch up",n.jsx("span",{"data-slot":"catch-up-count",className:"text-sidebar-foreground/70 text-2xs ml-auto tabular-nums",children:e})]})})}const ui={id:"now",label:af.now,sections:[],reason:"zone:now"};function aC(e){return e.collapsible?e.id.startsWith("group:")||Gc(e.id)!==null:!1}function Ur({model:e,zoneIds:t,nowSlot:s=null,silenceLiveRegion:r=!1}){const{update:o}=Yt(),a=sf(),c=no()?os(a.destination):null,d=Mn(),m=Ce(),{model:u,handlers:h}=qS(e),p=e.zones.flatMap(C=>C.sections).filter(aC),f=l.useCallback(C=>t===void 0||t.includes(C),[t]),g=l.useCallback(()=>{if(p.length===0)return;const C=p.some(v=>!v.collapsed);o(v=>{let N=v;for(const I of p){if(I.id.startsWith("group:")){N=rf(N,I.id.slice(6),C);continue}const D=Gc(I.id);D!==null&&(N=of(N,D,C))}return N})},[p,o]),x=HS(e),b=e.zones.some(C=>C.id==="now"),y=b||e.zones.some(C=>C.id==="getting-started"),k=s!==null&&!b&&f("now"),j={variants:US,transition:ii(m)};return c?n.jsx("div",{className:"flex min-h-0 flex-col","data-community-context":c,children:n.jsx(MS,{})}):n.jsx("div",{className:"flex flex-col gap-1",...h,children:n.jsx(Ee,{mode:"wait",initial:!1,children:d.phase==="cold"?n.jsx(G.div,{exit:{opacity:0},transition:ii(m),children:n.jsx(LS,{})},"skeleton"):n.jsxs(G.div,{className:"flex flex-col gap-1",variants:zS,initial:d.startedWarm?!1:"hidden",animate:"shown",children:[k&&n.jsx(G.div,{...j,children:n.jsx(ns,{zone:ui,onToggleAll:g,lead:s,silenceLiveRegion:r})}),x&&!y&&!k&&f("now")&&n.jsx(G.div,{...j,children:n.jsx(ns,{zone:ui,onToggleAll:g,allClear:!0,silenceLiveRegion:r})}),u.zones.filter(C=>f(C.id)).map(C=>n.jsx(G.div,{...j,children:C.id==="today"?n.jsx(nC,{zone:C,onToggleAll:g,silenceLiveRegion:r}):n.jsx(ns,{zone:C,onToggleAll:g,silenceLiveRegion:r,...C.id==="now"?{lead:s}:{}})},C.id))]},"zones")})})}function iC(){Zd();const e=nu(),t=eu(e),s=Mn();return n.jsxs("nav",{"aria-label":"Sidebar","aria-busy":s.phase==="cold"?!0:void 0,className:"flex min-h-0 flex-1 flex-col",children:[n.jsx(cf,{className:"sidebar-scroll-edges px-2 py-3",children:n.jsx(Yc,{activeTarget:e.activeTarget,children:n.jsx(OS,{displayNames:e.displayNames,rooms:e.rooms,children:n.jsx(Ur,{model:t})})})}),n.jsx(Jd,{})]})}const cC=2;function lC(){return{label:"Active now",rules:{statuses:["needs-attention","active"]}}}function dC(e){const t=new Map;for(const s of e)t.set(s.runtime,(t.get(s.runtime)??0)+1);return Array.from(t.entries()).filter(([,s])=>s>=cC).map(([s,r])=>({runtime:s,count:r,label:Ye(s).label})).sort((s,r)=>r.count-s.count||s.label.localeCompare(r.label)).map(({runtime:s,label:r})=>({label:`Runs on ${r}`,rules:{runtimes:[s]}}))}const mi="agent:";function uC(){const[e]=On(),t=ro(),{data:s}=Rn(),r=l.useMemo(()=>((s==null?void 0:s.agents)??[]).map(i=>i.projectPath),[s]),{data:o}=ws(r),a=l.useMemo(()=>Hc(r,o??{}),[r,o]);return l.useMemo(()=>{const i=new Set(r);let c=null,d=-1/0;for(const[u,h]of Object.entries(t)){if(!u.startsWith(mi))continue;const p=u.slice(mi.length);if(!i.has(p))continue;const f=Date.parse(h);Number.isNaN(f)||f<=d||(d=f,c=p)}const m=e!==null&&i.has(e)?e:c;return m===null?null:{path:m,displayName:a[m]??m}},[a,t,r,e])}function mC(e){l.useEffect(()=>{if(!Pe())return;const t=s=>{!(s.metaKey||s.ctrlKey)||s.shiftKey||s.altKey||s.key.toLowerCase()==="n"&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function hC(e){const t=e.smartGroupPresets.length===0?[]:[{kind:"separator",id:"sep-smart"},...e.smartGroupPresets.map(r=>({kind:"action",id:`new-group-preset:${r.label}`,label:r.label,icon:rt,opensInput:!1,run:()=>e.onCreatePresetSmartGroup(r)})),{kind:"action",id:"new-group-custom",label:"Custom rules",icon:rt,opensInput:!0,run:e.onOpenSmartGroupDialog}],s=[t.length===0?{kind:"action",id:"new-group",label:"Section",icon:rt,opensInput:!0,run:e.onNewGroup}:{kind:"submenu",id:"new-group",label:"Section",icon:rt,items:[{kind:"action",id:"new-group-empty",label:"Empty section",icon:rt,opensInput:!0,run:e.onNewGroup},...t]}];return[{kind:"action",id:"new-session",label:"Session",icon:Bc,opensInput:!1,...e.showSessionShortcut?{hint:Mt(xn.NEW_SESSION)}:{},run:e.onNewSession},...e.lastUsedAgentName===null?[]:[{kind:"note",id:"new-session-note",icon:hf,text:`Starts with ${e.lastUsedAgentName} (last used)`}],{kind:"separator",id:"sep-rooms"},{kind:"action",id:"new-channel",label:"Channel",icon:ho,opensInput:!0,run:e.onNewChannel},{kind:"action",id:"new-message",label:"Group message",icon:kl,opensInput:!0,run:e.onNewMessage},{kind:"separator",id:"sep-agents"},{kind:"action",id:"new-agent",label:"Agent",icon:ff,opensInput:!0,run:e.onNewAgent},...s]}function fC(){const e=Ne(),t=Kn(O=>O.menuOpen),s=Kn(O=>O.preselect),r=Kn(O=>O.setMenuOpen),o=Kn(O=>O.requestNewGroup),a=Ie(),i=Pc(),[,c]=On(),d=Fx(),m=uC(),{update:u}=Yt(),[h,p]=l.useState(!1),[f,g]=l.useState(!1),[x,b]=l.useState(!1),{data:y}=Rn(),k=l.useMemo(()=>((y==null?void 0:y.agents)??[]).map(O=>O.projectPath),[y]),{data:j}=ws(k),C=l.useMemo(()=>k.map(O=>{var P,F;return{projectPath:O,runtime:((P=j==null?void 0:j[O])==null?void 0:P.runtime)??"claude-code",namespace:((F=j==null?void 0:j[O])==null?void 0:F.namespace)??null,attention:"inactive",lastActivityAt:null}}),[k,j]),v=lf(C),N=l.useMemo(()=>v?[lC(),...dC(C)]:[],[C,v]),I=l.useMemo(()=>{const O=new Map;for(const P of C)O.has(P.runtime)||O.set(P.runtime,Ye(P.runtime).label);return Array.from(O,([P,F])=>({value:P,label:F})).sort((P,F)=>P.label.localeCompare(F.label))},[C]),D=l.useMemo(()=>{const O=new Set;for(const P of C)P.namespace&&O.add(P.namespace);return Array.from(O).sort()},[C]),T=l.useCallback((O,P)=>u(F=>df(F,O,P).next),[u]),E=l.useCallback(O=>{Tt.getState().recordOpened("room",O.id),a({...pe.channels(),search:{id:O.id}})},[a]),w=l.useCallback(()=>i(m==null?void 0:m.path),[m,i]);mC(w);const A=l.useCallback(O=>{const[P]=O;if(P!==void 0&&$x(O)){c(P.agentPath,{onOpened:()=>Tt.getState().recordOpened("agent",P.agentPath)});return}const F=uf(O.map(V=>V.displayName));d.mutate({agentPaths:O.map(V=>V.agentPath),title:F},{onSuccess:E})},[E,c,d]),S=hC({onNewSession:w,lastUsedAgentName:(m==null?void 0:m.displayName)??null,onNewChannel:()=>p(!0),onNewMessage:()=>g(!0),onNewAgent:()=>Ss.getState().open(),onNewGroup:()=>o(),smartGroupPresets:N,onCreatePresetSmartGroup:O=>T(O.label,O.rules),onOpenSmartGroupDialog:()=>b(!0),showSessionShortcut:Pe()}),M=Vc(S),R=l.useRef(null);return l.useEffect(()=>{if(!t||s===null)return;const O=requestAnimationFrame(()=>{var P,F;(F=(P=R.current)==null?void 0:P.querySelector(`[data-menu-item-id="${s}"]`))==null||F.focus()});return()=>cancelAnimationFrame(O)},[t,s]),n.jsxs(n.Fragment,{children:[n.jsxs(vc,{open:t,onOpenChange:r,children:[n.jsx(wc,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"sidebar-new-button",className:z("bg-sidebar-accent text-sidebar-accent-foreground hover:bg-sidebar-accent/70 focus-visible:ring-sidebar-ring flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium outline-hidden transition-colors duration-150 focus-visible:ring-2",e&&z(Vt,"px-3")),children:[n.jsx(Ht,{className:"size-3.5"}),"New"]})}),n.jsx(jc,{ref:R,align:"end",className:"w-56",onCloseAutoFocus:M.onCloseAutoFocus,children:n.jsx(jr,{variant:"dropdown",nodes:M.nodes})})]}),h&&n.jsx(Bx,{open:!0,onOpenChange:O=>!O&&p(!1),onCreated:E}),n.jsx(zx,{open:f,onOpenChange:g,onStart:A,hideTrigger:!0}),n.jsx(mf,{open:x,onOpenChange:b,mode:"create",runtimeOptions:I,namespaceOptions:D,onSubmit:({name:O,rules:P})=>T(O,P)})]})}function pC(){const e=B(s=>s.setGlobalPaletteOpen),t=Ne();return n.jsxs("button",{type:"button","data-testid":"sidebar-search-pill",onClick:()=>e(!0),className:z("bg-sidebar-accent/40 text-sidebar-foreground/60 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground focus-visible:ring-sidebar-ring flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-[13px] outline-hidden transition-colors duration-150 focus-visible:ring-2",t&&Vt),children:[n.jsx(pn,{className:"size-(--size-icon-sm) shrink-0"}),n.jsx("span",{className:"truncate",children:"Jump to anything…"}),n.jsx(Qc,{className:"bg-sidebar-accent text-sidebar-foreground/70 ml-auto shrink-0 border-transparent",children:Mt(xn.COMMAND_PALETTE)})]})}function gC(e){const t=[];return e.you!==null&&t.push({kind:"action",id:"you",label:e.you.name,description:"View profile",icon:Jr,leading:e.you.face,guardsFocus:!0,run:e.you.onOpen}),t.push({kind:"action",id:"dorkos-account",label:"DorkOS account",description:e.accountStatus,icon:Xc,guardsFocus:!0,run:e.onOpenAccount},{kind:"action",id:"settings",label:"Settings",icon:As,guardsFocus:!0,run:e.onOpenSettings}),t}function xC(e){return e.isDevMode?[{kind:"separator",id:"sep-version"},{kind:"note",id:"version",icon:xr,text:"Development build"}]:e.version===null?[]:[{kind:"separator",id:"sep-version"},{kind:"action",id:"version",label:`v${e.version} beta`,icon:xr,opensInput:!1,hint:"Check for updates",run:e.onCheckForUpdates}]}function yC(e){const t=(e==null?void 0:e.trim())??"";return t.length===0||t===pf?"Your team":t.endsWith("s")?`${t}’ team`:`${t}’s team`}function bC(e,t){const s=gf(e);return l.createElement(xf,{size:t,kind:s.kind,color:s.color,emoji:s.emoji,imageUrl:s.imageUrl,fallback:s.fallback,origin:s.origin})}function du(e="xs"){var i;const t=Qr(),{open:s}=qe(),{open:r}=fo(),o=Gj(),a=((i=t.data)==null?void 0:i.members.find(c=>c.isSelf))??null;return{you:a===null?null:{name:a.displayName,face:bC(a,e),onOpen:()=>r(a.id)},accountStatus:Wj(o),onOpenAccount:()=>s("account"),onOpenSettings:()=>s()}}function vC(e=[]){var m;const t=Qr(),s=ie(),r=ce(),o=du(),a=((m=t.data)==null?void 0:m.members.find(u=>u.isSelf))??null,{data:i,refetch:c}=be({queryKey:De.current(),queryFn:()=>s.getConfig(),staleTime:Vi}),d=l.useCallback(async()=>{var f,g;await r.invalidateQueries({queryKey:De.all});const u=await c(),h=(f=u.data)==null?void 0:f.version,p=((g=u.data)==null?void 0:g.latestVersion)??null;if(h===void 0){ae.error("Couldn’t check for updates");return}if(p!==null&&uo(p,h)){ae.success(`Version ${p} is available`);return}ae.success("You’re up to date")},[r,c]);return{teamName:yC((a==null?void 0:a.displayName)??null),nameUnknown:t.isPending,identityNodes:gC(o),nodes:[...e,...xC({version:(i==null?void 0:i.version)??null,isDevMode:(i==null?void 0:i.isDevMode)??!1,onCheckForUpdates:()=>void d()})]}}const wC="https://dorkos.ai/docs/self-hosting/space-server";function jC(e){const t=[];for(const s of e)s.hostOperator===!0&&!t.includes(s.pinnedOrigin)&&t.push(s.pinnedOrigin);return t}function kC(e){var o,a,i;const t=e.status!=="pending"&&((o=e.access)==null?void 0:o.state)!=="unverified",s=((i=(a=e.access)==null?void 0:a.lastKnown)==null?void 0:i.lifecycle)??null,r=e.status==="connected";return{hostReachable:t,canInvite:t&&r&&s==="active",canOpenSettings:t,canLeave:t&&r}}function Vn(e){try{return new URL(e).host}catch{return e}}function SC(e){const t=[],s=e.selected;if(s){const{connection:a,availability:i}=s,c=[],d={host:Vn(a.pinnedOrigin)};i.canInvite&&c.push({kind:"action",id:"community-invite",label:"Invite people",icon:bf,external:d,run:e.onInvite}),i.canOpenSettings&&c.push({kind:"action",id:"community-settings",label:"Space settings",icon:As,external:d,run:e.onOpenSettings}),s.canMoveUp&&c.push({kind:"action",id:"community-move-up",label:"Move up",icon:vf,run:()=>e.onMove("up")}),s.canMoveDown&&c.push({kind:"action",id:"community-move-down",label:"Move down",icon:wf,run:()=>e.onMove("down")}),c.push({kind:"separator",id:"community-sep-end"}),c.push({kind:"action",id:"community-disconnect",label:"Disconnect",icon:jf,opensInput:!0,destructive:!0,run:e.onDisconnect}),i.canLeave&&c.push({kind:"action",id:"community-leave",label:"Leave space",icon:kf,opensInput:!0,external:d,run:e.onLeave}),t.push({kind:"submenu",id:"community-actions",label:`Manage ${a.label}`,icon:Nr,items:c})}const r=[...e.creationOrigins.map(a=>({kind:"action",id:e.creationOrigins.length===1?"add-community-create":`add-community-create-${Vn(a)}`,label:e.creationOrigins.length===1?"Create a space on your server":`Create a space on ${Vn(a)}`,icon:Ly,opensInput:!0,external:{host:Vn(a)},run:()=>e.onCreate(a)})),{kind:"action",id:"add-community-deploy",label:"Run your own space server",icon:yf,run:e.onDeploy}],o=[];return e.hosting&&o.push({kind:"action",id:"add-community-start",label:"Start a space",icon:po,opensInput:!0,run:e.hosting.onStart}),o.push({kind:"action",id:"add-community-join",label:"Join a space",icon:Jc,opensInput:!0,run:e.onJoin}),e.hosting&&o.push({kind:"action",id:"add-community-yours",label:"Your spaces",icon:My,guardsFocus:!0,run:e.hosting.onOpenYourSpaces}),o.push({kind:"separator",id:"add-community-sep-advanced"},{kind:"submenu",id:"add-community-advanced",label:"Advanced",icon:ic,items:r}),t.push({kind:"submenu",id:"add-community",label:"Add a space",icon:Ht,items:o}),t}function uu(e){var s,r,o,a,i,c;const t=(r=(s=e.access)==null?void 0:s.lastKnown)==null?void 0:r.lifecycle;return{kind:"community",key:`community:${e.ref}`,ref:e.ref,remoteCommunityId:e.remoteCommunityId,label:e.label,icon:{kind:"community",ref:e.ref},pinnedOrigin:e.pinnedOrigin,membershipState:t==="deletion_pending"?"deletion-pending":t==="taken_down"?"taken-down":t??(e.status==="pending"?"pending":"active"),connectionState:e.status,availability:((o=e.access)==null?void 0:o.state)==="verified"?"online":((a=e.access)==null?void 0:a.state)==="unverified"?"offline":"unknown",unreadCount:((i=e.attention)==null?void 0:i.unreadCount)??null,mentionCount:((c=e.attention)==null?void 0:c.mentionCount)??null}}function CC(e){var r,o;if(e.status==="reconnect-required")return"Reconnect required";const t=(o=(r=e.access)==null?void 0:r.lastKnown)==null?void 0:o.lifecycle;if(e.seemsGoneSince&&t!=="deleted"&&t!=="taken_down")return"Seems to be gone";const s=uu(e);if(s.membershipState!=="active")return s.membershipState.replace("-"," ");if(s.availability!=="online")return s.availability}function NC({connection:e,onOpenChange:t,onDisconnected:s}){var p;const r=Zc(),o=Ql(e),[a,i]=l.useState(e);e!==null&&e!==a&&i(e);const c=(a==null?void 0:a.label)??"this space",d=(a==null?void 0:a.status)==="pending"?[]:(p=o.data)==null?void 0:p.agents,m=d===void 0&&o.fetchStatus==="fetching",u=d?Jl(c,d):m?null:Zl(c);function h(){e&&r.mutate(e,{onSuccess:f=>{t(!1);const g=ed(e.label,f);g.tone==="success"?ae.success(g.message):ae.warning(g.message,{duration:15e3}),s(e)}})}return n.jsx(Sf,{open:e!==null,onOpenChange:f=>{f||r.reset(),t(f)},children:n.jsxs(Cf,{children:[n.jsxs(Nf,{children:[n.jsxs(Af,{children:["Disconnect this DorkOS from ",c,"?"]}),n.jsx(Ef,{asChild:!0,children:n.jsxs("div",{className:"space-y-2",children:[n.jsxs("p",{children:["Its channels leave this app. You stay a member of ",c,"."]}),n.jsx("p",{children:"You can connect again later."}),u&&n.jsx("p",{className:"text-foreground",children:u}),m&&n.jsx("p",{children:"Checking for agents you added from here…"})]})})]}),o.isError&&d===void 0&&!m&&n.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-sm sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[n.jsxs("p",{className:"text-destructive",children:["Couldn’t check which of your agents are on ",c,"."]}),n.jsx(_,{size:"sm",variant:"outline",onClick:()=>void o.refetch(),children:"Check again"})]}),r.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t disconnect. Check DorkOS is running and try again."}),n.jsxs(If,{children:[n.jsx(Tf,{disabled:r.isPending,children:"Keep connected"}),n.jsx(_,{variant:"destructive",disabled:r.isPending||m,onClick:h,children:r.isPending?"Disconnecting…":"Disconnect"})]})]})})}function AC(e,t){var r;const s=typeof e=="object"&&e!==null?e:{};switch(s.code){case"COMMUNITY_SELECTION_REQUIRED":return`That address has several spaces. Use one space’s own link, like ${IC(t)}.`;case"COMMUNITY_NAME_NOT_FOUND":return"No space uses that address. Check the spelling, or ask for its full link.";case"COMMUNITY_RATE_LIMITED":return`Too many tries. Your address may be fine. Wait ${Rf((r=s.body)==null?void 0:r.retryAfterSeconds)}, then try again.`;case"COMMUNITY_UPGRADE_REQUIRED":return"This space’s server is too old for this DorkOS. Ask its owner to update it.";default:return"Couldn’t connect. Check the space’s address and try again."}}function EC(e){const t=typeof e=="object"&&e!==null?e.code:"";return t!=="COMMUNITY_RATE_LIMITED"&&t!=="COMMUNITY_UPGRADE_REQUIRED"}function IC(e){try{return`${new URL(e??"").origin}/your-space`}catch{return"https://example.com/acme"}}const TC="That invitation link is incomplete or isn’t secure. Copy the whole link again.";function RC(e){let t;try{t=new URL(e.trim())}catch{return!1}return/^\/(?:c\/[^/]+\/)?join\/?$/u.test(t.pathname)&&!kr(e)}function DC(e){const t=new URL(e.trim()),s=/^(\/c\/[^/]+)\/join\/?$/u.exec(t.pathname);return s?`${t.origin}${s[1]}`:t.origin}function OC({request:e,onOpenChange:t,installName:s,onConnected:r}){var P;const o=jn(!0),a=qt(!0),i=Df(o),c=e!==null,d=Ls(F=>F.links),m=Ls(F=>F.rememberLink),u=Ls(F=>F.ending),h=(o==null?void 0:o.ownerKey)??null,[p,f]=l.useState(null),g=F=>f(F===null?null:{owner:h,ref:F}),[x,b]=l.useState(null),[y,k]=l.useState(null),[j,C]=l.useState((u==null?void 0:u.id)??0),[v,N]=l.useState(null),[I,D]=l.useState(null);e!==I&&(D(e),e&&(g(e.ref),b(null))),p!==null&&h!==null&&p.owner!==h&&(p.owner===null?f({owner:h,ref:p.ref}):(f(null),b(null),N(null)));const T=p!==null&&p.owner===h?p.ref:null,E=T===null||(P=a.data)==null?void 0:P.find(F=>F.ref===T),w=!E&&y!==null&&!y.settled&&y.address===i&&y.connection.ref===T?y.connection:null,A=E??w;if(A&&h!==null&&((v==null?void 0:v.owner)!==h||v.ref!==A.ref||v.label!==A.label)&&N({owner:h,ref:A.ref,label:A.label}),u&&u.id!==j)C(u.id),u.ref===T&&u.outcome!=="connected"&&(g(null),b({address:i,value:u.outcome==="expired"?`Approval for ${u.label} expired. Connect again to continue.`:`Approval for ${u.label} was cancelled.`}));else if(c&&T!==null&&!A&&a.isSuccess){const F=(v==null?void 0:v.owner)===h&&v.ref===T?v.label:"this space";g(null),b({address:i,value:`Approval for ${F} ended somewhere else. Connect again to continue.`})}Of(c&&(A==null?void 0:A.status)==="pending"?A.ref:null);const S=Mf((A==null?void 0:A.status)==="pending"?A:null),M=c&&(A==null?void 0:A.status)==="connected"?A.ref:null,R=l.useRef(r),O=l.useRef(t);return l.useEffect(()=>{R.current=r,O.current=t}),l.useEffect(()=>{M===null||!A||(ae.success(`${A.label} is connected.`,{id:`community-approval-${M}`}),O.current(!1),R.current(M))},[M]),n.jsx(et,{open:c,onOpenChange:t,children:n.jsx(tt,{className:"!min-h-0 sm:max-w-md",children:n.jsx(MC,{authority:o,connection:A,check:S,approvalUrl:A&&(d==null?void 0:d.address)===i?d.urls[A.ref]:void 0,notice:(x==null?void 0:x.address)===i?x.value:"",installName:s,onStarted:F=>{m(i,F.connection.ref,F.approvalUrl),k({address:i,connection:F.connection,settled:!1}),g(F.connection.ref),b({address:i,value:`Next, approve this DorkOS on ${F.connection.label}.`})},onStartSettled:F=>k(V=>(V==null?void 0:V.connection.ref)===F?{...V,settled:!0}:V),onEnded:F=>{g(null),b({address:i,value:F})},onCancelled:F=>{t(!1),ae.success(`Approval for ${F} was cancelled.`)},onClose:()=>t(!1)})})})}function MC({authority:e,connection:t,check:s,approvalUrl:r,notice:o,installName:a,onStarted:i,onStartSettled:c,onEnded:d,onCancelled:m,onClose:u}){const h=ie(),p=ce(),f=kc(),g=l.useId(),[x,b]=l.useState(""),[y,k]=l.useState(null),[j,C]=l.useState(!1),[v,N]=l.useState(a),I=l.useRef(null),D=l.useRef(null),T=t===null?"form":t.status,E=l.useRef(T);l.useEffect(()=>{var ee,te;const H=E.current;E.current=T,H!==T&&(T==="form"?(ee=I.current)==null||ee.focus():T==="pending"&&((te=D.current)==null||te.focus()))},[T]);const w=kn({mutationFn:async H=>{if(!e||!pt(e))throw new Error("Community owner is still loading.");const ee=await h.startCommunityConnection({url:H,installName:v.trim()});if(!pt(e))throw new Error("Community owner changed.");return ee},onSuccess:async H=>{b(""),i(H),e&&await p.invalidateQueries({queryKey:it.connections(e)}),c(H.connection.ref)}}),A=Zc(),S=Ql((t==null?void 0:t.status)==="reconnect-required"?t:null),M=w.error;l.useEffect(()=>{var H;(M||j)&&((H=I.current)==null||H.focus())},[M,j]);const R=kr(x),O=j?TC:w.error?AC(w.error,w.variables):null;function P(H){if(H.preventDefault(),!(!x.trim()||w.isPending)){if(RC(x)){w.reset(),C(!0);return}if(kr(x)){if(!dt(f.linkFor(x.trim())))return;b(DC(x)),k({host:new URL(x.trim()).host,withAccount:f.signsInWithAccount(x)}),w.reset();return}v.trim()&&w.mutate(x.trim())}}function F(H){A.mutate(H,{onSuccess:ee=>{if(H.status==="pending")m(H.label);else{const te=ed(H.label,ee);d(te.tone==="success"?`${H.label} is disconnected. Connect again to continue.`:te.message)}},onSettled:()=>{e&&p.invalidateQueries({queryKey:it.connections(e)})}})}const V=n.jsx("p",{role:"status","aria-live":"polite",className:o?"text-muted-foreground text-sm":"sr-only",children:o});if(t===null)return n.jsxs("form",{onSubmit:P,children:[n.jsxs(Xe,{children:[n.jsx(ze,{children:"Join a space"}),n.jsx(Je,{children:"Bring a space’s channels here. You approve it on the space’s site."})]}),n.jsxs(lt,{className:"space-y-4 py-4",children:[V,n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_e,{htmlFor:`${g}-url`,children:"Space address or invitation link"}),n.jsx(Ze,{ref:I,id:`${g}-url`,type:"url",inputMode:"url",placeholder:"https://example.com/acme","aria-describedby":O?`${g}-url-hint ${g}-url-error`:`${g}-url-hint`,"aria-invalid":j||w.error&&EC(w.error)?!0:void 0,required:!0,autoComplete:"off",value:x,onChange:H=>{b(H.target.value),k(null),C(!1)},disabled:w.isPending||!e}),n.jsx("p",{id:`${g}-url-hint`,"aria-live":"polite",className:"text-muted-foreground text-xs",children:y?y.withAccount?`Join on ${y.host} with your DorkOS account in the new tab, then connect.`:`Finish joining on ${y.host} in the new tab, then connect.`:"Its link, short address or an invitation link."})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_e,{htmlFor:`${g}-name`,children:"Name for this installation"}),n.jsx(Ze,{id:`${g}-name`,required:!0,maxLength:120,"aria-describedby":`${g}-name-hint`,value:v,onChange:H=>N(H.target.value),disabled:w.isPending||!e}),n.jsx("p",{id:`${g}-name-hint`,className:"text-muted-foreground text-xs",children:"What the space calls this DorkOS."})]}),O&&n.jsx("p",{id:`${g}-url-error`,role:"alert",className:"text-destructive text-sm",children:O})]}),n.jsxs(Dt,{children:[n.jsx(_,{type:"button",variant:"outline",onClick:u,children:"Cancel"}),n.jsx(_,{type:"submit",disabled:w.isPending||!x.trim()||!R&&(!e||!v.trim()),children:w.isPending?"Connecting…":R?"Open invitation":"Connect"})]})]});const Z=n.jsx("p",{className:"text-muted-foreground text-xs break-all",children:t.pinnedOrigin});if(t.status==="reconnect-required"){const H=!S.data&&S.fetchStatus==="fetching",ee=S.data?Jl(t.label,S.data.agents):H?null:Zl(t.label);return n.jsxs(n.Fragment,{children:[n.jsxs(Xe,{children:[n.jsxs(ze,{children:["Reconnect ",t.label]}),n.jsxs(Je,{children:["DorkOS can’t reach ",t.label,"’s channels. Disconnect, then connect again."]})]}),n.jsxs(lt,{className:"space-y-3 py-4",children:[Z,ee&&n.jsx("p",{className:"text-sm",children:ee}),S.isError&&!S.data&&!H&&n.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-2 text-sm sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[n.jsxs("p",{className:"text-destructive",children:["Couldn’t check which of your agents are on ",t.label,"."]}),n.jsx(_,{size:"sm",variant:"outline",onClick:()=>void S.refetch(),children:"Check again"})]}),A.isError&&n.jsx("p",{role:"alert",className:"text-destructive text-sm",children:"Couldn’t disconnect. Check DorkOS is running and try again."})]}),n.jsxs(Dt,{children:[n.jsx(_,{type:"button",variant:"outline",onClick:u,children:"Close"}),n.jsx(_,{disabled:A.isPending||H,onClick:()=>F(t),children:A.isPending?"Disconnecting…":"Disconnect"})]})]})}return n.jsxs(n.Fragment,{children:[n.jsxs(Xe,{children:[n.jsxs(ze,{children:["Approve on ",t.label]}),n.jsx(Je,{asChild:!0,children:n.jsxs("div",{className:"space-y-1",children:[n.jsxs("p",{children:["Approve this DorkOS on ",t.label,"’s site."]}),r&&f.signsInWithAccount(r)&&n.jsx("p",{children:"Sign in there with your DorkOS account."}),n.jsx("p",{children:"This screen moves on once you do."})]})})]}),n.jsxs(lt,{className:"space-y-3 py-4",children:[Z,V,n.jsxs("p",{className:"flex items-center gap-2 text-sm",children:[n.jsx(wt,{})," Waiting for your approval"]}),r?n.jsx(_,{asChild:!0,children:n.jsxs("a",{ref:D,href:f.linkFor(r),target:"_blank",rel:"noopener noreferrer",children:["Open ",t.label," to approve",n.jsx(yn,{className:"size-3.5","aria-hidden":!0})]})}):n.jsx("p",{className:"text-muted-foreground text-sm",children:"Approve in the tab that opened. Closed it? Cancel and connect again."}),(A.isError||!!s.error)&&n.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[n.jsx("p",{children:A.isError?"Couldn’t confirm it was cancelled. Refresh to check.":"Couldn’t check approval. Try again."}),!A.isError&&n.jsx(_,{size:"sm",variant:"outline",onClick:s.retry,disabled:s.isFetching,children:"Check approval"})]})]}),n.jsxs(Dt,{children:[n.jsx(_,{type:"button",variant:"outline",onClick:u,children:"Close"}),n.jsx(_,{variant:"outline",disabled:A.isPending,onClick:()=>F(t),children:A.isPending?"Cancelling…":"Cancel approval"})]})]})}function _C(e){if(!["ArrowDown","ArrowUp","Home","End"].includes(e.key))return;const t=[...e.currentTarget.querySelectorAll('[role^="menuitem"]:not(:disabled):not([aria-disabled="true"])')];if(t.length===0)return;e.preventDefault();const s=t.indexOf(document.activeElement),r=t.length-1;let o;e.key==="Home"?o=0:e.key==="End"?o=r:e.key==="ArrowDown"?o=s<0||s===r?0:s+1:o=s<=0?r:s-1,t[o].focus()}function hi({sheet:e,label:t="Actions",children:s}){return e?n.jsx("div",{role:"menu","aria-label":t,tabIndex:-1,onKeyDown:_C,children:s}):n.jsx(n.Fragment,{children:s})}function or(){let e=!1;const t=()=>{e=!0};return document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",t,!0),{acted:()=>e,stop:()=>{document.removeEventListener("pointerdown",t,!0),document.removeEventListener("keydown",t,!0)}}}function PC({trigger:e,selectedRef:t}){const s=ie(),r=Ne(),o=Ie(),a=Ae({select:f=>f.location}),i=l.useRef(!1),c=l.useRef(!1),[d,m]=l.useState(null);function u(f,g){var b;if(!r||(f||(c.current=!1),g))return;if(f){const y=or();Pf({cancelled:y.acted}).finally(y.stop);return}const x=document.activeElement;(x===null||x===document.body)&&((b=e.current)==null||b.focus())}async function h(f){if(f.ref===t||i.current||f.status!=="connected")return;const g=ta();if(g.ownerKey===null)return;const x={epoch:g.epoch,ownerKey:g.ownerKey},b={pathname:a.pathname,search:a.search};c.current=r;const y=or();i.current=!0,m(f.ref);let k=!1,j=null;try{await o({...pe.channels(),search:{community:f.ref}}),k=!0,j=bn();const C=await s.resolveCommunityNavigation(f.ref),v=C?null:(await s.listRemoteCommunityRooms(f.ref)).rooms.find(I=>I.readable&&!I.archived)??null,N=(C==null?void 0:C.roomId)??(v==null?void 0:v.roomId);if(!pt(x)||!j.isCurrent()){u(!1,y.acted());return}N&&await o({...pe.channels(),search:{community:f.ref,...N?{id:N}:{},...C!=null&&C.threadId?{thread:C.threadId}:{}}}),u(!0,y.acted())}catch{u(!1,y.acted()),k&&(j==null?void 0:j.isCurrent())===!0&&pt(x)&&await o({to:b.pathname,search:b.search,replace:!0}).then(()=>!0,()=>!1)&&ae.error(`Couldn’t open ${f.label}.`,{description:"You’re still where you were. Try again in a moment."})}finally{y.stop(),i.current=!1,m(null)}}async function p(){if(t===void 0||i.current)return;const f=ta();if(f.ownerKey===null)return;const g={epoch:f.epoch,ownerKey:f.ownerKey},x=bn();c.current=r;const b=or();i.current=!0;try{const y=await s.getCommunityNavigation();if(y.ownerKey!==g.ownerKey||!pt(g)||!x.isCurrent()){u(!1,b.acted());return}const k=_f.safeParse(y.installationDestination);await o(k.success?{to:k.data.path,search:k.data.search}:{...pe.home()}),u(!0,b.acted())}catch{const y=pt(g)&&x.isCurrent();y&&await o({...pe.home()}),u(y,b.acted())}finally{b.stop(),i.current=!1}}return{pendingRef:d,isSelecting:()=>i.current,holdCloseFocus:()=>{c.current=!0},takeCloseFocusHold:()=>{const f=c.current;return c.current=!1,f},selectCommunity:h,selectInstallation:p}}function LC(e){const t=l.useRef(e);l.useEffect(()=>{t.current=e},[e]),l.useEffect(()=>{const s=r=>{if(r.isComposing||!(r.metaKey||r.ctrlKey)||!r.shiftKey||r.altKey||r.key.toLowerCase()!=="k")return;r.preventDefault();const o=document.activeElement;t.current(o instanceof HTMLElement&&o!==document.body?o:null)};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[])}function FC(e,t){const s=new Map(t.map((r,o)=>[r,o]));return[...e].sort((r,o)=>{const a=s.get(r.ref)??Number.MAX_SAFE_INTEGER,i=s.get(o.ref)??Number.MAX_SAFE_INTEGER;return a-i||r.label.localeCompare(o.label)||r.ref.localeCompare(o.ref)})}function $C(e){return e.charAt(0).toLowerCase()+e.slice(1)}function mu({triggerClassName:e,compact:t=!1}){var X;const s=Ne(),r=Ie(),o=no(),a=Ae({select:U=>U.location.search.community}),i=o?a:void 0,c=Lf(),d=Ff(),m=qt(),u=l.useMemo(()=>{var U;return FC(m.data??[],((U=c.data)==null?void 0:U.order)??[])},[m.data,(X=c.data)==null?void 0:X.order]),h=u.find(U=>U.ref===i)??null,p=l.useRef(null),f=l.useRef(null),g=l.useRef(null),{pendingRef:x,isSelecting:b,holdCloseFocus:y,takeCloseFocusHold:k,selectCommunity:j,selectInstallation:C}=PC({trigger:g,selectedRef:i}),[v,N]=l.useState(""),[I,D]=l.useState(!1),[T,E]=l.useState(null),[w,A]=l.useState(null),S=wj(),[M,R]=l.useState(null),O=i?u.findIndex(U=>U.ref===i):-1;function P(U,de){dt(new URL(Hf(U.remoteCommunityId,de),U.pinnedOrigin).toString())}const F=SC({selected:h?{connection:h,availability:kC(h),canMoveUp:O>0,canMoveDown:O>=0&&O<u.length-1}:null,onMove:U=>{h&&d.mutate({ref:h.ref,direction:U})},onInvite:()=>h&&P(h,"community"),onOpenSettings:()=>h&&P(h),onLeave:()=>h&&P(h,"account"),onDisconnect:()=>A(h),onJoin:()=>E({ref:null}),creationOrigins:jC(u),onCreate:U=>dt(new URL(Kf,U).toString()),onDeploy:()=>dt(wC),hosting:S?{onStart:()=>R({kind:"start"}),onOpenYourSpaces:()=>R({kind:"hosted"})}:null}),Z=vC(o?F:[]),H=Vc([...Z.identityNodes,...Z.nodes]),ee=H.nodes.slice(0,Z.identityNodes.length),te=H.nodes.slice(Z.identityNodes.length),se=Z.teamName,L=Z.nameUnknown,q=i!==void 0&&m.data===void 0,K=i===void 0?L:q,ne=i===void 0?se:(h==null?void 0:h.label)??"Space",W=s&&u.length>=8&&v.trim().length>0?u.filter(U=>U.label.toLocaleLowerCase().includes(v.trim().toLocaleLowerCase())):u;LC(U=>{f.current=U,D(!0)});function le(U){if(b())return;if(f.current=null,U==="installation"){C();return}const de=u.find(xe=>`community:${xe.ref}`===U);if(de){if(de.status==="connected"){j(de);return}y(),E({ref:de.ref})}}function ve(U){D(U),U||N("")}function we(U){if(H.onCloseAutoFocus(U),k()){U.preventDefault();return}const de=f.current;f.current=null,!(U.defaultPrevented||!(de!=null&&de.isConnected))&&(U.preventDefault(),de.focus())}l.useEffect(()=>{if(!I)return;const U=requestAnimationFrame(()=>{var de;return(de=p.current)==null?void 0:de.focus()});return()=>cancelAnimationFrame(U)},[I]);async function We(U){var ye;const xe=(ye=(await m.refetch()).data)==null?void 0:ye.find(Le=>Le.ref===U&&Le.status==="connected");xe&&await j(xe)}function Q(U){os(bn().destination)===U.ref&&r({...pe.home(),replace:!0})}return n.jsxs(n.Fragment,{children:[n.jsxs($f,{open:I,onOpenChange:ve,children:[n.jsx(Bf,{asChild:!0,children:n.jsxs("button",{ref:g,type:"button","data-testid":"sidebar-header-block","aria-label":K?"Context menu":`${ne} menu`,"aria-busy":x!==null||void 0,className:e,children:[t?i===void 0?n.jsx(ya,{className:"size-4 shrink-0","aria-hidden":!0}):n.jsx(Nr,{className:"size-4 shrink-0","aria-hidden":!0}):K?n.jsx(yt,{className:"my-[3px] h-3.5 w-24 rounded-sm","data-testid":"sidebar-team-name-skeleton"}):n.jsx("span",{className:"truncate",children:ne}),n.jsx(mt,{className:t?"size-3 shrink-0 opacity-50":"size-3.5 shrink-0 opacity-50","aria-hidden":!0}),n.jsx("span",{className:"sr-only",children:"Choose context"})]})}),n.jsxs(zf,{align:"start",className:"max-h-(--radix-dropdown-menu-content-available-height) w-64 overflow-y-auto",onCloseAutoFocus:we,children:[s&&n.jsx(na,{children:o?"Switch context":"Menu"}),n.jsx(hi,{sheet:s,label:"You",children:n.jsx(jr,{variant:s?"sheet":"dropdown",nodes:ee,onSheetClose:()=>ve(!1)})}),o&&n.jsx(sa,{}),o&&!s&&n.jsx(na,{children:"Switch context"}),o&&s&&u.length>=8&&n.jsx("div",{className:"px-4 pb-2",children:n.jsx(Ze,{type:"search",value:v,onChange:U=>N(U.target.value),placeholder:"Find a space","aria-label":"Find a space"})}),o&&n.jsxs(Uf,{value:i?`community:${i}`:"installation",onValueChange:le,children:[n.jsx(ra,{value:"installation",icon:ya,disabled:x!==null,itemRef:i===void 0?p:void 0,className:x!==null?"opacity-50":void 0,children:n.jsx("span",{className:"min-w-0 flex-1 truncate",children:se})}),W.map(U=>{var At;const de=uu(U),xe=de.mentionCount??0,ye=Math.max(0,(de.unreadCount??0)-xe),Le=[xe>0?`${xe} ${xe===1?"mention":"mentions"}`:null,ye>0?`${ye} other unread`:null,((At=U.attention)==null?void 0:At.state)==="stale"?`last checked ${$C(lo(U.attention.verifiedAt))}`:null].filter(Boolean).join(", ");return n.jsx(ra,{value:`community:${U.ref}`,icon:Nr,disabled:x!==null,itemRef:U.ref===i?p:void 0,description:[CC(U),Le].filter(Boolean).join(" · ")||void 0,className:x!==null?"opacity-50":void 0,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[n.jsx("span",{className:"min-w-0 truncate",children:U.label}),Ux(U)&&n.jsx("span",{role:"img",className:"bg-status-warning-dot size-2 shrink-0 rounded-full","aria-label":"Someone asked to take over this space",title:"Someone asked to take over this space"}),xe>0&&n.jsxs("span",{className:"bg-primary text-primary-foreground shrink-0 rounded-full px-1.5 text-xs","aria-label":`${xe} ${xe===1?"mention":"mentions"}`,children:["@",xe]}),ye>0&&n.jsx("span",{className:"bg-muted text-muted-foreground shrink-0 rounded-full px-1.5 text-xs","aria-label":`${ye} other unread`,children:ye})]})},U.ref)})]}),te.length>0&&n.jsxs(n.Fragment,{children:[n.jsx(sa,{}),n.jsx(hi,{sheet:s,children:n.jsx(jr,{variant:s?"sheet":"dropdown",nodes:te,onSheetClose:()=>ve(!1)})})]})]})]}),n.jsx(OC,{request:T,onOpenChange:U=>{U||E(null)},installName:L?"My DorkOS":se,onConnected:U=>void We(U)}),n.jsx(Kj,{entry:S,dialog:M,onDialogChange:R,installName:L?"My DorkOS":se,onConnected:U=>void We(U)}),n.jsx(NC,{connection:w,onOpenChange:U=>{U||A(null)},onDisconnected:Q})]})}function BC(){return n.jsx(mu,{compact:!0,triggerClassName:z("hover:bg-accent focus-visible:ring-ring text-foreground flex shrink-0 items-center rounded-md px-1 py-1.5 outline-hidden focus-visible:ring-2",Vt)})}function hu(){const e=Ne();return n.jsxs(qf,{className:"gap-2 px-2 py-3",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[!e&&n.jsx(mu,{triggerClassName:"text-sidebar-foreground hover:bg-sidebar-accent/70 focus-visible:ring-sidebar-ring flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 py-1 text-left text-[13px] font-semibold outline-hidden transition-colors duration-150 focus-visible:ring-2"}),n.jsx(fC,{})]}),n.jsx(pC,{})]})}function zC(){const e=du("sm");return n.jsxs("div",{className:"space-y-1 pb-2",children:[e.you!==null&&n.jsx(fi,{leading:e.you.face,label:e.you.name,description:"View profile",onClick:e.you.onOpen}),n.jsx(fi,{leading:n.jsx(Xc,{className:"text-muted-foreground size-7 p-0.5","aria-hidden":!0}),label:"DorkOS account",description:e.accountStatus,onClick:e.onOpenAccount})]})}function fi({leading:e,label:t,description:s,onClick:r}){return n.jsxs("button",{type:"button",onClick:r,className:z("hover:bg-accent focus-visible:ring-ring flex w-full items-center gap-3 rounded-md px-2 py-2 text-left outline-hidden focus-visible:ring-2",Vt),children:[n.jsx("span",{className:"flex shrink-0",children:e}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"text-foreground block truncate text-sm font-medium",children:t}),s!==void 0&&n.jsx("span",{className:"text-muted-foreground block truncate text-xs",children:s})]}),n.jsx(Tn,{className:"text-muted-foreground size-4 shrink-0","aria-hidden":!0})]})}const UC=6e4;function KC(e){return e===null?!0:(e.selectionStart??0)===0&&(e.selectionEnd??0)===0}function HC(e,t,s){if(!e)return null;const r=t===null?s:[t,...s];for(const o of r){const{item:a}=o.item;if(a.type==="agent"&&ke(a.data)===e)return{kind:"agent",agent:a.data};if((a.type==="room"||a.type==="dm")&&a.id===e)return{kind:"room",room:a.data}}return null}function qC(){const{globalPaletteOpen:e,setGlobalPaletteOpen:t}=h0(),s=B($=>$.openMessageSearch),[r,o]=l.useState(""),a=l.useRef(null),[i,c]=l.useState(""),d=l.useRef(null),[m,u]=l.useState([]),[h,p]=l.useState(null),[f,g]=l.useState(null),[x,b]=l.useState(null),y=m[m.length-1],[k,j]=l.useState(0),C=Ne(),v=B($=>$.globalPaletteInitialSearch),N=B($=>$.clearGlobalPaletteInitialSearch),I=l.useCallback(()=>{t(!1),N(),o(""),c(""),u([]),p(null),b(null)},[t,N]),{handleAgentSelect:D,startNewSession:T,handleFeatureAction:E,handleQuickAction:w,handleRoomSelect:A,handleSessionSelect:S,handleCommandSelect:M,handlePageSelect:R,recordAgentOpened:O,selectedCwd:P}=wk(I),F=ce(),V=l.useCallback($=>{const ge=Wf(F,$.projectPath);return Gf(ge?{session:ge}:{agentId:$.id})},[F]),Z=l.useCallback($=>{if(!Yf()){D($);return}ss(V($),{target:"tab"}),O($.projectPath),I()},[V,D,O,I]),H=l.useCallback($=>{ss(V($),{target:"window"}),O($.projectPath),I()},[V,O,I]),ee=Vf(),te=yk(),se=co(UC),{allAgents:L,newActions:q,rooms:K,sessions:ne,continueRows:W,recent:le,searchableItems:ve}=m0(P,se);Qf(L);const{bestMatch:we,rows:We,prefix:Q,term:X}=gk(ve,r,{usage:te,now:se,scope:x}),U=Q==="#",de=Nk(X),xe=de?{term:de,isScoped:x!==null,onSelect:()=>{I(),s(de)}}:null,ye=l.useMemo(()=>i?L.find($=>$.name===i)??null:null,[i,L]),Le=HC(i,we,We),At=l.useCallback($=>{b($),o(""),c("")},[]),nt=!C&&ye!==null,Et=l.useMemo(()=>{var $;return i?ne.find(ge=>ge.id===i)??(($=W.find(ge=>ge.session.id===i))==null?void 0:$.session)??null:null},[i,ne,W]),Ln=Wd((h==null?void 0:h.id)??"",(h==null?void 0:h.projectPath)??""),Fn=l.useCallback(()=>{u($=>$.slice(0,-1)),p($=>m.length<=1?null:$),c("")},[m.length]),$n=l.useCallback($=>{p($),u(ge=>[...ge,"agent-actions"]),o(""),c(""),j(ge=>ge+1)},[]);l.useEffect(()=>{e&&v!=null&&(o(v),N(),requestAnimationFrame(()=>{const $=a.current;if($){const ge=v.length;$.setSelectionRange(ge,ge)}}))},[e,v,N]);const Bn=l.useCallback($=>{t($),$?j(ge=>ge+1):(o(""),c(""),u([]),p(null),b(null))},[t]),Xt=Sk({rootRef:d,activePage:y??"root",onPin:c,resetKey:JSON.stringify([e,y??null,r,x&&Od(x)])}),Is=!r&&x===null,Ts=l.useId(),Rs=n.jsx(et,{open:e,onOpenChange:Bn,children:n.jsx(tt,{className:z("!min-h-0 overflow-hidden p-0 transition-[max-width] duration-200","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",nt?"max-w-[640px]":"max-w-[480px]",C&&"h-[85vh]"),children:n.jsxs(G.div,{variants:Xd,initial:"hidden",animate:"visible",exit:"exit",className:z("flex overflow-hidden",C&&"h-full flex-col"),children:[n.jsxs(el,{ref:d,loop:!0,shouldFilter:!1,value:i,onValueChange:c,onPointerMove:Xt.onPointerMove,className:z("min-w-0 flex-1",C&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),onKeyDown:$=>{if(Xt.onKeyDown($),$.key==="Enter"&&($.metaKey||$.ctrlKey)&&!y&&(Et==null?void 0:Et.cwd)!=null){$.preventDefault(),T(Et.cwd),I();return}if($.key==="Enter"&&($.metaKey||$.ctrlKey)&&!y&&ye){$.preventDefault(),Z(ye);return}if($.key==="Enter"&&($.metaKey||$.ctrlKey)&&y==="agent-actions"&&h){$.preventDefault(),Z(h);return}if($.key==="Tab"&&!$.shiftKey&&!y&&Le){$.preventDefault(),$.stopPropagation(),At(Le);return}if($.key==="Backspace"&&x&&!y&&KC(a.current)){$.preventDefault(),b(null);return}$.key==="Backspace"&&!r&&m.length>0&&($.preventDefault(),Fn()),$.key==="Escape"&&m.length>0&&($.preventDefault(),$.stopPropagation(),Fn())},children:[m.length>0&&n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1 border-b px-3 py-1.5 text-xs",children:[n.jsx("button",{onClick:()=>{u([]),p(null),j($=>$+1)},className:"hover:text-foreground transition-colors",children:"All"}),n.jsx("span",{children:"/"}),n.jsxs("span",{children:["Agent: ",h==null?void 0:h.name]})]}),n.jsx(tl,{ref:a,"data-testid":"command-palette-input",leading:x&&!y?n.jsx(Ck,{scope:x}):void 0,placeholder:y==="agent-actions"?`${(h==null?void 0:h.name)??"Agent"} actions…`:x&&!y?"Search within…":"Search rooms, agents, commands…",value:r,onValueChange:o}),n.jsx(nl,{children:n.jsxs(dn,{className:"h-full",children:[n.jsxs(Xf,{children:[n.jsx("p",{children:"No results found."}),n.jsx(Gd,{className:"justify-center pb-0"})]}),n.jsx(Ee,{mode:"wait",initial:!1,children:n.jsxs(G.div,{"data-palette-page":y??"root",initial:{opacity:0,x:y?16:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:y?-16:16},transition:{duration:.15,ease:"easeOut"},children:[!y&&n.jsx(Uk,{staggerKey:k,isZeroQuery:Is,isRoomMode:U,scope:x,hasQuery:X.length>0,selectedCwd:P,selectedValue:i,continueRows:W,recent:le,newActions:q,bestMatch:we,rows:We,rooms:K,searchHandoff:xe,onFeatureAction:E,onQuickAction:w,onGoToAgentActions:$n,onRoomSelect:A,onSessionSelect:$=>S($.id,$.cwd),onCommandSelect:M,onPageSelect:R}),y==="agent-actions"&&h&&n.jsx(Ek,{agent:h,onOpenHere:()=>D(h),onOpenNewTab:()=>Z(h),onOpenNewWindow:ee?()=>H(h):void 0,onNewSession:()=>{T(h.projectPath),O(h.projectPath),I()},onEditSettings:()=>{Jf.getState().openProfileDocked(h.projectPath),I()},onBrowseSessions:Ln.sessionCount>0?()=>{g(h),O(h.projectPath),I()}:void 0,recentSessions:Ln.recentSessions,onSelectSession:$=>S($,h.projectPath)})]},y??"root")})]})}),n.jsx(Tk,{page:y,hasAgentSelected:nt,canScope:!y&&Le!==null,isScoped:x!==null})]}),n.jsx(Ee,{children:nt&&ye&&n.jsx(Ak,{agent:ye},ye.id)})]})})});return n.jsxs(n.Fragment,{children:[n.jsx(Zf,{id:Ts,children:Rs}),f!==null&&n.jsx(ep,{agentPath:f.projectPath,agentName:f.displayName??f.name,agentVisual:js(f),open:!0,onOpenChange:$=>{$||g(null)},onSelectSession:$=>S($,f.projectPath),onNewSession:()=>T(f.projectPath)})]})}const WC="",GC="";function YC(e){const t=[];let s=e,r=!1;for(;s.length>0;){const o=r?GC:WC,a=s.indexOf(o);if(a===-1){t.push({text:s,matched:r});break}a>0&&t.push({text:s.slice(0,a),matched:r}),s=s.slice(a+o.length),r=!r}return t}function VC({excerpt:e,className:t}){const s=YC(e);return n.jsx("span",{className:t,children:s.map((r,o)=>r.matched?n.jsx("mark",{className:"text-foreground bg-transparent font-semibold",children:r.text},o):n.jsx("span",{children:r.text},o))})}const fu="rooms",QC=["claude-code","opencode"];function XC(e){if(e.source===fu)return{kind:"room",...pe.channels(),search:{id:e.container,entry:e.ordinal}};if(e.sessionId===void 0)return{kind:"unopenable"};const t=e.messageId!==void 0&&QC.includes(e.source);return{kind:"session",...ut({session:e.sessionId,dir:e.containerPath??void 0,...t?{message:e.messageId}:{}})}}function JC(e,t){return e.source===fu?t.get(e.container)??"Channel":e.containerPath===null?"Conversation":sl(e.containerPath)}function ZC(e){return e==="user"?"You":"Agent"}function eN({hit:e,containerLabel:t,value:s,onSelect:r,openable:o}){const a=e.source==="rooms"?ho:zy;return n.jsxs(fe,{value:s,onSelect:r,className:"flex flex-col items-start gap-1 py-2",children:[n.jsxs("div",{className:"text-muted-foreground flex w-full min-w-0 items-center gap-1.5 text-xs",children:[n.jsx(a,{className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"min-w-0 truncate",children:t}),n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("span",{className:"shrink-0",children:ZC(e.role)}),!o&&n.jsxs(n.Fragment,{children:[n.jsx("span",{"aria-hidden":"true",children:"·"}),n.jsx("span",{className:"shrink-0",children:"Ran outside DorkOS"})]}),e.createdAt!==null&&n.jsx("span",{className:"ml-auto shrink-0 tabular-nums",children:lo(e.createdAt)})]}),n.jsx(VC,{excerpt:e.excerpt,className:"text-foreground line-clamp-2 w-full text-sm break-words"}),e.containerPath!==null&&n.jsx("span",{dir:"rtl",className:"text-muted-foreground/70 text-3xs w-full truncate text-left",children:n.jsx("bdi",{dir:"ltr",children:e.containerPath})})]})}const tN=["Your channels and direct messages, as soon as they’re posted.","DorkOS conversations can lag five minutes.","Claude Code, Codex and OpenCode conversations, even outside DorkOS. These can lag five minutes."],nN=["Tool output is never searched: no errors, stack traces, file contents or diffs.","Matches whole words: “ogs” won’t find “dogs”. Type “dog*” to match word starts."],sN="Searches channels, direct messages, and DorkOS, Claude Code, Codex and OpenCode conversations. Not tool output.",rN=`Type at least ${rl} letters to search.`,oN="Search what was said…";function aN({detailOpen:e=!1,className:t}){const[s,r]=l.useState(null),o=s??e,a=nN;return n.jsxs(ps,{open:o,onOpenChange:r,className:z("px-3 py-2",t),children:[n.jsxs(gs,{className:z("text-muted-foreground/80 hover:text-foreground focus-ring text-2xs","flex w-full items-start gap-2 rounded-sm py-1 text-left leading-relaxed transition-colors"),children:[n.jsx("span",{className:"min-w-0 flex-1",children:sN}),n.jsx(mt,{className:z("mt-0.5 size-3 shrink-0 transition-transform",!o&&"-rotate-90"),"aria-hidden":"true"})]}),n.jsx(xs,{children:n.jsxs("ul",{className:"mt-2 space-y-1.5",children:[tN.map(i=>n.jsxs("li",{className:"text-muted-foreground flex gap-2 text-xs leading-relaxed",children:[n.jsx(Ft,{className:"text-brand mt-0.5 size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:i})]},i)),a.map(i=>n.jsxs("li",{className:"text-muted-foreground flex gap-2 text-xs leading-relaxed",children:[n.jsx(Uy,{className:"mt-0.5 size-3.5 shrink-0 opacity-60","aria-hidden":"true"}),n.jsx("span",{children:i})]},i))]})})]})}const iN=3e4,cN=e=>["message-search",e];function ar(e){return tp(e).some(t=>t.length>=rl)}function lN(e,t){const s=ie(),r=dN(e,np),o=t&&ar(e)&&ar(r),{data:a,isFetching:i,error:c}=be({queryKey:cN(r),queryFn:()=>s.search({q:r}),enabled:o,staleTime:iN,placeholderData:m=>m,retry:!1});return{submitted:o?r:"",tooShort:t&&r.trim().length>0&&!ar(r),results:o?(a==null?void 0:a.results)??[]:[],warnings:o?(a==null?void 0:a.warnings)??[]:[],isSearching:o&&i,error:o&&c instanceof Error?c:null}}function dN(e,t){const[s,r]=l.useState(e);return l.useEffect(()=>{const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t]),s}function uN(){const e=B(t=>t.toggleMessageSearch);l.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.shiftKey&&s.code==="KeyF"&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const ir="bg-muted rounded px-1 py-0.5 font-mono text-3xs";function mN(){uN();const e=B(v=>v.messageSearchOpen),t=B(v=>v.messageSearchQuery),s=B(v=>v.setMessageSearchOpen),r=Ne(),o=Ie(),a=ie(),[i,c]=l.useState("");l.useEffect(()=>{e&&c(t??"")},[e,t]);const{results:d,warnings:m,tooShort:u,isSearching:h,error:p,submitted:f}=lN(i,e),{data:g}=Ns({includeArchived:!0}),x=l.useMemo(()=>{const v=new Map;for(const N of g??[])v.set(N.id,N.kind==="channel"&&N.slug?`#${N.slug}`:N.title);return v},[g]),b=l.useCallback(()=>s(!1),[s]),y=l.useCallback((v,N)=>{if(N.kind!=="unopenable"&&(b(),o({to:N.to,search:N.search}),N.kind==="session"&&v.containerPath!==null)){const I=v.containerPath;a.browseDirectory(I).catch(D=>{if((D==null?void 0:D.status)===404){ae.info("That folder is gone",{description:`${I} is gone, so nothing new can run there. You can still read it.`});return}ae.info("Couldn’t open that folder",{description:`DorkOS couldn’t read ${I}. The conversation may not open.`})})}},[b,o,a]),k=d.length>0,j=!k&&!u&&!h&&f.trim().length>0&&p===null,C=!k&&!u&&f.trim().length>0&&p===null;return n.jsx(et,{open:e,onOpenChange:s,children:n.jsxs(tt,{"data-testid":"message-search-dialog",className:z("!min-h-0 max-w-[560px] overflow-hidden p-0","[&>button:last-child]:top-2 [&>button:last-child]:right-2.5",r&&"h-[85vh]"),children:[n.jsx(ze,{className:"sr-only",children:"Search your messages"}),n.jsx(G.div,{variants:Xd,initial:"hidden",animate:"visible",exit:"exit",className:z("flex overflow-hidden",r&&"h-full flex-col"),children:n.jsxs(el,{loop:!0,shouldFilter:!1,className:z("min-w-0 flex-1",r&&"flex flex-col [&_[cmdk-list]]:max-h-none [&_[cmdk-list]]:flex-1 [&_[cmdk-list]]:overflow-y-auto"),children:[n.jsx(tl,{"data-testid":"message-search-input",placeholder:oN,value:i,onValueChange:c}),p!==null&&n.jsxs("p",{className:"text-destructive flex items-start gap-2 px-3 py-3 text-xs leading-relaxed",children:[n.jsx(sp,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:p.message})]}),m.map(v=>n.jsxs("p",{role:"status",className:"text-muted-foreground text-2xs flex items-start gap-2 px-3 pt-2 leading-relaxed",children:[n.jsx(Hi,{className:"mt-0.5 size-3 shrink-0","aria-hidden":"true"}),n.jsx("span",{children:v.message})]},v.source)),n.jsx(nl,{children:n.jsx(dn,{className:"h-full",children:k&&n.jsx(Be,{className:z("transition-opacity duration-150",h&&"opacity-60"),children:d.map(v=>{const N=`${v.source}:${v.container}:${v.ordinal}`,I=XC(v);return n.jsx(eN,{value:N,hit:v,containerLabel:JC(v,x),openable:I.kind!=="unopenable",onSelect:()=>y(v,I)},N)})})})}),p===null&&n.jsxs("div",{className:"max-h-[45vh] min-h-0 shrink-0 overflow-y-auto",children:[u&&n.jsx("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:rN}),j&&n.jsxs("p",{className:"text-muted-foreground px-3 pt-3 text-xs",children:["No messages match “",f.trim(),"”."]}),n.jsx(aN,{detailOpen:C})]}),n.jsxs("div",{className:"text-muted-foreground flex flex-shrink-0 items-center gap-3 border-t px-3 py-1.5 text-xs",children:[n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:ir,children:"↑↓"}),"Navigate"]}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("kbd",{className:ir,children:"Enter"}),"Open"]}),n.jsxs("span",{className:"ml-auto inline-flex items-center gap-1",children:[n.jsx("kbd",{className:ir,children:"esc"}),"Close"]})]})]})})]})})}function hN(e){return`set${e.charAt(0).toUpperCase()}${e.slice(1)}`}function fN(e){const t=qe(),s=so(),r=fo();switch(e){case"settings":return{isOpen:t.isOpen,close:t.close};case"tasks":return{isOpen:s.isOpen,close:s.close};case"profile":return{isOpen:r.isOpen,close:r.close};default:return{isOpen:!1,close:()=>{}}}}function pN({contribution:e,openStateKey:t}){const s=B(u=>u[t]),r=B(u=>u[hN(t)]),o=fN(e.urlParam),a=o.isOpen,i=o.close,c=s||a,d=l.useCallback(u=>{r(u),!u&&a&&i()},[r,a,i]),m=e.component;return n.jsx(m,{open:c,onOpenChange:d})}function gN({contribution:e,openState:t}){const s=l.useSyncExternalStore(t.subscribe,t.getSnapshot),r=e.component;return s?n.jsx(rp,{fallback:null,onError:o=>{console.error(`[extensions] Dialog ${e.id} crashed and was closed:`,o),t.set(!1)},children:n.jsx(r,{open:!0,onOpenChange:t.set})}):null}function xN({contribution:e}){return e.openState?n.jsx(gN,{contribution:e,openState:e.openState}):n.jsx(pN,{contribution:e,openStateKey:e.openStateKey})}function yN(){const e=Cs("dialog");return n.jsx(n.Fragment,{children:e.map(t=>n.jsx(xN,{contribution:t},t.id))})}const bN=["session","id","thread","entry","itemId","agent","profile","continuedFrom","pkg","view","region","detail","panel"];function vN(e,t){if(e.length>=Fs)return e.slice(0,Fs);const s=new URLSearchParams(t);let r="";for(const o of bN)for(const a of s.getAll(o)){const i=new URLSearchParams([[o,a]]).toString(),c=r?`${r}&${i}`:i;e.length+1+c.length<=Fs&&(r=c)}return r?`${e}?${r}`:e}const wN=6e4,jN={bug:"when it’s fixed",idea:"when it ships",feedback:"when the team acts on it"};function kN(e,t){var s;return JSON.stringify([e.kind,t,e.screenshotDataUrl??null,((s=e.element)==null?void 0:s.selector)??null])}function pi(e,t,s,r){const o=Nl("bug",e,t),a=[...cp()];r&&a.push({at:new Date().toISOString(),kind:"console_error",message:ap(r).slice(0,ip)});const i=a.slice(-lp);return{clientReport:{version:o.version,platform:o.platform,runtimes:o.runtimes,flags:Object.fromEntries(Object.entries(o.flags).map(([c,d])=>[c,typeof d=="number"?String(d):d])),...lb(s)},...i.length>0?{breadcrumbs:i}:{}}}function SN(){const e=ie(),t=Ae({select:f=>f.location.pathname}),s=Ae({select:f=>f.location.searchStr}),r=op(),o=vN(t,s),a=Ae({select:f=>{const g=f.location.search;return typeof(g==null?void 0:g.session)=="string"?g.session:void 0}}),{data:i}=be({queryKey:De.current(),queryFn:()=>e.getConfig(),staleTime:300*1e3}),[c,d]=l.useState(!1),m=Ie(),u=l.useRef(null),h=l.useCallback(f=>i?pi(i,t,r,f==null?void 0:f.crashStack):void 0,[i,t,r]),p=l.useCallback(async f=>{var v;const g=f.message.trim();if(!g)return!1;const x=(v=f.contact)==null?void 0:v.trim(),b=kN(f,g),y=u.current;if(y&&y.fingerprint===b&&Date.now()-y.at<wN)return ae.info("Already sent a moment ago."),!0;const k=f.includeDiagnostics?pi(i,t,r,f.crashStack):void 0,j=f.includeDiagnostics&&f.kind==="bug",C=!!(f.includeConversation&&a);d(!0);try{const N=k&&j?await Jy():void 0,{ok:I}=await e.sendFeedback({kind:f.kind,message:g,...x?{contact:x}:{},...o?{route:o}:{},...k?{diagnostics:{...k,...N?{shellLogExcerpt:N}:{}}}:{},...j?{includeServerLogs:!0}:{},...C?{sessionId:a,includeTranscript:!0}:{},...f.screenshotDataUrl?{screenshot:{dataUrl:f.screenshotDataUrl}}:{},...f.anonymous?{anonymous:!0}:{},...f.element?{element:f.element}:{}});return I?(u.current={fingerprint:b,at:Date.now()},ae.success("Sent. Thank you.",{...f.notifyEmail?{description:`DorkOS emails ${f.notifyEmail} ${jN[f.kind]}.`}:{},action:{label:"Your reports",onClick:()=>m(pe.feedbackRequests())}})):ae.error("Couldn’t send. Your words are still here. Try again or open a GitHub issue."),I}finally{d(!1)}},[e,t,o,a,i,r,m]);return{isSubmitting:c,sessionId:a,route:o,buildDiagnostics:h,send:p}}const CN=24;function gi(e,t){const s=Math.max(e.left,t.left),r=Math.max(e.top,t.top),o=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height);return o<=s||a<=r?null:{left:s,top:r,width:o-s,height:a-r}}function NN(e){const{element:t,viewport:s,region:r,image:o}=e,a=e.padding??CN;if(o.width<=0||o.height<=0)return null;const i={left:t.left-a,top:t.top-a,width:t.width+a*2,height:t.height+a*2},c=gi(i,{left:0,top:0,width:s.width,height:s.height});if(!c)return null;const d=gi(c,r);if(!d)return null;const m=o.width/r.width,u=o.height/r.height,h=Math.round((d.left-r.left)*m),p=Math.round((d.top-r.top)*u),f=Math.round((d.left+d.width-r.left)*m),g=Math.round((d.top+d.height-r.top)*u),x=Math.min(Math.max(0,h),Math.max(0,o.width-1)),b=Math.min(Math.max(0,p),Math.max(0,o.height-1));return{sx:x,sy:b,sw:Math.max(1,f-x),sh:Math.max(1,g-b)}}function AN(e){return new Promise((t,s)=>{const r=new Image,o=i=>{clearTimeout(a),s(new Ue("failed",i))},a=setTimeout(()=>o(`The capture did not decode within ${is}ms.`),is);r.onload=()=>{clearTimeout(a),t(r)},r.onerror=()=>o("The capture did not decode, so it cannot be cropped."),r.src=e})}function EN(e,t){const s=document.createElement("canvas");s.width=t.sw,s.height=t.sh;const r=s.getContext("2d");if(!r)throw new Ue("failed","This browser gave no 2d canvas context to crop with.");return r.drawImage(e,t.sx,t.sy,t.sw,t.sh,0,0,t.sw,t.sh),s.toDataURL("image/png")}async function IN(e,t){const s=t.getBoundingClientRect();if(s.width===0&&s.height===0)throw new Ue("failed","That element has no size to crop to.");if(!Wl().contains(t))throw new Ue("failed","That element is not part of the app that was captured.");const r=await AN(e.dataUrl),o=NN({element:{left:s.left,top:s.top,width:s.width,height:s.height},viewport:{width:window.innerWidth,height:window.innerHeight},region:e.region,image:{width:r.naturalWidth||r.width,height:r.naturalHeight||r.height}});if(!o)throw new Ue("failed","That element is no longer inside the captured picture.");return Ar(EN(r,o))}const xi={"too-large":"That image is too big to send. Crop it to the part that matters.",unreadable:"Couldn’t read that image. Try a PNG or JPEG.",unsupported:"This browser can’t prepare images to send."},TN={failed:"Couldn’t capture the app view. You can still add a screenshot yourself.",unsupported:"Couldn’t start the app capture. Reload, or add a screenshot yourself."};function RN(e){return e instanceof Ue?TN[e.reason]:e instanceof St?xi[e.reason]:xi.unreadable}const cr="Only images can be attached.",DN="Files";function rn(e){return e?Array.from(e.types).includes(DN):!1}function yi(e){return e.find(t=>t.type.startsWith("image/"))}function ON(e={}){const{enabled:t=!1}=e,[s,r]=l.useState(null),[o,a]=l.useState(!1),[i,c]=l.useState(!1),d=l.useRef(0),m=l.useRef(0),u=l.useCallback(async v=>{const N=++m.current;a(!0);try{const I=await v();return N!==m.current?null:(r(I),I)}catch(I){return N!==m.current||ae.error(RN(I)),null}finally{N===m.current&&a(!1)}},[]),h=l.useCallback(async v=>{if(!v.type.startsWith("image/")){ae.error(cr);return}await u(()=>Ar(v))},[u]),p=l.useCallback(async()=>{await u(async()=>Ar(await ab()))},[u]),f=l.useCallback(v=>u(async()=>IN(await Gl(),v)),[u]),g=l.useCallback(()=>{m.current+=1,r(null),a(!1)},[]),x=l.useCallback(v=>{m.current+=1,d.current=0,v!==void 0&&!gb(v)?(console.warn("[feedback] Ignoring an initial screenshot that is not a bounded image data URL."),r(null)):r(v??null),a(!1),c(!1)},[]);l.useEffect(()=>{if(!t)return;const v=N=>{rn(N.dataTransfer)&&N.preventDefault()};return window.addEventListener("dragover",v),window.addEventListener("drop",v),()=>{window.removeEventListener("dragover",v),window.removeEventListener("drop",v)}},[t]);const b=l.useCallback(v=>{var D;const N=Array.from(((D=v.clipboardData)==null?void 0:D.items)??[]).map(T=>T.getAsFile()).filter(T=>T!==null);if(N.length===0)return;const I=yi(N);if(!I){ae.error(cr);return}v.preventDefault(),h(I)},[h]),y=l.useCallback(v=>{rn(v.dataTransfer)&&(v.preventDefault(),d.current+=1,c(!0))},[]),k=l.useCallback(v=>{rn(v.dataTransfer)&&(v.preventDefault(),v.dataTransfer.dropEffect="copy")},[]),j=l.useCallback(v=>{rn(v.dataTransfer)&&(d.current=Math.max(0,d.current-1),d.current===0&&c(!1))},[]),C=l.useCallback(v=>{if(!rn(v.dataTransfer))return;v.preventDefault(),d.current=0,c(!1);const N=yi(Array.from(v.dataTransfer.files));if(!N){ae.error(cr);return}h(N)},[h]);return{dataUrl:s,isPreparing:o,isDraggingOver:i,attach:h,capture:p,captureElement:f,clear:g,reset:x,handlers:{onPaste:b,onDragEnter:y,onDragOver:k,onDragLeave:j,onDrop:C}}}const bi=mp,MN="root";function pu(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["'\\[\]]/g,t=>`\\${t}`)}function vi(e,t){try{const s=t.ownerDocument.querySelectorAll(e);return s.length===1&&s[0]===t}catch{return!1}}function gu(e){return e.id?`#${pu(e.id)}`:null}function Kr(e,t){const s=e.getAttribute(t);return s?`[${t}="${pu(s)}"]`:null}function _N(e){const t=e.tagName;let s=1,r=e.previousElementSibling;for(;r;)r.tagName===t&&(s+=1),r=r.previousElementSibling;return s}function PN(e){const t=e.tagName.toLowerCase(),s=gu(e);if(s)return s;const r=Kr(e,"data-testid")??Kr(e,"data-slot"),o=`:nth-of-type(${_N(e)})`;if(!r)return`${t}${o}`;const a=`${t}${r}`;return(e.parentElement?Array.from(e.parentElement.children).filter(c=>c.matches(a)):[e]).length===1?a:`${a}${o}`}function LN(e){for(const r of[gu(e),Kr(e,"data-testid")])if(r&&r.length<=bi&&vi(r,e))return r;const t=[];let s=e;for(;s&&s.id!==MN&&s.tagName!=="BODY";){t.unshift(PN(s));const r=t.join(" > ");if(r.length>bi){t.shift();break}if(vi(r,e))return r;s=s.parentElement}return t.join(" > ")||e.tagName.toLowerCase()}function wi(e,t){var r;const s=(r=e.closest(`[${t}]`))==null?void 0:r.getAttribute(t);if(!(!s||s.length>dp))return s}function FN(e){const t=wi(e,"data-slot"),s=wi(e,"data-testid"),r=xu(e);return{selector:LN(e),...t?{slot:t}:{},...s?{testId:s}:{},...r?{label:r}:{}}}const lr=40,$N=["button","a[href]","summary","input","select","textarea",'[role="button"]','[role="link"]','[role="menuitem"]','[role="tab"]','[role="option"]','[role="checkbox"]','[role="switch"]'].join(", "),BN=new Set(["INPUT","SELECT","TEXTAREA"]),zN=['[contenteditable]:not([contenteditable="false"])','[role="textbox"]','[role="searchbox"]','[role="combobox"]'].join(", "),UN=["h1","h2","h3","h4","h5","h6",'[role="heading"]',"label","legend","th","dt"].join(", ");function KN(e){if(typeof Intl<"u"&&"Segmenter"in Intl){const t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e),s=>s.segment)}return Array.from(e)}function hn(e){const t=(e??"").replace(/\s+/g," ").trim();if(!t)return;const s=KN(t);if(s.length<=lr)return t;const r=s.slice(0,lr-1),o=r.lastIndexOf(" ");return`${(o>lr/2?r.slice(0,o):r).join("").trimEnd()}…`}function HN(e){var r;const s=(((r=e.getAttribute("aria-labelledby"))==null?void 0:r.split(/\s+/).filter(Boolean))??[]).map(o=>{var a;return((a=e.ownerDocument.getElementById(o))==null?void 0:a.textContent)??""}).join(" ");return hn(s)}function Qn(e){return hn(e.getAttribute("aria-label"))??HN(e)}function xu(e){const t=qN(e);return t&&t.length<=up?t:void 0}function qN(e){var a,i;const t=e.closest(zN);if(t)return Qn(t);const s=e.closest($N);if(s){if(BN.has(s.tagName)){const c=s;return Qn(s)??hn((i=(a=c.labels)==null?void 0:a[0])==null?void 0:i.textContent)}return Qn(s)??hn(s.textContent)}const r=Qn(e);if(r)return r;const o=e.closest(UN);return o?hn(o.textContent):void 0}function ji(e){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[-_\s]+/).filter(Boolean).map(r=>r.toLowerCase());if(t.length===0)return null;const s=t.join(" ");return s.charAt(0).toUpperCase()+s.slice(1)}function WN(e){var c;const t=xu(e);if(t)return{text:t,onScreen:!0};const s=e.getAttribute("data-testid")??e.getAttribute("data-slot"),r=s?ji(s):null;if(r)return{text:r,onScreen:!1};const o=(c=e.parentElement)==null?void 0:c.closest("[data-testid], [data-slot]"),a=(o==null?void 0:o.getAttribute("data-testid"))??(o==null?void 0:o.getAttribute("data-slot")),i=a?ji(a):null;return i?{text:i,onScreen:!1}:null}const GN="This part";function yu(e){return(e==null?void 0:e.text)??GN}function YN(e){return e?e.onScreen?`What’s wrong with “${e.text}”?`:`What’s wrong with the ${e.text.toLowerCase()}?`:"What’s wrong with this part?"}function VN(e){return e!=null&&e.onScreen?`Remove “${e.text}”`:`Remove ${yu(e).toLowerCase()}`}const ki=500;function Si(e){const t=e.trim();return t.length>ki?`${t.slice(0,ki)}… [trimmed]`:t}function QN(e){const t=[`${e.role}: ${e.content.trim()}`.trim()];for(const s of e.toolCalls??[])t.push(` [tool: ${s.toolName}]`),s.input&&t.push(` input: ${Si(s.input)}`),s.result&&t.push(` result: ${Si(s.result)}`);return t.join(`
|
|
87
|
-
`)}function XN(e){const t=e.slice(-20),s=hp(fp(t.map(QN).join(`
|
|
88
|
-
|
|
89
|
-
`))).trim();return s.length>oa?`${s.slice(0,oa-1)}…`:s}function JN(e,t){const s=ie(),[r]=On(),{data:o,isLoading:a,isError:i}=be({queryKey:["feedback-transcript-preview",e,r],queryFn:async()=>{const{messages:c}=await s.getMessages(e,r??void 0);return XN(c)},enabled:t&&!!e,staleTime:30*1e3});return{text:o??"",isLoading:a,isError:i}}function ZN(){return n.jsx("div",{"data-slot":"feedback-preview-footer",className:"bg-background relative -mx-4 -mb-4 shrink-0 border-t px-4 py-3 sm:mx-0 sm:px-0",children:n.jsxs("p",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[n.jsx(ol,{className:"size-3 shrink-0","aria-hidden":!0}),"Private. Only the DorkOS core team sees these. Never public."]})})}function $e({label:e,value:t}){return n.jsxs("div",{className:"flex items-baseline justify-between gap-4 py-1",children:[n.jsx("span",{className:"text-muted-foreground shrink-0 text-xs",children:e}),n.jsx("span",{className:"text-foreground text-right font-mono text-xs break-all",children:t})]})}function eA({diagnostics:e,kind:t,route:s}){if(!e)return n.jsx("p",{className:"text-muted-foreground text-xs",children:"Gathering diagnostics…"});const{clientReport:r,breadcrumbs:o}=e,{viewport:a,browser:i,shell:c,theme:d,locale:m,timezone:u}=r;return n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsxs("div",{className:"rounded-md border p-3",children:[n.jsx($e,{label:"Page",value:s}),n.jsx($e,{label:"Version",value:r.version}),n.jsx($e,{label:"Platform",value:r.platform}),n.jsx($e,{label:"Runtimes",value:r.runtimes.length?r.runtimes.join(", "):"none"}),a&&n.jsx($e,{label:"Window",value:`${a.width}×${a.height}${a.devicePixelRatio&&a.devicePixelRatio!==1?` @${a.devicePixelRatio}x`:""}`}),c&&n.jsx($e,{label:"Shell",value:c}),d&&n.jsx($e,{label:"Theme",value:d}),m&&n.jsx($e,{label:"Locale",value:m}),u&&n.jsx($e,{label:"Timezone",value:u}),i&&n.jsx($e,{label:"Browser",value:i}),Object.entries(r.flags).map(([h,p])=>n.jsx($e,{label:h,value:String(p)},h))]}),n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("span",{className:"text-muted-foreground text-xs font-medium",children:["Recent events (",(o==null?void 0:o.length)??0,")"]}),o&&o.length>0?n.jsx("ul",{className:"flex flex-col gap-1",children:o.map((h,p)=>n.jsxs("li",{className:"text-foreground font-mono text-xs break-all",children:[n.jsx("span",{className:"text-muted-foreground",children:h.kind})," ",h.message]},p))}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No recent errors or warnings."})]}),t==="bug"&&n.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[n.jsx("p",{children:Pe()?"Recent server and app log excerpts are added when you send.":"An excerpt of recent server logs is added when you send."}),n.jsx("p",{children:"Scrubbed first: home paths shown as ~, tokens removed, web addresses cut to the page."})]})]})}function tA({sessionId:e,active:t}){const{text:s,isLoading:r,isError:o}=JN(e,t);return r?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(yt,{className:"h-4 w-3/4"}),n.jsx(yt,{className:"h-4 w-full"}),n.jsx(yt,{className:"h-4 w-2/3"})]}):o?n.jsx("p",{className:"text-muted-foreground text-xs",children:"Couldn’t load the conversation preview."}):s?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"text-muted-foreground space-y-1 text-xs",children:[n.jsx("p",{children:"The last ~10 turns, gathered and scrubbed when you send."}),n.jsx("p",{children:"Home paths shown as ~, tokens removed, long tool output trimmed."})]}),n.jsx("pre",{className:"text-foreground bg-muted/40 rounded-md p-3 font-mono text-xs break-words whitespace-pre-wrap",children:s})]}):n.jsx("p",{className:"text-muted-foreground text-xs",children:"No recent conversation to attach."})}function nA({dataUrl:e}){return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("p",{className:"text-muted-foreground text-xs",children:"Sent exactly as shown, shrunk to keep the message small."}),n.jsx("img",{src:e,alt:"The screenshot you attached",className:"bg-muted/30 w-full rounded-md border object-contain"})]})}function sA({open:e,onOpenChange:t,initialTab:s,diagnostics:r,kind:o,route:a,showConversation:i,sessionId:c,screenshotDataUrl:d}){const m=!Ne(),u=["diagnostics",...i?["conversation"]:[],...d?["screenshot"]:[]],h=u.includes(s)?s:"diagnostics";return n.jsx(et,{open:e,onOpenChange:t,children:n.jsxs(tt,{className:z("max-h-[85vh]",m&&"max-w-lg"),children:[n.jsxs(Xe,{children:[n.jsx(ze,{className:"text-sm font-medium",children:"What will be sent"}),n.jsx(Je,{className:"text-muted-foreground text-xs",children:"Each part is sent only if its toggle is on."})]}),n.jsxs(xl,{defaultValue:h,className:"flex min-h-0 flex-col gap-3 px-4 pb-4 sm:px-0",children:[n.jsxs(yl,{className:z("grid shrink-0",u.length===3&&"grid-cols-3",u.length===2&&"grid-cols-2",u.length===1&&"grid-cols-1"),children:[n.jsx(Jn,{value:"diagnostics",children:"Diagnostics"}),i&&n.jsx(Jn,{value:"conversation",children:"Conversation"}),d&&n.jsx(Jn,{value:"screenshot",children:"Screenshot"})]}),n.jsx(zs,{value:"diagnostics",className:"min-h-0",children:n.jsx(dn,{className:"max-h-[45vh]",children:n.jsx(eA,{diagnostics:r,kind:o,route:a})})}),i&&n.jsx(zs,{value:"conversation",className:"min-h-0",children:n.jsx(dn,{className:"max-h-[45vh]",children:n.jsx(tA,{sessionId:c,active:e})})}),d&&n.jsx(zs,{value:"screenshot",className:"min-h-0",children:n.jsx(dn,{className:"max-h-[45vh]",children:n.jsx(nA,{dataUrl:d})})}),n.jsx(ZN,{})]},h)]})})}const rA="0 0 0 9999px rgb(0 0 0 / 0.5)";function oA(e){var r,o;const t=(r=e.closest("[data-slot]"))==null?void 0:r.getAttribute("data-slot");return((o=e.closest("[data-testid]"))==null?void 0:o.getAttribute("data-testid"))??t??e.tagName.toLowerCase()}function aA(e){let t=e;for(;t;){if(/^(auto|scroll|overlay)$/.test(getComputedStyle(t).overflowY)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function iA({phase:e,onSelect:t,onCancel:s}){const r=l.useRef(null),o=l.useRef(null),[a,i]=l.useState(null),c=e==="picking",d=l.useCallback((x,b)=>{const y=r.current;if(!y)return null;const k=y.style.pointerEvents;y.style.pointerEvents="none";try{return document.elementFromPoint(x,b)}finally{y.style.pointerEvents=k}},[]),m=l.useCallback(x=>{var b;return x instanceof Node&&!!((b=o.current)!=null&&b.contains(x))},[]),u=l.useCallback(x=>{if(!c)return;if(m(x.target)){i(null);return}const b=d(x.clientX,x.clientY);if(!b){i(null);return}const y=b.getBoundingClientRect();i({element:b,box:{left:y.left,top:y.top,width:y.width,height:y.height},label:oA(b)})},[c,d,m]),h=l.useCallback(x=>{if(!c||m(x.target))return;const b=d(x.clientX,x.clientY)??(a==null?void 0:a.element);b&&t(b)},[c,d,m,t,a]),p=l.useCallback(x=>{if(!c)return;const b=aA(d(x.clientX,x.clientY));b==null||b.scrollBy({left:x.deltaX,top:x.deltaY})},[c,d]);l.useEffect(()=>{if(!c)return;const x=b=>{b.preventDefault(),b.stopImmediatePropagation(),b.key==="Escape"&&s()};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[c,s]),l.useEffect(()=>{var b;const x=document.activeElement;return(b=r.current)==null||b.focus(),()=>{x instanceof HTMLElement&&x.focus()}},[]),l.useEffect(()=>{if(!c)return;const x=()=>{i(b=>{if(!b)return b;const y=b.element.getBoundingClientRect();return{...b,box:{left:y.left,top:y.top,width:y.width,height:y.height}}})};return window.addEventListener("scroll",x,!0),()=>window.removeEventListener("scroll",x,!0)},[c]);const f=c?a:null,g=f!==null&&f.box.top<28;return hs.createPortal(n.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":"Point at the part of the app that looks wrong",tabIndex:-1,className:z("fixed inset-0 z-50 focus:outline-none",c?"cursor-crosshair":"cursor-wait"),onPointerMove:u,onPointerLeave:()=>i(null),onClick:h,onWheel:p,onContextMenu:x=>{x.preventDefault(),c&&s()},children:[c&&(f?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"border-primary pointer-events-none absolute rounded-sm border-2",style:{left:f.box.left,top:f.box.top,width:f.box.width,height:f.box.height,boxShadow:rA}}),n.jsx("div",{className:"bg-primary text-primary-foreground pointer-events-none absolute max-w-[60vw] truncate rounded-sm px-1.5 py-0.5 font-mono text-[11px] leading-tight",style:{left:Math.max(4,f.box.left),top:g?f.box.top+f.box.height+4:f.box.top-22},children:f.label})]}):n.jsx("div",{className:"absolute inset-0 bg-black/50"})),c&&n.jsxs("div",{ref:o,className:"bg-popover text-popover-foreground absolute bottom-6 left-1/2 flex -translate-x-1/2 items-center gap-3 rounded-lg border px-3 py-2 shadow-lg",children:[n.jsxs("span",{className:"flex items-center gap-2 text-xs",children:[n.jsx(as,{className:"size-3.5 shrink-0","aria-hidden":!0}),"Click the part that looks wrong. Esc to cancel."]}),n.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring rounded-sm text-xs underline underline-offset-2 transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:"Cancel"})]})]}),document.body)}const Ci="text-muted-foreground hover:text-foreground h-8 px-2 text-xs aria-disabled:pointer-events-none aria-disabled:opacity-50";function dr({tip:e,children:t}){return n.jsxs(Bt,{children:[n.jsx(zt,{asChild:!0,children:t}),n.jsx(Ut,{className:"max-w-60 text-center",children:e})]})}function cA({showPictureTools:e,isPreparing:t,hasPointed:s,hasWords:r,isMobile:o,onCapture:a,onPointAtElement:i,onPick:c}){const d=l.useId(),m=l.useId(),u=l.useId(),h=l.useId();function p(k){var C;const j=(C=k.target.files)==null?void 0:C[0];k.target.value="",j&&c(j)}const f=r&&!o;if(!e&&!f)return null;const g=o?"Add a photo":"Add an image",x=o?"Add a photo from your library.":"Add an image from your files, or paste or drop one here.",b="Take a picture of this app. Never the rest of your screen.",y="Click the part that looks wrong. DorkOS crops the picture to it.";return n.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-t px-1.5 py-1.5",children:[e&&n.jsxs(n.Fragment,{children:[n.jsx("span",{id:m,className:"sr-only",children:b}),n.jsx(dr,{tip:b,children:n.jsxs(_,{"aria-describedby":m,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||a()},"aria-disabled":t||void 0,className:Ci,children:[n.jsx(_y,{className:"size-3.5","aria-hidden":!0}),"Capture app"]})}),!o&&n.jsx(dr,{tip:y,children:n.jsxs(_,{"aria-describedby":u,type:"button",variant:"ghost",size:"sm",onClick:()=>{t||i()},"aria-disabled":t||void 0,className:Ci,children:[n.jsx(as,{className:"size-3.5","aria-hidden":!0}),s?"Point again":"Point at it"]})}),!o&&n.jsx("span",{id:u,className:"sr-only",children:y}),n.jsx("span",{id:h,className:"sr-only",children:x}),n.jsx(dr,{tip:x,children:n.jsxs("label",{htmlFor:d,"aria-disabled":t||void 0,className:"text-muted-foreground hover:text-foreground hover:bg-accent focus-within:ring-ring flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors duration-150 focus-within:ring-2 aria-disabled:pointer-events-none aria-disabled:opacity-50",children:[n.jsx(pp,{className:"size-3.5","aria-hidden":!0}),n.jsx("input",{id:d,type:"file",accept:"image/*","aria-label":g,"aria-describedby":h,disabled:t,className:"sr-only",onChange:p})]})})]}),f&&n.jsxs("span",{className:"text-muted-foreground ml-auto pr-1.5 text-xs","aria-hidden":!0,children:[jt?"⌘↵":"Ctrl+↵"," to send"]})]})}function Ni({imageUrl:e,alt:t,caption:s,pointed:r=!1,detail:o,onOpen:a,onRemove:i,removeLabel:c}){const d=n.jsxs(n.Fragment,{children:[e?n.jsx("img",{src:e,alt:t,className:"size-full object-cover"}):n.jsx("span",{className:"text-muted-foreground flex size-full items-center justify-center",children:n.jsx(as,{className:"size-4","aria-hidden":!0})}),s&&n.jsxs("span",{className:"bg-background/85 absolute inset-x-0 bottom-0 flex items-center gap-1 truncate px-1.5 py-0.5 text-left text-[11px] leading-tight",children:[r&&n.jsx(as,{className:"size-3 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"truncate",children:s})]})]}),m=a?n.jsx("button",{type:"button",onClick:a,"aria-label":`Open ${t.charAt(0).toLowerCase()}${t.slice(1)}`,className:"focus-visible:ring-ring relative block size-full overflow-hidden rounded-[inherit] focus-visible:ring-2 focus-visible:outline-none",children:d}):n.jsx("div",{role:"img","aria-label":t,className:"relative size-full overflow-hidden rounded-[inherit]",children:d});return n.jsxs("div",{className:"bg-muted/40 relative h-16 w-28 shrink-0 rounded-md border",children:[o&&a?n.jsxs(Bt,{children:[n.jsx(zt,{asChild:!0,children:m}),n.jsx(Ut,{className:"max-w-72 font-mono text-[11px] break-all",children:o})]}):m,n.jsx("button",{type:"button",onClick:i,"aria-label":c,className:"bg-background/90 text-muted-foreground hover:text-foreground focus-visible:ring-ring absolute top-1 right-1 flex size-5 items-center justify-center rounded-full border transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:n.jsx(He,{className:"size-3","aria-hidden":!0})})]})}function Ai({label:e,summary:t,pressed:s,onPressedChange:r,onPreview:o}){return n.jsxs("span",{className:z("inline-flex items-center rounded-full border text-xs transition-colors duration-150",s?"bg-muted/60 text-foreground":"text-muted-foreground"),children:[n.jsxs(Bt,{children:[n.jsx(zt,{asChild:!0,children:n.jsxs("button",{type:"button","aria-pressed":s,onClick:()=>r(!s),className:"hover:text-foreground focus-visible:ring-ring flex items-center gap-1.5 rounded-full py-1 pr-1.5 pl-2.5 focus-visible:ring-2 focus-visible:outline-none",children:[n.jsx("span",{"aria-hidden":!0,className:z("size-1.5 rounded-full transition-colors duration-150",s?"bg-primary":"bg-muted-foreground/40")}),e]})}),n.jsx(Ut,{className:"max-w-60",children:t})]}),n.jsx("button",{type:"button",onClick:o,"aria-label":`Preview ${e.toLowerCase()}`,className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring flex items-center rounded-full py-1 pr-2.5 pl-1 focus-visible:ring-2 focus-visible:outline-none",children:n.jsx(gp,{className:"size-3.5","aria-hidden":!0})})]})}function lA({currentUser:e,anonymous:t,onToggleAnonymous:s,contact:r,onContactChange:o}){const a=l.useId(),i=l.useId();if(e)return n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1.5 text-xs",children:[t?n.jsx(qy,{className:"size-3.5 shrink-0","aria-hidden":!0}):n.jsx(xp,{className:"size-3.5 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:t?"Sending anonymously":`Replying to ${e.email}`}),n.jsx("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring shrink-0 rounded-sm underline underline-offset-2 transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:t?"Use my account":"Send anonymously"})]}),t&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"Without your name or email, the team can’t reply. Track it in Your reports."})]});const c=r.trim().length>0&&!al(r);return n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsx(_e,{htmlFor:a,className:"text-xs",children:"Your email"}),n.jsx(Ze,{id:a,type:"email",inputMode:"email",autoComplete:"email",value:r,onChange:d=>o(d.target.value),placeholder:"you@example.com",maxLength:yp,"aria-describedby":i,onKeyDown:d=>{d.key==="Enter"&&!d.metaKey&&!d.ctrlKey&&d.preventDefault()},"aria-invalid":c||void 0}),n.jsx("p",{id:i,className:"text-muted-foreground text-xs",children:c?"Not an email yet, so no reply can reach you.":"Get a note when it’s fixed. DorkOS remembers it."})]})}const dA=[{value:"feedback",label:"Feedback",icon:Kt},{value:"bug",label:"Bug",icon:bp},{value:"idea",label:"Idea",icon:cx}];function uA({kind:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"What kind of feedback",className:"flex gap-1.5",children:dA.map(({value:s,label:r,icon:o})=>{const a=e===s;return n.jsxs("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>t(s),className:z("focus-visible:ring-ring flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-medium transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",a?"border-foreground/60 text-foreground bg-muted/60":"text-muted-foreground hover:text-foreground"),children:[n.jsx(o,{className:"size-3.5","aria-hidden":!0}),r]},s)})})}function mA({needsWords:e,canSend:t,isSubmitting:s,onOpenGitHubIssue:r}){const o=l.useId();return n.jsxs(Dt,{className:"shrink-0 flex-col gap-2 sm:flex-col sm:justify-start sm:space-x-0",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[e?n.jsx("p",{id:o,"aria-live":"polite",className:"text-status-warning min-w-0 flex-1 text-xs",children:"Add a few words about what to look for."}):n.jsxs("p",{className:"text-muted-foreground flex min-w-0 flex-1 items-center gap-1.5 text-xs",children:[n.jsx(ol,{className:"size-3 shrink-0","aria-hidden":!0}),"Only the DorkOS team sees this"]}),n.jsx(_,{type:"submit",disabled:!t,"aria-keyshortcuts":"Meta+Enter Control+Enter","aria-describedby":e?o:void 0,className:"shrink-0",children:s?"Sending…":"Send"})]}),n.jsxs("p",{className:"text-muted-foreground text-center text-xs",children:["Prefer a public GitHub issue?"," ",n.jsx("button",{type:"button",onClick:r,className:"hover:text-foreground focus-visible:ring-ring rounded-sm underline underline-offset-2 transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-none",children:"Open one instead"})]})]})}const hA={feedback:"What works, what does not, what you wish it did…",bug:"What happened, and what did you expect instead?",idea:"What would you like DorkOS to do?"};function Ei(e,t,s){return{diagnostics:e==="bug"||s,conversation:e==="bug"&&t}}function fA({open:e,onOpenChange:t,initialKind:s,prefillMessage:r,crashStack:o,currentUser:a,initialScreenshotDataUrl:i}){const c=!Ne(),{isSubmitting:d,sessionId:m,route:u,buildDiagnostics:h,send:p}=SN(),f=Ay(),g=!!m,x=!!a,b=l.useId(),[y,k]=l.useState(s??"feedback"),[j,C]=l.useState(r??""),[v,N]=l.useState(aa),[I,D]=l.useState(!1),[T,E]=l.useState(!1),[w,A]=l.useState(!1),[S,M]=l.useState(!1),[R,O]=l.useState("diagnostics"),[P,F]=l.useState(null),[V,Z]=l.useState(null),[H,ee]=l.useState(null),[te,se]=l.useState(null),[L,q]=l.useState(0),K=l.useRef(L);l.useEffect(()=>{K.current=L},[L]);const[ne,W]=l.useState(!1),[le,ve]=l.useState(o),[we,We]=l.useState(m),Q=l.useRef(null),X=ON({enabled:e}),U=j.trim().length>0,de=U||X.dataUrl!==null||P!==null,[xe,ye]=l.useState(e);if(e!==xe&&(ye(e),e)){M(!1),se(null);const J=i;if(!!(r||o||J)||!de){const zn=s??"feedback",Un=Ei(zn,g,!!o);k(zn),C(r??""),N(aa()),D(!1),E(Un.diagnostics),A(Un.conversation),W(!1),F(null),Z(null),ve(o),We(m),X.reset(J),q(Ms=>Ms+1)}else m!==we&&(A(!1),We(m))}function Le(J){const Fe=Ei(J,g,!!le);E(Fe.diagnostics),A(Fe.conversation)}function At(J){k(J),Le(J)}function nt(J){O(J),M(!0)}async function Et(J){const Fe=K.current,zn=FN(J),Un=WN(J);V&&X.dataUrl===V&&X.clear(),Z(null),se("capturing");const Ms=await X.captureElement(J);Fe===K.current&&(se(null),F(zn),ee(Un),Z(Ms),k("bug"),ne||Le("bug"))}function Ln(){V&&X.dataUrl===V&&X.clear(),F(null),Z(null)}function Fn(){C(""),F(null),Z(null),W(!1),ve(void 0),X.clear()}const $n=U&&!d&&!X.isPreparing,Bn=x?I||a==null?void 0:a.email:al(v)?v.trim():void 0;async function Xt(){!$n||!await p({kind:y,message:j,...x?{}:{contact:v},includeDiagnostics:T,includeConversation:w,anonymous:I,...le?{crashStack:le}:{},...X.dataUrl?{screenshotDataUrl:X.dataUrl}:{},...P?{element:P}:{},...Bn?{notifyEmail:Bn}:{}})||(x||jp(v),Fn(),t(!1))}function Is(J){J.preventDefault(),Xt()}function Ts(J){const Fe=Q.current;Fe&&(J.preventDefault(),Fe.focus(),Fe.setSelectionRange(Fe.value.length,Fe.value.length))}function Rs(J){J.key!=="Enter"||!(J.metaKey||J.ctrlKey)||J.nativeEvent.isComposing||S||(J.preventDefault(),Xt())}const $=X.handlers,ge=te!==null,Ds=P?H:null,zo=yu(Ds),Os=!!(P&&V&&X.dataUrl===V),Uo=!!X.dataUrl&&!Os,Tu=!U&&(!!X.dataUrl||P!==null);return n.jsxs(n.Fragment,{children:[ge&&n.jsx(iA,{phase:te,onSelect:J=>void Et(J),onCancel:()=>se(null)}),n.jsx(et,{open:e&&!ge,onOpenChange:t,children:n.jsxs(tt,{...$,onKeyDown:Rs,desktopProps:{className:"max-w-md",onOpenAutoFocus:Ts},className:z("max-h-[85vh] !min-h-0",X.isDraggingOver&&"ring-primary ring-2"),children:[n.jsxs(Xe,{children:[n.jsx(ze,{className:"text-sm font-medium",children:"Send feedback"}),n.jsx(Je,{className:"text-muted-foreground text-xs",children:"Straight to the DorkOS team. Private."})]}),n.jsxs("form",{onSubmit:Is,noValidate:!0,className:"flex min-h-0 flex-1 flex-col gap-4",children:[n.jsxs(lt,{alignWithHeader:!0,className:"flex flex-col gap-4",children:[n.jsx(uA,{kind:y,onChange:At}),n.jsxs("div",{className:z("dark:bg-input/30 flex flex-col rounded-lg border transition-[border-color,box-shadow] duration-150","focus-within:border-ring focus-within:ring-ring focus-within:ring-[3px]",X.isDraggingOver&&"border-primary"),children:[n.jsx(_e,{htmlFor:b,className:"sr-only",children:"Your message"}),n.jsx(vp,{ref:Q,id:b,value:j,onChange:J=>C(J.target.value),placeholder:P?YN(Ds):hA[y],rows:4,maxLength:wp,className:"min-h-24 resize-none rounded-lg border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent"}),(P||Uo||X.isPreparing||X.isDraggingOver)&&n.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-2.5 pb-2.5",children:[P&&n.jsx(Ni,{imageUrl:Os?V??void 0:void 0,alt:`The part you pointed at: ${zo}`,caption:zo,pointed:!0,detail:P.selector,...Os?{onOpen:()=>nt("screenshot")}:{},onRemove:Ln,removeLabel:VN(Ds)}),Uo&&X.dataUrl&&n.jsx(Ni,{imageUrl:X.dataUrl,alt:"The screenshot you attached",onOpen:()=>nt("screenshot"),onRemove:X.clear,removeLabel:"Remove screenshot"}),(X.isPreparing||X.isDraggingOver)&&n.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground text-xs",children:X.isDraggingOver?"Drop to attach":"Getting it ready…"})]}),n.jsx(cA,{showPictureTools:!0,isPreparing:X.isPreparing,hasPointed:P!==null,hasWords:U,isMobile:!c,onCapture:()=>void X.capture(),onPointAtElement:()=>se("picking"),onPick:J=>void X.attach(J)})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n.jsx("span",{className:"text-muted-foreground mr-0.5 text-xs",children:"Also send"}),n.jsx(Ai,{label:"Diagnostics",summary:"Version, window size, browser, and recent errors.",pressed:T,onPressedChange:J=>{W(!0),E(J)},onPreview:()=>nt("diagnostics")}),g&&n.jsx(Ai,{label:"This conversation",summary:"Shows what led to the bug.",pressed:w,onPressedChange:J=>{W(!0),A(J)},onPreview:()=>nt("conversation")})]}),n.jsx(lA,{currentUser:a??null,anonymous:I,onToggleAnonymous:()=>D(J=>!J),contact:v,onContactChange:N})]}),n.jsx(mA,{needsWords:Tu,canSend:$n,isSubmitting:d,onOpenGitHubIssue:()=>f(y==="idea"?"feature":"bug")})]}),n.jsx(sA,{open:S,onOpenChange:M,initialTab:R,diagnostics:h(le?{crashStack:le}:void 0),kind:y,route:u,showConversation:g,sessionId:m,...X.dataUrl?{screenshotDataUrl:X.dataUrl}:{}})]})})]})}function pA(){const e=an(a=>a.open),t=an(a=>a.prefill),s=an(a=>a.openFeedback),r=an(a=>a.setOpen),o=kp();return l.useEffect(()=>{const a=Sp();a&&s(a)},[s]),n.jsx(fA,{open:e,onOpenChange:r,initialKind:t.kind,prefillMessage:t.message,crashStack:t.crashStack,currentUser:o?{email:o.email,name:o.name}:null})}const gA=new Set(["permission-prompt","question","schedule-approval"]),xA={"permission-prompt":"Needs your approval to go on.",question:"Has a question for you.","schedule-approval":"Wants to run on a timer."};function bu(e){const t=qc(),s=Cp(),r=ln(e),o=l.useRef(null);l.useEffect(()=>{var m,u,h,p;if(s)return;const a=new Map;for(const f of t)gA.has(f.kind)&&a.set(f.id,{id:f.id,who:f.primary,summary:xA[f.kind],deepLink:f.deepLink});const i=o.current;if(o.current=new Set(a.keys()),i===null)return;const c=[...a.values()].filter(f=>!i.has(f.id)),d=[...i].filter(f=>!a.has(f));c.length>0&&((u=(m=r.read()).onArrive)==null||u.call(m,c)),d.length>0&&((p=(h=r.read()).onDepart)==null||p.call(h,d,a.size))},[s,t,r])}function yA(){const{permission:e}=Np(),{prefs:t}=Ap(),s=go(),r=Pe(),o=l.useRef(new Map),a=ln(s),i=l.useCallback(()=>r||e!=="granted"||typeof document>"u"||!document.hidden?!1:typeof window<"u"&&typeof window.Notification<"u",[r,e]),c=l.useCallback((h,p,f,g)=>{let x;try{x=new Notification(p,{body:f,tag:h,silent:!0})}catch{return}x.onclick=()=>{var b;window.focus(),x.close(),o.current.delete(h),g!==null&&((b=a.read())==null||b({href:g}))},x.onclose=()=>{o.current.delete(h)},o.current.set(h,{notification:x,href:g})},[a]),d=l.useCallback(h=>{if(i())for(const p of h)c(p.id,`${p.who} needs you`,p.summary,p.deepLink)},[i,c]),m=l.useCallback(h=>{for(const p of h){const f=o.current.get(p);f!==void 0&&(f.notification.close(),o.current.delete(p))}},[]);bu({onArrive:d,onDepart:m});const u=t.notifyOnTurnCompleteWhileAway;ue("notification",h=>{const p=Ep.safeParse(h);if(!p.success)return;const f=p.data.notification;if(f.tier!=="notable"||!u||!i())return;const g=Ip(f),x=g===null?null:bA(g.to,g.search);c(f.id,f.title,f.body??"",x)}),l.useEffect(()=>{const h=o.current;return()=>{for(const{notification:p}of h.values())p.close();h.clear()}},[])}function bA(e,t){const s=new URLSearchParams;for(const[o,a]of Object.entries(t))a!=null&&s.set(o,String(a));const r=s.toString();return r===""?e:`${e}?${r}`}function vA(){const{play:e}=kx(),t=l.useCallback(()=>{e("knock"),Sx()},[e]),s=l.useCallback((r,o)=>{o===0&&e("settle")},[e]);return bu({onArrive:t,onDepart:s}),yA(),null}function wA(){const e=Ie();l.useEffect(()=>{var s,r,o;if(!((s=window.electronAPI)!=null&&s.onNavigate))return;const t=window.electronAPI.onNavigate(a=>{e({href:a})});return(o=(r=window.electronAPI).getPendingNavigate)==null||o.call(r).then(a=>{a&&e({href:a})}),t},[e])}function jA(){const{closeActive:e}=No();l.useEffect(()=>{const t=window.electronAPI;if(t!=null&&t.onCloseTab)return t.onCloseTab(()=>e())},[e])}function kA(){const[e,t]=l.useState(!1);return l.useEffect(()=>{var a,i,c;if(!((a=window.electronAPI)!=null&&a.onFullscreenChange))return;let s=!0,r=!1;const o=window.electronAPI.onFullscreenChange(d=>{r=!0,t(d)});return(c=(i=window.electronAPI).getFullscreenState)==null||c.call(i).then(d=>{s&&!r&&t(d)}),()=>{s=!1,o()}},[]),e}const Ii="window-blurred";function SA(){l.useEffect(()=>{var a,i,c;if(!Tp||!((a=window.electronAPI)!=null&&a.onFocusChange))return;const e=document.documentElement,t=d=>{e.classList.toggle(Ii,!d)};let s=!0,r=!1;const o=window.electronAPI.onFocusChange(d=>{r=!0,t(d)});return(c=(i=window.electronAPI).getFocusState)==null||c.call(i).then(d=>{s&&!r&&t(d)}),()=>{s=!1,o(),e.classList.remove(Ii)}},[])}const CA="/channels";function NA(){var h,p;rv();const e=Rp(),t=ys(),s=e===CA?t.id??null:null,{data:r}=pc(t.community?null:s),a=(h=qt(!!t.community).data)==null?void 0:h.find(f=>f.ref===t.community),i=eo(a==null?void 0:a.access),c=gc(t.community??"",s??"",!!(t.community&&s&&i.capabilities.read),i.fingerprint),{data:d}=Ns(),m=l.useMemo(()=>(d??[]).filter(_t).length,[d]),u=!t.community&&s&&r?r:null;return{room:u,roomTitle:t.community&&s?((p=c.data)==null?void 0:p.title)??null:u?to(u):null,unreadRoomCount:m}}function AA(){const e=jn(),t=qt(),s=ce(),r=Ie(),o=l.useRef(null);l.useEffect(()=>{var d;if(!e||!t.data)return;const a=JSON.stringify([e.ownerKey,e.epoch]),i=((d=o.current)==null?void 0:d.owner)===a?o.current.rows:null,c=new Map(t.data.map(m=>[m.ref,{status:m.status,label:m.label,generation:ia(m.ref)}]));if(o.current={owner:a,rows:c},!!i)for(const[m,u]of i){if(u.status!=="connected")continue;const h=c.get(m);if((h==null?void 0:h.status)==="connected")continue;const p=os(bn().destination)===m,f=ia(m)>u.generation,g=h===void 0?"removed":"revoked";(f?Promise.resolve():Dp(s,e,m,g)).then(()=>{p&&os(bn().destination)===m&&r({...pe.home(),replace:!0})}),g==="revoked"&&ae(`This DorkOS can no longer reach ${u.label}.`,{description:"Still a member? Pick it in the sidebar switcher to reconnect."})}},[e,t.data,r,s])}function EA(){AA(),Sb(),Op()}function IA({isFullscreen:e}){return n.jsx("div",{className:z("desktop-darwin:block app-drag-region hidden shrink-0",!e&&"desktop-darwin:h-11"),"aria-hidden":"true"})}class TA extends l.Component{constructor(){super(...arguments);Jt(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(s,r){console.error("[Sidebar] Body contribution error:",s,r)}componentDidUpdate(s){s.contributionId!==this.props.contributionId&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?n.jsx("div",{"data-testid":"sidebar-body-error",className:"flex h-full items-center justify-center p-4",children:n.jsx("p",{className:"text-muted-foreground text-center text-sm",children:"This panel couldn’t load. Reload the page."})}):this.props.children}}const RA=5e3;function vu({testId:e,headline:t,detail:s}){const{isFetching:r,refetch:o}=Oe({refetchInterval:RA});return n.jsx("div",{"data-testid":e,className:"bg-background text-foreground flex h-dvh flex-col items-center justify-center px-6",children:n.jsxs("div",{className:"flex w-full max-w-md flex-col items-center text-center",children:[n.jsx(Ve,{size:120,className:"mb-8 opacity-80 dark:hidden"}),n.jsx(Ve,{variant:"white",size:120,className:"mb-8 hidden opacity-80 dark:block"}),n.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:t}),n.jsx("p",{className:"text-muted-foreground mt-3 text-sm",children:s}),n.jsx(_,{variant:"outline",className:"mt-6",onClick:()=>void o(),disabled:r,children:r?"Trying…":"Try again"})]})})}function DA(){return n.jsx(vu,{testId:"server-unreachable",headline:"DorkOS can’t reach its server",detail:"It may still be starting up. DorkOS keeps checking."})}const OA="HOST_NOT_ALLOWED",Ti=240;function MA({status:e,message:t,code:s}){const r=s===OA&&t?t:void 0,o=r===void 0?`Your settings didn’t load (HTTP ${e}). DorkOS keeps trying.`:r.length>Ti?`${r.slice(0,Ti).trimEnd()}…`:r;return n.jsx(vu,{testId:"server-error",headline:"The server answered with an error",detail:o})}function _A(e){const t=e;return{...typeof(t==null?void 0:t.status)=="number"?{status:t.status}:{},...typeof(t==null?void 0:t.message)=="string"&&t.message.length>0?{message:t.message}:{},...typeof(t==null?void 0:t.code)=="string"&&t.code.length>0?{code:t.code}:{}}}let ur={at:0};function PA(e,t){return e>ur.at&&(ur=t==null?{at:e}:{at:e,..._A(t)}),e>Pt?ur:void 0}function LA(e){return e.state.dataUpdatedAt>Pt?!0:"always"}const wu=["unattended-autonomy"],FA=6e4;function ju(){const e=ie(),{data:t}=be({queryKey:[...wu],queryFn:()=>e.getUnattendedAutonomy(),staleTime:FA});return t}function $A(){const e=ce(),t=()=>{e.invalidateQueries({queryKey:[...wu]})};ue("relay_bindings_changed",t),ue("tasks_changed",t),ue("relay_adapters_changed",t)}function BA(e){return!e}function zA(e){var t;return((t=e.at(-1))==null?void 0:t.pathname)??""}function UA({descriptors:e}){const t=e.reduce((s,r)=>s===null||r.priority>s.priority?r:s,null);return n.jsx(Ee,{mode:"wait",initial:!1,children:t&&n.jsx(G.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:[0,0,.2,1]},className:"shrink-0 overflow-hidden",children:t.render()},t.id)})}const KA=["memory-provider-status"],HA=6e4;function qA(){const e=ie(),{data:t}=be({queryKey:[...KA],queryFn:()=>e.getMemoryProviderStatus(),staleTime:HA});return t}function WA(e){const t=new Map;for(const s of e){if(s.kind!=="signin.required")continue;const r=t.get(s.subject.id);(r===void 0||GA(s,r))&&t.set(s.subject.id,s)}return[...t.entries()].filter(([,s])=>s.outcome!=="cleared").map(([s])=>s)}function GA(e,t){return e.createdAt!==t.createdAt?e.createdAt>t.createdAt:e.id>t.id}function YA({configuredId:e,benched:t}){return n.jsxs(bo,{variant:"warning",children:["The ",n.jsx("span",{className:"font-medium",children:e})," memory"," ",t?"stopped answering":"isn’t set up",". DorkOS uses its own memory until you restart."]})}const VA="runtimes",QA=3;function XA({runtimes:e}){const{open:t}=qe(),s=Mp();if(e.length===0)return null;const r=e.slice(0,QA).map(il),o=e.length-r.length,a=e.length===1?`${r[0]} sign-in`:`${ZA(r)} sign-ins`,i=o>0?`, and ${o} more`:"";return n.jsxs(bo,{variant:"critical",icon:Jc,actions:n.jsxs(n.Fragment,{children:[s&&n.jsx(JA,{runtimes:e,renderCreditsOffer:s}),n.jsx(_,{variant:"outline",size:"sm",onClick:()=>t(VA),children:"Sign in"})]}),children:["Your ",n.jsx("span",{className:"font-medium",children:a})," stopped working",i,". Agents and tasks wait until you sign in again."]})}function JA({runtimes:e,renderCreditsOffer:t}){var d;const s=Yr(),{data:r}=Xi(),o=!_p(),a=((d=Ac().data)==null?void 0:d.linked)===!0,i=Pp(a,Ec({enabled:a}).data),c=e.find(m=>Lp(Fp(s.data,m),r,m)==="lead");return c?n.jsxs(Cn,{children:[n.jsx(Nn,{asChild:!0,children:n.jsx(_,{size:"sm","data-testid":"signin-banner-credits",disabled:i===null,children:i===null?"DorkOS credits":`${i} DorkOS credits`})}),n.jsxs(An,{align:"end",className:"w-80 p-4",children:[n.jsxs(En,{children:["Run ",il(c)," on DorkOS credits"]}),n.jsxs("div",{className:"space-y-3",children:[t({runtime:c,origin:`signin-banner:${c}`,fullWidth:!0}),n.jsx($p,{remote:o})]})]})]}):null}function ZA(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const e1=2,t1={binding:"connection",task:"scheduled task"};function n1(e){return e.map((t,s)=>n.jsxs(l.Fragment,{children:[s>0&&(s===e.length-1?" and ":", "),t]},s))}function s1({drivers:e}){const t=go(),s=ks();if(e.length===0)return null;const r=e.slice(0,e1),o=e.length-r.length,a=r.map(c=>n.jsxs(n.Fragment,{children:["the ",n.jsx("span",{className:"font-medium",children:c.name})," ",t1[c.kind]]}));o>0&&a.push(n.jsxs(n.Fragment,{children:[o," more"]}));const i=new Set(e.map(c=>c.kind));return n.jsxs(bo,{variant:"info",icon:Ot,actions:t?n.jsxs(n.Fragment,{children:[i.has("binding")&&n.jsx(_,{variant:"outline",size:"sm",onClick:()=>s(),children:"Connections"}),i.has("task")&&n.jsx(_,{variant:"outline",size:"sm",onClick:()=>t({...pe.tasks()}),children:"Schedules"})]}):void 0,children:["Running unattended at full power: ",n1(a),"."]})}const Bo={critical:40,warning:30,info:20};function r1(){const e=ju();return!e||e.drivers.length===0?null:{id:"unattended-autonomy",variant:"info",priority:Bo.info,render:()=>n.jsx(s1,{drivers:e.drivers})}}function o1(){const e=qA();return!e||e.configuredId===e.activeId?null:{id:"memory-provider-benched",variant:"warning",priority:Bo.warning,render:()=>n.jsx(YA,{configuredId:e.configuredId,benched:e.benched})}}const a1={kinds:["signin.required"]};function i1(){const{notifications:e}=Bp(a1),t=l.useMemo(()=>WA(e),[e]);return t.length===0?null:{id:"runtime-signin",variant:"critical",priority:Bo.critical,render:()=>n.jsx(XA,{runtimes:t})}}function c1(e){const t=r1(),s=o1(),r=i1();return[t,s,r].filter(o=>o!==null)}function l1(){const e=Sn(),[t,s]=l.useState(!1),r=()=>{e.mutate({telemetry:{install:!1,heartbeat:!1,usage:!1,userHasDecided:!0}})},o=()=>{e.mutate({telemetry:{install:!0,heartbeat:!0,usage:!0,userHasDecided:!0}})};return n.jsxs(n.Fragment,{children:[n.jsxs(yr,{children:[n.jsx(br,{children:"Share anonymous usage data?"}),n.jsx(vr,{children:"A daily ping, package installs and feature use. Never your prompts, code or files."})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[n.jsx(zp,{open:t,onToggle:()=>s(a=>!a)}),n.jsx("a",{href:"https://dorkos.ai/telemetry",target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground text-xs font-medium underline underline-offset-2",children:"Full contract"})]}),t&&n.jsx(Up,{})]}),n.jsxs(wr,{className:"items-center gap-2 sm:justify-between",children:[e.isError?n.jsx("p",{role:"alert",className:"text-destructive text-xs",children:"Couldn’t save your choice. Try again."}):n.jsx("span",{"aria-hidden":!0}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(_,{variant:"outline",size:"sm",onClick:r,disabled:e.isPending,children:"Don’t share"}),n.jsx(_,{size:"sm",onClick:o,disabled:e.isPending,children:"Share anonymously"})]})]})]})}const ku={high:30,low:10};function d1(){var t;const{data:e}=Oe();return(t=e==null?void 0:e.telemetry)!=null&&t.userHasDecided?null:{id:"telemetry-consent",priority:ku.low,render:()=>n.jsx(l1,{})}}function u1(){var s,r,o;const{data:e}=Oe();return!e||!(((s=e.onboarding)==null?void 0:s.completedAt)!=null||((r=e.onboarding)==null?void 0:r.dismissedAt)!=null)||((o=e.ui)==null?void 0:o.fullPowerDecidedAt)!=null?null:{id:"full-power-door",priority:ku.high,render:({onClose:a})=>n.jsx(Qb,{onClose:a})}}function m1(){const e=u1(),t=d1();return[e,t].filter(s=>s!==null)}function h1(e){return e.reduce((t,s)=>t===null||s.priority>t.priority?s:t,null)}function f1({onboardingOverlayVisible:e=!1}){const t=m1(),{data:s,dataUpdatedAt:r}=Oe(),o=B(y=>y.momentShownThisLaunch),a=B(y=>y.markMomentShown),[i,c]=l.useState(null),[d,m]=l.useState(null),u=l.useRef(null),h=(s==null?void 0:s.onboarding)!=null&&(s.onboarding.completedAt!=null||s.onboarding.dismissedAt!=null),p=r>Pt,f=e||!p||!h,g=f?null:h1(t);i===null&&g!==null&&!o&&(c(g.id),m(g)),l.useEffect(()=>{i!==null&&a()},[i,a]);const x=!f&&i!==null&&t.some(y=>y.id===i),b=()=>c(null);return n.jsx(tc,{open:x,onOpenChange:y=>{y||b()},children:d!==null&&n.jsx(Kp,{ref:u,onOpenAutoFocus:y=>{var k;y.preventDefault(),(k=u.current)==null||k.focus()},children:d.render({onClose:b})},d.id)})}const p1=[];function g1(){const{approvals:e,isError:t,retry:s}=Hp(),{interactions:r}=qp(),o=Wp(),a=Gp(e),i=Yp(r),c=Ie(),d=l.useMemo(()=>[...e.map(u=>Vp(u.approvalId)),...r.map(u=>Qp(u.interaction.id))],[e,r]);return!t&&a.length===0&&r.length===0&&o.length===0?{slot:null,coveredSignalIds:p1}:{coveredSignalIds:d,slot:n.jsxs("div",{"data-testid":"mobile-now-attention",className:"flex flex-col gap-2 px-2 pt-0.5 pb-1",children:[t&&n.jsx(Xp,{onRetry:s}),(r.length>0||o.length>0)&&n.jsx(Jp,{asks:r,agentNames:i,onOpenSession:u=>{c(ut({session:u}))}}),a.length>0&&n.jsx(Zp,{approvals:a})]})}}const Su=[{id:"home",label:"Home",icon:mc,badged:!0,kind:"panel"},{id:"library",label:"All",icon:ho,badged:!1,kind:"panel"},{id:"dorkbot",label:"DorkBot",icon:po,badged:!1,kind:"action"},{id:"you",label:"You",icon:Jr,badged:!1,kind:"panel"}],x1=cl.filter(e=>e==="library"),y1=cl.filter(e=>e!=="library"),Hr="calc(3.5rem + env(safe-area-inset-bottom))",ms=eg(e=>({panelUp:!1,raise:()=>e({panelUp:!0}),lower:()=>e({panelUp:!1})}));function Ri(){ms.getState().lower()}function b1({current:e,needsYouCount:t,dorkBotReady:s,onSelect:r,label:o="Main"}){return n.jsx("nav",{"aria-label":o,"data-testid":"mobile-tab-bar",className:"bg-sidebar border-border/60 flex shrink-0 items-stretch border-t",style:{height:Hr,paddingBottom:"env(safe-area-inset-bottom)"},children:Su.map(a=>{const i=a.icon,c=a.id===e,d=a.badged&&t>0?t:null,m=a.kind==="action"&&!s;return n.jsxs("button",{type:"button",onClick:()=>r(a.id),disabled:m,"aria-current":c?"page":void 0,"data-testid":`mobile-tab-${a.id}`,"data-mobile-tab":"",className:z("focus-ring text-2xs relative flex flex-1 flex-col items-center justify-center gap-0.5 transition-[color,background-color,scale] duration-150","active:bg-sidebar-accent motion-safe:active:scale-[0.96]",c?"text-sidebar-foreground font-semibold":"text-sidebar-foreground/70 hover:text-sidebar-foreground font-medium","disabled:pointer-events-none disabled:opacity-50"),children:[n.jsxs("span",{className:"relative",children:[n.jsx(i,{className:"size-5","aria-hidden":!0}),d!==null&&n.jsx("span",{"data-testid":`mobile-tab-badge-${a.id}`,"aria-hidden":!0,className:"text-3xs absolute -top-1.5 -right-2.5 min-w-4 rounded-full bg-amber-500 px-1 text-center leading-4 font-semibold text-amber-950 tabular-nums",children:d})]}),a.label]},a.id)})})}function v1(){const e=Mc(),t=Ie(),s=Ae({select:r=>r.location.pathname});return e.length===0?null:n.jsxs("section",{"aria-labelledby":"mobile-add-ons-heading",className:"mt-4",children:[n.jsx("h2",{id:"mobile-add-ons-heading",className:"text-muted-foreground px-2 pb-1.5 text-xs font-medium",children:"Add-ons"}),n.jsx("ul",{className:"bg-sidebar-accent/60 flex flex-col gap-0.5 rounded-lg p-1",children:e.map(r=>{const o=_c(r.extensionId,r.path),a=s===o;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>void t({href:o}),"aria-current":a?"page":void 0,className:z("flex w-full items-center gap-2.5 rounded-md px-2.5 text-[13px]",Vt,a?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/80 hover:bg-sidebar-accent"),children:[n.jsx(Dn,{icon:r.icon,className:"size-4 shrink-0"}),n.jsx("span",{className:"truncate",children:r.title})]})},r.id)})})]})}function mr({id:e,active:t,children:s}){return n.jsx("div",{id:`mobile-tab-panel-${e}`,"data-testid":`mobile-tab-panel-${e}`,"data-active":t?"":void 0,inert:!t,className:z("absolute inset-0",!t&&"invisible"),children:s})}function w1({takeover:e}){Zd();const t=g1(),s=nu({coveredSignalIds:t.coveredSignalIds}),r=eu(s),{ask:o,ready:a}=tg(),[i,c]=l.useState("home"),d=ms(x=>x.panelUp),m=ms(x=>x.raise),u=Lt();l.useEffect(()=>u.subscribe("onBeforeLoad",Ri),[u]),l.useEffect(()=>Ri,[]),l.useEffect(()=>(document.documentElement.style.setProperty("--mobile-tab-dock",Hr),()=>{document.documentElement.style.removeProperty("--mobile-tab-dock")}),[]);const h=l.useCallback(x=>{const b=Su.find(y=>y.id===x);if(b!==void 0){if(b.kind==="action"){if(!a)return;c(x),o();return}c(x),m()}},[o,a,m]),p=r.zones.find(x=>x.id==="now"),f=(p==null?void 0:p.needsYouCount)??s.attention.length,g=lu((p==null?void 0:p.liveRegionText)??ng(f));return n.jsxs(Yc,{activeTarget:s.activeTarget,children:[n.jsxs("div",{"data-testid":"mobile-tab-panels",inert:!d,className:z("bg-background fixed inset-x-0 top-0 z-30",!d&&"pointer-events-none invisible"),style:{bottom:`calc(${Hr} + var(--pip-dock, 0px))`},children:[n.jsx(mr,{id:"home",active:i==="home",children:n.jsxs(Us,{width:"full",className:"px-3 py-2",children:[n.jsx(hu,{}),n.jsx(Ur,{model:r,zoneIds:y1,nowSlot:t.slot,silenceLiveRegion:!0}),n.jsx(Jd,{})]})}),n.jsx(mr,{id:"library",active:i==="library",children:n.jsx(Us,{width:"full",className:"px-3 py-2",children:e??n.jsx(Ur,{model:r,zoneIds:x1,silenceLiveRegion:!0})})}),n.jsx(mr,{id:"you",active:i==="you",children:n.jsxs(Us,{width:"full",className:"px-3 py-4",children:[n.jsx("h1",{className:"text-foreground px-2 pb-2 text-sm font-semibold",children:"You"}),n.jsx(zC,{}),n.jsx(ll,{}),n.jsx(v1,{})]})})]}),n.jsx("span",{"data-testid":"mobile-needs-you-live-region","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:g}),n.jsx(b1,{current:d?i:null,needsYouCount:f,dorkBotReady:a,onSelect:h})]})}function j1(){const{open:e}=qe(),t=B(r=>r.setControlCenterOpen),s=Es(()=>t(!1));return n.jsxs("section",{className:"@container flex flex-col gap-2","data-testid":"control-center-dial",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Power"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"What agents may do without asking you."})]}),n.jsx(sg,{surface:"control-center"}),n.jsxs(_,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 self-start px-2 text-xs",onClick:s(()=>e("permissions")),children:["Edit permissions",n.jsx(Tn,{className:"size-3.5","aria-hidden":!0})]})]})}const on={unconfigured:"Use DorkOS from your phone. One-time setup.",off:"Use DorkOS from your phone or another computer.",starting:"Connecting…",stopping:"Turning off…"};function k1(){const e=xo(),t=oo(),s=B(u=>u.setRemoteAccessOpen),r=B(u=>u.setControlCenterOpen),a=Es(()=>r(!1))(()=>s(!0)),i=e.tokenConfigured,c=e.state==="starting"||e.state==="stopping",d=e.hasServerReport;let m;return d?i?e.error!==null?m=n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[n.jsx("span",{className:"text-destructive truncate",children:ml(e.error)}),n.jsx("button",{type:"button",onClick:a,className:"focus-ring text-foreground shrink-0 rounded-sm underline underline-offset-2",children:"Fix…"})]}):e.state==="connected"?m=`On · ${e.host??"connected"}`:e.state==="reconnecting"?m=e.host?`On · ${e.host} · reconnecting…`:"Reconnecting…":e.state==="starting"?m=on.starting:e.state==="stopping"?m=on.stopping:m=on.off:m=on.unconfigured:m=on.off,n.jsx(dl,{label:"Remote access",description:n.jsx("span",{"data-testid":"remote-access-row-description",className:z("block min-w-0",c&&"motion-safe:animate-breath"),children:m}),children:n.jsx(ul,{checked:i&&e.isChecked,disabled:!d||i&&e.isTransitioning,"aria-label":"Remote access",onCheckedChange:u=>{if(!i){a();return}t.toggle(u)}})})}const S1=1,C1=10,N1=4;function A1(){var d,m;const{data:e}=Oe(),t=Sn(),s=ce(),{limits:r,setLimits:o}=rg(),a=()=>void s.invalidateQueries({queryKey:De.all}),i=((d=e==null?void 0:e.claudeCode)==null?void 0:d.persistentSession)??!0,c=((m=e==null?void 0:e.scheduler)==null?void 0:m.maxConcurrentRuns)??N1;return n.jsx(og,{children:n.jsxs(ag,{children:[n.jsx(k1,{}),n.jsx(gx,{}),n.jsx(ca,{label:"Limit automatic replies",description:(r==null?void 0:r.turnLimitsEnabled)===!1?"Agents reply to each other without limit until you press Stop.":n.jsxs(n.Fragment,{children:["Agents pause after a long back-and-forth."," ",n.jsxs(la,{label:"About reply limits",children:[n.jsx("p",{children:"Your next message starts the count over."}),n.jsx("p",{children:"Set the numbers in Settings → Advanced → Room limits."})]})]}),checked:(r==null?void 0:r.turnLimitsEnabled)??!0,disabled:r===null,onCheckedChange:u=>o({turnLimitsEnabled:u})}),n.jsx(ca,{label:"Warm agents",description:n.jsxs(n.Fragment,{children:["Replies start about 4× faster. Each warm agent uses up to about 1 GB."," ",n.jsxs(la,{label:"About warm agents",children:[n.jsx("p",{children:"Your agent stays running between messages."}),n.jsx("p",{children:"At most twelve agents stay warm at once."})]})]}),checked:i,disabled:t.isPending,onCheckedChange:u=>t.mutate({runtimes:{claudeCode:{persistentSession:u}}},{onSuccess:a})}),n.jsx(dl,{label:"Scheduled runs at once",description:"How many scheduled tasks run together.",children:n.jsx(ig,{value:c,min:S1,max:C1,"aria-label":"Scheduled runs at once",onCommit:u=>t.mutate({scheduler:{maxConcurrentRuns:u}},{onSuccess:a})})})]})})}const Di="claude-code";function E1(){var I,D,T,E,w;const{data:e}=Oe(),{data:t}=Qi(),{sessions:s}=Oc(),r=cg(),{data:o}=lg(r),{data:a}=dg(),i=ug(),c=i.data,d=Yb(),m=go(),{open:u}=qe(),{open:h}=fo(),p=ks(),f=B(A=>A.setControlCenterOpen),g=Es(()=>f(!1)),x=i.isError,b=t===void 0||e===void 0||c===void 0&&!x,y=e==null?void 0:e.executionDefaults,k=(y==null?void 0:y.runtime)??Di,j=(I=t==null?void 0:t.capabilities[k])==null?void 0:I.permissionModes,C=((D=j==null?void 0:j.values.find(A=>A.id===j.default))==null?void 0:D.stop)??"ask",v=(y==null?void 0:y.trustStop)??C,N=[];if(!b){for(const S of(y==null?void 0:y.perRuntime)??[])S.trustStop===null||S.trustStop===v||N.push({key:`runtime:${S.runtime}`,kind:"runtime",name:Ye(S.runtime).label,detail:$s(S.trustStop),onOpen:m?g(()=>u("runtimes")):null});for(const S of s){const M=(T=t==null?void 0:t.capabilities[S.runtime])==null?void 0:T.permissionModes,R=M==null?void 0:M.values.find(P=>P.id===S.permissionMode),O=R==null?void 0:R.stop;!O||O===v||N.push({key:`session:${S.id}`,kind:"session",name:S.title||"Untitled session",detail:(R==null?void 0:R.label)??Bs(S.permissionMode),onOpen:m?g(()=>m(ut({session:S.id,dir:S.cwd}))):null})}const A=((w=(E=t==null?void 0:t.capabilities[Di])==null?void 0:E.permissionModes)==null?void 0:w.values)??[];for(const S of o??[]){const M=A.find(O=>O.id===S.permissionMode),R=M==null?void 0:M.stop;!R||R===v||N.push({key:`task:${S.id}`,kind:"task",name:S.displayName??S.name,detail:(M==null?void 0:M.label)??Bs(S.permissionMode),onOpen:m?g(()=>m({...pe.tasks()})):null})}for(const S of a??[]){const M=A.find(O=>O.id===S.permissionMode),R=M==null?void 0:M.stop;!R||R===v||N.push({key:`binding:${S.id}`,kind:"binding",name:S.label||S.adapterId,detail:(M==null?void 0:M.label)??Bs(S.permissionMode),onOpen:m?g(()=>p({app:S.adapterId})):null})}}if(c){const A=new Map(c.areas.map(R=>[R.id,R.label])),S=new Map(c.areas.flatMap(R=>R.actions.map(O=>[O.id,O.title]))),M=R=>g(()=>h(R,"permissions"));for(const R of c.exceptions){const O=R.action?S.get(R.action)??R.action:A.get(R.area),P=mg[R.state];N.push({key:`agent-permission:${R.agentId}:${R.action??R.area}`,kind:"agent-permission",name:R.agentName,detail:`${O??R.area} ${P}`,why:{question:`Why is ${O??R.area} set to ${P} for ${R.agentName}?`,sentence:hg({state:R.state,source:R.action?"agent-action":"agent-area",preset:c.preset,agentName:R.agentName}),...R.lastChange?{lastChange:R.lastChange}:{}},onOpen:M(R.agentId),onReset:()=>d.mutate({agentId:R.agentId,key:R.action?{kind:"action",action:R.action}:{kind:"area",area:R.area},surface:"control-center"}),resetting:d.isPending})}for(const R of c.filesAndCommands.exceptions)N.push({key:`agent-permission:${R.agentId}:files`,kind:"agent-permission",name:R.agentName,detail:`Files & commands ${$s(R.stop)}`,why:{question:`Why is Files & commands set to ${$s(R.stop)} for ${R.agentName}?`,sentence:fg(R.stop,"agent",R.agentName),...R.lastChange?{lastChange:R.lastChange}:{}},onOpen:M(R.agentId),onReset:()=>d.mutate({agentId:R.agentId,key:{kind:"files"},surface:"control-center"}),resetting:d.isPending})}return{rows:N,isEmpty:!b&&!x&&N.length===0,isResolving:b,permissionsUnreadable:x}}const I1={runtime:gg,session:uc,task:yo,binding:Vr,"agent-permission":pg};function T1(){const{rows:e,isEmpty:t,isResolving:s,permissionsUnreadable:r}=E1();return n.jsxs("section",{className:"flex flex-col gap-2","data-testid":"control-center-overrides",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Exceptions"}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"These skip the preset. Changing the preset leaves them alone."})]}),s?n.jsx("p",{className:"text-muted-foreground px-1 text-xs",children:"Checking…"}):t?n.jsx("p",{"data-testid":"overrides-ledger-empty",className:"text-muted-foreground px-1 text-xs",children:"Everything follows your preset. Chats open in other projects aren’t counted."}):n.jsx("ul",{className:"flex flex-col gap-0.5",children:e.map(o=>{const a=I1[o.kind];return n.jsxs("li",{className:"flex items-center gap-1",children:[n.jsxs("button",{type:"button","data-testid":`override-row-${o.kind}`,onClick:()=>{var i;return(i=o.onOpen)==null?void 0:i.call(o)},disabled:!o.onOpen,"aria-label":`${o.name}: ${o.detail}. Open.`,className:"focus-ring hover:bg-accent/60 flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs transition-colors disabled:pointer-events-none disabled:opacity-60",children:[n.jsx(a,{className:"text-muted-foreground size-3.5 shrink-0","aria-hidden":!0}),n.jsx("span",{className:"min-w-16 flex-1 truncate",children:o.name}),n.jsx("span",{className:"text-muted-foreground min-w-0 truncate",children:o.detail}),n.jsx(Tn,{className:"text-muted-foreground/60 size-3.5 shrink-0","aria-hidden":!0})]}),o.why?n.jsx(xg,{question:o.why.question,sentence:o.why.sentence,...o.why.lastChange?{lastChange:o.why.lastChange}:{},className:"shrink-0 px-1"}):null,o.onReset?n.jsxs(_,{variant:"ghost",size:"sm",className:"h-7 shrink-0 px-2 text-xs",disabled:o.resetting,"aria-label":`Reset ${o.name}: ${o.detail}`,onClick:o.onReset,children:[n.jsx(yg,{className:"size-3.5","aria-hidden":!0}),"Reset"]}):null]},o.key)})}),r?n.jsx("p",{"data-testid":"overrides-ledger-permissions-error",className:"text-muted-foreground px-1 text-xs",children:"Couldn’t load agents with their own permissions. See Settings → Permissions."}):null]})}const R1=2;function D1(){const e=ju();if(!e||e.drivers.length===0)return null;const t=e.drivers.slice(0,R1).map(o=>o.name),s=e.drivers.length-t.length,r=s>0?[...t,`${s} more`]:t;return n.jsxs("p",{"data-testid":"control-center-unattended",className:"text-status-success flex items-start gap-1.5 px-1 text-xs",children:[n.jsx(Ot,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),n.jsxs("span",{children:["Running unattended at full power: ",r.join(", "),"."]})]})}function O1(){const e=hl();return fl(e)?n.jsxs("p",{"data-testid":"control-center-keep-awake",className:"text-muted-foreground flex items-start gap-1.5 px-1 text-xs",children:[n.jsx(Dl,{className:"mt-px size-3 shrink-0","aria-hidden":!0}),n.jsxs("span",{children:["Keeping this computer awake: ",pl(e.working),"."]})]}):null}function M1(){return n.jsxs("div",{className:"flex flex-col gap-4","data-testid":"control-center-body",children:[n.jsx(j1,{}),n.jsx(A1,{}),n.jsx(T1,{}),n.jsx(D1,{}),n.jsx(O1,{})]})}function _1(){const e=B(r=>r.controlCenterOpen),t=B(r=>r.setControlCenterOpen),s=Ne();return n.jsxs(Cn,{open:e,onOpenChange:t,modal:!0,autoFocus:!0,children:[n.jsx(Nn,{asChild:!0,children:n.jsx("button",{type:"button","data-testid":"control-center-trigger","aria-label":"Control Center",className:"focus-ring text-muted-foreground hover:text-foreground inline-flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(Ot,{className:"size-4","aria-hidden":!0})})}),n.jsxs(An,{side:"bottom",align:"end","aria-label":"Control Center",className:"w-96 max-w-[calc(100vw-1.5rem)] p-3",children:[!s&&n.jsxs("header",{className:"mb-3 flex items-center gap-2",children:[n.jsx(Ot,{className:"text-status-success size-4 shrink-0","aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:"Control Center"})]}),n.jsx(En,{children:"Control Center"}),n.jsx(M1,{})]})]})}function P1(){const e=B(t=>t.toggleControlCenter);l.useEffect(()=>{const t=s=>{(s.metaKey||s.ctrlKey)&&s.shiftKey&&(s.key==="l"||s.key==="L")&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function L1(e,t){const s=l.useRef(null),[r,o]=l.useState(0);return l.useEffect(()=>{if(!t)return;const a=s.current;s.current=e,a!==null&&a!=="connected"&&e==="connected"&&o(i=>i+1)},[e,t]),r}function Cu(e){return e==="connected"?"Remote access is on":e==="starting"?"Connecting…":e==="reconnecting"?"Reconnecting…":e==="stopping"?"Turning off…":"Remote access"}function F1({url:e}){const t=Ce();return n.jsxs("div",{"data-testid":"remote-access-qr",children:[n.jsx(G.div,{initial:t?!1:{clipPath:"inset(0 100% 0 0)"},animate:{clipPath:"inset(0 0% 0 0)"},transition:{duration:.2,ease:[0,0,.2,1]},children:n.jsx(bg,{url:e,size:168})}),n.jsx("p",{className:"text-muted-foreground mt-2 text-center text-xs",children:"Scan with your phone"})]})}function $1({url:e}){const{copied:t,failed:s,copy:r}=ao();let o,a;return t?(o=n.jsx(Ft,{className:"size-3.5"}),a="Copied"):s?(o=n.jsx(He,{className:"text-destructive size-3.5"}),a="Couldn’t copy"):(o=n.jsx(Kc,{className:"size-3.5"}),a="Copy link"),n.jsxs("div",{className:"bg-muted/40 rounded-lg border p-2.5","data-testid":"remote-access-link",children:[n.jsx("p",{className:"text-foreground truncate font-mono text-xs",title:e,children:e}),n.jsxs(_,{variant:"outline",size:"sm",className:"mt-2 w-full gap-1.5",onClick:()=>void r(e),children:[o,a]})]})}function B1({onClose:e}){const t=xo(),s=oo(),r=Ne(),o=B(u=>u.setRemoteAccessOpen),a=Es(e),i=t.url,c=i?n.jsx($1,{url:i},"link"):null,d=i?n.jsx(F1,{url:i},"qr"):null,m=r?[c,d]:[d,c];return n.jsxs("div",{className:"flex flex-col gap-3","data-testid":"remote-access-panel",children:[!r&&n.jsxs("header",{className:"flex items-center gap-2",children:[n.jsx("span",{className:z("inline-block size-2 shrink-0 rounded-full",t.state==="connected"?"bg-status-success":"bg-status-warning-dot"),"aria-hidden":!0}),n.jsx("h2",{className:"text-sm font-semibold",children:Cu(t.state)})]}),t.error!==null&&n.jsx("p",{role:"alert","data-testid":"remote-access-panel-error",className:"text-destructive text-xs",children:ml(t.error)}),i===null&&n.jsx("p",{className:"text-muted-foreground text-xs",children:"Your link appears here when it’s ready."}),m,n.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[n.jsx("span",{className:"text-muted-foreground text-sm",children:"Remote access"}),n.jsx(ul,{checked:t.isChecked,disabled:t.isTransitioning,"aria-label":"Remote access",onCheckedChange:u=>void s.toggle(u)})]}),n.jsx(_,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground -mx-1 justify-start",onClick:a(()=>o(!0)),children:"Manage…"})]})}function Nu(e,t){return e==="starting"?"Remote access is connecting":e==="reconnecting"?"Remote access is reconnecting":e==="stopping"?"Remote access is turning off":t?`Remote access is on at ${t}`:"Remote access is on"}function z1(e,t){const s=e==="starting"?"Open remote access":"Show link and QR code";return`${Nu(e,t)}. ${s}`}function U1(){const e=xo(),t=B(i=>i.remoteAccessBeaconOpen),s=B(i=>i.setRemoteAccessBeaconOpen),r=Ce(),o=L1(e.state,e.hasServerReport);l.useEffect(()=>{!e.isLive&&t&&s(!1)},[e.isLive,t,s]);const a=e.isLive?Nu(e.state,e.host):"";return n.jsxs(n.Fragment,{children:[n.jsx("span",{role:"status",className:"sr-only","data-testid":"remote-access-announcement",children:a}),e.isLive&&n.jsxs(Cn,{open:t,onOpenChange:s,modal:!0,children:[n.jsx(Nn,{asChild:!0,children:n.jsxs("button",{type:"button","data-testid":"remote-access-beacon","data-state-name":e.state,"aria-label":z1(e.state,e.host),className:z("focus-ring text-muted-foreground hover:text-foreground relative inline-flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",e.state==="reconnecting"&&"opacity-70"),children:[n.jsx(zc,{className:z("size-4",e.state==="starting"&&"motion-safe:animate-breath"),"aria-hidden":!0}),n.jsx("span",{"aria-hidden":!0,"data-testid":"remote-access-beacon-dot",className:z("border-background absolute right-0.5 bottom-0.5 size-1.5 rounded-full border",e.state==="connected"?"bg-status-success":"bg-status-warning-dot")}),o>0&&!r&&n.jsx("span",{"aria-hidden":!0,"data-testid":"remote-access-beacon-ripple",className:"animate-beacon-ripple border-status-success pointer-events-none absolute inset-0 rounded-full border"},o)]})}),n.jsxs(An,{side:"bottom",align:"end","aria-label":"Remote access",className:"w-72 max-w-[calc(100vw-1.5rem)] p-3",children:[n.jsx(En,{children:Cu(e.state)}),n.jsx(B1,{onClose:()=>s(!1)})]})]})]})}function K1({work:e}){const{isDesktop:t}=wg();return t?n.jsxs("p",{className:"text-sm font-medium",children:["Keeping awake: ",e]}):n.jsxs(En,{className:"text-sm font-medium",children:["Keeping awake: ",e]})}function H1(){const e=hl(),{open:t}=qe(),[s,r]=l.useState(!1);if(!fl(e))return null;const o=pl(e.working);return n.jsxs(Cn,{open:s,onOpenChange:r,children:[n.jsx(Nn,{asChild:!0,children:n.jsx("button",{type:"button","data-testid":"keep-awake-beacon","aria-label":`Keeping this computer awake: ${o}. Show details`,className:"focus-ring text-muted-foreground hover:text-foreground inline-flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",children:n.jsx(Dl,{className:"size-4","aria-hidden":!0})})}),n.jsxs(An,{side:"bottom",align:"end","aria-label":"Keeping awake",className:"w-72 max-w-[calc(100vw-1.5rem)] space-y-2 p-3",children:[n.jsx(K1,{work:o}),n.jsx("p",{className:"text-muted-foreground text-xs",children:vg}),n.jsx(_,{variant:"outline",size:"sm",onClick:()=>{r(!1),t(da.tab,da.section)},children:"Sleep settings"})]})]})}function q1(){const e=ie(),t=ce();return kn({mutationFn:s=>e.createAgent(s),onSuccess:()=>{t.invalidateQueries({queryKey:["agents"]}),t.invalidateQueries({queryKey:["mesh","agents"]}),t.invalidateQueries({queryKey:["mesh","agent-paths"]}),t.invalidateQueries({queryKey:["team"]})},meta:{errorLabel:"Couldn’t create that agent",isShownInline:s=>{var r;return((r=s.body)==null?void 0:r.code)==="template_needs_review"}}})}async function W1(e,t){try{return(await e.browseDirectory(t)).entries.some(r=>r.name===".dork")?"exists-has-dork":"exists-no-dork"}catch(s){const r=s instanceof Error?s.message:"";return r.includes("EACCES")||r.includes("permission")?"error":"no-path"}}function G1({step:e,templateName:t,seedDisplayName:s=null,faceSeed:r=null,runtimeSeed:o="claude-code"}){var L;const a=ie(),{data:i}=be({queryKey:De.current(),queryFn:()=>a.getConfig(),staleTime:3e4}),c=((L=i==null?void 0:i.agents)==null?void 0:L.defaultDirectory)??"",[d,m]=l.useState(""),[u,h]=l.useState(!1),[p,f]=l.useState(""),[g,x]=l.useState(!1),[b,y]=l.useState(!1),[k,j]=l.useState(null),[C,v]=l.useState(""),[N,I]=l.useState(!1),[D,T]=l.useState(o),[E,w]=l.useState(s);s!==E&&(w(s),s&&(m(s),h(!1)));const[A,S]=l.useState(o);o!==A&&(S(o),T(o));const M=l.useMemo(()=>d?jg(d):"",[d]),R=l.useMemo(()=>M?kg(M):{valid:!1,error:void 0},[M]),O=d.length>0&&M.length>0&&!R.valid,P=p||(c&&M?`${c}/${M}`:""),F=e!=="naming"||!P?"idle":k!==null&&k.directory===P?k.status:"checking",V=d.length>0&&R.valid&&F!=="error",Z=l.useRef(null);l.useEffect(()=>{if(e!=="naming")return;const q=t?!d||u?t.replace(/^@[^/]+\//,""):null:u?"":null;if(q===null)return;const K=`${e}|${t??""}`;Z.current!==K&&(Z.current=K,m(q),h(!!t))},[e,t]);const H=l.useRef(null);l.useEffect(()=>{if(e!=="naming"||N||!r)return;const q=`${e}|${r}`;H.current!==q&&(H.current=q,v(r))},[e,r]),l.useEffect(()=>{if(e!=="naming"||!P)return;const q=P,K=setTimeout(()=>{W1(a,q).then(ne=>{j({directory:q,status:ne})})},500);return()=>clearTimeout(K)},[e,P,a]);function ee(q){m(q),u&&h(!1)}function te(q){v(q),I(!0)}function se(){Z.current=null,H.current=null,m(""),h(!1),f(""),x(!1),y(!1),j(null),v(""),I(!1),T(o)}return{displayName:d,slug:M,handleNameChange:ee,nameAutoFilled:u,slugValidation:R,showSlugError:O,defaultDirectory:c,resolvedDirectory:P,directoryOverride:p,setDirectoryOverride:f,directoryOpen:g,setDirectoryOpen:x,directoryPickerOpen:b,setDirectoryPickerOpen:y,conflictStatus:F,canSubmit:V,icon:C,setIcon:te,runtime:D,setRuntime:T,reset:se}}function Y1(e){var a;const t=(e==null?void 0:e.packageName)??null,{data:s,isError:r,error:o}=ox(t,e!=null&&e.marketplace?{marketplace:e.marketplace}:void 0);return{schedules:((a=s==null?void 0:s.preview)==null?void 0:a.schedules)??[],isChecking:t!==null&&s===void 0&&!r,failed:t!==null&&r,...t!==null&&r&&ax(o)&&{refusal:o},...s!=null&&s.disclosed&&s.contentHash?{approval:{approvedDisclosure:s.disclosed,approvedContentHash:s.contentHash},packageAgentName:s.manifest.name}:{}}}const V1={gallery:{title:"New agent",description:"What will your agent do?"},naming:{title:"Name your agent",description:"Give it a name and a face."},arrival:{description:"Add a ready-made agent."}},hr={keeper:["Keeper","Warden","Steward","Curator","Archivist","Ledger","Tally","Sorter"],scout:["Scout","Ranger","Pathfinder","Lookout","Recon","Probe","Tracer","Radar"],guardian:["Sentinel","Guardian","Aegis","Bastion","Vigil","Auditor","Gatekeep","Warden"],builder:["Forge","Smith","Builder","Mason","Wright","Maker","Anvil","Crafter"],scribe:["Scribe","Quill","Muse","Author","Penn","Bard","Editor","Note"],default:["Scout","Sage","Pilot","Beacon","Atlas","Nova","Ranger","Echo","Vera","Onyx"]},Q1=[["keeper",["board","organize","tidy","manage","linear","jira","project","backlog","task"]],["scout",["research","search","monitor","watch","discover","scan","find","intel","inbox","email","mail"]],["guardian",["review","security","audit","qa","test","lint","guard","protect","compliance"]],["builder",["build","code","scaffold","deploy","engineer","refactor","ci","release"]],["scribe",["doc","write","content","blog","summar","note","changelog","copy"]]];function X1(e){if(!e)return hr.default;const t=[e.name,e.description,e.category,...e.tags??[]].filter(Boolean).join(" ").toLowerCase();for(const[s,r]of Q1)if(r.some(o=>t.includes(o)))return hr[s];return hr.default}function J1(e,t,s){if(e.length===0)return[];const r=Math.min(s,e.length),o=(t%e.length+e.length)%e.length;return Array.from({length:r},(a,i)=>e[(o+i)%e.length])}const Z1=64,eE=16,Oi=3;function tE(e){return e.map(t=>t.replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim().slice(0,Z1)).filter(t=>t.length>0).slice(0,eE)}function nE(e){const t=tE(e.capabilities??[]),s=t.length>0?`
|
|
90
|
-
|
|
91
|
-
Your declared abilities include: ${t.join(", ")}. Draw your first-action offer from these when it fits.`:"";return["You have just been created. This is your first moment awake — greet the person who made you.","",`Read your ${Rt.soul} to recall who you are, then, in 2 to 4 short sentences:`,"- Introduce yourself in your own voice, drawn from that persona.","- State plainly what your job is.","- Propose one concrete first action you could take — as an offer, and wait for their go-ahead.","",`Do NOT start any work yet — do not act on the project or change any files. (Reading your own ${Rt.soul} so you can introduce yourself is fine; anything beyond that waits for their go-ahead.) Just make the offer and let them decide. Speak warmly and directly to the person.`+s].join(`
|
|
92
|
-
`)}function sE(e){return[`You have just been created${e.displayName?` and named ${e.displayName}`:""}, and you do not have a job yet — the person who made you will define it with you, right now, in this conversation. This is your first moment awake, and by the end of it you will have written your own ${Rt.soul}.`,"","Run a short interview to discover who you should be, then capture it:","","1. Say a brief, warm hello (1 to 2 sentences) and ask them what they would like you to take care of. Do not assume a role yet.","",`2. Hold a SHORT interview. Ask AT MOST ${Oi} questions in total across this whole conversation — this is a hard limit. Only ask what you genuinely need to write a good soul (typically the scope of the work, how often you should do it, and anything you must never touch). If their first answer already tells you enough, ask fewer. For a one-word or vague answer, ask a single clarifying question and then proceed with a reasonable role rather than interrogating them. If they say something like "just figure it out," do not push — propose a sensible role from what you have and move on. Never trap them in endless back-and-forth: once you have asked ${Oi} questions, stop asking and write your best soul from what you learned.`,"","3. Before you write, tell them in one line what you understood and that you are about to capture it as your soul — so they see it coming. Then write it.","",`4. Write your ${Rt.soul} now, using your file-editing tools. It lives at \`.dork/${Rt.soul}\` in your working directory and already contains a "Personality Traits" block fenced by \`${Sg}\` and \`${ua}\` — leave that fenced block exactly as it is. Replace only the prose BELOW the \`${ua}\` marker with your persona: who you are in your own voice, what you take care of, how you go about it, and the boundaries you keep. Keep it concise.`,"","5. After the file is written, confirm it in one or two sentences and propose ONE concrete first action you could take — as an offer, and wait for their go-ahead.","",`Do not start the actual job yet — your own ${Rt.soul} is the only file you touch now. Do not act on their project or run their work until they say go. Speak warmly and directly to the person throughout.`].join(`
|
|
93
|
-
`)}const rE={template:nE,"design-your-own":sE};function oE(e,t){return rE[e](t)}function aE(e,t){return Cx(oE(e,t))}const Au="🤖",iE=["🤖","🦾","🧭","🛰️","📡","🔭","🗺️","🧠","🦉","🦊","🐝","🐙","🚀","⚡","🌟","🔮","🛠️","🔧","📊","📋","✅","🗂️","🔔","🛡️"];function Mi({face:e,title:t,subtitle:s,chips:r,variant:o,tabIndex:a,onSelect:i,onKeyDown:c,ref:d,"data-testid":m}){return n.jsxs("button",{ref:d,type:"button",tabIndex:a,onClick:i,onKeyDown:c,"data-gallery-card":"","data-testid":m,className:z("card-interactive group flex h-full flex-col gap-2 rounded-xl border p-4 text-left","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",o==="design"?"border-primary/40 bg-primary/5 hover:border-primary/60 border-dashed":"bg-card hover:border-border/80 hover:shadow-md"),children:[n.jsx("span",{className:"text-3xl leading-none","aria-hidden":!0,children:e}),n.jsxs("div",{className:"space-y-0.5",children:[n.jsx("p",{className:"text-sm font-semibold",children:t}),n.jsx("p",{className:"text-muted-foreground text-xs leading-relaxed",children:s})]}),r&&r.length>0&&n.jsx("div",{className:"mt-auto flex flex-wrap gap-1 pt-1",children:r.map(u=>n.jsx("span",{className:"bg-muted text-muted-foreground text-2xs rounded-full px-2 py-0.5",children:u},u))})]})}function cE(e){return{source:e.source,name:e.name,displayName:gl(e),description:e.description,icon:e.icon,tags:e.tags,category:e.category,packageName:e.name,...e.marketplace?{marketplace:e.marketplace}:{}}}function lE(e){return e.tags&&e.tags.length>0?e.tags.slice(0,2):e.category?[e.category]:[]}function dE(e){const t=e.replace(/\/+$/,"");return t.split("/").pop()??t}function uE({onDesignYourOwn:e,onSelectTemplate:t,onImport:s}){const{data:r,error:o,isLoading:a}=Cg(),i=jl(a),[c,d]=l.useState(""),[m,u]=l.useState(!1),h=l.useMemo(()=>(r??[]).filter(f=>f.type==="agent"),[r]),p=Oy(h.length+1);return n.jsxs("div",{className:"space-y-5",children:[n.jsxs("div",{role:"group","aria-label":"Choose what your agent will do",className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"agent-gallery",children:[n.jsx(Mi,{ref:p.setRef(0),variant:"design",face:n.jsx(po,{className:"text-primary size-7"}),title:"Design your own",subtitle:"Describe the job in your own words.",tabIndex:p.tabIndexFor(0),onSelect:e,onKeyDown:f=>p.handleKeyDown(f,0),"data-testid":"gallery-design-your-own"}),h.map((f,g)=>{const x=g+1;return n.jsx(Mi,{ref:p.setRef(x),variant:"template",face:f.icon??Au,title:gl(f),subtitle:f.description??"A ready-made agent.",chips:lE(f),tabIndex:p.tabIndexFor(x),onSelect:()=>t(cE(f)),onKeyDown:b=>p.handleKeyDown(b,x),"data-testid":`gallery-template-${f.name}`},f.name)}),i&&h.length===0&&Array.from({length:2}).map((f,g)=>n.jsx(yt,{className:"h-28 rounded-xl","data-testid":"gallery-skeleton"},g))]}),!i&&h.length===0&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"gallery-templates-note",children:o?"Couldn’t load ready-made agents. Check marketplace sources in Settings.":"No ready-made agents yet. Add a marketplace source in Settings."}),n.jsxs(ps,{open:m,onOpenChange:u,children:[n.jsx(gs,{asChild:!0,children:n.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground flex items-center gap-1 text-xs transition-colors","data-testid":"advanced-toggle",children:[n.jsx(mt,{className:z("size-3.5 transition-transform",m&&"rotate-180")}),"Build from a template URL"]})}),n.jsx(xs,{children:n.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[n.jsx(Ze,{value:c,onChange:f=>d(f.target.value),placeholder:"github.com/org/repo","data-testid":"custom-url-input",className:"flex-1"}),n.jsx(_,{size:"sm",disabled:!c,onClick:()=>{const f=dE(c);t({source:c,name:f,displayName:Ng(f)}),d("")},"data-testid":"custom-url-go",children:"Continue"})]})})]}),n.jsx("div",{className:"border-t pt-3",children:n.jsxs("button",{type:"button",onClick:s,className:"text-muted-foreground hover:text-foreground inline-flex items-center gap-1.5 text-sm transition-colors","data-testid":"gallery-import-link",children:[n.jsx(Ag,{className:"size-4"}),"Bring in an existing project folder",n.jsx("span",{"aria-hidden":!0,children:"→"})]})})]})}function mE({value:e,onChange:t}){return n.jsx("div",{role:"group","aria-label":"Choose a face",className:"flex flex-wrap gap-1.5","data-testid":"face-picker",children:iE.map(s=>{const r=s===e;return n.jsx("button",{type:"button","aria-label":`Face ${s}`,"aria-pressed":r,onClick:()=>t(s),className:z("flex size-9 items-center justify-center rounded-md border text-lg transition-colors","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",r?"border-primary bg-primary/10":"hover:border-border hover:bg-accent border-transparent"),"data-testid":`face-${s}`,children:n.jsx("span",{"aria-hidden":!0,children:s})},s)})})}function hE({value:e,onChange:t}){return n.jsx("div",{role:"radiogroup","aria-label":"Runs on",className:"flex gap-1.5","data-testid":"runtime-picker",children:Eg.map(s=>{const r=Ye(s),o=r.icon,a=e===s;return n.jsxs("button",{type:"button",role:"radio","aria-checked":a,onClick:()=>t(s),className:z("flex flex-1 items-center justify-center gap-1.5 rounded-md border px-2 py-1.5 text-xs transition-colors","focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",a?"border-primary bg-primary/10 font-medium":"hover:border-border hover:bg-accent border-transparent"),"data-testid":`runtime-${s}`,children:[n.jsx(o,{size:14}),r.label]},s)})})}function fE({face:e,name:t,jobLine:s,capabilities:r,className:o}){const a=t.trim()||"Your agent",i=t.trim().length===0;return n.jsxs("div",{className:z("bg-card shadow-soft flex flex-col items-center gap-3 rounded-lg border p-5",o),"data-testid":"agent-preview",children:[n.jsx("span",{className:"bg-primary/10 flex size-16 items-center justify-center rounded-full text-3xl","aria-hidden":!0,children:e}),n.jsxs("div",{className:"space-y-1 text-center",children:[n.jsx("p",{className:z("text-lg font-semibold",i&&"text-muted-foreground"),"data-testid":"preview-name",children:a}),n.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:s})]}),r.length>0&&n.jsx("div",{className:"flex flex-wrap justify-center gap-1.5","data-testid":"preview-capabilities",children:r.map(c=>n.jsx("span",{className:"bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs",children:c},c))})]})}function Eu({schedules:e,checkFailed:t,testIdPrefix:s}){return n.jsxs(n.Fragment,{children:[e.length>0&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":`${s}-package-schedules`,children:[n.jsx(yo,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Brings a schedule"}),n.jsx("dd",{className:"min-w-0 space-y-1",children:e.map((r,o)=>n.jsxs("p",{children:[n.jsx("span",{className:"font-medium",children:r.name}),": ",ix(r)]},`${r.name}-${o}`))})]}),t&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":`${s}-offer-check-failed`,children:[n.jsx(Ki,{className:"text-status-warning-dot mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Not checked"}),n.jsx("dd",{className:"min-w-0",children:"Couldn’t check for scheduled work. Anything it brings still needs your approval."})]})]})}const _i=4;function pE({form:e,suggestionPool:t,jobLine:s,previewCapabilities:r,onBack:o,onImportInstead:a,onCreate:i,isCreating:c,packageSchedules:d=[],offerCheckFailed:m=!1,isCheckingOffer:u=!1,offerRefusal:h,packageDirectory:p,templateReview:f,inheritance:g,isCheckingInheritance:x=!1}){const b=l.useRef(null),[y,k]=l.useState(0),j=e.displayName.trim().toLowerCase(),C=t.filter(D=>D.toLowerCase()!==j),v=J1(C,y,_i);l.useEffect(()=>{const D=setTimeout(()=>{var T;return(T=b.current)==null?void 0:T.focus()},160);return()=>clearTimeout(D)},[]);const N=e.displayName.trim(),I=c?`Creating ${N||"your agent"}…`:`Create ${N||"agent"}`;return n.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[n.jsxs("div",{className:"space-y-5",children:[n.jsxs("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground -ml-1 inline-flex items-center gap-1 text-xs transition-colors","data-testid":"naming-back",children:[n.jsx(yc,{className:"size-3.5"}),"Choose a different agent"]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(_e,{htmlFor:"agent-name",className:"text-sm",children:"Name"}),n.jsx(Ze,{ref:b,id:"agent-name",placeholder:"Name your agent",value:e.displayName,onChange:D=>e.handleNameChange(D.target.value),"aria-invalid":e.showSlugError,"aria-describedby":e.showSlugError?"agent-name-error":void 0,className:"h-11 text-base"}),e.showSlugError&&n.jsx("p",{id:"agent-name-error",className:"text-destructive text-xs",role:"alert",children:e.slugValidation.error}),e.conflictStatus==="exists-has-dork"&&n.jsxs("div",{"data-testid":"conflict-status",children:[n.jsx("p",{className:"text-status-warning-fg text-xs font-medium",children:"This folder has a project"}),n.jsx("button",{type:"button",className:"text-primary text-xs hover:underline",onClick:a,"data-testid":"import-instead-link",children:"Import it instead"})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-muted-foreground text-xs",children:"Need a name?"}),n.jsx("button",{type:"button",onClick:()=>k(D=>D+_i),"aria-label":"Show other names",className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring rounded text-sm transition-colors focus-visible:ring-2 focus-visible:outline-none","data-testid":"suggestion-reroll",children:n.jsx("span",{"aria-hidden":!0,children:"🎲"})})]}),n.jsx("div",{className:"flex flex-wrap gap-1.5","data-testid":"name-suggestions",children:v.map(D=>n.jsx("button",{type:"button",onClick:()=>e.handleNameChange(D),className:"bg-muted hover:bg-accent focus-visible:ring-ring rounded-full px-2.5 py-1 text-xs transition-colors focus-visible:ring-2 focus-visible:outline-none","data-testid":`suggestion-${D}`,children:D},D))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx(_e,{className:"text-sm",children:"Face"}),!e.icon&&n.jsx("span",{className:"text-muted-foreground text-xs",children:"Picked for you if skipped"})]}),n.jsx(mE,{value:e.icon,onChange:e.setIcon})]}),n.jsxs(ps,{open:e.directoryOpen,onOpenChange:e.setDirectoryOpen,children:[n.jsx(gs,{asChild:!0,children:n.jsxs("button",{type:"button",className:"text-muted-foreground hover:text-foreground flex w-full items-center gap-1 text-sm transition-colors","data-testid":"details-toggle",children:[n.jsx(mt,{className:z("size-4 transition-transform",e.directoryOpen&&"rotate-180")}),"Details",e.directoryOverride&&n.jsx("span",{className:"bg-primary/10 text-primary ml-1 rounded px-1.5 py-0.5 text-xs",children:"Custom"})]})}),n.jsx(xs,{children:n.jsxs("div",{className:"space-y-4 pt-3",children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_e,{className:"text-muted-foreground text-xs",children:"Runs on"}),n.jsx(hE,{value:e.runtime,onChange:e.setRuntime})]}),p?n.jsxs("div",{className:"space-y-1.5","data-testid":"package-directory",children:[n.jsx(_e,{className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx("p",{className:"font-mono text-xs [overflow-wrap:anywhere]",children:p}),n.jsx("p",{className:"text-muted-foreground text-xs",children:"Kept in its package’s folder so updates reach it."})]}):n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(_e,{htmlFor:"agent-directory",className:"text-muted-foreground text-xs",children:"Directory"}),n.jsx(Ig,{id:"agent-directory",placeholder:e.resolvedDirectory||(e.defaultDirectory?`${e.defaultDirectory}/…`:""),value:e.directoryOverride,onChange:e.setDirectoryOverride,onBrowse:()=>e.setDirectoryPickerOpen(!0),browseTestId:"browse-directory-button","data-testid":"directory-preview"}),e.conflictStatus==="no-path"&&n.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"conflict-status",children:"Creates a new folder"}),e.conflictStatus==="exists-no-dork"&&n.jsx("p",{className:"text-muted-foreground text-xs","data-testid":"conflict-status",children:"That folder is already there. The project goes inside it."}),e.conflictStatus==="error"&&n.jsx("p",{className:"text-destructive text-xs","data-testid":"conflict-status",children:"Can’t open this folder. Pick another."})]}),!p&&e.slug&&!e.showSlugError&&n.jsxs("p",{className:"text-muted-foreground text-xs",children:["Folder name:"," ",n.jsx("code",{className:"bg-muted rounded px-1 py-0.5 font-mono text-xs",children:e.slug})]})]})})]})]}),n.jsxs("div",{className:"flex flex-col gap-4 self-start",children:[n.jsx(fE,{face:e.icon||Au,name:e.displayName,jobLine:s,capabilities:r}),(d.length>0||m)&&n.jsx("dl",{className:"bg-muted/30 space-y-2.5 rounded-lg border p-3.5 text-sm",children:n.jsx(Eu,{schedules:d,checkFailed:m,testIdPrefix:"naming"})}),h!==void 0&&n.jsx(bl,{error:h}),f,u&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"naming-checking-offer",children:"Checking for scheduled work…"}),g,n.jsx(_,{size:"lg",onClick:i,disabled:!e.canSubmit||c||u||x||h!==void 0,"data-testid":"create-button",children:I})]})]})}function gE({seed:e,packageSchedules:t,isCheckingOffer:s,offerCheckFailed:r,offerRefusal:o,resolvedDirectory:a,canSubmit:i,isCreating:c,inheritance:d,isCheckingInheritance:m=!1,onCreate:u,onCustomize:h,onNotNow:p}){const{displayName:f,persona:g,runtime:x,capabilities:b,skills:y,schedule:k,icon:j}=e.template,C=Ye(x??"claude-code").label,v=f.trim().charAt(0).toUpperCase()||"?",N=j&&Sr(j)?j:v,I=e.sourceLabel?`Offered by ${e.sourceLabel}.`:"A ready-made agent.";return n.jsxs("div",{className:"mx-auto max-w-md space-y-6","data-testid":"arrival-confirm",children:[n.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[n.jsx("span",{className:"bg-primary/10 text-primary flex size-20 items-center justify-center rounded-full text-4xl font-semibold","aria-hidden":"true",children:N}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs(ze,{className:"text-xl",children:["Meet ",f]}),n.jsx(Je,{children:I})]})]}),g&&n.jsx("p",{className:"text-foreground text-sm leading-relaxed whitespace-pre-line",children:g}),n.jsxs("dl",{className:"bg-muted/30 space-y-2.5 rounded-lg border p-3.5 text-sm",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(xE,{runtime:x}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Runs on"}),n.jsx("dd",{children:C})]}),n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(vs,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Lives in"}),n.jsx("dd",{className:"min-w-0",children:a?n.jsx("code",{className:"text-xs break-all",children:a}):n.jsx(yt,{className:"h-3.5 w-48 max-w-full rounded"})})]}),k&&n.jsxs("div",{className:"flex items-start gap-2","data-testid":"arrival-schedule",children:[n.jsx(yo,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Runs on a schedule"}),n.jsx("dd",{children:k})]}),n.jsx(Eu,{schedules:t,checkFailed:r,testIdPrefix:"arrival"}),b&&b.length>0&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(Tg,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Can"}),n.jsx("dd",{children:b.join(", ")})]}),y&&y.length>0&&n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(hc,{className:"text-muted-foreground mt-0.5 size-4 shrink-0"}),n.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Uses skills"}),n.jsx("dd",{children:y.join(", ")})]})]}),o!==void 0&&n.jsx(bl,{error:o}),n.jsxs("div",{className:"flex flex-col gap-2",children:[!i&&n.jsx("p",{className:"text-status-warning-fg text-center text-xs","data-testid":"arrival-needs-name",children:"Needs a name. Choose “Customize first” to add one."}),s&&n.jsx("p",{className:"text-muted-foreground text-center text-xs","data-testid":"arrival-checking-offer",children:"Checking for scheduled work…"}),d,n.jsx(_,{size:"lg",onClick:u,disabled:c||!i||s||m||o!==void 0,"data-testid":"arrival-create",children:c?"Creating…":`Create ${f}`}),n.jsxs("div",{className:"flex items-center justify-center gap-4",children:[n.jsx(_,{variant:"ghost",size:"sm",onClick:h,className:"text-muted-foreground","data-testid":"arrival-customize",children:"Customize first"}),n.jsx(_,{variant:"ghost",size:"sm",onClick:p,className:"text-muted-foreground","data-testid":"arrival-not-now",children:"Not now"})]})]})]})}function xE({runtime:e}){const t=Ye(e??"claude-code").icon;return n.jsx(t,{size:16,className:"text-muted-foreground shrink-0"})}function yE(e){const t=e==null?void 0:e.body;return(t==null?void 0:t.code)==="template_needs_review"?t.template:void 0}function bE(e,t){const s=e.replace(/\/*$/,"/");return t.filter(r=>r.path===e||r.path.startsWith(s))}function vE(e){return e.omitted==="link"?"A link. It isn’t copied into the agent.":e.omitted==="not-text"?`Not text (${e.bytes} bytes).`:`Too long to show (${e.bytes} bytes). Read it in the template first.`}function wE(e){const t=(e.settings??[]).filter(s=>s.omitted==="too-long"||s.omitted==="not-text");return t.length===0?"Create with these":t.length===1?`Create without seeing ${t[0].path}`:`Create without seeing ${t.length} files`}function jE(e){const{disclosed:t}=e;return[...e.findings.map(s=>({key:`finding:${s.path}`,label:s.path,detail:"Settings the agent loads: hooks, permission rules or servers.",files:bE(s.path,e.settings??[])})),...t.hooks.map((s,r)=>({key:`hook:${r}`,label:Qe(s.command),detail:`Runs on ${s.event}${s.source?`, while ${Qe(s.source)} is in use`:""}.`})),...(t.skillCommands??[]).map((s,r)=>({key:`command:${s.source}:${r}`,label:Qe(s.command),detail:`Runs when skill “${Qe(s.skill)}” is used (${Qe(s.source)})`+(s.usesArguments?". Reads the text typed after it.":".")})),...t.mcpServers.map(s=>({key:`mcp:${s.name}`,label:s.command?Dg(s.command,s.args):Qe(s.url??s.name),detail:`Starts the MCP server “${Qe(s.name)}”.`})),...t.skillTools.map(s=>({key:`tools:${s.source}`,label:s.tools.map(Qe).join(", "),detail:`Skill “${Qe(s.skill)}” may use these without asking you.`}))]}function kE({template:e,onCreateAnyway:t,onCancel:s,isCreating:r}){return n.jsxs("div",{role:"alert",className:"space-y-3 rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-sm","data-testid":"template-review",children:[n.jsxs("p",{className:"flex items-center gap-2 font-medium text-amber-700 dark:text-amber-300",children:[n.jsx(Rg,{className:"size-4 shrink-0","aria-hidden":!0}),"This template brings things that run in your agent’s chats"]}),n.jsxs("p",{className:"text-muted-foreground text-xs [overflow-wrap:anywhere]",children:["From ",e.source,". Check each before you create the agent."]}),n.jsx("ul",{className:"space-y-2",children:jE(e).map(o=>{var a;return n.jsxs("li",{className:"text-xs",children:[n.jsx("code",{className:"bg-muted text-foreground block rounded px-1.5 py-1 font-mono [overflow-wrap:anywhere] whitespace-pre-wrap",children:o.label}),n.jsx("span",{className:"text-muted-foreground",children:o.detail}),(a=o.files)==null?void 0:a.map(i=>n.jsxs("details",{className:"mt-1","data-testid":"template-settings-file",children:[n.jsx("summary",{className:"text-muted-foreground hover:text-foreground cursor-pointer",children:i.path===o.label?"Show what it contains":`Show ${i.path}`}),i.content!==void 0?n.jsx("pre",{className:"border-border/60 bg-muted/40 mt-1 max-h-[50dvh] overflow-auto rounded border p-2 font-mono text-xs break-words whitespace-pre-wrap md:max-h-56",children:i.content}):n.jsx("p",{className:"text-muted-foreground mt-1",children:vE(i)})]},i.path))]},o.key)})}),n.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[n.jsx(_,{variant:"ghost",size:"sm",onClick:s,disabled:r,children:"Don’t create it"}),n.jsx(_,{size:"sm",onClick:t,disabled:r,className:"h-auto max-w-full py-1.5 text-left [overflow-wrap:anywhere] whitespace-normal",children:r?"Creating…":wE(e)})]})]})}function SE(){const{isOpen:e,seed:t,onCreated:s,close:r}=Ss(),o=gn(H=>H.open),a=q1(),i=Ie(),[c,d]=l.useState("gallery"),[m,u]=l.useState(null),[h,p]=l.useState(!1);e!==h&&(p(e),e&&(u(null),d(t?"arrival":"gallery")));const f=t!=null&&t.template.icon&&Sr(t.template.icon)?t.template.icon:void 0,g=m!=null&&m.icon&&Sr(m.icon)?m.icon:f??null,x=(t==null?void 0:t.template.runtime)??"claude-code",b=(t==null?void 0:t.packageName)!==void 0?t:(m==null?void 0:m.packageName)!==void 0?{packageName:m.packageName,marketplace:m.marketplace}:null,y=Y1(b),{data:k}=Oe(),j=b&&y.packageAgentName&&(k!=null&&k.dorkHome)?`${k.dorkHome}/agents/${y.packageAgentName}`:void 0,[C,v]=l.useState(null),N=G1({step:c,templateName:(m==null?void 0:m.displayName)??null,seedDisplayName:(t==null?void 0:t.template.displayName)??null,faceSeed:g,runtimeSeed:x}),I=X1(m?{name:m.name,description:m.description,category:m.category,tags:m.tags}:t?{name:t.template.displayName,description:t.template.persona}:void 0),D=m?m.description??"A ready-made agent.":t!=null&&t.template.persona?t.template.persona:"You’ll define the job together in your first conversation.",T=m?m.tags??[]:(t==null?void 0:t.template.capabilities)??[];function E(){N.reset(),v(null),u(null),d("gallery")}const w=l.useCallback(H=>{u(H),d("naming")},[]),A=l.useCallback(()=>{u(null),d("naming")},[]);function S(){d(t?"arrival":"gallery")}function M(){r(),E(),o()}function R(H){var se;if(!N.canSubmit||a.isPending)return;const ee=(b==null?void 0:b.packageName)!==void 0&&y.approval?{package:{name:b.packageName,...b.marketplace?{marketplace:b.marketplace}:{},...y.approval}}:void 0,te=ee?void 0:(m==null?void 0:m.source)??(t==null?void 0:t.template.source);a.mutate({name:N.slug,displayName:N.displayName.trim()||void 0,runtime:N.runtime,...!ee&&N.directoryOverride?{directory:N.directoryOverride}:{},...N.icon?{icon:N.icon}:{},...ee??{},...te?{template:te}:{},...H?{approvedTemplateHash:H}:{},...t!=null&&t.template.persona?{persona:t.template.persona}:{},...(se=t==null?void 0:t.template.capabilities)!=null&&se.length?{capabilities:t.template.capabilities}:{}},{onSuccess:L=>{const q=crypto.randomUUID(),K=L.displayName??L.name,ne=m||t?"template":"design-your-own";oc.getState().register(q,{name:L.name,displayName:K,agentId:L.id,icon:L.icon,color:L.color,bornAt:L.registeredAt,path:L._path,runtime:L.runtime,kickoffMessage:aE(ne,{displayName:K,capabilities:L.capabilities})}),Gx();const W=s;if(r(),E(),W){W();return}i(ut({agentId:L.id,draft:"1",session:q,runtime:L.runtime}))},onError:L=>{const q=yE(L);q&&v(q)}})}function O(H){H||(r(),E())}const P=nc(e),F=n.jsx(pv,{agentName:N.displayName||(t==null?void 0:t.template.displayName)||""}),V=V1[c],Z=c==="gallery"?"max-w-6xl":c==="naming"?"max-w-5xl":"max-w-2xl";return n.jsx(et,{open:e,onOpenChange:O,defaultFullscreen:!0,children:n.jsxs(tt,{className:"flex flex-col gap-0 p-0",children:["title"in V&&n.jsxs(Xe,{className:"shrink-0 border-b px-5 py-4",children:[n.jsx(ze,{children:V.title}),n.jsx(Je,{children:V.description})]}),n.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:V.description}),n.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-6 sm:px-8",children:n.jsxs("div",{className:`mx-auto my-auto w-full ${Z}`,children:[n.jsx(Ee,{mode:"wait",children:n.jsxs(G.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[c==="gallery"&&n.jsx(uE,{onDesignYourOwn:A,onSelectTemplate:w,onImport:M}),c==="arrival"&&t&&n.jsx(gE,{seed:t,packageSchedules:y.schedules,isCheckingOffer:y.isChecking,offerCheckFailed:y.failed,offerRefusal:y.refusal,resolvedDirectory:j??N.resolvedDirectory,canSubmit:N.canSubmit,isCreating:a.isPending,inheritance:F,isCheckingInheritance:P.isPending,onCreate:()=>R(),onCustomize:()=>d("naming"),onNotNow:()=>O(!1)}),c==="naming"&&n.jsx(pE,{form:N,suggestionPool:I,jobLine:D,previewCapabilities:T,onBack:S,onImportInstead:M,onCreate:()=>R(),isCreating:a.isPending,packageSchedules:y.schedules,offerCheckFailed:y.failed,offerRefusal:y.refusal,isCheckingOffer:y.isChecking,packageDirectory:j,inheritance:F,isCheckingInheritance:P.isPending,templateReview:C?n.jsx(kE,{template:C,isCreating:a.isPending,onCreateAnyway:()=>R(C.contentHash),onCancel:()=>v(null)}):void 0})]},c)}),c!=="gallery"&&n.jsx(xx,{className:"mt-6"})]})}),n.jsx(sc,{open:N.directoryPickerOpen,onOpenChange:N.setDirectoryPickerOpen,initialPath:N.directoryOverride||N.defaultDirectory,onSelect:H=>{N.setDirectoryOverride(H),N.directoryOpen||N.setDirectoryOpen(!0)}})]})})}function CE({content:e}){return n.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-4 text-center text-sm",children:e.title})}const fr=64,NE={type:"spring",stiffness:480,damping:44};function AE({content:e,onRestore:t,onClose:s}){l.useEffect(()=>(document.documentElement.style.setProperty("--pip-dock",`${fr}px`),()=>{document.documentElement.style.removeProperty("--pip-dock")}),[]);const r=Px();return hs.createPortal(n.jsxs(G.div,{"data-slot":"pip-minibar",role:"complementary","aria-label":e.title,initial:{y:fr},animate:{y:0},exit:{y:fr},transition:NE,style:{bottom:`max(var(--mobile-tab-dock, 0px), ${r}px)`},className:"bg-background border-border shadow-elevated fixed inset-x-0 z-40 flex h-16 items-center border-t",children:[n.jsxs("button",{type:"button",onClick:t,className:"focus-ring flex h-full min-w-0 flex-1 items-center gap-3 px-4 text-left",children:[n.jsx("span",{className:"bg-primary size-2 shrink-0 animate-pulse rounded-full"}),n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e.title}),n.jsx(Py,{className:"text-muted-foreground size-4 shrink-0"})]}),n.jsx("button",{type:"button","aria-label":"Close",onClick:s,className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-ring mr-3 shrink-0 rounded-md p-2 transition-colors",children:n.jsx(He,{className:"size-4"})})]}),document.body)}const Xn={peek:.5,expanded:.94},EE=.4,IE=800,Pi=500,pr={type:"spring",stiffness:480,damping:44};function TE({content:e,onClose:t,onMinimize:s,children:r}){const o=cy(),a=oy(),[i,c]=l.useState("peek"),[d,m]=l.useState(()=>window.innerHeight);l.useEffect(()=>{const x=()=>m(window.innerHeight);return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);const u=Xn.expanded*d,h=(Xn.expanded-Xn.peek)*d,p=i==="expanded"?0:h;l.useEffect(()=>{a.start({y:p,transition:pr})},[a,p]);const f=(x,b)=>{const y=p+b.offset.y,k=b.velocity.y,j=y-h,C=Xn.peek*d;if(j>EE*C||j>0&&k>IE){s();return}let v;k<-Pi?v="expanded":k>Pi?v="peek":v=y<h/2?"expanded":"peek",v===i?a.start({y:p,transition:pr}):c(v)},g=x=>{x.target.closest("button")||o.start(x)};return hs.createPortal(n.jsxs(G.div,{"data-slot":"pip-sheet",role:"complementary","aria-label":e.title,initial:{y:u},animate:a,exit:{y:u},transition:pr,drag:"y",dragListener:!1,dragControls:o,dragConstraints:{top:0,bottom:u},dragElastic:.1,dragMomentum:!1,onDragEnd:f,style:{height:u},className:"bg-background border-border shadow-modal fixed inset-x-0 bottom-0 z-40 flex flex-col rounded-t-lg border-t",children:[n.jsxs("div",{onPointerDown:g,className:"cursor-grab touch-none select-none active:cursor-grabbing",children:[n.jsx("div",{className:"bg-muted mx-auto mt-4 h-2 w-[100px] rounded-full"}),n.jsxs("div",{className:"flex items-center justify-between gap-2 border-b px-4 pt-1 pb-2",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:e.title}),n.jsx("button",{type:"button","aria-label":"Minimize",onClick:s,className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-ring shrink-0 rounded-md p-1 transition-colors",children:n.jsx(mt,{className:"size-4"})}),n.jsx("button",{type:"button","aria-label":"Close",onClick:t,className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-ring shrink-0 rounded-md p-1 transition-colors",children:n.jsx(He,{className:"size-4"})})]})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:r})]}),document.body)}const Li=360,Fi=240,$i=16,gr={demo:CE,mcp_app:RE,widget:DE};function RE({content:e}){return n.jsx(Kx,{sessionId:e.sessionId,serverName:e.serverName,uri:e.uri,title:e.title,className:"h-full"})}function DE({content:e}){return n.jsx(mv,{sessionId:e.sessionId})}function OE(e){l.useEffect(()=>{},[e])}function Bi(){return{x:window.innerWidth-Li-$i,y:window.innerHeight-Fi-$i,width:Li,height:Fi}}function ME(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Iu(e){switch(e.kind){case"demo":{const t=gr.demo;return n.jsx(t,{content:e})}case"mcp_app":{const t=gr.mcp_app;return n.jsx(t,{content:e})}case"widget":{const t=gr.widget;return n.jsx(t,{content:e})}default:return e}}function _E({content:e,onClose:t}){const s=B(c=>c.pipGeometry),r=B(c=>c.setPipGeometry),[o,a]=l.useState(Bi);l.useEffect(()=>{if(s!==null)return;const c=()=>a(d=>{const m=Bi();return ME(d,m)?d:m});return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[s]);const i=s??o;return n.jsx(Ee,{children:e!==null&&n.jsx(Vy,{title:e.title,geometry:i,onGeometryChange:r,onClose:t,children:Iu(e)},"pip-panel")})}function PE(){const e=B(d=>d.pipContent),t=B(d=>d.pipMinimized),s=B(d=>d.closePip),r=B(d=>d.minimizePip),o=B(d=>d.restorePip),a=B(d=>d.openPip),i=Ne();OE(a);const c=l.useRef(i);return l.useEffect(()=>{i&&!c.current&&e!==null&&r(),c.current=i},[i,e,r]),i?n.jsx(Ee,{children:e!==null&&(t?n.jsx(AE,{content:e,onRestore:o,onClose:s},"pip-minibar"):n.jsx(TE,{content:e,onClose:s,onMinimize:r,children:Iu(e)},"pip-sheet"))}):n.jsx(_E,{content:e,onClose:s})}function LE(){const e=B(r=>r.shortcutsPanelOpen),t=B(r=>r.setShortcutsPanelOpen),s=Og();return n.jsx(et,{open:e,onOpenChange:t,children:n.jsxs(tt,{className:"sm:max-w-md",children:[n.jsx(Xe,{children:n.jsx(ze,{children:"Keyboard shortcuts"})}),n.jsx(lt,{className:"space-y-6",children:s.map(({group:r,label:o,shortcuts:a})=>n.jsxs("div",{children:[n.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-medium tracking-wider uppercase",children:o}),n.jsx("div",{className:"space-y-1",children:a.map(i=>n.jsxs("div",{className:"flex items-center justify-between py-1.5 text-sm",children:[n.jsx("span",{children:i.label}),n.jsx(Qc,{className:"inline-flex",children:Mt(i)})]},i.id))})]},r))})]})})}function FE(){const e=B(t=>t.toggleShortcutsPanel);l.useEffect(()=>{const t=s=>{const r=s.target,o=r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable;s.key==="?"&&!o&&(s.preventDefault(),e())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}const $E=15e3;function BE(){const e=Ae({select:r=>r.location.pathname}),s=Cs("sidebar.body").find(r=>{var o;return(o=r.visibleWhen)==null?void 0:o.call(r,{pathname:e})});if(s){const r=s.component;return{key:`body:${s.id}`,body:n.jsx(TA,{contributionId:s.id,children:n.jsx(l.Suspense,{fallback:null,children:n.jsx(r,{})})}),direction:1,isTakeover:!0}}return{key:"dashboard",body:n.jsx(iC,{}),direction:-1,isTakeover:!1}}function zE(){const e=Ae({select:t=>t.matches});return ww(e)}function UE(){const{sidebarOpen:e,setSidebarOpen:t}=B(),s=Ne(),r=ms(Q=>Q.panelUp),[o]=Mg(),a=Ae({select:Q=>Q.location.pathname}),i=Ae({select:Q=>Q.location.searchStr}),c=new URLSearchParams(i),d=a==="/channels"&&!!c.get("community")&&!!c.get("id"),m=BA(Ce()??!1),u=Ae({select:Q=>zA(Q.matches)});ov();const[h]=On(),p=B(Q=>Q.isStreaming),f=B(Q=>Q.activeForm),g=B(Q=>Q.isWaitingForUser),x=B(Q=>Q.tasksBadgeCount),{data:b}=fc(h),y=Zr(b??null,h??""),{room:k,roomTitle:j,unreadRoomCount:C}=NA();EA(),Iy({cwd:h,isStreaming:p,color:b?y.color:void 0}),Ty({cwd:h,activeForm:f,isStreaming:p,isWaitingForUser:g,agentName:b?ke(b):void 0,agentEmoji:b?y.emoji:void 0,tasksBadgeCount:x,roomTitle:j,unreadRoomCount:C}),FE(),yw(),dx(),P1(),ux(),mx(),Nx(),$w(),Bw(),Hw(),wA(),jA();const v=kA();SA(),lv(),xv(),nw(),gv(),_g(),$A(),Pg(),dv(),Wb(),vb(),Ry(),Lg(),Gb(),Fg(),l0(),yx();const N=B(Q=>Q.onboardingHiddenForSession),I=B(Q=>Q.setOnboardingHiddenForSession),{shouldShowOnboarding:D,isLoading:T,isOnboardingComplete:E,isOnboardingDismissed:w}=Nt(),A=Nb({shouldShowOnboarding:D,onboardingHiddenForSession:N});Eb({done:E||w,overlayVisible:A}),fv({blocked:A});const{dataUpdatedAt:S,errorUpdatedAt:M,error:R}=Oe({refetchOnMount:LA}),O=S>Pt,P=M>Pt,F=PA(M,R),[V,Z]=l.useState(!1);l.useEffect(()=>{if(O)return;const Q=setTimeout(()=>Z(!0),$E);return()=>clearTimeout(Q)},[O]);const H=(F==null?void 0:F.status)===void 0,ee=!O&&H&&(P||V),te=O||(F==null?void 0:F.status)===void 0?void 0:F,[se,L]=l.useState(!1);l.useEffect(()=>{if(!T)return;const Q=setTimeout(()=>L(!0),3e3);return()=>clearTimeout(Q)},[T]);const q=l.useCallback(()=>I(!0),[I]),K=BE(),{origin:ne,originLabel:W}=$g(o),{data:le}=Bg(o,{enabled:!1,select:Q=>Q.title}),ve=zE(),we=l.useMemo(()=>({sessionId:o??void 0,agentName:b?ke(b):void 0,agentVisual:b?y:void 0,origin:ne,originLabel:W,sessionTitle:le,sessionDirectoryName:h?sl(h):void 0,room:k,teamViewMode:zg(new URLSearchParams(i).get("view")??void 0)}),[o,b,y,ne,W,le,h,k,i]),We=c1();return ee?n.jsx(DA,{}):(te==null?void 0:te.status)!==void 0?n.jsx(MA,{status:te.status,message:te.message,code:te.code}):T&&!se?n.jsx("div",{className:"bg-background h-dvh"}):n.jsx(Ug,{children:n.jsxs(ty,{reducedMotion:"user",children:[n.jsx(Ee,{mode:"wait",children:A?n.jsx(G.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-50",children:n.jsx(Uv,{onComplete:q,renderRuntimeConnect:Kg})},"onboarding"):n.jsx(G.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},className:"h-dvh",children:n.jsxs("div",{"data-testid":"app-shell",className:"bg-background text-foreground flex h-dvh flex-col",children:[n.jsxs(Hg,{open:e,onOpenChange:t,className:z("flex-1 overflow-hidden",s&&"min-h-0"),style:{"--sidebar-width":"calc(272px + 1rem)"},children:[!s&&n.jsxs(qg,{variant:"inset",children:[n.jsx(IA,{isFullscreen:v}),n.jsx(hu,{}),n.jsx("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",children:n.jsx(Ee,{mode:"wait",initial:!1,custom:K.direction,children:n.jsx(G.div,{"data-testid":"sidebar-body-swap",custom:K.direction,initial:"enter",animate:"center",exit:"exit",variants:{enter:Q=>({x:`${Q*100}%`,opacity:0}),center:{x:0,opacity:1},exit:Q=>({x:`${Q*-100}%`,opacity:0})},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:K.body},K.key)})}),n.jsx(Wg,{className:"px-2 py-3",children:n.jsx(ll,{})}),n.jsx(Gg,{})]}),n.jsxs(Yg,{className:"overflow-hidden",inert:s&&r,children:[Pe()&&n.jsx(_w,{className:z("app-drag-region",!e&&!v&&"desktop-darwin:pl-20")}),n.jsxs("header",{className:"app-drag-region @container/bar relative flex h-9 shrink-0 items-center gap-1 border-b px-2 transition-[border-color] duration-300 lg:gap-2",children:[!s&&n.jsxs(n.Fragment,{children:[n.jsx(Vg,{className:"-ml-0.5"}),n.jsx(Fw,{}),n.jsx(Qg,{orientation:"vertical",className:"mr-1 h-4"})]}),s&&n.jsx(BC,{}),n.jsx(Ee,{mode:"wait",initial:!1,children:ve&&n.jsx(G.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.1},className:"flex min-w-0 flex-1 items-center gap-1 self-stretch lg:gap-2",children:n.jsx(Xg,{value:we,children:n.jsx(ve.Header,{})})},ve.key)}),n.jsx(_1,{}),n.jsx(U1,{}),n.jsx(H1,{}),n.jsx(Jg,{})]}),n.jsx(UA,{descriptors:We}),n.jsx("main",{id:fd,className:"flex-1 overflow-hidden pb-[var(--pip-dock,0px)]",children:n.jsxs(Zg,{direction:"horizontal",id:Ir,autoSaveId:Ir,children:[n.jsx(cc,{id:"main-content",order:1,minSize:30,defaultSize:100,children:n.jsx(G.div,{initial:m?{opacity:0}:!1,animate:{opacity:1},transition:m?{duration:.12,ease:"easeOut"}:{duration:0},"data-route-fade":m,className:"h-full",children:n.jsx(ex,{})},u)}),n.jsx(xw,{pathname:a,isRemoteCommunityRoom:d})]})})]})]}),s&&n.jsx(w1,{takeover:K.isTakeover?K.body:null})]})},"main-app")}),n.jsx(yN,{}),n.jsx(f1,{onboardingOverlayVisible:A}),n.jsx(pA,{}),n.jsx(qC,{}),n.jsx(mN,{}),n.jsx(SE,{}),n.jsx(ew,{}),n.jsx(LE,{}),n.jsx(Xy,{}),n.jsx(PE,{}),n.jsx(tx,{}),n.jsx(vA,{})]})})}const CI=UE;export{CI as component};
|