remote-codex 0.11.9 → 0.11.10
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/apps/relay-server/dist/index.js +66 -5
- package/apps/supervisor-api/dist/{chunk-NWZLUCQV.js → chunk-HMFJNQDI.js} +3 -2
- package/apps/supervisor-api/dist/index.js +1 -1
- package/apps/supervisor-api/dist/worker-index.js +1 -1
- package/apps/supervisor-web/dist/assets/core-oEok_Crl.js +12 -0
- package/apps/supervisor-web/dist/assets/{css-DPfMkruS.js → css-CLj8gQPS.js} +1 -1
- package/apps/supervisor-web/dist/assets/engine-javascript-DBd1bXLz.js +141 -0
- package/apps/supervisor-web/dist/assets/graph-vendor-C5ap-Sga.css +1 -0
- package/apps/supervisor-web/dist/assets/graph-vendor-DVPtkh3h.js +23 -0
- package/apps/supervisor-web/dist/assets/{html-GMplVEZG.js → html-pp8916En.js} +1 -1
- package/apps/supervisor-web/dist/assets/index-Cp9GkemI.css +1 -0
- package/apps/supervisor-web/dist/assets/index-M5xKhovw.js +5 -0
- package/apps/supervisor-web/dist/assets/markdown-vendor-BQJfKm05.js +291 -0
- package/apps/supervisor-web/dist/assets/react-vendor-CgLzZcV4.js +60 -0
- package/apps/supervisor-web/dist/assets/{shellscript-Yzrsuije.js → shellscript-CEILq0vU.js} +1 -1
- package/apps/supervisor-web/dist/assets/{sql-BLtJtn59.js → sql-CRqJ_cUM.js} +1 -1
- package/apps/supervisor-web/dist/assets/{terminal-vendor-BHwWZ4Dd.js → terminal-vendor-B365Go3Z.js} +1 -1
- package/apps/supervisor-web/dist/assets/thread-ui-DldLSgqC.js +3604 -0
- package/apps/supervisor-web/dist/assets/ui-vendor-CeKGesq3.js +50 -0
- package/apps/supervisor-web/dist/index.html +9 -8
- package/package.json +2 -2
- package/packages/shared/src/index.ts +1 -0
- package/apps/supervisor-api/dist/chunk-2ELO2EVR.js +0 -27897
- package/apps/supervisor-api/dist/chunk-XKQPZVOC.js +0 -27890
- package/apps/supervisor-web/dist/assets/abap-BdImnpbu.js +0 -1
- package/apps/supervisor-web/dist/assets/actionscript-3-CoDkCxhg.js +0 -1
- package/apps/supervisor-web/dist/assets/ada-bCR0ucgS.js +0 -1
- package/apps/supervisor-web/dist/assets/andromeeda-C4gqWexZ.js +0 -1
- package/apps/supervisor-web/dist/assets/angular-html-CU67Zn6k.js +0 -1
- package/apps/supervisor-web/dist/assets/angular-ts-BwZT4LLn.js +0 -1
- package/apps/supervisor-web/dist/assets/apache-Pmp26Uib.js +0 -1
- package/apps/supervisor-web/dist/assets/apex-D8_7TLub.js +0 -1
- package/apps/supervisor-web/dist/assets/apl-dKokRX4l.js +0 -1
- package/apps/supervisor-web/dist/assets/applescript-Co6uUVPk.js +0 -1
- package/apps/supervisor-web/dist/assets/ara-BRHolxvo.js +0 -1
- package/apps/supervisor-web/dist/assets/asciidoc-Ve4PFQV2.js +0 -1
- package/apps/supervisor-web/dist/assets/asm-D_Q5rh1f.js +0 -1
- package/apps/supervisor-web/dist/assets/astro-CbQHKStN.js +0 -1
- package/apps/supervisor-web/dist/assets/aurora-x-D-2ljcwZ.js +0 -1
- package/apps/supervisor-web/dist/assets/awk-DMzUqQB5.js +0 -1
- package/apps/supervisor-web/dist/assets/ayu-mirage-32ctXXKs.js +0 -1
- package/apps/supervisor-web/dist/assets/ballerina-BFfxhgS-.js +0 -1
- package/apps/supervisor-web/dist/assets/bat-BkioyH1T.js +0 -1
- package/apps/supervisor-web/dist/assets/beancount-k_qm7-4y.js +0 -1
- package/apps/supervisor-web/dist/assets/berry-uYugtg8r.js +0 -1
- package/apps/supervisor-web/dist/assets/bibtex-CHM0blh-.js +0 -1
- package/apps/supervisor-web/dist/assets/bicep-Bmn6On1c.js +0 -1
- package/apps/supervisor-web/dist/assets/bird2-DPOp833l.js +0 -1
- package/apps/supervisor-web/dist/assets/blade-D4QpJJKB.js +0 -1
- package/apps/supervisor-web/dist/assets/bsl-BO_Y6i37.js +0 -1
- package/apps/supervisor-web/dist/assets/c-BIGW1oBm.js +0 -1
- package/apps/supervisor-web/dist/assets/c3-eo99z4R2.js +0 -1
- package/apps/supervisor-web/dist/assets/cadence-Bv_4Rxtq.js +0 -1
- package/apps/supervisor-web/dist/assets/cairo-KRGpt6FW.js +0 -1
- package/apps/supervisor-web/dist/assets/catppuccin-frappe-DFWUc33u.js +0 -1
- package/apps/supervisor-web/dist/assets/catppuccin-latte-C9dUb6Cb.js +0 -1
- package/apps/supervisor-web/dist/assets/catppuccin-macchiato-DQyhUUbL.js +0 -1
- package/apps/supervisor-web/dist/assets/catppuccin-mocha-D87Tk5Gz.js +0 -1
- package/apps/supervisor-web/dist/assets/clarity-D53aC0YG.js +0 -1
- package/apps/supervisor-web/dist/assets/clojure-P80f7IUj.js +0 -1
- package/apps/supervisor-web/dist/assets/cmake-D1j8_8rp.js +0 -1
- package/apps/supervisor-web/dist/assets/cobol-nwyudZeR.js +0 -1
- package/apps/supervisor-web/dist/assets/codeowners-Bp6g37R7.js +0 -1
- package/apps/supervisor-web/dist/assets/codeql-DsOJ9woJ.js +0 -1
- package/apps/supervisor-web/dist/assets/coffee-Ch7k5sss.js +0 -1
- package/apps/supervisor-web/dist/assets/common-lisp-Cg-RD9OK.js +0 -1
- package/apps/supervisor-web/dist/assets/coq-DkFqJrB1.js +0 -1
- package/apps/supervisor-web/dist/assets/cpp-CofmeUqb.js +0 -1
- package/apps/supervisor-web/dist/assets/crystal-tKQVLTB8.js +0 -1
- package/apps/supervisor-web/dist/assets/csharp-COcwbKMJ.js +0 -1
- package/apps/supervisor-web/dist/assets/cue-D82EKSYY.js +0 -1
- package/apps/supervisor-web/dist/assets/cypher-COkxafJQ.js +0 -1
- package/apps/supervisor-web/dist/assets/d-85-TOEBH.js +0 -1
- package/apps/supervisor-web/dist/assets/dark-plus-C3mMm8J8.js +0 -1
- package/apps/supervisor-web/dist/assets/dart-CF10PKvl.js +0 -1
- package/apps/supervisor-web/dist/assets/dax-CEL-wOlO.js +0 -1
- package/apps/supervisor-web/dist/assets/desktop-BmXAJ9_W.js +0 -1
- package/apps/supervisor-web/dist/assets/diff-D97Zzqfu.js +0 -1
- package/apps/supervisor-web/dist/assets/docker-BcOcwvcX.js +0 -1
- package/apps/supervisor-web/dist/assets/dotenv-Da5cRb03.js +0 -1
- package/apps/supervisor-web/dist/assets/dracula-BzJJZx-M.js +0 -1
- package/apps/supervisor-web/dist/assets/dracula-soft-BXkSAIEj.js +0 -1
- package/apps/supervisor-web/dist/assets/dream-maker-BtqSS_iP.js +0 -1
- package/apps/supervisor-web/dist/assets/edge-BkV0erSs.js +0 -1
- package/apps/supervisor-web/dist/assets/elixir-CDX3lj18.js +0 -1
- package/apps/supervisor-web/dist/assets/elm-DbKCFpqz.js +0 -1
- package/apps/supervisor-web/dist/assets/emacs-lisp-C9XAeP06.js +0 -1
- package/apps/supervisor-web/dist/assets/erb-B12qg9BL.js +0 -1
- package/apps/supervisor-web/dist/assets/erlang-DsQrWhSR.js +0 -1
- package/apps/supervisor-web/dist/assets/everforest-dark-BgDCqdQA.js +0 -1
- package/apps/supervisor-web/dist/assets/everforest-light-C8M2exoo.js +0 -1
- package/apps/supervisor-web/dist/assets/fennel-BYunw83y.js +0 -1
- package/apps/supervisor-web/dist/assets/fish-BvzEVeQv.js +0 -1
- package/apps/supervisor-web/dist/assets/fluent-C4IJs8-o.js +0 -1
- package/apps/supervisor-web/dist/assets/fortran-fixed-form-CkoXwp7k.js +0 -1
- package/apps/supervisor-web/dist/assets/fortran-free-form-BxgE0vQu.js +0 -1
- package/apps/supervisor-web/dist/assets/fsharp-CXgrBDvD.js +0 -1
- package/apps/supervisor-web/dist/assets/gdresource-BOOCDP_w.js +0 -1
- package/apps/supervisor-web/dist/assets/gdscript-C5YyOfLZ.js +0 -1
- package/apps/supervisor-web/dist/assets/gdshader-DkwncUOv.js +0 -1
- package/apps/supervisor-web/dist/assets/genie-D0YGMca9.js +0 -1
- package/apps/supervisor-web/dist/assets/gherkin-DyxjwDmM.js +0 -1
- package/apps/supervisor-web/dist/assets/git-commit-F4YmCXRG.js +0 -1
- package/apps/supervisor-web/dist/assets/git-rebase-r7XF79zn.js +0 -1
- package/apps/supervisor-web/dist/assets/github-dark-DHJKELXO.js +0 -1
- package/apps/supervisor-web/dist/assets/github-dark-default-Cuk6v7N8.js +0 -1
- package/apps/supervisor-web/dist/assets/github-dark-dimmed-DH5Ifo-i.js +0 -1
- package/apps/supervisor-web/dist/assets/github-dark-high-contrast-E3gJ1_iC.js +0 -1
- package/apps/supervisor-web/dist/assets/github-light-DAi9KRSo.js +0 -1
- package/apps/supervisor-web/dist/assets/github-light-default-D7oLnXFd.js +0 -1
- package/apps/supervisor-web/dist/assets/github-light-high-contrast-BfjtVDDH.js +0 -1
- package/apps/supervisor-web/dist/assets/gleam-BspZqrRM.js +0 -1
- package/apps/supervisor-web/dist/assets/glimmer-js-Rg0-pVw9.js +0 -1
- package/apps/supervisor-web/dist/assets/glimmer-ts-U6CK756n.js +0 -1
- package/apps/supervisor-web/dist/assets/glsl-DplSGwfg.js +0 -1
- package/apps/supervisor-web/dist/assets/gn-n2N0HUVH.js +0 -1
- package/apps/supervisor-web/dist/assets/gnuplot-DdkO51Og.js +0 -1
- package/apps/supervisor-web/dist/assets/go-CxLEBnE3.js +0 -1
- package/apps/supervisor-web/dist/assets/graphql-ChdNCCLP.js +0 -1
- package/apps/supervisor-web/dist/assets/groovy-gcz8RCvz.js +0 -1
- package/apps/supervisor-web/dist/assets/gruvbox-dark-hard-CFHQjOhq.js +0 -1
- package/apps/supervisor-web/dist/assets/gruvbox-dark-medium-GsRaNv29.js +0 -1
- package/apps/supervisor-web/dist/assets/gruvbox-dark-soft-CVdnzihN.js +0 -1
- package/apps/supervisor-web/dist/assets/gruvbox-light-hard-CH1njM8p.js +0 -1
- package/apps/supervisor-web/dist/assets/gruvbox-light-medium-DRw_LuNl.js +0 -1
- package/apps/supervisor-web/dist/assets/gruvbox-light-soft-hJgmCMqR.js +0 -1
- package/apps/supervisor-web/dist/assets/hack-CaT9iCJl.js +0 -1
- package/apps/supervisor-web/dist/assets/haml-B8DHNrY2.js +0 -1
- package/apps/supervisor-web/dist/assets/handlebars-BL8al0AC.js +0 -1
- package/apps/supervisor-web/dist/assets/haskell-Df6bDoY_.js +0 -1
- package/apps/supervisor-web/dist/assets/haxe-CzTSHFRz.js +0 -1
- package/apps/supervisor-web/dist/assets/hcl-BWvSN4gD.js +0 -1
- package/apps/supervisor-web/dist/assets/highlighted-body-OFNGDK62-BRQR8o0F.js +0 -1
- package/apps/supervisor-web/dist/assets/hjson-D5-asLiD.js +0 -1
- package/apps/supervisor-web/dist/assets/hlsl-D3lLCCz7.js +0 -1
- package/apps/supervisor-web/dist/assets/horizon-BUw7H-hv.js +0 -1
- package/apps/supervisor-web/dist/assets/horizon-bright-Cn-bp-IR.js +0 -1
- package/apps/supervisor-web/dist/assets/houston-DnULxvSX.js +0 -1
- package/apps/supervisor-web/dist/assets/html-derivative-BFtXZ54Q.js +0 -1
- package/apps/supervisor-web/dist/assets/http-jrhK8wxY.js +0 -1
- package/apps/supervisor-web/dist/assets/hurl-irOxFIW8.js +0 -1
- package/apps/supervisor-web/dist/assets/hxml-Bvhsp5Yf.js +0 -1
- package/apps/supervisor-web/dist/assets/hy-DFXneXwc.js +0 -1
- package/apps/supervisor-web/dist/assets/imba-DGztddWO.js +0 -1
- package/apps/supervisor-web/dist/assets/index-APXuQABa.js +0 -5
- package/apps/supervisor-web/dist/assets/index-Dh2-KXLR.css +0 -1
- package/apps/supervisor-web/dist/assets/ini-BEwlwnbL.js +0 -1
- package/apps/supervisor-web/dist/assets/java-CylS5w8V.js +0 -1
- package/apps/supervisor-web/dist/assets/jinja-4LBKfQ-Z.js +0 -1
- package/apps/supervisor-web/dist/assets/jison-wvAkD_A8.js +0 -1
- package/apps/supervisor-web/dist/assets/json5-C9tS-k6U.js +0 -1
- package/apps/supervisor-web/dist/assets/jsonc-Des-eS-w.js +0 -1
- package/apps/supervisor-web/dist/assets/jsonl-DcaNXYhu.js +0 -1
- package/apps/supervisor-web/dist/assets/jsonnet-DFQXde-d.js +0 -1
- package/apps/supervisor-web/dist/assets/jssm-C2t-YnRu.js +0 -1
- package/apps/supervisor-web/dist/assets/julia-CxzCAyBv.js +0 -1
- package/apps/supervisor-web/dist/assets/just-Cw27pwNe.js +0 -1
- package/apps/supervisor-web/dist/assets/kanagawa-dragon-CkXjmgJE.js +0 -1
- package/apps/supervisor-web/dist/assets/kanagawa-lotus-CfQXZHmo.js +0 -1
- package/apps/supervisor-web/dist/assets/kanagawa-wave-DWedfzmr.js +0 -1
- package/apps/supervisor-web/dist/assets/kdl-DV7GczEv.js +0 -1
- package/apps/supervisor-web/dist/assets/kotlin-BdnUsdx6.js +0 -1
- package/apps/supervisor-web/dist/assets/kusto-DZf3V79B.js +0 -1
- package/apps/supervisor-web/dist/assets/laserwave-DUszq2jm.js +0 -1
- package/apps/supervisor-web/dist/assets/latex-CWtU0Tv5.js +0 -1
- package/apps/supervisor-web/dist/assets/lean-BZvkOJ9d.js +0 -1
- package/apps/supervisor-web/dist/assets/less-B1dDrJ26.js +0 -1
- package/apps/supervisor-web/dist/assets/light-plus-B7mTdjB0.js +0 -1
- package/apps/supervisor-web/dist/assets/liquid-DYVedYrR.js +0 -1
- package/apps/supervisor-web/dist/assets/llvm-DjAJT7YJ.js +0 -1
- package/apps/supervisor-web/dist/assets/log-2UxHyX5q.js +0 -1
- package/apps/supervisor-web/dist/assets/logo-BtOb2qkB.js +0 -1
- package/apps/supervisor-web/dist/assets/lua-BaeVxFsk.js +0 -1
- package/apps/supervisor-web/dist/assets/luau-C-HG3fhB.js +0 -1
- package/apps/supervisor-web/dist/assets/make-CHLpvVh8.js +0 -1
- package/apps/supervisor-web/dist/assets/markdown-vendor-C22AWDSP.js +0 -29
- package/apps/supervisor-web/dist/assets/marko-CnJfTvn9.js +0 -1
- package/apps/supervisor-web/dist/assets/material-theme-D5KoaKCx.js +0 -1
- package/apps/supervisor-web/dist/assets/material-theme-darker-BfHTSMKl.js +0 -1
- package/apps/supervisor-web/dist/assets/material-theme-lighter-B0m2ddpp.js +0 -1
- package/apps/supervisor-web/dist/assets/material-theme-ocean-CyktbL80.js +0 -1
- package/apps/supervisor-web/dist/assets/material-theme-palenight-Csfq5Kiy.js +0 -1
- package/apps/supervisor-web/dist/assets/matlab-D7o27uSR.js +0 -1
- package/apps/supervisor-web/dist/assets/mdc-BMNejdWA.js +0 -1
- package/apps/supervisor-web/dist/assets/mdx-Cmh6b_Ma.js +0 -1
- package/apps/supervisor-web/dist/assets/mermaid-mWjccvbQ.js +0 -1
- package/apps/supervisor-web/dist/assets/min-dark-CafNBF8u.js +0 -1
- package/apps/supervisor-web/dist/assets/min-light-CTRr51gU.js +0 -1
- package/apps/supervisor-web/dist/assets/mipsasm-CKIfxQSi.js +0 -1
- package/apps/supervisor-web/dist/assets/mojo-rZm6bMo-.js +0 -1
- package/apps/supervisor-web/dist/assets/monokai-D4h5O-jR.js +0 -1
- package/apps/supervisor-web/dist/assets/moonbit-_H4v1dQx.js +0 -1
- package/apps/supervisor-web/dist/assets/move-IF9eRakj.js +0 -1
- package/apps/supervisor-web/dist/assets/narrat-DRg8JJMk.js +0 -1
- package/apps/supervisor-web/dist/assets/nextflow-Zz6hmt5N.js +0 -1
- package/apps/supervisor-web/dist/assets/nextflow-groovy-BeH2EWoN.js +0 -1
- package/apps/supervisor-web/dist/assets/nginx-BpAMiNFr.js +0 -1
- package/apps/supervisor-web/dist/assets/night-owl-C39BiMTA.js +0 -1
- package/apps/supervisor-web/dist/assets/night-owl-light-CMTm3GFP.js +0 -1
- package/apps/supervisor-web/dist/assets/nim-CVrawwO9.js +0 -1
- package/apps/supervisor-web/dist/assets/nix-CwoSXNpI.js +0 -1
- package/apps/supervisor-web/dist/assets/nord-Ddv68eIx.js +0 -1
- package/apps/supervisor-web/dist/assets/nushell-Cz2AlsmD.js +0 -1
- package/apps/supervisor-web/dist/assets/objective-c-DXmwc3jG.js +0 -1
- package/apps/supervisor-web/dist/assets/objective-cpp-CLxacb5B.js +0 -1
- package/apps/supervisor-web/dist/assets/ocaml-C0hk2d4L.js +0 -1
- package/apps/supervisor-web/dist/assets/odin-BBf5iR-q.js +0 -1
- package/apps/supervisor-web/dist/assets/one-dark-pro-DVMEJ2y_.js +0 -1
- package/apps/supervisor-web/dist/assets/one-light-C3Wv6jpd.js +0 -1
- package/apps/supervisor-web/dist/assets/openscad-C4EeE6gA.js +0 -1
- package/apps/supervisor-web/dist/assets/pascal-D93ZcfNL.js +0 -1
- package/apps/supervisor-web/dist/assets/perl-C0TMdlhV.js +0 -1
- package/apps/supervisor-web/dist/assets/php-Dhbhpdrm.js +0 -1
- package/apps/supervisor-web/dist/assets/pkl-u5AG7uiY.js +0 -1
- package/apps/supervisor-web/dist/assets/plastic-3e1v2bzS.js +0 -1
- package/apps/supervisor-web/dist/assets/plsql-ChMvpjG-.js +0 -1
- package/apps/supervisor-web/dist/assets/po-BTJTHyun.js +0 -1
- package/apps/supervisor-web/dist/assets/poimandres-CS3Unz2-.js +0 -1
- package/apps/supervisor-web/dist/assets/polar-C0HS_06l.js +0 -1
- package/apps/supervisor-web/dist/assets/postcss-CXtECtnM.js +0 -1
- package/apps/supervisor-web/dist/assets/powerquery-CEu0bR-o.js +0 -1
- package/apps/supervisor-web/dist/assets/powershell-Dpen1YoG.js +0 -1
- package/apps/supervisor-web/dist/assets/prisma-Dd19v3D-.js +0 -1
- package/apps/supervisor-web/dist/assets/prolog-CbFg5uaA.js +0 -1
- package/apps/supervisor-web/dist/assets/proto-C7zT0LnQ.js +0 -1
- package/apps/supervisor-web/dist/assets/pug-CGlum2m_.js +0 -1
- package/apps/supervisor-web/dist/assets/puppet-BMWR74SV.js +0 -1
- package/apps/supervisor-web/dist/assets/purescript-CklMAg4u.js +0 -1
- package/apps/supervisor-web/dist/assets/qml-3beO22l8.js +0 -1
- package/apps/supervisor-web/dist/assets/qmldir-C8lEn-DE.js +0 -1
- package/apps/supervisor-web/dist/assets/qss-IeuSbFQv.js +0 -1
- package/apps/supervisor-web/dist/assets/r-Dspwwk_N.js +0 -1
- package/apps/supervisor-web/dist/assets/racket-BqYA7rlc.js +0 -1
- package/apps/supervisor-web/dist/assets/raku-DXvB9xmW.js +0 -1
- package/apps/supervisor-web/dist/assets/razor-Uh8Bk_45.js +0 -1
- package/apps/supervisor-web/dist/assets/react-vendor-5VdTO_Bg.js +0 -60
- package/apps/supervisor-web/dist/assets/red-bN70gL4F.js +0 -1
- package/apps/supervisor-web/dist/assets/reg-C-SQnVFl.js +0 -1
- package/apps/supervisor-web/dist/assets/regexp-CDVJQ6XC.js +0 -1
- package/apps/supervisor-web/dist/assets/rel-C3B-1QV4.js +0 -1
- package/apps/supervisor-web/dist/assets/riscv-BM1_JUlF.js +0 -1
- package/apps/supervisor-web/dist/assets/ron-D8l8udqQ.js +0 -1
- package/apps/supervisor-web/dist/assets/rose-pine-dawn-DHQR4-dF.js +0 -1
- package/apps/supervisor-web/dist/assets/rose-pine-moon-D4_iv3hh.js +0 -1
- package/apps/supervisor-web/dist/assets/rose-pine-qdsjHGoJ.js +0 -1
- package/apps/supervisor-web/dist/assets/rosmsg-BJDFO7_C.js +0 -1
- package/apps/supervisor-web/dist/assets/rst-BrH8l1NY.js +0 -1
- package/apps/supervisor-web/dist/assets/ruby-Dw2BHqvy.js +0 -1
- package/apps/supervisor-web/dist/assets/rust-B1yitclQ.js +0 -1
- package/apps/supervisor-web/dist/assets/sas-cz2c8ADy.js +0 -1
- package/apps/supervisor-web/dist/assets/sass-Cj5Yp3dK.js +0 -1
- package/apps/supervisor-web/dist/assets/scala-C151Ov-r.js +0 -1
- package/apps/supervisor-web/dist/assets/scheme-C98Dy4si.js +0 -1
- package/apps/supervisor-web/dist/assets/scss-OYdSNvt2.js +0 -1
- package/apps/supervisor-web/dist/assets/sdbl-DVxCFoDh.js +0 -1
- package/apps/supervisor-web/dist/assets/shaderlab-Dg9Lc6iA.js +0 -1
- package/apps/supervisor-web/dist/assets/shellsession-BADoaaVG.js +0 -1
- package/apps/supervisor-web/dist/assets/slack-dark-BthQWCQV.js +0 -1
- package/apps/supervisor-web/dist/assets/slack-ochin-DqwNpetd.js +0 -1
- package/apps/supervisor-web/dist/assets/smalltalk-BERRCDM3.js +0 -1
- package/apps/supervisor-web/dist/assets/snazzy-light-Bw305WKR.js +0 -1
- package/apps/supervisor-web/dist/assets/solarized-dark-DXbdFlpD.js +0 -1
- package/apps/supervisor-web/dist/assets/solarized-light-L9t79GZl.js +0 -1
- package/apps/supervisor-web/dist/assets/solidity-rGO070M0.js +0 -1
- package/apps/supervisor-web/dist/assets/soy-Brmx7dQM.js +0 -1
- package/apps/supervisor-web/dist/assets/sparql-rVzFXLq3.js +0 -1
- package/apps/supervisor-web/dist/assets/splunk-BtCnVYZw.js +0 -1
- package/apps/supervisor-web/dist/assets/ssh-config-_ykCGR6B.js +0 -1
- package/apps/supervisor-web/dist/assets/stata-BH5u7GGu.js +0 -1
- package/apps/supervisor-web/dist/assets/stylus-BEDo0Tqx.js +0 -1
- package/apps/supervisor-web/dist/assets/surrealql-Bq5Q-fJD.js +0 -1
- package/apps/supervisor-web/dist/assets/svelte-C_ipcX3V.js +0 -1
- package/apps/supervisor-web/dist/assets/swift-D82vCrfD.js +0 -1
- package/apps/supervisor-web/dist/assets/synthwave-84-CbfX1IO0.js +0 -1
- package/apps/supervisor-web/dist/assets/system-verilog-CnnmHF94.js +0 -1
- package/apps/supervisor-web/dist/assets/systemd-4A_iFExJ.js +0 -1
- package/apps/supervisor-web/dist/assets/talonscript-CkByrt1z.js +0 -1
- package/apps/supervisor-web/dist/assets/tasl-QIJgUcNo.js +0 -1
- package/apps/supervisor-web/dist/assets/tcl-dwOrl1Do.js +0 -1
- package/apps/supervisor-web/dist/assets/templ-P3uqSqPl.js +0 -1
- package/apps/supervisor-web/dist/assets/terraform-BETggiCN.js +0 -1
- package/apps/supervisor-web/dist/assets/tex-idrVyKtj.js +0 -1
- package/apps/supervisor-web/dist/assets/thread-ui-BEieA99i.css +0 -1
- package/apps/supervisor-web/dist/assets/thread-ui-LDojdlO_.js +0 -1997
- package/apps/supervisor-web/dist/assets/tokyo-night-hegEt444.js +0 -1
- package/apps/supervisor-web/dist/assets/ts-tags-zn1MmPIZ.js +0 -1
- package/apps/supervisor-web/dist/assets/tsv-B_m7g4N7.js +0 -1
- package/apps/supervisor-web/dist/assets/turtle-BsS91CYL.js +0 -1
- package/apps/supervisor-web/dist/assets/twig-DNn4PbVi.js +0 -1
- package/apps/supervisor-web/dist/assets/typespec-BGHnOYBU.js +0 -1
- package/apps/supervisor-web/dist/assets/typst-DHCkPAjA.js +0 -1
- package/apps/supervisor-web/dist/assets/ui-vendor-xVD8_rhm.js +0 -6
- package/apps/supervisor-web/dist/assets/v-BcVCzyr7.js +0 -1
- package/apps/supervisor-web/dist/assets/vala-CsfeWuGM.js +0 -1
- package/apps/supervisor-web/dist/assets/vb-D17OF-Vu.js +0 -1
- package/apps/supervisor-web/dist/assets/verilog-BQ8w6xss.js +0 -1
- package/apps/supervisor-web/dist/assets/vesper-DU1UobuO.js +0 -1
- package/apps/supervisor-web/dist/assets/vhdl-CeAyd5Ju.js +0 -1
- package/apps/supervisor-web/dist/assets/viml-CJc9bBzg.js +0 -1
- package/apps/supervisor-web/dist/assets/vitesse-black-Bkuqu6BP.js +0 -1
- package/apps/supervisor-web/dist/assets/vitesse-dark-D0r3Knsf.js +0 -1
- package/apps/supervisor-web/dist/assets/vitesse-light-CVO1_9PV.js +0 -1
- package/apps/supervisor-web/dist/assets/vue-DN_0RTcg.js +0 -1
- package/apps/supervisor-web/dist/assets/vue-html-AaS7Mt5G.js +0 -1
- package/apps/supervisor-web/dist/assets/vue-vine-CQOfvN7w.js +0 -1
- package/apps/supervisor-web/dist/assets/vyper-CDx5xZoG.js +0 -1
- package/apps/supervisor-web/dist/assets/wasm-CG6Dc4jp.js +0 -1
- package/apps/supervisor-web/dist/assets/wasm-MzD3tlZU.js +0 -1
- package/apps/supervisor-web/dist/assets/wenyan-BV7otONQ.js +0 -1
- package/apps/supervisor-web/dist/assets/wgsl-Dx-B1_4e.js +0 -1
- package/apps/supervisor-web/dist/assets/wikitext-BhOHFoWU.js +0 -1
- package/apps/supervisor-web/dist/assets/wit-5i3qLPDT.js +0 -1
- package/apps/supervisor-web/dist/assets/wolfram-lXgVvXCa.js +0 -1
- package/apps/supervisor-web/dist/assets/xml-sdJ4AIDG.js +0 -1
- package/apps/supervisor-web/dist/assets/xsl-CtQFsRM5.js +0 -1
- package/apps/supervisor-web/dist/assets/zenscript-DVFEvuxE.js +0 -1
- package/apps/supervisor-web/dist/assets/zig-VOosw3JB.js +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{j as e,u as es,d as nt,r,L as It,N as Os,e as cr,f as ur,b as io,B as co,h as mr,i as We,O as uo,k as mo,c as ho}from"./react-vendor-CgLzZcV4.js";import{u as Jt,a as ca,C as wn,f as ps,T as hr,A as po,b as fo,t as pr,E as xo,c as go,d as bo,e as vo,g as jo,L as yo,P as wo,h as No}from"./thread-ui-DldLSgqC.js";import{l as dt}from"./ui-vendor-CeKGesq3.js";import"./graph-vendor-DVPtkh3h.js";import"./terminal-vendor-B365Go3Z.js";import"./markdown-vendor-BQJfKm05.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))n(d);new MutationObserver(d=>{for(const o of d)if(o.type==="childList")for(const m of o.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&n(m)}).observe(document,{childList:!0,subtree:!0});function a(d){const o={};return d.integrity&&(o.integrity=d.integrity),d.referrerPolicy&&(o.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?o.credentials="include":d.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(d){if(d.ep)return;d.ep=!0;const o=a(d);fetch(d.href,o)}})();var So=["codex","claude","opencode"],Tt="codex",Pa={codex:{displayName:"Codex",description:"Local Codex app-server runtime.",defaultTransport:"stdio",homeEnvVar:"CODEX_HOME",commandEnvVar:"CODEX_COMMAND",defaultHomeDir:".codex",defaultCommand:"codex"},claude:{displayName:"Claude Code",description:"Local Claude Code Agent SDK runtime.",defaultTransport:"sdk",homeEnvVar:"CLAUDE_HOME",commandEnvVar:"CLAUDE_COMMAND",defaultHomeDir:".claude",defaultCommand:"claude"},opencode:{displayName:"OpenCode",description:"Local OpenCode runtime.",defaultTransport:"sdk",homeEnvVar:"OPENCODE_HOME",commandEnvVar:"OPENCODE_COMMAND",defaultHomeDir:".opencode",defaultCommand:"opencode"}};function ko(t){return typeof t=="string"&&So.includes(t)}function Co(t){return ko(t)?t:null}var Aa=15;function To(t){return t.replace(/\s+/g," ").trim()}function Io(t){const s=To(t);if(!s)return"";const a=Array.from(s);return a.length<=Aa?s:`${a.slice(0,Aa).join("")}...`}const Eo=["codex","claude","opencode"],fr="codex",xr={codex:{displayName:"Codex",description:"Local Codex app-server runtime.",defaultTransport:"stdio",homeEnvVar:"CODEX_HOME",commandEnvVar:"CODEX_COMMAND",defaultHomeDir:".codex",defaultCommand:"codex"},claude:{displayName:"Claude Code",description:"Local Claude Code Agent SDK runtime.",defaultTransport:"sdk",homeEnvVar:"CLAUDE_HOME",commandEnvVar:"CLAUDE_COMMAND",defaultHomeDir:".claude",defaultCommand:"claude"},opencode:{displayName:"OpenCode",description:"Local OpenCode runtime.",defaultTransport:"sdk",homeEnvVar:"OPENCODE_HOME",commandEnvVar:"OPENCODE_COMMAND",defaultHomeDir:".opencode",defaultCommand:"opencode"}},Ua=15;function Ro(t){return t.replace(/\s+/g," ").trim()}function Po(t){const s=Ro(t);if(!s)return"";const a=Array.from(s);return a.length<=Ua?s:`${a.slice(0,Ua).join("")}...`}class re extends Error{constructor(s,a){super(a.message),this.statusCode=s,this.payload=a}}const Qn="remote-codex-auth-token",ea="remote-codex-relay-token",gr="remote-codex-relay-mode",ta="remote-codex-relay-device-id",sa="remote-codex-relay-thread-id";function br(){return typeof window>"u"?null:window.localStorage.getItem(Qn)}function Ao(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(Qn,t);return}window.localStorage.removeItem(Qn)}}function vr(){return typeof window>"u"?null:window.localStorage.getItem(ea)}function ua(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(ea,t);return}window.localStorage.removeItem(ea)}}function fs(){var t;return typeof window>"u"?!1:((t=window.__REMOTE_CODEX_BOOTSTRAP__)==null?void 0:t.mode)==="relay"||window.location.pathname.startsWith("/relay-portal")||window.location.pathname.startsWith("/relay-admin")||window.location.search.includes("relay=1")||window.localStorage.getItem(gr)==="true"}function xs(){typeof window>"u"||window.localStorage.setItem(gr,"true")}function na(){return fs()}function jr(){return typeof window>"u"?null:window.localStorage.getItem(ta)}function bn(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(ta,t);return}window.localStorage.removeItem(ta)}}function Uo(){return typeof window>"u"?null:window.localStorage.getItem(sa)}function vn(t){if(!(typeof window>"u")){if(t){window.localStorage.setItem(sa,t);return}window.localStorage.removeItem(sa)}}function yr(t){if(!fs())return t;if(t.startsWith("/api/")){const s=jr();return s?`/relay/devices/${encodeURIComponent(s)}${t}`:`/relay${t}`}return t}function Oo(t){return t===400?"bad_request":t===401?"unauthorized":t===403?"forbidden":t===404?"not_found":t===409?"conflict":t===429||t===503?"service_unavailable":"internal_error"}function $o(t,s){const a=s==null?void 0:s.trim(),n=a?`${t} ${a}`:`${t}`;return t===429?`Too many requests (${n}).`:t===503?`Upstream service unavailable (${n}).`:`Request failed (${n}).`}function cs(t,s,a){const n=typeof(s==null?void 0:s.message)=="string"&&s.message.trim()?s.message.trim():a,d=s!=null&&s.details&&typeof s.details=="object"?s.details:void 0;return{code:(s==null?void 0:s.code)??Oo(t.status),message:n,...d?{details:d}:{}}}async function wr(t){var d,o;const s=$o(t.status,t.statusText),a=((o=(d=t.headers)==null?void 0:d.get)==null?void 0:o.call(d,"content-type"))??"",n=async()=>cs(t,await t.json(),s);if(a.includes("application/json"))try{return await n()}catch{return cs(t,null,s)}try{if(typeof t.text!="function")try{return await n()}catch{return cs(t,null,s)}const m=(await t.text()).trim();if(m.startsWith("{"))try{return cs(t,JSON.parse(m),s)}catch{}return cs(t,m?{message:`${s}
|
|
2
|
+
${m}`}:null,s)}catch{try{return await n()}catch{return cs(t,null,s)}}}async function U(t,s){const a=new Headers(s==null?void 0:s.headers);(s==null?void 0:s.body)!==void 0&&!(s.body instanceof FormData)&&!a.has("Content-Type")&&a.set("Content-Type","application/json");const n=await fetch(yr(String(t)),Sr({...s,headers:a}));if(!n.ok){const d=await wr(n);throw new re(n.status,d)}return await n.json()}function Mo(t){const s=String(t);return s.includes("/exports/pdf")?s.includes("format=html")?"remote-codex-transcript.html":"remote-codex-transcript.pdf":"download"}function Lo(t){var d;if(!t)return null;const s=t.match(/filename\*=UTF-8''([^;]+)/i);if(s!=null&&s[1])try{return decodeURIComponent(s[1].trim())}catch{return s[1].trim()}const a=t.match(/filename="([^"]+)"/i);if(a!=null&&a[1])return a[1].trim();const n=t.match(/filename=([^;]+)/i);return((d=n==null?void 0:n[1])==null?void 0:d.trim())??null}async function Nr(t,s){const a=await fetch(yr(String(t)),Sr(s));if(!a.ok){const d=await wr(a);throw new re(a.status,d)}const n=Lo(a.headers.get("content-disposition"))??Mo(t);return{blob:await a.blob(),filename:n}}function Sr(t={}){const s=new Headers(t.headers),a=vr(),n=br();return fs()&&a&&!s.has("Authorization")?s.set("Authorization",`Bearer ${a}`):n&&!s.has("Authorization")&&s.set("Authorization",`Bearer ${n}`),{...t,credentials:t.credentials??"same-origin",headers:s}}function Do(t,s){return`${t.baseUrl.replace(/\/+$/,"")}${s}`}function Ho(t,s){const a=new Headers(s==null?void 0:s.headers);return a.set("Authorization",`Bearer ${t.token}`),a}async function Se(t,s,a){return U(Do(t,s),{...a,headers:Ho(t,a)})}function ma(t,s){return`${t.replace(/\/+$/,"")}${s}`}function _o(t,s,a=typeof window>"u"?void 0:window.location.href){const n=new URL(ma(t,`/api/auth/oauth/${s}/start`));return a&&n.searchParams.set("returnTo",a),n.toString()}function Bo(t,s){return U(ma(t,"/api/auth/password/register"),{method:"POST",body:JSON.stringify(s)})}function Fo(t,s){return U(ma(t,"/api/auth/password/login"),{method:"POST",body:JSON.stringify(s)})}function ha(t){return Se(t,"/api/me",{cache:"no-store"})}function Wo(t,s=10){const a=new URLSearchParams({limit:String(s)});return Se(t,`/api/usage/events?${a.toString()}`,{cache:"no-store"})}function qo(t){return Se(t,"/api/usage/harness/summary",{cache:"no-store"})}function zo(t,s=10){const a=new URLSearchParams({limit:String(s)});return Se(t,`/api/usage/harness/events?${a.toString()}`,{cache:"no-store"})}function Vo(t,s){return Se(t,"/api/me",{method:"PATCH",body:JSON.stringify(s)})}function kr(t){return Se(t,"/api/projects",{cache:"no-store"})}function Jo(t,s){return Se(t,"/api/projects",{method:"POST",body:JSON.stringify(s)})}function Go(t,s,a){return Se(t,`/api/projects/${encodeURIComponent(s)}`,{method:"PATCH",body:JSON.stringify(a)})}function Ko(t,s){return Se(t,`/api/projects/${encodeURIComponent(s)}`,{method:"DELETE"})}function aa(t,s){const a=s?`?projectId=${encodeURIComponent(s)}`:"";return Se(t,`/api/workspaces${a}`,{cache:"no-store"})}function Yo(t,s){const a=s.projectId?`/api/projects/${encodeURIComponent(s.projectId)}/workspaces`:"/api/workspaces",n=s.projectId?{name:s.name,slug:s.slug}:s;return Se(t,a,{method:"POST",body:JSON.stringify(n)})}function Oa(t,s,a){return Se(t,`/api/workspaces/${encodeURIComponent(s)}`,{method:"PATCH",body:JSON.stringify(a)})}function ra(t,s){return Se(t,`/api/workspaces/${encodeURIComponent(s)}/sessions`,{cache:"no-store"})}function Zo(t,s,a){return Se(t,`/api/workspaces/${encodeURIComponent(s)}/sessions`,{method:"POST",body:JSON.stringify(a)})}function $a(t,s,a){return Se(t,`/api/sessions/${encodeURIComponent(s)}`,{method:"PATCH",body:JSON.stringify(a)})}function Xo(t,s){return Se(t,`/api/sessions/${encodeURIComponent(s)}/close`,{method:"POST"})}function Cr(t,s){return Se(t,`/api/sessions/${encodeURIComponent(s)}/resume`,{method:"POST"})}function Qo(t){return Se(t,"/api/sandbox/start",{method:"POST"})}function el(t){return Se(t,"/api/sandbox/stop",{method:"POST"})}function tl(t){return Se(t,"/api/sandbox/restart",{method:"POST"})}function Ma(t){return Se(t,"/api/sandbox/health",{cache:"no-store"})}function sl(t){return Se(t,"/api/sandbox/harness/status",{cache:"no-store"})}function La(t,s){return Se(t,`/api/sandbox/harness/modules/${encodeURIComponent(s)}/tools`,{cache:"no-store"})}function Da(t,s){return Se(t,`/api/sandbox/harness/modules/${encodeURIComponent(s)}/runs`,{cache:"no-store"})}function nl(t,s){return Se(t,`/api/admin/sandboxes/${encodeURIComponent(s)}`,{cache:"no-store"})}function Tr(t,s,a){return Se(t,`/api/sandboxes/${encodeURIComponent(s)}/route-token`,{method:"POST",body:JSON.stringify(a)})}function Nn(t,s,a){const n=s.replace(/^\/+/,""),d=new URL(`/api/sandboxes/${encodeURIComponent(t.sandboxId)}/${n}`,t.routerBaseUrl);for(const[o,m]of Object.entries(a??{}))m!=null&&d.searchParams.set(o,String(m));return d.toString()}function Sn(t,s){const a=new Headers(s==null?void 0:s.headers);return a.set("Authorization",`Bearer ${t.token}`),a}function us(t,s,a={}){return U(Nn(t,`/api/threads/${encodeURIComponent(s)}`,a),{cache:"no-store",headers:Sn(t)})}function al(t,s,a){return U(Nn(t,`/api/threads/${encodeURIComponent(s)}/items/${encodeURIComponent(a)}/detail`),{cache:"no-store",headers:Sn(t)})}function $n(t,s,a){return U(Nn(t,`/api/threads/${encodeURIComponent(s)}/prompt`),{method:"POST",body:JSON.stringify(a),headers:Sn(t)})}function Ha(t,s,a={}){return U(Nn(t,`/api/threads/${encodeURIComponent(s)}/interrupt`),{method:"POST",body:JSON.stringify(a),headers:Sn(t)})}function _a(t,s){const a=t.originalName.trim();if(a)return a;const n=t.file.name.trim();return n||(t.kind==="photo"?`photo-${s+1}.jpg`:`file-${s+1}`)}function rl(){return U("/api/config/runtime")}function ol(){return U("/api/auth/session",{cache:"no-store"})}async function ll(t){const s=await U("/api/auth/login",{method:"POST",body:JSON.stringify(t)});return Ao(s.token??null),s}function $s(){return U("/relay/auth/session",{credentials:"same-origin"})}async function il(t){xs();const s=await U("/relay/auth/login",{method:"POST",body:JSON.stringify(t)});return ua(s.token),s}async function dl(t){xs();const s=await U("/relay/auth/register",{method:"POST",body:JSON.stringify(t)});return ua(s.token),s}async function Ir(){const t=await U("/relay/auth/logout",{method:"POST"});return ua(null),bn(null),vn(null),t}function Er(){return U("/relay/portal")}function Rr(t){return U("/relay/devices",{method:"POST",body:JSON.stringify(t)})}function Pr(t){return U(`/relay/devices/${encodeURIComponent(t)}`,{method:"DELETE"})}function cl(t){return U("/relay/account",{method:"PATCH",body:JSON.stringify(t)})}function ul(t){return U("/relay/account/password",{method:"PATCH",body:JSON.stringify(t)})}function ml(t){return U("/relay/shares",{method:"POST",body:JSON.stringify(t)})}function hl(t){return U(`/relay/shares/${encodeURIComponent(t)}`,{method:"DELETE"})}function pl(){return U("/relay/admin")}function fl(t){return U("/relay/admin/settings/registration",{method:"PATCH",body:JSON.stringify({enabled:t})})}function xl(t,s){return U(`/relay/admin/users/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({enabled:s})})}function gl(){return U("/api/config/workspace-settings",{cache:"no-store"})}function bl(t){return U("/api/config/workspace-settings",{method:"PATCH",body:JSON.stringify(t)})}function pa(){return U("/api/agent-runtimes",{cache:"no-store"})}function Ar(t){return U(`/api/agent-runtimes/${encodeURIComponent(t)}/status`,{cache:"no-store"})}function vl(t){return U(`/api/agent-runtimes/${encodeURIComponent(t)}/restart`,{method:"POST"})}function jl(t,s){return U(`/api/agent-runtimes/${encodeURIComponent(t)}/install`,{method:"POST",body:JSON.stringify({action:s})})}function oa(t){return U(`/api/agent-runtimes/${encodeURIComponent(t)}/models`,{cache:"no-store"})}function Ur(t,s){return U(`/api/config/providers/${encodeURIComponent(t)}/files/${encodeURIComponent(s)}`,{cache:"no-store"})}function Or(t,s,a){return U(`/api/config/providers/${encodeURIComponent(t)}/files/${encodeURIComponent(s)}`,{method:"PATCH",body:JSON.stringify(a)})}function yl(t){return U(`/api/config/providers/${encodeURIComponent(t)}/archives`,{cache:"no-store"})}function wl(t,s={}){return U(`/api/config/providers/${encodeURIComponent(t)}/archives`,{method:"POST",body:JSON.stringify(s)})}function Nl(t,s,a){return U(`/api/config/providers/${encodeURIComponent(t)}/archives/${encodeURIComponent(s)}`,{method:"PATCH",body:JSON.stringify(a)})}function Sl(t,s){return U(`/api/config/providers/${encodeURIComponent(t)}/archives/${encodeURIComponent(s)}/apply`,{method:"POST"})}function kl(){return U("/api/service/build-restart",{method:"POST"})}function Cl(){return U("/healthz",{cache:"no-store"})}function fa(){return U("/api/workspaces")}function Tl(t){return U(`/api/workspaces/${encodeURIComponent(t)}/files/tree`,{cache:"no-store"})}function Il(t,s){const a=new URLSearchParams({path:s.path});return s.offset!==void 0&&a.set("offset",String(s.offset)),s.limit!==void 0&&a.set("limit",String(s.limit)),U(`/api/workspaces/${encodeURIComponent(t)}/files/preview?${a.toString()}`,{cache:"no-store"})}function El(t,s){const a=new URLSearchParams({path:s.path});return`/api/workspaces/${encodeURIComponent(t)}/files/raw?${a.toString()}`}function Rl(t,s){const a=new URLSearchParams({path:s.path});return Nr(`/api/workspaces/${encodeURIComponent(t)}/files/download?${a.toString()}`,{cache:"no-store"})}function Pl(t,s){const a=new FormData;return a.append("file",s.file,s.file.name),U(`/api/workspaces/${encodeURIComponent(t)}/files/upload`,{method:"POST",body:a})}function $r(){return U("/api/threads")}function Ba(t,s={}){const a=new URLSearchParams;return s.limit!==void 0&&a.set("limit",String(s.limit)),s.beforeTurnId&&a.set("beforeTurnId",s.beforeTurnId),U(`/api/threads/${t}${a.size>0?`?${a.toString()}`:""}`)}function Al(t,s){return U(`/api/threads/${t}/items/${encodeURIComponent(s)}/detail`)}function Ul(){return U("/api/plugins",{cache:"no-store"})}function Ol(t){return U("/api/plugins/import",{method:"POST",body:JSON.stringify(t)})}function $l(t,s){return U(`/api/plugins/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(s)})}function Ml(t){return U(`/api/plugins/${encodeURIComponent(t)}`,{method:"DELETE"})}function Ll(t){return U(`/api/threads/${t}/export-turns`,{cache:"no-store"})}function Dl(t,s){var n,d,o;const a=new URLSearchParams;return s.format!==void 0&&a.set("format",s.format),a.set("mode",s.mode),s.limit!==void 0&&a.set("limit",String(s.limit)),s.turnIds!==void 0&&a.set("turnIds",s.turnIds.join(",")),s.profile!==void 0&&a.set("profile",s.profile),((n=s.options)==null?void 0:n.includeTokenAndPrice)!==void 0&&a.set("includeTokenAndPrice",String(s.options.includeTokenAndPrice)),((d=s.options)==null?void 0:d.includeCommandOutput)!==void 0&&a.set("includeCommandOutput",String(s.options.includeCommandOutput)),((o=s.options)==null?void 0:o.includeAbsolutePaths)!==void 0&&a.set("includeAbsolutePaths",String(s.options.includeAbsolutePaths)),`/api/threads/${encodeURIComponent(t)}/exports/pdf?${a.toString()}`}function Hl(t,s){return Nr(Dl(t,s),{cache:"no-store"})}function _l(t){return U(`/api/threads/${t}/shell`)}function Bl(t){return U("/api/threads/start",{method:"POST",body:JSON.stringify(t)})}function Fl(t){return U("/api/threads/import",{method:"POST",body:JSON.stringify(typeof t=="string"?{sessionId:t}:t)})}function Wl(t,s={}){return U(`/api/threads/${t}/shell`,{method:"POST",...Object.keys(s).length>0?{body:JSON.stringify(s)}:{}})}function ql(t){return U(`/api/shells/${t}/terminate`,{method:"POST"})}function zl(t,s){return U(`/api/shells/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function Fa(t,s={}){return U(`/api/threads/${t}/resume`,{method:"POST",...Object.keys(s).length>0?{body:JSON.stringify(s)}:{}})}function Vl(t){return U(`/api/threads/${t}/disconnect`,{method:"POST"})}function Jl(t,s){const a=s.attachments??[];if(a.length===0)return U(`/api/threads/${t}/prompt`,{method:"POST",body:JSON.stringify(s)});const n=new FormData;n.append("prompt",s.prompt),s.clientRequestId!==void 0&&n.append("clientRequestId",s.clientRequestId),s.model!==void 0&&n.append("model",s.model),s.reasoningEffort!==void 0&&s.reasoningEffort!==null&&n.append("reasoningEffort",s.reasoningEffort),s.collaborationMode!==void 0&&n.append("collaborationMode",s.collaborationMode),s.sandboxMode!==void 0&&s.sandboxMode!==null&&n.append("sandboxMode",s.sandboxMode);const d=a.map((o,m)=>({clientId:o.clientId,kind:o.kind,originalName:_a(o,m),placeholder:o.placeholder}));n.append("attachmentManifest",JSON.stringify(d));for(const[o,m]of a.entries())n.append("attachments",m.file,_a(m,o));return U(`/api/threads/${t}/prompt`,{method:"POST",body:n})}function Wa(t,s={}){return U(`/api/threads/${t}/interrupt`,{method:"POST",body:JSON.stringify(s)})}function Mr(t,s){return U(`/api/threads/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function Lr(t){return U(`/api/threads/${t}`,{method:"DELETE"})}function Gl(t,s){return U(`/api/threads/${t}/settings`,{method:"PATCH",body:JSON.stringify(s)})}function Kl(t){return U(`/api/threads/${t}/compact`,{method:"POST"})}function Yl(t){return U(`/api/threads/${t}/goal`,{cache:"no-store"})}function Zl(t,s){return U(`/api/threads/${t}/goal`,{method:"PATCH",body:JSON.stringify(s)})}function Xl(t){return U(`/api/threads/${t}/goal`,{method:"DELETE"})}function Ql(t){return U(`/api/threads/${t}/fork-turns`,{cache:"no-store"})}function qa(t,s){return U(`/api/threads/${t}/fork`,{method:"POST",body:JSON.stringify(s)})}function ei(t){return U(`/api/threads/${t}/skills`,{cache:"no-store"})}function ti(t){return U(`/api/threads/${t}/mcp-servers`,{cache:"no-store"})}function si(t){return U(`/api/threads/${t}/hooks`,{cache:"no-store"})}function ni(t,s){return U(`/api/threads/${t}/hooks`,{method:"POST",body:JSON.stringify(s)})}function ai(t,s){return U(`/api/threads/${t}/hooks`,{method:"PUT",body:JSON.stringify(s)})}function ri(t,s){return U(`/api/threads/${t}/hooks/trust`,{method:"POST",body:JSON.stringify(s)})}function oi(t,s){return U(`/api/threads/${t}/hooks/untrust`,{method:"POST",body:JSON.stringify(s)})}function li(t,s,a){return U(`/api/threads/${t}/requests/${encodeURIComponent(s)}/respond`,{method:"POST",body:JSON.stringify(a)})}function ii(t){return U("/api/workspaces",{method:"POST",body:JSON.stringify(t)})}function di(t,s){return U(`/api/workspaces/${t}`,{method:"PATCH",body:JSON.stringify(s)})}function ci(t){return U(`/api/workspaces/${t}`,{method:"DELETE"})}function ui(t,s){return U(`/api/workspaces/${t}/favorite`,{method:"POST",body:JSON.stringify(s)})}function Dr(t){const s=window.location.protocol==="https:"?"wss:":"ws:",a=new WebSocket(Hr(s));return a.addEventListener("message",n=>{try{const d=JSON.parse(n.data);hi(d)&&t(d)}catch{}}),a}function mi(t={}){const s=window.location.protocol==="https:"?"wss:":"ws:",a=new WebSocket(Hr(s));return a.addEventListener("message",n=>{var d,o;try{const m=JSON.parse(n.data);if(m.type==="supervisor.connected"){(d=t.onConnected)==null||d.call(t,m);return}pi(m)&&((o=t.onShellEvent)==null||o.call(t,m))}catch{}}),{socket:a,send(n){a.send(JSON.stringify(n))}}}function Hr(t){const s=new URL(`${t}//${window.location.host}/ws`);if(fs()){const o=jr();s.pathname=o?`/relay/devices/${encodeURIComponent(o)}/ws`:"/relay/ws"}const a=br(),n=vr(),d=Uo();return fs()&&n&&s.searchParams.set("relaySession",n),fs()&&d&&s.searchParams.set("threadId",d),a&&s.searchParams.set("token",a),s.toString()}function hi(t){return"threadId"in t&&t.type.startsWith("thread.")&&typeof t.payload=="object"&&t.payload!==null}function pi(t){return"shellId"in t&&t.type.startsWith("shell.")&&typeof t.payload=="object"&&t.payload!==null}function fi(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:e.jsx("path",{d:"M2 3.25h12v1.5H2Zm0 4h12v1.5H2Zm0 4h12v1.5H2Z"})})}function fn(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:e.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})}function Mn(t=!1){return`flex w-full items-center rounded-[0.95rem] px-3 py-2 text-left text-sm transition ${t?"cursor-not-allowed bg-[var(--theme-muted)] text-[var(--theme-fg-muted)]":"text-[var(--theme-fg)] hover:bg-[var(--theme-hover)]"}`}const xi=[{value:"light",label:"Light",description:"Always use the bright theme."},{value:"dark",label:"Dark",description:"Always use the dark theme."},{value:"system",label:"System",description:"Follow the operating system appearance."}],_r={hostConfigFiles:[],toolboxItems:[],hookCommandTemplates:[],providerConfigFormat:"none",mcpConfigFormat:"none",configArchives:!1,buildRestart:!1},gi={codex:{packageName:"@openai/codex",installCommand:null,updateCommand:"npm install -g @openai/codex@latest"},claude:{packageName:"@anthropic-ai/claude-agent-sdk",installCommand:"npm install -g @anthropic-ai/claude-code @anthropic-ai/claude-agent-sdk",updateCommand:"npm install -g @anthropic-ai/claude-code@latest @anthropic-ai/claude-agent-sdk@latest"},opencode:{packageName:"opencode-ai",installCommand:"npm install -g opencode-ai @opencode-ai/sdk",updateCommand:"npm install -g opencode-ai@latest @opencode-ai/sdk@latest"}};function la(t){const s=gi[t];return{packageName:s.packageName,installed:t==="codex",installedVersion:null,latestVersion:null,installCommand:s.installCommand,updateCommand:s.updateCommand,busy:!1,lastError:null}}function bi(t,s){return{provider:t,displayName:s,description:`${s} backend descriptor is not available.`,enabled:!1,isDefault:t===fr,status:{state:"stopped",transport:xr[t].defaultTransport,lastStartedAt:null,lastError:"Backend descriptor is not available.",restartCount:0},capabilities:{sessions:{list:!1,read:!1,resume:!1,importLocal:!1},turns:{start:!1,streamInput:!1,steer:!1,interrupt:!1,compact:!1},branching:{fork:!1,hardRollback:!1,resumeAt:!1,rewindFiles:!1},controls:{planMode:!1,permissionRequests:!1,sandboxMode:!1,performanceMode:!1,goals:!1},management:{models:!1,mcpStatus:!1,skills:!1,hooks:!1,hookTrust:!1,hostConfigFiles:!1,providerSettings:!1},usage:{contextWindow:!1,tokenUsage:!1,costUsd:!1}},managementSchema:_r,installation:la(t)}}function Ln(t){const s=t.installation??la(t.provider);return{...t,installation:{...la(t.provider),...s}}}const hs=[...Eo.map(t=>bi(t,xr[t].displayName))];function vi(t){var s;return((s=hs.find(a=>a.provider===t))==null?void 0:s.managementSchema)??_r}function ji(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function yi(t){const s=t.payload.details,a=typeof(s==null?void 0:s.stderr)=="string"&&s.stderr.trim()?s.stderr.trim():typeof(s==null?void 0:s.stdout)=="string"&&s.stdout.trim()?s.stdout.trim():null;return a?`${t.message}
|
|
3
|
+
${a}`:t.message}function Es(t){return{path:t,exists:!1,originalContent:"",draftContent:"",loading:!1,saving:!1,error:null,saveMessage:null}}function Br({className:t=""}){const s=Jt();return s?e.jsx("button",{type:"button","aria-label":s.navOpen?"Close Navigation":"Open Navigation","aria-expanded":s.navOpen,"aria-controls":"app-shell-navigation-menu",onClick:s.toggleNav,className:`inline-flex h-10 w-10 shrink-0 items-center justify-center text-[var(--theme-fg)] transition hover:text-[var(--theme-fg-soft)] ${t}`.trim(),children:s.navOpen?e.jsx(fn,{}):e.jsx(fi,{})}):null}function Fr({className:t=""}){const s=Jt(),a=es(),n=nt(),d=r.useRef(null),o=a.pathname==="/workspaces",m=a.pathname==="/threads/import";return r.useEffect(()=>{if(!(s!=null&&s.navOpen))return;const h=s;function g(b){const E=b.target;if(!E)return;const x=d.current;x!=null&&x.contains(E)||E instanceof Element&&E.closest('[aria-controls="app-shell-navigation-menu"]')||h.closeNav()}return document.addEventListener("pointerdown",g),()=>{document.removeEventListener("pointerdown",g)}},[s]),s!=null&&s.navOpen?e.jsxs("div",{ref:d,id:"app-shell-navigation-menu",onPointerDown:h=>{h.stopPropagation()},onMouseDown:h=>{h.stopPropagation()},onTouchStart:h=>{h.stopPropagation()},className:`rounded-[1.8rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4 shadow-2xl shadow-black/15 backdrop-blur ${t}`.trim(),children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-semibold tracking-wide text-[var(--theme-accent-strong)]",children:"Remote Codex"}),e.jsx("p",{className:"mt-1 text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Navigation"})]}),e.jsxs("nav",{className:"mt-4 flex flex-col gap-1.5 text-sm",children:[e.jsx("button",{type:"button",disabled:o,onClick:()=>{o||(s.closeNav(),n("/workspaces"))},className:Mn(o),children:"Workspaces"}),e.jsx("button",{type:"button",disabled:m,onClick:()=>{m||(s.closeNav(),n("/threads/import"))},className:Mn(m),children:"Import Session"}),e.jsx("button",{type:"button",onClick:()=>{s.openSettings()},className:Mn(),children:"Settings"})]})]}):null}function xa({embedded:t=!1}={}){const s=Jt(),a=ca(),[n,d]=r.useState(""),[o,m]=r.useState({busy:!1,message:null,error:null}),[h,g]=r.useState(!1),[b,E]=r.useState(null),[x,p]=r.useState({}),k=b?x[b]:null,[T,A]=r.useState({busy:!1,message:null,error:null}),[v,D]=r.useState([]),[Z,q]=r.useState(hs),[_,ne]=r.useState({loading:!1,saving:!1,error:null,operatingProvider:null,operatingAction:null,message:null}),[c,F]=r.useState(null),[ae,I]=r.useState({devHomeDraft:"",loading:!1,saving:!1,message:null,error:null}),[z,B]=r.useState({loading:!1,creating:!1,applyingId:null,renamingId:null,renameDraft:"",message:null,error:null}),ge=(s==null?void 0:s.themeMode)??"system",pe=t||!!(s!=null&&s.settingsOpen);async function H(){const j=n.trim();if(!(!j||o.busy)){m({busy:!0,message:null,error:null});try{await a.importPluginManifest({manifestJson:j,enabled:!0}),d(""),m({busy:!1,message:"Plugin manifest imported.",error:null})}catch(w){m({busy:!1,message:null,error:w instanceof Error?w.message:"Unable to import plugin manifest."})}}}const me=(s==null?void 0:s.effectiveTheme)??"dark",C=(s==null?void 0:s.defaultBackend)??fr,le=a.plugins.filter(j=>j.enabled).length,oe=a.loading?"Loading...":`${le}/${a.plugins.length} enabled`,$=Z.find(j=>j.provider===C)??hs.find(j=>j.provider===C)??hs[0],K=$.managementSchema??vi($.provider),W=K.hostConfigFiles;r.useEffect(()=>{if(!pe||t||!s||!K.configArchives)return;const j=s;function w(R){R.key==="Escape"&&j.closeSettings()}return window.addEventListener("keydown",w),()=>{window.removeEventListener("keydown",w)}},[K.configArchives,t,pe,s]),r.useEffect(()=>{if(!pe)return;let j=!1;return ne(w=>({...w,loading:!0,error:null})),pa().then(w=>{if(j)return;const R=[...w.map(Ln),...hs.filter(X=>!w.some(ve=>ve.provider===X.provider))];q(R),ne(X=>({...X,loading:!1}))}).catch(w=>{j||(q(hs),ne(R=>({...R,loading:!1,error:w instanceof re?w.message:"Unable to load backend settings."})))}),()=>{j=!0}},[pe]),r.useEffect(()=>{if(!pe)return;let j=!1;return I(w=>({...w,loading:!0,message:null,error:null})),gl().then(w=>{j||(F(w),I(R=>({...R,devHomeDraft:w.devHome,loading:!1})))}).catch(w=>{j||I(R=>({...R,loading:!1,error:w instanceof re?w.message:"Unable to load workspace settings."}))}),()=>{j=!0}},[pe]),r.useEffect(()=>{if(!pe||!$.capabilities.management.hostConfigFiles)return;let j=!1;async function w(){p(X=>{const ve={...X};for(const Pe of W)ve[Pe.name]={...Es(Pe.name),...X[Pe.name],loading:!0,saving:!1,error:null,saveMessage:null};return ve});const R=await Promise.allSettled(W.map(async X=>({name:X.name,result:await Ur($.provider,X.name)})));j||p(X=>{var Pe,ht;const ve={...X};for(const Ae of R){if(Ae.status==="fulfilled"){const{name:rt,result:Ke}=Ae.value;ve[rt]={path:Ke.path,exists:Ke.exists,originalContent:Ke.content,draftContent:Ke.content,loading:!1,saving:!1,error:null,saveMessage:null};continue}const wt=Ae.reason instanceof re?Ae.reason.message:"Unable to load the file.",Ge=((Pe=W[R.indexOf(Ae)])==null?void 0:Pe.name)??((ht=W[0])==null?void 0:ht.name);Ge&&(ve[Ge]={...Es(Ge),...ve[Ge],loading:!1,saving:!1,error:wt,saveMessage:null})}return ve})}return w(),()=>{j=!0}},[$.capabilities.management.hostConfigFiles,$.provider,W,pe]),r.useEffect(()=>{if(!pe)return;let j=!1;async function w(){B(R=>({...R,loading:!0,error:null,message:null}));try{const R=await yl($.provider);if(j)return;D(R),B(X=>({...X,loading:!1}))}catch(R){if(j)return;B(X=>({...X,loading:!1,error:R instanceof re?R.message:"Unable to load config archives."}))}}return w(),()=>{j=!0}},[$.provider,K.configArchives,pe]);async function be(){if(!(T.busy||_.saving)){A({busy:!0,message:null,error:null});try{const j=await vl($.provider),w=Ln(j);A({busy:!1,message:w.status.state==="ready"?`${w.displayName} backend restarted.`:`${w.displayName} backend state: ${w.status.state}`,error:null}),q(R=>R.map(X=>X.provider===w.provider?w:X))}catch(j){A({busy:!1,message:null,error:j instanceof re?j.message:"Unable to restart the app server."})}}}async function fe(j,w){if(T.busy||_.saving)return;const R=Z.find(X=>X.provider===j);ne(X=>({...X,saving:!0,operatingProvider:j,operatingAction:w,message:null,error:null}));try{const X=await jl(j,w),ve=Ln(X);q(Pe=>Pe.map(ht=>ht.provider===ve.provider?ve:ht)),ne(Pe=>({...Pe,saving:!1,operatingProvider:null,operatingAction:null,message:ve.installation.lastError?`${ve.displayName} ${w==="install"?"installed":"updated"}, but requires attention:
|
|
4
|
+
${ve.installation.lastError}`:`${ve.displayName} ${w==="install"?"installed":"updated"}.`,error:null}))}catch(X){ne(ve=>({...ve,saving:!1,operatingProvider:null,operatingAction:null,message:null,error:X instanceof re?yi(X):`Unable to ${w} ${(R==null?void 0:R.displayName)??j}.`}))}}async function at(){if(!(T.busy||_.saving)){A({busy:!0,message:null,error:null});try{await kl(),A({busy:!1,message:"Build and restart launched. The page may disconnect briefly.",error:null})}catch(j){A({busy:!1,message:null,error:j instanceof re?j.message:"Unable to launch build and restart."})}}}async function ct(){const j=ae.devHomeDraft.trim();if(!(!j||ae.saving)){I(w=>({...w,saving:!0,message:null,error:null}));try{const w=await bl({devHome:j});F(w),I(R=>({...R,devHomeDraft:w.devHome,saving:!1,message:"Workspace defaults saved."}))}catch(w){I(R=>({...R,saving:!1,error:w instanceof re?w.message:"Unable to save workspace settings."}))}}}async function Ye(j){const w=x[j];if(!(!w||w.saving)){p(R=>({...R,[j]:{...Es(j),...R[j],saving:!0,error:null,saveMessage:null}}));try{const R=await Or($.provider,j,{content:w.draftContent});p(X=>({...X,[j]:{path:R.path,exists:R.exists,originalContent:R.content,draftContent:R.content,loading:!1,saving:!1,error:null,saveMessage:"Saved"}}))}catch(R){p(X=>({...X,[j]:{...Es(j),...X[j],saving:!1,error:R instanceof re?R.message:"Unable to save the file.",saveMessage:null}}))}}}async function yt(){if(!z.creating){B(j=>({...j,creating:!0,message:null,error:null}));try{const j=await wl($.provider);D(w=>[j,...w]),B(w=>({...w,creating:!1,message:"Backup created."}))}catch(j){B(w=>({...w,creating:!1,error:j instanceof re?j.message:"Unable to create a config backup."}))}}}async function qe(j){if(!z.applyingId){B(w=>({...w,applyingId:j.id,message:null,error:null}));try{const w=await Sl($.provider,j.id);B(R=>({...R,applyingId:null,message:w.status.state==="ready"?`Applied "${w.archive.label}" and restarted ${$.displayName}.`:`Applied "${w.archive.label}". ${$.displayName} state: ${w.status.state}.`}))}catch(w){B(R=>({...R,applyingId:null,error:w instanceof re?w.message:"Unable to apply the config archive."}))}}}async function ut(j){const w=z.renameDraft.trim();if(!(!w||z.renamingId!==j.id)){B(R=>({...R,message:null,error:null}));try{const R=await Nl($.provider,j.id,{label:w});D(X=>X.map(ve=>ve.id===j.id?R:ve)),B(X=>({...X,renamingId:null,renameDraft:"",message:"Backup renamed."}))}catch(R){B(X=>({...X,error:R instanceof re?R.message:"Unable to rename the config backup."}))}}}if(!pe)return null;const Le=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-3 grid gap-2",children:[a.plugins.map(j=>e.jsxs("label",{className:"flex items-start justify-between gap-3 rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2.5",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium text-[var(--theme-fg)]",children:j.name}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--theme-fg-muted)]",children:j.description}),e.jsx("span",{className:"mt-2 block text-[10px] uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:[...j.capabilities.artifactTypes.map(w=>w.type),...j.capabilities.threadPanels.map(w=>w.kind??w.id)].join(", ")||"utility"}),e.jsx("span",{className:"mt-1 block text-[10px] uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:j.source==="imported"?"Imported manifest":"Built-in module"})]}),e.jsx("input",{type:"checkbox",checked:j.enabled,onChange:w=>void a.setPluginEnabled(j.id,w.currentTarget.checked),className:"mt-1 h-4 w-4 shrink-0 accent-[var(--theme-accent-solid)]"})]},j.id)),a.plugins.length===0&&e.jsx("p",{className:"rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No plugins are registered."})]}),e.jsxs("div",{className:"mt-3 border-t border-[var(--theme-border)] pt-3",children:[e.jsx("label",{className:"block text-xs font-medium text-[var(--theme-fg)]",children:"Import manifest JSON"}),e.jsx("textarea",{value:n,onChange:j=>{d(j.currentTarget.value),(o.message||o.error)&&m({busy:!1,message:null,error:null})},placeholder:'{"id":"example.viewer","name":"Example Viewer","version":"0.1.0",...}',rows:4,className:"mt-2 min-h-28 w-full resize-y rounded-[0.9rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2 font-mono text-xs leading-5 text-[var(--theme-fg)] outline-none transition placeholder:text-[var(--theme-fg-muted)] focus:border-[var(--theme-accent-border)]"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("p",{className:"max-w-[42rem] text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Imports register manifest-declared artifact types. Rendering code still needs a trusted built-in frontend module."}),e.jsx("button",{type:"button",onClick:()=>void H(),disabled:!n.trim()||o.busy,className:"rounded-full border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] px-3 py-1.5 text-xs font-medium text-[var(--theme-accent-strong)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:o.busy?"Importing...":"Import"})]}),o.error&&e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:o.error}),o.message&&e.jsx("p",{className:"mt-2 text-xs text-emerald-300",children:o.message})]}),a.error&&e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:a.error})]}),mt=e.jsxs(e.Fragment,{children:[t?null:e.jsx("div",{className:"shrink-0 p-5 pb-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Settings"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold text-[var(--theme-fg)]",children:"Settings"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--theme-fg-soft)]",children:"Choose the default backend and manage host-side runtime files."})]}),e.jsx("button",{type:"button","aria-label":"Close Settings",onClick:s==null?void 0:s.closeSettings,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg)] transition hover:border-[var(--theme-border-contrast)] hover:bg-[var(--theme-hover)]",children:e.jsx(fn,{})})]})}),e.jsx("div",{className:`min-h-0 flex-1 overflow-y-auto ${t?"p-0":"p-5 pt-5"}`,children:e.jsxs("div",{className:"space-y-2",children:[t?null:e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Appearance"}),e.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:["Choose light, dark, or follow the system setting. Active:"," ",me,"."]})]})}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-3",children:xi.map(j=>{const w=ge===j.value;return e.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s.setThemeMode(j.value),className:`block rounded-[1rem] border px-3 py-2.5 text-left transition ${w?"border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)]":"border-[var(--theme-border)] bg-[var(--theme-surface-strong)] hover:bg-[var(--theme-hover)]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--theme-fg)]",children:j.label}),w?e.jsx("span",{className:"rounded-full border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-[var(--theme-accent-strong)]",children:"Active"}):null]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:j.description})]},j.value)})})]}),e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Plugins"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Enable renderers and thread extensions loaded by this supervisor."})]}),e.jsx("button",{type:"button",onClick:()=>void a.refresh(),disabled:a.loading,className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:text-[var(--theme-fg-muted)]",children:a.loading?"Loading...":"Refresh"})]}),t?e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 rounded-[0.95rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2",children:[e.jsx("span",{className:"text-xs text-[var(--theme-fg-muted)]",children:oe}),e.jsx("button",{type:"button",onClick:()=>g(!0),className:"rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-panel)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)]",children:"Manage"})]}):Le]}),e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Workspace defaults"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Git projects clone into dev home. New workspace directories can create one missing child under this path."})]})}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--theme-fg-muted)]",children:"Workspace root"}),e.jsx("p",{title:(c==null?void 0:c.workspaceRoot)??"Loading workspace root",className:"mt-1 truncate rounded-[0.9rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2 font-mono text-xs text-[var(--theme-fg-soft)]",children:ae.loading&&!c?"Loading...":(c==null?void 0:c.workspaceRoot)??"Unavailable"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-dev-home",className:"text-[11px] uppercase tracking-[0.18em] text-[var(--theme-fg-muted)]",children:"Dev home"}),e.jsxs("div",{className:"mt-1 flex flex-col gap-2 sm:flex-row",children:[e.jsx("input",{id:"settings-dev-home",value:ae.devHomeDraft,onChange:j=>I(w=>({...w,devHomeDraft:j.target.value,message:null,error:null})),placeholder:"/Users/name/dev",className:"min-w-0 flex-1 rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-2 text-sm text-[var(--theme-fg)] outline-none focus:border-[var(--theme-accent-border)]"}),e.jsx("button",{type:"button","aria-label":"Save workspace defaults",onClick:()=>void ct(),disabled:ae.loading||ae.saving||!ae.devHomeDraft.trim(),className:"rounded-full bg-[var(--theme-accent-solid)] px-4 py-2 text-xs font-medium text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)] disabled:cursor-not-allowed disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:ae.saving?"Saving...":"Save"})]})]})]}),ae.error?e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:ae.error}):ae.message?e.jsx("p",{className:"mt-2 text-xs text-emerald-300",children:ae.message}):null]}),e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Runtime controls"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Inspect installed backend versions, install optional runtimes, or restart the selected backend."})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void be(),disabled:T.busy||_.saving,className:"rounded-full border border-sky-400/35 bg-sky-400/10 px-3 py-1.5 text-xs font-medium text-sky-500 transition hover:bg-sky-400/16 disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:T.busy?"Restarting...":"Restart"}),e.jsx("button",{type:"button",onClick:()=>void at(),disabled:T.busy||_.saving,className:"rounded-full border border-amber-400/35 bg-amber-400/10 px-3 py-1.5 text-xs font-medium text-amber-500 transition hover:bg-amber-400/16 disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:T.busy?"Working...":"Build and restart"})]})]}),e.jsx("div",{className:"mt-3 grid gap-2",children:Z.map(j=>{const w=j.installation,R=!w.installed&&!!w.installCommand,X=w.installed&&!!w.updateCommand,ve=_.saving&&_.operatingProvider===j.provider,Pe=R?"Install":"Update";return e.jsxs("div",{className:"flex flex-col gap-2 rounded-[0.95rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--theme-fg)]",children:j.displayName}),e.jsx("span",{className:`rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em] ${j.enabled?"border-emerald-400/35 bg-emerald-400/10 text-emerald-400":"border-[var(--theme-border)] bg-[var(--theme-muted)] text-[var(--theme-fg-muted)]"}`,children:j.enabled?"Ready":w.installed?j.status.state:"Not installed"})]}),e.jsxs("p",{className:"mt-1 truncate text-xs text-[var(--theme-fg-muted)]",children:["Version:"," ",w.installedVersion??(w.installed?"Installed":"Unavailable"),w.latestVersion?` · Latest: ${w.latestVersion}`:""]}),w.lastError?e.jsx("p",{className:"mt-1 line-clamp-2 text-xs text-rose-300",children:w.lastError}):null]}),R||X?e.jsx("button",{type:"button","aria-label":`${R?"Install":"Update"} ${j.displayName}`,onClick:()=>void fe(j.provider,R?"install":"update"),disabled:T.busy||_.saving||!R&&!X,className:"shrink-0 rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-panel)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:ve?_.operatingAction==="install"?"Installing...":"Updating...":Pe}):null]},j.provider)})}),T.error?e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:T.error}):T.message?e.jsx("p",{className:"mt-2 text-xs text-emerald-300",children:T.message}):_.message?e.jsx("p",{className:`mt-2 whitespace-pre-line text-xs ${_.message.includes("requires attention")?"text-amber-300":"text-emerald-300"}`,children:_.message}):_.error?e.jsx("p",{className:"mt-2 whitespace-pre-line text-xs text-rose-300",children:_.error}):null]}),e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Provider host files"}),e.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:[$.displayName," exposes these editable files through its backend schema."]})]})}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[W.map(j=>{const w=x[j.name]??{path:j.name,exists:!1,originalContent:"",draftContent:"",loading:!1},R=w.draftContent!==w.originalContent;return e.jsx("button",{type:"button",onClick:()=>E(j.name),className:"block rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-left transition hover:bg-[var(--theme-hover)]",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:j.label}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:j.description})]}),e.jsx("div",{className:"shrink-0",children:w.loading?e.jsx("span",{className:"text-[11px] uppercase tracking-[0.2em] text-[var(--theme-fg-muted)]",children:"Loading"}):R?e.jsx("span",{className:"rounded-full border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-[var(--theme-accent-strong)]",children:"Unsaved"}):w.exists?e.jsx("span",{className:"rounded-full border border-emerald-400/25 bg-emerald-400/10 px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-emerald-600 dark:text-emerald-100",children:"Ready"}):e.jsx("span",{className:"rounded-full border border-sky-300/25 bg-sky-300/10 px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-600 dark:text-sky-100",children:"New"})})]})},j.name)}),W.length===0?e.jsx("p",{className:"rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs text-[var(--theme-fg-muted)]",children:"This backend does not expose editable host files."}):null]})]}),K.configArchives?e.jsxs("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Config archives"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:"Backup the selected backend host files, then apply a saved archive with a backend restart."})]}),e.jsx("button",{type:"button",onClick:()=>void yt(),disabled:z.creating,className:"shrink-0 rounded-full border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] px-3 py-1.5 text-xs font-medium text-[var(--theme-accent-strong)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:z.creating?"Creating...":"Create backup"})]}),z.error?e.jsx("p",{className:"mt-2 text-xs text-rose-300",children:z.error}):z.message?e.jsx("p",{className:"mt-2 text-xs text-emerald-300",children:z.message}):null,e.jsx("div",{className:"mt-3 space-y-2",children:z.loading?e.jsx("p",{className:"rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs text-[var(--theme-fg-muted)]",children:"Loading backups..."}):v.length===0?e.jsx("p",{className:"rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No config backups yet."}):v.map(j=>{const w=z.renamingId===j.id;return e.jsx("div",{className:"rounded-[1.1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[w?e.jsxs("div",{className:"flex max-w-xl gap-2",children:[e.jsx("input",{"aria-label":`Rename ${j.label}`,value:z.renameDraft,onChange:R=>B(X=>({...X,renameDraft:R.target.value,error:null,message:null})),className:"min-w-0 flex-1 rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-1.5 text-sm text-[var(--theme-fg)] outline-none focus:border-[var(--theme-accent-border)]"}),e.jsx("button",{type:"button","aria-label":`Save archive name ${j.label}`,onClick:()=>void ut(j),className:"rounded-full bg-[var(--theme-accent-solid)] px-3 py-1.5 text-xs font-medium text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)]",children:"Save"}),e.jsx("button",{type:"button",onClick:()=>B(R=>({...R,renamingId:null,renameDraft:""})),className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)]",children:"Cancel"})]}):e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:j.label}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-[11px] text-[var(--theme-fg-muted)]",children:[e.jsxs("span",{children:["Created ",ji(j.createdAt)]}),W.map(R=>{var X;return e.jsxs("span",{className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-2 py-0.5 font-mono",children:[R.name,":"," ",(X=j.files[R.name])!=null&&X.exists?"saved":"missing"]},R.name)})]})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>B(R=>({...R,renamingId:j.id,renameDraft:j.label,message:null,error:null})),disabled:w,className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:text-[var(--theme-fg-muted)]",children:"Rename"}),e.jsx("button",{type:"button",onClick:()=>void qe(j),disabled:z.applyingId!==null,className:"rounded-full border border-emerald-400/35 bg-emerald-400/10 px-3 py-1.5 text-xs font-medium text-emerald-600 transition hover:bg-emerald-400/16 disabled:cursor-not-allowed disabled:border-[var(--theme-border)] disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)] dark:text-emerald-100",children:z.applyingId===j.id?"Applying...":"Apply"})]})]})},j.id)})})]}):null]})})]});return t?e.jsxs("div",{className:"flex min-h-0 flex-col overflow-hidden",children:[mt,h?e.jsxs("div",{className:"fixed inset-0 z-[90] flex items-start justify-center p-4 pt-[max(env(safe-area-inset-top),4rem)] sm:items-center sm:pt-4",children:[e.jsx("button",{type:"button","aria-label":"Close plugins panel",onClick:()=>g(!1),className:"absolute inset-0 bg-black/35 backdrop-blur-[2px]"}),e.jsxs("section",{className:"relative z-10 flex max-h-[min(82vh,42rem)] w-full max-w-2xl flex-col overflow-hidden rounded-[1.35rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] shadow-2xl shadow-black/25",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--theme-border)] px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:"Plugins"}),e.jsx("p",{className:"mt-1 text-xs text-[var(--theme-fg-muted)]",children:oe})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void a.refresh(),disabled:a.loading,className:"rounded-full border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-1.5 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:text-[var(--theme-fg-muted)]",children:a.loading?"Loading...":"Refresh"}),e.jsx("button",{type:"button","aria-label":"Close plugins panel",onClick:()=>g(!1),className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)]",children:e.jsx(fn,{})})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:Le})]})]}):null]}):e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-start justify-center p-4 pt-[max(env(safe-area-inset-top),1rem)] sm:items-center",children:[e.jsx("button",{type:"button","aria-label":"Close Settings",onClick:s==null?void 0:s.closeSettings,className:"ui-overlay-scrim absolute inset-0 backdrop-blur-sm"}),e.jsx("section",{role:"dialog","aria-modal":"true","aria-label":"Settings",className:"relative z-10 flex max-h-[calc(100vh-2rem)] w-full max-w-4xl flex-col overflow-hidden rounded-[1.8rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] shadow-2xl shadow-black/20",children:mt}),b&&k?e.jsx("div",{className:"pointer-events-none fixed inset-0 z-[71] flex items-center justify-center p-4",children:e.jsxs("div",{className:"pointer-events-auto relative z-10 flex max-h-[min(88vh,56rem)] w-full max-w-3xl flex-col overflow-hidden rounded-[1.6rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] shadow-2xl shadow-black/25",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-[var(--theme-border)] px-4 py-3 sm:px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:b}),e.jsx("p",{className:"mt-1 break-all font-mono text-xs text-[var(--theme-fg-muted)]",children:k.path})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[k.error?e.jsx("span",{className:"text-xs text-rose-300",children:k.error}):k.saveMessage?e.jsx("span",{className:"text-xs text-emerald-300",children:k.saveMessage}):null,e.jsx("button",{type:"button","aria-label":`Save ${b}`,onClick:()=>void Ye(b),disabled:k.loading||k.saving||k.draftContent===k.originalContent,className:"rounded-full bg-[var(--theme-accent-solid)] px-4 py-2 text-sm font-medium text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)] disabled:cursor-not-allowed disabled:bg-[var(--theme-muted)] disabled:text-[var(--theme-fg-muted)]",children:k.saving?"Saving...":"Save"}),e.jsx("button",{type:"button","aria-label":"Close File Editor",onClick:()=>E(null),className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-[var(--theme-border-strong)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg)] transition hover:border-[var(--theme-border-contrast)] hover:bg-[var(--theme-hover)]",children:e.jsx(fn,{})})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-5",children:e.jsx("textarea",{"aria-label":`Edit ${b}`,value:k.draftContent,onChange:j=>p(w=>({...w,[b]:{...Es(b),...w[b],draftContent:j.target.value,error:null,saveMessage:null}})),spellCheck:!1,className:"min-h-[28rem] w-full rounded-[1rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-3 font-mono text-[13px] leading-6 text-[var(--theme-fg)] outline-none transition focus:border-[var(--theme-accent-border)]",placeholder:k.loading?"Loading...":`Edit ${b} here`})})]})}):null]})}function wi(t){const s=(t==null?void 0:t.trim())??"";return s?Array.from(s).slice(0,2).join("").toUpperCase():"??"}function ga(){const t=nt(),s=es(),[a,n]=r.useState(null),[d,o]=r.useState(!1);r.useEffect(()=>{if(!na())return;let b=!1;return $s().then(E=>{b||n(E.authenticated?E:null)}).catch(()=>{b||n(null)}),()=>{b=!0}},[s.pathname]),r.useEffect(()=>{o(!1)},[s.pathname]);const m=(a==null?void 0:a.user)??null,h=r.useMemo(()=>wi(m==null?void 0:m.username),[m==null?void 0:m.username]);if(!na()||!m)return null;async function g(){await Ir(),n(null),t("/relay-portal")}return e.jsxs("div",{className:"fixed right-3 top-[calc(env(safe-area-inset-top)+0.55rem)] z-50",children:[e.jsx("button",{"aria-expanded":d,"aria-haspopup":"menu","aria-label":`Relay account menu for ${m.username}`,className:"inline-flex h-10 w-10 items-center justify-center rounded-full border border-[var(--theme-border)] bg-[var(--theme-panel)] text-sm font-semibold text-[var(--theme-fg)] shadow-lg transition hover:bg-[var(--theme-hover)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-accent-ring)]",onClick:()=>o(b=>!b),type:"button",children:h}),d?e.jsxs("div",{className:"absolute right-0 mt-2 w-64 overflow-hidden rounded-xl border border-[var(--theme-border)] bg-[var(--theme-panel)] p-1 shadow-xl",role:"menu",children:[e.jsxs("div",{className:"border-b border-[var(--theme-border)] px-3 py-2",children:[e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:m.username}),e.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:m.email})]}),e.jsxs(It,{className:"flex items-center gap-2 rounded-lg px-3 py-2 text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)]",role:"menuitem",to:"/relay-account",children:[e.jsx(dt.Settings,{className:"h-4 w-4"}),"Account settings"]}),e.jsxs(It,{className:"flex items-center gap-2 rounded-lg px-3 py-2 text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)]",role:"menuitem",to:"/relay-devices",children:[e.jsx(dt.MonitorSmartphone,{className:"h-4 w-4"}),"Device management"]}),e.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)]",onClick:()=>void g(),role:"menuitem",type:"button",children:[e.jsx(dt.LogOut,{className:"h-4 w-4"}),"Logout"]})]}):null]})}const Ni="http://127.0.0.1:8790",ba="remote-codex-control-plane-auth";function Si(t){const s=t.baseUrl||Ni;if(t.token){const a={baseUrl:s,token:t.token};return t.email!==void 0&&(a.email=t.email),t.displayName!==void 0&&(a.displayName=t.displayName),t.expiresAt!==void 0&&(a.expiresAt=t.expiresAt),a}if(t.subject){const a={baseUrl:s,token:`dev:${t.subject}`};return t.email!==void 0&&(a.email=t.email),t.displayName!==void 0&&(a.displayName=t.displayName),a}return null}function Qt(){if(typeof window>"u")return null;const t=window.localStorage.getItem(ba);if(!t)return null;try{const s=Si(JSON.parse(t));return!(s!=null&&s.baseUrl)||!s.token||s.expiresAt&&Date.parse(s.expiresAt)<=Date.now()?null:s}catch{return null}}function xn(t){window.localStorage.setItem(ba,JSON.stringify(t))}function jn(){window.localStorage.removeItem(ba)}function ki(){return!!Qt()}function Ci({eyebrow:t,hidden:s,onClose:a,children:n}){return e.jsx("aside",{className:"control-right-column","aria-hidden":s,children:e.jsxs("section",{className:"control-panel control-inspector-panel",children:[e.jsxs("div",{className:"control-panel-heading",children:[e.jsx("h2",{children:"Inspector"}),e.jsx("span",{children:t}),e.jsx("button",{type:"button",className:"control-inline-icon-button",onClick:a,"aria-label":"Close details inspector",children:"x"})]}),n]})})}function Ti({topBar:t,alerts:s,children:a,sidebar:n,main:d,inspector:o,inspectorOpen:m}){const h=a??e.jsxs(e.Fragment,{children:[n,e.jsx("main",{className:"control-main-column",children:d}),e.jsx("button",{type:"button",className:"control-inspector-scrim","aria-hidden":"true",tabIndex:-1}),o]});return e.jsxs("div",{className:"control-plane-console",children:[t,e.jsx("div",{className:"control-alert-stack",children:s}),e.jsx("div",{className:`control-console-grid ${m?"inspector-open":"inspector-collapsed"}`,children:h})]})}function Ii({children:t}){return e.jsx("aside",{className:"control-explorer-panel",children:t})}function Ei({title:t,subtitle:s,actions:a}){return e.jsxs("header",{className:"control-console-header",children:[e.jsxs("div",{className:"control-window-controls","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsxs("div",{className:"control-titlebar-copy",children:[e.jsx("h1",{children:t}),e.jsx("span",{children:s})]}),e.jsx("div",{className:"control-header-actions",children:a})]})}const Ri=6e4,Pi=5e3,Ai=3e3,rn={estructural:"Estructural",quntur:"Quntur",farmaco:"Farmaco"};function on(t){if(!t)return"no activity yet";const s=Date.parse(t);if(!Number.isFinite(s))return t;const a=Date.now()-s,n=Math.abs(a),d=a>=0?"ago":"from now",o=6e4,m=60*o,h=24*m;return n<o?"just now":n<m?`${Math.round(n/o)}m ${d}`:n<h?`${Math.round(n/m)}h ${d}`:`${Math.round(n/h)}d ${d}`}function Dn(t){return t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)}function Mt(t){switch(t){case"running":return"border-[var(--status-success-border)] bg-[var(--status-success-bg)] text-[var(--status-success-fg)]";case"failed":case"degraded":case"unknown":return"border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] text-[var(--status-danger-fg)]";case"stopped":return"border-[var(--status-neutral-border)] bg-[var(--status-neutral-bg)] text-[var(--status-neutral-fg)]";default:return"border-[var(--status-warning-border)] bg-[var(--status-warning-bg)] text-[var(--status-warning-fg)]"}}function Ne(t){return t?t.split(/[_\s-]+/).filter(Boolean).map(s=>`${s.charAt(0).toUpperCase()}${s.slice(1)}`).join(" "):"Unknown"}function As(t){switch(t){case"empty":return"Local workspace";case"git":return"Git workspace";default:return Ne(t)}}function Ui(t){return As(t.sourceType)}function Hn(t){return t.workerSessionId?"Runtime ready":"Not started"}function Rs(t){return t?`${t.type}:${t.id}`:""}function ln(t){switch(t){case"codex":return"Codex";case"claude":return"Claude";case"opencode":return"OpenCode";default:return Ne(t)}}function za({open:t}){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",focusable:"false",children:e.jsx("path",{d:t?"M4.5 6.25 8 9.75l3.5-3.5":"M6.25 4.5 9.75 8l-3.5 3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function Oi(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",focusable:"false",children:e.jsx("path",{d:"M2.75 5.25h10.5v7H2.75zM2.75 4a1 1 0 0 1 1-1h3l1.25 1.25h4.25a1 1 0 0 1 1 1",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.25"})})}function $i(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",focusable:"false",children:e.jsx("path",{d:"M3 3.75h10v8.5H3zM5.25 6h5.5M5.25 8h5.5M5.25 10h3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.25"})})}function Mi(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",focusable:"false",children:e.jsx("path",{d:"M4 3.25h5.25L12 6v6.75H4zM9.25 3.25V6H12M6 8.25h4M6 10.25h3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.25"})})}function Li(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",focusable:"false",children:e.jsx("path",{d:"m3.2 10.9-.45 2.35 2.35-.45 6.95-6.95-1.9-1.9zm7.8-7.8.95-.95a1.35 1.35 0 0 1 1.9 1.9l-.95.95",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.25"})})}function Di(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",focusable:"false",children:e.jsx("path",{d:"M3 4.25h10M6.25 4.25V3h3.5v1.25M4.5 4.25l.55 8.25h5.9l.55-8.25M6.75 6.75v3.5M9.25 6.75v3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.25"})})}function Va(t){switch(t){case"connecting":return"Connecting";case"ready":return"Ready";case"reconnecting":return"Reconnecting";default:return"Idle"}}function Hi(t){if(!t)return"Loading runtime";if(t.state==="starting"){const s=t.startupProgress??0;return s<25?"Request received":s<50?"Scheduling sandbox":s<90?"Preparing runtime":"Opening sandbox route"}return t.state==="stopping"?"Stopping sandbox":t.state==="running"?"Ready":t.state==="degraded"?"Checking readiness":t.state==="failed"?"Startup failed":t.state==="stopped"?"Stopped":Ne(t.state)}function _i(t){if(!t)return"Loading sandbox registry";switch(t.state){case"running":return"Healthy";case"starting":return"Waiting for runtime readiness";case"stopping":return"Shutdown in progress";case"degraded":return"Needs attention";case"failed":return"Failed";case"stopped":return"Offline";default:return"Unknown"}}function Bi(t,s){const a="Sign in before managing the sandbox.";if(!t)return{start:{label:"Start",disabled:!0,title:a},stop:{label:"Stop",disabled:!0,title:a},restart:{label:"Restart",disabled:!0,title:a},health:{label:"Health",disabled:!0,title:a},inspect:{label:"Inspect",disabled:!0,title:a}};if(!s){const g="Wait for the sandbox registry to load.";return{start:{label:"Start",disabled:!0,title:g},stop:{label:"Stop",disabled:!0,title:g},restart:{label:"Restart",disabled:!0,title:g},health:{label:"Health",disabled:!0,title:g},inspect:{label:"Inspect",disabled:!0,title:g}}}const n=s.state,d=n==="running"||n==="degraded"||n==="starting",o=n==="running"||n==="degraded";return{start:{label:n==="starting"?"Starting...":n==="stopping"?"Stopping...":n==="restarting"?"Restarting...":n==="running"?"Running":n==="failed"?"Retry start":"Start",disabled:n==="running"||n==="starting"||n==="stopping"||n==="restarting"||n==="degraded",title:n==="starting"?"Sandbox startup is already in progress.":n==="running"?"Sandbox is already running.":n==="stopping"?"Wait for sandbox shutdown to finish before starting again.":n==="restarting"?"Sandbox restart is already in progress.":n==="degraded"?"Use Restart to recover a degraded sandbox.":void 0},stop:{label:"Stop",disabled:!d,title:d?void 0:"Stop is available only while the sandbox is running or starting."},restart:{label:n==="restarting"?"Restarting...":"Restart",disabled:!o,title:n==="failed"?"Use Retry start after a failed startup.":o?void 0:"Restart is available only when the sandbox is running or degraded."},health:{label:"Health",disabled:!1,title:void 0},inspect:{label:"Inspect",disabled:!1,title:void 0}}}function Fi(t){if(!t)return null;if(t.state==="running"&&t.idleTimeoutAt){const s=Date.parse(t.idleTimeoutAt);if(Number.isFinite(s)&&s>Date.now())return{tone:"warning",text:`Sandbox will stop after idle timeout at ${t.idleTimeoutAt}.`}}return t.state==="degraded"?{tone:"warning",text:t.statusReason??"Sandbox is reachable but not fully ready."}:t.state==="failed"?{tone:"danger",text:t.lastFailureMessage??t.statusReason??"Sandbox startup failed."}:t.state==="unknown"?{tone:"warning",text:t.statusReason??"Sandbox state is unknown."}:["running","starting","stopping"].includes(t.state)?null:{tone:"neutral",text:"Sandbox is offline."}}function Wi(t,s){return s?"unavailable":t?!t.enabled||!t.chemistryToolsEnabled?"not configured":t.keyPresent?t.health?"ready":"degraded":"missing key":"idle"}function Ja(t){switch(t){case"ready":return Mt("running");case"unavailable":case"missing key":return Mt("failed");case"not configured":case"idle":return Mt("stopped");default:return Mt("starting")}}function Ga(t){return t?typeof t.text=="string"?t.text.trim():t.payload===void 0?"":JSON.stringify(t.payload,null,2):""}function Ka(t){const s=t==null?void 0:t.payload;if(Array.isArray(s))return s;if(s&&typeof s=="object")for(const a of["tools","runs","items","artifacts"]){const n=s[a];if(Array.isArray(n))return n}return[]}function Ya(t,s){if(!t||typeof t!="object")return String(t??s);const a=t;for(const n of["name","tool","run_id","id","title","path"]){const d=a[n];if(typeof d=="string"&&d.trim())return d}return s}function Za(t){if(!t||typeof t!="object")return"";const s=t;return["status","type","module","execution_mode"].map(a=>{const n=s[a];return typeof n=="string"&&n.trim()?n:null}).filter(Boolean).join(" / ")}function dn({label:t,value:s,onChange:a,type:n="text"}){return e.jsxs("label",{className:"grid gap-1.5 text-xs font-medium text-[var(--theme-fg-muted)]",children:[e.jsx("span",{children:t}),e.jsx("input",{type:n,value:s,onChange:d=>a(d.currentTarget.value),className:"h-10 rounded-[0.7rem] border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 text-sm text-[var(--theme-fg)] outline-none transition focus:border-[var(--theme-accent-border)] focus:ring-2 focus:ring-[var(--theme-accent-soft)]"})]})}function Oe({children:t,onClick:s,disabled:a=!1,type:n="button",title:d,ariaLabel:o}){return e.jsx("button",{type:n,"aria-label":o,onClick:s,disabled:a,title:d,className:"h-10 rounded-[0.75rem] border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 text-sm font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:text-[var(--theme-fg-muted)]",children:t})}function Fe({label:t,value:s}){const a=s&&s.trim()?s:"not assigned";return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsxs("dd",{children:[e.jsx("span",{children:a}),s?e.jsx("button",{type:"button",className:"control-copy-button",onClick:()=>{var n;(n=navigator.clipboard)==null||n.writeText(s)},children:"Copy"}):null]})]})}function qi({status:t}){return e.jsx("span",{className:`control-status-pill compact ${Mt(t)}`,children:Ne(t)})}function _n({label:t,onEdit:s,onDelete:a}){return e.jsxs("span",{className:"control-tree-actions",children:[e.jsx("button",{type:"button",className:"control-tree-action-button",onClick:n=>{n.stopPropagation(),s()},"aria-label":`Rename ${t}`,title:`Rename ${t}`,children:e.jsx(Li,{})}),e.jsx("button",{type:"button",className:"control-tree-action-button danger",onClick:n=>{n.stopPropagation(),a()},"aria-label":`Delete ${t}`,title:`Delete ${t}`,children:e.jsx(Di,{})})]})}function Bn({label:t,value:s,onChange:a,onCancel:n,onSubmit:d}){return e.jsxs("form",{className:"control-tree-edit-form",onSubmit:d,children:[e.jsxs("label",{children:[e.jsx("span",{children:t}),e.jsx("input",{value:s,onChange:o=>a(o.currentTarget.value),autoFocus:!0})]}),e.jsx("button",{type:"submit",children:"Save"}),e.jsx("button",{type:"button",onClick:n,children:"Cancel"})]})}function zi(){var nn;const t=nt(),[s,a]=r.useState(()=>{const u=Qt();return u?{baseUrl:u.baseUrl,token:u.token}:null}),[n,d]=r.useState(null),[o,m]=r.useState(null),[h,g]=r.useState(null),[b,E]=r.useState(null),[x,p]=r.useState(null),[k,T]=r.useState([]),[A,v]=r.useState(null),[D,Z]=r.useState([]),[q,_]=r.useState([]),[ne,c]=r.useState([]),[F,ae]=r.useState([]),[I,z]=r.useState(""),[B,ge]=r.useState(""),[pe,H]=r.useState(""),[me,C]=r.useState(null),[le,oe]=r.useState(null),[$,K]=r.useState(null),[W,be]=r.useState(null),[fe,at]=r.useState("farmaco"),[ct,Ye]=r.useState(null),[yt,qe]=r.useState(null),[ut,Le]=r.useState(null),[mt,j]=r.useState("Computational chemistry"),[w,R]=r.useState("Molecule study"),[X,ve]=r.useState("Plan calculation"),[Pe,ht]=r.useState("codex"),[Ae,wt]=r.useState(null),[Ge,rt]=r.useState(""),[Ke,Ze]=r.useState(null),[Et,Lt]=r.useState(null),[Gt,Kt]=r.useState(null),[ee,ie]=r.useState(null),[ce,ue]=r.useState(!1),[ke,V]=r.useState(null),[Xe,$e]=r.useState(!1),[Qe,ft]=r.useState("summary"),[Dt,xt]=r.useState(()=>{var u;return((u=Qt())==null?void 0:u.displayName)??""}),[gs,bs]=r.useState(null),[vs,Nt]=r.useState(null),[Yt,gt]=r.useState(null),[js,we]=r.useState(null),[ot,St]=r.useState(null),[Rt,ys]=r.useState(null),[et,pt]=r.useState({projects:!1,workspaces:!1,sessions:!1,usageEvents:!1,harness:!1}),[Pt,ze]=r.useState("idle"),Te=r.useRef(null),Ht=r.useRef(null),kt=!!(s&&n),Ce=(o==null?void 0:o.state)==="running",je=Bi(kt,o),Ms=(o==null?void 0:o.state)==="starting"||(o==null?void 0:o.state)==="stopping"||(o==null?void 0:o.state)==="restarting"||(o==null?void 0:o.state)==="degraded"||typeof(o==null?void 0:o.startupProgress)=="number"&&o.startupProgress>0&&o.startupProgress<100,J=r.useMemo(()=>q.find(u=>u.id===I)??null,[q,I]),Q=r.useMemo(()=>ne.find(u=>u.id===B)??null,[B,ne]),te=r.useMemo(()=>F.find(u=>u.id===pe)??null,[pe,F]),ws=kt&&!!J,ts=kt&&!!Q&&Ce,Ns=Fi(o),At=J?void 0:"Select a project before creating a workspace.",Ut=Q?Ce?void 0:"Start the sandbox before creating a session.":"Select a workspace before creating a session.",Ls=te?Ce?void 0:"Start the sandbox before connecting a session.":"Select a session before connecting.",Ct=Q?"session":J?"workspace":"project",_t=Ct==="project"?"Project":Ct==="workspace"?"Workspace":"Session",bt=ke==="project"?"Create project":ke==="workspace"?`Create workspace in ${(J==null?void 0:J.name)??"project"}`:ke==="session"?`Create session in ${(Q==null?void 0:Q.name)??"workspace"}`:"",Bt=ke==="workspace"?At:ke==="session"?Ut:void 0,Ss=[J==null?void 0:J.name,Q==null?void 0:Q.name,te==null?void 0:te.title].filter(Boolean).join(" / "),Zt=Wi(W,ut),Ds=W!=null&&W.modules.length?W.modules:["farmaco","quntur","estructural"],he=Ka(ct),Ot=Ka(yt),ss=Ga(ct),ns=Ga(yt),ks=((n==null?void 0:n.displayName)??(n==null?void 0:n.email)??"U").trim().charAt(0).toUpperCase()||"U",Hs=((b==null?void 0:b.inputTokens)??0)+((b==null?void 0:b.outputTokens)??0),lt=(x==null?void 0:x.totalCostUsd)??Number((b==null?void 0:b.costUsd)??0)+Number((A==null?void 0:A.costUsd)??0),as=F.filter(u=>u.status==="active").length,_s=F.filter(u=>!u.workerSessionId).length,Bs=F.filter(u=>u.status==="failed"||u.status==="closed").length,Fs=[{label:"All",value:F.length},{label:"Active",value:as},{label:"Needs runtime",value:_s},{label:"Closed",value:Bs}],Cn=(s==null?void 0:s.baseUrl)??((nn=Qt())==null?void 0:nn.baseUrl)??"not connected",Ws=(te==null?void 0:te.lastActivityAt)??(te==null?void 0:te.updatedAt)??null,Tn=(o==null?void 0:o.lastSeenAt)??(o==null?void 0:o.updatedAt)??null,qs=Hi(o),In=_i(o),En=(Q==null?void 0:Q.name)??(J==null?void 0:J.name)??"Control Plane",Rn=Ss||"Choose a project and workspace to manage sessions";async function Ve(u,N){Lt(u),Kt(null),ie(null),bs(null),Nt(null),gt(null),we(null),St(null),ys(null);try{return await N()}catch(S){if(S instanceof re&&S.payload.code==="gateway_unavailable"&&bs(S.message),S instanceof re&&S.payload.code==="quota_exceeded"){const G=S.payload.details??{},Me=typeof G.limit=="number"?G.limit:null,He=typeof G.used=="number"?G.used:null,$t=typeof G.quotaProfile=="string"?G.quotaProfile:(n==null?void 0:n.quotaProfile)??"current";Nt(Me!==null&&He!==null?`${$t} quota exhausted (${He}/${Me}).`:"Quota exceeded.")}return S instanceof re&&S.payload.code==="account_inactive"&>(S.message),S instanceof re&&(S.statusCode===401||S.payload.code==="unauthorized")&&(we(S.message),jn()),S instanceof re&&S.payload.code==="forbidden"&&ys(S.message),Kt(S instanceof Error?S.message:`${u} failed.`),null}finally{Lt(null)}}async function Cs(u=s){if(u){pt(N=>({...N,projects:!0,usageEvents:!0}));try{const N=await ha(u),[S,G,Me,He]=await Promise.all([kr(u),Wo(u,10),qo(u),zo(u,10)]);d(N.user),m(N.sandbox),E(N.usage),p(N.billing??null),T(G.events),v(Me.usage),Z(He.events),_(S.projects),xt(N.user.displayName??""),z($t=>S.projects.some(On=>On.id===$t)?$t:"")}finally{pt(N=>({...N,projects:!1,usageEvents:!1}))}}}async function zs(u=s,N=fe){if(!u||!Ce){be(null),Ye(null),qe(null),Le(null);return}pt(S=>({...S,harness:!0})),Le(null);try{const S=await sl(u);be(S);const G=S.modules.includes(N)?N:S.modules[0]??N;if(at(G),S.enabled&&S.keyPresent&&S.chemistryToolsEnabled){const[Me,He]=await Promise.all([La(u,G),Da(u,G)]);Ye(Me),qe(He)}else Ye(null),qe(null)}catch(S){be(null),Ye(null),qe(null),Le(S instanceof Error?S.message:"Harness status refresh failed.")}finally{pt(S=>({...S,harness:!1}))}}r.useEffect(()=>{s&&Ve("Load control plane",async()=>{await Cs(s),ie("Control plane session is ready.")})},[]),r.useEffect(()=>{if(!s||!B){ae([]),H("");return}H(""),pt(u=>({...u,sessions:!0})),Ve("Load sessions",async()=>{try{const u=await ra(s,B);ae(u.sessions)}finally{pt(u=>({...u,sessions:!1}))}})},[s,B]),r.useEffect(()=>{if(!s||!o||!Ms)return;let u=!1;const N=setTimeout(()=>{Ma(s).then(S=>{u||m(S.sandbox)}).catch(S=>{u||St(S instanceof Error?S.message:"Sandbox health refresh failed.")})},Ai);return()=>{u=!0,clearTimeout(N)}},[s,o==null?void 0:o.state,o==null?void 0:o.startupProgress,o==null?void 0:o.updatedAt,Ms]),r.useEffect(()=>{if(!s||!Ce){be(null),Ye(null),qe(null),Le(null);return}zs(s,fe)},[s,Ce,o==null?void 0:o.updatedAt]),r.useEffect(()=>{if(!s||!I){c([]),ge(""),ae([]),H("");return}ge(""),ae([]),H(""),pt(u=>({...u,workspaces:!0})),Ve("Load workspaces",async()=>{try{const u=await aa(s,I);c(u.workspaces)}finally{pt(u=>({...u,workspaces:!1}))}})},[s,I]),r.useEffect(()=>()=>{Te.current&&clearTimeout(Te.current),vt()},[]),r.useEffect(()=>{function u(N){N.key==="Escape"&&(ue(!1),V(null),C(null),$e(!1))}return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[]);function vt(){const u=Ht.current;Ht.current=null,u&&u.readyState!==WebSocket.CLOSED&&u.close()}function jt(){Te.current&&(clearTimeout(Te.current),Te.current=null)}function Pn(u){return`${u.wsBaseUrl.replace(/\/+$/,"")}/api/sandboxes/${encodeURIComponent(u.sandboxId)}/ws?token=${encodeURIComponent(u.token)}`}function Vs(u,N="connecting"){vt();const S=Pn(u);K(S),St(null),ze(N);const G=new WebSocket(S);Ht.current=G,G.addEventListener("open",()=>{Ht.current===G&&ze("ready")}),G.addEventListener("error",()=>{Ht.current===G&&(St("Sandbox route connection failed."),ze("idle"))}),G.addEventListener("close",Me=>{Ht.current===G&&(St(Me.reason||"Sandbox route closed before the session could stay connected."),ze("idle"))})}function Js(u){if(jt(),!u)return;const N=Date.parse(u.expiresAt);if(!Number.isFinite(N))return;const S=Math.max(Pi,N-Date.now()-Ri);Te.current=setTimeout(()=>{Ys()},S)}async function Ft(){jn(),a(null),d(null),m(null),g(null),E(null),T([]),ys(null),_([]),c([]),ae([]),v(null),Z([]),oe(null),ue(!1),V(null),jt(),ze("idle"),ie("Signed out locally.")}async function De(u){u.preventDefault(),s&&await Ve("Update profile",async()=>{const N=await Vo(s,{displayName:Dt});d(N.user);const S=Qt();S&&xn({...S,email:N.user.email,displayName:N.user.displayName}),ie("Profile updated.")})}async function Gs(u){u.preventDefault(),s&&await Ve("Create project",async()=>{const N=await Jo(s,{name:mt,slug:Dn(mt)});await Cs(s),V(null),ie(`Project "${N.project.name}" created. Select it before creating a workspace.`)})}async function Ks(u){u.preventDefault(),!(!s||!J)&&await Ve("Create workspace",async()=>{const N=await Yo(s,{projectId:J.id,name:w,slug:Dn(w)}),S=await aa(s,J.id);c(S.workspaces),ge(""),ae([]),H(""),V(null),ie(`Workspace "${N.workspace.name}" created. Select it before creating a session.`)})}async function An(u){u.preventDefault(),!(!s||!Q||!Ce)&&await Ve("Create session",async()=>{const N=await Zo(s,Q.id,{provider:Pe,title:X}),S=await ra(s,Q.id);ae(S.sessions),H(""),V(null),ie(`Session "${N.session.title}" created. Select it before connecting.`)})}async function Wt(u){s&&await Ve(`${u} sandbox`,async()=>{if(u==="start")m((await Qo(s)).sandbox);else if(u==="stop")m((await el(s)).sandbox),oe(null),K(null),vt(),jt(),ze("idle");else if(u==="restart")m((await tl(s)).sandbox),oe(null),K(null),vt(),jt(),ze("idle");else{const N=await Ma(s);m(N.sandbox),ie(`Sandbox health is ${Ne(N.status.state)}.`)}})}async function rs(u){if(at(u),!(!s||!Ce)){pt(N=>({...N,harness:!0})),Le(null);try{const[N,S]=await Promise.all([La(s,u),Da(s,u)]);Ye(N),qe(S)}catch(N){Ye(null),qe(null),Le(N instanceof Error?N.message:"Harness module refresh failed.")}finally{pt(N=>({...N,harness:!1}))}}}async function os(){!s||!o||await Ve("Inspect sandbox",async()=>{const u=await nl(s,o.id);g(u),ie("Sandbox detail loaded.")})}async function ls(u="connecting",N=pe){return!s||!o||!Ce?null:Ve("Create route token",async()=>{const S={scopes:["worker:read","worker:write","session:prompt","provider:turn:create"]};J!=null&&J.id&&(S.projectId=J.id),B&&(S.workspaceId=B),N&&(S.sessionId=N);const G=await Tr(s,o.id,S);return oe(G),Js(G),Vs(G,u),ie("Route token is available in memory."),G})}async function Ys(){if(!s||!o||o.state!=="running"||!pe)return;ze("reconnecting"),await ls("reconnecting",pe)||ze("idle")}function Xt(u){C(null),H(u.id),oe(null),K(null),vt(),jt(),ze("idle"),ft("summary"),$e(!0)}function Zs(u){Xt(u),$e(!0)}function Xs(u,N){var S;N&&(C(null),(S=navigator.clipboard)==null||S.writeText(N),ie(`${u} copied.`))}function is(u,N){wt(u),rt(N),C(null)}function qt(){wt(null),rt("")}async function ds(u){if(u.preventDefault(),!s||!Ae)return;const N=Ge.trim();if(!N){Kt("Name is required.");return}const S=Ae;await Ve(`Rename ${S.type}`,async()=>{if(S.type==="project"){const G=await Go(s,S.id,{name:N,slug:Dn(N)});_(Me=>Me.map(He=>He.id===G.project.id?G.project:He))}else if(S.type==="workspace"){const G=await Oa(s,S.id,{name:N});c(Me=>Me.map(He=>He.id===G.workspace.id?G.workspace:He))}else{const G=await $a(s,S.id,{title:N});ae(Me=>Me.map(He=>He.id===G.session.id?G.session:He))}qt(),ie(`${Ne(S.type)} renamed.`)})}function Ts(u){if(!u)return{title:"Delete item",description:"This item will be removed from the active control plane view."};if(u.type==="project"){const S=q.find(G=>G.id===u.id);return{title:`Delete project ${(S==null?void 0:S.name)??""}`.trim(),description:"The project will be archived and removed from the active project list. Its existing workspace records remain in the control plane database."}}if(u.type==="workspace"){const S=ne.find(G=>G.id===u.id);return{title:`Delete workspace ${(S==null?void 0:S.name)??""}`.trim(),description:"The workspace will be marked deleted and removed from this project view. Sessions under it will no longer be shown from the active workspace browser."}}const N=F.find(S=>S.id===u.id);return{title:`Delete session ${(N==null?void 0:N.title)??""}`.trim(),description:"The session will be marked deleted and removed from this workspace view. This does not delete files in the sandbox workspace."}}async function Is(){if(!s||!Ke)return;const u=Ke;await Ve(`Delete ${u.type}`,async()=>{if(u.type==="project"){const N=await Ko(s,u.id);_(S=>S.filter(G=>G.id!==N.project.id)),I===N.project.id&&(z(""),ge(""),H(""),c([]),ae([]))}else if(u.type==="workspace"){const N=await Oa(s,u.id,{status:"deleted"});c(S=>S.filter(G=>G.id!==N.workspace.id)),B===N.workspace.id&&(ge(""),H(""),ae([]))}else{const N=await $a(s,u.id,{status:"deleted"});ae(S=>S.filter(G=>G.id!==N.session.id)),pe===N.session.id&&H("")}Ae&&Rs(Ae)===Rs(u)&&qt(),Ze(null),oe(null),K(null),vt(),jt(),ze("idle"),ie(`${Ne(u.type)} deleted.`)})}async function Qs(u){!s||!Ce||await Ve("Close session",async()=>{const N=await Xo(s,u.id);ae(S=>S.map(G=>G.id===N.session.id?N.session:G)),H(N.session.id),oe(null),K(null),vt(),jt(),ze("idle"),ie("Session finalized and disconnected.")})}async function en(u){!s||!Ce||await Ve("Resume session",async()=>{const N=await Cr(s,u.id);ae(S=>S.map(G=>G.id===N.session.id?N.session:G)),H(N.session.id),await ls("connecting",N.session.id),ie("Session resumed."),t(`/control-plane/sessions/${encodeURIComponent(N.session.id)}`)})}const Un=e.jsx(Ei,{title:En,subtitle:Rn,actions:e.jsxs(e.Fragment,{children:[o?e.jsx("span",{className:`control-status-pill ${Mt(o.state)}`,children:Ne(o.state)}):null,e.jsx(Oe,{onClick:()=>void Cs(s),disabled:!s||Et==="Load control plane",children:"Refresh"}),e.jsx(Oe,{onClick:()=>$e(u=>!u),ariaLabel:Xe?"Hide details inspector":"Show details inspector",children:"Inspector"}),e.jsxs("div",{className:"control-account-menu",children:[e.jsx("button",{type:"button",className:"control-avatar-button",onClick:()=>ue(u=>!u),"aria-haspopup":"menu","aria-expanded":ce,"aria-label":"Open account menu",children:ks}),ce?e.jsxs("div",{className:"control-account-popover",role:"menu",children:[e.jsxs("div",{className:"control-account-identity",children:[e.jsx("span",{className:"control-avatar-badge",children:ks}),e.jsxs("div",{children:[e.jsx("strong",{children:(n==null?void 0:n.displayName)||(n==null?void 0:n.email)||"Account"}),e.jsx("span",{children:(n==null?void 0:n.email)??"Loading account"})]})]}),e.jsxs("dl",{className:"control-detail-list compact two",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Status"}),e.jsx("dd",{children:Ne((n==null?void 0:n.status)??"loading")})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Plan"}),e.jsx("dd",{children:(n==null?void 0:n.plan)??"developer"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Quota"}),e.jsx("dd",{children:(n==null?void 0:n.quotaProfile)??"default"})]})]}),e.jsxs("form",{onSubmit:De,className:"control-inline-form",children:[e.jsx(dn,{label:"Display name",value:Dt,onChange:xt}),e.jsx(Oe,{type:"submit",disabled:!s||Et==="Update profile",children:"Save"})]}),e.jsxs("div",{className:"control-usage-grid compact",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Requests"}),e.jsx("strong",{children:(b==null?void 0:b.requestCount)??0})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Tokens"}),e.jsx("strong",{children:Hs})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Total cost"}),e.jsxs("strong",{children:["$",lt.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Harness"}),e.jsx("strong",{children:(A==null?void 0:A.eventCount)??0})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Compute"}),e.jsx("strong",{children:Number((A==null?void 0:A.computeUnits)??0).toFixed(1)})]}),e.jsxs("div",{children:[e.jsx("span",{children:"LLM cost"}),e.jsxs("strong",{children:["$",Number((b==null?void 0:b.costUsd)??0).toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Harness cost"}),e.jsxs("strong",{children:["$",Number((A==null?void 0:A.costUsd)??0).toFixed(2)]})]})]}),e.jsxs("details",{className:"control-account-disclosure",children:[e.jsx("summary",{children:"Account details"}),e.jsx("dl",{className:"control-detail-list compact",children:e.jsx(Fe,{label:"Control plane API",value:Cn})})]}),e.jsxs("details",{className:"control-account-disclosure",children:[e.jsx("summary",{children:"Usage history"}),e.jsx("div",{className:"control-usage-events compact",children:et.usageEvents?e.jsx("p",{className:"control-empty",children:"Loading LLM usage..."}):k.length===0?e.jsx("p",{className:"control-empty",children:"No LLM usage events yet."}):k.slice(0,4).map(u=>e.jsxs("div",{children:[e.jsx("strong",{children:u.model}),e.jsxs("span",{children:[u.provider,", ",u.inputTokens+u.outputTokens," tokens, $",Number(u.costUsd).toFixed(2)]}),e.jsx("small",{children:u.occurredAt})]},u.id))}),e.jsx("div",{className:"control-usage-events compact",children:et.usageEvents?e.jsx("p",{className:"control-empty",children:"Loading Harness usage..."}):D.length===0?e.jsx("p",{className:"control-empty",children:"No Harness usage events yet."}):D.slice(0,4).map(u=>e.jsxs("div",{children:[e.jsx("strong",{children:u.tool??u.module}),e.jsxs("span",{children:[u.module,", ",u.status,", $",Number(u.costUsd).toFixed(2)]}),e.jsx("small",{children:u.occurredAt})]},u.id))})]}),e.jsx(Oe,{onClick:Ft,children:"Sign out"})]}):null]})]})}),tn=e.jsxs(e.Fragment,{children:[Gt?e.jsx("div",{className:"control-alert danger",children:Gt}):null,ee?e.jsx("div",{className:"control-alert success",children:ee}):null,gs?e.jsxs("div",{className:"control-alert warning",children:["LLM gateway unavailable: ",gs]}):null,vs?e.jsxs("div",{className:"control-alert danger",children:["LLM quota exceeded: ",vs]}):null,Yt?e.jsxs("div",{className:"control-alert danger",children:["Account disabled: ",Yt]}):null,js?e.jsxs("div",{className:"control-alert warning",children:["Session expired: ",js]}):null,Rt?e.jsxs("div",{className:"control-alert warning",children:["Admin access denied: ",Rt]}):null,Pt==="reconnecting"?e.jsx("div",{className:"control-alert warning",children:"Reconnecting sandbox route."}):null,Pt==="connecting"?e.jsx("div",{className:"control-alert neutral",children:"Connecting sandbox route."}):null,ot?e.jsxs("div",{className:"control-alert danger",children:["Sandbox offline: ",ot]}):null,Ns?e.jsx("div",{className:`control-alert ${Ns.tone}`,children:Ns.text}):null]}),sn=Ts(Ke);return e.jsxs(e.Fragment,{children:[e.jsxs(Ti,{topBar:Un,alerts:tn,sidebar:null,main:null,inspector:null,inspectorOpen:Xe,children:[e.jsxs(Ii,{children:[e.jsxs("div",{className:"control-explorer-toolbar",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Remote Codex"}),e.jsx("span",{children:(n==null?void 0:n.email)??"Product account"})]}),e.jsx("button",{type:"button",className:"control-icon-button",onClick:()=>V(Ct),"aria-label":`Open create panel for ${_t.toLowerCase()}`,title:`Create ${_t.toLowerCase()}`,children:"+"})]}),ke?e.jsxs("div",{className:"control-create-popover",children:[e.jsxs("div",{className:"control-panel-heading",children:[e.jsx("h2",{children:bt}),e.jsx("button",{type:"button",className:"control-icon-button quiet",onClick:()=>V(null),"aria-label":"Close create panel",children:"x"})]}),ke==="project"?e.jsxs("form",{onSubmit:Gs,className:"control-create-form",children:[e.jsx(dn,{label:"Project name",value:mt,onChange:j}),e.jsx(Oe,{type:"submit",disabled:!kt,children:"Create project"})]}):ke==="workspace"?e.jsxs("form",{onSubmit:Ks,className:"control-create-form",children:[e.jsx(dn,{label:"Workspace name",value:w,onChange:R}),Bt?e.jsx("p",{className:"control-rule-note",children:Bt}):null,e.jsx(Oe,{type:"submit",disabled:!ws,title:At,children:"Create workspace"})]}):e.jsxs("form",{onSubmit:An,className:"control-create-form",children:[e.jsx(dn,{label:"Session title",value:X,onChange:ve}),e.jsxs("label",{className:"control-field",children:[e.jsx("span",{children:"Provider"}),e.jsxs("select",{value:Pe,onChange:u=>ht(u.currentTarget.value),disabled:!ts,children:[e.jsx("option",{value:"codex",children:"Codex"}),e.jsx("option",{value:"claude",children:"Claude"}),e.jsx("option",{value:"opencode",children:"OpenCode"})]})]}),Bt?e.jsx("p",{className:"control-rule-note",children:Bt}):null,e.jsx(Oe,{type:"submit",disabled:!ts,title:Ut,children:"Create session"})]})]}):null,e.jsxs("div",{className:"control-sidebar-body",children:[e.jsxs("section",{className:"control-sidebar-section",children:[e.jsxs("div",{className:"control-sidebar-section-title",children:[e.jsx("span",{children:"Workspace"}),e.jsx("strong",{children:(Q==null?void 0:Q.name)??(J==null?void 0:J.name)??"Not selected"})]}),e.jsxs("div",{className:"control-context-card",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Project"}),e.jsx("strong",{children:(J==null?void 0:J.name)??"Choose project"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Workspace"}),e.jsx("strong",{children:(Q==null?void 0:Q.name)??"Choose workspace"})]})]})]}),e.jsxs("section",{className:"control-sidebar-section",children:[e.jsxs("div",{className:"control-sidebar-section-title",children:[e.jsx("span",{children:"Sessions"}),e.jsx("strong",{children:F.length})]}),e.jsx("div",{className:"control-nav-list","aria-label":"Session filters",children:Fs.map((u,N)=>e.jsxs("button",{type:"button",className:`control-nav-row ${N===0?"selected":""}`,children:[e.jsx("span",{children:u.label}),e.jsx("strong",{children:u.value})]},u.label))})]}),e.jsxs("section",{className:"control-sidebar-section",children:[e.jsx("div",{className:"control-sidebar-section-title",children:e.jsx("span",{children:"System"})}),e.jsxs("div",{className:"control-nav-list","aria-label":"System navigation",children:[e.jsxs("button",{type:"button",className:"control-nav-row","aria-label":`Open sandbox details, ${Ne(o==null?void 0:o.state)}`,onClick:()=>{ft("summary"),$e(!0)},children:[e.jsx("span",{children:"Sandbox"}),e.jsx("strong",{children:Ne(o==null?void 0:o.state)})]}),e.jsxs("button",{type:"button",className:"control-nav-row",onClick:()=>ue(!0),children:[e.jsx("span",{children:"Usage"}),e.jsxs("strong",{children:["$",lt.toFixed(2)]})]}),e.jsxs("button",{type:"button",className:"control-nav-row",onClick:()=>ue(!0),children:[e.jsx("span",{children:"Settings"}),e.jsx("strong",{children:(n==null?void 0:n.plan)??"dev"})]})]})]})]}),e.jsx("div",{className:"control-explorer-tree",children:et.projects?e.jsx("p",{className:"control-empty",children:"Loading projects..."}):q.length===0?e.jsx("p",{className:"control-empty",children:"No projects yet."}):q.map(u=>e.jsxs("div",{className:"control-tree-group",children:[Rs(Ae)===`project:${u.id}`?e.jsx(Bn,{label:"Project name",value:Ge,onChange:rt,onCancel:qt,onSubmit:ds}):e.jsxs("div",{className:`control-tree-item ${I===u.id?"selected":""}`,children:[e.jsxs("button",{type:"button","aria-label":`Select project ${u.name}`,onClick:()=>{z(u.id),ge(""),ae([]),H(""),oe(null),K(null),vt(),jt(),ze("idle")},className:"control-tree-row project",children:[e.jsx("span",{className:"control-tree-caret",children:e.jsx(za,{open:I===u.id})}),e.jsx("span",{className:"control-tree-icon",children:e.jsx(Oi,{})}),e.jsx("strong",{children:u.name}),e.jsx("small",{children:Ne(u.status)})]}),e.jsx(_n,{label:`project ${u.name}`,onEdit:()=>is({type:"project",id:u.id},u.name),onDelete:()=>Ze({type:"project",id:u.id})})]}),I===u.id?e.jsx("div",{className:"control-tree-children",children:et.workspaces?e.jsx("p",{className:"control-empty",children:"Loading workspaces..."}):ne.length===0?e.jsx("p",{className:"control-empty",children:"No workspaces in this project."}):ne.map(N=>e.jsxs("div",{className:"control-tree-group",children:[Rs(Ae)===`workspace:${N.id}`?e.jsx(Bn,{label:"Workspace name",value:Ge,onChange:rt,onCancel:qt,onSubmit:ds}):e.jsxs("div",{className:`control-tree-item ${B===N.id?"selected":""}`,children:[e.jsxs("button",{type:"button","aria-label":`Select workspace ${N.name}`,onClick:()=>{ge(N.id),H(""),oe(null),K(null),vt(),jt(),ze("idle")},className:"control-tree-row workspace",children:[e.jsx("span",{className:"control-tree-caret",children:e.jsx(za,{open:B===N.id})}),e.jsx("span",{className:"control-tree-icon",children:e.jsx($i,{})}),e.jsx("strong",{children:N.name}),e.jsx("small",{children:Ui(N)})]}),e.jsx(_n,{label:`workspace ${N.name}`,onEdit:()=>is({type:"workspace",id:N.id},N.name),onDelete:()=>Ze({type:"workspace",id:N.id})})]}),B===N.id?e.jsx("div",{className:"control-tree-children sessions",children:et.sessions?e.jsx("p",{className:"control-empty",children:"Loading sessions..."}):F.length===0?e.jsx("p",{className:"control-empty",children:"No sessions for this workspace."}):F.map(S=>e.jsx("div",{className:"control-tree-group",children:Rs(Ae)===`session:${S.id}`?e.jsx(Bn,{label:"Session title",value:Ge,onChange:rt,onCancel:qt,onSubmit:ds}):e.jsxs("div",{className:`control-tree-item ${pe===S.id?"selected":""}`,children:[e.jsxs("button",{type:"button","aria-label":`Open session ${S.title} from workspace browser`,onClick:()=>void Xt(S),className:"control-tree-row session",children:[e.jsx("span",{className:"control-tree-caret"}),e.jsx("span",{className:"control-tree-icon",children:e.jsx(Mi,{})}),e.jsx("strong",{children:S.title}),e.jsxs("small",{children:[ln(S.provider)," / ",Ne(S.status),S.workerSessionId?"":" / Not started"]})]}),e.jsx(_n,{label:`session ${S.title}`,onEdit:()=>is({type:"session",id:S.id},S.title),onDelete:()=>Ze({type:"session",id:S.id})})]})},S.id))}):null]},N.id))}):null]},u.id))})]}),e.jsxs("main",{className:"control-main-column",children:[e.jsxs("section",{className:"control-workspace-hero","aria-label":"Current control plane context",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Current workspace"}),e.jsx("h2",{children:(Q==null?void 0:Q.name)??(J==null?void 0:J.name)??"Select a workspace"}),e.jsx("p",{children:Q?`${(J==null?void 0:J.name)??"Project"} · ${As(Q.sourceType)}`:"Pick a project and workspace before creating sessions."})]}),e.jsxs("div",{className:"control-workspace-hero-actions",children:[e.jsx("span",{className:`control-status-pill ${Mt((o==null?void 0:o.state)??"unknown")}`,children:Ne(o==null?void 0:o.state)}),e.jsx(Oe,{onClick:()=>void Wt("start"),disabled:je.start.disabled,title:je.start.title,ariaLabel:`Sandbox ${je.start.label}`,children:je.start.label}),e.jsx(Oe,{onClick:()=>void Wt("restart"),disabled:je.restart.disabled,title:je.restart.title,ariaLabel:"Sandbox restart",children:je.restart.label}),e.jsx(Oe,{onClick:()=>void Wt("health"),disabled:je.health.disabled,title:je.health.title,ariaLabel:"Sandbox health",children:je.health.label}),e.jsxs(Oe,{onClick:()=>V(Ct),disabled:Ct==="workspace"?!ws:Ct==="session"?!ts:!kt,title:Ct==="workspace"?At:Ct==="session"?Ut:void 0,children:["New ",_t]})]})]}),e.jsxs("section",{className:"control-overview-strip","aria-label":"Control plane overview",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Projects"}),e.jsx("strong",{children:q.length})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Workspaces"}),e.jsx("strong",{children:ne.length})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Active sessions"}),e.jsx("strong",{children:as})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Sandbox"}),e.jsx("strong",{children:Ne(o==null?void 0:o.state)})]})]}),e.jsxs("section",{className:"control-panel control-session-list-panel",children:[e.jsxs("div",{className:"control-panel-heading",children:[e.jsx("h2",{children:"Sessions"}),e.jsx("span",{children:Q?`${F.length} in workspace`:"Select workspace"})]}),Q?e.jsxs(e.Fragment,{children:[Ut?e.jsx("p",{className:"control-rule-note",children:Ut}):null,et.sessions?e.jsx("p",{className:"control-empty",children:"Loading sessions..."}):F.length===0?e.jsx("p",{className:"control-empty",children:"No sessions in this workspace. Start the sandbox, then create a session."}):e.jsx("div",{className:"control-session-list",role:"list","aria-label":"Workspace sessions",children:F.map(u=>e.jsxs("article",{role:"listitem",className:`control-session-row ${pe===u.id?"selected":""}`,children:[e.jsxs("button",{type:"button","aria-label":`Open session ${u.title} summary`,className:"control-session-row-main",onClick:()=>void Xt(u),children:[e.jsx("strong",{children:u.title}),e.jsxs("span",{children:[ln(u.provider)," · ",on(u.lastActivityAt??u.updatedAt)]})]}),e.jsxs("div",{className:"control-session-row-state",children:[e.jsx(qi,{status:u.status}),e.jsx("span",{children:Hn(u)})]}),e.jsxs("div",{className:"control-session-row-actions",children:[e.jsx(Oe,{onClick:()=>void en(u),disabled:!s||!Ce,title:Ce?void 0:"Start the sandbox before opening this session.",ariaLabel:`${u.workerSessionId?"Resume":"Start"} session ${u.title} from summary`,children:u.workerSessionId?"Resume":"Start"}),e.jsxs("div",{className:"control-row-menu",children:[e.jsx("button",{type:"button",className:"control-row-menu-trigger","aria-label":`More actions for session ${u.title}`,"aria-haspopup":"menu","aria-expanded":me===u.id,onClick:()=>C(N=>N===u.id?null:u.id),children:"..."}),me===u.id?e.jsxs("div",{className:"control-row-menu-popover",role:"menu",children:[e.jsx("button",{type:"button",role:"menuitem",onClick:()=>Zs(u),children:"Show details"}),e.jsx("button",{type:"button",role:"menuitem",onClick:()=>Xs("Session ID",u.id),children:"Copy session ID"}),u.sandboxId?e.jsx("button",{type:"button",role:"menuitem",onClick:()=>Xs("Sandbox ID",u.sandboxId),children:"Copy sandbox ID"}):null,e.jsx("button",{type:"button",role:"menuitem",disabled:!s||!u.workerSessionId||!Ce,title:u.workerSessionId?void 0:"Session has not been started yet.",onClick:()=>{C(null),Qs(u)},children:"Close session"})]}):null]})]})]},u.id))}),e.jsx("div",{className:"control-action-row start",children:e.jsx(Oe,{onClick:()=>V("session"),disabled:!ts,title:Ut,children:"Create session"})})]}):e.jsx("p",{className:"control-empty",children:"Choose a workspace from the browser to see its sessions."})]}),e.jsxs("section",{className:"control-panel control-selected-panel control-context-summary-panel",children:[e.jsxs("div",{className:"control-panel-heading",children:[e.jsx("h2",{children:te?"Selected session":Q?"Workspace context":J?"Project context":"Selection"}),e.jsx("span",{children:te?Ne(te.status):Q?As(Q.sourceType):J?Ne(J.status):"Root"})]}),te?e.jsxs(e.Fragment,{children:[e.jsxs("dl",{className:"control-detail-list compact summary",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Title"}),e.jsx("dd",{children:te.title})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Provider"}),e.jsx("dd",{children:ln(te.provider)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Status"}),e.jsx("dd",{children:e.jsx("span",{className:`control-status-pill compact ${Mt(te.status)}`,children:Ne(te.status)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Last activity"}),e.jsx("dd",{children:on(Ws)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Sandbox"}),e.jsx("dd",{children:Ce?"Ready":Ne(o==null?void 0:o.state)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Runtime"}),e.jsx("dd",{children:Hn(te)})]})]}),e.jsxs("div",{className:"control-action-row start",children:[e.jsx(Oe,{onClick:()=>void en(te),disabled:!s||!Ce,title:Ce?void 0:"Start the sandbox before opening this session.",ariaLabel:`${te.workerSessionId?"Resume":"Start"} session ${te.title} from detail`,children:te.workerSessionId?"Resume":"Start sandbox session"}),e.jsx(Oe,{onClick:()=>{ft("metadata"),$e(!0)},children:"Details"})]})]}):Q?e.jsx(e.Fragment,{children:e.jsxs("dl",{className:"control-detail-list compact summary",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Workspace"}),e.jsx("dd",{children:Q.name})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Project"}),e.jsx("dd",{children:(J==null?void 0:J.name)??Q.projectId})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Source"}),e.jsx("dd",{children:As(Q.sourceType)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Sessions"}),e.jsx("dd",{children:F.length})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Active"}),e.jsx("dd",{children:as})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Not started"}),e.jsx("dd",{children:_s})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Sandbox"}),e.jsx("dd",{children:Ne(o==null?void 0:o.state)})]})]})}):J?e.jsxs(e.Fragment,{children:[e.jsxs("dl",{className:"control-detail-list compact summary",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Selected project"}),e.jsx("dd",{children:J.name})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Status"}),e.jsx("dd",{children:Ne(J.status)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Workspaces"}),e.jsx("dd",{children:ne.length})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Path"}),e.jsx("dd",{children:Ss})]})]}),e.jsx("div",{className:"control-action-row start",children:e.jsx(Oe,{onClick:()=>V("workspace"),disabled:!ws,title:At,children:"Create workspace"})})]}):e.jsx("p",{className:"control-empty",children:"Select a project to open the workspace hierarchy."})]})]}),Xe?e.jsx("button",{type:"button",className:"control-inspector-scrim","aria-hidden":"true",tabIndex:-1,onClick:()=>$e(!1)}):null,e.jsxs(Ci,{eyebrow:te?"Session":Q?"Workspace":J?"Project":"Sandbox",hidden:!Xe,onClose:()=>$e(!1),children:[e.jsx("div",{className:"control-inspector-tabs",role:"tablist","aria-label":"Inspector sections",children:["summary","metadata","route","logs"].map(u=>e.jsx("button",{type:"button",role:"tab","aria-selected":Qe===u,className:Qe===u?"selected":"",onClick:()=>ft(u),children:u==="summary"?"Summary":u==="metadata"?"Metadata":u==="route"?"Route":"Logs"},u))}),Qe==="summary"?e.jsxs("div",{className:"control-inspector-tab-panel",role:"tabpanel",children:[e.jsxs("div",{className:"control-inspector-section",children:[e.jsxs("div",{className:"control-panel-heading compact",children:[e.jsx("h2",{children:"Sandbox"}),o?e.jsx("span",{children:o.resourceProfile}):null]}),o?e.jsxs("dl",{className:"control-detail-list compact summary",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"State"}),e.jsx("dd",{children:e.jsx("span",{className:`control-status-pill compact ${Mt(o.state)}`,children:Ne(o.state)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Stage"}),e.jsx("dd",{children:qs})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Health"}),e.jsx("dd",{children:In})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Last seen"}),e.jsx("dd",{children:on(Tn)})]})]}):e.jsx("p",{className:"control-empty",children:"Loading sandbox registry."})]}),e.jsxs("div",{className:"control-action-row",children:[e.jsx(Oe,{onClick:()=>void Wt("stop"),disabled:je.stop.disabled,title:je.stop.title,children:je.stop.label}),e.jsx(Oe,{onClick:os,disabled:je.inspect.disabled,title:je.inspect.title,children:je.inspect.label})]}),o&&typeof o.startupProgress=="number"&&o.startupProgress>0&&o.startupProgress<100?e.jsxs("div",{className:"control-progress",children:[e.jsx("span",{children:qs}),e.jsxs("span",{children:[o.startupProgress,"%"]}),e.jsx("div",{children:e.jsx("i",{style:{width:`${o.startupProgress}%`}})})]}):null,te||Q||J?e.jsxs("div",{className:"control-inspector-section",children:[e.jsxs("div",{className:"control-panel-heading compact",children:[e.jsx("h2",{children:te?"Session":Q?"Workspace":"Project"}),e.jsx("span",{children:te?Ne(te.status):Q?As(Q.sourceType):Ne(J==null?void 0:J.status)})]}),e.jsx("dl",{className:"control-detail-list compact summary",children:te?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Title"}),e.jsx("dd",{children:te.title})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Provider"}),e.jsx("dd",{children:ln(te.provider)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Runtime"}),e.jsx("dd",{children:Hn(te)})]})]}):Q?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Workspace"}),e.jsx("dd",{children:Q.name})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Sessions"}),e.jsx("dd",{children:F.length})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Active"}),e.jsx("dd",{children:as})]})]}):J?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Project"}),e.jsx("dd",{children:J.name})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Workspaces"}),e.jsx("dd",{children:ne.length})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Status"}),e.jsx("dd",{children:Ne(J.status)})]})]}):null})]}):e.jsxs("div",{className:"control-inspector-empty",children:[e.jsx("strong",{children:"No object selected"}),e.jsx("span",{children:"Select a project, workspace, or session to inspect its metadata."})]}),e.jsxs("div",{className:"control-inspector-section",children:[e.jsxs("div",{className:"control-panel-heading compact",children:[e.jsx("h2",{children:"Harness"}),e.jsx("span",{className:`control-status-pill ${Ja(Zt)}`,children:Ne(Zt)})]}),Ce?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"control-action-row",children:e.jsx(Oe,{onClick:()=>void zs(s,fe),disabled:!s||et.harness,children:et.harness?"Checking...":"Refresh"})}),ut?e.jsxs("div",{className:"control-alert warning",children:["Harness unavailable: ",ut]}):null,e.jsxs("dl",{className:"control-detail-list compact summary",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Key"}),e.jsx("dd",{children:W!=null&&W.keyPresent?"Present":"Not present"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Chemistry"}),e.jsx("dd",{children:W!=null&&W.chemistryToolsEnabled?"Enabled":"Disabled"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Health"}),e.jsx("dd",{children:W!=null&&W.health?"OK":"Not available"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Module"}),e.jsx("dd",{children:rn[fe]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Tools"}),e.jsx("dd",{children:he.length||"folder index"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Runs"}),e.jsx("dd",{children:Ot.length||"history available"})]})]})]}):e.jsx("p",{className:"control-empty",children:"Start the sandbox to inspect Harness tools."})]})]}):null,Qe==="metadata"?e.jsxs("div",{className:"control-inspector-tab-panel",role:"tabpanel",children:[te?e.jsxs("section",{className:"control-inspector-section",children:[e.jsx("div",{className:"control-panel-heading compact",children:e.jsx("h2",{children:"Session metadata"})}),e.jsxs("dl",{className:"control-detail-list",children:[e.jsx(Fe,{label:"Session ID",value:te.id}),e.jsx(Fe,{label:"Worker session",value:te.workerSessionId}),e.jsx(Fe,{label:"Workspace ID",value:te.workspaceId}),e.jsx(Fe,{label:"Sandbox ID",value:te.sandboxId}),e.jsxs("div",{children:[e.jsx("dt",{children:"Created"}),e.jsx("dd",{children:te.createdAt})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Updated"}),e.jsx("dd",{children:te.updatedAt})]})]})]}):null,Q?e.jsxs("section",{className:"control-inspector-section",children:[e.jsx("div",{className:"control-panel-heading compact",children:e.jsx("h2",{children:"Workspace metadata"})}),e.jsxs("dl",{className:"control-detail-list",children:[e.jsx(Fe,{label:"Workspace ID",value:Q.id}),e.jsx(Fe,{label:"Project ID",value:Q.projectId}),e.jsx(Fe,{label:"Path",value:Q.path}),e.jsxs("div",{children:[e.jsx("dt",{children:"Slug"}),e.jsx("dd",{children:Q.slug})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Created"}),e.jsx("dd",{children:Q.createdAt})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Updated"}),e.jsx("dd",{children:Q.updatedAt})]})]})]}):null,J?e.jsxs("section",{className:"control-inspector-section",children:[e.jsx("div",{className:"control-panel-heading compact",children:e.jsx("h2",{children:"Project metadata"})}),e.jsxs("dl",{className:"control-detail-list",children:[e.jsx(Fe,{label:"Project ID",value:J.id}),e.jsxs("div",{children:[e.jsx("dt",{children:"Slug"}),e.jsx("dd",{children:J.slug})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Created"}),e.jsx("dd",{children:J.createdAt})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Updated"}),e.jsx("dd",{children:J.updatedAt})]})]})]}):null,o?e.jsxs("section",{className:"control-inspector-section",children:[e.jsx("div",{className:"control-panel-heading compact",children:e.jsx("h2",{children:"Sandbox metadata"})}),e.jsxs("dl",{className:"control-detail-list",children:[e.jsx(Fe,{label:"Sandbox ID",value:o.id}),e.jsx(Fe,{label:"Image",value:o.image}),e.jsx(Fe,{label:"Worker ID",value:o.workerServiceName}),e.jsx(Fe,{label:"S3 prefix",value:o.s3Prefix}),o.statusReason?e.jsxs("div",{children:[e.jsx("dt",{children:"Status"}),e.jsx("dd",{children:o.statusReason})]}):null,o.lastFailureCode?e.jsxs("div",{children:[e.jsx("dt",{children:"Failure"}),e.jsx("dd",{children:o.lastFailureCode})]}):null,o.lastFailureMessage?e.jsxs("div",{children:[e.jsx("dt",{children:"Failure message"}),e.jsx("dd",{children:o.lastFailureMessage})]}):null,e.jsxs("div",{children:[e.jsx("dt",{children:"Created"}),e.jsx("dd",{children:o.createdAt})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Updated"}),e.jsx("dd",{children:o.updatedAt})]})]})]}):null]}):null,Qe==="route"?e.jsxs("div",{className:"control-inspector-tab-panel",role:"tabpanel",children:[e.jsxs("section",{className:"control-inspector-section",children:[e.jsxs("div",{className:"control-panel-heading compact",children:[e.jsx("h2",{children:"Route"}),e.jsx(Oe,{onClick:()=>void ls("connecting",pe),disabled:!Ce||!te,title:Ls,children:"Create route token"})]}),le?e.jsxs("dl",{className:"control-detail-list compact summary route-token",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Session"}),e.jsx("dd",{children:(te==null?void 0:te.title)??pe})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Connection"}),e.jsx("dd",{children:Va(Pt)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Token"}),e.jsxs("dd",{children:[on(le.expiresAt)," expiry"]})]})]}):e.jsx("p",{className:"control-empty",children:te?`Selected session: ${te.title}. Create a route token after the sandbox is running.`:"Select a session before creating a route token."})]}),le?e.jsxs("section",{className:"control-inspector-section",children:[e.jsx("div",{className:"control-panel-heading compact",children:e.jsx("h2",{children:"Route metadata"})}),e.jsxs("dl",{className:"control-detail-list",children:[e.jsx(Fe,{label:"Router URL",value:le.routerBaseUrl}),e.jsx(Fe,{label:"WebSocket URL",value:le.wsBaseUrl}),e.jsx(Fe,{label:"Worker socket",value:$}),e.jsxs("div",{children:[e.jsx("dt",{children:"Connection"}),e.jsx("dd",{children:Va(Pt)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Expires"}),e.jsx("dd",{children:le.expiresAt})]})]})]}):null]}):null,Qe==="logs"?e.jsxs("div",{className:"control-inspector-tab-panel",role:"tabpanel",children:[e.jsxs("section",{className:"control-inspector-section",children:[e.jsxs("div",{className:"control-panel-heading compact",children:[e.jsx("h2",{children:"Harness details"}),e.jsx("span",{className:`control-status-pill ${Ja(Zt)}`,children:Ne(Zt)})]}),Ce?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"control-segment-row",role:"tablist","aria-label":"Harness modules",children:Ds.map(u=>e.jsx("button",{type:"button",role:"tab","aria-selected":fe===u,className:fe===u?"selected":"",onClick:()=>void rs(u),disabled:et.harness||!(W!=null&&W.enabled)||!W.keyPresent,children:rn[u]},u))}),e.jsxs("dl",{className:"control-detail-list",children:[e.jsx(Fe,{label:"Base URL",value:W==null?void 0:W.baseUrl}),e.jsxs("div",{children:[e.jsx("dt",{children:"Enabled"}),e.jsx("dd",{children:W!=null&&W.enabled?"yes":"no"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Modules"}),e.jsx("dd",{children:Ds.map(u=>rn[u]).join(", ")})]})]}),e.jsxs("div",{className:"control-usage-events compact",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[rn[fe]," tools"]}),e.jsxs("small",{children:[he.length," advertised"]})]}),he.slice(0,5).map((u,N)=>e.jsxs("div",{children:[e.jsx("strong",{children:Ya(u,`tool-${N+1}`)}),e.jsx("span",{children:Za(u)||"tool"})]},`${fe}-tool-${N}`)),he.length===0&&ss?e.jsx("div",{children:e.jsx("span",{children:ss.slice(0,180)})}):null,he.length===0&&!ss?e.jsx("p",{className:"control-empty",children:"No tools reported for this module."}):null]}),e.jsxs("div",{className:"control-usage-events compact",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Recent runs"}),e.jsxs("small",{children:[Ot.length," reported"]})]}),Ot.slice(0,4).map((u,N)=>e.jsxs("div",{children:[e.jsx("strong",{children:Ya(u,`run-${N+1}`)}),e.jsx("span",{children:Za(u)||"run"})]},`${fe}-run-${N}`)),Ot.length===0&&ns?e.jsx("div",{children:e.jsx("span",{children:ns.slice(0,180)})}):null,Ot.length===0&&!ns?e.jsx("p",{className:"control-empty",children:"No runs reported yet."}):null]})]}):e.jsx("p",{className:"control-empty",children:"Start the sandbox to inspect Harness tools."})]}),h?e.jsxs("section",{className:"control-inspector-section",children:[e.jsxs("div",{className:"control-panel-heading compact",children:[e.jsx("h2",{children:"Admin inspection"}),e.jsx("span",{children:Ne(h.runtimeStatus.state)})]}),e.jsxs("dl",{className:"control-detail-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Namespace"}),e.jsx("dd",{children:h.sandbox.k8sNamespace??h.runtimeStatus.k8sNamespace??"not assigned"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Pod"}),e.jsx("dd",{children:h.sandbox.k8sPodName??h.runtimeStatus.k8sPodName??"not assigned"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Endpoint"}),e.jsx("dd",{children:h.endpoint.routerBaseUrl??"not assigned"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Worker URL"}),e.jsx("dd",{children:h.workerBaseUrl??"not assigned"})]})]}),h.runtimeStatus.statusReason?e.jsx("p",{className:"control-empty",children:h.runtimeStatus.statusReason}):null,e.jsx("div",{className:"control-usage-events",children:h.recentLifecycleErrors.length===0?e.jsx("p",{className:"control-empty",children:"No lifecycle audit entries."}):h.recentLifecycleErrors.slice(0,5).map(u=>e.jsxs("div",{children:[e.jsx("strong",{children:u.action}),e.jsx("small",{children:u.createdAt})]},u.id))})]}):e.jsxs("div",{className:"control-inspector-empty",children:[e.jsx("strong",{children:"No admin inspection loaded"}),e.jsx("span",{children:"Use Inspect from Summary to load sandbox runtime diagnostics."})]})]}):null]})]}),e.jsx(wn,{open:!!Ke,title:sn.title,description:sn.description,confirmLabel:"Delete",busy:!!(Et!=null&&Et.startsWith("Delete ")),onCancel:()=>Ze(null),onConfirm:Is})]})}const Vi="http://127.0.0.1:8790";function Xa({children:t}){const s=es(),[a,n]=r.useState(null);return r.useEffect(()=>{let d=!1;return Promise.resolve().then(()=>{d||n(ki())}),()=>{d=!0}},[s.pathname]),a===null?e.jsx("div",{className:"grid min-h-[60vh] place-items-center text-sm text-[var(--theme-fg-muted)]",children:"Loading account session..."}):a?t:e.jsx(Os,{to:"/control-plane/login",replace:!0,state:{from:s}})}function Ji(t){return{baseUrl:t.baseUrl,token:t.token}}function Gi(){if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search),s=t.get("control_plane_token"),a=t.get("control_plane_expires_at"),n=t.get("control_plane_base_url"),d=t.get("auth_error");return{token:s,expiresAt:a,baseUrl:n,error:d}}function Ki(){var ae;const t=nt(),s=es(),a=Qt(),[n,d]=r.useState("login"),[o,m]=r.useState((a==null?void 0:a.baseUrl)??Vi),[h,g]=r.useState((a==null?void 0:a.email)??"dev@example.com"),[b,E]=r.useState((a==null?void 0:a.displayName)??"Developer"),[x,p]=r.useState(""),[k,T]=r.useState(!1),[A,v]=r.useState(null),[D,Z]=r.useState(null),q=s.state,_=((ae=q==null?void 0:q.from)==null?void 0:ae.pathname)??"/control-plane",ne=r.useMemo(()=>{if(typeof window>"u")return;const I=new URL(window.location.href);return I.search="",I.toString()},[]);r.useEffect(()=>{const I=Gi();if(!I)return;if(I.error){Z(`OAuth sign in failed: ${I.error}`);return}if(!I.token||!I.baseUrl)return;const z={baseUrl:I.baseUrl,token:I.token};I.expiresAt&&(z.expiresAt=I.expiresAt),xn(z),ha(Ji(z)).then(B=>{xn({...z,email:B.user.email,displayName:B.user.displayName}),t("/control-plane",{replace:!0})}).catch(B=>{jn(),Z(B instanceof Error?B.message:"Unable to finish OAuth sign in.")})},[t]);async function c(I){I.preventDefault(),T(!0),Z(null),v(null);try{const z=n==="register"?await Bo(o,{email:h,password:x,displayName:b||null}):await Fo(o,{email:h,password:x});xn({baseUrl:o,token:z.session.token,expiresAt:z.session.expiresAt,email:z.user.email,displayName:z.user.displayName}),v("Account session is ready."),t(_,{replace:!0})}catch(z){z instanceof re&&z.payload.code==="conflict"?Z("An account already exists for this email. Use sign in instead."):Z(z instanceof Error?z.message:"Unable to authenticate.")}finally{T(!1)}}function F(I){window.location.assign(_o(o,I,ne))}return e.jsx("div",{className:"control-auth-shell",children:e.jsxs("section",{className:"control-auth-panel","aria-label":"Control plane account login",children:[e.jsxs("div",{className:"control-auth-aside",children:[e.jsx("p",{className:"control-kicker",children:"Remote Codex"}),e.jsx("h1",{children:"Control plane sign in"}),e.jsx("p",{children:"Use a product account to manage sandboxes, workspaces, route tokens, and usage from the cloud control plane."}),e.jsxs("div",{className:"control-auth-checks","aria-label":"Login capabilities",children:[e.jsx("span",{children:"Google"}),e.jsx("span",{children:"GitHub"}),e.jsx("span",{children:"Email password"})]})]}),e.jsxs("form",{onSubmit:c,className:"control-auth-form",children:[e.jsxs("div",{className:"control-auth-tabs",role:"tablist","aria-label":"Authentication mode",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":n==="login",onClick:()=>d("login"),children:"Sign in"}),e.jsx("button",{type:"button",role:"tab","aria-selected":n==="register",onClick:()=>d("register"),children:"Create account"})]}),e.jsxs("label",{className:"control-field",children:[e.jsx("span",{children:"Control plane URL"}),e.jsx("input",{value:o,onChange:I=>m(I.currentTarget.value)})]}),e.jsxs("div",{className:"control-oauth-row",children:[e.jsx("button",{type:"button",onClick:()=>F("google"),children:"Continue with Google"}),e.jsx("button",{type:"button",onClick:()=>F("github"),children:"Continue with GitHub"})]}),e.jsx("div",{className:"control-auth-divider",children:e.jsx("span",{children:"Email"})}),n==="register"?e.jsxs("label",{className:"control-field",children:[e.jsx("span",{children:"Display name"}),e.jsx("input",{value:b,onChange:I=>E(I.currentTarget.value)})]}):null,e.jsxs("label",{className:"control-field",children:[e.jsx("span",{children:"Email address"}),e.jsx("input",{type:"email",value:h,autoComplete:"email",onChange:I=>g(I.currentTarget.value)})]}),e.jsxs("label",{className:"control-field",children:[e.jsx("span",{children:"Password"}),e.jsx("input",{type:"password",value:x,autoComplete:n==="register"?"new-password":"current-password",minLength:8,onChange:I=>p(I.currentTarget.value)})]}),D?e.jsx("p",{className:"control-auth-error",children:D}):null,A?e.jsx("p",{className:"control-auth-message",children:A}):null,e.jsx("button",{type:"submit",className:"control-primary-button",disabled:k,children:k?"Working...":n==="register"?"Create account":"Sign in"})]})]})})}function Yi(t){return t.sandboxMode??(t.approvalMode==="guarded"?"workspace-write":"danger-full-access")}function Zi(t,s){const a=new Set(s.map(n=>n.id));return[...s,...t.filter(n=>!a.has(n.id))]}function zt(t,s){const a=new Set(s.map(n=>n.id));return[...t.filter(n=>!a.has(n.id)),...s]}function Xi(t,s){return{...t,pendingRequests:[...t.pendingRequests.filter(a=>a.id!==s.id),s]}}function Qi(t,s){const a=t.pendingRequests.filter(n=>n.id!==s);return a.length===t.pendingRequests.length?t:{...t,pendingRequests:a}}function ia(t,s,a){const n=s.filter(h=>!a.has(h.id)),d=t.filter(h=>!a.has(h.id));if(d.length===0)return n;const o=new Map(n.map(h=>[h.id,h]));return[...d.map(h=>o.get(h.id)??h),...n.filter(h=>!d.some(g=>g.id===h.id))].sort((h,g)=>h.createdAt.localeCompare(g.createdAt))}function ed(t){if(!t||typeof t!="object")return!1;const s=t;return typeof s.id=="string"&&(s.kind==="requestUserInput"||s.kind==="planDecision")&&typeof s.title=="string"&&typeof s.createdAt=="string"&&Array.isArray(s.questions)}function Wr(t,s){var o,m;if(!t||t.kind!==s.kind)return s;const a=h=>{let g=h;const b=typeof s.sequence=="number"&&Number.isFinite(s.sequence)?s.sequence:typeof t.sequence=="number"&&Number.isFinite(t.sequence)?t.sequence:null;b!==null&&g.sequence!==b&&(g={...g,sequence:b});const E=typeof s.transcriptOrder=="number"&&Number.isFinite(s.transcriptOrder)?s.transcriptOrder:typeof t.transcriptOrder=="number"&&Number.isFinite(t.transcriptOrder)?t.transcriptOrder:null;return E!==null&&g.transcriptOrder!==E&&(g={...g,transcriptOrder:E}),g};if(t.kind==="agentMessage"&&s.kind==="agentMessage")return a(t.text.length>s.text.length?{...s,text:t.text,sequence:s.sequence??t.sequence??null}:s);const n=((o=t.detailText)==null?void 0:o.trim())||t.text.trim(),d=((m=s.detailText)==null?void 0:m.trim())||s.text.trim();return a(n.length>d.length?t:s)}function td(t,s,a){if(!t||s&&s.turnId!==t.turnId)return s;const n=a.find(x=>x.id===t.turnId),d=new Map((n==null?void 0:n.items.map(x=>[x.id,x]))??[]),o=(n==null?void 0:n.items.filter(x=>x.kind==="agentMessage").map(x=>x.text.trim()).filter(Boolean))??[],m=x=>x.kind==="agentMessage"&&x.text.trim().length>0&&o.some(p=>p.includes(x.text.trim()));if(!s){const x=t.items.filter(p=>{const k=d.get(p.id);return k?k.kind!==p.kind||typeof p.sequence=="number"&&Number.isFinite(p.sequence)&&k.sequence!==p.sequence:!m(p)});return x.length===0?null:{...t,items:x}}const h=new Map(t.items.map(x=>[x.id,x])),g=new Map(s.items.map(x=>[x.id,x])),E=[...t.items.map(x=>x.id),...s.items.map(x=>x.id).filter(x=>!h.has(x))].map(x=>{const p=g.get(x),k=h.get(x);if(!p){const T=d.get(x);return!T&&k&&m(k)||T&&T.kind===(k==null?void 0:k.kind)&&!(k&&typeof k.sequence=="number"&&Number.isFinite(k.sequence)&&T.sequence!==k.sequence)?null:k??null}return Wr(k,p)}).filter(x=>!!x);return E.length===0?null:{turnId:s.turnId,items:E,updatedAt:s.updatedAt.localeCompare(t.updatedAt)>=0?s.updatedAt:t.updatedAt}}function Ps(t,s){const a=t.filter(n=>n.id!==s.id);return[s,...a]}function sd(t){return`${t.threadId}:${t.objective}:${t.createdAt}`}function nd(t,s){const a=Date.parse(t.updatedAt)||0,d=(Date.parse(s.updatedAt)||0)>=a?s:t,o=d===s?t:s;return{...d,localGoalId:d.localGoalId??o.localGoalId??null}}function qr(t){const s=new Map;for(const a of t){const n=sd(a),d=s.get(n);s.set(n,d?nd(d,a):a)}return[...s.values()].sort((a,n)=>Date.parse(n.updatedAt)-Date.parse(a.updatedAt))}function cn(t,s){return qr([s,...t])}function ad(t){const s=new Intl.NumberFormat(void 0,{notation:"compact",maximumFractionDigits:1});return t.tokenBudget===null?`${s.format(t.tokensUsed)} tok`:`${s.format(t.tokensUsed)}/${s.format(t.tokenBudget)} tok`}function rd(t){const s=Math.max(0,Math.floor(t/60)),a=Math.floor(s/60),n=s%60;return a>0?`${a}h ${n}m`:`${s}m`}function Qa(t,s){if(!s)return null;const a=t.find(n=>n.model===s);return a?a.supportedReasoningEfforts.length>1:null}function od(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(16).slice(2,10)}`}function Us(t,s){return(t==null?void 0:t.items.some(a=>a.kind==="userMessage"&&a.text.trim()===s))??!1}function er(t){return t.replace(/\s*\[PHOTO\s+[^\]]+\]\s*/g," ").replace(/\s+/g," ").trim()}function gn(t,s){const a=er(s);return a?(t==null?void 0:t.items.some(n=>n.kind==="userMessage"&&er(n.text)===a))??!1:!1}function Fn(t){return(t==null?void 0:t.items.some(s=>s.kind==="userMessage"&&/\[PHOTO\s+\.\/\.temp\/threads\/[^\]]+\]/.test(s.text)))??!1}function ld(t,s){return t.find(a=>Us(a,s))??(s.includes("[PHOTO ")?t.find(a=>gn(a,s))??null:null)}function id(t,s,a,n){let d=!1;const o=t.map(m=>m.id!==s?m:(d=!0,{...m,tokenUsage:a,priceEstimate:n}));return d?o:t}const dd=3e3,cd=6e4,ud=5e3,md=2147e6,hd=["worker:read","worker:write","session:prompt","provider:turn:create","provider:turn:interrupt"];function pd(t){if(!t)return"no activity yet";const s=Date.parse(t);if(!Number.isFinite(s))return t;const a=Date.now()-s,n=Math.abs(a),d=a>=0?"ago":"from now",o=6e4,m=60*o,h=24*m;return n<o?"just now":n<m?`${Math.round(n/o)}m ${d}`:n<h?`${Math.round(n/m)}h ${d}`:`${Math.round(n/h)}d ${d}`}function fd({title:t,children:s}){const[a,n]=r.useState(!1);return e.jsxs("section",{className:"control-metadata-disclosure",children:[e.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>n(d=>!d),className:"control-metadata-trigger",children:[e.jsx("span",{children:t}),e.jsx("span",{children:a?"Hide":"Show"})]}),a?s:null]})}function Re({label:t,value:s}){const a=s&&s.trim()?s:"not assigned";return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsxs("dd",{children:[e.jsx("span",{children:a}),s?e.jsx("button",{type:"button",className:"control-copy-button",onClick:()=>{var n;(n=navigator.clipboard)==null||n.writeText(s)},children:"Copy"}):null]})]})}function xd(t){if(!t||typeof t!="object")return null;const s=t,a=Array.isArray(s.content)?s.content.filter(n=>typeof n=="string"):typeof s.content=="string"?[s.content]:[];return a.length===0?null:{content:a.join(`
|
|
5
|
+
`),format:typeof s.format=="string"?s.format:"text",name:typeof s.name=="string"?s.name:null}}function gd({selected:t,onClose:s}){const a=ca(),[n,d]=r.useState(t.kind==="artifact"?"preview":"logs"),[o,m]=r.useState(!0),h=t.kind==="artifact"?t.artifact:null,g=t.kind==="historyDetail"?t.detail:null,b=t.item,E=h?xd(h.payload):null,x=h?a.renderArtifact({artifact:h,expanded:o,onToggleExpanded:()=>m(k=>!k)}):null,p=[{id:"preview",label:"Preview"},{id:"source",label:"Source"},{id:"logs",label:"Logs"},{id:"metadata",label:"Metadata"}];return e.jsxs("aside",{className:"control-artifact-inspector","aria-label":"Thread inspector",children:[e.jsxs("header",{className:"control-artifact-inspector-header",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{children:(h==null?void 0:h.type)??b.kind}),e.jsx("h2",{children:(h==null?void 0:h.title)??(g==null?void 0:g.title)??b.text??"Timeline detail"})]}),e.jsx("button",{type:"button",onClick:s,"aria-label":"Close thread inspector",children:"x"})]}),e.jsx("div",{className:"control-artifact-tabs",role:"tablist","aria-label":"Thread details",children:p.map(k=>e.jsx("button",{type:"button",role:"tab","aria-selected":n===k.id,onClick:()=>d(k.id),children:k.label},k.id))}),e.jsxs("div",{className:"control-artifact-panel",children:[n==="preview"?t.kind!=="artifact"?e.jsx("div",{className:"control-artifact-empty",children:"Preview is available for artifacts. Open Logs for this item detail."}):x?e.jsx("div",{className:"control-artifact-preview",children:x}):e.jsx("div",{className:"control-artifact-empty",children:"No renderer is enabled for this artifact type."}):null,n==="source"?g?e.jsx("pre",{className:"control-artifact-source-raw",children:g.text}):E?e.jsxs("div",{className:"control-artifact-source",children:[e.jsxs("div",{children:[e.jsx("span",{children:E.format}),E.name?e.jsx("strong",{children:E.name}):null]}),e.jsx("pre",{children:E.content})]}):e.jsx("pre",{className:"control-artifact-source-raw",children:JSON.stringify(h==null?void 0:h.payload,null,2)}):null,n==="logs"?e.jsx("div",{className:"control-artifact-logs",children:g?e.jsx("pre",{children:g.text}):e.jsxs("dl",{className:"control-detail-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Timeline item"}),e.jsx("dd",{children:b.text||b.previewText||(h==null?void 0:h.summaryText)||"Artifact created"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Status"}),e.jsx("dd",{children:b.status??"completed"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Source turn"}),e.jsx("dd",{children:(h==null?void 0:h.sourceTurnId)??b.sourceTurnId??"not assigned"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Source item"}),e.jsx("dd",{children:(h==null?void 0:h.sourceItemId)??b.id})]})]})}):null,n==="metadata"?e.jsxs("dl",{className:"control-detail-list",children:[e.jsx(Re,{label:"Timeline item id",value:b.id}),e.jsx(Re,{label:"Timeline kind",value:b.kind}),h?e.jsxs(e.Fragment,{children:[e.jsx(Re,{label:"Artifact id",value:h.id}),e.jsx(Re,{label:"Plugin id",value:h.pluginId}),e.jsx(Re,{label:"Artifact type",value:h.type}),e.jsx(Re,{label:"Created",value:ps(h.createdAt)}),e.jsx(Re,{label:"Source turn",value:h.sourceTurnId}),e.jsx(Re,{label:"Source item",value:h.sourceItemId})]}):e.jsxs(e.Fragment,{children:[e.jsx(Re,{label:"Detail id",value:g==null?void 0:g.id}),e.jsx(Re,{label:"Detail kind",value:g==null?void 0:g.kind})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Payload"}),e.jsx("dd",{children:e.jsx("pre",{children:JSON.stringify(h?h.payload:{item:b,detail:g},null,2)})})]})]}):null]})]})}const bd=[],vd=[],jd=[],yd={sessions:{list:!1,read:!0,resume:!0,importLocal:!1},turns:{start:!0,streamInput:!1,steer:!1,interrupt:!0,compact:!1},branching:{fork:!1,hardRollback:!1,resumeAt:!1,rewindFiles:!1},controls:{planMode:!1,permissionRequests:!1,sandboxMode:!1,performanceMode:!1,goals:!1},management:{models:!1,mcpStatus:!1,skills:!1,hooks:!1,hookTrust:!1,hostConfigFiles:!1,providerSettings:!1},usage:{contextWindow:!0,tokenUsage:!0,costUsd:!1}};function wd(){const t=Qt();return t?{baseUrl:t.baseUrl,token:t.token}:null}function zr(t){switch(t){case"idle":case"running":case"interrupted":case"failed":case"not_loaded":case"system_error":return t;case"active":return"idle";default:return"not_loaded"}}function tr(t,s,a){const n=a==null?void 0:a.thread;return{id:t.id,workspaceId:s.id,provider:t.provider,providerSessionId:t.workerSessionId??(n==null?void 0:n.providerSessionId)??null,source:"supervisor",title:t.title||(n==null?void 0:n.title)||"Remote session",model:(n==null?void 0:n.model)??null,reasoningEffort:(n==null?void 0:n.reasoningEffort)??null,fastMode:(n==null?void 0:n.fastMode)??!1,collaborationMode:(n==null?void 0:n.collaborationMode)??"default",approvalMode:(n==null?void 0:n.approvalMode)??"guarded",sandboxMode:(n==null?void 0:n.sandboxMode)??null,status:(n==null?void 0:n.status)??zr(t.status),summaryText:(n==null?void 0:n.summaryText)??null,lastError:(n==null?void 0:n.lastError)??null,activeTurnId:(n==null?void 0:n.activeTurnId)??null,isLoaded:!!(n!=null&&n.isLoaded),isPinned:!1,createdAt:t.createdAt,updatedAt:(n==null?void 0:n.updatedAt)??t.updatedAt,lastTurnStartedAt:(n==null?void 0:n.lastTurnStartedAt)??t.lastActivityAt,lastTurnCompletedAt:(n==null?void 0:n.lastTurnCompletedAt)??null,...n!=null&&n.contextUsage?{contextUsage:n.contextUsage}:{}}}function Nd(t,s,a){const n=new URL(`/api/sandboxes/${encodeURIComponent(t.sandboxId)}/api/threads/${encodeURIComponent(s)}/assets/image`,t.routerBaseUrl);return n.searchParams.set("path",a),n.toString()}const Sd={status:"not_created",connectionButtonDisabled:!0,connectionButtonLabel:"Remote shell unavailable",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:"Remote shell adapter not connected",isMobileShell:!1,hasShell:!1,busy:!1,loading:!1,error:"Remote sandbox shell routing is not connected yet."};function Wn(t){return t instanceof re&&t.statusCode===401&&t.payload.code==="invalid_route_token"}function sr(t){return t instanceof re&&(t.statusCode===404||t.statusCode===409)}function Vr(t,s){return Object.is(t,s)?!0:JSON.stringify(t)===JSON.stringify(s)}function qn(t,s){let a=t.length!==s.length||t.some((o,m)=>{var h;return o.id!==((h=s[m])==null?void 0:h.id)});const n=new Map(t.map(o=>[o.id,o])),d=s.map(o=>{const m=n.get(o.id);return m&&Vr(m,o)?m:(a=!0,o)});return a?d:t}function un(t,s){return Vr(t,s)?t:s}function kd(t,s){if(!t)return s;const a=qn(t.turns,zt(t.turns,s.turns)),n=qn(t.pendingRequests,ia(t.pendingRequests,s.pendingRequests,new Set)),d={...s,turns:a,pendingRequests:n,pendingSteers:qn(t.pendingSteers,s.pendingSteers)};return("answeredRequestNotes"in s||"answeredRequestNotes"in t)&&(d.answeredRequestNotes=un(t.answeredRequestNotes,s.answeredRequestNotes)??[]),("activityNotes"in s||"activityNotes"in t)&&(d.activityNotes=un(t.activityNotes,s.activityNotes)??[]),("livePlan"in s||"livePlan"in t)&&(d.livePlan=un(t.livePlan,s.livePlan)??null),("liveItems"in s||"liveItems"in t)&&(d.liveItems=un(t.liveItems,s.liveItems)??null),d}function Cd(){return e.jsx(Td,{})}function Td(){const{sessionId:t=""}=cr(),s=nt(),a=Jt(),n=r.useMemo(wd,[]),[d,o]=r.useState(null),[m,h]=r.useState(null),[g,b]=r.useState(null),[E,x]=r.useState([]),[p,k]=r.useState(null),[T,A]=r.useState(null),[v,D]=r.useState(null),[Z,q]=r.useState({prompt:"",attachments:[]}),[_,ne]=r.useState(!0),[c,F]=r.useState(!1),[ae,I]=r.useState(null),[z,B]=r.useState(0),[ge,pe]=r.useState("chat"),[H,me]=r.useState(!0),[C,le]=r.useState(null),oe=r.useRef(!1),$=r.useRef(null),K=r.useRef(null),W=r.useCallback(ee=>{D(ie=>{const ce=kd(ie,ee);return K.current=ce,ce})},[]),be=r.useCallback(async ee=>{if(!n)return null;const ie=await Tr(n,ee.sandbox.id,{projectId:ee.project.id,workspaceId:ee.workspace.id,sessionId:ee.session.id,scopes:hd});return A(ie),ie},[n]),fe=r.useCallback(async()=>!d||!m||!g||!p||d.state!=="running"?null:be({sandbox:d,project:m,workspace:g,session:p}),[be,m,d,p,g]),at=r.useCallback(async()=>{if(!n)return s("/control-plane/login",{replace:!0}),null;ne(!0),I(null);try{const ee=await ha(n);if(o(ee.sandbox),ee.sandbox.state!=="running")return k(null),A(null),D(null),K.current=null,I("Sandbox is not running. Start the sandbox from the control plane before opening chat."),null;const ie=await kr(n);for(const ce of ie.projects){const ue=await aa(n,ce.id);for(const ke of ue.workspaces){const V=await ra(n,ke.id),Xe=V.sessions.find(xt=>xt.id===t);if(!Xe)continue;const $e=await Cr(n,Xe.id),Qe=V.sessions.map(xt=>xt.id===$e.session.id?$e.session:xt),ft=await be({sandbox:ee.sandbox,project:ce,workspace:ke,session:$e.session});if(!ft)return I("Unable to issue a router token for this session."),null;if(h(ce),b(ke),x(Qe),k($e.session),!$e.session.workerSessionId)return D(null),K.current=null,I("Session resumed, but the worker did not return a thread id."),null;const Dt=await us(ft,$e.session.workerSessionId);return W(Dt),B(xt=>xt+1),{session:$e.session,token:ft,detail:Dt}}}return I("Session was not found in any project workspace."),null}catch(ee){return ee instanceof re&&ee.payload.code==="unauthorized"?(jn(),s("/control-plane/login",{replace:!0}),null):(I(ee instanceof Error?ee.message:"Unable to open control-plane session."),null)}finally{ne(!1)}},[W,n,be,s,t]);r.useEffect(()=>{at()},[at]),r.useEffect(()=>{le(null)},[t]),r.useEffect(()=>{if($.current&&(window.clearTimeout($.current),$.current=null),!T)return;const ee=Date.parse(T.expiresAt);if(!Number.isFinite(ee))return;const ie=Math.max(ud,Math.min(md,ee-Date.now()-cd));return $.current=window.setTimeout(()=>{fe().catch(ce=>{I(ce instanceof Error?ce.message:"Unable to refresh router token.")})},ie),()=>{$.current&&(window.clearTimeout($.current),$.current=null)}},[fe,T]);const ct=r.useCallback(async(ee={})=>{if(!(!T||!(p!=null&&p.workerSessionId))){ee.silent||I(null);try{W(await us(T,p.workerSessionId))}catch(ie){if(Wn(ie))try{const ce=await fe();if(ce&&p.workerSessionId){W(await us(ce,p.workerSessionId));return}}catch(ce){I(ce instanceof Error?ce.message:"Unable to refresh worker thread.");return}if(sr(ie)&&!oe.current){oe.current=!0;try{await at();return}finally{oe.current=!1}}I(ie instanceof Error?ie.message:"Unable to refresh worker thread.")}}},[W,at,fe,T,p==null?void 0:p.workerSessionId]);r.useEffect(()=>{if(!((v==null?void 0:v.thread.status)==="running"||!!(v!=null&&v.thread.activeTurnId)||c)||!T||!(p!=null&&p.workerSessionId))return;const ie=window.setInterval(()=>{ct({silent:!0})},dd);return()=>window.clearInterval(ie)},[v==null?void 0:v.thread.activeTurnId,v==null?void 0:v.thread.status,ct,T,c,p==null?void 0:p.workerSessionId]);async function Ye(ee){const ie=ee.prompt.trim();if(!ie||!T||!(p!=null&&p.workerSessionId))return!1;F(!0),I(null);try{return await $n(T,p.workerSessionId,{prompt:ie}),q({prompt:"",attachments:[]}),await ct(),B(ce=>ce+1),!0}catch(ce){if(Wn(ce))try{const ue=await fe();if(!ue||!p.workerSessionId)throw ce;await $n(ue,p.workerSessionId,{prompt:ie});const ke=await us(ue,p.workerSessionId);return W(ke),q({prompt:"",attachments:[]}),B(V=>V+1),!0}catch(ue){return I(ue instanceof Error?ue.message:"Unable to send prompt."),!1}if(sr(ce)&&!oe.current){oe.current=!0;try{const ue=await at();if(!(ue!=null&&ue.session.workerSessionId))throw ce;await $n(ue.token,ue.session.workerSessionId,{prompt:ie});const ke=await us(ue.token,ue.session.workerSessionId);return W(ke),q({prompt:"",attachments:[]}),B(V=>V+1),!0}catch(ue){return I(ue instanceof Error?ue.message:"Unable to send prompt."),!1}finally{oe.current=!1}}return I(ce instanceof Error?ce.message:"Unable to send prompt."),!1}finally{F(!1)}}async function yt(){var ee,ie;if(!(!T||!(p!=null&&p.workerSessionId))){F(!0),I(null);try{const ce=((ee=K.current)==null?void 0:ee.thread.activeTurnId)??void 0,ue=await Ha(T,p.workerSessionId,ce?{turnId:ce}:{});D(ke=>ke&&{...ke,thread:ue}),await ct({silent:!0})}catch(ce){if(Wn(ce))try{const ue=await fe();if(!ue||!p.workerSessionId)throw ce;const ke=((ie=K.current)==null?void 0:ie.thread.activeTurnId)??void 0,V=await Ha(ue,p.workerSessionId,ke?{turnId:ke}:{});D(Xe=>Xe&&{...Xe,thread:V}),W(await us(ue,p.workerSessionId));return}catch(ue){I(ue instanceof Error?ue.message:"Unable to interrupt turn.");return}I(ce instanceof Error?ce.message:"Unable to interrupt turn.")}finally{F(!1)}}}const qe=T?p!=null&&p.workerSessionId?void 0:"Reconnect this session before sending a prompt.":"Waiting for a router token...",ut=g?E.map(ee=>tr(ee,g,ee.id===(p==null?void 0:p.id)?v:null)):[],Le=p&&g?tr(p,g,v):null,mt=Le&&ut.every(ee=>ee.id!==Le.id)?[Le,...ut]:ut,j=(v==null?void 0:v.thread.status)??zr(p==null?void 0:p.status),w=pr(j),R=(v==null?void 0:v.thread.lastTurnStartedAt)??(v==null?void 0:v.thread.updatedAt)??(p==null?void 0:p.lastActivityAt)??(p==null?void 0:p.updatedAt)??null,X=(p==null?void 0:p.provider)??(v==null?void 0:v.thread.provider)??"codex",ve=(v==null?void 0:v.thread.model)??"default model",Pe=(T==null?void 0:T.expiresAt)??null,ht=e.jsxs("div",{className:"control-session-meta",children:[e.jsxs("dl",{className:"control-detail-list compact summary two",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Status"}),e.jsx("dd",{children:w})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Provider"}),e.jsx("dd",{children:X})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Workspace"}),e.jsx("dd",{children:(g==null?void 0:g.name)??(v==null?void 0:v.workspace.label)??"Unavailable"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Project"}),e.jsx("dd",{children:(m==null?void 0:m.name)??"None"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{children:ve})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Last activity"}),e.jsx("dd",{children:pd(R)})]})]}),e.jsx(fd,{title:"Diagnostics",children:e.jsxs("dl",{className:"control-detail-list",children:[e.jsx(Re,{label:"Control session id",value:(p==null?void 0:p.id)??t}),e.jsx(Re,{label:"Worker thread id",value:p==null?void 0:p.workerSessionId}),e.jsx(Re,{label:"Workspace path",value:(g==null?void 0:g.path)??(v==null?void 0:v.workspace.absPath)}),e.jsx(Re,{label:"Workspace id",value:g==null?void 0:g.id}),e.jsx(Re,{label:"Project id",value:m==null?void 0:m.id}),e.jsx(Re,{label:"Sandbox id",value:d==null?void 0:d.id}),e.jsx(Re,{label:"Router URL",value:(T==null?void 0:T.routerBaseUrl)??(d==null?void 0:d.routerBaseUrl)}),e.jsx(Re,{label:"Image",value:d==null?void 0:d.image}),e.jsx(Re,{label:"Worker service",value:d==null?void 0:d.workerServiceName}),e.jsx(Re,{label:"Session updated",value:ps((p==null?void 0:p.updatedAt)??null)}),e.jsx(Re,{label:"Route token expires",value:ps(Pe)})]})})]}),Ae=e.jsx("div",{className:"space-y-4 text-sm",children:e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-[var(--theme-fg-muted)]",children:"Remote Session"}),e.jsx("button",{type:"button",onClick:()=>void at(),disabled:_,className:"block w-full rounded-xl border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-60",children:_?"Reconnecting...":"Reconnect session"}),e.jsx("button",{type:"button",onClick:()=>void ct(),disabled:!T,className:"block w-full rounded-xl border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-3 py-2 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-60",children:"Refresh worker thread"})]})}),wt=r.useCallback(ee=>{le({kind:"artifact",...ee})},[]),Ge=r.useCallback(ee=>{le({kind:"historyDetail",...ee})},[]),rt=r.useCallback(async ee=>{if(!T||!(p!=null&&p.workerSessionId))throw new Error("Reconnect this session before loading item details.");return al(T,p.workerSessionId,ee)},[T,p==null?void 0:p.workerSessionId]),Ke=r.useMemo(()=>({scrollRequestKey:z,className:"thread-timeline-surface min-h-0 flex-1",onTailVisibilityChange:me,answeredRequestNotes:(v==null?void 0:v.answeredRequestNotes)??bd,activityNotes:(v==null?void 0:v.activityNotes)??vd,pendingSteers:(v==null?void 0:v.pendingSteers)??jd,onLoadHistoryItemDetail:rt,onSelectArtifact:wt,onSelectHistoryItemDetail:Ge}),[v==null?void 0:v.activityNotes,v==null?void 0:v.answeredRequestNotes,v==null?void 0:v.pendingSteers,wt,Ge,rt,z]),Ze=v?{busy:c,error:ae,model:v.thread.model,reasoningEffort:v.thread.reasoningEffort,fastMode:v.thread.fastMode??!1,collaborationMode:v.thread.collaborationMode,contextUsage:v.thread.contextUsage,capabilities:yd,toolboxItems:[],followTail:H,threadConnected:v.thread.isLoaded,disabled:!!qe,...qe?{disabledPlaceholder:qe}:{},draftPrompt:Z.prompt,draftAttachments:Z.attachments,onDraftChange:q,canInterrupt:!!v.thread.activeTurnId,onInterrupt:yt,shellControlState:Sd,onToggleView:()=>pe("shell"),onToggleFollow:()=>B(ee=>ee+1)}:null,Et=e.jsx("span",{className:"control-session-status-badge",children:w}),Lt=e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:e.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[e.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Remote shell transport unavailable"}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"The Terminal plugin is enabled, but this control-plane route does not yet provide the remote shell API adapter used by the main supervisor thread page."}),e.jsx("button",{type:"button",onClick:()=>pe("chat"),className:"mt-5 inline-flex h-9 items-center rounded-full border border-[var(--theme-border)] bg-[var(--theme-surface-strong)] px-4 text-sm font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-ring)] focus:ring-offset-2 focus:ring-offset-[var(--theme-surface)]",children:"Switch to chat"})]})}),Gt=r.useCallback(ee=>T&&(p!=null&&p.workerSessionId)?Nd(T,p.workerSessionId,ee):"",[T,p==null?void 0:p.workerSessionId]),Kt=r.useMemo(()=>({openThread:ee=>{s(`/control-plane/sessions/${ee}`)},getThreadHref:ee=>`/control-plane/sessions/${ee}`,getNewThreadHref:()=>"/control-plane",sendPrompt:Ye,interrupt:yt,getImageAssetUrl:Gt,shell:null}),[Gt,s]);return e.jsxs("div",{className:"control-chat-workspace",children:[e.jsx(hr,{threads:mt,detail:v,status:null,loading:_,error:_?null:ae,adapter:Kt,currentWorkspaceId:(g==null?void 0:g.id)??null,currentWorkspaceLabel:(g==null?void 0:g.name)??(v==null?void 0:v.workspace.label)??null,metaContent:ht,settingsContent:Ae,surfaceActions:Et,appMenuButton:e.jsx(fo,{}),appNavigationMenu:e.jsx(po,{currentPath:`/control-plane/sessions/${t}`,items:[{label:"Control Plane",href:"/control-plane"},{label:"Workspaces",href:"/workspaces"}],onNavigate:s}),onCloseAppNavigation:(a==null?void 0:a.closeNav)??(()=>{}),activeView:ge,timelineProps:Ke,shellEffectiveTheme:(a==null?void 0:a.effectiveTheme)??"dark",shellThemeMode:(a==null?void 0:a.themeMode)??"system",...a!=null&&a.setThemeMode?{onShellThemeModeChange:a.setThemeMode}:{},shellUnavailableContent:Lt,shellDisconnectedContent:Lt,shellContent:Lt,loadingContent:e.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Opening worker thread..."}),emptyContent:e.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"No worker thread is connected yet."}),...p?{currentThreadId:p.id}:{},...Ze?{composerProps:Ze}:{}}),C?e.jsx("div",{className:"control-artifact-inspector-overlay",children:e.jsx(gd,{selected:C,onClose:()=>le(null)})}):null]})}function Id({onLogin:t}){const[s,a]=r.useState(""),[n,d]=r.useState(""),[o,m]=r.useState(null),[h,g]=r.useState(!1);async function b(E){E.preventDefault(),m(null),g(!0);try{await t({username:s,password:n})}catch(x){x instanceof re?m(x.payload.message):m("Unable to sign in.")}finally{g(!1)}}return e.jsx("main",{className:"flex min-h-screen items-center justify-center bg-[var(--app-bg)] px-4 py-8 text-[var(--app-fg)]",children:e.jsxs("section",{className:"w-full max-w-sm rounded-[1.35rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] p-5 shadow-2xl shadow-[color-mix(in_oklch,var(--app-fg)_14%,transparent)] sm:p-6",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-muted)]",children:"Supervisor Access"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold tracking-normal text-[var(--theme-fg)]",children:"Sign in"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-[var(--theme-muted)]",children:"Use the admin credentials configured on this Remote Codex server."})]}),e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--theme-fg-soft)]",children:"Username"}),e.jsx("input",{autoComplete:"username",autoFocus:!0,className:"mt-2 h-11 w-full rounded-xl border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 text-sm text-[var(--theme-fg)] outline-none transition focus:border-[var(--theme-accent-solid)] focus:ring-2 focus:ring-[var(--theme-accent-border)]",disabled:h,name:"username",onChange:E=>a(E.target.value),value:s})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--theme-fg-soft)]",children:"Password"}),e.jsx("input",{autoComplete:"current-password",className:"mt-2 h-11 w-full rounded-xl border border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 text-sm text-[var(--theme-fg)] outline-none transition focus:border-[var(--theme-accent-solid)] focus:ring-2 focus:ring-[var(--theme-accent-border)]",disabled:h,name:"password",onChange:E=>d(E.target.value),type:"password",value:n})]}),o&&e.jsx("p",{className:"rounded-xl border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-sm text-[var(--status-danger-fg)]",children:o}),e.jsx("button",{className:"h-11 w-full rounded-xl bg-[var(--theme-accent-solid)] px-4 text-sm font-semibold text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-60",disabled:h||!s.trim()||!n,type:"submit",children:h?"Signing in...":"Sign in"})]})]})})}function zn(t,s){return t instanceof re?t.payload.message:t instanceof Error?t.message:s}function Ed(){var I;const[t,s]=r.useState(null),[a,n]=r.useState(""),[d,o]=r.useState(""),[m,h]=r.useState(""),[g,b]=r.useState(""),[E,x]=r.useState(!0),[p,k]=r.useState(!1),[T,A]=r.useState(!1),[v,D]=r.useState(null),[Z,q]=r.useState(null),[_,ne]=r.useState(!1);async function c(){var z;x(!0),q(null);try{xs();const B=await $s();s(B),n(((z=B.user)==null?void 0:z.username)??"")}catch(B){q(zn(B,"Unable to load account."))}finally{x(!1)}}r.useEffect(()=>{c()},[]);async function F(z){z.preventDefault(),k(!0),q(null),D(null);try{const B=await cl({username:a});s(ge=>ge!=null&&ge.authenticated?{...ge,user:B}:ge),n(B.username),D("Account updated.")}catch(B){q(zn(B,"Unable to update account."))}finally{k(!1)}}async function ae(z){z.preventDefault(),A(!0),q(null),D(null);try{if(m!==g){q("New passwords do not match.");return}await ul({currentPassword:d,newPassword:m}),o(""),h(""),b(""),D("Password changed.")}catch(B){q(zn(B,"Unable to change password."))}finally{A(!1)}}return e.jsx("main",{className:"min-h-screen bg-[var(--app-bg)] px-4 py-6 text-[var(--app-fg)] sm:px-6",children:e.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-5 pr-12 sm:pr-0",children:[e.jsxs("header",{className:"border-b border-[var(--theme-border)] pb-5",children:[e.jsx(It,{className:"text-sm text-[var(--theme-accent-strong)]",to:"/workspaces",children:"Back to workspaces"}),e.jsx("p",{className:"mt-4 text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-fg-muted)]",children:"Relay Account"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold text-[var(--theme-fg)]",children:"Account settings"})]}),E?e.jsx("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading account..."}):t!=null&&t.authenticated?e.jsxs(e.Fragment,{children:[Z?e.jsx(nr,{tone:"danger",children:Z}):null,v?e.jsx(nr,{tone:"success",children:v}):null,e.jsxs("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Profile"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"Username changes apply to future shares and login."})]}),e.jsxs("form",{className:"space-y-4",onSubmit:F,children:[e.jsxs("label",{className:"block text-sm text-[var(--theme-fg-soft)]",children:["Email",e.jsx("input",{className:"relay-input mt-2 w-full",disabled:!0,readOnly:!0,value:((I=t.user)==null?void 0:I.email)??""})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[e.jsxs("label",{className:"block flex-1 text-sm text-[var(--theme-fg-soft)]",children:["Username",e.jsx("input",{className:"relay-input mt-2 w-full",onChange:z=>n(z.target.value),value:a})]}),e.jsxs("button",{className:"relay-button-primary inline-flex h-10 items-center justify-center gap-2",disabled:p||!a.trim(),type:"submit",children:[e.jsx(dt.Save,{className:"h-4 w-4"}),"Save"]})]}),e.jsxs("button",{className:"relay-button-secondary inline-flex items-center gap-2",onClick:()=>ne(!0),type:"button",children:[_?e.jsx(dt.CheckCircle2,{className:"h-4 w-4"}):e.jsx(dt.MailCheck,{className:"h-4 w-4"}),_?"Verification queued":"Verify email"]})]})]}),e.jsxs("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Password"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"Use at least 8 characters."})]}),e.jsxs("form",{className:"grid gap-4 sm:grid-cols-3",onSubmit:ae,children:[e.jsx(Vn,{label:"Current password",value:d,onChange:o}),e.jsx(Vn,{label:"New password",value:m,onChange:h}),e.jsx(Vn,{label:"Confirm password",value:g,onChange:b}),e.jsxs("button",{className:"relay-button-primary inline-flex h-10 items-center justify-center gap-2 sm:col-span-3 sm:w-fit",disabled:T||!d||m.length<8||!g,type:"submit",children:[e.jsx(dt.Save,{className:"h-4 w-4"}),"Change password"]})]})]})]}):e.jsx("section",{className:"rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] p-4 text-sm text-[var(--status-danger-fg)]",children:"Relay login is required."})]})})}function Vn({label:t,value:s,onChange:a}){return e.jsxs("label",{className:"block text-sm text-[var(--theme-fg-soft)]",children:[t,e.jsx("input",{autoComplete:"new-password",className:"relay-input mt-2 w-full",onChange:n=>a(n.target.value),type:"password",value:s})]})}function nr({tone:t,children:s}){return e.jsx("div",{className:`rounded-lg border px-3 py-2 text-sm ${t==="danger"?"border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] text-[var(--status-danger-fg)]":"border-[var(--status-success-border)] bg-[var(--status-success-bg)] text-[var(--status-success-fg)]"}`,children:s})}function Jn(t){return t instanceof re?t.payload.message:t instanceof Error?t.message:"Unable to update relay admin state."}function Rd(){const[t,s]=r.useState(null),[a,n]=r.useState(!0),[d,o]=r.useState(null),[m,h]=r.useState(null);async function g(){n(!0),o(null);try{xs(),s(await pl())}catch(x){o(Jn(x))}finally{n(!1)}}r.useEffect(()=>{g()},[]);async function b(x){h("registration"),o(null);try{const p=await fl(x);s(k=>k&&{...k,registrationEnabled:p.registrationEnabled})}catch(p){o(Jn(p))}finally{h(null)}}async function E(x,p){h(x),o(null);try{const k=await xl(x,p);s(T=>T&&{...T,users:T.users.map(A=>A.id===k.id?k:A)})}catch(k){o(Jn(k))}finally{h(null)}}return e.jsxs("main",{className:"min-h-screen bg-[var(--app-bg)] px-4 py-6 text-[var(--app-fg)] sm:px-6",children:[e.jsx(ga,{}),e.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-5",children:[e.jsxs("header",{className:"flex flex-col gap-3 border-b border-[var(--theme-border)] pb-5 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-fg-muted)]",children:"Relay Admin"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold text-[var(--theme-fg)]",children:"Users and devices"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"Manage relay accounts, registration, and connected devices."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(It,{className:"relay-button-secondary",to:"/relay-portal",children:"Portal"}),e.jsx("button",{className:"relay-button-secondary",onClick:()=>void g(),type:"button",children:"Refresh"})]})]}),a?e.jsx("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading relay admin..."}):d?e.jsx("section",{className:"rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] p-4 text-sm text-[var(--status-danger-fg)]",children:d}):t?e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Registration"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"New users can create relay accounts without email verification."})]}),e.jsx("button",{className:"relay-button-primary",disabled:m==="registration",onClick:()=>void b(!t.registrationEnabled),type:"button",children:t.registrationEnabled?"Disable":"Enable"})]})}),e.jsxs("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Users"}),e.jsx("div",{className:"mt-4 overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[44rem] border-collapse text-left text-sm",children:[e.jsx("thead",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:e.jsxs("tr",{children:[e.jsx("th",{className:"border-b border-[var(--theme-border)] py-2 pr-3",children:"User"}),e.jsx("th",{className:"border-b border-[var(--theme-border)] py-2 pr-3",children:"Email"}),e.jsx("th",{className:"border-b border-[var(--theme-border)] py-2 pr-3",children:"Role"}),e.jsx("th",{className:"border-b border-[var(--theme-border)] py-2 pr-3",children:"Status"}),e.jsx("th",{className:"border-b border-[var(--theme-border)] py-2 pr-3",children:"Actions"})]})}),e.jsx("tbody",{children:t.users.map(x=>e.jsxs("tr",{children:[e.jsx("td",{className:"border-b border-[var(--theme-border)] py-3 pr-3 font-medium text-[var(--theme-fg)]",children:x.username}),e.jsx("td",{className:"border-b border-[var(--theme-border)] py-3 pr-3 text-[var(--theme-fg-muted)]",children:x.email}),e.jsx("td",{className:"border-b border-[var(--theme-border)] py-3 pr-3 text-[var(--theme-fg-muted)]",children:x.role}),e.jsx("td",{className:"border-b border-[var(--theme-border)] py-3 pr-3 text-[var(--theme-fg-muted)]",children:x.enabled?"Enabled":"Disabled"}),e.jsx("td",{className:"border-b border-[var(--theme-border)] py-3 pr-3",children:e.jsx("button",{className:"relay-button-secondary",disabled:m===x.id||x.role==="admin",onClick:()=>void E(x.id,!x.enabled),type:"button",children:x.enabled?"Disable":"Enable"})})]},x.id))})]})})]}),e.jsxs("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Devices"}),e.jsx("div",{className:"mt-4 grid gap-3 lg:grid-cols-2",children:t.devices.map(x=>e.jsxs("article",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${x.connected?"bg-emerald-500":"bg-[var(--theme-fg-muted)]"}`}),e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:x.name})]}),e.jsx("p",{className:"mt-2 font-mono text-xs text-[var(--theme-fg-muted)]",children:x.id}),e.jsxs("p",{className:"mt-1 text-xs text-[var(--theme-fg-muted)]",children:["Owner: ",x.ownerUserId]})]},x.id))})]})]}):null]})]})}function Gn(t,s){return t instanceof re?t.payload.message:t instanceof Error?t.message:s}function Pd(){const t=nt(),[s,a]=r.useState(null),[n,d]=r.useState(""),[o,m]=r.useState(null),[h,g]=r.useState(!0),[b,E]=r.useState(null),[x,p]=r.useState(null);async function k(){g(!0),p(null);try{xs(),a(await Er())}catch(D){p(Gn(D,"Unable to load devices."))}finally{g(!1)}}r.useEffect(()=>{k()},[]);async function T(D){D.preventDefault(),E("create"),p(null);try{const Z=await Rr({name:n});m(Z),d(""),await k()}catch(Z){p(Gn(Z,"Unable to create device."))}finally{E(null)}}async function A(D){E(D.id),p(null);try{await Pr(D.id),(o==null?void 0:o.device.id)===D.id&&m(null),await k()}catch(Z){p(Gn(Z,"Unable to delete device."))}finally{E(null)}}function v(D){bn(D.id),vn(null),t("/workspaces")}return e.jsx("main",{className:"min-h-screen bg-[var(--app-bg)] px-4 py-6 text-[var(--app-fg)] sm:px-6",children:e.jsxs("div",{className:"mx-auto w-full max-w-6xl space-y-5 pr-12 sm:pr-0",children:[e.jsxs("header",{className:"flex flex-col gap-3 border-b border-[var(--theme-border)] pb-5 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsx(It,{className:"text-sm text-[var(--theme-accent-strong)]",to:"/workspaces",children:"Back to workspaces"}),e.jsx("p",{className:"mt-4 text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-fg-muted)]",children:"Relay Devices"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold text-[var(--theme-fg)]",children:"Device management"})]}),e.jsxs("button",{className:"relay-button-secondary inline-flex items-center gap-2",onClick:()=>void k(),type:"button",children:[e.jsx(dt.RefreshCcw,{className:"h-4 w-4"}),"Refresh"]})]}),x?e.jsx(Od,{tone:"danger",children:x}):null,o?e.jsx(Ud,{result:o}):null,e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(20rem,0.8fr)_minmax(0,1.2fr)]",children:[e.jsxs("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsxs("div",{className:"mb-4 flex items-start gap-3",children:[e.jsx("span",{className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] text-[var(--theme-fg)]",children:e.jsx(dt.Plus,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Add device"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"Create a token for one private supervisor."})]})]}),e.jsxs("form",{className:"space-y-3",onSubmit:T,children:[e.jsxs("label",{className:"block text-sm text-[var(--theme-fg-soft)]",children:["Device name",e.jsx("input",{className:"relay-input mt-2 w-full",onChange:D=>d(D.target.value),placeholder:"MacBook Pro",value:n})]}),e.jsxs("button",{className:"relay-button-primary inline-flex h-10 w-full items-center justify-center gap-2",disabled:b==="create"||!n.trim(),type:"submit",children:[e.jsx(dt.MonitorSmartphone,{className:"h-4 w-4"}),"Create device token"]})]})]}),e.jsxs("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Devices"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"Connect to an online device before opening workspaces."})]}),e.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-0.5 text-xs text-[var(--theme-fg-muted)]",children:(s==null?void 0:s.devices.length)??0})]}),h?e.jsx("p",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] p-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading devices..."}):s!=null&&s.devices.length?e.jsx("div",{className:"space-y-3",children:s.devices.map(D=>e.jsx(Ad,{busy:b===D.id,device:D,onConnect:()=>v(D),onDelete:()=>void A(D)},D.id))}):e.jsx("div",{className:"rounded-lg border border-dashed border-[var(--theme-border)] bg-[var(--theme-surface)] p-5 text-sm text-[var(--theme-fg-muted)]",children:"No devices yet. Create a token, then start `remote-codex relay-supervisor` on your private machine."})]})]})]})})}function Ad({device:t,busy:s,onConnect:a,onDelete:n}){return e.jsx("article",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] p-3",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${t.connected?"bg-[var(--status-success-fg)]":"bg-[var(--theme-fg-muted)]"}`}),e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:t.name})]}),e.jsx("p",{className:"mt-1 font-mono text-xs text-[var(--theme-fg-muted)]",children:t.tokenPreview}),e.jsx("p",{className:"mt-1 text-xs text-[var(--theme-fg-muted)]",children:t.connected?`Online since ${rr(t.connectedAt)}`:`Offline. Last heartbeat: ${rr(t.lastHeartbeatAt)}`})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{className:"relay-button-primary inline-flex items-center gap-2",disabled:!t.connected,onClick:a,type:"button",children:[e.jsx(dt.Plug,{className:"h-4 w-4"}),"Connect"]}),e.jsxs("button",{className:"relay-button-secondary inline-flex items-center gap-2",disabled:s,onClick:n,type:"button",children:[e.jsx(dt.Trash2,{className:"h-4 w-4"}),"Delete"]})]})]})})}function Ud({result:t}){const s=$d(t.token);return e.jsxs("section",{className:"rounded-lg border border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] p-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:["Token created for ",t.device.name]}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"Store this token now. It will not be shown again."}),e.jsx(ar,{label:"Device token",value:t.token}),e.jsx(ar,{label:"Supervisor command",value:s})]})}function ar({label:t,value:s}){async function a(){var n;try{await((n=navigator.clipboard)==null?void 0:n.writeText(s))}catch{}}return e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:t}),e.jsxs("button",{className:"relay-button-secondary inline-flex items-center gap-1 px-2 py-1 text-xs",onClick:()=>void a(),type:"button",children:[e.jsx(dt.Copy,{className:"h-3.5 w-3.5"}),"Copy"]})]}),e.jsx("code",{className:"block break-all rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-2 font-mono text-xs text-[var(--theme-fg)]",children:s})]})}function Od({tone:t,children:s}){return e.jsx("div",{className:"rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-sm text-[var(--status-danger-fg)]",children:s})}function $d(t){return`REMOTE_CODEX_RELAY_SERVER_URL=${Md()} REMOTE_CODEX_RELAY_AGENT_TOKEN=${t} remote-codex relay-supervisor`}function Md(){return typeof window>"u"?"wss://relay.example.com":window.location.origin.replace(/^https:\/\//,"wss://").replace(/^http:\/\//,"ws://")}function rr(t){return t?new Date(t).toLocaleString():"never"}function kn(t,s){return t instanceof re?t.payload.message:t instanceof Error?t.message:s}function Jr(){var _,ne;const t=nt(),[s,a]=r.useState(null),[n,d]=r.useState(null),[o,m]=r.useState(!0),[h,g]=r.useState(null),[b,E]=r.useState(null);async function x(){m(!0),g(null);try{xs();const c=await $s();a(c),c.authenticated?d(await Er()):d(null)}catch(c){g(kn(c,"Unable to load relay portal."))}finally{m(!1)}}r.useEffect(()=>{x()},[]);async function p(){E(null),await x()}async function k(c){const F=await Rr({name:c});E(F),await x()}async function T(c){await Pr(c),await x()}async function A(c){await ml(c),await x()}async function v(c){await hl(c),await x()}async function D(){await Ir(),a(await $s()),d(null),E(null)}function Z(c){bn(c),vn(null),t("/workspaces")}function q(c,F){bn(c),vn(F),t(`/threads/${encodeURIComponent(F)}`)}return o?e.jsx(Kn,{children:"Checking relay session..."}):s!=null&&s.authenticated?e.jsx(Kn,{children:e.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-5",children:[e.jsxs("header",{className:"flex flex-col gap-3 border-b border-[var(--theme-border)] pb-5 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-fg-muted)]",children:"Relay Portal"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold text-[var(--theme-fg)]",children:(_=s.user)==null?void 0:_.username}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:"Manage devices and shared Remote Codex sessions."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[((ne=s.user)==null?void 0:ne.role)==="admin"?e.jsx(It,{className:"relay-button-secondary",to:"/relay-admin",children:"Admin"}):null,e.jsx("button",{className:"relay-button-secondary",onClick:()=>void x(),type:"button",children:"Refresh"}),e.jsx("button",{className:"relay-button-secondary",onClick:()=>void D(),type:"button",children:"Sign out"})]})]}),h?e.jsx(da,{tone:"danger",children:h}):null,b?e.jsxs(da,{tone:"accent",children:["Device token for ",b.device.name,". Store it on the device as REMOTE_CODEX_RELAY_AGENT_TOKEN. It will not be shown again.",e.jsx("code",{className:"mt-2 block break-all rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-2 font-mono text-xs",children:b.token}),e.jsx("code",{className:"mt-2 block break-all rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] px-3 py-2 font-mono text-xs",children:_d(b.token)})]}):null,e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[minmax(0,1.2fr)_minmax(20rem,0.8fr)]",children:[e.jsxs(Yn,{title:"Devices",description:"Owned devices and sessions shared with you.",children:[e.jsx(Dd,{onCreate:k}),e.jsx("div",{className:"mt-4 divide-y divide-[var(--theme-border)] rounded-lg border border-[var(--theme-border)]",children:n!=null&&n.devices.length?n.devices.map(c=>e.jsxs("div",{className:"flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${c.connected?"bg-emerald-500":"bg-[var(--theme-fg-muted)]"}`}),e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:c.name})]}),e.jsx("p",{className:"mt-1 font-mono text-xs text-[var(--theme-fg-muted)]",children:c.tokenPreview}),e.jsx("p",{className:"mt-1 text-xs text-[var(--theme-fg-muted)]",children:c.connected?`Online. Last heartbeat: ${or(c.lastHeartbeatAt??c.connectedAt)}`:`Offline. Last online: ${or(c.lastHeartbeatAt??c.connectedAt)}`})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{className:"relay-button-primary",disabled:!c.connected,onClick:()=>Z(c.id),type:"button",children:"Open"}),e.jsx("button",{className:"relay-button-secondary",onClick:()=>void T(c.id),type:"button",children:"Delete"})]})]},c.id)):e.jsx("p",{className:"p-3 text-sm text-[var(--theme-fg-muted)]",children:"No devices yet."})}),e.jsxs("div",{className:"mt-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--theme-fg)]",children:"Shared"}),e.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-0.5 text-[11px] text-[var(--theme-fg-muted)]",children:(n==null?void 0:n.sharedWithMe.length)??0})]}),e.jsx("div",{className:"mt-3 space-y-3",children:n!=null&&n.sharedWithMe.length?n.sharedWithMe.map(c=>e.jsx("article",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] p-3",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium text-[var(--theme-fg)]",children:c.label||c.threadId}),e.jsxs("p",{className:"mt-1 text-xs text-[var(--theme-fg-muted)]",children:[c.ownerUsername," / ",c.deviceName]})]}),e.jsx("button",{className:"relay-button-primary",onClick:()=>q(c.deviceId,c.threadId),type:"button",children:"Continue"})]})},c.id)):e.jsx("p",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] p-3 text-sm text-[var(--theme-fg-muted)]",children:"No shared sessions."})})]})]}),e.jsx(Yn,{title:"Invite",description:"Share a single thread with another relay user.",children:e.jsx(Hd,{devices:(n==null?void 0:n.devices)??[],onShare:A})})]}),e.jsx("section",{children:e.jsx(Yn,{title:"Shared By Me",description:"Active invitations you created.",children:e.jsx("div",{className:"space-y-3",children:n!=null&&n.sharedByMe.length?n.sharedByMe.map(c=>e.jsxs("article",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-surface)] p-3",children:[e.jsx("p",{className:"text-sm font-medium text-[var(--theme-fg)]",children:c.label||c.threadId}),e.jsxs("p",{className:"mt-1 text-xs text-[var(--theme-fg-muted)]",children:["Shared with ",c.targetUsername," on ",c.deviceName]}),e.jsx("button",{className:"relay-button-secondary mt-3",onClick:()=>void v(c.id),type:"button",children:"Revoke"})]},c.id)):e.jsx("p",{className:"text-sm text-[var(--theme-fg-muted)]",children:"No active shares."})})})})]})}):e.jsx(Kn,{children:e.jsx(Ld,{registrationEnabled:(s==null?void 0:s.registrationEnabled)??!0,initialError:h,onAuthenticated:p})})}function Ld({registrationEnabled:t,initialError:s,onAuthenticated:a}){const[n,d]=r.useState("login"),[o,m]=r.useState(""),[h,g]=r.useState(""),[b,E]=r.useState(""),[x,p]=r.useState(""),[k,T]=r.useState(""),[A,v]=r.useState(s),[D,Z]=r.useState(!1);async function q(_){_.preventDefault(),Z(!0),v(null);try{n==="login"?await il({identifier:o,password:x}):await dl({email:h,username:b,password:x,registrationPassword:k}),await a()}catch(ne){v(kn(ne,"Unable to authenticate with relay."))}finally{Z(!1)}}return e.jsxs("section",{className:"w-full max-w-sm rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-5 shadow-xl shadow-black/10",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-fg-muted)]",children:"Relay Access"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold text-[var(--theme-fg)]",children:n==="login"?"Sign in":"Create account"}),e.jsxs("form",{className:"mt-5 space-y-4",onSubmit:q,children:[n==="login"?e.jsx(Vt,{autoComplete:"username",label:"Email or username",onChange:m,value:o}):e.jsxs(e.Fragment,{children:[e.jsx(Vt,{autoComplete:"email",label:"Email",onChange:g,value:h}),e.jsx(Vt,{autoComplete:"username",label:"Username",onChange:E,value:b}),e.jsx(Vt,{autoComplete:"one-time-code",label:"Registration password",onChange:T,type:"password",value:k})]}),e.jsx(Vt,{autoComplete:n==="login"?"current-password":"new-password",label:"Password",onChange:p,type:"password",value:x}),A?e.jsx(da,{tone:"danger",children:A}):null,e.jsx("button",{className:"relay-button-primary h-11 w-full",disabled:D,type:"submit",children:D?"Working...":n==="login"?"Sign in":"Register"})]}),e.jsx("button",{className:"mt-4 text-sm text-[var(--theme-accent-strong)] disabled:text-[var(--theme-fg-muted)]",disabled:n==="login"?!t:!1,onClick:()=>d(n==="login"?"register":"login"),type:"button",children:n==="login"?t?"Create relay account":"Registration is disabled":"Use an existing account"})]})}function Dd({onCreate:t}){const[s,a]=r.useState(""),[n,d]=r.useState(!1),[o,m]=r.useState(null);async function h(g){g.preventDefault(),d(!0),m(null);try{await t(s),a("")}catch(b){m(kn(b,"Unable to create device."))}finally{d(!1)}}return e.jsxs("form",{className:"flex flex-col gap-2 sm:flex-row",onSubmit:h,children:[e.jsx("input",{className:"relay-input min-w-0 flex-1",onChange:g=>a(g.target.value),placeholder:"Device name",value:s}),e.jsx("button",{className:"relay-button-primary",disabled:n||!s.trim(),type:"submit",children:"Create"}),o?e.jsx("p",{className:"text-sm text-[var(--status-danger-fg)]",children:o}):null]})}function Hd({devices:t,onShare:s}){const a=r.useMemo(()=>{var v;return((v=t[0])==null?void 0:v.id)??""},[t]),[n,d]=r.useState(a),[o,m]=r.useState(""),[h,g]=r.useState(""),[b,E]=r.useState(""),[x,p]=r.useState(!1),[k,T]=r.useState(null);r.useEffect(()=>{!n&&a&&d(a)},[n,a]);async function A(v){v.preventDefault(),p(!0),T(null);try{await s({targetUsername:o,deviceId:n,threadId:h,...b.trim()?{label:b}:{}}),m(""),g(""),E(""),T("Invitation created.")}catch(D){T(kn(D,"Unable to create invitation."))}finally{p(!1)}}return e.jsxs("form",{className:"space-y-3",onSubmit:A,children:[e.jsxs("label",{className:"block text-sm text-[var(--theme-fg-soft)]",children:["Device",e.jsx("select",{className:"relay-input mt-2 w-full",onChange:v=>d(v.target.value),value:n,children:t.map(v=>e.jsx("option",{value:v.id,children:v.name},v.id))})]}),e.jsx(Vt,{label:"Username",onChange:m,value:o}),e.jsx(Vt,{label:"Thread ID",onChange:g,value:h}),e.jsx(Vt,{label:"Label",onChange:E,value:b}),k?e.jsx("p",{className:"text-sm text-[var(--theme-fg-muted)]",children:k}):null,e.jsx("button",{className:"relay-button-primary",disabled:x||!n||!o.trim()||!h.trim(),type:"submit",children:"Invite"})]})}function Kn({children:t}){return e.jsxs("main",{className:"min-h-screen bg-[var(--app-bg)] px-4 py-6 text-[var(--app-fg)] sm:px-6",children:[e.jsx(ga,{}),e.jsx("div",{className:"flex min-h-[calc(100vh-3rem)] items-center justify-center",children:t})]})}function Yn({title:t,description:s,children:a}){return e.jsxs("section",{className:"rounded-lg border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-base font-semibold text-[var(--theme-fg)]",children:t}),e.jsx("p",{className:"mt-1 text-sm text-[var(--theme-fg-muted)]",children:s})]}),a]})}function Vt({label:t,value:s,onChange:a,type:n="text",autoComplete:d}){return e.jsxs("label",{className:"block text-sm text-[var(--theme-fg-soft)]",children:[t,e.jsx("input",{autoComplete:d,className:"relay-input mt-2 w-full",onChange:o=>a(o.target.value),type:n,value:s})]})}function da({tone:t,children:s}){return e.jsx("div",{className:`rounded-lg border px-3 py-2 text-sm ${t==="danger"?"border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] text-[var(--status-danger-fg)]":"border-[var(--theme-accent-border)] bg-[var(--theme-accent-soft)] text-[var(--theme-fg)]"}`,children:s})}function _d(t){return`REMOTE_CODEX_RELAY_SERVER_URL=${Bd()} REMOTE_CODEX_RELAY_AGENT_TOKEN=${t} remote-codex relay-supervisor`}function Bd(){return typeof window>"u"?"wss://relay.example.com":window.location.origin.replace(/^https:\/\//,"wss://").replace(/^http:\/\//,"ws://")}function or(t){return t??"never"}const lr=3,Fd=10,Wd=1e3,qd=2e3,Zn=5500,zd=3e3,Xn=0,ms=1,mn=3,Vd=["read-only","workspace-write","danger-full-access"],Jd=[],Gd=[],Kd=[],Yd={workspace:!0,toolUsage:!1,guide:!1,threadGraph:!1,extensions:!1,defaultTab:"workspace"};function Zd(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-current",children:e.jsx("path",{d:"M5.75 1.75c-.97 0-1.75.78-1.75 1.75v.25H3.5c-.97 0-1.75.78-1.75 1.75v6c0 .97.78 1.75 1.75 1.75h4.75c.97 0 1.75-.78 1.75-1.75v-.25h.5c.97 0 1.75-.78 1.75-1.75v-6c0-.97-.78-1.75-1.75-1.75h-4.75Zm-.5 2V3.5c0-.28.22-.5.5-.5h4.75c.28 0 .5.22.5.5v6a.5.5 0 0 1-.5.5H10v-4.5c0-.97-.78-1.75-1.75-1.75h-3Zm-1.75 1.25h4.75c.28 0 .5.22.5.5v6a.5.5 0 0 1-.5.5H3.5a.5.5 0 0 1-.5-.5v-6c0-.28.22-.5.5-.5Z"})})}function Xd(){return e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M4.25 2.25h5.2l2.3 2.3v9.2h-7.5a2 2 0 0 1-2-2v-7.5a2 2 0 0 1 2-2Z"}),e.jsx("path",{d:"M9.25 2.5v2.25h2.25"}),e.jsx("path",{d:"M7 6.75v4"}),e.jsx("path",{d:"m5.45 9.35 1.55 1.55 1.55-1.55"})]})}function hn({status:t}){return e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2.5 6.75A8.22 8.22 0 0 1 8 4.5c2.14 0 4.1.8 5.5 2.25"}),e.jsx("path",{d:"M4.75 9a4.95 4.95 0 0 1 6.5 0"}),e.jsx("path",{d:"M6.9 11.3a1.9 1.9 0 0 1 2.2 0"}),t==="connected"?e.jsx("path",{d:"m6.7 13.2.9.9 1.7-2"}):t==="offline"?e.jsx("path",{d:"M3 3l10 10"}):t==="detached"?null:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11.8 11.1a2.2 2.2 0 0 1-1.8 2.7"}),e.jsx("path",{d:"m10.7 11.35 1.3-.55-.55-1.3"})]})]})}function Qd(t,s){if(!t)return"Thread disconnected";switch(s.status){case"connected":return"Realtime updates connected";case"reconnecting":return"Realtime updates reconnecting";case"offline":return"Browser offline";case"checking":return"Checking realtime connection"}}function ec(){var Ea;const{id:t=""}=cr(),s=nt(),a=Jt(),n=ca(),d=r.useRef(""),o=r.useRef(null),m=r.useRef(null),h=r.useRef(null),g=r.useRef(!1),b=r.useRef(null),E=r.useRef(null),x=r.useRef(typeof navigator>"u"?!0:navigator.onLine),p=r.useRef(!1),k=r.useRef(null),T=r.useRef(null),A=r.useRef(0),v=r.useRef(0),D=r.useRef(null),Z=r.useRef(null),q=r.useRef(null),_=r.useRef(null),ne=r.useRef(new Set),[c,F]=r.useState(null),[ae,I]=r.useState([]),[z,B]=r.useState([]),[ge,pe]=r.useState(null),[H,me]=r.useState(null),[C,le]=r.useState(null),[oe,$]=r.useState(""),[K,W]=r.useState(null),[be,fe]=r.useState(null),[at,ct]=r.useState(!0),[Ye,yt]=r.useState(0),[qe,ut]=r.useState(!0),[Le,mt]=r.useState(!1),[j,w]=r.useState(!1),[R,X]=r.useState("chat"),ve=n.getThreadPanels().some(l=>l.kind==="terminal"),Pe=r.useMemo(()=>({fetchState:_l,createShell:Wl,terminateShell:ql,updateShell:zl,connectSocket:mi}),[]),ht=r.useCallback(l=>`/threads/${l}`,[]),Ae=r.useCallback(l=>{s(`/threads/${l}`)},[s]),wt=r.useCallback(l=>l?`/threads/new?workspaceId=${encodeURIComponent(l)}`:"/threads/new",[]),Ge=r.useCallback(({threadId:l,path:i})=>`/api/threads/${l}/assets/image?path=${encodeURIComponent(i)}`,[]),[rt,Ke]=r.useState({prompt:"",attachments:[]}),[Ze,Et]=r.useState(!1),[Lt,Gt]=r.useState(0),[Kt,ee]=r.useState(0),[ie,ce]=r.useState(0),[ue,ke]=r.useState(!1),[V,Xe]=r.useState(null),[$e,Qe]=r.useState(!1),[ft,Dt]=r.useState(!1),[xt,gs]=r.useState(!1),[bs,vs]=r.useState(null),[Nt,Yt]=r.useState("idle"),[gt,js]=r.useState({status:x.current?"checking":"offline",browserOnline:x.current,healthOk:!1,socketOpen:!1,lastHealthyAt:null}),[we,ot]=r.useState(null),[St,Rt]=r.useState([]),[ys,et]=r.useState({status:"idle",data:null,error:null}),[pt,Pt]=r.useState({status:"idle",data:null,error:null}),[ze,Te]=r.useState({status:"idle",data:null,error:null}),[Ht,kt]=r.useState({status:"idle",data:null,error:null}),[Ce,je]=r.useState({status:"idle",data:null,error:null}),[Ms,J]=r.useState(!1),[Q,te]=r.useState(!1),[ws,ts]=r.useState(()=>new Set),[Ns,At]=r.useState(!1),[Ut,Ls]=r.useState(!1),[Ct,_t]=r.useState({status:"idle",data:null,error:null}),[bt,Bt]=r.useState(null),[Ss,Zt]=r.useState(!1),[Ds,he]=r.useState(null),Ot=((Ea=C==null?void 0:C.hostConfigFiles.find(l=>{var i;return(i=l.roles)==null?void 0:i.includes("mcp")}))==null?void 0:Ea.name)??null,ss=r.useCallback(()=>{const l=d.current;d.current="",o.current=null,l&&r.startTransition(()=>{$(i=>i+l)})},[]),ns=r.useCallback(l=>{d.current+=l,o.current===null&&(o.current=window.requestAnimationFrame(()=>{ss()}))},[ss]),ks=r.useCallback((l,i)=>{fe(f=>{const P=(f==null?void 0:f.turnId)===l?f.items:[],O=P.findIndex(Ue=>Ue.id===i.id),Y=Wr(P[O],i),de=O>=0?P.map((Ue,L)=>L===O?Y:Ue):[...P,Y];return{turnId:l,items:de,updatedAt:new Date().toISOString()}})},[]),Hs=r.useCallback((l,i,f,P)=>{fe(O=>{const Y=(O==null?void 0:O.turnId)===l?O.items:[],de=Y.find(_e=>_e.id===i),Ue=(de==null?void 0:de.kind)==="agentMessage"?{...de,text:`${de.text}${f}`,sequence:P??de.sequence??null}:{id:i,kind:"agentMessage",text:f,sequence:P},L=Y.findIndex(_e=>_e.id===i),Je=L>=0?Y.map((_e,Be)=>Be===L?Ue:_e):[...Y,Ue];return{turnId:l,items:Je,updatedAt:new Date().toISOString()}})},[]),lt=r.useCallback(()=>{d.current="",o.current!==null&&(window.cancelAnimationFrame(o.current),o.current=null)},[]);r.useEffect(()=>{et({status:"idle",data:null,error:null}),Pt({status:"idle",data:null,error:null}),Te({status:"idle",data:null,error:null}),kt({status:"idle",data:null,error:null}),je({status:"idle",data:null,error:null}),At(!1),_t({status:"idle",data:null,error:null})},[t]);const as=r.useCallback(async()=>{if(t){_t(l=>({status:"loading",data:l.data,error:null}));try{const l=await Ll(t);_t({status:"ready",data:l,error:null})}catch(l){const i=l instanceof re?l.payload.message:"Unable to load export turns.";_t(f=>({status:"failed",data:f.data,error:i}))}}},[t]);async function _s(l){if(t){he(null),Ls(!0);try{const{blob:i,filename:f}=await Hl(t,l),P=URL.createObjectURL(i),O=document.createElement("a");O.href=P,O.download=f,document.body.append(O),O.click(),O.remove(),window.setTimeout(()=>URL.revokeObjectURL(P),3e4),At(!1)}catch(i){const f=i instanceof re?i.payload.message:"Unable to export transcript.";he(f)}finally{Ls(!1)}}}async function Bs(){if(t){je(l=>{var i;return{status:"loading",data:l.data??((i=q.current)==null?void 0:i.goal)??null,error:null}});try{const l=await Yl(t);je({status:"ready",data:l.goal,error:null}),F(i=>i&&(l.goal?{...i,goal:l.goal,goalHistory:cn(i.goalHistory??[],l.goal)}:{...i,goal:l.goal}))}catch(l){je(i=>({status:"failed",data:i.data,error:l instanceof re?l.payload.message:"Unable to load goal."}))}}}async function Fs(l){if(t){je(i=>{var f;return{status:"loading",data:i.data??((f=q.current)==null?void 0:f.goal)??null,error:null}});try{const i=await Zl(t,l);je({status:"ready",data:i.goal,error:null}),F(f=>f&&(i.goal?{...f,goal:i.goal,goalHistory:cn(f.goalHistory??[],i.goal)}:{...f,goal:i.goal}))}catch(i){throw je(f=>({status:"failed",data:f.data,error:i instanceof re?i.payload.message:"Unable to update goal."})),i}}}async function Cn(){if(t){je(l=>{var i;return{status:"loading",data:l.data??((i=q.current)==null?void 0:i.goal)??null,error:null}});try{const l=await Xl(t);je({status:"ready",data:null,error:null}),F(i=>i&&(l.goalHistory?{...i,goal:null,goalHistory:l.goalHistory}:{...i,goal:null}))}catch(l){throw je(i=>({status:"failed",data:i.data,error:l instanceof re?l.payload.message:"Unable to clear goal."})),l}}}async function Ws(l){te(!0);try{await Fs({status:l})}finally{te(!1)}}async function Tn(){te(!0);try{await Cn()}finally{te(!1)}}async function qs(){if(t){et(l=>({status:"loading",data:l.data,error:null}));try{const l=await ei(t);et({status:"ready",data:l,error:null})}catch(l){et(i=>({status:"failed",data:i.data,error:l instanceof re?l.payload.message:"Unable to load skills."}))}}}async function In(){if(t){Pt(l=>({status:"loading",data:l.data,error:null}));try{const l=await ti(t);Pt({status:"ready",data:l,error:null})}catch(l){Pt(i=>({status:"failed",data:i.data,error:l instanceof re?l.payload.message:"Unable to load MCP servers."}))}}}async function En(){if(t){Te(l=>({status:"loading",data:l.data,error:null}));try{const l=await si(t);Te({status:"ready",data:l,error:null})}catch(l){Te(i=>({status:"failed",data:i.data,error:l instanceof re?l.payload.message:"Unable to load hooks."}))}}}async function Rn(l){if(t){Te(i=>({status:"loading",data:i.data,error:null}));try{const i=await ni(t,l);Te({status:"ready",data:i,error:null})}catch(i){throw Te(f=>({status:"failed",data:f.data,error:i instanceof re?i.payload.message:"Unable to create hook."})),i}}}async function Ve(l){if(t){Te(i=>({status:"loading",data:i.data,error:null}));try{const i=await ai(t,l);Te({status:"ready",data:i,error:null})}catch(i){throw Te(f=>({status:"failed",data:f.data,error:i instanceof re?i.payload.message:"Unable to update hook."})),i}}}async function Cs(l){if(t){Te(i=>({status:"loading",data:i.data,error:null}));try{const i=await ri(t,l);Te({status:"ready",data:i,error:null})}catch(i){throw Te(f=>({status:"failed",data:f.data,error:i instanceof re?i.payload.message:"Unable to trust hook."})),i}}}async function zs(l){if(t){Te(i=>({status:"loading",data:i.data,error:null}));try{const i=await oi(t,l);Te({status:"ready",data:i,error:null})}catch(i){throw Te(f=>({status:"failed",data:f.data,error:i instanceof re?i.payload.message:"Unable to untrust hook."})),i}}}async function vt(){if(t){kt(l=>({status:"loading",data:l.data,error:null}));try{const l=await Ql(t);kt({status:"ready",data:l,error:null})}catch(l){kt(i=>({status:"failed",data:i.data,error:l instanceof re?l.payload.message:"Unable to load turns for forking."}))}}}async function jt(){if(!t)return;const l=await qa(t,{mode:"latest"});I(i=>Ps(i,l.thread.thread)),s(`/threads/${l.thread.thread.id}`)}async function Pn(l){if(!t)return;const i=await qa(t,{mode:"turn",turnId:l});I(f=>Ps(f,i.thread.thread)),s(`/threads/${i.thread.thread.id}`)}const Vs=r.useCallback(l=>{const i=_.current,f=i&&Object.keys(i).length>0?{...l,thread:{...l.thread,...i}}:l,P=q.current;q.current=f,W(f.livePlan??null);const O=P?zt(P.turns,f.turns):f.turns;fe(L=>td(L,f.liveItems??null,O)),je(L=>L.status==="idle"?L:{...L,data:f.goal??null});const Y=f.thread.activeTurnId===null&&f.thread.status!=="running";F(L=>L&&!f.goalHistory?{...f,turns:zt(L.turns,f.turns),pendingRequests:ia(L.pendingRequests,f.pendingRequests,ne.current),...L.goalHistory?{goalHistory:L.goalHistory}:{}}:L?{...f,turns:zt(L.turns,f.turns),pendingRequests:ia(L.pendingRequests,f.pendingRequests,ne.current)}:f),I(L=>Ps(L,f.thread));const de=new Map(f.turns.map(L=>[L.id,L])),Ue=new Set((f.pendingSteers??[]).map(L=>L.clientRequestId).filter(L=>!!L));Rt(L=>L.filter(Je=>{if(Ue.has(Je.clientRequestId))return!1;const _e=de.get(Je.turnId);return!(!_e||Us(_e,Je.prompt)||f.thread.activeTurnId!==Je.turnId&&_e.status!=="inProgress")})),ot(L=>{if(!L)return L;const Je=L.serverTurnId??L.id,_e=f.turns.some(M=>M.id===Je),Be=de.get(Je)??null,ye=ld(f.turns,L.prompt),y=!!ye;if(ye&&!L.serverTurnId)return{...L,id:ye.id,serverTurnId:ye.id,status:L.status==="failed"?L.status:ye.status==="inProgress"?"inProgress":L.status};if(Be&&L.serverTurnId)return Us(Be,L.prompt)||L.prompt.includes("[PHOTO ")&&(gn(Be,L.prompt)||Fn(Be))?Be.status==="inProgress"?{...L,id:Be.id,serverTurnId:Be.id,status:L.status==="failed"?L.status:"inProgress"}:null:{...L,id:Be.id,serverTurnId:Be.id,status:L.status==="failed"?L.status:"inProgress"};if(!L.serverTurnId&&L.prompt.includes("[PHOTO ")&&f.thread.activeTurnId&&f.thread.status==="running"){const M=de.get(f.thread.activeTurnId);if(M&&Fn(M))return{...L,id:M.id,serverTurnId:M.id,status:L.status==="failed"?L.status:"inProgress"}}return _e||Y&&y?null:L}),(Y||Z.current&&f.turns.some(L=>L.id===Z.current))&&(Z.current=null,lt(),$(""),W(null),fe(null))},[lt]);r.useEffect(()=>{q.current=c},[c]);const Js=r.useCallback(async({seedThread:l}={})=>{var de;const i=v.current+1;v.current=i;const f=(l==null?void 0:l.provider)??((de=q.current)==null?void 0:de.thread.provider)??"codex",[P,O,Y]=await Promise.allSettled([$r(),Ar(f),oa(f)]);v.current===i&&(P.status==="fulfilled"?I(l?Ps(P.value,l):P.value):l&&I(Ue=>Ps(Ue,l)),O.status==="fulfilled"&&(D.current=f,pe(O.value.status),me(O.value.capabilities),le(O.value.managementSchema)),Y.status==="fulfilled"&&(D.current=f,B(Y.value)))},[]),Ft=r.useCallback(async({showLoading:l=!0,clearError:i=!0,reportError:f=!0,limit:P=lr}={})=>{const O=A.current+1;A.current=O,l&&ut(!0),i&&he(null);try{const Y=await Ba(t,{limit:P});if(A.current!==O)return;Vs(Y),D.current!==Y.thread.provider&&Js({seedThread:Y.thread})}catch(Y){if(A.current!==O||!f)return;he(Y instanceof Error?Y.message:"Unable to load thread detail.")}finally{A.current===O&&ut(!1)}},[Vs,t,Js]),De=r.useCallback(()=>{var Ue;const l=((Ue=m.current)==null?void 0:Ue.readyState)??mn,i=l===ms,f=x.current,P=Date.now(),O=b.current!==null&&P-Date.parse(b.current)<=Zn,Y=E.current!==null&&P-E.current<=Zn;let de;f?i&&Y?de="connected":l===Xn||h.current!==null||O||Y||g.current?de="reconnecting":de="checking":de="offline",js(L=>L.status===de&&L.browserOnline===f&&L.healthOk===O&&L.socketOpen===i&&L.lastHealthyAt===b.current?L:{status:de,browserOnline:f,healthOk:O,socketOpen:i,lastHealthyAt:b.current})},[]);r.useEffect(()=>{A.current+=1,v.current+=1,F(null),Ke({prompt:"",attachments:[]}),mt(!1),Yt("idle"),ot(null),Rt([]),fe(null),_.current=null,Z.current=null,ne.current=new Set,b.current=null,E.current=null,p.current=!1,x.current=typeof navigator>"u"?!0:navigator.onLine,js({status:x.current?"checking":"offline",browserOnline:x.current,healthOk:!1,socketOpen:!1,lastHealthyAt:null})},[t]),r.useEffect(()=>{if(Nt==="idle")return;const l=window.setTimeout(()=>{Yt("idle")},Nt==="copied"?1200:1600);return()=>{window.clearTimeout(l)}},[Nt]),r.useEffect(()=>{if(typeof document>"u")return;const{documentElement:l,body:i}=document;return l.classList.add("thread-detail-scroll-locked"),i.classList.add("thread-detail-scroll-locked"),()=>{l.classList.remove("thread-detail-scroll-locked"),i.classList.remove("thread-detail-scroll-locked")}},[]),r.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const l=window.matchMedia("(max-width: 639px)"),i=()=>Et(l.matches);return i(),l.addEventListener("change",i),()=>{l.removeEventListener("change",i)}},[]),r.useEffect(()=>{var i,f;if(typeof window>"u")return;const l=()=>{const P=window.visualViewport,O=P?Math.max(0,Math.round(window.innerHeight-P.height-P.offsetTop)):0;ce(O),document.documentElement.style.setProperty("--thread-detail-keyboard-inset",`${O}px`)};return l(),(i=window.visualViewport)==null||i.addEventListener("resize",l),(f=window.visualViewport)==null||f.addEventListener("scroll",l),window.addEventListener("resize",l),()=>{var P,O;(P=window.visualViewport)==null||P.removeEventListener("resize",l),(O=window.visualViewport)==null||O.removeEventListener("scroll",l),window.removeEventListener("resize",l),document.documentElement.style.removeProperty("--thread-detail-keyboard-inset")}},[]),r.useEffect(()=>{if(typeof document>"u")return;const l=()=>{const i=document.activeElement,f=T.current,P=f==null?void 0:f.querySelector('[aria-label="Prompt"]');ke(!!(i&&P&&(i===P||P.contains(i))))};return l(),document.addEventListener("focusin",l),document.addEventListener("focusout",l),()=>{document.removeEventListener("focusin",l),document.removeEventListener("focusout",l)}},[R,c==null?void 0:c.thread.id,Ze]),r.useEffect(()=>{const l=T.current;if(!l||typeof ResizeObserver>"u")return;const i=l.querySelector("form")??l,f=()=>{Gt(Math.max(l.getBoundingClientRect().height,i.getBoundingClientRect().height))};f();const P=new ResizeObserver(()=>{f()});return P.observe(i),()=>{P.disconnect()}},[R,Ze]),r.useEffect(()=>{var P,O;const l=T.current;if(!l||!Ze||R!=="chat"){ee(0);return}const i=()=>{const Y=l.getBoundingClientRect();ee(Math.max(0,Math.ceil(window.innerHeight-Y.top)))};i(),window.addEventListener("resize",i),(P=window.visualViewport)==null||P.addEventListener("resize",i),(O=window.visualViewport)==null||O.addEventListener("scroll",i);let f=null;return typeof ResizeObserver<"u"&&(f=new ResizeObserver(i),f.observe(l)),()=>{var Y,de;window.removeEventListener("resize",i),(Y=window.visualViewport)==null||Y.removeEventListener("resize",i),(de=window.visualViewport)==null||de.removeEventListener("scroll",i),f==null||f.disconnect()}},[R,c==null?void 0:c.thread.id,Ze,ie,ue]),r.useEffect(()=>{Ft({showLoading:!0,limit:lr})},[Ft]),r.useEffect(()=>{let l=!1,i=null;const f=()=>{Ft({showLoading:!1,clearError:!1,reportError:!1})},P=()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},O=()=>{l||!x.current||h.current!==null||(h.current=window.setTimeout(()=>{h.current=null,!l&&L()},Wd),De())},Y=()=>{const y=m.current;if(m.current=null,y)try{y.close()}catch{}},de=y=>{if(y.threadId===t){if(y.type==="thread.output.delta"&&typeof y.payload.delta=="string"){const M=typeof y.payload.turnId=="string"?y.payload.turnId:null,se=typeof y.payload.itemId=="string"?y.payload.itemId:null,Ie=typeof y.payload.sequence=="number"&&Number.isFinite(y.payload.sequence)?y.payload.sequence:null;M&&se?Hs(M,se,y.payload.delta,Ie):ns(y.payload.delta),M&&ot(xe=>xe&&(xe.serverTurnId===null||xe.serverTurnId===M)?{...xe,serverTurnId:M,id:M,status:xe.status==="failed"?xe.status:"inProgress",tokenUsage:xe.tokenUsage}:xe)}if(y.type==="thread.context.updated"){const M=y.payload.contextUsage&&typeof y.payload.contextUsage=="object"?y.payload.contextUsage:null;if(M){const se=M;F(Ie=>Ie&&{...Ie,thread:{...Ie.thread,contextUsage:se}}),I(Ie=>Ie.map(xe=>xe.id===t?{...xe,contextUsage:se}:xe))}}if(y.type==="thread.turn.token.updated"&&typeof y.payload.turnId=="string"&&y.payload.tokenUsage&&typeof y.payload.tokenUsage=="object"){const M=y.payload.turnId,se=y.payload.tokenUsage,Ie=y.payload.priceEstimate&&typeof y.payload.priceEstimate=="object"?y.payload.priceEstimate:null;F(xe=>{if(!xe)return xe;const tt=id(xe.turns,M,se,Ie);return tt===xe.turns?xe:{...xe,turns:tt}}),ot(xe=>xe&&(xe.serverTurnId===M||xe.id===M)?{...xe,tokenUsage:se,priceEstimate:Ie}:xe)}if(y.type==="thread.turn.started"||y.type==="thread.turn.completed"||y.type==="thread.turn.failed"||y.type==="thread.updated"||y.type==="thread.goal.updated"||y.type==="thread.goal.cleared"||y.type==="thread.request.created"||y.type==="thread.request.resolved"){if(y.type==="thread.goal.updated"){const M=y.payload.goal&&typeof y.payload.goal=="object"?y.payload.goal:null,se=Array.isArray(y.payload.goalHistory)?y.payload.goalHistory:null;je({status:"ready",data:M,error:null}),F(Ie=>Ie&&(se?{...Ie,goal:M,goalHistory:se}:M?{...Ie,goal:M,goalHistory:cn(Ie.goalHistory??[],M)}:{...Ie,goal:M}))}if(y.type==="thread.goal.cleared"){const M=Array.isArray(y.payload.goalHistory)?y.payload.goalHistory:null;je({status:"ready",data:null,error:null}),F(se=>se&&(M?{...se,goal:null,goalHistory:M}:{...se,goal:null}))}if(f(),y.type==="thread.turn.started"){lt(),$(""),fe(null),Z.current=null;const M=typeof y.payload.turnId=="string"?y.payload.turnId:null;M&&ot(se=>se&&{...se,serverTurnId:M,id:M,status:se.status==="failed"?se.status:"inProgress",error:null,tokenUsage:se.tokenUsage})}if(y.type==="thread.turn.completed"||y.type==="thread.turn.failed"){lt(),$("");const M=typeof y.payload.turnId=="string"?y.payload.turnId:null;M&&(Z.current=M,y.type==="thread.turn.failed"&&ot(se=>se&&(se.serverTurnId===M||se.id===M)?{...se,status:"failed",error:typeof y.payload.error=="string"?y.payload.error:"Unable to complete the turn.",tokenUsage:se.tokenUsage}:se))}}if(y.type==="thread.request.created"&&ed(y.payload.request)&&(ne.current.delete(y.payload.request.id),F(M=>M&&Xi(M,y.payload.request))),y.type==="thread.request.resolved"&&typeof y.payload.requestId=="string"){const M=y.payload.requestId;ne.current.add(M),F(se=>se&&Qi(se,M))}if((y.type==="thread.item.started"||y.type==="thread.item.completed")&&y.payload.item&&typeof y.payload.item=="object"&&typeof y.payload.turnId=="string"){const M=y.payload.turnId,se=y.payload.item;typeof se.id=="string"&&typeof se.text=="string"&&ks(M,se)}y.type==="thread.plan.updated"&&Array.isArray(y.payload.plan)&&W({turnId:String(y.payload.turnId??""),explanation:typeof y.payload.explanation=="string"?y.payload.explanation:null,plan:y.payload.plan})}},Ue=()=>{const y=m.current;if(!(!y||y.readyState!==ms))try{y.send(JSON.stringify({type:"supervisor.ping",timestamp:new Date().toISOString()}))}catch{p.current=!0,Y(),O(),De()}},L=()=>{var se;if(l||!x.current){De();return}const y=((se=m.current)==null?void 0:se.readyState)??mn;if(y===Xn||y===ms){De();return}const M=Dr(de);m.current=M,De(),M.addEventListener("message",Ie=>{if(m.current===M)try{const xe=JSON.parse(Ie.data);(xe.type==="supervisor.connected"||xe.type==="supervisor.pong")&&(E.current=Date.now(),De())}catch{}}),M.addEventListener("open",()=>{m.current===M&&(p.current=!0,f(),Ue(),De())}),M.addEventListener("close",()=>{m.current===M&&(m.current=null),p.current=!0,O(),De()}),M.addEventListener("error",()=>{m.current===M&&(m.current=null),p.current=!0,O(),De()})},Je=async()=>{var y;if(!(l||!x.current||g.current)){g.current=!0,De();try{await Cl();const M=p.current;b.current=new Date().toISOString(),M&&(p.current=!1,f()),(((y=m.current)==null?void 0:y.readyState)??mn)!==ms&&L()}catch{b.current=null,p.current=!0,O()}finally{g.current=!1,De()}}},_e=()=>{x.current=!0,p.current=!0,De(),L(),Je()},Be=()=>{x.current=!1,b.current=null,E.current=null,p.current=!0,P(),Y(),De()},ye=()=>{var se;if(l||!x.current){De();return}const y=((se=m.current)==null?void 0:se.readyState)??mn,M=E.current===null?null:Date.now()-E.current;y===ms&&M!==null&&M>Zn?(p.current=!0,Y(),O()):y===ms?Ue():y!==Xn&&L(),Je(),De()};return window.addEventListener("online",_e),window.addEventListener("offline",Be),L(),Je(),i=window.setInterval(ye,qd),()=>{l=!0,window.removeEventListener("online",_e),window.removeEventListener("offline",Be),P(),i!==null&&window.clearInterval(i),lt(),Y()}},[Hs,lt,t,Ft,ns,De,ks]),r.useEffect(()=>{if(!((c==null?void 0:c.thread.activeTurnId)!==null||(c==null?void 0:c.thread.status)==="running"||we!==null||St.length>0||oe.length>0||K!==null||be!==null))return;const i=window.setInterval(()=>{Ft({showLoading:!1,clearError:!1,reportError:!1})},zd);return()=>{window.clearInterval(i)}},[c==null?void 0:c.thread.activeTurnId,c==null?void 0:c.thread.status,oe.length,be,K,Ft,St.length,we]);const Gs=r.useCallback(async()=>{var l;if(!(!c||c.turns.length===0||Le)){mt(!0),he(null);try{const i=(l=c.turns[0])==null?void 0:l.id,f=await Ba(t,{limit:Fd,...i?{beforeTurnId:i}:{}});F(P=>P?{...f,turns:Zi(P.turns,f.turns)}:f),I(P=>P.map(O=>O.id===f.thread.id?f.thread:O))}catch(i){he(i instanceof Error?i.message:"Unable to load earlier turns.")}finally{mt(!1)}}},[c,t,Le]);async function Ks(l){var Je,_e,Be;if(R==="shell"){if((c==null?void 0:c.thread.isLoaded)===!1)return await Wt({attachShell:!0}),!1;let ye=!1;if((V==null?void 0:V.shellInputEnabled)!==!0&&((V==null?void 0:V.loading)===!1&&(V==null?void 0:V.isConnecting)!==!0&&(V==null?void 0:V.status)!=="creating"&&(V==null?void 0:V.status)!=="workspace_missing"&&(await((Je=k.current)==null?void 0:Je.toggleConnection()),ye=!0),(V==null?void 0:V.isConnecting)===!0))return he("Connecting to the shell. Try again after it attaches."),!1;if(((_e=k.current)==null?void 0:_e.sendCommand(l.prompt))??!1)he(null);else return he(ye?"Shell is still attaching. Try again after it connects.":"Connect the shell before sending commands."),!1;return!0}w(!0),he(null),yt(ye=>ye+1);const i=q.current,f=i?{...i.thread,..._.current??{}}:null,P=(f==null?void 0:f.model)??null,O=(f==null?void 0:f.reasoningEffort)??null,Y=od(),de=`optimistic-${Date.now()}`,Ue=`optimistic-steer-${Y}`,L=new Date().toISOString();try{let ye=q.current;if(ye&&!ye.thread.isLoaded){const Ee={...ye.thread,..._.current??{}},it=await Fa(t,{...ye.thread.model?{model:ye.thread.model}:{},...ye.thread.sandboxMode?{sandboxMode:ye.thread.sandboxMode}:{}}),st={...it,thread:{...it.thread,model:Ee.model??it.thread.model,reasoningEffort:Ee.reasoningEffort??it.thread.reasoningEffort,collaborationMode:Ee.collaborationMode??it.thread.collaborationMode,sandboxMode:Ee.sandboxMode??it.thread.sandboxMode??null}};ye=st,q.current=st,F(an=>an?{...st,turns:zt(an.turns,st.turns)}:st),I(an=>an.map(Ra=>Ra.id===st.thread.id?st.thread:Ra))}const y=ye?{...ye.thread,..._.current??{}}:null,M=(y==null?void 0:y.status)==="running"?y.activeTurnId:null,se=R==="chat"&&!!M;se&&M?Rt(Ee=>[...Ee,{id:Ue,clientRequestId:Y,turnId:M,prompt:l.prompt,createdAt:L,status:"steering"}]):(lt(),$(""),ot({id:de,serverTurnId:null,startedAt:L,status:"sending",error:null,prompt:l.prompt,model:P,reasoningEffort:O,reasoningEffortAvailable:Qa(z,P),tokenUsage:null,priceEstimate:null}));const Ie={prompt:l.prompt,clientRequestId:Y,...y!=null&&y.model?{model:y.model}:{},...y!=null&&y.reasoningEffort?{reasoningEffort:y.reasoningEffort}:{},...y!=null&&y.collaborationMode?{collaborationMode:y.collaborationMode}:{},...y!=null&&y.sandboxMode?{sandboxMode:y.sandboxMode}:{},...(Be=l.attachments)!=null&&Be.length?{attachments:l.attachments}:{}},xe=await Jl(t,Ie),tt=_.current&&Object.keys(_.current).length>0?{...xe,..._.current}:xe;F(Ee=>Ee&&{...Ee,thread:tt}),I(Ee=>Ee.map(it=>it.id===tt.id?tt:it)),se&&M?tt.activeTurnId!==null&&tt.activeTurnId!==M&&tt.lastTurnStartedAt!==(y==null?void 0:y.lastTurnStartedAt)?(lt(),$(""),W(null),Rt(it=>it.filter(st=>st.id!==Ue)),ot({id:de,serverTurnId:tt.activeTurnId,startedAt:tt.lastTurnStartedAt??L,status:"inProgress",error:null,prompt:l.prompt,model:P,reasoningEffort:O,reasoningEffortAvailable:Qa(z,P),tokenUsage:null,priceEstimate:null})):Rt(it=>it.map(st=>st.id===Ue?{...st,turnId:tt.activeTurnId??st.turnId,status:"accepted"}:st)):(ot(Ee=>Ee&&Ee.id===de?{...Ee,id:tt.activeTurnId??Ee.id,serverTurnId:tt.activeTurnId??Ee.serverTurnId,status:"inProgress",error:null,tokenUsage:Ee.tokenUsage,priceEstimate:Ee.priceEstimate}:Ee),W(null)),Ke({prompt:"",attachments:[]})}catch(ye){const y=ye instanceof re?ye.payload.message:ye instanceof Error?ye.message:"Unable to send prompt.";ye instanceof re?he(ye.payload.message):he(y),Rt(M=>M.filter(se=>se.clientRequestId!==Y)),ot(M=>M&&M.id===de?{...M,status:"failed",error:y}:M)}finally{w(!1)}}async function An(){const l=c==null?void 0:c.thread.providerSessionId;if(l)try{await navigator.clipboard.writeText(l),Yt("copied")}catch{Yt("failed")}}async function Wt(l){if(c){w(!0),he(null),lt(),$("");try{if(c.thread.isLoaded){const f=await Vl(t);F(P=>P?{...f,turns:zt(P.turns,f.turns)}:f),Xe(null),I(P=>P.map(O=>O.id===f.thread.id?f.thread:O)),Qe(!1);return}const i=await Fa(t,{...c.thread.model?{model:c.thread.model}:{},...c.thread.sandboxMode?{sandboxMode:c.thread.sandboxMode}:{}});F(f=>f?{...i,turns:zt(f.turns,i.turns)}:i),I(f=>f.map(P=>P.id===i.thread.id?i.thread:P)),l!=null&&l.attachShell&&R==="shell"&&Qe(!0)}catch(i){he(i instanceof Error?i.message:"Unable to change connection state.")}finally{w(!1)}}}async function rs(){var l;if(R==="shell"){const i=((l=k.current)==null?void 0:l.sendControl("ctrl_c"))??!1;he(i?null:"Connect the shell before sending Ctrl-C.");return}w(!0),he(null);try{const i=c!=null&&c.thread.activeTurnId?await Wa(t,{turnId:c.thread.activeTurnId}):await Wa(t);F(f=>f&&{...f,thread:i}),I(f=>f.map(P=>P.id===i.id?i:P)),lt(),$("")}catch(i){he(i instanceof Error?i.message:"Unable to interrupt turn.")}finally{w(!1)}}async function os(l){if(!c)return;const i=c,f={..._.current??{},...l.model!==void 0?{model:l.model}:{},...l.reasoningEffort!==void 0?{reasoningEffort:l.reasoningEffort}:{},...l.fastMode!==void 0?{fastMode:l.fastMode}:{},...l.collaborationMode!==void 0?{collaborationMode:l.collaborationMode}:{},...l.sandboxMode!==void 0?{sandboxMode:l.sandboxMode}:{}},P={...c.thread,...f};Dt(!0),_.current=f,q.current={...c,thread:P},F(O=>O&&{...O,thread:P}),I(O=>O.map(Y=>Y.id===P.id?{...Y,...P}:Y));try{const O=await Gl(t,{...l.model!==void 0?{model:l.model}:{},...l.reasoningEffort!==void 0?{reasoningEffort:l.reasoningEffort}:{},...l.fastMode!==void 0?{fastMode:l.fastMode}:{},...l.collaborationMode!==void 0?{collaborationMode:l.collaborationMode}:{},...l.sandboxMode!==void 0?{sandboxMode:l.sandboxMode}:{}});_.current=null,q.current=i?{...i,thread:O}:null,F(Y=>Y&&{...Y,thread:O}),I(Y=>Y.map(de=>de.id===O.id?O:de))}catch(O){_.current=null,q.current=i,F(i),I(Y=>Y.map(de=>de.id===i.thread.id?i.thread:de)),he(O instanceof Error?O.message:"Unable to update thread settings.")}finally{Dt(!1)}}const ls=r.useCallback(async(l,i)=>{vs(l),he(null);try{const f=await li(t,l,i);F(P=>P?{...f,turns:zt(P.turns,f.turns)}:f),W(f.livePlan??null),fe(f.liveItems??null)}catch(f){he(f instanceof Error?f.message:"Unable to answer this request.")}finally{vs(null)}},[t]),Ys=r.useCallback(l=>Al(t,l),[t]);async function Xt(){if(c){gs(!0),he(null);try{const l=await Kl(t);F(i=>i&&{...i,thread:l}),I(i=>i.map(f=>f.id===l.id?l:f))}catch(l){he(l instanceof Error?l.message:"Unable to compact this thread context.")}finally{gs(!1)}}}async function Zs(l,i){try{const f=await Mr(l,{title:i});I(P=>P.map(O=>O.id===f.id?{...O,title:f.title,updatedAt:f.updatedAt}:O)),F(P=>P&&P.thread.id===f.id?{...P,thread:{...P.thread,title:f.title,updatedAt:f.updatedAt}}:P)}catch(f){throw he(f instanceof Error?f.message:"Unable to rename thread."),f}}async function Xs(){if(bt){Zt(!0),he(null);try{await Lr(bt.id),I(i=>i.filter(f=>f.id!==bt.id));const l=bt.id===(c==null?void 0:c.thread.id);if(Bt(null),l){const i=ae.find(f=>f.id!==bt.id&&f.workspaceId===(c==null?void 0:c.thread.workspaceId))??ae.find(f=>f.id!==bt.id);s(i?`/threads/${i.id}`:"/threads")}}catch(l){he(l instanceof Error?l.message:"Unable to delete thread.")}finally{Zt(!1)}}}function is(){X(l=>l==="chat"?(c!=null&&c.thread.isLoaded&&Qe(!0),"shell"):"chat")}async function qt(){var i;const l=await((i=k.current)==null?void 0:i.copyLastCommandOutput());he(l?null:"Unable to copy the last shell command output.")}function ds(l){var f,P;const i=l==="clear"?((f=k.current)==null?void 0:f.sendCommand("clear"))??!1:((P=k.current)==null?void 0:P.sendControl(l))??!1;he(i?null:"Connect the shell before sending control input.")}r.useEffect(()=>{if(!(!$e||R!=="shell"||!k.current||(c==null?void 0:c.thread.isLoaded)===!1||(V==null?void 0:V.loading)!==!1)){if((V==null?void 0:V.status)==="attached"){Qe(!1);return}Qe(!1),k.current.toggleConnection()}},[R,c==null?void 0:c.thread.isLoaded,$e,V==null?void 0:V.loading,V==null?void 0:V.status]),r.useEffect(()=>{if(R!=="shell")return;const l=window.requestAnimationFrame(()=>{var i;(i=k.current)==null||i.refreshLayout({syncBackendSize:!1})});return()=>{window.cancelAnimationFrame(l)}},[R]);const Ts=c&&c.workspacePathStatus==="missing"?"Restore this workspace path on the current machine before continuing.":null,Is=Ze&&R==="chat",Qs=Is&&ue?ie:0,en=Math.max(Lt,144),Un=Math.max(Kt,en+Qs),tn=Is?Un+12:0,sn=c?e.jsxs("dl",{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"relative pr-9",children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Session ID"}),e.jsx("dd",{className:"mt-1 break-all text-[var(--theme-fg)]",children:c.thread.providerSessionId??"Unavailable"}),c.thread.providerSessionId&&e.jsx("button",{type:"button","aria-label":"Copy session ID",title:Nt==="copied"?"Copied":Nt==="failed"?"Copy failed":"Copy session ID",onClick:()=>void An(),className:`thread-mobile-hit-target absolute bottom-0 right-0 inline-flex h-5 w-5 items-center justify-center rounded-full border shadow-sm shadow-stone-950/25 backdrop-blur transition ${Nt==="copied"?"ui-status-info":Nt==="failed"?"ui-status-danger":"border-[var(--theme-border)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg-soft)] hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]"}`,children:e.jsx("span",{className:"scale-[0.72]",children:e.jsx(Zd,{})})})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Source"}),e.jsx("dd",{className:"mt-1 text-[var(--theme-fg)]",children:c.thread.source==="local_codex_import"?`Imported local ${c.thread.provider} session`:`${c.thread.provider} supervisor thread`})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Status"}),e.jsx("dd",{className:"mt-1 text-[var(--theme-fg)]",children:pr(c.thread.status)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Created"}),e.jsx("dd",{className:"mt-1 text-[var(--theme-fg)]",children:ps(c.thread.createdAt)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Workspace"}),e.jsx("dd",{className:"mt-1 break-words text-[var(--theme-fg)]",children:c.workspace.absPath})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Workspace path"}),e.jsx("dd",{className:"mt-1 text-[var(--theme-fg)]",children:c.workspacePathStatus==="present"?"Present":"Missing on this machine"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-[var(--theme-fg-muted)]",children:"Active turn"}),e.jsx("dd",{className:"mt-1 text-[var(--theme-fg)]",children:c.thread.activeTurnId??"None"})]})]}):null,nn=c&&(H!=null&&H.controls.sandboxMode)?e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-[var(--theme-fg-muted)]",children:"Sandbox Mode"}),e.jsx("div",{className:"mt-2 space-y-1.5",children:Vd.map(l=>{const i=Yi(c.thread)===l;return e.jsx("button",{type:"button",disabled:ft,onClick:()=>void os({sandboxMode:l}),className:`block w-full rounded-xl border px-3 py-2 text-left text-sm transition ${i?"ui-status-warning":"border-[var(--theme-border)] bg-[var(--theme-surface-strong)] text-[var(--theme-fg-soft)] hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]"} disabled:cursor-not-allowed disabled:opacity-60`,children:l},l)})})]})}):null,u=(we==null?void 0:we.serverTurnId)??null,N=we&&c?c.turns.find(l=>(Us(l,we.prompt)||we.prompt.includes("[PHOTO ")&&(gn(l,we.prompt)||Fn(l)))&&(u&&l.id===u||l.id===we.id||Us(l,we.prompt)||we.prompt.includes("[PHOTO ")&&gn(l,we.prompt)))??null:null,S=r.useMemo(()=>we&&!N?{id:we.id,startedAt:we.startedAt,status:we.status,error:we.error,model:we.model,reasoningEffort:we.reasoningEffort,reasoningEffortAvailable:we.reasoningEffortAvailable,tokenUsage:we.tokenUsage,priceEstimate:we.priceEstimate,items:[{id:`${we.id}-user-message`,kind:"userMessage",text:we.prompt}]}:null,[N,we]),G=(c==null?void 0:c.thread.isLoaded)??!1,Me=G?gt.status==="connected"?"ui-action-success shadow-lg shadow-stone-950/20":gt.status==="reconnecting"?"thread-live-connection-reconnecting ui-status-success shadow-lg shadow-stone-950/20":gt.status==="offline"?"ui-status-danger shadow-lg shadow-stone-950/20":"ui-status-warning shadow-lg shadow-stone-950/20":"host-icon-button border shadow-lg shadow-black/10",He=Qd(G,gt),$t=[He,G?null:"Tap to connect this thread",gt.lastHealthyAt?`Last healthy ${ps(gt.lastHealthyAt)}`:null].filter(Boolean).join(" · "),On=G?e.jsx("div",{role:"status","aria-live":"polite","aria-label":He,title:$t,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition ${Me}`,children:e.jsx(hn,{status:gt.status})}):e.jsx("button",{type:"button",onClick:()=>void Wt(),disabled:j||!c,"aria-label":j?"Connecting thread":"Connect thread",title:j?"Connecting thread":$t,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition ${Me}`,children:e.jsx(hn,{status:"detached"})}),Qr=G?e.jsx("div",{title:$t,className:`hidden lg:inline-flex h-9 w-9 items-center justify-center rounded-full transition ${Me}`,children:e.jsx(hn,{status:gt.status})}):e.jsx("button",{type:"button",onClick:()=>void Wt(),disabled:j||!c,title:j?"Connecting thread":$t,className:`hidden lg:inline-flex h-9 w-9 items-center justify-center rounded-full transition ${Me}`,children:e.jsx(hn,{status:"detached"})}),va=Ce.data??(c==null?void 0:c.goal)??null,ja=(c==null?void 0:c.goalHistory)??[],ya=va?cn(ja,va):qr(ja),wa=(H==null?void 0:H.controls.goals)??!1,eo=e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"5.5"}),e.jsx("circle",{cx:"8",cy:"8",r:"2"}),e.jsx("path",{d:"M8 1.7v2M8 12.3v2M1.7 8h2M12.3 8h2"})]}),to=Ms&&wa?e.jsxs("div",{className:"host-dialog w-96 max-w-[calc(100vw-1.5rem)] rounded-3xl border p-3 text-left shadow-2xl shadow-black/20 backdrop-blur-xl",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"host-page-title text-sm font-semibold",children:"Goal monitor"}),e.jsx("p",{className:"host-muted text-xs",children:"Current thread only"})]}),e.jsx("button",{type:"button",onClick:()=>J(!1),className:"host-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Close"})]}),Ce.error?e.jsx("p",{className:"host-error mt-3 rounded-2xl border px-3 py-2 text-xs",children:Ce.error}):null,e.jsx("div",{className:"mt-3 max-h-[28rem] space-y-2 overflow-auto pr-1",children:ya.length===0?e.jsx("p",{className:"host-empty-state rounded-2xl border px-3 py-3 text-sm",children:"No goals in this thread yet."}):ya.map(l=>{const i=`${l.threadId}:${l.objective}:${l.createdAt}`,f=ws.has(i),P=["active","paused","budgetLimited"].includes(l.status);return e.jsxs("div",{className:`rounded-2xl border px-3 py-3 ${P?"ui-status-info":"host-surface-strong"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("button",{type:"button",onClick:()=>ts(O=>{const Y=new Set(O);return Y.has(i)?Y.delete(i):Y.add(i),Y}),className:"min-w-0 flex-1 text-left",children:e.jsx("p",{className:`text-sm font-medium leading-5 ${f?"":"line-clamp-2"}`,children:l.objective})}),e.jsx("span",{className:"host-muted shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] uppercase tracking-[0.14em]",children:l.status})]}),e.jsxs("div",{className:"host-muted mt-2 flex flex-wrap gap-2 text-[11px]",children:[e.jsx("span",{children:rd(l.timeUsedSeconds)}),e.jsx("span",{children:ad(l)}),e.jsxs("span",{title:ps(l.updatedAt),children:["Updated ",new Date(l.updatedAt).toLocaleTimeString()]})]}),P?e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",disabled:Q||l.status==="active",onClick:()=>void Ws("active"),className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-50",children:"Continue"}),e.jsx("button",{type:"button",disabled:Q||l.status==="paused",onClick:()=>void Ws("paused"),className:"host-secondary-button rounded-full border px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-50",children:"Pause"}),e.jsx("button",{type:"button",disabled:Q,onClick:()=>void Tn(),className:"rounded-full border border-[var(--status-danger-border)] px-3 py-1.5 text-xs text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-50",children:"Terminate"})]}):null]},i)})})]}):null,Na=wa?e.jsx("button",{type:"button","aria-label":"Open goal monitor",title:"Open goal monitor",onClick:()=>{J(l=>!l),Bs()},className:"ui-status-info inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full shadow-lg shadow-stone-950/20 transition lg:h-9 lg:w-9",children:eo}):null,Sa=e.jsx("button",{type:"button","aria-label":"Export transcript",title:"Export transcript",onClick:()=>At(!0),disabled:!c,className:"host-icon-button inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border shadow-lg shadow-black/10 transition disabled:cursor-not-allowed disabled:opacity-50 lg:h-9 lg:w-9",children:e.jsx(Xd,{})}),so=e.jsxs("div",{className:"relative flex items-center justify-end gap-1.5",children:[Sa,Na,On]}),no=e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[Sa,Na,Qr]}),ao=r.useMemo(()=>({livePlan:K,liveItems:be,respondingRequestId:bs,onRespondToRequest:ls,scrollRequestKey:Ye,bottomSpacer:tn,className:"thread-timeline-surface min-h-0 flex-1",onTailVisibilityChange:ct,loadingEarlier:Le,onLoadEarlier:Gs,onOpenThread:Ae,answeredRequestNotes:(c==null?void 0:c.answeredRequestNotes)??Jd,activityNotes:(c==null?void 0:c.activityNotes)??Gd,pendingSteers:(c==null?void 0:c.pendingSteers)??Kd,optimisticSteers:St,optimisticTurn:S}),[c==null?void 0:c.answeredRequestNotes,c==null?void 0:c.activityNotes,c==null?void 0:c.pendingSteers,Gs,ls,be,K,Le,Ae,St,bs,Ye,tn,S]),ka=c?{busy:R==="chat"?j:!1,settingsBusy:ft,error:null,model:c.thread.model,reasoningEffort:c.thread.reasoningEffort,fastMode:c.thread.fastMode??!1,collaborationMode:c.thread.collaborationMode,modelOptions:z,contextUsage:c.thread.contextUsage,capabilities:H,toolboxItems:(C==null?void 0:C.toolboxItems)??[],hookCommandTemplates:(C==null?void 0:C.hookCommandTemplates)??[],mcpConfigFormat:(C==null?void 0:C.mcpConfigFormat)??"none",followTail:at,threadConnected:c.thread.isLoaded,shellAvailable:ve,disabled:!!Ts,...Ts?{disabledPlaceholder:Ts}:{},shellControlState:V,draftPrompt:rt.prompt,draftAttachments:rt.attachments,onDraftChange:Ke,canInterrupt:!!c.thread.activeTurnId,onInterrupt:rs,onCompact:Xt,onOpenForkTurns:vt,onForkLatest:jt,onForkTurn:Pn,onOpenSkills:qs,onOpenMcp:In,onOpenHooks:En,onCreateHook:Rn,onUpdateHook:Ve,onTrustHook:Cs,onUntrustHook:zs,goalState:Ce,onOpenGoal:Bs,onUpdateGoal:Fs,...Ot?{onReadProviderConfig:()=>Ur(c.thread.provider,Ot),onWriteProviderConfig:l=>Or(c.thread.provider,Ot,{content:l})}:{},onToggleFollow:()=>yt(l=>l+1),onUpdateSettings:os,onToggleView:is,onShellCopy:qt,onShellControl:ds,compactBusy:xt,skillsState:ys,mcpState:pt,hooksState:ze,forkTurnOptionsState:Ht}:null,Ca=c?{busy:j,settingsBusy:!1,error:c.thread.isLoaded?(V==null?void 0:V.error)??null:null,followTail:!1,capabilities:H,toolboxItems:(C==null?void 0:C.toolboxItems)??[],hookCommandTemplates:(C==null?void 0:C.hookCommandTemplates)??[],mcpConfigFormat:(C==null?void 0:C.mcpConfigFormat)??"none",threadConnected:c.thread.isLoaded,shellAvailable:ve,shellControlState:V,canInterrupt:!!(c.thread.isLoaded&&(V!=null&&V.isCommandRunning)),onInterrupt:rs,onToggleView:is,onShellCopy:qt,onShellControl:ds}:null,Ta=r.useCallback(l=>c?Ge({threadId:c.thread.id,path:l}):"",[c==null?void 0:c.thread.id,Ge]),Ia=r.useMemo(()=>{const l=(c==null?void 0:c.workspace.id)??null;return l?{listTree:()=>Tl(l),readFile:i=>Il(l,{path:i.path,...i.offset!==void 0?{offset:i.offset}:{},...i.limit!==void 0?{limit:i.limit}:{}}),getRawFileUrl:i=>El(l,{path:i.path}),uploadFile:i=>Pl(l,{file:i.file}),downloadNode:async i=>{if(i.kind!=="file")return;const f=await Rl(l,{path:i.path}),P=URL.createObjectURL(f.blob),O=document.createElement("a");O.href=P,O.download=f.filename,document.body.append(O),O.click(),O.remove(),URL.revokeObjectURL(P)}}:null},[c==null?void 0:c.workspace.id]),ro=r.useMemo(()=>({openThread:Ae,getThreadHref:ht,getNewThreadHref:wt,renameThread:Zs,deleteThread:Bt,sendPrompt:Ks,interrupt:rs,compact:Xt,updateSettings:os,loadHistoryItemDetail:Ys,getImageAssetUrl:Ta,workspace:Ia,shell:Pe}),[Ta,wt,ht,Xt,rs,Ys,Ks,Zs,os,Pe,Ae,Ia]),oo=c!=null&&c.thread.workspaceId?`/threads?workspaceId=${encodeURIComponent(c.thread.workspaceId)}`:"/workspaces",lo=e.jsxs(e.Fragment,{children:[e.jsx(xo,{open:Ns,busy:Ut,turnsState:Ct,onCancel:()=>{Ut||At(!1)},onLoadTurns:as,onExport:_s}),e.jsx(wn,{open:bt!==null,title:"Delete Thread",description:bt?`Delete ${Po(bt.title)} from supervisor. The backend session id will no longer appear in this workspace list.`:"",confirmLabel:"Delete Thread",busy:Ss,onCancel:()=>{Ss||Bt(null)},onConfirm:()=>void Xs()})]});return e.jsx(hr,{threads:ae,detail:c,status:ge,loading:qe,error:qe?null:Ds,plugins:n,adapter:ro,metaContent:sn,settingsContent:nn,globalSettingsContent:e.jsx(xa,{embedded:!0}),mobileHeaderAction:so,workspaceReturnHref:oo,onCloseAppNavigation:(a==null?void 0:a.closeNav)??(()=>{}),surfaceActions:no,floatingPanel:to,workspaceFeatures:Yd,activeView:R,liveOutput:oe,timelineProps:ao,timelineComponent:bo,useFloatingMobileComposer:Is,floatingMobileComposerBottomOffset:Qs,composerHostRef:T,shellPanelRef:k,shellPanelComponent:go,shellEffectiveTheme:(a==null?void 0:a.effectiveTheme)??"dark",shellThemeMode:(a==null?void 0:a.themeMode)??"system",...a!=null&&a.setThemeMode?{onShellThemeModeChange:a.setThemeMode}:{},onShellStateChange:Xe,loadingContent:e.jsx("div",{className:"host-muted flex flex-1 items-center justify-center px-6 py-12 text-center",children:"Loading thread detail..."}),emptyContent:e.jsx("div",{className:"host-muted flex flex-1 items-center justify-center px-6 py-12 text-center",children:"Unable to resolve this thread."}),dialogs:lo,...ka?{composerProps:ka}:{},...Ca?{shellComposerProps:Ca}:{}})}function tc(){const t=nt(),[s,a]=r.useState(""),[n,d]=r.useState(Tt),[o,m]=r.useState([]),[h,g]=r.useState(!0),[b,E]=r.useState(!1),[x,p]=r.useState(null);r.useEffect(()=>{let A=!1;return g(!0),pa().then(v=>{var Z,q;if(A)return;m(v);const D=((Z=v.find(_=>_.isDefault&&_.enabled))==null?void 0:Z.provider)??((q=v.find(_=>_.enabled))==null?void 0:q.provider)??Tt;d(D)}).catch(()=>{A||m([])}).finally(()=>{A||g(!1)}),()=>{A=!0}},[]);const k=r.useMemo(()=>o.length>0?o:[{provider:Tt,displayName:Pa[Tt].displayName,enabled:!0}],[o]);async function T(A){A.preventDefault();const v=s.trim();if(!v){p("Session ID is required.");return}E(!0),p(null);try{const D=await Fl({sessionId:v,provider:n});t(`/threads/${D.thread.id}`)}catch(D){D instanceof re?p(D.payload.message):p(D instanceof Error?D.message:"Unable to import session.")}finally{E(!1)}}return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"host-page-eyebrow text-xs uppercase tracking-[0.3em]",children:"Import Session"}),e.jsx("h2",{className:"host-page-title mt-2 text-3xl font-semibold",children:"Bring in a local backend session"}),e.jsx("p",{className:"host-page-description mt-3 max-w-3xl text-sm leading-6",children:"Select the backend and paste a session ID from this machine. Supervisor will recover the workspace path, reuse an existing workspace when possible, or create one with the last folder name as the default label."}),e.jsx("p",{className:"host-muted mt-2 max-w-3xl text-sm leading-6",children:"Imported history appears immediately, but sending a new prompt still requires a manual Resume / Connect."})]}),e.jsxs("form",{onSubmit:T,className:"host-panel space-y-5 rounded-3xl border p-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"backend-provider",className:"host-form-label text-sm font-medium",children:"Backend"}),e.jsx("select",{id:"backend-provider",value:n,onChange:A=>d(A.target.value),disabled:b||h,className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition",children:k.map(A=>e.jsxs("option",{value:A.provider,children:[A.displayName||Pa[A.provider].displayName,A.enabled?"":" (not ready)"]},A.provider))})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"session-id",className:"host-form-label text-sm font-medium",children:"Session ID"}),e.jsx("input",{id:"session-id",value:s,onChange:A=>a(A.target.value),placeholder:"019d6fb7-7033-7a30-a2c7-74d0919e87d4",className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition"})]}),x&&e.jsx("div",{className:"host-error rounded-2xl border px-4 py-3 text-sm",children:x}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx("button",{type:"submit",disabled:b,className:"ui-action-primary rounded-full px-5 py-3 font-medium transition disabled:cursor-not-allowed",children:b?"Importing...":"Import Session"})})]})]})}function yn(t){return t.enabled&&t.capabilities.sessions.resume&&t.capabilities.turns.start}function sc(t,s){var n;const a=t.find(d=>d.provider===s);return a&&yn(a)?a.provider:((n=t.find(yn))==null?void 0:n.provider)??Tt}function nc(){const t=nt(),s=Jt(),[a]=ur(),[n,d]=r.useState([]),[o,m]=r.useState([]),[h,g]=r.useState([]),[b,E]=r.useState((s==null?void 0:s.defaultBackend)??Tt),[x,p]=r.useState(""),[k,T]=r.useState(""),A=a.get("title"),[v,D]=r.useState(()=>A??""),[Z,q]=r.useState("yolo"),[_,ne]=r.useState(!0),[c,F]=r.useState(!1),[ae,I]=r.useState(null),z=a.get("workspaceId"),B=(s==null?void 0:s.defaultBackend)??Tt;r.useEffect(()=>{let H=!1;return Promise.all([fa(),pa()]).then(async([me,C])=>{var K,W,be;if(H)return;const le=sc(C,B);E(le),m(C);const oe=await oa(le);if(H)return;d(me),g(oe);const $=me.some(fe=>fe.id===z)?z:((K=me[0])==null?void 0:K.id)??"";p($),T(((W=oe.find(fe=>fe.isDefault))==null?void 0:W.model)??((be=oe[0])==null?void 0:be.model)??"")}).catch(me=>{H||I(me instanceof Error?me.message:"Unable to load creation form data.")}).finally(()=>{H||ne(!1)}),()=>{H=!0}},[B,z]),r.useEffect(()=>{if(!b)return;let H=!1;return g([]),T(""),I(null),oa(b).then(me=>{var C,le;H||(g(me),T(((C=me.find(oe=>oe.isDefault))==null?void 0:C.model)??((le=me[0])==null?void 0:le.model)??""))}).catch(me=>{H||(g([]),T(""),I(me instanceof Error?me.message:"Unable to load backend models."))}),()=>{H=!0}},[b]);function ge(){if(window.history.length>1){t(-1);return}if(z){t(`/threads?workspaceId=${encodeURIComponent(z)}`);return}t("/workspaces")}async function pe(H){H.preventDefault(),F(!0),I(null);try{const me=await Bl(v.trim()?{workspaceId:x,provider:b,model:k,approvalMode:Z,title:v.trim()}:{workspaceId:x,provider:b,model:k,approvalMode:Z});t(`/threads/${me.id}`)}catch(me){me instanceof re?I(me.payload.message):I(me instanceof Error?me.message:"Unable to create thread.")}finally{F(!1)}}return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"host-page-eyebrow text-xs uppercase tracking-[0.3em]",children:"New Thread"}),e.jsx("h2",{className:"host-page-title mt-2 text-3xl font-semibold",children:"Start a backend session"}),e.jsx("p",{className:"host-page-description mt-3 max-w-2xl text-sm leading-6",children:"Choose the workspace, model, and approval mode that should back the new thread."})]}),_?e.jsx("div",{className:"host-empty-state rounded-3xl border px-6 py-12 text-center",children:"Loading creation form..."}):e.jsxs("form",{onSubmit:pe,className:"host-panel space-y-5 rounded-3xl border p-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"host-form-label text-sm font-medium",htmlFor:"thread-backend",children:"Backend"}),e.jsx("select",{id:"thread-backend",value:b,onChange:H=>{const me=H.target.value;E(me)},className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition",children:o.map(H=>e.jsxs("option",{value:H.provider,disabled:!yn(H),children:[H.displayName,yn(H)?"":" (not available)"]},H.provider))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"host-form-label text-sm font-medium",htmlFor:"thread-workspace",children:"Workspace"}),e.jsx("select",{id:"thread-workspace",value:x,onChange:H=>p(H.target.value),className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition",children:n.map(H=>e.jsxs("option",{value:H.id,children:[H.label," · ",H.absPath]},H.id))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"host-form-label text-sm font-medium",htmlFor:"thread-model",children:"Model"}),e.jsxs("select",{id:"thread-model",value:k,onChange:H=>T(H.target.value),disabled:h.length===0,className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition",children:[h.length===0?e.jsx("option",{value:"",children:"No models available"}):null,h.map(H=>e.jsxs("option",{value:H.model,children:[H.displayName," · ",H.model]},H.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"host-form-label text-sm font-medium",htmlFor:"thread-title",children:"Title"}),e.jsx("input",{id:"thread-title",value:v,onChange:H=>D(H.target.value),placeholder:"Optional. Falls back to first prompt.",className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"host-form-label text-sm font-medium",htmlFor:"thread-approval-mode",children:"Approval mode"}),e.jsxs("select",{id:"thread-approval-mode",value:Z,onChange:H=>q(H.target.value),className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition",children:[e.jsx("option",{value:"yolo",children:"yolo"}),e.jsx("option",{value:"guarded",children:"guarded"})]})]}),ae&&e.jsx("div",{className:"host-error rounded-2xl border px-4 py-3 text-sm",children:ae}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"submit",disabled:c||!x||!k,className:"ui-action-primary rounded-full px-5 py-3 font-medium transition disabled:cursor-not-allowed",children:c?"Creating...":"Create Thread"}),e.jsx("button",{type:"button",onClick:ge,disabled:c,className:"host-secondary-button rounded-full border px-5 py-3 font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"})]})]})]})}function ac(t){return t?`/threads/new?workspaceId=${encodeURIComponent(t)}`:"/threads/new"}function rc({getThreadHref:t,onOpenThread:s,getNewThreadHref:a,renderThreadLink:n,onCloseAppNavigation:d,...o}){const m=nt(),h=Jt(),g=d??(h==null?void 0:h.closeNav),b=o.effectiveTheme??(h==null?void 0:h.effectiveTheme),E=o.themeMode??(h==null?void 0:h.themeMode),x=o.onThemeModeChange??(h==null?void 0:h.setThemeMode);return e.jsx(vo,{...o,workspaceReturnHref:o.workspaceReturnHref??"/workspaces",globalSettingsContent:o.globalSettingsContent??e.jsx(xa,{embedded:!0}),...b?{effectiveTheme:b}:{},...E?{themeMode:E}:{},...x?{onThemeModeChange:x}:{},getThreadHref:t??(p=>`/threads/${p}`),onOpenThread:s??(p=>m(`/threads/${p}`)),getNewThreadHref:a??ac,renderThreadLink:n??(({thread:p,children:k,className:T,onClick:A})=>e.jsx(It,{to:`/threads/${p.id}`,className:T,onClick:A,children:k})),...g?{onCloseAppNavigation:g}:{}})}function Gr({open:t,title:s,label:a,value:n,busy:d=!1,onChange:o,onCancel:m,onSubmit:h}){if(r.useEffect(()=>{if(!t)return;function b(E){E.key==="Escape"&&!d&&m()}return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b)}},[d,m,t]),!t)return null;function g(b){b.preventDefault(),h()}return io.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[e.jsx("button",{type:"button","aria-label":"Close rename dialog",onClick:m,disabled:d,className:"ui-overlay-scrim absolute inset-0 backdrop-blur-sm disabled:cursor-not-allowed"}),e.jsxs("form",{role:"dialog","aria-modal":"true","aria-label":s,onSubmit:g,className:"host-dialog relative z-[1] w-full max-w-md rounded-[1.6rem] border p-5 shadow-2xl shadow-black/20 sm:p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"host-page-title text-sm font-medium",children:s}),e.jsx("p",{className:"host-muted mt-1 text-sm",children:"Changes are saved only after confirmation."})]}),e.jsx("button",{type:"button","aria-label":"Close dialog",onClick:m,disabled:d,className:"host-icon-button inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border transition disabled:cursor-not-allowed disabled:opacity-60",children:e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:e.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),e.jsxs("div",{className:"mt-5",children:[e.jsx("label",{htmlFor:"rename-dialog-input",className:"host-form-label text-sm font-medium",children:a}),e.jsx("input",{id:"rename-dialog-input","aria-label":a,autoFocus:!0,value:n,onChange:b=>o(b.target.value),className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition"})]}),e.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:m,disabled:d,className:"host-secondary-button rounded-full border px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:d||!n.trim(),className:"ui-action-success rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:"Save"})]})]})]}),document.body)}function oc(){const[t]=ur(),s=nt(),a=Jt(),n=t.get("workspaceId"),[d,o]=r.useState([]),[m,h]=r.useState([]),[g,b]=r.useState(null),[E,x]=r.useState(!0),[p,k]=r.useState(null),[T,A]=r.useState(null),[v,D]=r.useState(""),[Z,q]=r.useState(null),[_,ne]=r.useState(null),[c,F]=r.useState(!1),ae=(a==null?void 0:a.defaultBackend)??Tt,I=r.useCallback(async()=>{x(!0),k(null);try{const[$,K,W]=await Promise.all([Ar(ae).then(be=>be.status),$r(),fa()]);b($),o(K),h(W)}catch($){k($ instanceof Error?$.message:"Unable to load threads.")}finally{x(!1)}},[ae]);r.useEffect(()=>{if(n===null)return;I();const $=Dr(K=>{o(W=>W.map(be=>be.id===K.threadId?{...be,status:K.type==="thread.updated"&&typeof K.payload.status=="string"?K.payload.status:be.status,lastError:(K.type==="thread.turn.failed"||K.type==="thread.turn.completed")&&typeof K.payload.error=="string"?K.payload.error:be.lastError,title:K.type==="thread.updated"&&typeof K.payload.title=="string"?K.payload.title:be.title}:be))});return()=>{$.close()}},[I,n]);const z=Object.fromEntries(m.map($=>[$.id,$.label])),B=m.find($=>$.id===n)??null,ge=r.useMemo(()=>n?d.filter($=>$.workspaceId===n):[],[n,d]),pe=ge.filter($=>$.status==="running").length,H=n?`/threads/new?workspaceId=${encodeURIComponent(n)}`:"/threads/new";if(n===null)return e.jsx(Os,{to:"/workspaces",replace:!0});function me(){switch(g==null?void 0:g.state){case"ready":return"bg-emerald-400 shadow-[0_0_0_3px_rgba(52,211,153,0.14)]";case"starting":return"bg-amber-300 shadow-[0_0_0_3px_rgba(252,211,77,0.12)]";case"degraded":case"failed":return"bg-rose-400 shadow-[0_0_0_3px_rgba(251,113,133,0.14)]";default:return"bg-stone-500 shadow-[0_0_0_3px_rgba(120,113,108,0.14)]"}}async function C($,K){try{const W=await Mr($,{title:K});o(be=>be.map(fe=>fe.id===W.id?{...fe,title:W.title,updatedAt:W.updatedAt}:fe))}catch(W){throw k(W instanceof Error?W.message:"Unable to rename thread."),W}}async function le(){if(!T)return;const $=v.trim();if($){q(T);try{await C(T,$),A(null),D("")}finally{q(null)}}}async function oe(){if(_){F(!0);try{await Lr(_.id),o($=>$.filter(K=>K.id!==_.id)),ne(null)}catch($){k($ instanceof Error?$.message:"Unable to delete thread.")}finally{F(!1)}}}return e.jsx(rc,{threads:d,workspaceLabels:z,status:g,loading:E,error:p,viewportConstrained:n!==null,showMobileAppMenu:!0,showMobileThreadNavToggle:!1,showMobileNewThreadShortcut:!1,currentWorkspaceId:n,currentWorkspaceLabel:(B==null?void 0:B.label)??null,onRenameThread:C,onDeleteThread:ne,children:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"host-panel flex min-h-0 flex-1 flex-col overflow-hidden rounded-[2rem] border shadow-2xl shadow-black/10",children:[e.jsx("div",{className:"border-b border-[var(--theme-border)] px-4 py-3 sm:px-6 sm:py-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h2",{className:"host-page-title min-w-0 truncate text-base font-semibold sm:text-lg",title:B?`${B.label} threads`:"All threads",children:B?B.label:"All Threads"}),e.jsx(It,{to:H,className:"ui-action-primary inline-flex h-9 shrink-0 items-center rounded-full px-3.5 text-xs font-medium uppercase tracking-[0.18em] transition",children:"New Thread"})]})}),e.jsx("div",{className:"px-4 py-3 sm:px-6 sm:py-4",children:e.jsxs("article",{className:"host-surface-strong inline-flex min-w-[12rem] max-w-full items-center gap-3 rounded-[1.25rem] border px-3.5 py-2.5",children:[e.jsx("span",{"aria-hidden":"true",className:`h-2.5 w-2.5 shrink-0 rounded-full ${me()}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"host-muted truncate text-[11px] uppercase tracking-[0.22em]",children:"Supervisor"}),e.jsx("p",{className:"host-soft truncate text-sm",children:(g==null?void 0:g.lastError)??((g==null?void 0:g.state)==="ready"?"Ready":(g==null?void 0:g.state)??"Checking")})]})]})}),!E&&!p&&ge.length>0&&e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col border-t border-[var(--theme-border)] px-4 py-4 sm:px-6 sm:py-5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"host-muted text-xs uppercase tracking-[0.28em]",children:"Recent Threads"}),e.jsxs("span",{className:"host-warning-pill rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase tracking-[0.18em]",children:[ge.length," total"]}),pe>0&&e.jsxs("span",{className:"host-muted text-xs",children:["· ",pe," running"]})]}),e.jsx("div",{className:"mt-3 min-h-0 flex-1",children:e.jsx(jo,{threads:ge,currentWorkspaceId:n,workspaceLabels:z,onOpenThread:$=>s(`/threads/${$}`),onBeginRenameThread:$=>{A($.id),D($.title)},onDeleteThread:$=>ne($),scrollable:!0,maxHeightClassName:"max-h-full",showDeleteButton:!0,showSessionCopyButton:!0})})]}),!E&&!p&&ge.length===0&&e.jsx("div",{className:"host-muted border-t border-[var(--theme-border)] px-4 py-6 text-sm sm:px-6",children:"No threads available in this workspace."})]}),e.jsx(Gr,{open:T!==null,title:"Rename Thread",label:"Thread Title",value:v,busy:Z!==null,onChange:D,onCancel:()=>{A(null),D("")},onSubmit:()=>void le()}),e.jsx(wn,{open:_!==null,title:"Delete Thread",description:_?`Delete ${Io(_.title)} from supervisor. The backend session id will no longer appear in this workspace list.`:"",confirmLabel:"Delete Thread",busy:c,onCancel:()=>{c||ne(null)},onConfirm:()=>void oe()})]})})}function ir(t){const s=t.trim(),a=s.replace(/[\\/]+$/,"");if(!a)return"";if(Kr(s)){const d=(a.split(/[?#]/)[0]??a).split(/[/:]/).filter(Boolean).at(-1)??"";return d.endsWith(".git")?d.slice(0,-4):d}return a.split(/[\\/]/).filter(Boolean).at(-1)??""}function Kr(t){const s=t.trim();return/^https?:\/\/.+/i.test(s)||/^ssh:\/\/.+/i.test(s)||/^git@[^:]+:.+/.test(s)}function lc({initialPath:t="",initialLabel:s="",submitLabel:a="Save Workspace",error:n,busy:d=!1,onSubmit:o}){const m=ir(t),[h,g]=r.useState(t),[b,E]=r.useState(s||m),[x,p]=r.useState(null),k=r.useRef(m);r.useEffect(()=>{const A=ir(h);E(v=>!v.trim()||v===k.current?A:v),k.current=A},[h]);async function T(A){A.preventDefault();const v=h.trim();if(!v){p("Workspace path or Git URL is required.");return}p(null);const D=b.trim(),Z=Kr(v)?"gitUrl":"absPath";await o(D?{[Z]:v,label:D}:{[Z]:v})}return e.jsxs("form",{onSubmit:T,className:"host-panel space-y-5 rounded-3xl border p-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"workspace-path",className:"host-form-label text-sm font-medium",children:"Path or Git URL"}),e.jsx("input",{id:"workspace-path",name:"absPath",value:h,onChange:A=>g(A.target.value),placeholder:"/Users/name/project or https://github.com/owner/repo.git",className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition"}),e.jsx("p",{className:"host-muted mt-2 text-xs",children:"Absolute paths register local directories. Git URLs clone into the configured dev home."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"workspace-label",className:"host-form-label text-sm font-medium",children:"Display label"}),e.jsx("input",{id:"workspace-label",name:"label",value:b,onChange:A=>E(A.target.value),placeholder:"Optional override",className:"host-form-control mt-2 w-full rounded-2xl border px-4 py-3 outline-none transition"}),e.jsx("p",{className:"host-muted mt-2 text-xs",children:"Defaults to the last folder name. You can override it."})]}),(x||n)&&e.jsx("div",{className:"host-error rounded-2xl border px-4 py-3 text-sm",children:x??n}),e.jsx("button",{type:"submit",disabled:d,className:"ui-action-primary rounded-full px-5 py-3 font-medium transition disabled:cursor-not-allowed",children:d?"Saving...":a})]})}function ic(){const t=nt(),[s,a]=r.useState(null),[n,d]=r.useState(!1);async function o(m){d(!0),a(null);try{const h=await ii(m);t(`/threads?workspaceId=${encodeURIComponent(h.id)}`)}catch(h){h instanceof re?a(h.payload.message):a(h instanceof Error?h.message:"Unable to create workspace.")}finally{d(!1)}}return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"host-page-eyebrow text-xs uppercase tracking-[0.3em]",children:"Add Workspace"}),e.jsx("h2",{className:"host-page-title mt-2 text-3xl font-semibold",children:"Create a workspace"}),e.jsx("p",{className:"host-page-description mt-3 max-w-2xl text-sm leading-6",children:"Register an existing local directory, create one missing child directory under dev home, or clone a Git repository into dev home."})]}),e.jsx(lc,{busy:n,error:s,submitLabel:"Create Workspace",onSubmit:o})]})}function dr(t){return Date.parse(t.lastOpenedAt??t.createdAt)}function dc(t,s){return t.isFavorite!==s.isFavorite?t.isFavorite?-1:1:dr(s)-dr(t)}function cc(t){return t?new Date(t).toLocaleString():"Never opened"}function uc(t,s=28){return t.length<=s?t:`...${t.slice(-(s-3))}`}function mc({active:t}){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:`h-3.5 w-3.5 fill-current ${t?"rotate-[18deg]":"rotate-[8deg]"}`,children:e.jsx("path",{d:"M10.7 1.75c.34 0 .62.28.62.63v1.24l1.43 1.42c.24.24.24.62 0 .86l-1.1 1.1v2.02c0 .17-.07.33-.19.45l-1.5 1.5v2.28c0 .28-.18.53-.44.6a.62.62 0 0 1-.69-.24L7.2 12.4l-2.83 2.83a.625.625 0 1 1-.88-.88l2.83-2.83-2.2-1.62a.62.62 0 0 1-.24-.69c.08-.26.32-.44.6-.44h2.28l1.5-1.5a.64.64 0 0 1 .45-.18h2.02l1.1-1.11-1.42-1.42H9.07a.63.63 0 0 1-.62-.63c0-.34.28-.62.62-.62h1.63Z"})})}function hc(){return e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-current",children:e.jsx("path",{d:"M6.1 1.75h3.8c.75 0 1.4.52 1.57 1.25h2.03c.35 0 .63.28.63.63 0 .34-.28.62-.63.62h-.66l-.62 8.03c-.08 1.09-.99 1.97-2.08 1.97H5.86c-1.09 0-2-.88-2.08-1.97l-.62-8.03H2.5a.62.62 0 1 1 0-1.25h2.03c.17-.73.82-1.25 1.57-1.25Zm0 1.25c-.07 0-.14.03-.19.08A.26.26 0 0 0 5.84 3h4.32a.26.26 0 0 0-.07-.17.26.26 0 0 0-.19-.08H6.1Zm-1.07 1.25.61 7.93c.03.44.4.79.84.79h3.04c.44 0 .81-.35.84-.79l.61-7.93H5.03Zm1.53 1.32c.35 0 .62.28.62.62v4.19a.62.62 0 1 1-1.24 0V6.19c0-.34.28-.62.62-.62Zm2.82 0c.34 0 .62.28.62.62v4.19a.62.62 0 1 1-1.24 0V6.19c0-.34.28-.62.62-.62Z"})})}function pc(){const t=nt(),[s,a]=r.useState([]),[n,d]=r.useState(!0),[o,m]=r.useState(null),[h,g]=r.useState(null),[b,E]=r.useState(null),[x,p]=r.useState(null),[k,T]=r.useState(""),[A,v]=r.useState(null),[D,Z]=r.useState(null),[q,_]=r.useState(null),[ne,c]=r.useState(!1);async function F(){d(!0),E(null);try{a(await fa())}catch(C){E(C instanceof Error?C.message:"Unable to load workspaces.")}finally{d(!1)}}r.useEffect(()=>{F(),rl().then(C=>{m(C),g(null)}).catch(C=>{g(C instanceof Error?C.message:"Unable to load supervisor config.")})},[]);async function ae(C){const le={...C,isFavorite:!C.isFavorite};a(oe=>oe.map($=>$.id===C.id?le:$));try{const oe=await ui(C.id,{isFavorite:!C.isFavorite});a($=>$.map(K=>K.id===oe.id?oe:K))}catch(oe){a($=>$.map(K=>K.id===C.id?C:K)),E(oe instanceof Error?oe.message:"Unable to update workspace.")}}async function I(C){const le=k.trim();if(le){v(C);try{const oe=await di(C,{label:le});a($=>$.map(K=>K.id===oe.id?oe:K)),p(null),T("")}catch(oe){E(oe instanceof Error?oe.message:"Unable to rename workspace.")}finally{v(null)}}}function z(C){p(C.id),T(C.label)}function B(){p(null),T("")}function ge(C){t(`/threads?workspaceId=${encodeURIComponent(C)}`)}async function pe(){if(q){c(!0);try{await ci(q.id),a(C=>C.filter(le=>le.id!==q.id)),_(null)}catch(C){E(C instanceof Error?C.message:"Unable to delete workspace.")}finally{c(!1)}}}function H(C,le){(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),ge(le))}const me=r.useMemo(()=>[...s].sort(dc),[s]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"host-topbar sticky top-[env(safe-area-inset-top)] z-20 -mx-4 border-b px-2.5 py-2 backdrop-blur sm:mx-0 sm:rounded-[1.4rem] sm:border sm:px-4",children:e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 sm:gap-2",children:[e.jsx(Br,{}),e.jsx(It,{to:"/threads/import",className:"host-info-pill inline-flex h-8 shrink-0 items-center rounded-full border px-2.5 text-[11px] font-medium uppercase tracking-[0.14em] transition sm:px-3 sm:text-xs sm:tracking-[0.18em]",children:"Import"}),e.jsx(It,{to:"/workspaces/new",className:"ui-action-primary inline-flex h-8 shrink-0 items-center rounded-full px-2.5 text-[11px] font-medium uppercase tracking-[0.14em] transition sm:px-3 sm:text-xs sm:tracking-[0.18em]",children:"Create"}),e.jsx("div",{className:"min-w-0 flex-1 text-right",children:e.jsx("p",{className:"host-page-eyebrow truncate text-[11px] uppercase tracking-[0.24em]",children:"Workspaces"})})]}),e.jsx(Fr,{className:"absolute left-0 top-[calc(100%+0.5rem)] z-30 w-[min(22rem,calc(100vw-1rem))]"})]})}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-[minmax(0,1fr)_20rem]",children:[e.jsxs("section",{className:"min-w-0 space-y-4",children:[n&&e.jsx("div",{className:"host-empty-state rounded-[1.6rem] border px-6 py-12 text-center",children:"Loading workspace registry..."}),b&&e.jsx("div",{className:"host-error rounded-[1.4rem] border px-4 py-4",children:b}),!n&&!b&&s.length===0&&e.jsxs("div",{className:"host-empty-state rounded-[1.6rem] border border-dashed px-6 py-12 text-center",children:[e.jsx("p",{className:"host-page-title text-lg font-medium",children:"No workspaces yet"}),e.jsx("p",{className:"host-muted mt-2 text-sm",children:"Add a local directory inside the configured workspace root to start building the registry."})]}),!n&&me.length>0&&e.jsx("div",{className:"space-y-2 overflow-x-hidden",children:me.map(C=>e.jsxs("article",{role:"link",tabIndex:0,onClick:()=>ge(C.id),onKeyDown:le=>H(le,C.id),className:"host-card relative overflow-hidden rounded-[1.35rem] border px-4 py-3 transition",children:[e.jsxs("div",{className:"absolute right-2.5 top-2.5 flex items-center gap-1.5",children:[e.jsx("button",{type:"button","aria-label":`Delete workspace ${C.label}`,title:"Delete workspace",onClick:le=>{le.stopPropagation(),_(C)},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-border)]",children:e.jsx(hc,{})}),e.jsx("button",{type:"button","aria-label":C.isFavorite?`Unpin workspace ${C.label}`:`Pin workspace ${C.label}`,title:C.isFavorite?"Unpin workspace":"Pin workspace",onClick:le=>{le.stopPropagation(),ae(C)},className:`inline-flex h-7 w-7 items-center justify-center rounded-full border transition ${C.isFavorite?"host-warning-pill":"host-icon-button"}`,children:e.jsx(mc,{active:C.isFavorite})})]}),e.jsx("div",{className:"flex min-w-0 items-start gap-3 pr-[4.6rem]",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx("p",{className:"host-page-title min-w-0 max-w-full truncate text-base font-semibold sm:text-lg",title:C.label,children:C.label}),e.jsx("button",{type:"button",onClick:le=>{le.stopPropagation(),z(C)},"aria-label":`Rename workspace ${C.label}`,className:"host-muted inline-flex h-4 w-4 shrink-0 items-center justify-center transition hover:text-[var(--theme-fg)]",children:e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3 w-3 fill-current",children:e.jsx("path",{d:"m11.9 1.6 2.5 2.5-8.2 8.2-3.3.7.7-3.3 8.3-8.1Zm-7.3 8.7-.3 1.3 1.3-.3 6.9-6.9-1-1-6.9 6.9Zm8.8-7.8-1-1-1 1 1 1 1-1Z"})})})]}),e.jsx("button",{type:"button","aria-label":C.absPath,title:C.absPath,onClick:le=>{le.stopPropagation(),Z(C.absPath)},className:"host-muted mt-1 inline-block max-w-full overflow-hidden whitespace-nowrap text-left text-[9px] leading-4 transition hover:text-[var(--theme-fg-soft)]",children:uc(C.absPath)}),e.jsx("div",{className:"host-muted mt-2 flex flex-wrap items-center gap-2 text-xs",children:e.jsxs("span",{className:"min-w-0 truncate",children:["Last opened: ",cc(C.lastOpenedAt)]})})]})})]},C.id))})]}),e.jsx(fc,{config:o,error:h,workspaceCount:s.length})]}),e.jsx(Gr,{open:x!==null,title:"Rename Workspace",label:"Workspace Label",value:k,busy:A!==null,onChange:T,onCancel:B,onSubmit:()=>x?I(x):void 0}),e.jsx(yo,{open:D!==null,title:"Workspace Path",text:D??"",onClose:()=>Z(null)}),e.jsx(wn,{open:q!==null,title:"Delete Workspace",description:q?`Delete ${q.label} from supervisor. This also removes its threads and local supervisor metadata.`:"",confirmLabel:"Delete Workspace",busy:ne,onCancel:()=>{ne||_(null)},onConfirm:()=>void pe()})]})}function fc({config:t,error:s,workspaceCount:a}){return e.jsxs("aside",{className:"space-y-3 xl:sticky xl:top-[calc(env(safe-area-inset-top)+4.25rem)] xl:self-start",children:[e.jsxs("section",{className:"rounded-[1.2rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-[var(--theme-fg-muted)]",children:"Supervisor"}),e.jsxs("dl",{className:"mt-4 space-y-3",children:[e.jsx(pn,{label:"Workspace root",value:(t==null?void 0:t.workspaceRoot)??"Loading..."}),e.jsx(pn,{label:"Environment",value:t?`${t.environment} · ${t.host}:${t.port}`:s??"Loading..."}),e.jsx(pn,{label:"Version",value:t?`${t.appName} ${t.appVersion}`:"Loading..."}),e.jsx(pn,{label:"Workspaces",value:String(a)})]})]}),s?e.jsx("section",{className:"rounded-[1.2rem] border border-[var(--status-warning-border)] bg-[var(--status-warning-bg)] p-4 text-sm text-[var(--status-warning-fg)]",children:"Runtime metadata is unavailable. Workspace actions may still work if a relay device is connected."}):null]})}function pn({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-[11px] font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:t}),e.jsx("dd",{className:"mt-1 break-words font-mono text-xs leading-5 text-[var(--theme-fg)]",children:s})]})}const Yr="remote-codex-theme-mode",Zr="remote-codex-default-backend";function Xr(){return!1}function xc(){return Xr()?e.jsx(Os,{to:"/control-plane",replace:!0}):e.jsx(Os,{to:"/workspaces",replace:!0})}function gc({children:t}){const s=es(),a=s.pathname.startsWith("/control-plane")||s.pathname==="/"&&Xr(),n=r.useMemo(()=>a?{}:{fetchPlugins:Ul,importPlugin:Ol,updatePlugin:$l,deletePlugin:Ml},[a]);return e.jsx(wo,{adapter:n,children:t})}function bc(){if(typeof window>"u")return"system";const t=window.localStorage.getItem(Yr);return t==="light"||t==="dark"||t==="system"?t:"system"}function vc(){if(typeof window>"u")return Tt;const t=window.localStorage.getItem(Zr);return Co(t)??Tt}function jc(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function yc({themeMode:t,setThemeMode:s,effectiveTheme:a}){const[n,d]=r.useState(!1),[o,m]=r.useState(!1),[h,g]=r.useState(vc),b=es(),E=/^\/threads\/[^/]+$/.test(b.pathname),x=/^\/control-plane\/sessions\/[^/]+$/.test(b.pathname),p=b.pathname==="/threads",k=E||x||p,T=p||E||x,A=E||x,v=b.pathname==="/workspaces",D=b.pathname.startsWith("/control-plane"),Z=v||p||D;r.useEffect(()=>{d(!1)},[b.pathname,b.search]);function q(ne){g(ne),window.localStorage.setItem(Zr,ne)}const _={navOpen:n,openNav:()=>d(!0),toggleNav:()=>d(ne=>!ne),closeNav:()=>d(!1),settingsOpen:o,openSettings:()=>{d(!1),m(!0)},closeSettings:()=>m(!1),themeMode:t,setThemeMode:s,effectiveTheme:a,defaultBackend:h,setDefaultBackend:q};return e.jsxs(No.Provider,{value:_,children:[e.jsxs("div",{className:`bg-[var(--app-bg)] text-[var(--app-fg)] ${k?"fixed inset-0 overflow-hidden overscroll-none":"min-h-screen"}`,children:[e.jsx(ga,{}),!Z&&!A&&e.jsxs("div",{className:"fixed left-4 top-4 z-50",children:[e.jsx(Br,{}),e.jsx(Fr,{className:"mt-3 w-[min(22rem,calc(100vw-2rem))]"})]}),e.jsx("main",{className:`mx-auto w-full ${T?"max-w-none":"max-w-[1600px]"} ${k?"absolute inset-0 pb-0 sm:pb-4":"pb-4"} ${T?E||x?"pt-0":p?"pt-[env(safe-area-inset-top)] sm:pt-4":"pt-[calc(env(safe-area-inset-top)+4rem)] sm:pt-4":v||D?"pt-[env(safe-area-inset-top)] sm:pt-4":"pt-4"} ${k?E||x?"overflow-hidden overscroll-none px-0":"overflow-hidden overscroll-none px-0 sm:px-6":"px-4 sm:px-6"}`,children:e.jsx("section",{className:`min-w-0 ${k?E||x?"h-full min-h-0 overflow-hidden overscroll-none":"h-full overflow-hidden overscroll-none":""}`,children:e.jsx(uo,{})})})]}),e.jsx(xa,{})]})}function wc({children:t}){const[s,a]=r.useState({status:"checking"});async function n(m){try{const h=await ol();if(m!=null&&m())return;a(!h.authRequired||h.authenticated?{status:"authenticated"}:{status:"loginRequired",session:h,error:null})}catch(h){if(m!=null&&m())return;if(h instanceof re&&h.statusCode===401){a({status:"loginRequired",session:{authenticated:!1,username:null,expiresAt:null,mode:"server",authRequired:!0},error:null});return}a({status:"unavailable",error:h instanceof Error?h.message:"Unable to check supervisor access."})}}r.useEffect(()=>{let m=!1;return n(()=>m),()=>{m=!0}},[]);async function d(m){await ll(m),a({status:"authenticated"})}function o(){a({status:"checking"}),n()}return s.status==="checking"?e.jsx("main",{className:"flex min-h-screen items-center justify-center bg-[var(--app-bg)] px-4 text-sm text-[var(--theme-muted)]",children:"Checking supervisor access..."}):s.status==="unavailable"?e.jsx("main",{className:"flex min-h-screen items-center justify-center bg-[var(--app-bg)] px-4 text-[var(--app-fg)]",children:e.jsxs("section",{className:"w-full max-w-md rounded-[1.35rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] p-5 shadow-2xl shadow-[color-mix(in_oklch,var(--app-fg)_14%,transparent)] sm:p-6",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-[var(--theme-muted)]",children:"Supervisor Access"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold tracking-normal text-[var(--theme-fg)]",children:"Unable to reach supervisor"}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-muted)]",children:s.error}),e.jsx("button",{className:"mt-5 h-11 rounded-xl bg-[var(--theme-accent-solid)] px-4 text-sm font-semibold text-[var(--theme-accent-solid-fg)] transition hover:bg-[var(--theme-accent-solid-hover)] focus:outline-none focus:ring-2 focus:ring-[var(--theme-accent-border)]",onClick:o,type:"button",children:"Retry"})]})}):s.status==="loginRequired"?e.jsxs(e.Fragment,{children:[s.error&&e.jsx("div",{className:"fixed left-1/2 top-4 z-50 w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 rounded-xl border border-[var(--status-warning-border)] bg-[var(--status-warning-bg)] px-3 py-2 text-sm text-[var(--status-warning-fg)]",children:s.error}),e.jsx(Id,{onLogin:d})]}):t}function Nc({children:t}){const[s,a]=r.useState({status:"checking"});return r.useEffect(()=>{let n=!1;return $s().then(d=>{n||a(d.authenticated?{status:"authenticated",session:d}:{status:"loginRequired"})}).catch(()=>{n||a({status:"loginRequired"})}),()=>{n=!0}},[]),s.status==="checking"?e.jsx("main",{className:"flex min-h-screen items-center justify-center bg-[var(--app-bg)] px-4 text-sm text-[var(--theme-muted)]",children:"Checking relay access..."}):s.status==="loginRequired"?e.jsx(Jr,{}):t}function Sc({children:t}){return es().pathname.startsWith("/control-plane")?t:na()?e.jsx(Nc,{children:t}):e.jsx(wc,{children:t})}function kc({themeMode:t,setThemeMode:s,effectiveTheme:a}){return e.jsxs(mr,{children:[e.jsx(We,{path:"/",element:e.jsx(Os,{to:"/workspaces",replace:!0})}),e.jsxs(We,{element:e.jsx(yc,{themeMode:t,setThemeMode:s,effectiveTheme:a}),children:[e.jsx(We,{path:"/workspaces",element:e.jsx(pc,{})}),e.jsx(We,{path:"/workspaces/new",element:e.jsx(ic,{})}),e.jsx(We,{path:"/relay-account",element:e.jsx(Ed,{})}),e.jsx(We,{path:"/relay-devices",element:e.jsx(Pd,{})}),e.jsx(We,{path:"/control-plane/login",element:e.jsx(Ki,{})}),e.jsx(We,{path:"/control-plane",element:e.jsx(Xa,{children:e.jsx(zi,{})})}),e.jsx(We,{path:"/control-plane/sessions/:sessionId",element:e.jsx(Xa,{children:e.jsx(Cd,{})})}),e.jsx(We,{path:"/threads",element:e.jsx(oc,{})}),e.jsx(We,{path:"/threads/import",element:e.jsx(tc,{})}),e.jsx(We,{path:"/threads/new",element:e.jsx(nc,{})}),e.jsx(We,{path:"/threads/:id",element:e.jsx(ec,{})})]})]})}function Cc(){const[t,s]=r.useState(()=>bc()),[a,n]=r.useState(()=>jc()),d=t==="system"?a:t;return r.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),m=()=>{n(o.matches?"dark":"light")};return m(),typeof o.addEventListener=="function"?o.addEventListener("change",m):o.addListener(m),()=>{typeof o.removeEventListener=="function"?o.removeEventListener("change",m):o.removeListener(m)}},[]),r.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Yr,t)},[t]),r.useEffect(()=>{const o=document.documentElement;o.dataset.themeMode=t,o.dataset.themeEffective=d,o.style.colorScheme=d},[d,t]),e.jsx("div",{className:"theme-shell theme-scrollbar",children:e.jsx(co,{children:e.jsx(gc,{children:e.jsxs(mr,{children:[e.jsx(We,{path:"/",element:e.jsx(xc,{})}),e.jsx(We,{path:"/relay-portal",element:e.jsx(Jr,{})}),e.jsx(We,{path:"/relay-admin",element:e.jsx(Rd,{})}),e.jsx(We,{path:"/*",element:e.jsx(Sc,{children:e.jsx(kc,{themeMode:t,setThemeMode:s,effectiveTheme:d})})})]})})})})}mo.createRoot(document.getElementById("root")).render(e.jsx(ho.StrictMode,{children:e.jsx(Cc,{})}));
|